mirror of
https://github.com/outbackdingo/scratchpkg.git
synced 2026-02-05 08:28:00 +00:00
updated
This commit is contained in:
47
pkgadd
47
pkgadd
@@ -6,6 +6,12 @@ YELLOW='\e[0;33m' #Yellow
|
||||
CYAN='\e[0;36m' #Cyan
|
||||
CRESET='\e[0m' #Reset color
|
||||
|
||||
INDEX_DIR=$ROOT/var/lib/scratchpkg/index
|
||||
LOCK_FILE=$ROOT/var/lib/scratchpkg/spkg.lock
|
||||
TMP_PKGINSTALL=$ROOT/var/lib/scratchpkg/spkg.install
|
||||
HOOK_DIR=/etc/hooks
|
||||
SYSUSERS_DIR=/etc/sysusers
|
||||
|
||||
nocolor() {
|
||||
RED=
|
||||
GREEN=
|
||||
@@ -38,25 +44,24 @@ runhooks() {
|
||||
opr=install
|
||||
fi
|
||||
|
||||
if [ "$(ls $HOOK_DIR/*.hook 2>/dev/null)" ]; then
|
||||
for hook in $(ls $HOOK_DIR/*.hook); do
|
||||
description=$(cat "$hook" | grep ^"# description" | sed 's/\://' | cut -d ' ' -f 3-)
|
||||
operation=$(cat "$hook" | grep ^"# operation" | sed 's/\://' | cut -d ' ' -f 3-)
|
||||
target=$(cat "$hook" | grep ^"# target" | sed 's/\://' | cut -d ' ' -f 3-)
|
||||
if [ -n "$description" ] && [ -n "$operation" ] && [ -n "$target" ]; then
|
||||
if [ "$(echo $operation | grep -w "$opr" )" ]; then
|
||||
if [ "$(grep -E $target $INDEX_DIR/$name/.files)" ]; then
|
||||
echo -e " ${BLUE}*${CRESET} $description"
|
||||
. $hook
|
||||
if [ "`type -t exechook`" = "function" ]; then
|
||||
exechook
|
||||
fi
|
||||
for hook in $(ls $HOOK_DIR/*.hook 2>/dev/null); do
|
||||
description=$(grep "^# description[[:blank:]]*:" $hook | sed 's/^# description[[:blank:]]*:[[:blank:]]*//')
|
||||
operation=$(grep "^# operation[[:blank:]]*:" $hook | sed 's/^# operation[[:blank:]]*:[[:blank:]]*//')
|
||||
target=$(grep "^# target[[:blank:]]*:" $hook | sed 's/^# target[[:blank:]]*:[[:blank:]]*//')
|
||||
if [ -n "$description" ] && [ -n "$operation" ] && [ -n "$target" ]; then
|
||||
if [ "$(echo $operation | grep -w "$opr" )" ]; then
|
||||
if [ "$(grep -E $target $INDEX_DIR/$name/.files)" ]; then
|
||||
msg2 "$description"
|
||||
. $hook
|
||||
if [ "`type -t exechook`" = "function" ]; then
|
||||
exechook
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
unset description operation target
|
||||
done
|
||||
fi
|
||||
fi
|
||||
unset description operation target
|
||||
unset -f exechook
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
@@ -167,12 +172,6 @@ ret() {
|
||||
|
||||
parse_opts $(extract_opt $@)
|
||||
|
||||
INDEX_DIR=$ROOT/var/lib/scratchpkg/index
|
||||
LOCK_FILE=$ROOT/var/lib/scratchpkg/spkg.lock
|
||||
TMP_PKGINSTALL=$ROOT/var/lib/scratchpkg/spkg.install
|
||||
HOOK_DIR=/etc/hook
|
||||
SYSUSERS_DIR=/etc/sysusers
|
||||
|
||||
# show help page
|
||||
if [ "$SHOWHELP" ] || [ -z "$PKGNAME" ]; then
|
||||
help
|
||||
@@ -366,13 +365,13 @@ if [ "$UPGRADE_PKG" ] && [ ! "$NO_POSTUPGRADE" ]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
msg "Package '$name-$version-$release' $oprdone."
|
||||
|
||||
if [ "$ROOT" = "" ]; then
|
||||
runhooks
|
||||
sysusers
|
||||
fi
|
||||
|
||||
msg "Package '$name-$version-$release' $oprdone."
|
||||
|
||||
# running ldconfig
|
||||
if [ "$ROOT" = "" ] && [ -x /sbin/ldconfig ]; then
|
||||
/sbin/ldconfig
|
||||
|
||||
95
pkginstall
Executable file
95
pkginstall
Executable file
@@ -0,0 +1,95 @@
|
||||
#!/bin/bash
|
||||
|
||||
getportpath() {
|
||||
for repo in ${PORT_REPO[@]}; do
|
||||
if [[ -f $repo/$1/$BUILD_SCRIPT ]]; then
|
||||
echo "$(dirname $repo/$1/$BUILD_SCRIPT)"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
confirm() {
|
||||
read -r -p "$1 (Y/n) " response
|
||||
case "$response" in
|
||||
[Nn][Oo]|[Nn]) echo "$2"; exit 2 ;;
|
||||
*) : ;;
|
||||
esac
|
||||
}
|
||||
|
||||
installpkg() {
|
||||
for i in ${PKG[@]}; do
|
||||
if [ -f $INDEX_DIR/$i/.pkginfo ]; then
|
||||
echo "Package '$i' already installed."
|
||||
else
|
||||
IPKG+=($i)
|
||||
fi
|
||||
done
|
||||
if [ "${#IPKG[@]}" = 0 ]; then
|
||||
echo "Nothing to do. Exiting..."
|
||||
return 0
|
||||
else
|
||||
echo
|
||||
fi
|
||||
echo "Resolving dependencies..."
|
||||
INST="$(pkgdeplist -l -n ${IPKG[@]})"
|
||||
|
||||
if [ "$INST" ]; then
|
||||
echo
|
||||
pkgcount=0
|
||||
for pkg in $INST; do
|
||||
pkgcount=$(( $pkgcount + 1 ))
|
||||
echo -n "$pkgcount)$pkg "
|
||||
done
|
||||
echo; echo
|
||||
confirm "Continue install package(s)?" "Package installation cancelled."
|
||||
count=0
|
||||
total=$(echo $INST | wc -w)
|
||||
for int in ${INST[@]}; do
|
||||
count=$(( $count + 1 ))
|
||||
pushd $(getportpath $int) &>/dev/null
|
||||
echo -ne "($count/$total) "
|
||||
pkgbuild -is || exit 1
|
||||
popd &>/dev/null
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
parse_opts() {
|
||||
while [ "$1" ]; do
|
||||
case $1 in
|
||||
*) PKG+=($1) ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
}
|
||||
|
||||
main() {
|
||||
mode=$1
|
||||
shift
|
||||
|
||||
parse_opts "$@"
|
||||
|
||||
if [ "$mode" = "install" ]; then
|
||||
installpkg
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Run 'scratch help' to see available mode and options"
|
||||
exit 5
|
||||
}
|
||||
|
||||
BUILD_SCRIPT="spkgbuild"
|
||||
INDEX_DIR="/var/lib/scratchpkg/index"
|
||||
|
||||
if [ -f /etc/scratchpkg.repo ]; then
|
||||
while read repodir repourl junk; do
|
||||
case $repodir in
|
||||
""|"#"*) continue ;;
|
||||
esac
|
||||
PORT_REPO+=($repodir)
|
||||
done < /etc/scratchpkg.repo
|
||||
fi
|
||||
|
||||
main "$@"
|
||||
6
scratch
6
scratch
@@ -614,6 +614,10 @@ duplicateports() {
|
||||
|
||||
searchpkg() {
|
||||
|
||||
local port
|
||||
local found
|
||||
local OUTPUT
|
||||
|
||||
for port in ${PORT_REPO[@]}; do
|
||||
if [ -d $port ]; then
|
||||
pushd $port
|
||||
@@ -635,7 +639,7 @@ searchpkg() {
|
||||
else
|
||||
echo -e "[ ] $search_result"
|
||||
fi
|
||||
unset description
|
||||
unset description name version release
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user