summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--scripts/makepkg.sh.in39
-rw-r--r--scripts/repo-add.sh.in6
2 files changed, 25 insertions, 20 deletions
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 24fddf69..c48bb343 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -27,7 +27,7 @@
# makepkg uses quite a few external programs during its execution. You
# need to have at least the following installed for makepkg to function:
-# awk, bsdtar (libarchive), bzip2, coreutils, fakeroot, find (findutils),
+# bsdtar (libarchive), bzip2, coreutils, fakeroot, find (findutils),
# getopt (util-linux), gettext, grep, gzip, openssl, sed
# gettext initialization
@@ -188,15 +188,15 @@ trap 'trap_exit "$(gettext "An unknown error has occurred. Exiting...")"' ERR
# extract the filename from a source entry
get_filename() {
# if a filename is specified, use it
- local filename=$(echo $1 | sed 's|::.*||')
+ local filename="${1%%::*}"
# if it is just an URL, we only keep the last component
- echo "$filename" | sed 's|^.*://.*/||g'
+ echo "${filename##*/}"
}
# extract the URL from a source entry
get_url() {
# strip an eventual filename
- echo $1 | sed 's|.*::||'
+ echo "${1#*::}"
}
##
@@ -246,11 +246,11 @@ check_buildenv() {
# ? - not found
##
in_opt_array() {
- local needle=$(echo $1 | tr '[:upper:]' '[:lower:]'); shift
+ local needle="${1,,}"; shift
local opt
for opt in "$@"; do
- opt=$(echo $opt | tr '[:upper:]' '[:lower:]')
+ opt="${opt,,}"
if [ "$opt" = "$needle" ]; then
echo 'y' # Enabled
return
@@ -282,14 +282,14 @@ in_array() {
get_downloadclient() {
# $1 = URL with valid protocol prefix
local url=$1
- local proto=$(echo "$url" | sed 's|://.*||')
+ local proto="${url%%://*}"
# loop through DOWNLOAD_AGENTS variable looking for protocol
local i
for i in "${DLAGENTS[@]}"; do
- local handler=$(echo $i | sed 's|::.*||')
+ local handler="${i%%::*}"
if [ "$proto" = "$handler" ]; then
- agent=$(echo $i | sed 's|^.*::||')
+ agent="${i##*::}"
break
fi
done
@@ -302,7 +302,7 @@ get_downloadclient() {
fi
# ensure specified program is installed
- local program="$(echo $agent | awk '{print $1 }')"
+ local program="${agent%% *}"
if [ ! -x "$program" ]; then
local baseprog=$(basename $program)
error "$(gettext "The download program %s is not installed.")" "$baseprog"
@@ -321,7 +321,7 @@ download_file() {
# destination file
local file=$3
# temporary download file, default to last component of the URL
- local dlfile=$(echo "$url" | sed 's|^.*://.*/||g')
+ local dlfile="${url##*/}"
# replace %o by the temporary dlfile if it exists
if echo "$dlcmd" | grep -q "%o" ; then
@@ -431,7 +431,7 @@ remove_deps() {
local dep depstrip deplist
deplist=""
for dep in $pkgdeps; do
- depstrip=$(echo $dep | sed -e 's|=.*$||' -e 's|>.*$||' -e 's|<.*$||')
+ depstrip="${dep%%[<=>]*}"
deplist="$deplist $depstrip"
done
@@ -513,7 +513,7 @@ generate_checksums() {
local integ
for integ in ${INTEGRITY_CHECK[@]}; do
- integ="$(echo $integ | tr '[:upper:]' '[:lower:]')"
+ integ="${integ,,}"
case "$integ" in
md5|sha1|sha256|sha384|sha512) : ;;
*)
@@ -546,7 +546,8 @@ generate_checksums() {
fi
fi
- local sum="$(openssl dgst -${integ} "$file" | awk '{print $NF}')"
+ local sum="$(openssl dgst -${integ} "$file")"
+ sum=${sum##* }
[ $ct -gt 0 ] && echo -n "$indent"
echo -n "'$sum'"
ct=$(($ct+1))
@@ -591,8 +592,9 @@ check_checksums() {
fi
if [ $found -gt 0 ] ; then
- local expectedsum="$(echo ${integrity_sums[$idx]} | tr '[A-F]' '[a-f]')"
- local realsum="$(openssl dgst -${integ} "$file" | awk '{print $NF}')"
+ local expectedsum="${integrity_sums[$idx],,}"
+ local realsum="$(openssl dgst -${integ} "$file")"
+ realsum="${realsum##* }"
if [ "$expectedsum" = "$realsum" ]; then
echo "$(gettext "Passed")" >&2
else
@@ -882,7 +884,8 @@ write_pkginfo() {
else
local packager="Unknown Packager"
fi
- local size=$(du -sk | awk '{print $1 * 1024}')
+ local size="$(du -sk)"
+ size="$(( ${size%%[^0-9]*} * 1024 ))"
msg2 "$(gettext "Generating .PKGINFO file...")"
echo "# Generated by makepkg $myver" >.PKGINFO
@@ -1588,7 +1591,7 @@ if [ "$CLEANCACHE" -eq 1 ]; then
echo -n "$(gettext " Are you sure you wish to do this? ")"
echo -n "$(gettext "[Y/n]")"
read answer
- answer=$(echo $answer | tr '[:lower:]' '[:upper:]')
+ answer="${answer^^}"
if [ "$answer" = "$(gettext "YES")" -o "$answer" = "$(gettext "Y")" ]; then
rm "$SRCDEST"/*
if [ $? -ne 0 ]; then
diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in
index 2a62d2ba..3f00441a 100644
--- a/scripts/repo-add.sh.in
+++ b/scripts/repo-add.sh.in
@@ -136,7 +136,8 @@ db_write_delta()
echo -e "%DELTAS%" >>$deltas
fi
# get md5sum and compressed size of package
- md5sum="$(openssl dgst -md5 "$deltafile" | awk '{print $NF}')"
+ md5sum="$(openssl dgst -md5 "$deltafile")"
+ md5sum="${md5sum##* }"
csize=$(@SIZECMD@ "$deltafile")
oldfile=$(xdelta3 printhdr $deltafile | grep "XDELTA filename (source)" | sed 's/.*: *//')
@@ -213,7 +214,8 @@ db_write_entry()
IFS=$OLDIFS
# get md5sum and compressed size of package
- md5sum="$(openssl dgst -md5 "$pkgfile" | awk '{print $NF}')"
+ md5sum="$(openssl dgst -md5 "$pkgfile")"
+ md5sum="${md5sum##* }"
csize=$(@SIZECMD@ "$pkgfile")
# ensure $pkgname and $pkgver variables were found