summaryrefslogtreecommitdiff
path: root/src/librefetch
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2014-06-16 18:58:28 -0400
committerLuke Shumaker <LukeShu@sbcglobal.net>2014-06-16 18:58:28 -0400
commit813bfa255a1e46f05e08dcb587b8f417b995b2d4 (patch)
treed2feedc9b750edf52788c767cc666daebb8d3884 /src/librefetch
parent8831cc585ae8e9071f8c022bdfaf75e42029d7e4 (diff)
parent5051daebf722a9020b015feabc4c39e6bdb187f1 (diff)
Merge branch 'master' of ssh://projects.parabolagnulinux.org:1863/~git/packages/libretools
Conflicts: src/librefetch/librefetch.8.ronn
Diffstat (limited to 'src/librefetch')
-rwxr-xr-xsrc/librefetch/librefetch61
-rw-r--r--src/librefetch/librefetch.8.ronn28
2 files changed, 62 insertions, 27 deletions
diff --git a/src/librefetch/librefetch b/src/librefetch/librefetch
index fdc7e00..8b02205 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
@@ -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"
@@ -70,7 +71,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"
}
@@ -79,13 +81,27 @@ main() {
makepkg_opts=()
extra_opts=()
mode=download-create
- parse_options "$@"
+ if ! parse_options "$@"; then
+ usage >&2
+ exit 1
+ fi
# Mode: help ###########################################################
if [[ $mode =~ help ]]; then
usage
- return 0
+ exit 0
+ fi
+
+ ########################################################################
+
+ makepkg="$(modified_makepkg "$(which makepkg)")"
+
+ # Mode: makepkg ########################################################
+
+ if [[ $mode =~ makepkg ]]; then
+ cat "$makepkg"
+ exit 0
fi
########################################################################
@@ -102,7 +118,6 @@ main() {
*/SRCBUILD) srcbuild="$(modified_srcbuild "$BUILDFILE")";;
*) srcbuild="$(modified_pkgbuild "$BUILDFILE")";;
esac
- makepkg="$(modified_makepkg "$(which makepkg)")"
# Mode: checksums ######################################################
@@ -112,14 +127,14 @@ main() {
PKGBUILD) sed -e 's/^[a-z]/mk&/' -e 's/^\s/ &/';;
SRCBUILD) cat;;
esac
- return 0
+ exit 0
fi
- # Mode: print ##########################################################
+ # Mode: srcbuild #######################################################
- if [[ $mode =~ print ]]; then
+ if [[ $mode =~ srcbuild ]]; then
cat "$srcbuild"
- return 0
+ exit 0
fi
########################################################################
@@ -137,7 +152,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
@@ -163,7 +178,7 @@ main() {
dlcmd="${dlcmd//\%o/\"\$dst\"}"
dlcmd="${dlcmd//\%u/\"\$src\"}"
- { eval "$dlcmd"; } >&2 && return 0
+ { eval "$dlcmd"; } >&2 && exit 0
fi
# Mode: create #########################################################
@@ -175,7 +190,7 @@ main() {
export pkg_file=$dst
cd "$BUILDFILEDIR"
- "$makepkg" "${makepkg_opts[@]}" -p "$srcbuild" >&2 || return $?
+ "$makepkg" "${makepkg_opts[@]}" -p "$srcbuild" >&2 || exit $?
fi
}
@@ -212,7 +227,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;;
@@ -221,7 +237,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
;;
@@ -235,17 +251,15 @@ 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
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
;;
@@ -259,12 +273,16 @@ 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 | bsdtar --null --files-from - --format=ustar --no-recursion \1 - |/
s/create_signature .*/&; return $?/ # do not procede to create symlinks
}
/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" -- {} +
}
@@ -273,6 +291,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$|:|
diff --git a/src/librefetch/librefetch.8.ronn b/src/librefetch/librefetch.8.ronn
index 895d063..6ee3ce8 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>] <SOURCE-URL> [<OUTPUT-FILE>]<br>
-`librefetch` `-`[`g`|`P`|`h`]
+`librefetch` `-`[`g`|`S`|`M`|`h`]
## DESCRIPTION
@@ -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
@@ -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,9 +47,15 @@ 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.
+Other options, if they are documented in `makepkg -h`, are passed to
+the modified copy of makepkg created during `create` mode.
+
## DOWNLOAD MODE
If <SOURCE-URL> begins with the string `libre://`, it is replaced with
@@ -93,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
@@ -174,10 +181,17 @@ 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.
+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