[pacman-dev] [PATCH 1/3] Add --with-bsdtar-bin configure option
Nezmer
git at nezmer.info
Thu Oct 14 16:57:00 EDT 2010
On Thu, Oct 14, 2010 at 04:56:17PM +0300, Nezmer wrote:
> This will enable us to use a custom name and/or location of bsdtar
> binary in scripts.
>
> Signed-off-by: Nezmer <git at nezmer.info>
> ---
> configure.ac | 6 ++++++
> contrib/Makefile.am | 1 +
> contrib/bacman.in | 4 ++--
> contrib/pacscripts.in | 4 ++--
> scripts/Makefile.am | 1 +
> scripts/makepkg.sh.in | 12 ++++++------
> scripts/pacman-optimize.sh.in | 4 ++--
> scripts/pkgdelta.sh.in | 2 +-
> scripts/repo-add.sh.in | 14 +++++++-------
> 9 files changed, 28 insertions(+), 20 deletions(-)
>
> diff --git a/configure.ac b/configure.ac
> index 6f601f4..50d4a04 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -98,6 +98,11 @@ AC_ARG_WITH(fetch,
> AS_HELP_STRING([--with-fetch], [use libfetch as an internal downloader]),
> [], [with_fetch=check])
>
> +# Custom bsdtar binary name and/or location
> +AC_ARG_WITH(bsdtar_bin,
> + AS_HELP_STRING([--with-bsdtar-bin=BSDTAR], [use bsdtar_bin as the bsdtar binary in scripts]),
> + BSDTAR_BIN=$with_bsdtar_bin)
> +
> # Help line for documentation
> AC_ARG_ENABLE(doc,
> AS_HELP_STRING([--disable-doc], [prevent make from looking at doc/ dir]),
> @@ -128,6 +133,7 @@ AC_PROG_MAKE_SET
> AC_PROG_LIBTOOL
> AC_CHECK_PROGS([PYTHON], [python2.7 python2.6 python2.5 python2 python], [false])
> AC_PATH_PROGS([BASH_SHELL], [bash bash4 bash3], [false])
> +AC_PATH_PROGS([BSDTAR_BIN], [bsdtar], [false])
>
> # find installed gettext
> AM_GNU_GETTEXT([external])
> diff --git a/contrib/Makefile.am b/contrib/Makefile.am
> index 55366b4..985b19f 100644
> --- a/contrib/Makefile.am
> +++ b/contrib/Makefile.am
> @@ -29,6 +29,7 @@ MOSTLYCLEANFILES = $(OURFILES) *.tmp
> edit = sed \
> -e 's|@sysconfdir[@]|$(sysconfdir)|g' \
> -e 's|@localstatedir[@]|$(localstatedir)|g' \
> + -e 's|@BSDTAR_BIN[@]|$(BSDTAR_BIN)|g' \
> -e 's|@BASH_SHELL[@]|$(BASH_SHELL)|g'
>
> $(OURFILES): Makefile
> diff --git a/contrib/bacman.in b/contrib/bacman.in
> index b4e3b4b..1891ef6 100755
> --- a/contrib/bacman.in
> +++ b/contrib/bacman.in
> @@ -133,7 +133,7 @@ while read i; do
> %FILES%)
> ret=0
> if [ -e "/$i" ]; then
> - bsdtar -cnf - "/$i" 2> /dev/null | bsdtar -xpf -
> + @BSDTAR_BIN@ -cnf - "/$i" 2> /dev/null | @BSDTAR_BIN@ -xpf -
>
> # Workaround to bsdtar not reporting a missing file as an error
> if [ ! -e "$work_dir/$i" -a ! -L "$work_dir/$i" ]; then
> @@ -288,7 +288,7 @@ ret=0
> shopt -s nullglob
> # TODO: Maybe this can be set globally for robustness
> shopt -s -o pipefail
> -bsdtar -cf - $comp_files * |
> + at BSDTAR_BIN@ -cf - $comp_files * |
> case "$PKGEXT" in
> *tar.gz) gzip -c -f -n ;;
> *tar.bz2) bzip2 -c -f ;;
> diff --git a/contrib/pacscripts.in b/contrib/pacscripts.in
> index d366409..6faf964 100755
> --- a/contrib/pacscripts.in
> +++ b/contrib/pacscripts.in
> @@ -85,7 +85,7 @@ print_db() {
> }
>
> print_pkg() {
> - if ! bsdtar -xOf "$1" .INSTALL 2>/dev/null; then
> + if ! @BSDTAR_BIN@ -xOf "$1" .INSTALL 2>/dev/null; then
> error "Package $1 does not include any .INSTALL script"
> return 1
> fi
> @@ -94,7 +94,7 @@ print_pkg() {
>
> print_scriptlet() {
> if [ -f "$1" ]; then
> - if bsdtar tf "$1" .PKGINFO &>/dev/null; then
> + if @BSDTAR_BIN@ tf "$1" .PKGINFO &>/dev/null; then
> print_pkg "$1"
> return
> fi
> diff --git a/scripts/Makefile.am b/scripts/Makefile.am
> index 78deb0b..4668ad1 100644
> --- a/scripts/Makefile.am
> +++ b/scripts/Makefile.am
> @@ -35,6 +35,7 @@ edit = sed \
> -e 's|@sysconfdir[@]|$(sysconfdir)|g' \
> -e 's|@localstatedir[@]|$(localstatedir)|g' \
> -e 's|@prefix[@]|$(prefix)|g' \
> + -e 's|@BSDTAR_BIN[@]|$(BSDTAR_BIN)|g' \
> -e 's|@BASH_SHELL[@]|$(BASH_SHELL)|g' \
> -e 's|@PACKAGE_VERSION[@]|$(REAL_PACKAGE_VERSION)|g' \
> -e 's|@PACKAGE_BUGREPORT[@]|$(PACKAGE_BUGREPORT)|g' \
> diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
> index bdf63ef..2731dbf 100644
> --- a/scripts/makepkg.sh.in
> +++ b/scripts/makepkg.sh.in
> @@ -671,7 +671,7 @@ extract_sources() {
> local cmd=''
> case "$file_type" in
> *application/x-tar*|*application/zip*|*application/x-zip*|*application/x-cpio*)
> - cmd="bsdtar" ;;
> + cmd="@BSDTAR_BIN@" ;;
> *application/x-gzip*)
> case "$ext" in
> gz|z|Z) cmd="gzip" ;;
> @@ -689,8 +689,8 @@ extract_sources() {
> esac ;;
> *)
> # See if bsdtar can recognize the file
> - if bsdtar -tf "$file" -q '*' &>/dev/null; then
> - cmd="bsdtar"
> + if @BSDTAR_BIN@ -tf "$file" -q '*' &>/dev/null; then
> + cmd="@BSDTAR_BIN@"
> else
> continue
> fi ;;
> @@ -698,7 +698,7 @@ extract_sources() {
>
> local ret=0
> msg2 "$(gettext "Extracting %s with %s")" "$file" "$cmd"
> - if [[ $cmd = bsdtar ]]; then
> + if [[ $cmd = @BSDTAR_BIN@ ]]; then
> $cmd -xf "$file" || ret=$?
> else
> rm -f "${file%.*}"
> @@ -1043,7 +1043,7 @@ create_package() {
> shopt -s nullglob
> # TODO: Maybe this can be set globally for robustness
> shopt -s -o pipefail
> - bsdtar -cf - $comp_files * |
> + @BSDTAR_BIN@ -cf - $comp_files * |
> case "$PKGEXT" in
> *tar.gz) gzip -c -f -n ;;
> *tar.bz2) bzip2 -c -f ;;
> @@ -1135,7 +1135,7 @@ create_srcpackage() {
> # tar it up
> msg2 "$(gettext "Compressing source package...")"
> cd "${srclinks}"
> - if ! bsdtar -c${TAR_OPT}Lf "$pkg_file" ${pkgbase}; then
> + if ! @BSDTAR_BIN@ -c${TAR_OPT}Lf "$pkg_file" ${pkgbase}; then
> error "$(gettext "Failed to create source package file.")"
> exit 1 # TODO: error code
> fi
> diff --git a/scripts/pacman-optimize.sh.in b/scripts/pacman-optimize.sh.in
> index f4642ab..a0026b7 100644
> --- a/scripts/pacman-optimize.sh.in
> +++ b/scripts/pacman-optimize.sh.in
> @@ -129,7 +129,7 @@ find "$dbroot" -type f | sort | xargs md5sum > "$workdir/pacsums.old"
> # step 2: tar it up
> msg "$(gettext "Tar'ing up %s...")" "$dbroot"
> cd "$dbroot"
> -bsdtar -czf "$workdir/pacman-db.tar.gz" ./
> + at BSDTAR_BIN@ -czf "$workdir/pacman-db.tar.gz" ./
> if (( $? )); then
> rm -rf "$workdir"
> die_r "$(gettext "Tar'ing up %s failed.")" "$dbroot"
> @@ -138,7 +138,7 @@ fi
> # step 3: make and sum the new db side-by-side with the old
> msg "$(gettext "Making and MD5sum'ing the new database...")"
> mkdir "$dbroot.new"
> -bsdtar -xpf "$workdir/pacman-db.tar.gz" -C "$dbroot.new"
> + at BSDTAR_BIN@ -xpf "$workdir/pacman-db.tar.gz" -C "$dbroot.new"
> if (( $? )); then
> rm -rf "$workdir"
> die_r "$(gettext "Untar'ing %s failed.")" "$dbroot"
> diff --git a/scripts/pkgdelta.sh.in b/scripts/pkgdelta.sh.in
> index 6bc3f5d..b569ea4 100644
> --- a/scripts/pkgdelta.sh.in
> +++ b/scripts/pkgdelta.sh.in
> @@ -76,7 +76,7 @@ read_pkginfo()
> IFS="
> "
> local line var val
> - for line in $(bsdtar -xOf "$1" .PKGINFO 2>/dev/null |
> + for line in $(@BSDTAR_BIN@ -xOf "$1" .PKGINFO 2>/dev/null |
> grep -v "^#" | sed 's|\(\w*\)\s*=\s*\(.*\)|\1="\2"|'); do
> eval "$line"
> if [[ -n $pkgname && -n $pkgver && -n $arch ]]; then
> diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in
> index d09d1b4..8b6a028 100644
> --- a/scripts/repo-add.sh.in
> +++ b/scripts/repo-add.sh.in
> @@ -198,7 +198,7 @@ db_write_entry()
>
> # read info from the zipped package
> local line var val
> - for line in $(bsdtar -xOqf "$pkgfile" .PKGINFO |
> + for line in $(@BSDTAR_BIN@ -xOqf "$pkgfile" .PKGINFO |
> grep -v '^#' | sed 's|\(\w*\)\s*=\s*\(.*\)|\1 \2|'); do
> # bash awesomeness here- var is always one word, val is everything else
> var=${line%% *}
> @@ -337,15 +337,15 @@ check_repo_db()
> if [[ -f $REPO_DB_FILE ]]; then
> # there are two situations we can have here- a DB with some entries,
> # or a DB with no contents at all.
> - if ! bsdtar -tqf "$REPO_DB_FILE" '*/desc' >/dev/null 2>&1; then
> + if ! @BSDTAR_BIN@ -tqf "$REPO_DB_FILE" '*/desc' >/dev/null 2>&1; then
> # check empty case
> - if [[ -n $(bsdtar -tqf "$REPO_DB_FILE" '*' 2>/dev/null) ]]; then
> + if [[ -n $(@BSDTAR_BIN@ -tqf "$REPO_DB_FILE" '*' 2>/dev/null) ]]; then
> error "$(gettext "Repository file '%s' is not a proper pacman database.")" "$REPO_DB_FILE"
> exit 1
> fi
> fi
> msg "$(gettext "Extracting database to a temporary location...")"
> - bsdtar -xf "$REPO_DB_FILE" -C "$tmpdir"
> + @BSDTAR_BIN@ -xf "$REPO_DB_FILE" -C "$tmpdir"
> else
> case "$cmd" in
> repo-remove)
> @@ -386,7 +386,7 @@ add()
> fi
>
> pkgfile=$1
> - if ! bsdtar -tqf "$pkgfile" .PKGINFO >/dev/null 2>&1; then
> + if ! @BSDTAR_BIN@ -tqf "$pkgfile" .PKGINFO >/dev/null 2>&1; then
> error "$(gettext "'%s' is not a package file, skipping")" "$pkgfile"
> return 1
> fi
> @@ -505,11 +505,11 @@ if (( success )); then
>
> cd "$tmpdir"
> if [[ -n $(ls) ]]; then
> - bsdtar -c${TAR_OPT}f "$filename" *
> + @BSDTAR_BIN@ -c${TAR_OPT}f "$filename" *
> else
> # we have no packages remaining? zip up some emptyness
> warning "$(gettext "No packages remain, creating empty database.")"
> - bsdtar -c${TAR_OPT}f "$filename" -T /dev/null
> + @BSDTAR_BIN@ -c${TAR_OPT}f "$filename" -T /dev/null
> fi
> cd "$startdir"
>
> --
> 1.7.3.1
>
Any thoughts on this one?
More information about the pacman-dev
mailing list