From eb798fe7dc8483f250eba20bd4797bcdbfb8adf5 Mon Sep 17 00:00:00 2001 From: emmett1 Date: Sat, 23 Sep 2017 22:52:03 +0800 Subject: [PATCH] updated --- buildpkg | 17 +++++----------- installpkg | 60 +++++++++++++++++++----------------------------------- removepkg | 22 ++------------------ scratch | 28 ++++++++++++------------- 4 files changed, 41 insertions(+), 86 deletions(-) diff --git a/buildpkg b/buildpkg index 8bfd218..67dfff3 100755 --- a/buildpkg +++ b/buildpkg @@ -33,6 +33,7 @@ updatemdsum() { md5sum $needupdatechecksum | awk '{ print $1 }' > .md5sum [ -f .md5sum ] && msg "md5sum updated." else + rm .md5sum || true touch .md5sum fi } @@ -431,26 +432,18 @@ updatepkgdepends() { # only installed depends will count as depends for dep in ${depends[@]}; do if [ -d $INDEX_DIR/$dep ]; then - if [ -z "$newdep" ]; then - newdep="$dep" - else - newdep="$newdep $dep" - fi + newdep+=($dep) fi done - depends="$newdep" + depends="${newdep[@]}" # only installed makedepends will count as makedepends for mdep in ${makedepends[@]}; do if [ -d $INDEX_DIR/$mdep ]; then - if [ -z "$newmdep" ]; then - newmdep="$mdep" - else - newmdep="$newmdep $mdep" - fi + newmdep+=($mdep) fi done - makedepends="$newmdep" + makedepends="${newmdep[@]}" } diff --git a/installpkg b/installpkg index b385301..6ebea54 100755 --- a/installpkg +++ b/installpkg @@ -115,8 +115,6 @@ installpkg() { registerpkg - msg "Successfully install ${color_green}$packagename${color_reset}." - if [ ! "$NO_POSTINSTALL" ] && [ ! "$UPGRADE_PKG" ]; then run_postinstall fi @@ -162,6 +160,8 @@ registerpkg() { tar -t -f $PKGNAME --exclude=.pkginfo --exclude=.pkginstall --exclude=.pkgreadme ${excludefile[@]} > $INDEX_DIR/$name/.files tar -x -f $PKGNAME -C $INDEX_DIR/$name .pkginstall .pkgreadme >/dev/null 2>&1 + msg "Successfully install ${color_green}$packagename${color_reset}." + } checkdeps() { @@ -199,13 +199,13 @@ checkpkgconflict() { checkconflict() { - while IFS=' ' read -r line; do - pushd $ROOT_DIR - if [ -e "$line" ]; then - fileconflict+=(${line}) - fi - popd - done < <(tar -tf "$PKGNAME" --exclude=.pkginfo --exclude=.pkginstall --exclude=.pkgreadme ${excludefile[@]} | grep -v '/$') + pushd $ROOT_DIR + while IFS=' ' read -r line; do + if [ -e "$line" ]; then + fileconflict+=(${line}) + fi + done < <(tar -tf "$PKGNAME" --exclude=.pkginfo --exclude=.pkginstall --exclude=.pkgreadme ${excludefile[@]} | grep -v '/$') + popd if [ "${#fileconflict[@]}" -gt 0 ]; then msgerr "File conflict found:" @@ -218,16 +218,16 @@ checkconflict() { } upcheckconflict() { - - while IFS=' ' read -r line; do - pushd $ROOT_DIR - if [ -e "$line" ]; then - if [ ! "$(grep -Fx "$line" "$INDEX_DIR/$name/.files")" ]; then - fileconflict+=(${line}) + + pushd $ROOT_DIR + while IFS=' ' read -r line; do + if [ -e "$line" ]; then + if [ ! "$(grep -Fx "$line" "$INDEX_DIR/$name/.files")" ]; then + fileconflict+=(${line}) + fi fi - fi - popd - done < <(tar -tf "$PKGNAME" --exclude=.pkginfo --exclude=.pkginstall --exclude=.pkgreadme ${excludefile[@]} | grep -v '/$') + done < <(tar -tf "$PKGNAME" --exclude=.pkginfo --exclude=.pkginstall --exclude=.pkgreadme ${excludefile[@]} | grep -v '/$') + popd if [ "${#fileconflict[@]}" -gt 0 ]; then msgerr "File conflict found:" @@ -277,16 +277,14 @@ updateinfopages() { backupconf() { - pushd $ROOT_DIR - + pushd $ROOT_DIR for bkp in ${backup[@]}; do if [ -e $bkp ]; then msg2 "Backup ${color_purple}$bkp${color_reset}" cp $bkp $BACKUP_DIR FILEBACKUP+=($bkp) fi - done - + done popd } @@ -459,15 +457,7 @@ parse_options() { NO_ORPHAN_CHECK=yes ;; *.spkg.txz) - [ -f $1 ] && PKGNAME=$1 || msg "${color_red}$1${color_reset} not exist." - ;; - --root) - if [ ! "$2" ]; then - msg "Option '$1' require an argument (root path)." - exit 1 - fi - ROOT="$2" - shift + [ -f "$1" ] && PKGNAME="$1" || msg "${color_red}$1${color_reset} not exist." ;; -h|--help) SHOW_HELP=yes @@ -495,14 +485,6 @@ main() { loadconfigfile - # CHANGE ROOT PATH ### - if [ "$ROOT" ]; then - ROOT_DIR="$ROOT" - INDEX_DIR="$ROOT_DIR/$INDEX_DIR" - BACKUP_DIR="$ROOT_DIR/$BACKUP_DIR" - REJECTED_DIR="$ROOT_DIR/$REJECTED_DIR" - fi - ### SHOW HELP ### if [ "$SHOW_HELP" ]; then help diff --git a/removepkg b/removepkg index 54e26b3..bc89a1e 100755 --- a/removepkg +++ b/removepkg @@ -44,8 +44,6 @@ removepkg() { msg2 "Removing dirs..." while IFS=' ' read -r line; do - #NOREMOVE="" - #if [ ! "$(find "$INDEX_DIR" -path "$INDEX_DIR"/$1 -prune -o -name .files -exec grep "$line" {} \;)" ]; then if [ ! "$(grep -R --exclude-dir="$1" -w "$line" "$INDEX_DIR")" ]; then pushd $ROOT_DIR if [ "$VERBOSE_REMOVE" = "yes" ]; then @@ -61,7 +59,7 @@ removepkg() { run_postremove fi - if [ "$(grep -w usr/share/info/ $INDEX_DIR/$1/.files)" ]; then + if [ "$(grep -x usr/share/info/ $INDEX_DIR/$1/.files)" ]; then UPDATE_INFO_PAGES=yes fi @@ -233,14 +231,6 @@ parse_options() { --no-orphan-check) NO_ORPHAN_CHECK=yes ;; - --root) - if [ ! "$2" ]; then - msg "Option '$1' require an argument (root path)." - exit 1 - fi - ROOT="$2" - shift - ;; *) RMNAME=$1 ;; @@ -263,14 +253,6 @@ main() { loadconfigfile - # CHANGE ROOT PATH ### - if [ "$ROOT" ]; then - ROOT_DIR="$ROOT" - INDEX_DIR="$ROOT_DIR/$INDEX_DIR" - BACKUP_DIR="$ROOT_DIR/$BACKUP_DIR" - REJECTED_DIR="$ROOT_DIR/$REJECTED_DIR" - fi - if [ -z $RMNAME ]; then msgerr "Please state package name for remove." exit 1 @@ -278,7 +260,7 @@ main() { ### CHECK FOR ROOT ACCESS ### if [ "$UID" != "0" ]; then - msgerr "${color_red}Removing package need root access.${color_reset}" + msgerr "Removing package need root access." exit 1 fi diff --git a/scratch b/scratch index 82f4de3..db2853a 100755 --- a/scratch +++ b/scratch @@ -111,16 +111,16 @@ showtree() { checkintegrity() { - for installed in $(ls $INDEX_DIR); do - while IFS=' ' read -r line; do - pushd $ROOT_DIR - if [ ! -e "$line" ]; then - msg "${color_yellow}$installed${color_reset} is missing: ${color_purple}/$line${color_reset}" - MISSING_FILE=yes - fi - popd - done < <(cat $INDEX_DIR/$installed/.files) - done + pushd $ROOT_DIR + for installed in $(ls $INDEX_DIR); do + while IFS=' ' read -r line; do + if [ ! -e "$line" ]; then + msg "${color_yellow}$installed${color_reset} is missing: ${color_purple}/$line${color_reset}" + MISSING_FILE=yes + fi + done < <(cat $INDEX_DIR/$installed/.files) + done + popd [ "$UID" != "0" ] && msg "${color_yellow}(check integrity is recommended run as root user or using sudo)${color_reset}" [ ! "$MISSING_FILE" ] && msg "Your system file is consistent with package tree." @@ -318,8 +318,6 @@ showportpath() { } interrupted() { - #echo "" - #msg "${color_yellow}Interrupted!${color_reset}" exit 1 } @@ -559,9 +557,9 @@ main() { # CHANGE ROOT PATH ### if [ "$ROOT" ]; then ROOT_DIR="$ROOT" - INDEX_DIR="$ROOT_DIR/$INDEX_DIR" - BACKUP_DIR="$ROOT_DIR/$BACKUP_DIR" - REJECTED_DIR="$ROOT_DIR/$REJECTED_DIR" + INDEX_DIR="$ROOT_DIR$INDEX_DIR" + BACKUP_DIR="$ROOT_DIR$BACKUP_DIR" + REJECTED_DIR="$ROOT_DIR$REJECTED_DIR" fi ### SHOW PORT PATH ###