From 9aa40b5189c5324e3d83cf78c78dca92dfda842d Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 10 May 2014 21:56:03 -0400 Subject: fix whitespace (one line had 8 spaces instead of a tab) --- src/librefetch/librefetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/librefetch') diff --git a/src/librefetch/librefetch b/src/librefetch/librefetch index fdc7e00..49159f5 100755 --- a/src/librefetch/librefetch +++ b/src/librefetch/librefetch @@ -264,7 +264,7 @@ makepkg_modify=' } /tidy_install\(\) \{/,/^\}$/ { - /for .*PURGE_TARGETS/itidy_install_purge + /for .*PURGE_TARGETS/itidy_install_purge /for .*PURGE_TARGETS/,/done/d /^\}$/ifind . -exec touch --no-dereference --date="1990-01-01 0:0:0 +0" -- {} + } -- cgit v1.2.3-54-g00ecf From b0b4a603d24d905d757df39ec2e90f46403cdd32 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 10 May 2014 21:57:34 -0400 Subject: librefetch: Make the order of files in a tarball deterministic --- src/librefetch/librefetch | 6 +++++- src/librefetch/librefetch.8.ronn | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'src/librefetch') diff --git a/src/librefetch/librefetch b/src/librefetch/librefetch index 49159f5..d0bbf1b 100755 --- a/src/librefetch/librefetch +++ b/src/librefetch/librefetch @@ -259,7 +259,11 @@ makepkg_modify=' /create_package\(\) \{/,/^\}$/ { /pkg_file=/d # allow us to set pkg_file s/"?\$\{comp_files\[@\]\}"?// # do not include .{PKGINFO,INSTALL,CHANGELOG} - s/bsdtar /&--format=ustar / # ustar, not pax + # This is long/gross. What it does: + # - pass --format=ustar to bsdtar, to inhibit it using the pax format + # - take the files that would be included in the tarball, and use + # find/sort/xargs to order them before passing them to bsdtar + s/bsdtar(.*) - ([^|]*) \|/find \2 -print0 | LC_ALL=C sort --zero-terminated | xargs -0 bsdtar --format=ustar --no-recursion \1 - |/ s/create_signature .*/&; return $?/ # do not procede to create symlinks } diff --git a/src/librefetch/librefetch.8.ronn b/src/librefetch/librefetch.8.ronn index 7d2dfb3..3b51fb4 100644 --- a/src/librefetch/librefetch.8.ronn +++ b/src/librefetch/librefetch.8.ronn @@ -173,6 +173,9 @@ The following modifications are made to makepkg: * Timestamps in `$pkgdir` are reset to "1990-01-01 0:0:0 +0", so that the resulting tarball will be the same, regardless of when it was created. + * Sort the files included in the tarball; normally the order of files + in a tarball is essentially random (even if it tends to be the same + when re-created on the same machine). * append `-libre` to `$srcdir` * append `-libre` to `$pkgbasedir` (which becomes `$pkgdir`) * Don't check if the package has already been built. -- cgit v1.2.3-54-g00ecf From f3dd569efc04b1fb315d2233fda043e15bb7430b Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 11 May 2014 01:41:20 -0400 Subject: librefetch: enhance debugging options (flags change) --- src/librefetch/librefetch | 24 ++++++++++++++++++------ src/librefetch/librefetch.8.ronn | 8 ++++++-- 2 files changed, 24 insertions(+), 8 deletions(-) (limited to 'src/librefetch') diff --git a/src/librefetch/librefetch b/src/librefetch/librefetch index d0bbf1b..c1c3494 100755 --- a/src/librefetch/librefetch +++ b/src/librefetch/librefetch @@ -70,7 +70,8 @@ usage() { directory, it is used instead" print " Alternate modes:" flag "-g, --geninteg" "Generage integrity checks for source files" - flag "-P, --print" "Print the effective build script (SRCBUILD)" + flag "-S, --srcbuild" "Print the effective build script (SRCBUILD)" + flag "-M, --makepkg" "Print the effective makepkg script" flag "-h, --help" "Show this message" } @@ -90,6 +91,17 @@ main() { ######################################################################## + makepkg="$(modified_makepkg "$(which makepkg)")" + + # Mode: makepkg ######################################################## + + if [[ $mode =~ makepkg ]]; then + cat "$makepkg" + return 0 + fi + + ######################################################################## + local BUILDFILEDIR="${BUILDFILE%/*}" if [[ -f "${BUILDFILEDIR}/SRCBUILD" ]]; then BUILDFILE="${BUILDFILEDIR}/SRCBUILD" @@ -102,7 +114,6 @@ main() { */SRCBUILD) srcbuild="$(modified_srcbuild "$BUILDFILE")";; *) srcbuild="$(modified_pkgbuild "$BUILDFILE")";; esac - makepkg="$(modified_makepkg "$(which makepkg)")" # Mode: checksums ###################################################### @@ -115,9 +126,9 @@ main() { return 0 fi - # Mode: print ########################################################## + # Mode: srcbuild ####################################################### - if [[ $mode =~ print ]]; then + if [[ $mode =~ srcbuild ]]; then cat "$srcbuild" return 0 fi @@ -212,7 +223,8 @@ parse_options() { -C) mode=create;; -D) mode=download;; -g|--geninteg) mode=checksums;; - -P|--print) mode=print;; + -S|--srcbuild) mode=srcbuild;; + -M|--makepkg) mode=makepkg;; -p) BUILDFILE="$(readlink -m -- "$opt")";; -h|--help) mode=help;; --) shift; break;; @@ -235,7 +247,7 @@ parse_options() { case "$mode" in help) # don't worry about it :;; - checksums|print) # don't take any extra arguments + checksums|srcbuild|makepkg) # don't take any extra arguments if [[ ${#extra_opts[@]} != 0 ]]; then print "%s: found extra non-flag arguments: %s" "$cmd" "${extra_opts[*]}" >&2 usage >&2 diff --git a/src/librefetch/librefetch.8.ronn b/src/librefetch/librefetch.8.ronn index 3b51fb4..4c9c1c4 100644 --- a/src/librefetch/librefetch.8.ronn +++ b/src/librefetch/librefetch.8.ronn @@ -31,7 +31,8 @@ There are 5 modes: * `download`: Download the tarball from the configured mirror. * `create`: Create the tarball from a `PKGBUILD`/`SRCBUILD`. * `checksums`: Generate integrity checks for source files. - * `print`: Print the effective build script. + * `srcbuild`: Print the effective build script. + * `makepkg`: Print the effective makepkg script. * `help`: Print `librefetch` usage information. The normal mode of operation is `download` mode. If `download` mode @@ -46,7 +47,10 @@ fails, it may choose to try `create` mode. directory, it is used instead. * `-g` | `--geninteg`: Use `checksums` mode: Generate integrity checks for source files. - * `-P` | `--print`: Use `print` mode: print the effective build script. + * `-S` | `--srcbuild`: Use `srcbuild` mode: print the effective build + script. + * `-M` | `--makepkg`: Use `makepkg` mode: print the effective makepkg + script. * `-h` | `--help`: Use `help` mode: Show useage information. ## DOWNLOAD MODE -- cgit v1.2.3-54-g00ecf From 0c5516fe647de69e92517b99794792b99754044e Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 15 May 2014 22:03:04 -0400 Subject: librefetch: Update 'Usage:' line. --- src/librefetch/librefetch | 2 +- src/librefetch/librefetch.8.ronn | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/librefetch') diff --git a/src/librefetch/librefetch b/src/librefetch/librefetch index c1c3494..65f5de9 100755 --- a/src/librefetch/librefetch +++ b/src/librefetch/librefetch @@ -30,7 +30,7 @@ trap "rm -rf -- $(printf '%q' "$tempdir")" EXIT cmd=${0##*/} usage() { print "Usage: %s [OPTIONS] SOURCE_URL [OUTPUT_FILE]" "$cmd" - print "Usage: %s -[g|P|h]" "$cmd" + print "Usage: %s -[g|S|M|h]" "$cmd" print "Downloads or creates a liberated source tarball." echo prose "The default mode is to create OUTPUT_FILE, first by trying diff --git a/src/librefetch/librefetch.8.ronn b/src/librefetch/librefetch.8.ronn index 4c9c1c4..d7b8edc 100644 --- a/src/librefetch/librefetch.8.ronn +++ b/src/librefetch/librefetch.8.ronn @@ -4,7 +4,7 @@ librefetch(8) -- downloads or creates a liberated source tarball ## SYNOPSIS `librefetch` [] []
-`librefetch` `-`[`g`|`P`|`h`] +`librefetch` `-`[`g`|`S`|`M`|`h`] ## DESCRIPTION -- cgit v1.2.3-54-g00ecf From 56472f6c28e278fb937e3456f91b52cc5ec0b143 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 15 May 2014 22:03:58 -0400 Subject: librefetch: fix a call to `printf` that should have been to `print` --- src/librefetch/librefetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/librefetch') diff --git a/src/librefetch/librefetch b/src/librefetch/librefetch index 65f5de9..98d85a2 100755 --- a/src/librefetch/librefetch +++ b/src/librefetch/librefetch @@ -233,7 +233,7 @@ parse_options() { makepkg_opts+=("$arg") $have_opt && makepkg_opts+=("$opt") else - printf '%s: invalid flag: %s' "$cmd" "$arg" + print '%s: invalid flag: %s' "$cmd" "$arg" return 1 fi ;; -- cgit v1.2.3-54-g00ecf From 3771f34a54bca198921d60a1bce83068b7bd4f49 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 15 May 2014 22:05:37 -0400 Subject: librefetch: The ERR trap is greedy; use exit instead of return from main(). --- src/librefetch/librefetch | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/librefetch') diff --git a/src/librefetch/librefetch b/src/librefetch/librefetch index 98d85a2..8fd8c1d 100755 --- a/src/librefetch/librefetch +++ b/src/librefetch/librefetch @@ -86,7 +86,7 @@ main() { if [[ $mode =~ help ]]; then usage - return 0 + exit 0 fi ######################################################################## @@ -97,7 +97,7 @@ main() { if [[ $mode =~ makepkg ]]; then cat "$makepkg" - return 0 + exit 0 fi ######################################################################## @@ -123,14 +123,14 @@ main() { PKGBUILD) sed -e 's/^[a-z]/mk&/' -e 's/^\s/ &/';; SRCBUILD) cat;; esac - return 0 + exit 0 fi # Mode: srcbuild ####################################################### if [[ $mode =~ srcbuild ]]; then cat "$srcbuild" - return 0 + exit 0 fi ######################################################################## @@ -148,7 +148,7 @@ main() { if [[ $mode =~ download ]]; then load_files librefetch - check_vars librefetch MIRRORS DOWNLOADER || return 1 + check_vars librefetch MIRRORS DOWNLOADER || exit 1 # Canonicalize $src if [[ "$src" == libre://* ]]; then @@ -174,7 +174,7 @@ main() { dlcmd="${dlcmd//\%o/\"\$dst\"}" dlcmd="${dlcmd//\%u/\"\$src\"}" - { eval "$dlcmd"; } >&2 && return 0 + { eval "$dlcmd"; } >&2 && exit 0 fi # Mode: create ######################################################### @@ -186,7 +186,7 @@ main() { export pkg_file=$dst cd "$BUILDFILEDIR" - "$makepkg" "${makepkg_opts[@]}" -p "$srcbuild" >&2 || return $? + "$makepkg" "${makepkg_opts[@]}" -p "$srcbuild" >&2 || exit $? fi } -- cgit v1.2.3-54-g00ecf From 79588f1bcc6f8052964717cdb8fe4eb82dceb0df Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 15 May 2014 22:06:13 -0400 Subject: librefetch: replace some makepkg messages with messages that make sense --- src/librefetch/librefetch | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/librefetch') diff --git a/src/librefetch/librefetch b/src/librefetch/librefetch index 8fd8c1d..f41615f 100755 --- a/src/librefetch/librefetch +++ b/src/librefetch/librefetch @@ -289,6 +289,9 @@ makepkg_modify=' arm -rf "$srcdir"\nmkdir "$srcdir" } +s|Making package:|Making source:| +s:Checking (run|build)time dependencies\.\.\.:Checking source dependencies...: + s|srcdir=.*|&-libre| s|pkgdirbase=.*|&-libre| s|check_build_status$|:| -- cgit v1.2.3-54-g00ecf From 7cdbee3ef93c1bef4b79310e4ef46cbde18c534f Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 15 May 2014 22:06:45 -0400 Subject: librefetch: call usage() consistently --- src/librefetch/librefetch | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/librefetch') diff --git a/src/librefetch/librefetch b/src/librefetch/librefetch index f41615f..b29598d 100755 --- a/src/librefetch/librefetch +++ b/src/librefetch/librefetch @@ -80,7 +80,10 @@ main() { makepkg_opts=() extra_opts=() mode=download-create - parse_options "$@" + if ! parse_options "$@"; then + usage >&2 + exit 1 + fi # Mode: help ########################################################### @@ -250,14 +253,12 @@ parse_options() { checksums|srcbuild|makepkg) # don't take any extra arguments if [[ ${#extra_opts[@]} != 0 ]]; then print "%s: found extra non-flag arguments: %s" "$cmd" "${extra_opts[*]}" >&2 - usage >&2 return 1 fi ;; *download*|*create*) # take 1 or 2 extra arguments if [[ ${#extra_opts[@]} != 1 ]] && [[ ${#extra_opts[@]} != 2 ]]; then print "%s: %d non-flag arguments found, expected 1 or 2: %s" "$cmd" ${#extra_opts[@]} >&2 - usage >&2 return 1 fi ;; -- cgit v1.2.3-54-g00ecf From 9bb1ddbaf5f0585f5854ee2c25204bda56b32974 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 15 May 2014 22:08:17 -0400 Subject: librefetch: Fix bug with xargs calling tar too many times (cut xargs out) --- src/librefetch/librefetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/librefetch') diff --git a/src/librefetch/librefetch b/src/librefetch/librefetch index b29598d..11cf380 100755 --- a/src/librefetch/librefetch +++ b/src/librefetch/librefetch @@ -276,7 +276,7 @@ makepkg_modify=' # - pass --format=ustar to bsdtar, to inhibit it using the pax format # - take the files that would be included in the tarball, and use # find/sort/xargs to order them before passing them to bsdtar - s/bsdtar(.*) - ([^|]*) \|/find \2 -print0 | LC_ALL=C sort --zero-terminated | xargs -0 bsdtar --format=ustar --no-recursion \1 - |/ + s/bsdtar(.*) - ([^|]*) \|/find \2 -print0 | LC_ALL=C sort --zero-terminated | bsdtar --null --files-from - --format=ustar --no-recursion \1 - |/ s/create_signature .*/&; return $?/ # do not procede to create symlinks } -- cgit v1.2.3-54-g00ecf From 22bb572086ff1c1667d553ac8233fc053a1556f2 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 15 May 2014 22:25:43 -0400 Subject: librefetch: clean up documentation --- src/librefetch/librefetch | 3 ++- src/librefetch/librefetch.8.ronn | 15 +++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) (limited to 'src/librefetch') diff --git a/src/librefetch/librefetch b/src/librefetch/librefetch index 11cf380..8b02205 100755 --- a/src/librefetch/librefetch +++ b/src/librefetch/librefetch @@ -53,7 +53,8 @@ usage() { prose "The default build script is 'PKGBUILD', or 'SRCBUILD' if it exists." echo - prose "Unrecognized options are passed straight to makepkg." + prose "Other options, if they are valid \`makepkg\` options, are passed + straight to makepkg." echo prose "%s does NOT support getopt-style flag combining. You must use '-a -b', not '-ab'." "$cmd" diff --git a/src/librefetch/librefetch.8.ronn b/src/librefetch/librefetch.8.ronn index d7b8edc..bb2e561 100644 --- a/src/librefetch/librefetch.8.ronn +++ b/src/librefetch/librefetch.8.ronn @@ -12,9 +12,9 @@ librefetch(8) -- downloads or creates a liberated source tarball tarballs for `PKGBUILD(5)` files. If a URL mentioned in the `source` array in a `PKGUILD` is in a -location that Parabola uploads "custom" source tarballs (or configured -locations), and no file is at that URL, librefetch will automatically -create it for you. +location that Parabola uploads "custom" source tarballs to (or +configured locations), and no file is at that URL, librefetch will +automatically create it for you. This works because a post-install script for the package configures `librefetch` as the download agent for `https://` URLs in @@ -53,6 +53,9 @@ fails, it may choose to try `create` mode. script. * `-h` | `--help`: Use `help` mode: Show useage information. +Other options, if they are documented in `makepkg -h`, are passed to +the modified copy of makepkg created during `create` mode. + ## DOWNLOAD MODE If begins with the string `libre://`, it is replaced with @@ -97,7 +100,7 @@ remain intact. As explained in the `CREATE MODE` section, in `create` mode, this program generates an `SRCBUILD` file. For debugging purposes, this -file can be printed instead of executed with `print` mode. +file can be printed instead of executed with `srcbuild` mode. ### PRE-EXISTING SRCBUILD @@ -184,6 +187,10 @@ The following modifications are made to makepkg: * append `-libre` to `$pkgbasedir` (which becomes `$pkgdir`) * Don't check if the package has already been built. +For debugging purposes, this modified makepkg can be printed instead +of executed with `makepkg` mode. Before it is run in create mode, +`PKGEXT`, `PKGDEST`, and `pkg_file` are set as environment variables. + ## CONFIGURATION See `librefetch.conf(5)` for details on configuring librefetch using -- cgit v1.2.3-54-g00ecf