From 4e57fa20c1f6e784d4152a3468565a68b9b094e4 Mon Sep 17 00:00:00 2001 From: Dave Woodfall Date: Mon, 5 Apr 2021 08:30:27 +0000 Subject: slackpkg: indents and line endings. Indent with spaces. Fix indent levels. Remove trailing whitespace. --- files/slackpkg | 620 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 310 insertions(+), 310 deletions(-) diff --git a/files/slackpkg b/files/slackpkg index 1076ba3..caf8d1d 100644 --- a/files/slackpkg +++ b/files/slackpkg @@ -57,19 +57,19 @@ SLACKWARE_VERSION=$(cat /etc/slackware-version | cut -f2 -d\ ) [ -n "$ROOT" ] && CONF=${CONF:-"${ROOT}/etc/slackpkg"} SOURCE=$(sed -n ' - # Remove leading and trailing blanks - s/^[[:blank:]]*// - s/[[:blank:]]*$// - # Only one token is allowed per line - /[[:blank:]]/d - # A single solidus should end the URI - s,[/]*$,/, - # Print the lines beginning with one of the URI schemes we look for - \@^file://@p - \@^cdrom://@p - \@^local://@p - \@^https\{0,1\}://@p - \@^ftps\{0,1\}://@p' $CONF/mirrors) + # Remove leading and trailing blanks + s/^[[:blank:]]*// + s/[[:blank:]]*$// + # Only one token is allowed per line + /[[:blank:]]/d + # A single solidus should end the URI + s,[/]*$,/, + # Print the lines beginning with one of the URI schemes we look for + \@^file://@p + \@^cdrom://@p + \@^local://@p + \@^https\{0,1\}://@p + \@^ftps\{0,1\}://@p' $CONF/mirrors) PATH='' builtin source $CONF/slackpkg.conf WORKDIR=${ROOT}/${WORKDIR} ERROR="" @@ -79,8 +79,8 @@ ERROR="" mkdir -p ${ROOT}/tmp TMPDIR=$(mktemp -p ${ROOT}/tmp -d slackpkg.XXXXXX 2>/dev/null) if [ $? -ne 0 ]; then - TMPDIR="${ROOT}/tmp/slackpkg.${RANDOM}" - mkdir -p -m 700 $TMPDIR || TMPDIR="FAILED" + TMPDIR="${ROOT}/tmp/slackpkg.${RANDOM}" + mkdir -p -m 700 $TMPDIR || TMPDIR="FAILED" fi # @@ -90,7 +90,7 @@ fi #======================================================================== # -# COMMAND LINE PARSING +# COMMAND LINE PARSING # if [ $# -eq 0 ]; then usage @@ -217,25 +217,25 @@ while [ -n "$1" ] ; do -mirror=*) SOURCE=$(echo $1 | cut -f2 -d=) shift - ;; + ;; install|reinstall|upgrade|remove|download) CMD=$1 shift if [ -n "$1" ]; then if echo $1 | egrep -q "^\.{0,2}/" ; then - if [ -e $1 ]; then - INPUTLIST=$(cat $1 | tr "\n" " ") - else - echo -e "The file $1 doesn't exist.\n" - cleanup - fi + if [ -e $1 ]; then + INPUTLIST=$(cat $1 | tr "\n" " ") + else + echo -e "The file $1 doesn't exist.\n" + cleanup + fi else - # - # Sanitize the argument. We have some problems with dots - # and plus (.+) - # - #INPUTLIST="$(echo $@ | sed -e 's/\+/\\\+/g' -e 's/\./\\\./g')" - INPUTLIST="$@" + # + # Sanitize the argument. We have some problems with dots + # and plus (.+) + # + #INPUTLIST="$(echo $@ | sed -e 's/\+/\\\+/g' -e 's/\./\\\./g')" + INPUTLIST="$@" fi elif [ "$CMD" != "blacklist" ]; then usage @@ -258,28 +258,28 @@ while [ -n "$1" ] ; do CMD=$1 shift if [ -n "$1" ]; then - echo -e "\n$CMD: Ignoring extra arguments: $@" >&2 >&1 + echo -e "\n$CMD: Ignoring extra arguments: $@" >&2 >&1 shift $# fi ;; generate-template|install-template|remove-template|search|file-search|info) CMD=$1 shift - if [ -n "$1" ]; then + if [ -n "$1" ]; then ARG=$1 - shift + shift else usage fi if [ -n "$1" ]; then - echo -e "\n$CMD: Ignoring extra arguments: $@" >&2 >&1 + echo -e "\n$CMD: Ignoring extra arguments: $@" >&2 >&1 shift $# fi ;; *) - echo -e "\n$1: Unknown option.\n" - usage + echo -e "\n$1: Unknown option.\n" + usage ;; esac done @@ -298,7 +298,7 @@ system_checkup #======================================================================== # -# READ EXTRA FUNCTIONS +# READ EXTRA FUNCTIONS # # If you want a new function or need a rewrite of an existing @@ -308,9 +308,9 @@ system_checkup # Remember - the new function scripts need to be executable # for i in /usr/libexec/slackpkg/functions.d/*.sh; do - if [ -x $i ]; then - . $i - fi + if [ -x $i ]; then + . $i + fi done #======================================================================== @@ -322,294 +322,294 @@ done # A *BIG* case with all slackpkg commands -:) # case "$CMD" in - help) - full_usage - ;; - check-updates) - # output to stdout if no change, or stderr if changes. Will cause - # cron jobs to notify system admin - if checkchangelog 1>/dev/null 2>/dev/null ; then - echo "Slackpkg: No updated packages since last check." - else - echo "Slackpkg: Updated packages are available since last check." >&2 - PENDING_UPDATES=1 - fi - ;; - show-changelog) - # display changelog and exit - if [ -e ${WORKDIR}/ChangeLog.txt ]; then - $MORECMD ${WORKDIR}/ChangeLog.txt - else - echo "ChangeLog.txt file not found. Aborting" - fi - POSTINST=off - ;; - update) - # If you are using "slackpkg update gpg" OR the system - # doesn't have Slackware GPG key, download and install - # the key - # - if [ "$UPARG" = "gpg" ] || [ "$GPGFIRSTTIME" = "0" ]; then - # - # Creates .gnupg directory if doesn't exist - # without this dir, gpg got an error. - # - if ! [ -e ~/.gnupg ]; then - mkdir ~/.gnupg - fi - getfile ${SOURCE}GPG-KEY $TMPDIR/gpgkey - gpg --yes --batch --delete-key "$SLACKKEY" &>/dev/null - gpg --import $TMPDIR/gpgkey &>/dev/null && \ - echo -e "\t\t\tSlackware Linux Project's GPG key added" - if [ "$UPARG" = "gpg" ]; then - cleanup - fi - fi - echo "Updating the package lists..." - updatefilelists - ;; - install) - makelist $INPUTLIST - if [ -n "$LIST" ]; then - showlist "$LIST" $CMD - install_pkg - else - echo -e "No packages match the pattern for install. Try:" - echo -e "\n\t$0 reinstall|upgrade $2\n" - POSTINST=off - fi - ;; - reinstall) - makelist $INPUTLIST - if [ -n "$LIST" ]; then - showlist "$LIST" $CMD - install_pkg - else - echo -e "No packages match the pattern for reinstall. Try:" - echo -e "\n\t$0 install|upgrade $2\n" - POSTINST=off - fi - ;; - upgrade) - sanity_check - makelist $INPUTLIST - if [ -n "$LIST" ]; then - showlist "$LIST" $CMD - upgrade_pkg - else - echo -e "No packages match the pattern for upgrade. Try:" - echo -e "\n\t$0 install|reinstall $2\n" - POSTINST=off - fi - ;; - download) - makelist $INPUTLIST - DELALL="off" - if ! [ "$LIST" = "" ]; then - showlist "$LIST" $CMD - for i in $SHOWLIST; do - getpkg $i true - done - else - echo -e "No packages match the pattern for download." - POSTINST=off - fi - ;; - remove) - makelist $INPUTLIST - if [ "$LIST" = "" ]; then - echo -e "The file(s) $INPUTLIST can't be removed - package not installed.\n" - cleanup - fi - showlist "$LIST" $CMD - remove_pkg - ;; - clean-system) - makelist $INPUTLIST - if [ -n "$LIST" ]; then - showlist "$LIST" remove - remove_pkg - else - echo -e "No packages match the pattern for clean-system\n" - POSTINST=off - fi - ;; - upgrade-all) - sanity_check - makelist $INPUTLIST - if ! [ -n "${LIST}" ]; then - echo -e "No packages match the pattern for upgrade. Try:" - echo -e "\n\t$0 install|reinstall $2\n" - POSTINST=off - else - showlist "$LIST" upgrade - if [ "$DOWNLOAD_ALL" = "on" ]; then - OLDDEL="$DELALL" - DELALL="off" - for i in $SHOWLIST; do - getpkg $i true - done - DELALL="$OLDDEL" - fi - FOUND="" - FOUND=$(echo $SHOWLIST | tr -s ' ' "\n" | grep "slackpkg-[0-9]") - if [ "$FOUND" != "" ]; then - getpkg $FOUND upgradepkg Upgrading - echo -e "slackpkg was upgraded - you will need start the upgrade process again...\n" - cleanup - exit 0 - fi - for i in pkgtools aaa_glibc-solibs glibc-solibs aaa_libraries aaa_elflibs readline sed; do - FOUND="" - FOUND=$(echo $SHOWLIST | tr -s ' ' "\n" | grep "${i}-[0-9]") - if [ "$FOUND" != "" ]; then - getpkg $FOUND upgradepkg Upgrading - fi - done - upgrade_pkg - fi - ;; - install-new) - makelist ${INPUTLIST} - if ! [ -n "${LIST}" ]; then - echo -e "No packages match the pattern for install. Try:" - echo -e "\n\t$0 upgrade|reinstall $2\n" - POSTINST=off - else - showlist "$LIST" install - install_pkg - fi - ;; - blacklist) - echo -e "Edit /etc/slackpkg/blacklist to add or remove packages." - echo -e "" - echo -e "Packages in blacklist:\n" - grep -v "^#" $CONF/blacklist | $MORECMD - echo -e "" - ;; - file-search) - PATTERN=$(echo $ARG | sed -e 's/\+/\\\+/g' -e 's/\./\\\./g' -e 's/ /\|/g') - makelist $PATTERN + help) + full_usage + ;; + check-updates) + # output to stdout if no change, or stderr if changes. Will cause + # cron jobs to notify system admin + if checkchangelog 1>/dev/null 2>/dev/null ; then + echo "Slackpkg: No updated packages since last check." + else + echo "Slackpkg: Updated packages are available since last check." >&2 + PENDING_UPDATES=1 + fi + ;; + show-changelog) + # display changelog and exit + if [ -e ${WORKDIR}/ChangeLog.txt ]; then + $MORECMD ${WORKDIR}/ChangeLog.txt + else + echo "ChangeLog.txt file not found. Aborting" + fi + POSTINST=off + ;; + update) + # If you are using "slackpkg update gpg" OR the system + # doesn't have Slackware GPG key, download and install + # the key + # + if [ "$UPARG" = "gpg" ] || [ "$GPGFIRSTTIME" = "0" ]; then + # + # Creates .gnupg directory if doesn't exist + # without this dir, gpg got an error. + # + if ! [ -e ~/.gnupg ]; then + mkdir ~/.gnupg + fi + getfile ${SOURCE}GPG-KEY $TMPDIR/gpgkey + gpg --yes --batch --delete-key "$SLACKKEY" &>/dev/null + gpg --import $TMPDIR/gpgkey &>/dev/null && \ + echo -e "\t\t\tSlackware Linux Project's GPG key added" + if [ "$UPARG" = "gpg" ]; then + cleanup + fi + fi + echo "Updating the package lists..." + updatefilelists + ;; + install) + makelist $INPUTLIST + if [ -n "$LIST" ]; then + showlist "$LIST" $CMD + install_pkg + else + echo -e "No packages match the pattern for install. Try:" + echo -e "\n\t$0 reinstall|upgrade $2\n" + POSTINST=off + fi + ;; + reinstall) + makelist $INPUTLIST + if [ -n "$LIST" ]; then + showlist "$LIST" $CMD + install_pkg + else + echo -e "No packages match the pattern for reinstall. Try:" + echo -e "\n\t$0 install|upgrade $2\n" + POSTINST=off + fi + ;; + upgrade) + sanity_check + makelist $INPUTLIST + if [ -n "$LIST" ]; then + showlist "$LIST" $CMD + upgrade_pkg + else + echo -e "No packages match the pattern for upgrade. Try:" + echo -e "\n\t$0 install|reinstall $2\n" + POSTINST=off + fi + ;; + download) + makelist $INPUTLIST + DELALL="off" + if ! [ "$LIST" = "" ]; then + showlist "$LIST" $CMD + for i in $SHOWLIST; do + getpkg $i true + done + else + echo -e "No packages match the pattern for download." + POSTINST=off + fi + ;; + remove) + makelist $INPUTLIST + if [ "$LIST" = "" ]; then + echo -e "The file(s) $INPUTLIST can't be removed - package not installed.\n" + cleanup + fi + showlist "$LIST" $CMD + remove_pkg + ;; + clean-system) + makelist $INPUTLIST + if [ -n "$LIST" ]; then + showlist "$LIST" remove + remove_pkg + else + echo -e "No packages match the pattern for clean-system\n" + POSTINST=off + fi + ;; + upgrade-all) + sanity_check + makelist $INPUTLIST + if ! [ -n "${LIST}" ]; then + echo -e "No packages match the pattern for upgrade. Try:" + echo -e "\n\t$0 install|reinstall $2\n" + POSTINST=off + else + showlist "$LIST" upgrade + if [ "$DOWNLOAD_ALL" = "on" ]; then + OLDDEL="$DELALL" + DELALL="off" + for i in $SHOWLIST; do + getpkg $i true + done + DELALL="$OLDDEL" + fi + FOUND="" + FOUND=$(echo $SHOWLIST | tr -s ' ' "\n" | grep "slackpkg-[0-9]") + if [ "$FOUND" != "" ]; then + getpkg $FOUND upgradepkg Upgrading + echo -e "slackpkg was upgraded - you will need start the upgrade process again...\n" + cleanup + exit 0 + fi + for i in pkgtools aaa_glibc-solibs glibc-solibs aaa_libraries aaa_elflibs readline sed; do + FOUND="" + FOUND=$(echo $SHOWLIST | tr -s ' ' "\n" | grep "${i}-[0-9]") + if [ "$FOUND" != "" ]; then + getpkg $FOUND upgradepkg Upgrading + fi + done + upgrade_pkg + fi + ;; + install-new) + makelist ${INPUTLIST} + if ! [ -n "${LIST}" ]; then + echo -e "No packages match the pattern for install. Try:" + echo -e "\n\t$0 upgrade|reinstall $2\n" + POSTINST=off + else + showlist "$LIST" install + install_pkg + fi + ;; + blacklist) + echo -e "Edit /etc/slackpkg/blacklist to add or remove packages." + echo -e "" + echo -e "Packages in blacklist:\n" + grep -v "^#" $CONF/blacklist | $MORECMD + echo -e "" + ;; + file-search) + PATTERN=$(echo $ARG | sed -e 's/\+/\\\+/g' -e 's/\./\\\./g' -e 's/ /\|/g') + makelist $PATTERN - if [ "$LIST" = "" ]; then - echo -e "No packages contains \"$PATTERN\" file." - else - echo -e "The list below shows the packages that contains \"$PATTERN\" file.\n" - searchlist "$LIST" - echo -e "\nYou can search specific packages using \"slackpkg search package\".\n" - fi - ;; - search) - PATTERN=$(echo $ARG | sed -e 's/\+/\\\+/g' -e 's/\./\\\./g' -e 's/ /\|/g') - makelist $PATTERN + if [ "$LIST" = "" ]; then + echo -e "No packages contains \"$PATTERN\" file." + else + echo -e "The list below shows the packages that contains \"$PATTERN\" file.\n" + searchlist "$LIST" + echo -e "\nYou can search specific packages using \"slackpkg search package\".\n" + fi + ;; + search) + PATTERN=$(echo $ARG | sed -e 's/\+/\\\+/g' -e 's/\./\\\./g' -e 's/ /\|/g') + makelist $PATTERN - if [ "$LIST" = "" ]; then - echo -e "No package name matches the pattern." - else - echo -e "The list below shows all packages with name matching \"$PATTERN\".\n" - searchlist "$LIST" - echo -e "\nYou can search specific files using \"slackpkg file-search file\".\n" - fi - ;; - info) - PATTERN=$(echo $ARG | sed -e 's/\+/\\\+/g' -e 's/\./\\\./g') - NAME=$(cutpkg $PATTERN) - awk -F: "/PACKAGE NAME:.* ${NAME}-[^-]+-(${ARCH}|fw|noarch)-[^-]+/,/^$/ { - found=1 - if (\$1 ~ /"$NAME"/) { - print \$PATTERN - } else { - print \$0 - } - } - END { - if ( found != 1 ) { - print \"No packages found! Try:\n\n\tslackpkg search $PATTERN\n\nand choose one (and ONLY one package).\n\" - } - }" ${WORKDIR}/PACKAGES.TXT 2>/dev/null - ;; - new-config) - POSTINST=on - ;; - generate-template) - TEMPLATE=$ARG.template - if [ -e $TEMPLATEDIR/$TEMPLATE ]; then - echo -e "\ + if [ "$LIST" = "" ]; then + echo -e "No package name matches the pattern." + else + echo -e "The list below shows all packages with name matching \"$PATTERN\".\n" + searchlist "$LIST" + echo -e "\nYou can search specific files using \"slackpkg file-search file\".\n" + fi + ;; + info) + PATTERN=$(echo $ARG | sed -e 's/\+/\\\+/g' -e 's/\./\\\./g') + NAME=$(cutpkg $PATTERN) + awk -F: "/PACKAGE NAME:.* ${NAME}-[^-]+-(${ARCH}|fw|noarch)-[^-]+/,/^$/ { + found=1 + if (\$1 ~ /"$NAME"/) { + print \$PATTERN + } else { + print \$0 + } + } + END { + if ( found != 1 ) { + print \"No packages found! Try:\n\n\tslackpkg search $PATTERN\n\nand choose one (and ONLY one package).\n\" + } + }" ${WORKDIR}/PACKAGES.TXT 2>/dev/null + ;; + new-config) + POSTINST=on + ;; + generate-template) + TEMPLATE=$ARG.template + if [ -e $TEMPLATEDIR/$TEMPLATE ]; then + echo -e "\ \"$TEMPLATE\" already exists!\n\ \nDo you want to overwrite $TEMPLATE (y/N)? \c" - answer - if [ "$ANSWER" = "Y" -o "$ANSWER" = "y" ]; then - rm $TEMPLATEDIR/$TEMPLATE - echo - else - cleanup - fi - fi - generate_template $ARG - ;; - install-template) - TEMPLATE=$ARG.template - if [ -e $TEMPLATEDIR/$TEMPLATE ]; then - ( cd $TEMPLATEDIR - parse_template $TEMPLATE - ) - INPUTLIST=$(cat ${TMPDIR}/${TEMPLATE}.tmp | tr "\n" " ") - else - echo -e "$ARG template not found!" - cleanup - fi + answer + if [ "$ANSWER" = "Y" -o "$ANSWER" = "y" ]; then + rm $TEMPLATEDIR/$TEMPLATE + echo + else + cleanup + fi + fi + generate_template $ARG + ;; + install-template) + TEMPLATE=$ARG.template + if [ -e $TEMPLATEDIR/$TEMPLATE ]; then + ( cd $TEMPLATEDIR + parse_template $TEMPLATE + ) + INPUTLIST=$(cat ${TMPDIR}/${TEMPLATE}.tmp | tr "\n" " ") + else + echo -e "$ARG template not found!" + cleanup + fi - makelist $INPUTLIST - if [ -n "$LIST" ]; then - showlist "$LIST" $CMD - install_pkg - else - echo -e "All packages from $ARG template are already installed" - POSTINST=off - fi - ;; - remove-template) - TEMPLATE=$ARG.template - if [ -e $TEMPLATEDIR/$TEMPLATE ]; then - ( cd $TEMPLATEDIR - parse_template $TEMPLATE - ) - INPUTLIST=$(cat ${TMPDIR}/${TEMPLATE}.tmp | tr "\n" " ") - else - echo -e "$ARG template not found!" - cleanup - fi + makelist $INPUTLIST + if [ -n "$LIST" ]; then + showlist "$LIST" $CMD + install_pkg + else + echo -e "All packages from $ARG template are already installed" + POSTINST=off + fi + ;; + remove-template) + TEMPLATE=$ARG.template + if [ -e $TEMPLATEDIR/$TEMPLATE ]; then + ( cd $TEMPLATEDIR + parse_template $TEMPLATE + ) + INPUTLIST=$(cat ${TMPDIR}/${TEMPLATE}.tmp | tr "\n" " ") + else + echo -e "$ARG template not found!" + cleanup + fi - makelist $INPUTLIST - if [ "$LIST" = "" ]; then - echo -e "The template $ARG can't be removed - it isn't installed.\n" - cleanup - fi - showlist "$LIST" $CMD - remove_pkg - ;; - *) - usage - ;; + makelist $INPUTLIST + if [ "$LIST" = "" ]; then + echo -e "The template $ARG can't be removed - it isn't installed.\n" + cleanup + fi + showlist "$LIST" $CMD + remove_pkg + ;; + *) + usage + ;; esac # # Executes the post-install. This is the default # Before runs post-install, check if the slackpkg option is -# remove, search, update, info or clean-system. -# That options don't change configurations files and, if +# remove, search, update, info or clean-system. +# That options don't change configurations files and, if # someone remove the kernel, i hope he knows what is doing. # for i in check-updates remove search file-search update info blacklist \ - clean-system download generate-template remove-template; do - if [ "$CMD" = "$i" ]; then - POSTINST=off - fi + clean-system download generate-template remove-template; do + if [ "$CMD" = "$i" ]; then + POSTINST=off + fi done if [ "$POSTINST" != "off" ]; then - lookkernel - looknew + lookkernel + looknew fi cleanup -- cgit v1.2.3