From 166055b380fd6a558a1b29636ca64d469c2730d4 Mon Sep 17 00:00:00 2001 From: Dave Woodfall Date: Wed, 21 Apr 2021 01:03:29 +0000 Subject: files/core-functions.sh: line ending fixes --- files/core-functions.sh | 102 ++++++++++++++++++++++++------------------------ 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/files/core-functions.sh b/files/core-functions.sh index c5bd313..92138e4 100644 --- a/files/core-functions.sh +++ b/files/core-functions.sh @@ -69,7 +69,7 @@ function system_setup() { # files and packages from there. # MEDIA=${SOURCE%%:*} - if [ "$MEDIA" = "cdrom" ] || [ "$MEDIA" = "file" ] || \ + if [ "$MEDIA" = "cdrom" ] || [ "$MEDIA" = "file" ] || [ "$MEDIA" = "local" ]; then SOURCE=/${SOURCE#${MEDIA}://} LOCAL=1 @@ -179,7 +179,7 @@ function system_checkup() { # Check slackpkg.conf version # SLCKCFVL=$( expr length $SLACKCFVERSION ) - if [ "$SLACKCFVERSION" != "$( echo $VERSION |cut -c1-$SLCKCFVL)" ] &&\ + if [ "$SLACKCFVERSION" != "$( echo $VERSION |cut -c1-$SLCKCFVL)" ] && [ "$CMD" != "new-config" ]; then echo -e "\ \nYour slackpkg.conf is outdated. Please, edit it using slackpkg.conf.new\n\ @@ -212,16 +212,16 @@ In ${CONF}/slackpkg.conf.new, there is a sample of the new configuration.\n\ # Checking if another instance of slackpkg is running # - if [ "$(ls /var/lock/slackpkg.* 2>/dev/null)" ] && \ - [ "$CMD" != "search" ] && \ - [ "$CMD" != "help" ] && \ + if [ "$(ls /var/lock/slackpkg.* 2>/dev/null)" ] && + [ "$CMD" != "search" ] && + [ "$CMD" != "help" ] && [ "$CMD" != "file-search" ]; then echo -e "\ \nAnother instance of slackpkg is running. If this is not correct, you can\n\ remove /var/lock/slackpkg.* files and run slackpkg again.\n" cleanup else - ls /var/lock/slackpkg.* &>/dev/null || \ + ls /var/lock/slackpkg.* &>/dev/null || touch /var/lock/slackpkg.$$ fi @@ -323,12 +323,12 @@ to the closest mirror and is very slow.\n" # Checking if the user has the permissions to install/upgrade/update # - if [ "$(id -u)" != "0" ] && \ - [ "$CMD" != "search" ] && \ - [ "$CMD" != "file-search" ] && \ - [ "$CMD" != "check-updates" ] && \ - [ "$CMD" != "show-changelog" ] && \ - [ "$CMD" != "help" ] && \ + if [ "$(id -u)" != "0" ] && + [ "$CMD" != "search" ] && + [ "$CMD" != "file-search" ] && + [ "$CMD" != "check-updates" ] && + [ "$CMD" != "show-changelog" ] && + [ "$CMD" != "help" ] && [ "$CMD" != "info" ]; then echo -e "\n\ Only root can install, upgrade, or remove packages.\n\ @@ -349,9 +349,9 @@ use slackpkg.\n" # if ! [ $(which md5sum 2>/dev/null) ]; then CHECKMD5=off - elif ! [ -f ${WORKDIR}/CHECKSUMS.md5 ] && \ - [ "$CMD" != "update" ] && \ - [ "$CMD" != "new-config" ] && \ + elif ! [ -f ${WORKDIR}/CHECKSUMS.md5 ] && + [ "$CMD" != "update" ] && + [ "$CMD" != "new-config" ] && [ "$CHECKMD5" = "on" ]; then echo -e "\n\ No CHECKSUMS.md5 found! Please disable md5sums checking\n\ @@ -390,15 +390,15 @@ file distributed with slackpkg.\n" # Check if the Slackware GPG key are found in the system # - GPGFIRSTTIME="$(gpg --list-keys \"$SLACKKEY\" 2>/dev/null \ - | grep -c "$SLACKKEY")" - if [ "$GPGFIRSTTIME" = "0" ] && \ - [ "$CMD" != "search" ] && \ - [ "$CMD" != "file-search" ] && \ - [ "$CMD" != "info" ] && \ - [ "$CMD" != "new-config" ] && \ - [ "$CMD" != "update" ] && \ - [ "$CMD" != "check-updates" ] && \ + GPGFIRSTTIME="$(gpg --list-keys \"$SLACKKEY\" 2>/dev/null | + grep -c "$SLACKKEY")" + if [ "$GPGFIRSTTIME" = "0" ] && + [ "$CMD" != "search" ] && + [ "$CMD" != "file-search" ] && + [ "$CMD" != "info" ] && + [ "$CMD" != "new-config" ] && + [ "$CMD" != "update" ] && + [ "$CMD" != "check-updates" ] && [ "$CHECKGPG" = "on" ]; then echo -e "\n\ You need the GPG key of $SLACKKEY.\n\ @@ -503,7 +503,7 @@ escaping: gcc-g\\+\\+" function havespace() { local DSIZE local ASIZE - DSIZE=$(grep "^${1}" ${TMPDIR}/tempsize | \ + DSIZE=$(grep "^${1}" ${TMPDIR}/tempsize | awk 'BEGIN { tot=0 } { tot+=$2 } END { print int(tot/1024)+1}') ASIZE=$(df ${1} | awk '/% \// { print 0+$(NF-2) }') if [ ${DSIZE} -gt ${ASIZE} ] ; then @@ -514,7 +514,7 @@ function havespace() { function checksize() { local i local ISOK=1 - tar -tvf ${1} | tr -s ' ' | grep -v '^[dl]' | cut -f6,3 -d\ | \ + tar -tvf ${1} | tr -s ' ' | grep -v '^[dl]' | cut -f6,3 -d\ | sed 's,[^/]*$,,' | awk ' { size[$2]+=$1 } END { @@ -539,7 +539,7 @@ function checkmd5() { local MD5ORIGINAL local MD5DOWNLOAD - MD5ORIGINAL=$( grep -v "/source/" ${CHECKSUMSFILE} |\ + MD5ORIGINAL=$( grep -v "/source/" ${CHECKSUMSFILE} | grep -m1 "/$(basename $1)$" | cut -f1 -d \ ) MD5DOWNLOAD=$(md5sum ${1} | cut -f1 -d \ ) if [ "$MD5ORIGINAL" = "$MD5DOWNLOAD" ]; then @@ -584,8 +584,8 @@ function givepriority { function listpkgname() { cut -f2 -d\ ${TMPDIR}/pkglist | sort > ${TMPDIR}/spkg cut -f2 -d\ ${TMPDIR}/tmplist | sort > ${TMPDIR}/lpkg - cat ${TMPDIR}/pkglist ${TMPDIR}/tmplist | \ - cut -f2-6 -d\ |sort | uniq -u | \ + cat ${TMPDIR}/pkglist ${TMPDIR}/tmplist | + cut -f2-6 -d\ |sort | uniq -u | cut -f1 -d\ | uniq > ${TMPDIR}/dpkg } @@ -679,18 +679,18 @@ function makelist() { case $CMD in upgrade) - VRFY=$(cut -f6 -d\ ${TMPDIR}/tmplist | \ + VRFY=$(cut -f6 -d\ ${TMPDIR}/tmplist | grep -x "${NAME}-[^-]\+-\(noarch\|fw\|${ARCH}\)-[^-]\+") - [ "${FULLNAME/%.t[blxg]z/}" != "${VRFY}" ] && \ - [ "${VRFY}" ] && \ + [ "${FULLNAME/%.t[blxg]z/}" != "${VRFY}" ] && + [ "${VRFY}" ] && LIST="$LIST ${FULLNAME}" ;; install) - grep -q " ${NAME} " ${TMPDIR}/tmplist || \ + grep -q " ${NAME} " ${TMPDIR}/tmplist || LIST="$LIST ${FULLNAME}" ;; reinstall) - grep -q " ${FULLNAME/%.t[blxg]z} " ${TMPDIR}/tmplist && \ + grep -q " ${FULLNAME/%.t[blxg]z} " ${TMPDIR}/tmplist && LIST="$LIST ${FULLNAME}" ;; esac @@ -699,7 +699,7 @@ function makelist() { ;; remove) for ARGUMENT in $(echo $INPUTLIST); do - for i in $(cat ${TMPDIR}/pkglist ${TMPDIR}/tmplist | \ + for i in $(cat ${TMPDIR}/pkglist ${TMPDIR}/tmplist | grep -w -- "${ARGUMENT}" | cut -f6 -d\ | sort -u); do PKGDATA=( $(grep -w -- "$i" ${TMPDIR}/tmplist) ) [ ! "$PKGDATA" ] && continue @@ -719,20 +719,20 @@ function makelist() { ;; upgrade-all) listpkgname - for i in $(comm -1 -2 ${TMPDIR}/lpkg ${TMPDIR}/dpkg | \ + for i in $(comm -1 -2 ${TMPDIR}/lpkg ${TMPDIR}/dpkg | comm -1 -2 - ${TMPDIR}/spkg) ; do givepriority ${i} [ ! "$FULLNAME" ] && continue VRFY=$(cut -f6 -d\ ${TMPDIR}/tmplist | grep -x "${NAME}-[^-]\+-\(noarch\|fw\|${ARCH}\)-[^-]\+") - [ "${FULLNAME/%.t[blxg]z}" != "${VRFY}" ] && \ - [ "${VRFY}" ] && \ + [ "${FULLNAME/%.t[blxg]z}" != "${VRFY}" ] && + [ "${VRFY}" ] && LIST="$LIST ${FULLNAME}" done ;; install-new) - for i in $(awk -f /usr/libexec/slackpkg/install-new.awk ${WORKDIR}/ChangeLog.txt |\ + for i in $(awk -f /usr/libexec/slackpkg/install-new.awk ${WORKDIR}/ChangeLog.txt | sort -u ) dialog aaa_terminfo fontconfig \ ntfs-3g ghostscript wqy-zenhei-font-ttf \ xbacklight xf86-video-geode ; do @@ -740,7 +740,7 @@ function makelist() { givepriority $i [ ! "$FULLNAME" ] && continue - grep -q " ${NAME} " ${TMPDIR}/tmplist || \ + grep -q " ${NAME} " ${TMPDIR}/tmplist || LIST="$LIST ${FULLNAME}" done ;; @@ -748,7 +748,7 @@ function makelist() { for i in $INPUTLIST ; do givepriority $i [ ! "$FULLNAME" ] && continue - grep -q " ${NAME} " ${TMPDIR}/tmplist || \ + grep -q " ${NAME} " ${TMPDIR}/tmplist || LIST="$LIST ${FULLNAME}" done ;; @@ -756,7 +756,7 @@ function makelist() { for i in $INPUTLIST ; do givepriority $i [ ! "$FULLNAME" ] && continue - grep -q " ${NAME} " ${TMPDIR}/tmplist && \ + grep -q " ${NAME} " ${TMPDIR}/tmplist && LIST="$LIST ${FULLNAME}" done ;; @@ -770,7 +770,7 @@ function makelist() { # Search filelist.gz for possible matches for i in ${PRIORITY[@]}; do if [ -e ${WORKDIR}/${i}-filelist.gz ]; then - PKGS="$(zegrep -w "${INPUTLIST}" ${WORKDIR}/${i}-filelist.gz | \ + PKGS="$(zegrep -w "${INPUTLIST}" ${WORKDIR}/${i}-filelist.gz | cut -d\ -f 1 | awk -F'/' '{print $NF}')" for FULLNAME in $PKGS ; do NAME=$(cutpkg ${FULLNAME}) @@ -847,7 +847,7 @@ function searchlist() { # First is the package already installed? # Amazing what a little sleep will do # exclusion is so much nicer :) - INSTPKG=$(ls -1 $ROOT/var/log/packages/ | \ + INSTPKG=$(ls -1 $ROOT/var/log/packages/ | grep -e "^${BASENAME}-[^-]\+-\(${ARCH}\|fw\|noarch\)-[^-]\+") # INSTPKG is local version @@ -1075,7 +1075,7 @@ Please check your mirror and try again." # echo -e "\t\tList of all files" for i in ${PRIORITY[@]} ; do - getfile ${SOURCE}${i}/MANIFEST.bz2 $TMPDIR/${i}-MANIFEST.bz2 && \ + getfile ${SOURCE}${i}/MANIFEST.bz2 $TMPDIR/${i}-MANIFEST.bz2 && DIRS="$DIRS $i" done @@ -1176,7 +1176,7 @@ Please check your mirror and try again." echo -e "\tFormatting lists to slackpkg style..." echo -e "\t\tPackage List: using $( basename $FILELIST ) as source" grep "\.t[blxg]z$" $FILELIST| \ - awk -f /usr/libexec/slackpkg/pkglist.awk |\ + awk -f /usr/libexec/slackpkg/pkglist.awk | sed -e 's/^M//g' > ${TMPDIR}/pkglist cp ${TMPDIR}/pkglist ${WORKDIR}/pkglist @@ -1239,7 +1239,7 @@ function sanity_check() { [ "$SPINNING" = "off" ] || spinning ${TMPDIR}/waiting & - for i in $(ls -1 $ROOT/var/log/packages/ | \ + for i in $(ls -1 $ROOT/var/log/packages/ | egrep -- "^.*-(${ARCH}|fw|noarch)-[^-]+-upgraded"); do REVNAME=$(echo ${i} | awk -F'-upgraded' '{ print $1 }') mv $ROOT/var/log/packages/${i} $ROOT/var/log/packages/${REVNAME} @@ -1381,18 +1381,18 @@ generate_template() { [ "$SPINNING" = "off" ] || spinning ${TMPDIR}/waiting & for i in $ROOT/var/log/packages/* ; do PKGNAME=$( cutpkg $(basename $i)) - grep -q " $PKGNAME " ${WORKDIR}/pkglist && \ + grep -q " $PKGNAME " ${WORKDIR}/pkglist && echo $PKGNAME >> $TMPDIR/$TEMPLATE.work done rm $TMPDIR/waiting echo " " echo -e "\tGenerating $TEMPLATE " - for TMPLATE in $( wc -l $TMPDIR/* | sort -r | \ + for TMPLATE in $( wc -l $TMPDIR/* | sort -r | awk -F/ '/template.tmp/ { print $NF }'); do if ! $( grep -q "^#include.*${TMPLATE/.tmp/}" \ $TMPDIR/allheaders) ; then - diff -y $TMPDIR/$TEMPLATE.work $TMPDIR/$TMPLATE | \ + diff -y $TMPDIR/$TEMPLATE.work $TMPDIR/$TMPLATE | awk -vTMPDIR=$TMPDIR \ '!/ TMPDIR"/same" } / TMPDIR"/notsame" }' @@ -1415,6 +1415,6 @@ generate_template() { if [ -e $TMPDIR/$TEMPLATE.header ]; then cat $TMPDIR/$TEMPLATE.header > $TEMPLATEDIR/$TEMPLATE fi - diff $TMPDIR/alluniqfiles $TMPDIR/$TEMPLATE.work |\ + diff $TMPDIR/alluniqfiles $TMPDIR/$TEMPLATE.work | awk '/>/ { print $2 }' >> $TEMPLATEDIR/$TEMPLATE } -- cgit v1.2.3