mirror of
https://github.com/moparisthebest/pacman
synced 2025-01-09 04:57:59 -05:00
makepkg, repo-add: replace external commands with bash substitutions where possible
This also removes the awk dependency from makepkg and repo-add. Signed-off-by: Cedric Staniewski <cedric@gmx.ca> Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
4281a1a7f2
commit
3d67d9b16c
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
# makepkg uses quite a few external programs during its execution. You
|
# makepkg uses quite a few external programs during its execution. You
|
||||||
# need to have at least the following installed for makepkg to function:
|
# 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
|
# getopt (util-linux), gettext, grep, gzip, openssl, sed
|
||||||
|
|
||||||
# gettext initialization
|
# gettext initialization
|
||||||
@ -188,15 +188,15 @@ trap 'trap_exit "$(gettext "An unknown error has occurred. Exiting...")"' ERR
|
|||||||
# extract the filename from a source entry
|
# extract the filename from a source entry
|
||||||
get_filename() {
|
get_filename() {
|
||||||
# if a filename is specified, use it
|
# 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
|
# 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
|
# extract the URL from a source entry
|
||||||
get_url() {
|
get_url() {
|
||||||
# strip an eventual filename
|
# strip an eventual filename
|
||||||
echo $1 | sed 's|.*::||'
|
echo "${1#*::}"
|
||||||
}
|
}
|
||||||
|
|
||||||
##
|
##
|
||||||
@ -246,11 +246,11 @@ check_buildenv() {
|
|||||||
# ? - not found
|
# ? - not found
|
||||||
##
|
##
|
||||||
in_opt_array() {
|
in_opt_array() {
|
||||||
local needle=$(echo $1 | tr '[:upper:]' '[:lower:]'); shift
|
local needle="${1,,}"; shift
|
||||||
|
|
||||||
local opt
|
local opt
|
||||||
for opt in "$@"; do
|
for opt in "$@"; do
|
||||||
opt=$(echo $opt | tr '[:upper:]' '[:lower:]')
|
opt="${opt,,}"
|
||||||
if [ "$opt" = "$needle" ]; then
|
if [ "$opt" = "$needle" ]; then
|
||||||
echo 'y' # Enabled
|
echo 'y' # Enabled
|
||||||
return
|
return
|
||||||
@ -282,14 +282,14 @@ in_array() {
|
|||||||
get_downloadclient() {
|
get_downloadclient() {
|
||||||
# $1 = URL with valid protocol prefix
|
# $1 = URL with valid protocol prefix
|
||||||
local url=$1
|
local url=$1
|
||||||
local proto=$(echo "$url" | sed 's|://.*||')
|
local proto="${url%%://*}"
|
||||||
|
|
||||||
# loop through DOWNLOAD_AGENTS variable looking for protocol
|
# loop through DOWNLOAD_AGENTS variable looking for protocol
|
||||||
local i
|
local i
|
||||||
for i in "${DLAGENTS[@]}"; do
|
for i in "${DLAGENTS[@]}"; do
|
||||||
local handler=$(echo $i | sed 's|::.*||')
|
local handler="${i%%::*}"
|
||||||
if [ "$proto" = "$handler" ]; then
|
if [ "$proto" = "$handler" ]; then
|
||||||
agent=$(echo $i | sed 's|^.*::||')
|
agent="${i##*::}"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@ -302,7 +302,7 @@ get_downloadclient() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# ensure specified program is installed
|
# ensure specified program is installed
|
||||||
local program="$(echo $agent | awk '{print $1 }')"
|
local program="${agent%% *}"
|
||||||
if [ ! -x "$program" ]; then
|
if [ ! -x "$program" ]; then
|
||||||
local baseprog=$(basename $program)
|
local baseprog=$(basename $program)
|
||||||
error "$(gettext "The download program %s is not installed.")" "$baseprog"
|
error "$(gettext "The download program %s is not installed.")" "$baseprog"
|
||||||
@ -321,7 +321,7 @@ download_file() {
|
|||||||
# destination file
|
# destination file
|
||||||
local file=$3
|
local file=$3
|
||||||
# temporary download file, default to last component of the URL
|
# 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
|
# replace %o by the temporary dlfile if it exists
|
||||||
if echo "$dlcmd" | grep -q "%o" ; then
|
if echo "$dlcmd" | grep -q "%o" ; then
|
||||||
@ -431,7 +431,7 @@ remove_deps() {
|
|||||||
local dep depstrip deplist
|
local dep depstrip deplist
|
||||||
deplist=""
|
deplist=""
|
||||||
for dep in $pkgdeps; do
|
for dep in $pkgdeps; do
|
||||||
depstrip=$(echo $dep | sed -e 's|=.*$||' -e 's|>.*$||' -e 's|<.*$||')
|
depstrip="${dep%%[<=>]*}"
|
||||||
deplist="$deplist $depstrip"
|
deplist="$deplist $depstrip"
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -513,7 +513,7 @@ generate_checksums() {
|
|||||||
|
|
||||||
local integ
|
local integ
|
||||||
for integ in ${INTEGRITY_CHECK[@]}; do
|
for integ in ${INTEGRITY_CHECK[@]}; do
|
||||||
integ="$(echo $integ | tr '[:upper:]' '[:lower:]')"
|
integ="${integ,,}"
|
||||||
case "$integ" in
|
case "$integ" in
|
||||||
md5|sha1|sha256|sha384|sha512) : ;;
|
md5|sha1|sha256|sha384|sha512) : ;;
|
||||||
*)
|
*)
|
||||||
@ -546,7 +546,8 @@ generate_checksums() {
|
|||||||
fi
|
fi
|
||||||
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"
|
[ $ct -gt 0 ] && echo -n "$indent"
|
||||||
echo -n "'$sum'"
|
echo -n "'$sum'"
|
||||||
ct=$(($ct+1))
|
ct=$(($ct+1))
|
||||||
@ -591,8 +592,9 @@ check_checksums() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $found -gt 0 ] ; then
|
if [ $found -gt 0 ] ; then
|
||||||
local expectedsum="$(echo ${integrity_sums[$idx]} | tr '[A-F]' '[a-f]')"
|
local expectedsum="${integrity_sums[$idx],,}"
|
||||||
local realsum="$(openssl dgst -${integ} "$file" | awk '{print $NF}')"
|
local realsum="$(openssl dgst -${integ} "$file")"
|
||||||
|
realsum="${realsum##* }"
|
||||||
if [ "$expectedsum" = "$realsum" ]; then
|
if [ "$expectedsum" = "$realsum" ]; then
|
||||||
echo "$(gettext "Passed")" >&2
|
echo "$(gettext "Passed")" >&2
|
||||||
else
|
else
|
||||||
@ -882,7 +884,8 @@ write_pkginfo() {
|
|||||||
else
|
else
|
||||||
local packager="Unknown Packager"
|
local packager="Unknown Packager"
|
||||||
fi
|
fi
|
||||||
local size=$(du -sk | awk '{print $1 * 1024}')
|
local size="$(du -sk)"
|
||||||
|
size="$(( ${size%%[^0-9]*} * 1024 ))"
|
||||||
|
|
||||||
msg2 "$(gettext "Generating .PKGINFO file...")"
|
msg2 "$(gettext "Generating .PKGINFO file...")"
|
||||||
echo "# Generated by makepkg $myver" >.PKGINFO
|
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 " Are you sure you wish to do this? ")"
|
||||||
echo -n "$(gettext "[Y/n]")"
|
echo -n "$(gettext "[Y/n]")"
|
||||||
read answer
|
read answer
|
||||||
answer=$(echo $answer | tr '[:lower:]' '[:upper:]')
|
answer="${answer^^}"
|
||||||
if [ "$answer" = "$(gettext "YES")" -o "$answer" = "$(gettext "Y")" ]; then
|
if [ "$answer" = "$(gettext "YES")" -o "$answer" = "$(gettext "Y")" ]; then
|
||||||
rm "$SRCDEST"/*
|
rm "$SRCDEST"/*
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
|
@ -136,7 +136,8 @@ db_write_delta()
|
|||||||
echo -e "%DELTAS%" >>$deltas
|
echo -e "%DELTAS%" >>$deltas
|
||||||
fi
|
fi
|
||||||
# get md5sum and compressed size of package
|
# 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")
|
csize=$(@SIZECMD@ "$deltafile")
|
||||||
|
|
||||||
oldfile=$(xdelta3 printhdr $deltafile | grep "XDELTA filename (source)" | sed 's/.*: *//')
|
oldfile=$(xdelta3 printhdr $deltafile | grep "XDELTA filename (source)" | sed 's/.*: *//')
|
||||||
@ -213,7 +214,8 @@ db_write_entry()
|
|||||||
IFS=$OLDIFS
|
IFS=$OLDIFS
|
||||||
|
|
||||||
# get md5sum and compressed size of package
|
# 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")
|
csize=$(@SIZECMD@ "$pkgfile")
|
||||||
|
|
||||||
# ensure $pkgname and $pkgver variables were found
|
# ensure $pkgname and $pkgver variables were found
|
||||||
|
Loading…
Reference in New Issue
Block a user