xbps-src: reduce basename(1) usage.

This saves a few exec()s.
This commit is contained in:
Juan RP 2019-04-13 13:43:07 +02:00 committed by maxice8
parent 64061588fc
commit 1ee6a3174f
5 changed files with 19 additions and 13 deletions

View File

@ -5,7 +5,8 @@ do_extract() {
mkdir -p ${wrksrc}
for f in ${distfiles}; do
curfile=$(basename "${f#*>}")
curfile="${f#*>}"
curfile="${curfile##*/}"
cp ${XBPS_SRCDISTDIR}/${pkgname}-${version}/${curfile} ${wrksrc}/${curfile}
done
}

View File

@ -3,6 +3,7 @@
hook() {
local srcdir="$XBPS_SRCDISTDIR/$pkgname-$version"
local f j curfile found extractdir
if [ -z "$distfiles" -a -z "$checksum" ]; then
mkdir -p $wrksrc
@ -11,7 +12,8 @@ hook() {
# Check that distfiles are there before anything else.
for f in ${distfiles}; do
curfile=$(basename "${f#*>}")
curfile="${f#*>}"
curfile="${curfile##*/}"
if [ ! -f $srcdir/$curfile ]; then
msg_error "$pkgver: cannot find ${curfile}, use 'xbps-src fetch' first.\n"
fi
@ -24,7 +26,8 @@ hook() {
msg_normal "$pkgver: extracting distfile(s), please wait...\n"
for f in ${distfiles}; do
curfile=$(basename "${f#*>}")
curfile="${f#*>}"
curfile="${curfile##*/}"
for j in ${skip_extraction}; do
if [ "$curfile" = "$j" ]; then
found=1
@ -122,7 +125,7 @@ hook() {
fi
;;
gem)
tar -xOf $srcdir/$curfile data.tar.gz | tar -xz -C $extractdir --transform="s,^,$(basename $wrksrc)/,"
tar -xOf $srcdir/$curfile data.tar.gz | tar -xz -C $extractdir --transform="s,^,${wrksrc##*/}/,"
if [ $? -ne 0 ]; then
msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
fi

View File

@ -212,8 +212,10 @@ hook() {
# Detect distfiles with obsolete checksum and purge them from the cache
for f in ${distfiles}; do
curfile=$(basename "${f#*>}")
curfile="${f#*>}"
curfile="${curfile##*/}"
distfile="$srcdir/$curfile"
if [ -f "$distfile" ]; then
cksum=$(get_cksum $curfile $dfcount)
if [ "${cksum:0:1}" = "@" ]; then
@ -239,7 +241,8 @@ hook() {
# Download missing distfiles and verify their checksums
dfcount=0
for f in ${distfiles}; do
curfile=$(basename "${f#*>}")
curfile="${f#*>}"
curfile="${curfile##*/}"
distfile="$srcdir/$curfile"
# If file lock cannot be acquired wait until it's available.

View File

@ -99,7 +99,8 @@ show_pkg_build_depends() {
_pkgname="$f"
fi
_pkgname=${_pkgname/-32bit}
_srcpkg=$(basename $(readlink -f ${XBPS_SRCPKGDIR}/${_pkgname}))
_srcpkg=$(readlink -f ${XBPS_SRCPKGDIR}/${_pkgname})
_srcpkg=${_srcpkg##*/}
echo "${_srcpkg}" >> $result
done
sort -u $result

View File

@ -1,6 +1,8 @@
#!/bin/bash
# vim: set ts=4 sw=4 et:
readonly PROGNAME="${0##*/}"
print_cross_targets() {
local f
for f in common/cross-profiles/*.sh; do
@ -10,7 +12,7 @@ print_cross_targets() {
usage() {
cat << _EOF
$(basename $0): [options] <target> [arguments]
$PROGNAME: [options] <target> [arguments]
Targets: (only one may be specified)
@ -380,14 +382,10 @@ exit_func() {
exit 2
}
basename_cwd() {
echo $(basename $(pwd))
}
read_pkg() {
if [ -z "${XBPS_TARGET_PKG}" ]; then
[ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
XBPS_TARGET_PKG=$(basename_cwd)
XBPS_TARGET_PKG=${PWD##*/}
fi
setup_pkg "$XBPS_TARGET_PKG" "$XBPS_CROSS_BUILD" "$1"
}