Code clean up part 3
- avoid double quotes where possible - replace 'echo ""' with 'echo' - remove "useless use of cat" - "awk" statement refactoring
This commit is contained in:
parent
54d23fc0dc
commit
041bc88276
35
apt-cyg
35
apt-cyg
|
@ -60,10 +60,10 @@ function usage()
|
||||||
|
|
||||||
function version()
|
function version()
|
||||||
{
|
{
|
||||||
echo "apt-cyg version 0.59"
|
echo 'apt-cyg version 0.59'
|
||||||
echo "Written by Stephen Jungels"
|
echo 'Written by Stephen Jungels'
|
||||||
echo ""
|
echo
|
||||||
echo "Copyright (c) 2005-9 Stephen Jungels. Released under the GPL."
|
echo 'Copyright (c) 2005-9 Stephen Jungels. Released under the GPL.'
|
||||||
}
|
}
|
||||||
|
|
||||||
function findworkspace()
|
function findworkspace()
|
||||||
|
@ -299,7 +299,7 @@ case "$command" in
|
||||||
else print "Package not found"
|
else print "Package not found"
|
||||||
}
|
}
|
||||||
' RS='\n\n@ ' FS='\n' package="$pkg" setup.ini > "release/$pkg/desc"
|
' RS='\n\n@ ' FS='\n' package="$pkg" setup.ini > "release/$pkg/desc"
|
||||||
desc=`cat "release/$pkg/desc"`
|
desc=$(<"release/$pkg/desc")
|
||||||
if test "-$desc-" = "-Package not found-"
|
if test "-$desc-" = "-Package not found-"
|
||||||
then
|
then
|
||||||
echo Package $pkg not found or ambiguous name, exiting
|
echo Package $pkg not found or ambiguous name, exiting
|
||||||
|
@ -311,7 +311,7 @@ case "$command" in
|
||||||
# download and unpack the bz2 or xz file
|
# download and unpack the bz2 or xz file
|
||||||
|
|
||||||
# pick the latest version, which comes first
|
# pick the latest version, which comes first
|
||||||
install=`cat "release/$pkg/desc" | awk '/^install: / { print $2; exit }'`
|
install=$(awk '/^install: / {print $2; exit}' "release/$pkg/desc")
|
||||||
|
|
||||||
if test "-$install-" = "--"
|
if test "-$install-" = "--"
|
||||||
then
|
then
|
||||||
|
@ -324,8 +324,8 @@ case "$command" in
|
||||||
wget -nc $mirror/$install
|
wget -nc $mirror/$install
|
||||||
|
|
||||||
# check the md5
|
# check the md5
|
||||||
digest=`cat "desc" | awk '/^install: / { print $4; exit }'`
|
digest=$(awk '/^install: / {print $4; exit}' desc)
|
||||||
digactual=`md5sum $file | awk '{print $1}'`
|
digactual=$(md5sum $file | awk NF=1)
|
||||||
if ! test $digest = $digactual
|
if ! test $digest = $digactual
|
||||||
then
|
then
|
||||||
echo MD5 sum did not match, exiting
|
echo MD5 sum did not match, exiting
|
||||||
|
@ -333,13 +333,7 @@ case "$command" in
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Unpacking..."
|
echo "Unpacking..."
|
||||||
# determine file type
|
tar xvf $file -C / > "/etc/setup/$pkg.lst"
|
||||||
if [ "${file##*.}" == "xz" ]
|
|
||||||
then
|
|
||||||
cat $file | tar xvJf - -C / > "/etc/setup/$pkg.lst"
|
|
||||||
else
|
|
||||||
cat $file | bunzip2 | tar xvf - -C / > "/etc/setup/$pkg.lst"
|
|
||||||
fi
|
|
||||||
gzip -f "/etc/setup/$pkg.lst"
|
gzip -f "/etc/setup/$pkg.lst"
|
||||||
cd ../..
|
cd ../..
|
||||||
|
|
||||||
|
@ -360,8 +354,12 @@ case "$command" in
|
||||||
|
|
||||||
# recursively install required packages
|
# recursively install required packages
|
||||||
|
|
||||||
echo '/^requires: / {s=gensub("(requires: )?([^ ]+) ?", "\\2 ", "g", $0); print s}' > /tmp/awk.$$
|
requires=$(awk '
|
||||||
requires=`cat "release/$pkg/desc" | awk -f /tmp/awk.$$`
|
$0 ~ rq {
|
||||||
|
sub(rq, "")
|
||||||
|
print
|
||||||
|
}
|
||||||
|
' rq='^requires: ' "release/$pkg/desc")
|
||||||
warn=0
|
warn=0
|
||||||
if ! test "-$requires-" = "--"
|
if ! test "-$requires-" = "--"
|
||||||
then
|
then
|
||||||
|
@ -435,7 +433,8 @@ case "$command" in
|
||||||
"/etc/preremove/$pkg.sh"
|
"/etc/preremove/$pkg.sh"
|
||||||
rm "/etc/preremove/$pkg.sh"
|
rm "/etc/preremove/$pkg.sh"
|
||||||
fi
|
fi
|
||||||
cat "/etc/setup/$pkg.lst.gz" | gzip -d | awk '/[^\/]$/ {print "rm -f \"/" $0 "\""}' | sh
|
gzip -cd "/etc/setup/$pkg.lst.gz" |
|
||||||
|
awk '/[^\/]$/ {print "rm -f \"/" $0 "\""}' | sh
|
||||||
rm "/etc/setup/$pkg.lst.gz"
|
rm "/etc/setup/$pkg.lst.gz"
|
||||||
rm -f /etc/postinstall/$pkg.sh.done
|
rm -f /etc/postinstall/$pkg.sh.done
|
||||||
awk '$1 != pkg' pkg="$pkg" /etc/setup/installed.db > /tmp/awk.$$
|
awk '$1 != pkg' pkg="$pkg" /etc/setup/installed.db > /tmp/awk.$$
|
||||||
|
|
Loading…
Reference in New Issue