From bc318b20bd836891526cef1ae1a967e85ce376a6 Mon Sep 17 00:00:00 2001 From: emmett1 Date: Tue, 24 Dec 2019 22:20:19 +0800 Subject: [PATCH] cleanup --- pkgbuild | 15 ++++++++------- scratch | 47 ++++++++++++++++++++++++++++++----------------- 2 files changed, 38 insertions(+), 24 deletions(-) diff --git a/pkgbuild b/pkgbuild index d845c65..4fffb4e 100755 --- a/pkgbuild +++ b/pkgbuild @@ -376,17 +376,17 @@ packaging() { popd >/dev/null - [ -f .pkglist ] || generate_pkglist + [ -f .pkgfiles ] || generate_pkgfiles } -generate_pkglist() { +generate_pkgfiles() { if [ ! -f "$PACKAGE_DIR/$PKGNAME" ]; then msgerr "Package '$PKGNAME' not found." abort 1 fi - msg "Generating .pkglist..." - tar -tvf "$PACKAGE_DIR/$PKGNAME" | awk '{print $1,$2,$6}' > .pkglist + msg "Generating .pkgfiles..." + tar -tvf "$PACKAGE_DIR/$PKGNAME" | awk '{print $1,$2,$6}' > .pkgfiles } check_buildscript() { @@ -500,7 +500,7 @@ parse_opts() { -x | --extract) EXTRACT_ONLY=yes ;; -w | --keep-work) KEEP_WORK=yes ;; -l | --log) LOGGING=yes ;; - -p | --pkglist) GENPKGLIST=yes ;; + -p | --pkgfiles) GENPKGFILES=yes ;; -h | --help) SHOWHELP=yes ;; --no-preinstall) OPTS+=($1) ;; --no-postinstall) OPTS+=($1) ;; @@ -535,6 +535,7 @@ Options: -g, --genmdsum generate md5sum -o, --download download only source file -x, --extract extract only source file + -p, --pkgfiles generate list files in package -w, --keep-work keep working directory -l, --log log build process -h, --help show this help message @@ -612,8 +613,8 @@ main() { exit 1 ;; esac - if [ "$GENPKGLIST" = "yes" ]; then - generate_pkglist + if [ "$GENPKGFILES" = "yes" ]; then + generate_pkgfiles exit 0 fi diff --git a/scratch b/scratch index 30b66bc..6ed68d8 100755 --- a/scratch +++ b/scratch @@ -108,9 +108,13 @@ allinstalled() { } get_depends() { - local ppath - ppath=$(getportpath "$1") || return 0 - grep "^# depends[[:blank:]]*:" $ppath/$BUILD_SCRIPT | sed 's/^# depends[[:blank:]]*:[[:blank:]]*//' | tr ' ' '\n' | awk '!a[$0]++' + local pkg=$1 + ppath=$(getportpath $pkg) || return 0 + grep "^# depends[[:blank:]]*:" $ppath/$BUILD_SCRIPT \ + | sed 's/^# depends[[:blank:]]*:[[:blank:]]*//' \ + | tr ' ' '\n' \ + | awk '!a[$0]++' \ + | sed 's/,//' } confirm() { @@ -1362,7 +1366,6 @@ scratch_dup() { } scratch_deplist() { - needarg $@ while [ "$1" ]; do case $1 in -q) quick=1;; @@ -1418,7 +1421,7 @@ deplist() { CHECK+=($1) # check dependencies - for i in $(pkg_depends $1); do + for i in $(get_depends $1); do if [ "$quick" = 1 ] && isinstalled $i; then continue else @@ -1449,17 +1452,6 @@ deplist() { done } -pkg_depends() { - needarg $@ - local pkg=$1 - ppath=$(getportpath $pkg) || return 1 - grep "^# depends[[:blank:]]*:" $ppath/spkgbuild \ - | sed 's/^# depends[[:blank:]]*:[[:blank:]]*//' \ - | tr ' ' '\n' \ - | awk '!a[$0]++' \ - | sed 's/,//' -} - usage_extra() { cat << EOF Usage: @@ -1523,6 +1515,7 @@ Options: -v, --verbose print install process -y, --yes dont ask confirmation -l, --log log build process + --exclude= exclude dependencies, comma separated --no-backup skip backup configuration file --no-preupgrade skip pre-upgrade script --no-postupgrade skip post-upgrade script @@ -1546,6 +1539,7 @@ Options: -s, --sync sync ports before upgrades -y, --yes dont ask confirmation -l, --log log build process + --exclude= exclude dependencies, comma separated --no-backup skip backup configuration file --no-preupgrade skip pre-upgrade script --no-postupgrade skip post-upgrade script @@ -1583,6 +1577,7 @@ Options: -v, --verbose print install files -l, --log log build process -y, --yes dont ask confirmation + --exclude= exclude dependencies, comma separated --no-backup skip backup configuration file (use with -r/--reinstall) --no-preinstall skip pre-install script --no-postinstall skip post-install script @@ -1594,19 +1589,37 @@ Options: EOF } +usage_deplist() { + cat << EOF +Usage: + $(basename $0) deplist [ ] + +Options: + -q, --quick print only not-installed pkg in quick format + --exclude= exclude dependencies, comma separated + +EOF +} + + usage_help() { cat << EOF Usage: $(basename $0) help -Operation: +Operations: build build package install install packages upgrade upgrade packages sysup full system upgrades remove remove packages + deplist list all dependencies extra various extra options +Global options: + --repo= add custom repo + --nocolor disable colour output + EOF }