From 0318548c81d95cc2483aaf44e63f487650a74f87 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Fri, 3 Jan 2014 22:33:48 -0500 Subject: librefetch: accept HTTP URLs, but don't create if they aren't in $MIRROR But, don't update the documentation. I have a feeling things will change again in the next few commits. --- src/librefetch/librefetch | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'src/librefetch') diff --git a/src/librefetch/librefetch b/src/librefetch/librefetch index 93bcd1e..e963b96 100755 --- a/src/librefetch/librefetch +++ b/src/librefetch/librefetch @@ -127,12 +127,12 @@ main() { local src dst case ${#extra_opts[@]} in 1) - src="${extra_opts[0]#*://}" - dst="$(readlink -m -- "${src##*/}")" + src="${extra_opts[0]}" + dst="${src##*/}" ;; 2) - src="${extra_opts[0]#*://}" - dst="$(readlink -m -- "${extra_opts[1]}")" + src="${extra_opts[0]}" + dst="${extra_opts[1]}" ;; *) print "%s: %d non-flag arguments found, expected 1 or 2: %s" "$cmd" ${#extra_opts[@]} >> /dev/stderr @@ -140,17 +140,25 @@ main() { return 1 esac + if [[ "$src" == libre://* ]]; then + src="${MIRROR}/${src#libre://}" + fi + + if [[ "$src" != "$MIRROR"* ]]; then + # inhibit create + mode=download + fi + dst="$(readlink -m -- "$dst")" # canonicalize $dst + # Mode: download ####################################################### if [[ $mode =~ download ]]; then load_files librefetch check_vars librefetch MIRROR DOWNLOADER || return 1 - local url="${MIRROR}/${src}" - local dlcmd="${DOWNLOADER}" dlcmd="${dlcmd//\%o/\"$dst\"}" - dlcmd="${dlcmd//\%u/\"$url\"}" + dlcmd="${dlcmd//\%u/\"$src\"}" { eval "$dlcmd"; } >> /dev/stderr && return 0 fi -- cgit v1.2.3-2-g168b From 0f078d1763a156993c372a49ae0f8ceefde52444 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Fri, 3 Jan 2014 22:34:23 -0500 Subject: librefetch: partially update the docs --- src/librefetch/librefetch | 8 +++++--- src/librefetch/librefetch.conf.5.ronn | 5 +++-- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'src/librefetch') diff --git a/src/librefetch/librefetch b/src/librefetch/librefetch index e963b96..42253b2 100755 --- a/src/librefetch/librefetch +++ b/src/librefetch/librefetch @@ -37,9 +37,11 @@ usage() { prose "If OUTPUT_FILE isn't specified, it defaults to the non-directory part of SOURCE_URL, in the current directory." echo - prose "In download mode, the glob '*://' is stripped from the beginning - of SOURCE_URL, and the resulting path is attempted to be - downloaded from the configured mirror." + prose "Unless '-C' is specified, if SOURCE_URL does not begin with the + configured mirror, create mode is inhibited." + echo + prose "In download mode, it simply tries to download SOURCE_URL. At the + beginning of a URL, 'libre://' expands to the configured mirror." echo prose "In create mode, it looks at a build script, and uses that to create the source tarball. SOURCE_URL is ignored, except that it diff --git a/src/librefetch/librefetch.conf.5.ronn b/src/librefetch/librefetch.conf.5.ronn index 4e59877..7b25400 100644 --- a/src/librefetch/librefetch.conf.5.ronn +++ b/src/librefetch/librefetch.conf.5.ronn @@ -25,8 +25,9 @@ If `$XDG_CONFIG_HOME` is not set, a default value is set: ## OPTIONS * `MIRROR='https://repo.parabolagnulinux.org/other/'`: - The location to download pre-built source tarball in download - mode. + Files from within this tree will be attempted to be built if + downloading them fails. Also, `libre://` expands to this + location. * `DOWNLOADER='/usr/bin/curl -fLC - --retry 3 --retry-delay 3 -o %o %u'`: The HTTP client to use when downloading pre-built source tarballs in download mode. -- cgit v1.2.3-2-g168b From 6eb64cb5bdce43fb5b1a83f93496083761ea2718 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 4 Jan 2014 19:37:33 -0500 Subject: librefetch: clean up option parsing --- src/librefetch/librefetch | 74 +++++++++++++++++++++++++++-------------------- 1 file changed, 43 insertions(+), 31 deletions(-) (limited to 'src/librefetch') diff --git a/src/librefetch/librefetch b/src/librefetch/librefetch index 42253b2..eb7eb61 100755 --- a/src/librefetch/librefetch +++ b/src/librefetch/librefetch @@ -99,11 +99,6 @@ main() { # Mode: checksums ###################################################### if [[ $mode =~ checksums ]]; then - if [[ ${#extra_opts[@]} != 0 ]]; then - print "%s: found extra non-flag arguments: %s" "$cmd" "${extra_opts[*]}" >> /dev/stderr - usage >> /dev/stderr - return 1 - fi "$makepkg" "${makepkg_opts[@]}" -g -p "$srcbuild" | case ${BUILDFILE##*/} in PKGBUILD) sed -e 's/^[a-z]/mk&/' -e 's/^\s/ &/';; @@ -115,42 +110,27 @@ main() { # Mode: print ########################################################## if [[ $mode =~ print ]]; then - if [[ ${#extra_opts[@]} != 0 ]]; then - print "%s: found extra non-flag arguments: %s" "$cmd" "${extra_opts[*]}" >> /dev/stderr - usage >> /dev/stderr - return 1 - fi cat "$srcbuild" return 0 fi ######################################################################## - local src dst - case ${#extra_opts[@]} in - 1) - src="${extra_opts[0]}" - dst="${src##*/}" - ;; - 2) - src="${extra_opts[0]}" - dst="${extra_opts[1]}" - ;; - *) - print "%s: %d non-flag arguments found, expected 1 or 2: %s" "$cmd" ${#extra_opts[@]} >> /dev/stderr - usage >> /dev/stderr - return 1 - esac + local src="${extra_opts[0]}" + local dst="${extra_opts[1]:-${src##*/}}" + # canonicalize $src if [[ "$src" == libre://* ]]; then src="${MIRROR}/${src#libre://}" fi + # canonicalize $dst + dst="$(readlink -m -- "$dst")" + # check to see if $src is a candidate for create mode if [[ "$src" != "$MIRROR"* ]]; then # inhibit create mode=download fi - dst="$(readlink -m -- "$dst")" # canonicalize $dst # Mode: download ####################################################### @@ -179,10 +159,17 @@ main() { # sets the variables BUILDFILE, makepkg_opts, extra_opts, mode parse_options() { - # Detect makepkg options that take a second argument + # Detect makepkg options local makepkg_orig="$(which makepkg)" - local makepkg_opt2long=($("${makepkg_orig}" -h | sed -rn 's/\s*(--\S*) <.*/\1/p')) - local makepkg_opt2short=($("${makepkg_orig}" -h | sed -rn 's/\s*(-.) <.*/\1/p')) + # --long flags that take a second argument + local makepkg_opt2long=( $(LC_ALL=C "${makepkg_orig}" -h | sed -rn 's/\s*(--\S*) <.*/\1/p')) + # -s hort flags that take a second argument + local makepkg_opt2short=($(LC_ALL=C "${makepkg_orig}" -h | sed -rn 's/\s*(-.) <.*/\1/p')) + # all flags + local makepkg_argall=( $(LC_ALL=C "${makepkg_orig}" -h | sed -rn \ + -e 's/^ +(-.) .*/\1/p' \ + -e 's/^ +(-.), (--\S*) .*/\1\n\2/p' \ + -e 's/^ +(--\S*) .*/\1/p')) local opt local have_opt @@ -207,8 +194,13 @@ parse_options() { -p) BUILDFILE="$(readlink -m -- "$opt")";; -h|--help) mode=help;; -*) - makepkg_opts+=("$arg") - $have_opt && makepkg_opts+=("$opt") + if in_array "${arg}" "${makepkg_argall[@]}"; then + makepkg_opts+=("$arg") + $have_opt && makepkg_opts+=("$opt") + else + printf '%s: invalid flag: %s' "$cmd" "$arg" + return 1 + fi ;; --) shift; break;; *) extra_opts+=("$arg");; @@ -216,6 +208,26 @@ parse_options() { shift done extra_opts+=("$@") + + # check the number of extra_opts + case "$mode" in + help) # don't worry about it + :;; + checksums|print) # don't take any extra arguments + if [[ ${#extra_opts[@]} != 0 ]]; then + print "%s: found extra non-flag arguments: %s" "$cmd" "${extra_opts[*]}" >> /dev/stderr + usage >> /dev/stderr + 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[@]} >> /dev/stderr + usage >> /dev/stderr + return 1 + fi + ;; + esac } # Modify makepkg ############################################################### -- cgit v1.2.3-2-g168b From 8698eb5f1dff6d046fb708d1e4f529d83e88cb4c Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 4 Jan 2014 19:39:02 -0500 Subject: librefetch: Update the docs: `version` mode is gone, a while ago. --- src/librefetch/librefetch | 2 +- src/librefetch/librefetch.8.ronn | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'src/librefetch') diff --git a/src/librefetch/librefetch b/src/librefetch/librefetch index eb7eb61..6268d75 100755 --- a/src/librefetch/librefetch +++ b/src/librefetch/librefetch @@ -28,7 +28,7 @@ trap cleanup EXIT cmd=${0##*/} usage() { print "Usage: %s [OPTIONS] SOURCE_URL [OUTPUT_FILE]" "$cmd" - print "Usage: %s -[g|P|V|h]" "$cmd" + print "Usage: %s -[g|P|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 c2b8ffe..16c3838 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` [options] []
-`librefetch` -[g|V|h] +`librefetch` -[g|P|h] ## DESCRIPTION @@ -18,7 +18,7 @@ package adds `librefetch` as a download agent for `libre://` to `makepkg.conf`. Because of this, it is almost never necessary to call `librefetch` manually. -There are 7 modes: +There are 6 modes: * `download-create`: The default mode. First try `download` mode, then `create` mode. @@ -26,7 +26,6 @@ There are 7 modes: * `create`: Create the tarball from a `PKGBUILD`/`SRCBUILD`. * `checksums`: Generate integrity checks for source files. * `print`: Print the effective build script. - * `version`: Print `librefetch` version information. * `help`: Print `librefetch` usage information. ## OPTIONS @@ -39,7 +38,6 @@ There are 7 modes: * `-g` | `--geninteg`: Use `checksums` mode: Generate integrity checks for source files. * `-P` | `--print`: Use `print` mode: print the effective build script. - * `-V` | `--version`: Use `version` mode: Show version information. * `-h` | `--help`: Use `help` mode: Show useage information. ## CREATE MODE -- cgit v1.2.3-2-g168b From f1487a80edac9e8f651f7bf2970e8fa4d2a9e971 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Fri, 3 Jan 2014 23:06:17 -0500 Subject: librefetch: defer canonicalizing $src until we've validated $MIRROR --- src/librefetch/librefetch | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'src/librefetch') diff --git a/src/librefetch/librefetch b/src/librefetch/librefetch index 6268d75..3d7f667 100755 --- a/src/librefetch/librefetch +++ b/src/librefetch/librefetch @@ -119,18 +119,11 @@ main() { local src="${extra_opts[0]}" local dst="${extra_opts[1]:-${src##*/}}" - # canonicalize $src - if [[ "$src" == libre://* ]]; then - src="${MIRROR}/${src#libre://}" - fi - # canonicalize $dst - dst="$(readlink -m -- "$dst")" + # Don't canonicalize $src unless mode =~ download, and we've validated + # that $MIRROR is configured. - # check to see if $src is a candidate for create mode - if [[ "$src" != "$MIRROR"* ]]; then - # inhibit create - mode=download - fi + # Canonicalize $dst + dst="$(readlink -m -- "$dst")" # Mode: download ####################################################### @@ -138,6 +131,17 @@ main() { load_files librefetch check_vars librefetch MIRROR DOWNLOADER || return 1 + # Canonicalize $src + if [[ "$src" == libre://* ]]; then + src="${MIRROR}/${src#libre://}" + fi + + # check to see if $src is a candidate for create mode + if [[ "$src" != "$MIRROR"* ]]; then + # inhibit create + mode=download + fi + local dlcmd="${DOWNLOADER}" dlcmd="${dlcmd//\%o/\"$dst\"}" dlcmd="${dlcmd//\%u/\"$src\"}" -- cgit v1.2.3-2-g168b From 403b4f20e5cfd2d2c0348de076effd3ddb616844 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Fri, 3 Jan 2014 23:07:13 -0500 Subject: librefetch: replace MIRROR with MIRRORS (but doesn't update the docs) --- src/librefetch/librefetch | 16 ++++++++++++---- src/librefetch/librefetch.conf | 5 ++++- 2 files changed, 16 insertions(+), 5 deletions(-) (limited to 'src/librefetch') diff --git a/src/librefetch/librefetch b/src/librefetch/librefetch index 3d7f667..61fc3ad 100755 --- a/src/librefetch/librefetch +++ b/src/librefetch/librefetch @@ -120,7 +120,7 @@ main() { local dst="${extra_opts[1]:-${src##*/}}" # Don't canonicalize $src unless mode =~ download, and we've validated - # that $MIRROR is configured. + # that $MIRRORS is configured. # Canonicalize $dst dst="$(readlink -m -- "$dst")" @@ -129,15 +129,23 @@ main() { if [[ $mode =~ download ]]; then load_files librefetch - check_vars librefetch MIRROR DOWNLOADER || return 1 + check_vars librefetch MIRRORS DOWNLOADER || return 1 # Canonicalize $src if [[ "$src" == libre://* ]]; then - src="${MIRROR}/${src#libre://}" + src="${MIRRORS[0]}/${src#libre://}" fi # check to see if $src is a candidate for create mode - if [[ "$src" != "$MIRROR"* ]]; then + local inmirror=false; + local mirror + for mirror in "${MIRRORS[@]}"; do + if [[ "$src" == "$mirror"* ]]; then + inmirror=true + break + fi + done + if ! $inmirror; then # inhibit create mode=download fi diff --git a/src/librefetch/librefetch.conf b/src/librefetch/librefetch.conf index ce328d8..6948e8d 100644 --- a/src/librefetch/librefetch.conf +++ b/src/librefetch/librefetch.conf @@ -1,2 +1,5 @@ -MIRROR='https://repo.parabolagnulinux.org/other/' +MIRRORS=( + 'https://repo.parabolagnulinux.org/sources/' + 'https://repo.parabolagnulinux.org/other/' +) DOWNLOADER='/usr/bin/curl -fLC - --retry 3 --retry-delay 3 -o %o %u' -- cgit v1.2.3-2-g168b From 5f97f7885b8bdb7a6fea34d6d073428b199d66ef Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 4 Jan 2014 16:07:40 -0500 Subject: librefetch: fiddle with DOWNLOADER percent-substitution --- src/librefetch/librefetch | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/librefetch') diff --git a/src/librefetch/librefetch b/src/librefetch/librefetch index 61fc3ad..a477315 100755 --- a/src/librefetch/librefetch +++ b/src/librefetch/librefetch @@ -151,8 +151,10 @@ main() { fi local dlcmd="${DOWNLOADER}" - dlcmd="${dlcmd//\%o/\"$dst\"}" - dlcmd="${dlcmd//\%u/\"$src\"}" + [[ $dlcmd = *%u* ]] || dlcmd="$dlcmd %u" + dlcmd="${dlcmd//\%o/$(printf '%q' "$dst")}" + dlcmd="${dlcmd//\%u/$(printf '%q' "$src")}" + { eval "$dlcmd"; } >> /dev/stderr && return 0 fi -- cgit v1.2.3-2-g168b From 811df5ff79f76b8128380715ac5ae127cd76be56 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 4 Jan 2014 19:32:14 -0500 Subject: librefetch: update docs --- src/librefetch/librefetch | 7 +++-- src/librefetch/librefetch.8.ronn | 54 ++++++++++++++++++++++++++++------- src/librefetch/librefetch.conf.5.ronn | 17 +++++++---- 3 files changed, 58 insertions(+), 20 deletions(-) (limited to 'src/librefetch') diff --git a/src/librefetch/librefetch b/src/librefetch/librefetch index a477315..819a51a 100755 --- a/src/librefetch/librefetch +++ b/src/librefetch/librefetch @@ -37,11 +37,12 @@ usage() { prose "If OUTPUT_FILE isn't specified, it defaults to the non-directory part of SOURCE_URL, in the current directory." echo - prose "Unless '-C' is specified, if SOURCE_URL does not begin with the + prose "Unless '-C' is specified, if SOURCE_URL does not begin with a configured mirror, create mode is inhibited." echo prose "In download mode, it simply tries to download SOURCE_URL. At the - beginning of a URL, 'libre://' expands to the configured mirror." + beginning of a URL, 'libre://' expands to the first configured + mirror." echo prose "In create mode, it looks at a build script, and uses that to create the source tarball. SOURCE_URL is ignored, except that it @@ -56,7 +57,7 @@ usage() { '-a -b', not '-ab'." "$cmd" echo print "Example usage:" - print ' $ %s libre://mypackage-1.0.tar.gz' "$cmd" + print ' $ %s https://repo.parabolagnulinux.org/other/mypackage/mypackage-1.0.tar.gz' "$cmd" echo print "Options:" print " Settings:" diff --git a/src/librefetch/librefetch.8.ronn b/src/librefetch/librefetch.8.ronn index 16c3838..c7247d5 100644 --- a/src/librefetch/librefetch.8.ronn +++ b/src/librefetch/librefetch.8.ronn @@ -3,31 +3,40 @@ librefetch(8) -- downloads or creates a liberated source tarball ## SYNOPSIS -`librefetch` [options] []
-`librefetch` -[g|P|h] +`librefetch` [] []
+`librefetch` `-`[`g`|`P`|`h`] ## DESCRIPTION `librefetch` is a program to streamline creation of custom source tarballs for `PKGBUILD(5)` files. -To automatically use `librefetch` to download or create a source -tarball, you can add `libre://FILENAME.tar.gz` to the source array in -your `PKGBUILD`. This works because a post-install script for the -package adds `librefetch` as a download agent for `libre://` to -`makepkg.conf`. Because of this, it is almost never necessary to call -`librefetch` manually. +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. -There are 6 modes: +This works because a post-install script for the package configures +`librefetch` as the download agent for `https://` URLs in +`makepkg.conf`; allowing it to jump in and create a file if need be. +Because of this, it is almost never necessary to call `librefetch` +manually. + +The post-install script also configures `librefetch` as the download +agent for `libre://` URLs, for compatability with PKGBUILDs that used +a previous version of librefetch. + +There are 5 modes: - * `download-create`: The default mode. First try `download` mode, - then `create` mode. * `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. * `help`: Print `librefetch` usage information. +The normal mode of operation is `download` mode. If `download` mode +fails, it may choose to try `create` mode. + ## OPTIONS * `-C`: Force `create` mode (don't download) @@ -40,6 +49,24 @@ There are 6 modes: * `-P` | `--print`: Use `print` mode: print the effective build script. * `-h` | `--help`: Use `help` mode: Show useage information. +## DOWNLOAD MODE + +If begins with the string `libre://`, it is replaced with +the first value in `MIRRORS`, as configured in `librefetch.conf(5)`; +this is for compatability with PKGBUILDs that used a previous version +of librefetch. + +It uses `DOWNLOADER`, as configured in `librefetch.conf` to attempt to +download the source tarball from that URL. If that fails, and +following conditions are met, it proceeds to `create` mode: + + * The `-D` flag has not been specified to inhibit `create` mode. + * The `` begins with one of the values in `MIRRORS`. + +The latter requirement allows librefetch to be used as a generic +HTTP(S) download agent, that can automatically create files from +whitelisted locations. + ## CREATE MODE The principle of `create` mode is that a special `PKGBUILD(5)`, called @@ -155,6 +182,11 @@ The following modifications are made to makepkg: See `librefetch.conf(5)` for details on configuring librefetch using the `librefetch.conf` file. +## BUGS + +In download mode, if the local download location contains the string +`%u`, it will be replaced by the URL being downloaded from. + ## SEE ALSO librefetch.conf(5), makepkg(8), PKGBUILD(5), SRCBUILD(5) diff --git a/src/librefetch/librefetch.conf.5.ronn b/src/librefetch/librefetch.conf.5.ronn index 7b25400..6158104 100644 --- a/src/librefetch/librefetch.conf.5.ronn +++ b/src/librefetch/librefetch.conf.5.ronn @@ -24,14 +24,19 @@ If `$XDG_CONFIG_HOME` is not set, a default value is set: ## OPTIONS - * `MIRROR='https://repo.parabolagnulinux.org/other/'`: - Files from within this tree will be attempted to be built if - downloading them fails. Also, `libre://` expands to this - location. + * `MIRRORS=( ... )`: + A list of locations that generated source tarballs may be located + at. If a URL begins with `libre://`, then `libre://` is replaced + with the first location listed here. * `DOWNLOADER='/usr/bin/curl -fLC - --retry 3 --retry-delay 3 -o %o %u'`: The HTTP client to use when downloading pre-built source tarballs - in download mode. + in download mode. The format and semantics are similar to + `DLAGENTS` in `makepkg.conf`(5). If present, `%u` will be replaced + with the download URL (correctly quoted), otherwise the download + URL will be appended to the end of the command. If present, `%o` + will be replaced with the local filename that it should be + downloaded to. ## SEE ALSO -librefetch(8) +librefetch(8), makepkg.conf(5) -- cgit v1.2.3-2-g168b From 0ab5354f379e27ad863903953044a41382ad50a6 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 5 Jan 2014 20:43:41 -0500 Subject: librefetch: parse an '--' argument correctly --- 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 819a51a..c723721 100755 --- a/src/librefetch/librefetch +++ b/src/librefetch/librefetch @@ -208,6 +208,7 @@ parse_options() { -P|--print) mode=print;; -p) BUILDFILE="$(readlink -m -- "$opt")";; -h|--help) mode=help;; + --) shift; break;; -*) if in_array "${arg}" "${makepkg_argall[@]}"; then makepkg_opts+=("$arg") @@ -217,7 +218,6 @@ parse_options() { return 1 fi ;; - --) shift; break;; *) extra_opts+=("$arg");; esac shift -- cgit v1.2.3-2-g168b From a6ce111ab2fd71e0c13f5e165addeb18a4125f1e Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 20 Jan 2014 00:47:41 -0500 Subject: librefetch: improve error handling --- src/librefetch/librefetch | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'src/librefetch') diff --git a/src/librefetch/librefetch b/src/librefetch/librefetch index c723721..87a55cd 100755 --- a/src/librefetch/librefetch +++ b/src/librefetch/librefetch @@ -18,12 +18,12 @@ # You should have received a copy of the GNU General Public License # along with Parabola. If not, see . -. $(librelib conf.sh) -. libremessages +. $(librelib conf) +. $(librelib messages) +setup_traps declare -r tempdir="$(mktemp -d --tmpdir ${0##*/}.XXXXXXXXXXX)" -cleanup() { rm -rf -- "$tempdir"; } -trap cleanup EXIT +trap "rm -rf -- $(printf '%q' "$tempdir")" EXIT cmd=${0##*/} usage() { @@ -91,10 +91,15 @@ main() { local BUILDFILEDIR="${BUILDFILE%/*}" if [[ -f "${BUILDFILEDIR}/SRCBUILD" ]]; then BUILDFILE="${BUILDFILEDIR}/SRCBUILD" - srcbuild="$(modified_srcbuild "$BUILDFILE")" - else - srcbuild="$(modified_pkgbuild "$BUILDFILE")" fi + if [[ ! -f "$BUILDFILE" ]]; then + error "%s does not exist." "$BUILDFILE" + exit 1 + fi + case "$BUILDFILE" in + */SRCBUILD) srcbuild="$(modified_srcbuild "$BUILDFILE")";; + *) srcbuild="$(modified_pkgbuild "$BUILDFILE")";; + esac makepkg="$(modified_makepkg "$(which makepkg)")" # Mode: checksums ###################################################### -- cgit v1.2.3-2-g168b From b129824bfc9c5c85cadf98dfb724405d63dfc6c3 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 20 Jan 2014 00:59:48 -0500 Subject: normalize to use >&2 instead of /dev/stderr --- src/librefetch/librefetch | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/librefetch') diff --git a/src/librefetch/librefetch b/src/librefetch/librefetch index 87a55cd..5556ddd 100755 --- a/src/librefetch/librefetch +++ b/src/librefetch/librefetch @@ -161,7 +161,7 @@ main() { dlcmd="${dlcmd//\%o/$(printf '%q' "$dst")}" dlcmd="${dlcmd//\%u/$(printf '%q' "$src")}" - { eval "$dlcmd"; } >> /dev/stderr && return 0 + { eval "$dlcmd"; } >&2 && return 0 fi # Mode: create ######################################################### @@ -173,7 +173,7 @@ main() { export pkg_file=$dst cd "$BUILDFILEDIR" - "$makepkg" "${makepkg_opts[@]}" -p "$srcbuild" >> /dev/stderr || return $? + "$makepkg" "${makepkg_opts[@]}" -p "$srcbuild" >&2 || return $? fi } @@ -235,15 +235,15 @@ parse_options() { :;; checksums|print) # don't take any extra arguments if [[ ${#extra_opts[@]} != 0 ]]; then - print "%s: found extra non-flag arguments: %s" "$cmd" "${extra_opts[*]}" >> /dev/stderr - usage >> /dev/stderr + 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[@]} >> /dev/stderr - usage >> /dev/stderr + 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-2-g168b From 904702fba288da6c95044b528911966613e54935 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 20 Jan 2014 11:37:40 -0500 Subject: librefetch: fix the %u bug by deferring variable evaluation until the eval. --- src/librefetch/librefetch | 4 ++-- src/librefetch/librefetch.8.ronn | 5 ----- 2 files changed, 2 insertions(+), 7 deletions(-) (limited to 'src/librefetch') diff --git a/src/librefetch/librefetch b/src/librefetch/librefetch index 5556ddd..443b4f6 100755 --- a/src/librefetch/librefetch +++ b/src/librefetch/librefetch @@ -158,8 +158,8 @@ main() { local dlcmd="${DOWNLOADER}" [[ $dlcmd = *%u* ]] || dlcmd="$dlcmd %u" - dlcmd="${dlcmd//\%o/$(printf '%q' "$dst")}" - dlcmd="${dlcmd//\%u/$(printf '%q' "$src")}" + dlcmd="${dlcmd//\%o/"\$dst"}" + dlcmd="${dlcmd//\%u/"\$src"}" { eval "$dlcmd"; } >&2 && return 0 fi diff --git a/src/librefetch/librefetch.8.ronn b/src/librefetch/librefetch.8.ronn index c7247d5..7d2dfb3 100644 --- a/src/librefetch/librefetch.8.ronn +++ b/src/librefetch/librefetch.8.ronn @@ -182,11 +182,6 @@ The following modifications are made to makepkg: See `librefetch.conf(5)` for details on configuring librefetch using the `librefetch.conf` file. -## BUGS - -In download mode, if the local download location contains the string -`%u`, it will be replaced by the URL being downloaded from. - ## SEE ALSO librefetch.conf(5), makepkg(8), PKGBUILD(5), SRCBUILD(5) -- cgit v1.2.3-2-g168b From ea11eca851e1b54e36d310f4d69e099f169191e8 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 2 Feb 2014 00:05:22 -0500 Subject: I forgot to bump the copyright year on all the files I've touched this year --- 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 443b4f6..90c40db 100755 --- a/src/librefetch/librefetch +++ b/src/librefetch/librefetch @@ -1,7 +1,7 @@ #!/usr/bin/env bash # librefetch # -# Copyright 2013 Luke Shumaker +# Copyright 2013-2014 Luke Shumaker # # This file is part of Parabola. # -- cgit v1.2.3-2-g168b From c43f0808583070a22e904cd650e8ed17fe781806 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 2 Feb 2014 00:20:19 -0500 Subject: Normalize to use the string "Copyright (C)" --- 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 90c40db..4ecc8fe 100755 --- a/src/librefetch/librefetch +++ b/src/librefetch/librefetch @@ -1,7 +1,7 @@ #!/usr/bin/env bash # librefetch # -# Copyright 2013-2014 Luke Shumaker +# Copyright (C) 2013-2014 Luke Shumaker # # This file is part of Parabola. # -- cgit v1.2.3-2-g168b From 39a5bee5b060a092cbc6f9b40295bb8853e760a9 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 9 Feb 2014 14:20:07 -0500 Subject: librefetch: touch symlinks correctly, don't be tricked by files that look like flags --- 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 4ecc8fe..82c8703 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/,/done/d - /^\}$/ifind . -exec touch --date="1990-01-01 0:0:0 +0" {} + + /^\}$/ifind . -exec touch --no-dereference --date="1990-01-01 0:0:0 +0" -- {} + } /download_sources\(\) \{/ { -- cgit v1.2.3-2-g168b From d25f30f25ce61367c81133c9cd01fe3169d8f6c0 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Fri, 21 Mar 2014 14:39:06 -0400 Subject: Do an audit of copyright and license claims --- src/librefetch/librefetch | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/librefetch') diff --git a/src/librefetch/librefetch b/src/librefetch/librefetch index 82c8703..4f2d788 100755 --- a/src/librefetch/librefetch +++ b/src/librefetch/librefetch @@ -3,6 +3,8 @@ # # Copyright (C) 2013-2014 Luke Shumaker # +# License: GNU GPLv3+ +# # This file is part of Parabola. # # Parabola is free software: you can redistribute it and/or modify -- cgit v1.2.3-2-g168b From 9c0e1f70df2de45b6b4d0525b64f517ff2533e1b Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 22 Mar 2014 18:34:23 -0400 Subject: Fix librefetch to quote correctly with Bash 4.3 --- src/librefetch/librefetch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/librefetch') diff --git a/src/librefetch/librefetch b/src/librefetch/librefetch index 4f2d788..fdc7e00 100755 --- a/src/librefetch/librefetch +++ b/src/librefetch/librefetch @@ -160,8 +160,8 @@ main() { local dlcmd="${DOWNLOADER}" [[ $dlcmd = *%u* ]] || dlcmd="$dlcmd %u" - dlcmd="${dlcmd//\%o/"\$dst"}" - dlcmd="${dlcmd//\%u/"\$src"}" + dlcmd="${dlcmd//\%o/\"\$dst\"}" + dlcmd="${dlcmd//\%u/\"\$src\"}" { eval "$dlcmd"; } >&2 && return 0 fi -- cgit v1.2.3-2-g168b From bcdde66dc12bb7ebd8d6cf4833115b719b24f2e1 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 25 Mar 2014 21:03:02 -0400 Subject: touch up the librefetch(8) man page --- src/librefetch/librefetch.8.ronn | 59 ++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 29 deletions(-) (limited to 'src/librefetch') diff --git a/src/librefetch/librefetch.8.ronn b/src/librefetch/librefetch.8.ronn index 7d2dfb3..895d063 100644 --- a/src/librefetch/librefetch.8.ronn +++ b/src/librefetch/librefetch.8.ronn @@ -11,7 +11,7 @@ librefetch(8) -- downloads or creates a liberated source tarball `librefetch` is a program to streamline creation of custom source tarballs for `PKGBUILD(5)` files. -If a URL mentioned in the `source` array in a `PKGUILD` is in a +If a URL mentioned in the 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. @@ -52,16 +52,16 @@ fails, it may choose to try `create` mode. ## DOWNLOAD MODE If begins with the string `libre://`, it is replaced with -the first value in `MIRRORS`, as configured in `librefetch.conf(5)`; +the first value in , as configured in `librefetch.conf(5)`; this is for compatability with PKGBUILDs that used a previous version of librefetch. -It uses `DOWNLOADER`, as configured in `librefetch.conf` to attempt to +It uses , as configured in `librefetch.conf` to attempt to download the source tarball from that URL. If that fails, and following conditions are met, it proceeds to `create` mode: * The `-D` flag has not been specified to inhibit `create` mode. - * The `` begins with one of the values in `MIRRORS`. + * The begins with one of the values in . The latter requirement allows librefetch to be used as a generic HTTP(S) download agent, that can automatically create files from @@ -70,13 +70,13 @@ whitelisted locations. ## CREATE MODE The principle of `create` mode is that a special `PKGBUILD(5)`, called -a `SRCBUILD(5)`, installs source files to `$pkgdir`, and the resulting -"package" is then used as a source tarball. The `SRCBUILD` exists in -the same directory as the `PKGBUILD`. It can be created manually, or -generated on-the-fly from the `PKGBUILD`. Extra steps are taken to -ensure that as long as the same directory contents go in, an identical -tarball will come out--the checksum of the file should not change -based on when it is built or who builds it. +`SRCBUILD(5)`, that installs source files to <$pkgdir>, and the +resulting "package" is then used as a source tarball. The `SRCBUILD` +exists in the same directory as the `PKGBUILD`. It can be created +manually, or generated on-the-fly from the `PKGBUILD`. Extra steps +are taken to ensure that as long as the same directory contents go in, +an identical tarball will come out--the checksum of the file should +not change based on when it is built or who builds it. The `SRCBUILD` is either created, or sanitized if it already exists, then fed to a modified version of `makepkg(8)`. @@ -98,14 +98,14 @@ file can be printed instead of executed with `print` mode. ### PRE-EXISTING SRCBUILD The use of `SRCBUILD` files pre-dates `librefetch`. By convention, -they set `PKGDEST` and `PKGEXT` in `package()` in order to modify the +they set and in `package()` in order to modify the behavior of `makepkg`. Because a modified version of `makepkg` is used, this interferes with the correct behavior. To compensate for this, lines containing "`PKGDEST=`" or "`PKGEXT=`" are deleted from the `SRCBUILD`. The general idea is that `build()` makes any modifications to the -source, then `package()` copies it from `$srcdir` to `$pkgdir`. +source, then `package()` copies it from <$srcdir> to <$pkgdir>. ### SRCBUILD FROM PKGBUILD @@ -131,31 +131,32 @@ Following is a table of the translations. makedepends = mkdepends Functions prepare() { :; } - build() { mksource; } - check() { :; } + build() { mksource; } + check() { :; } package() { cp -a "$srcdir"/*/ "$pkgdir/"; } The `mksource()` function does not need to be defined. If it isn't defined, then no transformations will be made to the source between it -being extracted to `$srcdir` and copied to `$pkgdir`. +being extracted to <$srcdir> and copied to <$pkgdir>. In summary: - * Set `mksource=()` and `mkmd5sums=(`) to act as `source=(`) and - `md5sums=()` + * Set and to act as and + , respectively. * Declare a `mksource()` function to make modifications to the source, if nescessary. Other changes: - * `pkgname` is set to `pkgbase`, or the first element of the - `pkgname` array. - * `options=()` is set have `makepkg` avoid making changes to - `$pkgdir`. The exact change is: + * is set to , or the first element of the + array (the effect is that split packaging is turnes + off). + * is set have `makepkg` avoid making changes to + <$pkgdir>. The exact change is: options=(!strip docs libtool staticlibs emptydirs !zipman purge !upx) - * `PURGE_TARGETS=()` has vcs directories added to it: + * has vcs directories added to it: PURGE_TARGETS=(.bzr/ .cvs/ .git/ .hg/ .svn/ .makepkg/) @@ -163,18 +164,18 @@ Other changes: The following modifications are made to makepkg: - * Allow us to manipulate the output file (`$pkg_file`) - * Do not include metadata in the output file (`${comp_files[@]}`) + * Allow us to manipulate the output file (<$pkg_file>) + * Do not include metadata in the output file (<${comp_files[@]}>) * Force 'ustar' tar format, don't allow it to upgrade to 'pax' to store extended file attributes. * Don't symlink the resulting file into the current directory. - * `PURGE_TARGETS` interprets an item as a directory if it ends with a + * interprets an item as a directory if it ends with a slash ("/"). - * Timestamps in `$pkgdir` are reset to "1990-01-01 0:0:0 +0", so that + * 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. - * append `-libre` to `$srcdir` - * append `-libre` to `$pkgbasedir` (which becomes `$pkgdir`) + * append `-libre` to <$srcdir> + * append `-libre` to <$pkgbasedir> (which becomes <$pkgdir>) * Don't check if the package has already been built. ## CONFIGURATION -- cgit v1.2.3-2-g168b 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-2-g168b 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-2-g168b 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-2-g168b 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-2-g168b 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-2-g168b 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-2-g168b 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-2-g168b 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-2-g168b 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-2-g168b 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-2-g168b