xbps-src: replace basename(1) with ${var##*/}.
Reduce number of fork+exec due to using a subshell to execute basename(1).
This commit is contained in:
parent
ea9c012c04
commit
bcdacb66a0
20 changed files with 28 additions and 23 deletions
|
@ -147,9 +147,9 @@ _vinstall() {
|
|||
fi
|
||||
|
||||
if [ -z "$targetfile" ]; then
|
||||
install -Dm${mode} ${file} "${_destdir}/${targetdir}/$(basename ${file})"
|
||||
install -Dm${mode} ${file} "${_destdir}/${targetdir}/${file##*/}"
|
||||
else
|
||||
install -Dm${mode} ${file} "${_destdir}/${targetdir}/$(basename ${targetfile})"
|
||||
install -Dm${mode} ${file} "${_destdir}/${targetdir}/${targetfile##*/}"
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ try_mirrors() {
|
|||
local curfile="$1" distfile="$2" dfcount="$3" subdir="$4" f="$5"
|
||||
local filesum cksum basefile mirror path scheme
|
||||
[ -z "$XBPS_DISTFILES_MIRROR" ] && return
|
||||
basefile="$(basename $f)"
|
||||
basefile="${f##*/}"
|
||||
cksum=$(get_cksum $curfile $dfcount)
|
||||
for mirror in $XBPS_DISTFILES_MIRROR; do
|
||||
scheme="file"
|
||||
|
|
|
@ -4,7 +4,8 @@ _process_patch() {
|
|||
local _args= _patch= i=$1
|
||||
|
||||
_args="-Np0"
|
||||
_patch=$(basename $i)
|
||||
_patch=${i##*/}
|
||||
|
||||
if [ -f $PATCHESDIR/${_patch}.args ]; then
|
||||
_args=$(cat $PATCHESDIR/${_patch}.args)
|
||||
elif [ -n "$patch_args" ]; then
|
||||
|
|
|
@ -32,7 +32,7 @@ hook() {
|
|||
if [ -h ${PKGDESTDIR}/"$j" ]; then
|
||||
dirat=$(dirname "$j")
|
||||
lnkat=$(readlink ${PKGDESTDIR}/"$j")
|
||||
newlnk=$(basename "$j")
|
||||
newlnk="${j##*/}"
|
||||
rm -f ${PKGDESTDIR}/"$j"
|
||||
cd ${PKGDESTDIR}/"$dirat"
|
||||
ln -s "${lnkat}".gz "${newlnk}".gz
|
||||
|
|
|
@ -205,7 +205,7 @@ _EOF
|
|||
if [ -d ${PKGDESTDIR}/usr/share/gconf/schemas ]; then
|
||||
_add_trigger gconf-schemas
|
||||
for f in ${PKGDESTDIR}/usr/share/gconf/schemas/*.schemas; do
|
||||
_schemas="${_schemas} $(basename $f)"
|
||||
_schemas="${_schemas} ${f##*/}"
|
||||
done
|
||||
echo "export gconf_schemas=\"${_schemas}\"" >> $tmpf
|
||||
fi
|
||||
|
|
|
@ -8,7 +8,7 @@ make_debug() {
|
|||
[ -n "$nodebug" ] && return 0
|
||||
|
||||
dname=$(echo "$(dirname $1)"|sed -e "s|${PKGDESTDIR}||g")
|
||||
fname="$(basename $1)"
|
||||
fname="${1##*/}"
|
||||
dbgfile="${dname}/${fname}"
|
||||
|
||||
mkdir -p "${PKGDESTDIR}/usr/lib/debug/${dname}"
|
||||
|
@ -27,7 +27,7 @@ attach_debug() {
|
|||
[ -n "$nodebug" ] && return 0
|
||||
|
||||
dname=$(echo "$(dirname $1)"|sed -e "s|${PKGDESTDIR}||g")
|
||||
fname="$(basename $1)"
|
||||
fname="${1##*/}"
|
||||
dbgfile="${dname}/${fname}"
|
||||
|
||||
$OBJCOPY --add-gnu-debuglink="${PKGDESTDIR}/usr/lib/debug/${dbgfile}" "$1"
|
||||
|
@ -69,7 +69,7 @@ hook() {
|
|||
continue
|
||||
fi
|
||||
|
||||
fname=$(basename "$f")
|
||||
fname=${f##*/}
|
||||
for x in ${nostrip_files}; do
|
||||
if [ "$x" = "$fname" ]; then
|
||||
found=1
|
||||
|
|
|
@ -79,8 +79,12 @@ _EOF
|
|||
}
|
||||
|
||||
install_wrappers() {
|
||||
local fname
|
||||
|
||||
for f in ${XBPS_COMMONDIR}/wrappers/*.sh; do
|
||||
install -m0755 ${f} ${XBPS_WRAPPERDIR}/$(basename ${f%.sh})
|
||||
fname=${f##*/}
|
||||
fname=${fname%.sh}
|
||||
install -m0755 ${f} ${XBPS_WRAPPERDIR}/${fname}
|
||||
done
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ collect_sonames() {
|
|||
|
||||
# real pkg
|
||||
find ${_destdir} -type f -name "*.so*" | while read f; do
|
||||
_fname=$(basename "$f")
|
||||
_fname="${f##*/}"
|
||||
case "$(file -bi "$f")" in
|
||||
application/x-sharedlib*)
|
||||
# shared library
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
# $5 - internal [OPTIONAL]
|
||||
|
||||
if [ $# -lt 3 -o $# -gt 5 ]; then
|
||||
echo "$(basename $0): invalid number of arguments: pkgname targetpkg target [cross-target]"
|
||||
echo "${0##*/}: invalid number of arguments: pkgname targetpkg target [cross-target]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
# $2 - cross target [OPTIONAL]
|
||||
|
||||
if [ $# -lt 1 -o $# -gt 2 ]; then
|
||||
echo "$(basename $0): invalid number of arguments: pkgname [cross-target]"
|
||||
echo "${0##*/}: invalid number of arguments: pkgname [cross-target]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
# $2 - cross target [OPTIONAL]
|
||||
|
||||
if [ $# -lt 1 -o $# -gt 2 ]; then
|
||||
echo "$(basename $0): invalid number of arguments: pkgname [cross-target]"
|
||||
echo "${0##*/}: invalid number of arguments: pkgname [cross-target]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
# $2 - cross target [OPTIONAL]
|
||||
|
||||
if [ $# -lt 1 -o $# -gt 2 ]; then
|
||||
echo "$(basename $0): invalid number of arguments: pkgname [cross-target]"
|
||||
echo "${0##*/}: invalid number of arguments: pkgname [cross-target]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
# $2 - cross target [OPTIONAL]
|
||||
|
||||
if [ $# -lt 1 -o $# -gt 2 ]; then
|
||||
echo "$(basename $0): invalid number of arguments: pkgname [cross-target]"
|
||||
echo "${0##*/}: invalid number of arguments: pkgname [cross-target]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
# $2 - cross target [OPTIONAL]
|
||||
|
||||
if [ $# -lt 1 -o $# -gt 2 ]; then
|
||||
echo "$(basename $0): invalid number of arguments: pkgname [cross-target]"
|
||||
echo "${0##*/}: invalid number of arguments: pkgname [cross-target]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
# $3 - cross-target [OPTIONAL]
|
||||
|
||||
if [ $# -lt 2 -o $# -gt 3 ]; then
|
||||
echo "$(basename $0): invalid number of arguments: pkgname repository [cross-target]"
|
||||
echo "${0##*/}: invalid number of arguments: pkgname repository [cross-target]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
# $2 - cross target [OPTIONAL]
|
||||
|
||||
if [ $# -lt 1 -o $# -gt 2 ]; then
|
||||
echo "$(basename $0): invalid number of arguments: pkgname [cross-target]"
|
||||
echo "${0##*/}: invalid number of arguments: pkgname [cross-target]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# vim: set ts=4 sw=4 et:
|
||||
|
||||
bulk_getlink() {
|
||||
local p="$(basename $1)"
|
||||
local p="${1##*/}"
|
||||
local target="$(readlink $XBPS_SRCPKGDIR/$p)"
|
||||
|
||||
if [ $? -eq 0 -a -n "$target" ]; then
|
||||
|
|
|
@ -182,7 +182,7 @@ run_pkg_hooks() {
|
|||
eval unset -f hook
|
||||
for f in ${XBPS_COMMONDIR}/hooks/${phase}/*.sh; do
|
||||
[ ! -r $f ] && continue
|
||||
hookn=$(basename $f)
|
||||
hookn=${f##*/}
|
||||
hookn=${hookn%.sh}
|
||||
. $f
|
||||
run_func hook "$phase hook: $hookn" ${phase}_${hookn}
|
||||
|
|
|
@ -75,7 +75,7 @@ purge_distfiles() {
|
|||
hashes=($XBPS_SRCDISTDIR/by_sha256/*)
|
||||
readonly HASHLEN=64
|
||||
for file in ${hashes[@]}; do
|
||||
hash_distfile=$(basename "$file")
|
||||
hash_distfile=${file##*/}
|
||||
hash=${hash_distfile:0:$HASHLEN}
|
||||
[ -n "${my_hashes[$hash]}" ] && continue
|
||||
inode=$(stat "$file" --printf "%i")
|
||||
|
|
|
@ -6,7 +6,7 @@ update_hash_cache() {
|
|||
mkdir -p "$cache"
|
||||
find "$XBPS_SRCDISTDIR" -type f | grep -v by_sha256 | while read -r distfile; do
|
||||
cksum=$(cat "$distfile" | sha256sum | cut -d " " -f 1)
|
||||
curfile="$(basename ${distfile})"
|
||||
curfile="${distfile##*/}"
|
||||
ln -vf "$distfile" "${cache}/${cksum}_${curfile}"
|
||||
done
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue