diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/chroot-tools/arch-nspawn.patch | 14 | ||||
-rwxr-xr-x | src/chroot-tools/librechroot | 2 | ||||
-rw-r--r-- | src/chroot-tools/makechrootpkg.sh.patch | 41 | ||||
-rw-r--r-- | src/chroot-tools/mkarchroot.patch | 10 | ||||
-rwxr-xr-x | src/gitget/gitget | 5 | ||||
-rwxr-xr-x | src/gitget/libregit | 9 | ||||
-rw-r--r-- | src/lib/libremessages.1.ronn | 10 | ||||
-rwxr-xr-x | src/librefetch/librefetch | 61 | ||||
-rw-r--r-- | src/librefetch/librefetch.8.ronn | 28 |
9 files changed, 114 insertions, 66 deletions
diff --git a/src/chroot-tools/arch-nspawn.patch b/src/chroot-tools/arch-nspawn.patch index afdf51a..5e0f10b 100644 --- a/src/chroot-tools/arch-nspawn.patch +++ b/src/chroot-tools/arch-nspawn.patch @@ -1,5 +1,5 @@ ---- arch-nspawn.in 2014-03-21 13:59:31.812992892 -0400 -+++ arch-nspawn 2014-03-21 14:24:23.520619552 -0400 +--- arch-nspawn.in 2014-05-11 00:58:42.030932904 -0400 ++++ arch-nspawn.ugly 2014-05-11 22:33:47.186717386 -0400 @@ -1,4 +1,6 @@ #!/bin/bash +# License: GNU GPLv2 @@ -7,3 +7,13 @@ # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; version 2 of the License. +@@ -103,7 +105,8 @@ + machine_name="${machine_name#-}" + fi + +-exec ${CARCH:+setarch "$CARCH"} systemd-nspawn -q \ ++CHROOTARCH="$(. $(librelib conf); get_var chroot CHROOTARCH "$CARCH")" ++exec ${CHROOTARCH:+setarch "$CHROOTARCH"} systemd-nspawn -q \ + -D "$working_dir" \ + --machine "$machine_name" \ + "${mount_args[@]}" \ diff --git a/src/chroot-tools/librechroot b/src/chroot-tools/librechroot index 6be9f09..4edcb2f 100755 --- a/src/chroot-tools/librechroot +++ b/src/chroot-tools/librechroot @@ -336,6 +336,8 @@ main() { printf '%q ' "${CHROOTEXTRAPKG[@]}" printf ')\n' fi + # TODO: only set CHROOTARCH if $CARCH != $(uname -m) + printf 'CHROOTARCH=%q\n' "$(uname -m)" } > "$copydir"/etc/libretools.d/chroot.conf if [[ $mode != delete ]]; then diff --git a/src/chroot-tools/makechrootpkg.sh.patch b/src/chroot-tools/makechrootpkg.sh.patch index 5cea39a..8180d89 100644 --- a/src/chroot-tools/makechrootpkg.sh.patch +++ b/src/chroot-tools/makechrootpkg.sh.patch @@ -1,5 +1,5 @@ ---- makechrootpkg.sh.in 2014-03-21 13:59:31.239683366 -0400 -+++ makechrootpkg.sh.ugly 2014-03-21 14:19:20.747789508 -0400 +--- makechrootpkg.sh.in 2014-05-10 22:03:27.956692573 -0400 ++++ makechrootpkg.sh.ugly 2014-05-10 22:09:15.376594518 -0400 @@ -1,4 +1,6 @@ #!/bin/bash +# License: GNU GPLv2 @@ -12,8 +12,8 @@ shopt -s nullglob +init_variables() { - _makepkg_args=(-s --noconfirm -L --holdver) - makepkg_args=("${_makepkg_args[@]}") + default_makepkg_args=(-s --noconfirm -L --holdver) + makepkg_args=("${default_makepkg_args[@]}") repack=false @@ -29,9 +32,10 @@ bindmounts_rw=() @@ -35,7 +35,7 @@ while getopts 'hcur:I:l:nTD:d:' arg; do case "$arg" in h) usage ;; -@@ -93,9 +98,6 @@ +@@ -91,9 +96,6 @@ [[ ! -d $chrootdir ]] && die "No chroot dir defined, or invalid path '%s'" "$passeddir" [[ ! -d $chrootdir/root ]] && die "Missing chroot dir root directory. Try using: mkarchroot %s/root base-devel" "$chrootdir" @@ -45,7 +45,7 @@ if [[ ${copy:0:1} = / ]]; then copydir=$copy else -@@ -115,30 +117,48 @@ +@@ -113,30 +115,48 @@ esac done @@ -100,11 +100,14 @@ # Get a read lock on the root chroot to make # sure we don't clone a half-updated chroot slock 8 "$chrootdir/root.lock" "Locking clean chroot" -@@ -159,11 +179,16 @@ +@@ -157,14 +177,19 @@ # Drop the read lock again lock_close 8 - fi + + # Update mtime + touch "$copydir" } -clean_temporary() { @@ -120,7 +123,7 @@ if [[ "$chroottype" == btrfs ]] && ! mountpoint -q "$copydir"; then btrfs subvolume delete "$copydir" >/dev/null || die "Unable to delete subvolume %s" "$copydir" -@@ -178,9 +203,14 @@ +@@ -179,9 +204,14 @@ stat_done } @@ -135,7 +138,7 @@ for install_pkg in "${install_pkgs[@]}"; do pkgname="${install_pkg##*/}" cp "$install_pkg" "$copydir/$pkgname" -@@ -193,11 +223,19 @@ +@@ -194,11 +224,19 @@ rm "$copydir/$pkgname" done @@ -157,7 +160,7 @@ $repack || rm -rf "$copydir/build" mkdir -p "$copydir/build" -@@ -236,12 +274,12 @@ +@@ -237,12 +275,12 @@ chown -R nobody "$copydir"/{build,pkgdest,srcpkgdest,logdest,srcdest,startdir} @@ -172,7 +175,7 @@ sed -i '/^PACKAGER=/d' "$copydir/etc/makepkg.conf" echo "PACKAGER='${PACKAGER}'" >> "$copydir/etc/makepkg.conf" fi -@@ -254,20 +292,38 @@ +@@ -255,20 +293,38 @@ chmod 440 "$copydir/etc/sudoers.d/nobody-pacman" fi @@ -213,7 +216,7 @@ makepkg --config="$copydir/etc/makepkg.conf" --verifysource -o else ( export SRCDEST BUILDDIR="$builddir" -@@ -277,10 +333,10 @@ +@@ -278,10 +334,10 @@ (( $? != 0 )) && die "Could not download sources." # Clean up garbage from verifysource @@ -226,7 +229,7 @@ # This function isn't run in makechrootpkg, # so no global variables local run_namcap="$1"; shift -@@ -291,6 +347,7 @@ +@@ -292,6 +348,7 @@ shopt -s nullglob # XXX: Workaround makepkg disliking read-only dirs @@ -234,7 +237,7 @@ ln -sft /srcdest /srcdest_host/* ln -sft /startdir /startdir_host/* -@@ -316,11 +373,29 @@ +@@ -317,11 +374,29 @@ # Safety check if [[ ! -w PKGBUILD ]]; then @@ -265,7 +268,7 @@ if $run_namcap; then pacman -S --needed --noconfirm namcap -@@ -333,12 +408,24 @@ +@@ -334,12 +409,24 @@ exit 0 } @@ -290,7 +293,7 @@ for l in "$copydir"/logdest/*; do [[ $l == */logpipe.* ]] && continue chown "$src_owner" "$l" -@@ -352,6 +439,10 @@ +@@ -353,6 +440,10 @@ } # }}} @@ -300,8 +303,8 @@ + umask 0022 - load_vars /etc/makepkg.conf -@@ -363,30 +454,45 @@ + load_vars "$USER_HOME/.makepkg.conf" +@@ -364,30 +455,45 @@ [[ -d $SRCPKGDEST ]] || SRCPKGDEST=$PWD [[ -d $LOGDEST ]] || LOGDEST=$PWD @@ -353,7 +356,7 @@ if (( ret != 0 )); then if $temp_chroot; then -@@ -397,3 +503,4 @@ +@@ -398,3 +504,4 @@ else true fi diff --git a/src/chroot-tools/mkarchroot.patch b/src/chroot-tools/mkarchroot.patch index 171b38a..9366d92 100644 --- a/src/chroot-tools/mkarchroot.patch +++ b/src/chroot-tools/mkarchroot.patch @@ -1,5 +1,5 @@ ---- mkarchroot.in 2014-03-21 13:59:31.593002027 -0400 -+++ mkarchroot.ugly 2014-03-21 14:23:12.027238102 -0400 +--- mkarchroot.in 2014-05-10 22:10:54.871326879 -0400 ++++ mkarchroot.ugly 2014-05-10 22:10:54.887993222 -0400 @@ -1,4 +1,6 @@ #!/bin/bash +# License: GNU GPLv2 @@ -7,19 +7,19 @@ # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; version 2 of the License. -@@ -65,6 +67,11 @@ +@@ -66,6 +68,11 @@ chmod 0755 "$working_dir" fi +_env=() +while read -r varname; do + _env+=("$varname=${!varname}") -+done < { declare -x | sed -r 's/^declare -x ([^=]*)=.*/\1/' | grep -i '_proxy$'; } ++done < <(declare -x | sed -r 's/^declare -x ([^=]*)=.*/\1/' | grep -i '_proxy$') +env -i "${_env[@]}" \ pacstrap -GMcd ${pac_conf:+-C "$pac_conf"} "$working_dir" \ "${cache_dirs[@]/#/--cachedir=}" "$@" || die 'Failed to install all packages' -@@ -72,7 +79,7 @@ +@@ -73,7 +80,7 @@ echo 'LANG=C' > "$working_dir/etc/locale.conf" echo "$CHROOT_VERSION" > "$working_dir/.arch-chroot" diff --git a/src/gitget/gitget b/src/gitget/gitget index bcc528c..fe5d46b 100755 --- a/src/gitget/gitget +++ b/src/gitget/gitget @@ -87,7 +87,7 @@ download_git_checkout() { fi fi msg2 "Updating %s %s repo..." "${name}" "git" - if ! git pull origin "$ref"; then + if ! { git fetch --all -p && git checkout "$ref" && git pull origin "$ref"; } ; then # only warn on failure to allow offline builds warning "Failure while updating %s %s repo" "${repo}" "git" fi @@ -145,8 +145,7 @@ download_git_bare() { } usage() { - print 'Usage: %s [OPTIONS] bare URL DIRECTORY' "${0##*/}" - print 'Usage: %s [OPTIONS] checkout URL DIRECTORY' "${0##*/}" + print 'Usage: %s [OPTIONS] [bare|checkout] URL DIRECTORY' "${0##*/}" print 'A URL-handler for git urls. Capable of updating or cloning.' echo prose "Clones or pulls from the git URL, to a local DIRECTORY. If diff --git a/src/gitget/libregit b/src/gitget/libregit index 25550e5..41aefc3 100755 --- a/src/gitget/libregit +++ b/src/gitget/libregit @@ -20,18 +20,17 @@ . libremessages usage() { - print 'Usage: %s repo ref dir' "${0##*/}" + print 'Usage: %s REPO REF DIR' "${0##*/}" print 'A compatability wrapper around `gitget checkout`' echo prose "This exists because gitget used to be called libregit, and took the arguments in this format, and I'm sure there are a few scripts floating around that use it." echo - prose "Clones or pulls from the git URL 'repo', and checks out the git - ref 'ref' to the directory 'dir'." + prose "Clones or pulls from the git URL '<REPO>', and checks out the git + ref '<REF>' to the directory '<DIR>'." } - main() { [[ $# == 3 ]] || { usage >&2; return 1; } repo=$1 @@ -40,3 +39,5 @@ main() { gitget checkout "${repo}#ref=${ref}" "${dir}" } + +main "$@" diff --git a/src/lib/libremessages.1.ronn b/src/lib/libremessages.1.ronn index d39dad0..2bf73a1 100644 --- a/src/lib/libremessages.1.ronn +++ b/src/lib/libremessages.1.ronn @@ -156,15 +156,16 @@ these, you could end up deleting a lot of someone's work. * `cleanup` [<EXIT_STATUS>]: *If* `setup_workdir` has been run, `rm -rf "$WORKDIR"`. If given - a numeric argument, it will then call `exit`(1) with that argument. + a numeric argument, it will then call `exit`(1) with that + argument, otherwise it calls `exit`(1) with a status of 0. * `abort`: Calls `msg` with the message "Aborting...", then calls - `cleanup 0`. + `cleanup 255`. * `die` <MESSAGE> [<ARGS>...]: Exactly like `error`, but calls `cleanup` and calls `exit`(1) - with a status of 1. + with a status of 255. ### LOCKFILE ROUTINES @@ -212,9 +213,6 @@ pull it into a separate program. xterm and rxvt (and their various <TERM> values; "rxvt-unicode-256color" is still rxvt). -Also, I think `abort` calling `cleanup 1` would make more sense than -`cleanup 0`. - ## SEE ALSO librelib(7), gettext(1), common.sh(3) 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 |