add --root= and add umash 022 to pkgbuild

This commit is contained in:
emmett1
2019-12-26 17:41:12 +08:00
parent 53d20dac09
commit 5580b416e6
2 changed files with 38 additions and 19 deletions

View File

@@ -163,6 +163,8 @@ prepare_src() {
SRC=$WORK_DIR/$name/src
PKG=$WORK_DIR/$name/pkg
umask 022
rm -fr $WORK_DIR/$name
mkdir -p $SRC $PKG
@@ -505,6 +507,7 @@ parse_opts() {
-l | --log) LOGGING=yes ;;
-p | --pkgfiles) GENPKGFILES=yes ;;
-h | --help) SHOWHELP=yes ;;
--root=*) OPTS+=($1) ;;
--no-preinstall) OPTS+=($1) ;;
--no-postinstall) OPTS+=($1) ;;
--no-preupgrade) OPTS+=($1) ;;

54
scratch
View File

@@ -795,6 +795,10 @@ scratch_install() {
fi
shift
done
# use custom root location
if [ "$ROOT_DIR" ]; then
OPTS+=(--root=$ROOT_DIR)
fi
# if reinstall, dont calculate dep, just reinstall it then exit
if [ "$REINSTALL" = 1 ]; then
for ii in ${PKGNAME[@]}; do
@@ -948,6 +952,10 @@ scratch_remove() {
fi
shift
done
# use custom root location
if [ "$ROOT_DIR" ]; then
OPTS+=(--root=$ROOT_DIR)
fi
for i in ${PKGNAME[@]}; do
if ! isinstalled $i; then
@@ -1014,6 +1022,11 @@ scratch_sysup() {
shift
done
# use custom root location
if [ "$ROOT_DIR" ]; then
OPTS+=(--root=$ROOT_DIR)
fi
if [ "$SYNC" = 1 ]; then
scratch_sync
fi
@@ -1120,6 +1133,10 @@ scratch_upgrade() {
fi
shift
done
# use custom root location
if [ "$ROOT_DIR" ]; then
OPTS+=(--root=$ROOT_DIR)
fi
for pkg in ${PKGNAME[@]}; do
if ! isinstalled $pkg; then
msgerr "Package '$pkg' not installed."
@@ -1617,7 +1634,8 @@ Operations:
extra various extra options
Global options:
--repo=<repo> add custom repo
--repo=<path> add custom local repo path
--root=<path> use custom root path
--nocolor disable colour output
EOF
@@ -1647,17 +1665,28 @@ main() {
return $?
}
mode=$1
shift
for opt in $@; do
case $opt in
--nocolor) nocolor ;;
--repo=*) PORT_REPO+=(${opt#*=}) ;;
--root=*) ROOT_DIR=(${opt#*=}) ;;
--*) MAINOPTS+=($opt) ;;
-*) for (( i=1; i<${#opt}; i++ )); do MAINOPTS+=(-${opt:$i:1}); done ;;
*) MAINOPTS+=($opt) ;;
esac
done
BUILD_SCRIPT="spkgbuild"
INDEX_DIR="/var/lib/scratchpkg/index"
INDEX_DIR="$ROOT_DIR/var/lib/scratchpkg/index"
REPO_FILE="/etc/scratchpkg.repo"
SOURCE_DIR="/var/cache/scratchpkg/sources"
PACKAGE_DIR="/var/cache/scratchpkg/packages"
if [ ! -f "$REPO_FILE" ]; then
msgerr "repo file not exist. ($REPO_FILE)"
exit 1
else
if [ -f "$REPO_FILE" ]; then
while read -r repodir repourl junk; do
case $repodir in
""|"#"*) continue ;;
@@ -1666,19 +1695,6 @@ else
done < "$REPO_FILE"
fi
mode=$1
shift
for opt in $@; do
case $opt in
--nocolor) nocolor ;;
--repo=*) PORT_REPO+=(${opt#*=}) ;;
--*) MAINOPTS+=($opt) ;;
-*) for (( i=1; i<${#opt}; i++ )); do MAINOPTS+=(-${opt:$i:1}); done ;;
*) MAINOPTS+=($opt) ;;
esac
done
main ${MAINOPTS[@]}
exit $?