From 0ece2bada35fe16f4a5ec0cbfa456c41f9ee4925 Mon Sep 17 00:00:00 2001 From: emmett1 Date: Mon, 18 Dec 2017 22:53:04 +0800 Subject: [PATCH] updated --- buildpkg | 2 +- installpkg | 6 +++--- removepkg | 14 +++++++------- scratch | 34 ++++++++++++++++++---------------- 4 files changed, 29 insertions(+), 27 deletions(-) diff --git a/buildpkg b/buildpkg index 6e44a07..f52260c 100755 --- a/buildpkg +++ b/buildpkg @@ -199,7 +199,7 @@ buildpackage() { pushd $SRC - (exec &> >(tee -i $LOG_DIR/$name.log); echo $(date); set -e -x; build) + (exec &> >(tee -i $LOG_DIR/$name.log); echo "$name-$version"; echo $(date); set -e -x; build) if [ $? != 0 ]; then msgerr "Build ${color_red}$PKGNAME${color_reset} failed." diff --git a/installpkg b/installpkg index ef83c6a..81a47b6 100755 --- a/installpkg +++ b/installpkg @@ -390,9 +390,9 @@ runhooks() { 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-) + 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 diff --git a/removepkg b/removepkg index 54d2b77..549b1e4 100755 --- a/removepkg +++ b/removepkg @@ -183,9 +183,9 @@ runremovehooks() { if [ "${#runthishook[@]}" -gt 0 ]; then for hook in ${runthishook[@]}; 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-) + 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 msg "$description" . $hook @@ -193,7 +193,7 @@ runremovehooks() { exechook fi fi - unset description operation target exec + unset description operation target done fi @@ -203,8 +203,8 @@ runpreremovehooks() { if [ "$(ls $HOOK_DIR/*.hook 2>/dev/null)" ]; then for hook in $(ls $HOOK_DIR/*.hook); do - operation=$(cat "$hook" | grep ^"# Operation" | sed 's/\://' | cut -d ' ' -f 3-) - target=$(cat "$hook" | grep ^"# Target" | 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 [ "$(echo $operation | grep -w "remove" )" ]; then if [ "$(grep -E $target $INDEX_DIR/$1/.files)" ]; then runthishook+=($hook) @@ -265,7 +265,7 @@ main() { ### CHECK DIRECTORY ### checkdirexist "$INDEX_DIR" "$BACKUP_DIR" "$REJECTED_DIR" checkdirwrite "$INDEX_DIR" "$BACKUP_DIR" "$REJECTED_DIR" - checkdirread "$INDEX_DIR" "$BACKUP_DIR" "$REJECTED_DIR" + checkdirread "$INDEX_DIR" "$BACKUP_DIR" "$REJECTED_DIR" ### PACKAGE NAME ### if [ -z $RMNAME ]; then diff --git a/scratch b/scratch index 43ce56f..7124e73 100755 --- a/scratch +++ b/scratch @@ -79,18 +79,16 @@ searchpkg() { for port in ${PORT_REPO[@]}; do if [ -d $port ]; then OUTPUT=() - for list in $(ls $port); do - if [ -f $port/$list/$BUILD_SCRIPT ]; then - if [ "$(cat $port/$list/$BUILD_SCRIPT | grep ^'# description' | tr -d ':' | cut -d ' ' -f 3- | grep -i $SEARCH_PKG)" ] || [ "$(echo $list | grep -i $SEARCH_PKG)" ]; then - OUTPUT+=($list) - fi - fi - done - for out in ${OUTPUT[@]}; do - if [ -f $port/$out/$BUILD_SCRIPT ]; then - pushd $port/$out - getpkginfo - popd + pushd $port + OUTPUT=$(grep -R "# description" | grep -i "$SEARCH_PKG" | cut -d '/' -f1) + popd + if [ "$OUTPUT" ]; then + found=yes + for out in ${OUTPUT[@]}; do + if [ -f $port/$out/$BUILD_SCRIPT ]; then + pushd $port/$out + getpkginfo + popd if [ ! -z "$name" ] && [ ! -z "$version" ] && [ ! -z "$release" ]; then portname=$(basename $port) search_result="${color_purple}($portname)${color_reset} ${color_gray}$name${color_reset} ${color_cyan}$version-$release${color_reset}" @@ -100,7 +98,7 @@ searchpkg() { msg3 "$search_result ${color_green}[installed]${color_reset}" msg4 "$description" else - msg3 "$search_result ${color_yellow}[outdated] $iversion-$irelease${color_reset}" + msg3 "$search_result ${color_yellow}[installed $iversion-$irelease]${color_reset}" msg4 "$description" fi else @@ -109,17 +107,21 @@ searchpkg() { fi unset description fi - fi - done + fi + done + fi fi done + if [ "$found" != "yes" ]; then + msg "No matching package found." + fi } checkowner() { for installed in $(ls $INDEX_DIR); do for output in $(cat $INDEX_DIR/$installed/.files | grep $OWNER_FILE_NAME); do - msg "${color_cyan}$installed${color_reset} => ${color_purple}$output${color_reset}" + echo -e "${color_cyan}$installed${color_reset} => ${color_purple}$output${color_reset}" done done