From 23a0d5b8b29a156467f929297584daed2f013c41 Mon Sep 17 00:00:00 2001 From: Dominic Cleal Date: Thu, 11 Feb 2016 12:10:13 +0000 Subject: [PATCH 01/72] Sign apt's Release file with multiple GPG keys The GPG config option and associated command arguments now accept multiple GPG keys, which are all used to sign the Release file. This makes it easier to roll keys, similar to the Debian archives which are signed with multiple release keys. --- bin/freight-cache | 17 +++++++++++++---- bin/freight-init | 17 ++++++++++++----- etc/freight.conf.example | 6 +++++- lib/freight/apt.sh | 25 +++++++++++++++---------- man/man1/freight-cache.1 | 4 ++-- man/man1/freight-cache.1.ronn | 2 +- man/man1/freight-init.1 | 4 ++-- man/man1/freight-init.1.ronn | 2 +- man/man5/freight.5 | 4 ++-- man/man5/freight.5.ronn | 2 +- 10 files changed, 54 insertions(+), 29 deletions(-) diff --git a/bin/freight-cache b/bin/freight-cache index c6e8fcc..6a6fd37 100755 --- a/bin/freight-cache +++ b/bin/freight-cache @@ -6,7 +6,7 @@ #/ Usage: freight cache [-k] [-g ] [-p ] [-c ] [-v] [-h] [/][...] #/ -k, --keep keep unreferenced versions of packages -#/ -g , --gpg= GPG key to use +#/ -g , --gpg= GPG key to use, may be given multiple times #/ -p , #/ --passphrase-file= path to file containing the passphrase of the GPG key #/ -c , --conf= config file to parse @@ -23,9 +23,18 @@ while [ "$#" -gt 0 ] do case "$1" in -k|--keep) KEEP=1 shift;; - -g|--gpg) GPG="$2" shift 2;; - -g*) GPG="$(echo "$1" | cut -c"3-")" shift;; - --gpg=*) GPG="$(echo "$1" | cut -c"7-")" shift;; + -g|--gpg) + [ -z "$GPG" ] && GPG=() + GPG+=("$2") + shift 2;; + -g*) + [ -z "$GPG" ] && GPG=() + GPG+=("$(echo "$1" | cut -c"3-")") + shift;; + --gpg=*) + [ -z "$GPG" ] && GPG=() + GPG+=("$(echo "$1" | cut -c"7-")") + shift;; -p|--passphrase-file) GPG_PASSPHRASE_FILE="$2" shift 2;; -p*) GPG_PASSPHRASE_FILE="$(echo "$1" | cut -c"3-")" shift;; --passphrase-file=*) GPG_PASSPHRASE_FILE="$(echo "$1" | cut -c"19-")" shift;; diff --git a/bin/freight-init b/bin/freight-init index a8671c5..597c477 100755 --- a/bin/freight-init +++ b/bin/freight-init @@ -17,6 +17,7 @@ set -e CONF="etc/freight.conf" +GPG=() usage() { grep "^#/" "$0" | cut -c"4-" >&2 @@ -25,9 +26,15 @@ usage() { while [ "$#" -gt 0 ] do case "$1" in - -g|--gpg) GPG="$2" shift 2;; - -g*) GPG="$(echo "$1" | cut -c"3-")" shift;; - --gpg=*) GPG="$(echo "$1" | cut -c"7-")" shift;; + -g|--gpg) + GPG+=("$2") + shift 2;; + -g*) + GPG+=("$(echo "$1" | cut -c"3-")") + shift;; + --gpg=*) + GPG+=("$(echo "$1" | cut -c"7-")") + shift;; -c|--conf) CONF="$2" shift 2;; -c*) CONF="$(echo "$1" | cut -c"3-")" shift;; --conf=*) CONF="$(echo "$1" | cut -c"8-")" shift;; @@ -50,7 +57,7 @@ do esac done DIRNAME="$(cd "${1:-"."}" && pwd)" -[ -z "$GPG" -o -z "$DIRNAME" ] && usage 1 +[ ${#GPG[@]} -eq 0 -o -z "$DIRNAME" ] && usage 1 # The default value for VARLIB and VARCACHE lies within DIRNAME but otherwise # follows the FHS style. @@ -67,7 +74,7 @@ mkdir -p "$(dirname "$CONF")" cat >"$CONF" <>"$CONF" [ "$ORIGIN" ] && echo "ORIGIN=\"$ORIGIN\"" >>"$CONF" diff --git a/etc/freight.conf.example b/etc/freight.conf.example index 8e8fa7c..446a16f 100644 --- a/etc/freight.conf.example +++ b/etc/freight.conf.example @@ -13,10 +13,14 @@ LABEL="Freight" # time (off). CACHE="off" -# GPG key to use to sign repositories. This is required by the `apt` +# GPG key(s) to use to sign repositories. This is required by the `apt` # repository provider. Use `gpg --gen-key` (see `gpg`(1) for more # details) to generate a key and put its email address here. +# +# Multiple addresses can be given in an array to sign the repository with +# them all. GPG="example@example.com" +# GPG=("example@example.com" "another@example.com") # Whether to follow symbolic links in `$VARLIB` to produce extra components # in the cache directory (on) or not (off). diff --git a/lib/freight/apt.sh b/lib/freight/apt.sh index ad6040c..2abde86 100644 --- a/lib/freight/apt.sh +++ b/lib/freight/apt.sh @@ -181,25 +181,30 @@ EOF } >"$DISTCACHE/Release" - # Sign the top-level `Release` file with `gpg`. - gpg -abs$([ "$TTY" ] || echo " --no-tty") --use-agent -u"$GPG" \ - $([ "$GPG_PASSPHRASE_FILE" ] && echo " --batch --passphrase-fd 1 --passphrase-file $GPG_PASSPHRASE_FILE") \ - -o"$DISTCACHE/Release.gpg" "$DISTCACHE/Release" || { - cat <> $DISTCACHE/Release.gpg + rm -f $TMP/release_last_signature.gpg + done # Generate `pubkey.gpg` containing the plaintext public key and # `keyring.gpg` containing a complete GPG keyring containing only - # the appropriate public key. `keyring.gpg` is appropriate for + # the appropriate public keys. `keyring.gpg` is appropriate for # copying directly to `/etc/apt/trusted.gpg.d`. mkdir -m700 -p "$TMP/gpg" - gpg -q --export -a "$GPG" | + gpg -q --export -a ${GPG[*]} | tee "$VARCACHE/pubkey.gpg" | gpg -q --homedir "$TMP/gpg" --import chmod 644 "$TMP/gpg/pubring.gpg" diff --git a/man/man1/freight-cache.1 b/man/man1/freight-cache.1 index 51c4713..412308b 100644 --- a/man/man1/freight-cache.1 +++ b/man/man1/freight-cache.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "FREIGHT\-CACHE" "1" "January 2014" "" "Freight" +.TH "FREIGHT\-CACHE" "1" "February 2016" "" "Freight" . .SH "NAME" \fBfreight\-cache\fR \- (re)builds package repositories @@ -29,7 +29,7 @@ Keep unreferenced versions of packages\. This is different than keeping multiple . .TP \fB\-g\fR \fIemail\fR, \fB\-\-gpg=\fR\fIemail\fR -Use an alternate GPG key\. +Use an alternate GPG key\. May be given multiple times\. . .TP \fB\-p\fR \fIpassphrase file\fR, \fB\-\-passphrase\-file=\fR\fIpassphrase file\fR diff --git a/man/man1/freight-cache.1.ronn b/man/man1/freight-cache.1.ronn index 99d3f8c..ec994d8 100644 --- a/man/man1/freight-cache.1.ronn +++ b/man/man1/freight-cache.1.ronn @@ -20,7 +20,7 @@ From version 0.0.8 onwards, distros in an APT repository no longer share the con * `-k`, `--keep`: Keep unreferenced versions of packages. This is different than keeping multiple versions of a package in the repository, which is supported without any special options. * `-g` _email_, `--gpg=`_email_: - Use an alternate GPG key. + Use an alternate GPG key. May be given multiple times. * `-p` _passphrase file_, `--passphrase-file=`_passphrase file_: Use an alternate file containing the GPG key passphrase. This file should obviously be protected and only readable by the user running Freight. * `-c` _conf_, `--conf=`_conf_: diff --git a/man/man1/freight-init.1 b/man/man1/freight-init.1 index 6a36afd..9dfe102 100644 --- a/man/man1/freight-init.1 +++ b/man/man1/freight-init.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "FREIGHT\-INIT" "1" "January 2014" "" "Freight" +.TH "FREIGHT\-INIT" "1" "February 2016" "" "Freight" . .SH "NAME" \fBfreight\-init\fR \- initialize a Freight directory @@ -22,7 +22,7 @@ Configuration is stored in \fB_dirname_/\.freight\.conf\fR\. . .TP \fB\-g\fR \fIgpg\fR, \fB\-\-gpg=\fR\fIgpg\fR` -GPG key\. +GPG key\. May be given multiple times\. . .TP \fB\-l\fR \fIvarlib\fR, \fB\-\-varlib=\fR\fIvarlib\fB_\fR\fR diff --git a/man/man1/freight-init.1.ronn b/man/man1/freight-init.1.ronn index c010f2a..210d0e4 100644 --- a/man/man1/freight-init.1.ronn +++ b/man/man1/freight-init.1.ronn @@ -16,7 +16,7 @@ Configuration is stored in `_dirname_/.freight.conf`. ## OPTIONS * `-g` _gpg_, `--gpg=`_gpg_`: - GPG key. + GPG key. May be given multiple times. * `-l` _varlib_, `--varlib=`_varlib`_: VARLIB directory to use. Defaults to `_dirname_/lib` * `--varcache=`_varcache`_: diff --git a/man/man5/freight.5 b/man/man5/freight.5 index 874db71..8e6f753 100644 --- a/man/man5/freight.5 +++ b/man/man5/freight.5 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "FREIGHT" "5" "January 2014" "" "Freight" +.TH "FREIGHT" "5" "February 2016" "" "Freight" . .SH "NAME" \fBfreight\fR \- Freight configuration @@ -37,7 +37,7 @@ The \fBLabel\fR field in the Debian archive\. . .TP \fBGPG\fR -The GPG key to use\. This value must be set either in a configuration file or by using the \fB\-g\fR option to \fBfreight\-cache\fR(1)\. +The GPG key(s) to use\. This value must be set either in a configuration file or by using the \fB\-g\fR option to \fBfreight\-cache\fR(1)\. Multiple keys can be given to sign the repository with more signatures\. . .TP \fBGPG_PASSPHRASE_FILE\fR diff --git a/man/man5/freight.5.ronn b/man/man5/freight.5.ronn index de75aa1..4a84c05 100644 --- a/man/man5/freight.5.ronn +++ b/man/man5/freight.5.ronn @@ -20,7 +20,7 @@ The Freight configuration is a `source`d shell script that defines a few importa * `CACHE`: _on_ to cache package control files or _off_ to read them from the packages on each `freight-cache`(1) run. * `GPG`: - The GPG key to use. This value must be set either in a configuration file or by using the `-g` option to `freight-cache`(1). + The GPG key(s) to use. This value must be set either in a configuration file or by using the `-g` option to `freight-cache`(1). Multiple keys can be given to sign the repository with more signatures. * `GPG_PASSPHRASE_FILE`: Pathname of a file containing the GPGP private key's passphrase. This sets the `--passphrase-fd` and `--passphrase-file` options to `gpg`(1). The passphrase file can be set either in a configuration file or by using the `-p` option to `freight-cache`(1). * `SYMLINKS`: From fbf0d24ea0a6e2f1e5070b376de8b64fe622c729 Mon Sep 17 00:00:00 2001 From: Youhei SASAKI Date: Sat, 28 Nov 2015 21:57:31 +0900 Subject: [PATCH 02/72] Add Date:, Valid-Until Signed-off-by: Youhei SASAKI --- lib/freight/apt.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/freight/apt.sh b/lib/freight/apt.sh index ad6040c..8796283 100644 --- a/lib/freight/apt.sh +++ b/lib/freight/apt.sh @@ -76,6 +76,8 @@ apt_filesize() { # Setup the repository for the distro named in the first argument, # including all packages read from `stdin`. apt_cache() { + REL_DATE="$(LC_ALL=en_US date '+%a, %d %b %Y %H:%M:%S %Z')" + VALID_DATE="Fri, 31 Nov 2038 00:00:00 JST" DIST="$1" SUITE="${SUITE:-$DIST}" @@ -129,6 +131,8 @@ Component: $COMP Origin: $ORIGIN Label: $LABEL Architecture: $ARCH +Date: $REL_DATE +Valid-Until: $VALID_DATE EOF gzip -c "$DISTCACHE/$COMP/binary-$ARCH/Packages" \ >"$DISTCACHE/$COMP/binary-$ARCH/Packages.gz" @@ -141,6 +145,8 @@ Component: $COMP Origin: $ORIGIN Label: $LABEL Architecture: source +Date: $REL_DATE +Valid-Until: $VALID_DATE EOF gzip -c "$DISTCACHE/$COMP/source/Sources" \ >"$DISTCACHE/$COMP/source/Sources.gz" @@ -158,6 +164,8 @@ Suite: $SUITE Codename: $DIST Components: $(echo "$COMPS" | tr \\n " ") Architectures: $ARCHS +Date: $REL_DATE +Valid-Until: $VALID_DATE EOF # Finish the top-level `Release` file with references and From 3b24261db6364f8561b4ef559a9d3dfc354f4b18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuli=20Sepp=C3=A4nen?= Date: Fri, 4 Mar 2016 11:05:28 +0200 Subject: [PATCH 03/72] Change project URL --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index a3cb9b9..d8437ec 100644 --- a/Makefile +++ b/Makefile @@ -55,7 +55,7 @@ build: -n freight -v $(VERSION) --iteration $(BUILD) -a all \ -d coreutils -d dash -d dpkg -d gnupg -d grep \ -m "Richard Crowley " \ - --url "https://github.com/rcrowley/freight" \ + --url "https://github.com/freight-team/freight" \ --description "A modern take on the Debian archive." \ -C debian . make uninstall prefix=/usr sysconfdir=/etc DESTDIR=debian From 5f9749813c56e0a79e1a911c0de7533c04f9454f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuli=20Sepp=C3=A4nen?= Date: Fri, 4 Mar 2016 11:06:03 +0200 Subject: [PATCH 04/72] Removed deploy target This target was specific to rcrowley's own setup --- Makefile | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Makefile b/Makefile index d8437ec..fd20246 100644 --- a/Makefile +++ b/Makefile @@ -60,10 +60,6 @@ build: -C debian . make uninstall prefix=/usr sysconfdir=/etc DESTDIR=debian -deploy: - scp freight_$(VERSION)-$(BUILD)_all.deb root@rcrowley.org: - ssh -t root@rcrowley.org "freight add freight_$(VERSION)-$(BUILD)_all.deb apt/squeeze apt/wheezy apt/sid apt/lucid apt/precise apt/quantal apt/raring apt/saucy apt/trusty && rm freight_$(VERSION)-$(BUILD)_all.deb && freight cache apt/squeeze apt/wheezy apt/sid apt/lucid apt/precise apt/quantal apt/raring apt/saucy apt/trusty" - man: find man -name \*.ronn | xargs -n1 ronn --manual=Freight --style=toc @@ -83,4 +79,4 @@ gh-pages: man git push origin gh-pages git checkout -q master -.PHONY: all install uninstall deb deploy man gh-pages +.PHONY: all install uninstall deb man gh-pages From ffda6d94672b78fdc611cc208c35c05ae0680edf Mon Sep 17 00:00:00 2001 From: Youhei SASAKI Date: Mon, 17 Aug 2015 14:55:57 +0900 Subject: [PATCH 05/72] Add support {,.orig,.debian}.tar.xz Signed-off-by: Youhei SASAKI --- bin/freight-add | 2 +- lib/freight/apt.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/freight-add b/bin/freight-add index 603b8d9..a2452c7 100755 --- a/bin/freight-add +++ b/bin/freight-add @@ -35,7 +35,7 @@ done while [ "$#" -gt 0 ] do case "$1" in - *.deb|*.dsc|*.orig.tar.gz|*.diff.gz|*.debian.tar.gz|*.tar.gz) + *.deb|*.dsc|*.orig.tar.gz|*.orig.tar.xz|*.diff.gz|*.debian.tar.gz|*.debian.tar.xz|*.tar.gz|*.tar.xz) PATHNAMES="$PATHNAMES $1" shift;; *.build|*.changes) shift;; *) break;; diff --git a/lib/freight/apt.sh b/lib/freight/apt.sh index aeda4d0..e32e9cb 100644 --- a/lib/freight/apt.sh +++ b/lib/freight/apt.sh @@ -112,7 +112,7 @@ apt_cache() { # and will find the associated *.orig.tar.gz, *.diff.gz, and/or # *.tar.gz as they are needed. *.dsc) apt_cache_source "$DIST" "$DISTCACHE" "$PATHNAME" "$COMP" "$PACKAGE";; - *.debian.tar.gz|*.diff.gz|*.orig.tar.gz|*.tar.gz|*.deb-control|*.dsc-cached) ;; + *.debian.tar.gz|*.debian.tar.xz|*.diff.gz|*.orig.tar.gz|*.orig.tar.xz|*.tar.gz|*.tar.xz|*.deb-control|*.dsc-cached) ;; *) echo "# [freight] skipping extraneous file $PATHNAME" >&2;; esac From 14d91ba88eeca9c1f022990d7bcfce03c34319bf Mon Sep 17 00:00:00 2001 From: Youhei SASAKI Date: Fri, 21 Aug 2015 17:35:38 +0900 Subject: [PATCH 06/72] support debian.tar.xz Signed-off-by: Youhei SASAKI --- lib/freight/apt.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/freight/apt.sh b/lib/freight/apt.sh index e32e9cb..bf4e632 100644 --- a/lib/freight/apt.sh +++ b/lib/freight/apt.sh @@ -349,14 +349,17 @@ apt_cache_source() { ORIG_VERSION="$(apt_source_origversion "$PATHNAME")" DIRNAME="$(dirname "$PATHNAME")" DSC_FILENAME="${NAME}_${VERSION%*:}.dsc" - DEBTAR_FILENAME="${NAME}_${VERSION%*:}.debian.tar.gz" + DEBTAR_GZ_FILENAME="${NAME}_${VERSION%*:}.debian.tar.gz" + DEBTAR_XZ_FILENAME="${NAME}_${VERSION%*:}.debian.tar.xz" DIFFGZ_FILENAME="${NAME}_${VERSION%*:}.diff.gz" ORIG_FILENAME="${NAME}_${ORIG_VERSION}.orig.tar.gz" TAR_FILENAME="${NAME}_${VERSION%*:}.tar.gz" # Find which style of diff they're using. - if [ -f "$VARLIB/apt/$DIST/$DIRNAME/$DEBTAR_FILENAME" ] - then DIFF_FILENAME=${DEBTAR_FILENAME} + if [ -f "$VARLIB/apt/$DIST/$DIRNAME/$DEBTAR_GZ_FILENAME" ] + then DIFF_FILENAME=${DEBTAR_GZ_FILENAME} + elif [ -f "$VARLIB/apt/$DIST/$DIRNAME/$DEBTAR_XZ_FILENAME" ] + then DIFF_FILENAME=${DEBTAR_XZ_FILENAME} else DIFF_FILENAME=${DIFFGZ_FILENAME} fi From be1975803883f0599e08c46f817b7ade6a38c354 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuli=20Sepp=C3=A4nen?= Date: Fri, 4 Mar 2016 12:57:55 +0200 Subject: [PATCH 07/72] Post-fork changes to README.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Samuli Seppänen --- README.md | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 92f7032..aa5502c 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,14 @@ A modern take on the Debian archive. +This repository has been forked (in the traditional sense of the word) from +Richard Crowley's [freight](https://github.com/rcrowley/freight) repository. A +fork had become necessary because the main project was not actively maintained +and serious issues had started to crop up. While fixes and improvements were +available in various freight GitHub forks, they were not merged to the main +project. This fork and the associated GitHub organization, +[freight-team](https://github.com/freight-team), attempts to fix these issues. + ## Usage Install Freight and create a minimal configuration in `/usr/local/etc/freight.conf` or `/etc/freight.conf` as appropriate containing the name of your GPG key: @@ -27,7 +35,7 @@ Serve `/var/cache/freight` via your favorite web server and install it as an APT ### From source - git clone git://github.com/rcrowley/freight.git + git clone git://github.com/freight-team/freight.git cd freight && make && sudo make install ### From a Debian archive @@ -58,8 +66,8 @@ There's also [French documentation](http://blog.valouille.fr/2014/03/creer-un-de ## Contribute -Freight is [BSD-licensed](https://github.com/rcrowley/freight/blob/master/LICENSE) +Freight is [BSD-licensed](https://github.com/freight-team/freight/blob/master/LICENSE) -* Source code: -* Issue tracker: -* Wiki: +* Source code: +* Issue tracker: +* Wiki: From c75755258e7e02bbeb668e472474b19c01501cf0 Mon Sep 17 00:00:00 2001 From: Dominic Cleal Date: Fri, 4 Mar 2016 11:48:10 +0000 Subject: [PATCH 08/72] Add basic BATS test suite for freight-{add,cache} A set of tests for freight-add and freight-cache are added to check that an ordinary deb can be added and generated into a repository. A further test runs apt locally against the Freight cache to check the repo is functional. Fixes #5 --- .gitignore | 2 ++ .travis.yml | 3 +++ Makefile | 10 ++++++-- README.md | 8 +++++++ test/apt_add.bats | 29 +++++++++++++++++++++++ test/apt_cache.bats | 42 +++++++++++++++++++++++++++++++++ test/apt_helpers.bash | 12 ++++++++++ test/fixtures/apt.conf | 2 ++ test/fixtures/gpg.conf | 8 +++++++ test/fixtures/test_1.0_all.deb | Bin 0 -> 3592 bytes test/freight_helpers.bash | 41 ++++++++++++++++++++++++++++++++ 11 files changed, 155 insertions(+), 2 deletions(-) create mode 100644 .travis.yml create mode 100644 test/apt_add.bats create mode 100644 test/apt_cache.bats create mode 100644 test/apt_helpers.bash create mode 100644 test/fixtures/apt.conf create mode 100644 test/fixtures/gpg.conf create mode 100644 test/fixtures/test_1.0_all.deb create mode 100644 test/freight_helpers.bash diff --git a/.gitignore b/.gitignore index d1aa7b0..6f8cf2c 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,5 @@ *~ etc/freight.conf var +test/tmp +!test/fixtures/*.deb diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..6379564 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,3 @@ +sudo: false +script: + - make check diff --git a/Makefile b/Makefile index fd20246..bcfa07c 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ mandir=${prefix}/share/man all: clean: - rm -rf *.deb debian man/man*/*.html + rm -rf *.deb debian man/man*/*.html test/tmp find . -name '*~' -delete install: install-bin install-lib install-man install-sysconf @@ -79,4 +79,10 @@ gh-pages: man git push origin gh-pages git checkout -q master -.PHONY: all install uninstall deb man gh-pages +test/tmp/bats: + git clone https://github.com/sstephenson/bats test/tmp/bats + +check: test/tmp/bats + test/tmp/bats/bin/bats test/ + +.PHONY: all install uninstall deb man gh-pages check diff --git a/README.md b/README.md index aa5502c..9d410da 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Freight +[![Build Status](https://travis-ci.org/freight-team/freight.svg?branch=master)](https://travis-ci.org/freight-team/freight) + A modern take on the Debian archive. This repository has been forked (in the traditional sense of the word) from @@ -71,3 +73,9 @@ Freight is [BSD-licensed](https://github.com/freight-team/freight/blob/master/LI * Source code: * Issue tracker: * Wiki: + +### Test suite + +The Freight test suite can be executed by running `make check` from any git checkout of this repository. git and GnuPG are required for most tests, and extended tests require apt. + +Contributions should include a new test case where possible by extending one or more of the `test/*.bats` files. diff --git a/test/apt_add.bats b/test/apt_add.bats new file mode 100644 index 0000000..f84abe7 --- /dev/null +++ b/test/apt_add.bats @@ -0,0 +1,29 @@ +# vim: noet:ts=4:sw=4:ft=sh + +load freight_helpers + +setup() { + freight_init +} + +@test "freight-add adds package to distro main component" { + test "$(freight_add ${FIXTURES}/test_1.0_all.deb apt/example 2>&1)" = "# [freight] added ${FIXTURES}/test_1.0_all.deb to apt/example" + test -e ${FREIGHT_LIB}/apt/example/test_1.0_all.deb +} + +@test "freight-add adds package to a component" { + freight_add ${FIXTURES}/test_1.0_all.deb apt/example/comp + test -e ${FREIGHT_LIB}/apt/example/comp/test_1.0_all.deb +} + +@test "freight-add adds package and hard link to multiple components" { + freight_add ${FIXTURES}/test_1.0_all.deb apt/example/comp apt/example/another + test -e ${FREIGHT_LIB}/apt/example/comp/test_1.0_all.deb + test -e ${FREIGHT_LIB}/apt/example/another/test_1.0_all.deb + test $(stat -c '%i' ${FREIGHT_LIB}/apt/example/comp/*.deb) -eq $(stat -c '%i' ${FREIGHT_LIB}/apt/example/another/*.deb) +} + +@test "freight-add detects duplicate package" { + freight_add ${FIXTURES}/test_1.0_all.deb apt/example + test "$(freight_add ${FIXTURES}/test_1.0_all.deb apt/example 2>&1)" = "# [freight] apt/example already has ${FIXTURES}/test_1.0_all.deb" +} diff --git a/test/apt_cache.bats b/test/apt_cache.bats new file mode 100644 index 0000000..47a3a57 --- /dev/null +++ b/test/apt_cache.bats @@ -0,0 +1,42 @@ +# vim: noet:ts=4:sw=4:ft=sh + +load freight_helpers +load apt_helpers + +setup() { + freight_init + freight_add ${FIXTURES}/test_1.0_all.deb apt/example + freight_add ${FIXTURES}/test_1.0_all.deb apt/example/comp + configure_local_apt +} + +@test "freight-cache builds distro Release file" { + freight_cache -v + test -e ${FREIGHT_CACHE}/dists/example/Release + egrep "^Components: comp main" ${FREIGHT_CACHE}/dists/example/Release +} + +@test "freight-cache builds per-component Release file" { + freight_cache -v + test -e ${FREIGHT_CACHE}/dists/example/comp/binary-amd64/Release + test -e ${FREIGHT_CACHE}/dists/example/main/binary-amd64/Release +} + +@test "freight-cache builds pool" { + freight_cache -v + test -e ${FREIGHT_CACHE}/pool/example/comp/t/test/test_1.0_all.deb + test -e ${FREIGHT_CACHE}/pool/example/main/t/test/test_1.0_all.deb +} + +@test "freight-cache generates valid Release.gpg signature" { + freight_cache -v + gpg --verify ${FREIGHT_CACHE}/dists/example/Release.gpg ${FREIGHT_CACHE}/dists/example/Release +} + +@test "apt-get fetches package list" { + check_apt_support + freight_cache -v + echo "deb file://${FREIGHT_CACHE} example main" > ${TMPDIR}/apt/etc/apt/sources.list + apt-get -c ${FIXTURES}/apt.conf update + apt-cache -c ${FIXTURES}/apt.conf show test +} diff --git a/test/apt_helpers.bash b/test/apt_helpers.bash new file mode 100644 index 0000000..04ba1ed --- /dev/null +++ b/test/apt_helpers.bash @@ -0,0 +1,12 @@ +# vim: noet:ts=4:sw=4:ft=sh + +configure_local_apt() { + mkdir -p ${TMPDIR}/apt/etc/apt + mkdir -p ${TMPDIR}/apt/var/lib/apt + mkdir -p ${TMPDIR}/apt/var/cache/apt +} + +check_apt_support() { + type apt-get || skip "missing apt-get" + apt-get --version | grep Ver:.*deb || skip "missing apt-get deb support" +} diff --git a/test/fixtures/apt.conf b/test/fixtures/apt.conf new file mode 100644 index 0000000..fe68786 --- /dev/null +++ b/test/fixtures/apt.conf @@ -0,0 +1,2 @@ +Dir "./test/tmp/apt"; +Debug::NoLocking true; diff --git a/test/fixtures/gpg.conf b/test/fixtures/gpg.conf new file mode 100644 index 0000000..0c54e4b --- /dev/null +++ b/test/fixtures/gpg.conf @@ -0,0 +1,8 @@ +Key-Type: 1 +Key-Length: 1024 +Subkey-Type: 1 +Subkey-Length: 1024 +Name-Real: Freight Test Key +Name-Email: freight@example.com +Name-Comment: TEST USE ONLY +Expire-Date: 0 diff --git a/test/fixtures/test_1.0_all.deb b/test/fixtures/test_1.0_all.deb new file mode 100644 index 0000000000000000000000000000000000000000..42b9103fcb47ae2927fb0c35c354cd26bfe3b76a GIT binary patch literal 3592 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 Date: Sun, 6 Mar 2016 15:09:04 +0000 Subject: [PATCH 09/72] Run tests on both dash and bash (as sh) --- .travis.yml | 3 +++ Makefile | 12 ++++++++++-- bin/freight | 2 +- bin/freight-add | 2 +- bin/freight-cache | 2 +- bin/freight-clear-cache | 2 +- bin/freight-init | 2 +- 7 files changed, 18 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6379564..d4c5d45 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,6 @@ sudo: false +env: + - SH=dash + - SH=bash script: - make check diff --git a/Makefile b/Makefile index bcfa07c..2ca7c4a 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,8 @@ VERSION=0.3.5 BUILD=1 +SH=dash + prefix=/usr/local bindir=${prefix}/bin libdir=${prefix}/lib @@ -82,7 +84,13 @@ gh-pages: man test/tmp/bats: git clone https://github.com/sstephenson/bats test/tmp/bats -check: test/tmp/bats - test/tmp/bats/bin/bats test/ +test/tmp/bin: + mkdir -p test/tmp/bin + +test/tmp/bin/sh: test/tmp/bin + ln -sf $$(which $(SH)) test/tmp/bin/sh + +check: test/tmp/bats test/tmp/bin/sh + PATH=test/tmp/bin/:$$PATH test/tmp/bats/bin/bats test/ .PHONY: all install uninstall deb man gh-pages check diff --git a/bin/freight b/bin/freight index 1208b19..3a86b4a 100755 --- a/bin/freight +++ b/bin/freight @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env sh # `freight` dispatches to `freight-*` commands. diff --git a/bin/freight-add b/bin/freight-add index a2452c7..40d268e 100755 --- a/bin/freight-add +++ b/bin/freight-add @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env sh # Add a package to the Freight library. diff --git a/bin/freight-cache b/bin/freight-cache index 6a6fd37..bc3ddbd 100755 --- a/bin/freight-cache +++ b/bin/freight-cache @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env sh # Rebuild the Freight cache from the Freight library. The cache contains # actual repositories that are suitable targets for `apt-get` (and maybe diff --git a/bin/freight-clear-cache b/bin/freight-clear-cache index d120859..a60523a 100755 --- a/bin/freight-clear-cache +++ b/bin/freight-clear-cache @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env sh # Clear the cache that is built up during freight-cache runs # so that it can be regenerated on the next freight-cache invocation. diff --git a/bin/freight-init b/bin/freight-init index 597c477..e6dbe88 100755 --- a/bin/freight-init +++ b/bin/freight-init @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env sh # Initialize a Freight directory (similar to git init). From 0fbb0686523ccd346b5fbf91c82a3ac5037743bd Mon Sep 17 00:00:00 2001 From: Dominic Cleal Date: Sun, 6 Mar 2016 16:43:52 +0000 Subject: [PATCH 10/72] Test multiple GPG signatures --- test/apt_cache.bats | 7 +++++++ test/fixtures/gpg2.conf | 8 ++++++++ test/freight_helpers.bash | 1 + 3 files changed, 16 insertions(+) create mode 100644 test/fixtures/gpg2.conf diff --git a/test/apt_cache.bats b/test/apt_cache.bats index 47a3a57..9253b21 100644 --- a/test/apt_cache.bats +++ b/test/apt_cache.bats @@ -33,6 +33,13 @@ setup() { gpg --verify ${FREIGHT_CACHE}/dists/example/Release.gpg ${FREIGHT_CACHE}/dists/example/Release } +@test "freight-cache signs Release.gpg with two keys" { + sed -i 's/^GPG=.*/GPG="freight@example.com freight2@example.com"/' $FREIGHT_CONFIG + freight_cache -v + test $(grep -c BEGIN ${FREIGHT_CACHE}/dists/example/Release.gpg) -eq 2 + gpg --verify ${FREIGHT_CACHE}/dists/example/Release.gpg ${FREIGHT_CACHE}/dists/example/Release +} + @test "apt-get fetches package list" { check_apt_support freight_cache -v diff --git a/test/fixtures/gpg2.conf b/test/fixtures/gpg2.conf new file mode 100644 index 0000000..3d3971c --- /dev/null +++ b/test/fixtures/gpg2.conf @@ -0,0 +1,8 @@ +Key-Type: 1 +Key-Length: 1024 +Subkey-Type: 1 +Subkey-Length: 1024 +Name-Real: Freight Test Second Key +Name-Email: freight2@example.com +Name-Comment: TEST USE ONLY +Expire-Date: 0 diff --git a/test/freight_helpers.bash b/test/freight_helpers.bash index b3ab40b..aa5c990 100644 --- a/test/freight_helpers.bash +++ b/test/freight_helpers.bash @@ -37,5 +37,6 @@ gpg_init() { mkdir -p $GNUPGHOME chmod 0700 $GNUPGHOME gpg --batch --gen-key test/fixtures/gpg.conf + gpg --batch --gen-key test/fixtures/gpg2.conf fi } From a29a0bd859db41fd082952b0df0501c08f47178e Mon Sep 17 00:00:00 2001 From: Dominic Cleal Date: Sun, 6 Mar 2016 15:21:07 +0000 Subject: [PATCH 11/72] Replace bash-only GPG UID array with string Using a space-separated string of GPG UIDs is compatible with non-bash, POSIX compatible shells such as dash. Fixes #8 --- bin/freight-cache | 21 +++++++++++++++------ bin/freight-init | 24 ++++++++++++++++++------ etc/freight.conf.example | 5 ++--- lib/freight/apt.sh | 4 ++-- 4 files changed, 37 insertions(+), 17 deletions(-) diff --git a/bin/freight-cache b/bin/freight-cache index bc3ddbd..133b23a 100755 --- a/bin/freight-cache +++ b/bin/freight-cache @@ -24,16 +24,25 @@ do case "$1" in -k|--keep) KEEP=1 shift;; -g|--gpg) - [ -z "$GPG" ] && GPG=() - GPG+=("$2") + if [ -z "$GPG" ]; then + GPG=$2 + else + GPG="$GPG $2" + fi shift 2;; -g*) - [ -z "$GPG" ] && GPG=() - GPG+=("$(echo "$1" | cut -c"3-")") + if [ -z "$GPG" ]; then + GPG=$(echo "$1" | cut -c"3-") + else + GPG="$GPG $(echo "$1" | cut -c"3-")" + fi shift;; --gpg=*) - [ -z "$GPG" ] && GPG=() - GPG+=("$(echo "$1" | cut -c"7-")") + if [ -z "$GPG" ]; then + GPG=$(echo "$1" | cut -c"7-") + else + GPG="$GPG $(echo "$1" | cut -c"7-")" + fi shift;; -p|--passphrase-file) GPG_PASSPHRASE_FILE="$2" shift 2;; -p*) GPG_PASSPHRASE_FILE="$(echo "$1" | cut -c"3-")" shift;; diff --git a/bin/freight-init b/bin/freight-init index e6dbe88..55265d9 100755 --- a/bin/freight-init +++ b/bin/freight-init @@ -17,7 +17,7 @@ set -e CONF="etc/freight.conf" -GPG=() +GPG="" usage() { grep "^#/" "$0" | cut -c"4-" >&2 @@ -27,13 +27,25 @@ while [ "$#" -gt 0 ] do case "$1" in -g|--gpg) - GPG+=("$2") + if [ -z "$GPG" ]; then + GPG=$2 + else + GPG="$GPG $2" + fi shift 2;; -g*) - GPG+=("$(echo "$1" | cut -c"3-")") + if [ -z "$GPG" ]; then + GPG=$(echo "$1" | cut -c"3-") + else + GPG="$GPG $(echo "$1" | cut -c"3-")" + fi shift;; --gpg=*) - GPG+=("$(echo "$1" | cut -c"7-")") + if [ -z "$GPG" ]; then + GPG=$(echo "$1" | cut -c"7-") + else + GPG="$GPG $(echo "$1" | cut -c"7-")" + fi shift;; -c|--conf) CONF="$2" shift 2;; -c*) CONF="$(echo "$1" | cut -c"3-")" shift;; @@ -57,7 +69,7 @@ do esac done DIRNAME="$(cd "${1:-"."}" && pwd)" -[ ${#GPG[@]} -eq 0 -o -z "$DIRNAME" ] && usage 1 +[ -z "$GPG" -o -z "$DIRNAME" ] && usage 1 # The default value for VARLIB and VARCACHE lies within DIRNAME but otherwise # follows the FHS style. @@ -74,7 +86,7 @@ mkdir -p "$(dirname "$CONF")" cat >"$CONF" <>"$CONF" [ "$ORIGIN" ] && echo "ORIGIN=\"$ORIGIN\"" >>"$CONF" diff --git a/etc/freight.conf.example b/etc/freight.conf.example index 446a16f..771336c 100644 --- a/etc/freight.conf.example +++ b/etc/freight.conf.example @@ -17,10 +17,9 @@ CACHE="off" # repository provider. Use `gpg --gen-key` (see `gpg`(1) for more # details) to generate a key and put its email address here. # -# Multiple addresses can be given in an array to sign the repository with -# them all. +# Multiple addresses can be given sign the repository with them all. GPG="example@example.com" -# GPG=("example@example.com" "another@example.com") +# GPG="example@example.com another@example.com" # Whether to follow symbolic links in `$VARLIB` to produce extra components # in the cache directory (on) or not (off). diff --git a/lib/freight/apt.sh b/lib/freight/apt.sh index bf4e632..bb279ea 100644 --- a/lib/freight/apt.sh +++ b/lib/freight/apt.sh @@ -191,7 +191,7 @@ EOF # Sign the top-level `Release` file with `gpg`, for each key and # concatenate signatures. - for GPGKEY in ${GPG[@]}; do + for GPGKEY in $GPG; do gpg -abs$([ "$TTY" ] || echo " --no-tty") --use-agent -u"$GPGKEY" \ $([ "$GPG_PASSPHRASE_FILE" ] && echo " --batch --passphrase-fd 1 --passphrase-file $GPG_PASSPHRASE_FILE") \ -o"$TMP/release_last_signature.gpg" "$DISTCACHE/Release" || { @@ -212,7 +212,7 @@ EOF # the appropriate public keys. `keyring.gpg` is appropriate for # copying directly to `/etc/apt/trusted.gpg.d`. mkdir -m700 -p "$TMP/gpg" - gpg -q --export -a ${GPG[*]} | + gpg -q --export -a $GPG | tee "$VARCACHE/pubkey.gpg" | gpg -q --homedir "$TMP/gpg" --import chmod 644 "$TMP/gpg/pubring.gpg" From 6f246063e218e11fc34ab2d52329552703aac7ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuli=20Sepp=C3=A4nen?= Date: Mon, 7 Mar 2016 15:48:27 +0200 Subject: [PATCH 12/72] Add IRC notifications to .travis.yml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Samuli Seppänen --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index d4c5d45..5d9fcbf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,3 +4,5 @@ env: - SH=bash script: - make check +notifications: + irc: "chat.freenode.net#freight" From 944f20ea08275986ac22f2a5162e937ef000290f Mon Sep 17 00:00:00 2001 From: Michael Moll Date: Mon, 7 Mar 2016 14:48:30 +0100 Subject: [PATCH 13/72] reference IRC channel in README closes GH-7 --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 9d410da..e72e351 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # Freight +[![IRC channel](https://kiwiirc.com/buttons/irc.freenode.net/freight.png)](https://kiwiirc.com/client/irc.freenode.net/?#freight) [![Build Status](https://travis-ci.org/freight-team/freight.svg?branch=master)](https://travis-ci.org/freight-team/freight) A modern take on the Debian archive. From baf2bba663f964c92e6d55692893ff452335c70e Mon Sep 17 00:00:00 2001 From: Dominic Cleal Date: Mon, 7 Mar 2016 14:32:23 +0000 Subject: [PATCH 14/72] Rebuild manual --- README.md | 9 +++++---- man/man1/freight-add.1 | 2 +- man/man1/freight-cache.1 | 2 +- man/man1/freight-clear-cache.1 | 2 +- man/man1/freight-init.1 | 2 +- man/man1/freight.1 | 2 +- man/man5/freight.5 | 2 +- 7 files changed, 11 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index e72e351..480d366 100644 --- a/README.md +++ b/README.md @@ -62,10 +62,11 @@ There's also [French documentation](http://blog.valouille.fr/2014/03/creer-un-de ## Manuals -* [`freight`(1)](http://rcrowley.github.com/freight/freight.1.html) -* [`freight-add`(1)](http://rcrowley.github.com/freight/freight-add.1.html) -* [`freight-cache`(1)](http://rcrowley.github.com/freight/freight-cache.1.html) -* [`freight`(5)](http://rcrowley.github.com/freight/freight.5.html) +* [`freight`(1)](http://freight-team.github.io/freight/freight.1.html) +* [`freight-add`(1)](http://freight-team.github.io/freight/freight-add.1.html) +* [`freight-cache`(1)](http://freight-team.github.io/freight/freight-cache.1.html) +* [`freight-clear-cache`(1)](http://freight-team.github.io/freight/freight-clear-cache.1.html) +* [`freight`(5)](http://freight-team.github.io/freight/freight.5.html) ## Contribute diff --git a/man/man1/freight-add.1 b/man/man1/freight-add.1 index e8344bb..22cac9d 100644 --- a/man/man1/freight-add.1 +++ b/man/man1/freight-add.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "FREIGHT\-ADD" "1" "January 2014" "" "Freight" +.TH "FREIGHT\-ADD" "1" "March 2016" "" "Freight" . .SH "NAME" \fBfreight\-add\fR \- add a package to Freight diff --git a/man/man1/freight-cache.1 b/man/man1/freight-cache.1 index 412308b..6247662 100644 --- a/man/man1/freight-cache.1 +++ b/man/man1/freight-cache.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "FREIGHT\-CACHE" "1" "February 2016" "" "Freight" +.TH "FREIGHT\-CACHE" "1" "March 2016" "" "Freight" . .SH "NAME" \fBfreight\-cache\fR \- (re)builds package repositories diff --git a/man/man1/freight-clear-cache.1 b/man/man1/freight-clear-cache.1 index 04af341..55fdef2 100644 --- a/man/man1/freight-clear-cache.1 +++ b/man/man1/freight-clear-cache.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "FREIGHT\-CLEAR\-CACHE" "1" "July 2014" "" "Freight" +.TH "FREIGHT\-CLEAR\-CACHE" "1" "March 2016" "" "Freight" . .SH "NAME" \fBfreight\-clear\-cache\fR \- clears existing package repositories diff --git a/man/man1/freight-init.1 b/man/man1/freight-init.1 index 9dfe102..3026afd 100644 --- a/man/man1/freight-init.1 +++ b/man/man1/freight-init.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "FREIGHT\-INIT" "1" "February 2016" "" "Freight" +.TH "FREIGHT\-INIT" "1" "March 2016" "" "Freight" . .SH "NAME" \fBfreight\-init\fR \- initialize a Freight directory diff --git a/man/man1/freight.1 b/man/man1/freight.1 index 3f17ae5..71e9345 100644 --- a/man/man1/freight.1 +++ b/man/man1/freight.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "FREIGHT" "1" "January 2014" "" "Freight" +.TH "FREIGHT" "1" "March 2016" "" "Freight" . .SH "NAME" \fBfreight\fR \- a modern take on the Debian archive diff --git a/man/man5/freight.5 b/man/man5/freight.5 index 8e6f753..b4e7eaa 100644 --- a/man/man5/freight.5 +++ b/man/man5/freight.5 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "FREIGHT" "5" "February 2016" "" "Freight" +.TH "FREIGHT" "5" "March 2016" "" "Freight" . .SH "NAME" \fBfreight\fR \- Freight configuration From 10ded235e631faba12ecfd86ef7820b1584f3dc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuli=20Sepp=C3=A4nen?= Date: Wed, 9 Mar 2016 17:19:54 +0200 Subject: [PATCH 15/72] Update Debian installation instructions in README.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Samuli Seppänen --- README.md | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 480d366..10a9c92 100644 --- a/README.md +++ b/README.md @@ -43,11 +43,20 @@ Serve `/var/cache/freight` via your favorite web server and install it as an APT ### From a Debian archive - echo "deb http://packages.rcrowley.org $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/rcrowley.list - sudo wget -O /etc/apt/trusted.gpg.d/rcrowley.gpg http://packages.rcrowley.org/keyring.gpg + wget -O - https://swupdate.openvpn.net/repos/repo-public.gpg|sudo apt-key add - + echo "deb http://build.openvpn.net/freight_team $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/freight.list sudo apt-get update sudo apt-get -y install freight +### From a custom-made Debian package + +First [install FPM](https://github.com/jordansissel/fpm). Then clone the freight +repository, build a package and install it: + + git clone git://github.com/freight-team/freight.git + cd freight && make build + sudo dpkg -i freight_-_all.deb + ### From Fedora/EPEL repositories EL users must first [configure EPEL](http://fedoraproject.org/wiki/EPEL/FAQ#How_can_I_install_the_packages_from_the_EPEL_software_repository.3F). From c958bd590578942f48a6890d1f56d2e9b89eeef4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuli=20Sepp=C3=A4nen?= Date: Wed, 9 Mar 2016 17:20:19 +0200 Subject: [PATCH 16/72] Bump version to 0.3.6-2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Samuli Seppänen --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 2ca7c4a..daa3fb4 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ -VERSION=0.3.5 -BUILD=1 +VERSION=0.3.6 +BUILD=2 SH=dash From f1c309f72298d1634022aa828d34c9d839694639 Mon Sep 17 00:00:00 2001 From: Michael Moll Date: Mon, 7 Mar 2016 22:37:01 +0100 Subject: [PATCH 17/72] handle .tar.bz2 and .tar.lzma files --- bin/freight-add | 2 +- lib/freight/apt.sh | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/bin/freight-add b/bin/freight-add index 40d268e..2b197ec 100755 --- a/bin/freight-add +++ b/bin/freight-add @@ -35,7 +35,7 @@ done while [ "$#" -gt 0 ] do case "$1" in - *.deb|*.dsc|*.orig.tar.gz|*.orig.tar.xz|*.diff.gz|*.debian.tar.gz|*.debian.tar.xz|*.tar.gz|*.tar.xz) + *.deb|*.dsc|*.orig.tar.gz|*.orig.tar.bz2|*.orig.tar.xz|*.orig.tar.lzma|*.diff.gz|*.debian.tar.gz|*.debian.tar.bz2|*.debian.tar.xz|*.debian.tar.lzma|*.tar.gz|*.tar.bz2|*.tar.xz|*.tar.lzma) PATHNAMES="$PATHNAMES $1" shift;; *.build|*.changes) shift;; *) break;; diff --git a/lib/freight/apt.sh b/lib/freight/apt.sh index bb279ea..80d22a4 100644 --- a/lib/freight/apt.sh +++ b/lib/freight/apt.sh @@ -112,7 +112,7 @@ apt_cache() { # and will find the associated *.orig.tar.gz, *.diff.gz, and/or # *.tar.gz as they are needed. *.dsc) apt_cache_source "$DIST" "$DISTCACHE" "$PATHNAME" "$COMP" "$PACKAGE";; - *.debian.tar.gz|*.debian.tar.xz|*.diff.gz|*.orig.tar.gz|*.orig.tar.xz|*.tar.gz|*.tar.xz|*.deb-control|*.dsc-cached) ;; + *.debian.tar.gz|*.debian.tar.bz2|*.debian.tar.xz|*.debian.tar.lzma|*.diff.gz|*.orig.tar.gz|*.orig.tar.bz2|*.orig.tar.xz|*.orig.tar.lzma|*.tar.gz|*.tar.bz2|*.tar.xz|*.tar.lzma|*.deb-control|*.dsc-cached) ;; *) echo "# [freight] skipping extraneous file $PATHNAME" >&2;; esac @@ -350,7 +350,9 @@ apt_cache_source() { DIRNAME="$(dirname "$PATHNAME")" DSC_FILENAME="${NAME}_${VERSION%*:}.dsc" DEBTAR_GZ_FILENAME="${NAME}_${VERSION%*:}.debian.tar.gz" + DEBTAR_BZ2_FILENAME="${NAME}_${VERSION%*:}.debian.tar.bz2" DEBTAR_XZ_FILENAME="${NAME}_${VERSION%*:}.debian.tar.xz" + DEBTAR_LZMA_FILENAME="${NAME}_${VERSION%*:}.debian.tar.lzma" DIFFGZ_FILENAME="${NAME}_${VERSION%*:}.diff.gz" ORIG_FILENAME="${NAME}_${ORIG_VERSION}.orig.tar.gz" TAR_FILENAME="${NAME}_${VERSION%*:}.tar.gz" @@ -358,8 +360,12 @@ apt_cache_source() { # Find which style of diff they're using. if [ -f "$VARLIB/apt/$DIST/$DIRNAME/$DEBTAR_GZ_FILENAME" ] then DIFF_FILENAME=${DEBTAR_GZ_FILENAME} + elif [ -f "$VARLIB/apt/$DIST/$DIRNAME/$DEBTAR_BZ2_FILENAME" ] + then DIFF_FILENAME=${DEBTAR_BZ2_FILENAME} elif [ -f "$VARLIB/apt/$DIST/$DIRNAME/$DEBTAR_XZ_FILENAME" ] then DIFF_FILENAME=${DEBTAR_XZ_FILENAME} + elif [ -f "$VARLIB/apt/$DIST/$DIRNAME/$DEBTAR_LZMA_FILENAME" ] + then DIFF_FILENAME=${DEBTAR_LZMA_FILENAME} else DIFF_FILENAME=${DIFFGZ_FILENAME} fi From 5fa356817e5749e66639d199e811358fbaf575ee Mon Sep 17 00:00:00 2001 From: Bruno Ranieri Date: Wed, 9 Mar 2016 15:01:59 +0100 Subject: [PATCH 18/72] Fixed warnings about not removable non-empty folders in apt_clean() --- lib/freight/apt.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/freight/apt.sh b/lib/freight/apt.sh index 80d22a4..4832eec 100644 --- a/lib/freight/apt.sh +++ b/lib/freight/apt.sh @@ -460,5 +460,6 @@ apt_cache_source() { # Clean up old packages in the pool. apt_clean() { - find "$VARCACHE/pool" -links 1 -delete || true + find "$VARCACHE/pool" -links 1 -type f -delete + find "$VARCACHE/pool" -type d -empty -delete } From 785b8c585dde40ebcf861b79431b8ec339c38746 Mon Sep 17 00:00:00 2001 From: Dominic Cleal Date: Thu, 10 Mar 2016 15:07:30 +0000 Subject: [PATCH 19/72] Add tests for freight-cache with apt_clean Adds bats-assert for a useful collection of assertions, refactoring existing apt_add tests to use it for output/success checking. --- Makefile | 7 +++++-- test/apt_add.bats | 8 ++++++-- test/apt_cache.bats | 22 ++++++++++++++++++++++ test/fixtures/test_1.0_all.deb | Bin 3592 -> 892 bytes test/freight_helpers.bash | 2 ++ 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index daa3fb4..a51aa47 100644 --- a/Makefile +++ b/Makefile @@ -82,7 +82,10 @@ gh-pages: man git checkout -q master test/tmp/bats: - git clone https://github.com/sstephenson/bats test/tmp/bats + git clone --depth 1 https://github.com/sstephenson/bats.git test/tmp/bats + +test/tmp/bats-assert: + git clone --depth 1 https://github.com/jasonkarns/bats-assert.git test/tmp/bats-assert test/tmp/bin: mkdir -p test/tmp/bin @@ -90,7 +93,7 @@ test/tmp/bin: test/tmp/bin/sh: test/tmp/bin ln -sf $$(which $(SH)) test/tmp/bin/sh -check: test/tmp/bats test/tmp/bin/sh +check: test/tmp/bats test/tmp/bats-assert test/tmp/bin/sh PATH=test/tmp/bin/:$$PATH test/tmp/bats/bin/bats test/ .PHONY: all install uninstall deb man gh-pages check diff --git a/test/apt_add.bats b/test/apt_add.bats index f84abe7..035f67a 100644 --- a/test/apt_add.bats +++ b/test/apt_add.bats @@ -7,7 +7,9 @@ setup() { } @test "freight-add adds package to distro main component" { - test "$(freight_add ${FIXTURES}/test_1.0_all.deb apt/example 2>&1)" = "# [freight] added ${FIXTURES}/test_1.0_all.deb to apt/example" + run freight_add ${FIXTURES}/test_1.0_all.deb apt/example + assert_success + assert_output "# [freight] added ${FIXTURES}/test_1.0_all.deb to apt/example" test -e ${FREIGHT_LIB}/apt/example/test_1.0_all.deb } @@ -25,5 +27,7 @@ setup() { @test "freight-add detects duplicate package" { freight_add ${FIXTURES}/test_1.0_all.deb apt/example - test "$(freight_add ${FIXTURES}/test_1.0_all.deb apt/example 2>&1)" = "# [freight] apt/example already has ${FIXTURES}/test_1.0_all.deb" + run freight_add ${FIXTURES}/test_1.0_all.deb apt/example + assert_success + assert_output "# [freight] apt/example already has ${FIXTURES}/test_1.0_all.deb" } diff --git a/test/apt_cache.bats b/test/apt_cache.bats index 9253b21..400c61f 100644 --- a/test/apt_cache.bats +++ b/test/apt_cache.bats @@ -47,3 +47,25 @@ setup() { apt-get -c ${FIXTURES}/apt.conf update apt-cache -c ${FIXTURES}/apt.conf show test } + +@test "freight-cache removes deleted packages from pool" { + freight_cache -v + test -e ${FREIGHT_CACHE}/pool/example/main/t/test/test_1.0_all.deb + rm -f ${FREIGHT_LIB}/apt/example/test_1.0_all.deb + + run freight_cache -v + assert_success + assert_output "" + test ! -e ${FREIGHT_CACHE}/pool/example/main/t/test/test_1.0_all.deb +} + +@test "freight-cache --keep retains deleted packages in pool" { + freight_cache -v + test -e ${FREIGHT_CACHE}/pool/example/main/t/test/test_1.0_all.deb + rm -f ${FREIGHT_LIB}/apt/example/test_1.0_all.deb + + run freight_cache -v --keep + assert_success + assert_output "" + test -e ${FREIGHT_CACHE}/pool/example/main/t/test/test_1.0_all.deb +} diff --git a/test/fixtures/test_1.0_all.deb b/test/fixtures/test_1.0_all.deb index 42b9103fcb47ae2927fb0c35c354cd26bfe3b76a..455b2b1c3f451d9083c262486d1b4562fcc75a96 100644 GIT binary patch delta 737 zcmeB>`NKA$qTblhNC5&8xa7Mz7~*;#hA}X|y?EE_uz?8shq&jOpP2qeT^H->XcFh* zYHs{)Xq%Uq8FVRRxqtqfga-$#S2O>&*T|ebxtPz=Q|hc9_p4oVu01H3d+)PrXu50I zR9De|;gxYNd*W=d_tYqe9ZTq5gY(l}) zDW#|Oo6h-mkFzY>`jyjix$XD9`_8%)SF(4R%Pl=qGr754=C4|Lb}w|ax+;H3Qrbvv z|4+q7>(@&&pn(VOwG5XpNo}93z+_TyY+;Ti7%yK=Utnp#z*JluY{1L%!emBnMoL;< zLQXmXU@;!0E|94si6>|IFiS+i|Zw(dW#b*lRWIJS-8bpWDy+<^E#X@k#8boxRl9 zL`{~xdmELr&|q_jX8rp6e?Q$6HC=S+;r7z?mKmk`5A`Nh6_x$Zox96;HZT8&n{_3b zc{6OD=4@K?vbp=|Qg!F(aQo{5o&UDGKc1T78tr@dnYa|canj7wYxDG9-&k#Z_+ROn qi(jWQzx^L*z~y#OLxOd2f=Evj4vsKHs!f=IVZEyEbp{Ov1}*>tVMxdT delta 3458 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 QD1f9Hln_W_Kte+EA8|a Date: Thu, 10 Mar 2016 15:43:05 +0000 Subject: [PATCH 20/72] Fix exit code of freight-cache --keep --- bin/freight-cache | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/freight-cache b/bin/freight-cache index 133b23a..ce199c1 100755 --- a/bin/freight-cache +++ b/bin/freight-cache @@ -109,6 +109,8 @@ do eval "${MANAGER}_cache" "$DIST" # Clean up old packages as dictated by the manager. - [ -z "$KEEP" ] && eval "${MANAGER}_clean" + if [ -z "$KEEP" ]; then + eval "${MANAGER}_clean" + fi done From b638ad7f536e19bcf6a4a9c47d86fa7ce5d0a87c Mon Sep 17 00:00:00 2001 From: Michael Moll Date: Fri, 11 Mar 2016 13:57:32 +0100 Subject: [PATCH 21/72] add shellcheck to travis --- .travis.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5d9fcbf..ce2242f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,19 @@ -sudo: false +sudo: required +dist: trusty env: - SH=dash - SH=bash +before_script: + - sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu/ trusty-backports restricted main universe" + - sudo apt-get -y update + - sudo apt-get -y install shellcheck rng-tools +# see https://github.com/travis-ci/travis-ci/issues/1913#issuecomment-53972361 + - sudo rm -f /dev/random + - sudo mknod -m 0666 /dev/random c 1 9 + - echo HRNGDEVICE=/dev/urandom | sudo tee /etc/default/rng-tools + - sudo /etc/init.d/rng-tools restart script: + - find bin lib -type f | xargs shellcheck -s sh - make check notifications: irc: "chat.freenode.net#freight" From c112399233494386ff8ad3a74ee14d00a38477ff Mon Sep 17 00:00:00 2001 From: Michael Moll Date: Mon, 14 Mar 2016 12:05:31 +0100 Subject: [PATCH 22/72] fix shellcheck warnings (or silence them) --- bin/freight | 8 ++++---- bin/freight-add | 4 +++- bin/freight-cache | 3 ++- bin/freight-clear-cache | 3 ++- lib/freight/apt.sh | 18 ++++++++++++------ lib/freight/conf.sh | 7 ++++++- 6 files changed, 29 insertions(+), 14 deletions(-) diff --git a/bin/freight b/bin/freight index 3a86b4a..4543ecd 100755 --- a/bin/freight +++ b/bin/freight @@ -7,13 +7,13 @@ set -e # Just like the DevStructure tools, which try to be just like Git, accept # a subcommand that really just completes the name of a real command. COMMAND=$0-$1 -[ -x $COMMAND ] && { +[ -x "$COMMAND" ] && { shift - exec $COMMAND "$@" + exec "$COMMAND" "$@" } # Be helpful in this case since no subcommand was found. -echo "Usage: $(basename $0) [...]" >&2 +echo "Usage: $(basename "$0") [...]" >&2 echo "Common commands: add cache init" >&2 -echo "See all available commands by typing \"$(basename $0)-\"" >&2 +echo "See all available commands by typing \"$(basename "$0")-\"" >&2 exit 1 diff --git a/bin/freight-add b/bin/freight-add index 2b197ec..34b31e4 100755 --- a/bin/freight-add +++ b/bin/freight-add @@ -26,7 +26,7 @@ do esac done -. "$(dirname $(dirname $0))/lib/freight/conf.sh" +. "$(dirname "$(dirname "$0")")/lib/freight/conf.sh" # The non-option argument(s) following the last option are package files. # Binary packages have only one but source packages require two or three. @@ -36,6 +36,7 @@ while [ "$#" -gt 0 ] do case "$1" in *.deb|*.dsc|*.orig.tar.gz|*.orig.tar.bz2|*.orig.tar.xz|*.orig.tar.lzma|*.diff.gz|*.debian.tar.gz|*.debian.tar.bz2|*.debian.tar.xz|*.debian.tar.lzma|*.tar.gz|*.tar.bz2|*.tar.xz|*.tar.lzma) + # shellcheck disable=SC2153 PATHNAMES="$PATHNAMES $1" shift;; *.build|*.changes) shift;; *) break;; @@ -49,6 +50,7 @@ done # later Freight commands will rely on the link count being reduced to one. mkdir -p "$VARLIB" TMP="$(mktemp -d "$VARLIB/freight.$$.XXXXXXXXXX")" +# shellcheck disable=SC2064 trap "rm -rf \"$TMP\"" EXIT INT TERM for PATHNAME in $PATHNAMES do diff --git a/bin/freight-cache b/bin/freight-cache index ce199c1..5ab5f73 100755 --- a/bin/freight-cache +++ b/bin/freight-cache @@ -67,6 +67,7 @@ LIB="$(cd "$(dirname "$(dirname "$0")")/lib/freight" && pwd)" # Create a working directory on the same device as the Freight cache. mkdir -p "$VARCACHE" TMP="$(mktemp -d "$VARCACHE/work.$$.XXXXXXXXXX")" +# shellcheck disable=SC2064 trap "rm -rf \"$TMP\"" EXIT INT TERM # Enter the Freight library directory so that items in `$@` may be given as @@ -84,7 +85,7 @@ then tr "\n" " " )" else - DIRS="$@" + DIRS=$* fi for DIR in $DIRS do diff --git a/bin/freight-clear-cache b/bin/freight-clear-cache index a60523a..14ee0ee 100755 --- a/bin/freight-clear-cache +++ b/bin/freight-clear-cache @@ -32,6 +32,7 @@ done # Create a working directory on the same device as the Freight cache. mkdir -p "$VARCACHE" TMP="$(mktemp -d "$VARCACHE/work.$$.XXXXXXXXXX")" +# shellcheck disable=SC2064 trap "rm -rf \"$TMP\"" EXIT INT TERM # Enter the Freight library directory so that items in `$@` may be given as @@ -49,7 +50,7 @@ then tr "\n" " " )" else - DIRS="$@" + DIRS=$* fi for DIR in $DIRS do diff --git a/lib/freight/apt.sh b/lib/freight/apt.sh index 4832eec..19bcb62 100644 --- a/lib/freight/apt.sh +++ b/lib/freight/apt.sh @@ -1,4 +1,6 @@ -TTY="$(tty -s && echo "1" || :)" +if tty -s; then + TTY="1" +fi # Fetch the given field from the package's control file. apt_info() { @@ -123,6 +125,7 @@ apt_cache() { # the `Packages` file, too. for COMP in $COMPS do + # shellcheck disable=SC2153 for ARCH in $ARCHS do cat >"$DISTCACHE/$COMP/binary-$ARCH/Release" <> $DISTCACHE/Release.gpg - rm -f $TMP/release_last_signature.gpg + cat "$TMP"/release_last_signature.gpg >> "$DISTCACHE"/Release.gpg + rm -f "$TMP"/release_last_signature.gpg done # Generate `pubkey.gpg` containing the plaintext public key and @@ -212,6 +216,7 @@ EOF # the appropriate public keys. `keyring.gpg` is appropriate for # copying directly to `/etc/apt/trusted.gpg.d`. mkdir -m700 -p "$TMP/gpg" + # shellcheck disable=SC2086 gpg -q --export -a $GPG | tee "$VARCACHE/pubkey.gpg" | gpg -q --homedir "$TMP/gpg" --import @@ -229,9 +234,9 @@ EOF # Clear the cached control files from the dist apt_clear_cache() { # First remove the binary control cache - find "$VARLIB/apt/$DIST" -name *-control | xargs --no-run-if-empty rm + find "$VARLIB/apt/$DIST" -name '*-control' -print0 | xargs -0 --no-run-if-empty rm # Next remove the source control cache - find "$VARLIB/apt/$DIST" -name *-cached | xargs --no-run-if-empty rm + find "$VARLIB/apt/$DIST" -name '*-cached' -print0 | xargs -0 --no-run-if-empty rm } # Add a binary package to the given dist and to the pool. @@ -324,6 +329,7 @@ EOF # Add the `Filename` field containing the path to the # package, starting with `pool/`. + # shellcheck disable=SC2086 sed "s,^Filename: FILENAME$,Filename: $POOL/$FILENAME,g" "$CONTROL" | tee -a $FILES >/dev/null diff --git a/lib/freight/conf.sh b/lib/freight/conf.sh index 139da65..84c6192 100644 --- a/lib/freight/conf.sh +++ b/lib/freight/conf.sh @@ -6,18 +6,23 @@ VARLIB="/var/lib/freight" VARCACHE="/var/cache/freight" # Default architectures. +# shellcheck disable=SC2034 ARCHS="i386 amd64" # Default `Origin` and `Label` fields for `Release` files. +# shellcheck disable=SC2034 ORIGIN="Freight" +# shellcheck disable=SC2034 LABEL="Freight" +# shellcheck disable=SC2034 CACHE="off" +# shellcheck disable=SC2034 SYMLINKS="off" # Source all existing configuration files from lowest- to highest-priority. -PREFIX="$(dirname $(dirname $0))" +PREFIX="$(dirname "$(dirname "$0")")" if [ "$PREFIX" = "/usr" ] then [ -f "/etc/freight.conf" ] && . "/etc/freight.conf" else [ -f "$PREFIX/etc/freight.conf" ] && . "$PREFIX/etc/freight.conf" From db59b700637d937a55cd1fcc6d41e0ff5d859eca Mon Sep 17 00:00:00 2001 From: Dominic Cleal Date: Wed, 16 Mar 2016 14:40:02 +0000 Subject: [PATCH 23/72] Fix Valid-Until date to be a valid, parsable date --- lib/freight/apt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/freight/apt.sh b/lib/freight/apt.sh index 19bcb62..7444804 100644 --- a/lib/freight/apt.sh +++ b/lib/freight/apt.sh @@ -79,7 +79,7 @@ apt_filesize() { # including all packages read from `stdin`. apt_cache() { REL_DATE="$(LC_ALL=en_US date '+%a, %d %b %Y %H:%M:%S %Z')" - VALID_DATE="Fri, 31 Nov 2038 00:00:00 JST" + VALID_DATE="Tue, 30 Nov 2038 00:00:00 JST" DIST="$1" SUITE="${SUITE:-$DIST}" From c56e0b9db32ff39cc85a7676804386e464123fbb Mon Sep 17 00:00:00 2001 From: Dominic Cleal Date: Thu, 17 Mar 2016 08:53:06 +0000 Subject: [PATCH 24/72] Add vim modelines for 4-space expanded tabs --- bin/freight | 2 ++ bin/freight-add | 2 ++ bin/freight-cache | 2 ++ bin/freight-clear-cache | 2 ++ bin/freight-init | 2 ++ lib/freight/apt.sh | 2 ++ lib/freight/conf.sh | 2 ++ test/apt_add.bats | 2 +- test/apt_cache.bats | 2 +- test/apt_helpers.bash | 2 +- test/freight_helpers.bash | 2 +- 11 files changed, 18 insertions(+), 4 deletions(-) diff --git a/bin/freight b/bin/freight index 4543ecd..b3bec4c 100755 --- a/bin/freight +++ b/bin/freight @@ -17,3 +17,5 @@ echo "Usage: $(basename "$0") [...]" >&2 echo "Common commands: add cache init" >&2 echo "See all available commands by typing \"$(basename "$0")-\"" >&2 exit 1 + +# vim: et:ts=4:sw=4 diff --git a/bin/freight-add b/bin/freight-add index 34b31e4..8976a4c 100755 --- a/bin/freight-add +++ b/bin/freight-add @@ -102,3 +102,5 @@ do esac done done + +# vim: et:ts=4:sw=4 diff --git a/bin/freight-cache b/bin/freight-cache index 5ab5f73..ccda268 100755 --- a/bin/freight-cache +++ b/bin/freight-cache @@ -115,3 +115,5 @@ do fi done + +# vim: et:ts=4:sw=4 diff --git a/bin/freight-clear-cache b/bin/freight-clear-cache index 14ee0ee..c935bbd 100755 --- a/bin/freight-clear-cache +++ b/bin/freight-clear-cache @@ -66,3 +66,5 @@ do eval "${MANAGER}_clear_cache" "$DIST" done + +# vim: et:ts=4:sw=4 diff --git a/bin/freight-init b/bin/freight-init index 55265d9..f8d5d02 100755 --- a/bin/freight-init +++ b/bin/freight-init @@ -95,3 +95,5 @@ EOF # return 0 when we come here exit 0 + +# vim: et:ts=4:sw=4 diff --git a/lib/freight/apt.sh b/lib/freight/apt.sh index 7444804..d181927 100644 --- a/lib/freight/apt.sh +++ b/lib/freight/apt.sh @@ -469,3 +469,5 @@ apt_clean() { find "$VARCACHE/pool" -links 1 -type f -delete find "$VARCACHE/pool" -type d -empty -delete } + +# vim: et:ts=4:sw=4 diff --git a/lib/freight/conf.sh b/lib/freight/conf.sh index 84c6192..f9b8d11 100644 --- a/lib/freight/conf.sh +++ b/lib/freight/conf.sh @@ -50,3 +50,5 @@ fi # Normalize directory names. VARLIB=${VARLIB%%/} VARCACHE=${VARCACHE%%/} + +# vim: et:ts=4:sw=4 diff --git a/test/apt_add.bats b/test/apt_add.bats index 035f67a..d04393f 100644 --- a/test/apt_add.bats +++ b/test/apt_add.bats @@ -1,4 +1,4 @@ -# vim: noet:ts=4:sw=4:ft=sh +# vim: et:ts=4:sw=4:ft=sh load freight_helpers diff --git a/test/apt_cache.bats b/test/apt_cache.bats index 400c61f..710c97d 100644 --- a/test/apt_cache.bats +++ b/test/apt_cache.bats @@ -1,4 +1,4 @@ -# vim: noet:ts=4:sw=4:ft=sh +# vim: et:ts=4:sw=4:ft=sh load freight_helpers load apt_helpers diff --git a/test/apt_helpers.bash b/test/apt_helpers.bash index 04ba1ed..cd93dfe 100644 --- a/test/apt_helpers.bash +++ b/test/apt_helpers.bash @@ -1,4 +1,4 @@ -# vim: noet:ts=4:sw=4:ft=sh +# vim: et:ts=4:sw=4:ft=sh configure_local_apt() { mkdir -p ${TMPDIR}/apt/etc/apt diff --git a/test/freight_helpers.bash b/test/freight_helpers.bash index 3d571fc..bdbf2cc 100644 --- a/test/freight_helpers.bash +++ b/test/freight_helpers.bash @@ -1,4 +1,4 @@ -# vim: noet:ts=4:sw=4:ft=sh +# vim: et:ts=4:sw=4:ft=sh TOPDIR=$PWD FIXTURES=${TOPDIR}/test/fixtures From dde23f466a5bd0ce0c61d73d6f11b9c0e1e0f1e8 Mon Sep 17 00:00:00 2001 From: Dominic Cleal Date: Thu, 17 Mar 2016 08:54:52 +0000 Subject: [PATCH 25/72] Replace hard tab with four spaces --- bin/freight | 4 +- bin/freight-add | 44 +-- bin/freight-cache | 124 +++---- bin/freight-clear-cache | 50 +-- bin/freight-init | 84 ++--- lib/freight/apt.sh | 676 +++++++++++++++++++------------------- lib/freight/conf.sh | 8 +- test/apt_add.bats | 30 +- test/apt_cache.bats | 76 ++--- test/apt_helpers.bash | 10 +- test/freight_helpers.bash | 34 +- 11 files changed, 570 insertions(+), 570 deletions(-) diff --git a/bin/freight b/bin/freight index b3bec4c..1343662 100755 --- a/bin/freight +++ b/bin/freight @@ -8,8 +8,8 @@ set -e # a subcommand that really just completes the name of a real command. COMMAND=$0-$1 [ -x "$COMMAND" ] && { - shift - exec "$COMMAND" "$@" + shift + exec "$COMMAND" "$@" } # Be helpful in this case since no subcommand was found. diff --git a/bin/freight-add b/bin/freight-add index 8976a4c..b9fe6d4 100755 --- a/bin/freight-add +++ b/bin/freight-add @@ -15,15 +15,15 @@ usage() { } while [ "$#" -gt 0 ] do - case "$1" in - -c|--conf) CONF="$2" shift 2;; - -c*) CONF="$(echo "$1" | cut -c"3-")" shift;; - --conf=*) CONF="$(echo "$1" | cut -c"8-")" shift;; - -v|--verbose) VERBOSE=1 shift;; - -h|--help) usage 0;; - -*) echo "# [freight] unknown switch: $1" >&2;; - *) break;; - esac + case "$1" in + -c|--conf) CONF="$2" shift 2;; + -c*) CONF="$(echo "$1" | cut -c"3-")" shift;; + --conf=*) CONF="$(echo "$1" | cut -c"8-")" shift;; + -v|--verbose) VERBOSE=1 shift;; + -h|--help) usage 0;; + -*) echo "# [freight] unknown switch: $1" >&2;; + *) break;; + esac done . "$(dirname "$(dirname "$0")")/lib/freight/conf.sh" @@ -34,13 +34,13 @@ done # to be `/` pairs for this (source) package. while [ "$#" -gt 0 ] do - case "$1" in - *.deb|*.dsc|*.orig.tar.gz|*.orig.tar.bz2|*.orig.tar.xz|*.orig.tar.lzma|*.diff.gz|*.debian.tar.gz|*.debian.tar.bz2|*.debian.tar.xz|*.debian.tar.lzma|*.tar.gz|*.tar.bz2|*.tar.xz|*.tar.lzma) - # shellcheck disable=SC2153 - PATHNAMES="$PATHNAMES $1" shift;; - *.build|*.changes) shift;; - *) break;; - esac + case "$1" in + *.deb|*.dsc|*.orig.tar.gz|*.orig.tar.bz2|*.orig.tar.xz|*.orig.tar.lzma|*.diff.gz|*.debian.tar.gz|*.debian.tar.bz2|*.debian.tar.xz|*.debian.tar.lzma|*.tar.gz|*.tar.bz2|*.tar.xz|*.tar.lzma) + # shellcheck disable=SC2153 + PATHNAMES="$PATHNAMES $1" shift;; + *.build|*.changes) shift;; + *) break;; + esac done [ -z "$PATHNAMES" ] && usage 1 [ -z "$*" ] && usage 1 @@ -54,7 +54,7 @@ TMP="$(mktemp -d "$VARLIB/freight.$$.XXXXXXXXXX")" trap "rm -rf \"$TMP\"" EXIT INT TERM for PATHNAME in $PATHNAMES do - cp "$PATHNAME" "$TMP/" + cp "$PATHNAME" "$TMP/" done # Enter the Freight library directory so that items in `$@` may be given as @@ -81,10 +81,10 @@ add() { # files in the Freight cache. for PATHNAME in $PATHNAMES do - FILENAME="$(basename "$PATHNAME")" - for DIRNAME in "$@" - do - mkdir -p "$DIRNAME" + FILENAME="$(basename "$PATHNAME")" + for DIRNAME in "$@" + do + mkdir -p "$DIRNAME" case "$FILENAME" in *_*_*.deb) add "$FILENAME" "$DIRNAME" "$PATHNAME";; *.deb) @@ -100,7 +100,7 @@ do add "$FILENAME" "$DIRNAME" "$PATHNAME" "$DEBNAME";; *) add "$FILENAME" "$DIRNAME" "$PATHNAME";; esac - done + done done # vim: et:ts=4:sw=4 diff --git a/bin/freight-cache b/bin/freight-cache index ccda268..22c28ef 100755 --- a/bin/freight-cache +++ b/bin/freight-cache @@ -16,45 +16,45 @@ set -e usage() { - grep "^#/" "$0" | cut -c"4-" >&2 - exit "$1" + grep "^#/" "$0" | cut -c"4-" >&2 + exit "$1" } while [ "$#" -gt 0 ] do - case "$1" in - -k|--keep) KEEP=1 shift;; - -g|--gpg) - if [ -z "$GPG" ]; then - GPG=$2 - else - GPG="$GPG $2" - fi - shift 2;; - -g*) - if [ -z "$GPG" ]; then - GPG=$(echo "$1" | cut -c"3-") - else - GPG="$GPG $(echo "$1" | cut -c"3-")" - fi - shift;; - --gpg=*) - if [ -z "$GPG" ]; then - GPG=$(echo "$1" | cut -c"7-") - else - GPG="$GPG $(echo "$1" | cut -c"7-")" - fi - shift;; - -p|--passphrase-file) GPG_PASSPHRASE_FILE="$2" shift 2;; - -p*) GPG_PASSPHRASE_FILE="$(echo "$1" | cut -c"3-")" shift;; - --passphrase-file=*) GPG_PASSPHRASE_FILE="$(echo "$1" | cut -c"19-")" shift;; - -c|--conf) CONF="$2" shift 2;; - -c*) CONF="$(echo "$1" | cut -c"3-")" shift;; - --conf=*) CONF="$(echo "$1" | cut -c"8-")" shift;; - -v|--verbose) VERBOSE=1 shift;; - -h|--help) usage 0;; - -*) echo "# [freight] unknown switch: $1" >&2;; - *) break;; - esac + case "$1" in + -k|--keep) KEEP=1 shift;; + -g|--gpg) + if [ -z "$GPG" ]; then + GPG=$2 + else + GPG="$GPG $2" + fi + shift 2;; + -g*) + if [ -z "$GPG" ]; then + GPG=$(echo "$1" | cut -c"3-") + else + GPG="$GPG $(echo "$1" | cut -c"3-")" + fi + shift;; + --gpg=*) + if [ -z "$GPG" ]; then + GPG=$(echo "$1" | cut -c"7-") + else + GPG="$GPG $(echo "$1" | cut -c"7-")" + fi + shift;; + -p|--passphrase-file) GPG_PASSPHRASE_FILE="$2" shift 2;; + -p*) GPG_PASSPHRASE_FILE="$(echo "$1" | cut -c"3-")" shift;; + --passphrase-file=*) GPG_PASSPHRASE_FILE="$(echo "$1" | cut -c"19-")" shift;; + -c|--conf) CONF="$2" shift 2;; + -c*) CONF="$(echo "$1" | cut -c"3-")" shift;; + --conf=*) CONF="$(echo "$1" | cut -c"8-")" shift;; + -v|--verbose) VERBOSE=1 shift;; + -h|--help) usage 0;; + -*) echo "# [freight] unknown switch: $1" >&2;; + *) break;; + esac done LIB="$(cd "$(dirname "$(dirname "$0")")/lib/freight" && pwd)" @@ -79,40 +79,40 @@ cd "$VARLIB" # Rebuild each distro serially. if [ -z "$*" ] then - DIRS="$( - find "$VARLIB" -mindepth 2 -maxdepth 2 -type d -printf "%P\n" | - grep -v "^\\." | - tr "\n" " " - )" + DIRS="$( + find "$VARLIB" -mindepth 2 -maxdepth 2 -type d -printf "%P\n" | + grep -v "^\\." | + tr "\n" " " + )" else - DIRS=$* + DIRS=$* fi for DIR in $DIRS do - # Parse the manager and distro out of the Freight library path. - DIR="$(readlink -f "$DIR")" - DIR="${DIR##"$VARLIB/"}" - MANAGER="$(dirname "$DIR")" - DIST="$(basename "$DIR")" + # Parse the manager and distro out of the Freight library path. + DIR="$(readlink -f "$DIR")" + DIR="${DIR##"$VARLIB/"}" + MANAGER="$(dirname "$DIR")" + DIST="$(basename "$DIR")" - # Should we follow symbolic links when finding components to cache? - [ "$SYMLINKS" = "on" ] && FIND_L="-L" || FIND_L="" + # Should we follow symbolic links when finding components to cache? + [ "$SYMLINKS" = "on" ] && FIND_L="-L" || FIND_L="" - # From here the process is customized on a per-manager basis. The - # sorted list of package filenames comes on `stdin` and the name of - # the distro is the only argument. From there, each manager can do - # whatever it wants. - . "$LIB/$MANAGER.sh" - SORT="$(sort -V <"/dev/null" 2>"/dev/null" && echo "sort -V" || echo "sort")" - find $FIND_L "$DIR" -type "f" -printf "%P\n" 2>"/dev/null" | - eval "$SORT" | - eval "${MANAGER}_cache" "$DIST" + # From here the process is customized on a per-manager basis. The + # sorted list of package filenames comes on `stdin` and the name of + # the distro is the only argument. From there, each manager can do + # whatever it wants. + . "$LIB/$MANAGER.sh" + SORT="$(sort -V <"/dev/null" 2>"/dev/null" && echo "sort -V" || echo "sort")" + find $FIND_L "$DIR" -type "f" -printf "%P\n" 2>"/dev/null" | + eval "$SORT" | + eval "${MANAGER}_cache" "$DIST" - # Clean up old packages as dictated by the manager. - if [ -z "$KEEP" ]; then - eval "${MANAGER}_clean" - fi + # Clean up old packages as dictated by the manager. + if [ -z "$KEEP" ]; then + eval "${MANAGER}_clean" + fi done diff --git a/bin/freight-clear-cache b/bin/freight-clear-cache index c935bbd..192b150 100755 --- a/bin/freight-clear-cache +++ b/bin/freight-clear-cache @@ -11,20 +11,20 @@ set -e usage() { - grep "^#/" "$0" | cut -c"4-" >&2 - exit "$1" + grep "^#/" "$0" | cut -c"4-" >&2 + exit "$1" } while [ "$#" -gt 0 ] do - case "$1" in - -c|--conf) CONF="$2" shift 2;; - -c*) CONF="$(echo "$1" | cut -c"3-")" shift;; - --conf=*) CONF="$(echo "$1" | cut -c"8-")" shift;; - -v|--verbose) VERBOSE=1 shift;; - -h|--help) usage 0;; - -*) echo "# [freight] unknown switch: $1" >&2;; - *) break;; - esac + case "$1" in + -c|--conf) CONF="$2" shift 2;; + -c*) CONF="$(echo "$1" | cut -c"3-")" shift;; + --conf=*) CONF="$(echo "$1" | cut -c"8-")" shift;; + -v|--verbose) VERBOSE=1 shift;; + -h|--help) usage 0;; + -*) echo "# [freight] unknown switch: $1" >&2;; + *) break;; + esac done . "$(dirname "$(dirname "$0")")/lib/freight/conf.sh" @@ -44,26 +44,26 @@ cd "$VARLIB" # Rebuild each distro serially. if [ -z "$*" ] then - DIRS="$( - find "$VARLIB" -mindepth 2 -maxdepth 2 -type d -printf "%P\n" | - grep -v "^\\." | - tr "\n" " " - )" + DIRS="$( + find "$VARLIB" -mindepth 2 -maxdepth 2 -type d -printf "%P\n" | + grep -v "^\\." | + tr "\n" " " + )" else - DIRS=$* + DIRS=$* fi for DIR in $DIRS do - # Parse the manager and distro out of the Freight library path. - DIR="$(readlink -f "$DIR")" - DIR="${DIR##"$VARLIB/"}" - MANAGER="$(dirname "$DIR")" - DIST="$(basename "$DIR")" + # Parse the manager and distro out of the Freight library path. + DIR="$(readlink -f "$DIR")" + DIR="${DIR##"$VARLIB/"}" + MANAGER="$(dirname "$DIR")" + DIST="$(basename "$DIR")" - # From here the process is customized on a per-manager basis. - . "$(dirname "$(dirname "$0")")/lib/freight/$MANAGER.sh" - eval "${MANAGER}_clear_cache" "$DIST" + # From here the process is customized on a per-manager basis. + . "$(dirname "$(dirname "$0")")/lib/freight/$MANAGER.sh" + eval "${MANAGER}_clear_cache" "$DIST" done diff --git a/bin/freight-init b/bin/freight-init index f8d5d02..bf6297d 100755 --- a/bin/freight-init +++ b/bin/freight-init @@ -25,48 +25,48 @@ usage() { } while [ "$#" -gt 0 ] do - case "$1" in - -g|--gpg) - if [ -z "$GPG" ]; then - GPG=$2 - else - GPG="$GPG $2" - fi - shift 2;; - -g*) - if [ -z "$GPG" ]; then - GPG=$(echo "$1" | cut -c"3-") - else - GPG="$GPG $(echo "$1" | cut -c"3-")" - fi - shift;; - --gpg=*) - if [ -z "$GPG" ]; then - GPG=$(echo "$1" | cut -c"7-") - else - GPG="$GPG $(echo "$1" | cut -c"7-")" - fi - shift;; - -c|--conf) CONF="$2" shift 2;; - -c*) CONF="$(echo "$1" | cut -c"3-")" shift;; - --conf=*) CONF="$(echo "$1" | cut -c"8-")" shift;; - --libdir) VARLIB="$2" shift 2;; - --libdir=*) VARLIB="$(echo "$1" | cut -c"10-")" shift;; - --cachedir) VARCACHE="$2" shift 2;; - --cachedir=*) VARCACHE="$(echo "$1" | cut -c"12-")" shift;; - --archs) ARCHS="$2" shift 2;; - --archs=*) ARCHS="$(echo "$1" | cut -c"9-")" shift;; - --origin) ORIGIN="$2" shift 2;; - --origin=*) ORIGIN="$(echo "$1" | cut -c"10-")" shift;; - --label) LABEL="$2" shift 2;; - --label=*) LABEL="$(echo "$1" | cut -c"9-")" shift;; - --suite) SUITE="$2" shift 2;; - --suite=*) SUITE="$(echo "$1" | cut -c"9-")" shift;; - -v|--verbose) VERBOSE=1 shift;; - -h|--help) usage 0;; - -*) echo "# [freight] unknown switch: $1" >&2;; - *) break;; - esac + case "$1" in + -g|--gpg) + if [ -z "$GPG" ]; then + GPG=$2 + else + GPG="$GPG $2" + fi + shift 2;; + -g*) + if [ -z "$GPG" ]; then + GPG=$(echo "$1" | cut -c"3-") + else + GPG="$GPG $(echo "$1" | cut -c"3-")" + fi + shift;; + --gpg=*) + if [ -z "$GPG" ]; then + GPG=$(echo "$1" | cut -c"7-") + else + GPG="$GPG $(echo "$1" | cut -c"7-")" + fi + shift;; + -c|--conf) CONF="$2" shift 2;; + -c*) CONF="$(echo "$1" | cut -c"3-")" shift;; + --conf=*) CONF="$(echo "$1" | cut -c"8-")" shift;; + --libdir) VARLIB="$2" shift 2;; + --libdir=*) VARLIB="$(echo "$1" | cut -c"10-")" shift;; + --cachedir) VARCACHE="$2" shift 2;; + --cachedir=*) VARCACHE="$(echo "$1" | cut -c"12-")" shift;; + --archs) ARCHS="$2" shift 2;; + --archs=*) ARCHS="$(echo "$1" | cut -c"9-")" shift;; + --origin) ORIGIN="$2" shift 2;; + --origin=*) ORIGIN="$(echo "$1" | cut -c"10-")" shift;; + --label) LABEL="$2" shift 2;; + --label=*) LABEL="$(echo "$1" | cut -c"9-")" shift;; + --suite) SUITE="$2" shift 2;; + --suite=*) SUITE="$(echo "$1" | cut -c"9-")" shift;; + -v|--verbose) VERBOSE=1 shift;; + -h|--help) usage 0;; + -*) echo "# [freight] unknown switch: $1" >&2;; + *) break;; + esac done DIRNAME="$(cd "${1:-"."}" && pwd)" [ -z "$GPG" -o -z "$DIRNAME" ] && usage 1 diff --git a/lib/freight/apt.sh b/lib/freight/apt.sh index d181927..082532d 100644 --- a/lib/freight/apt.sh +++ b/lib/freight/apt.sh @@ -4,131 +4,131 @@ fi # Fetch the given field from the package's control file. apt_info() { - egrep -i "^$2:" "$1" | cut -d: -f2- | awk '{print $1}' + egrep -i "^$2:" "$1" | cut -d: -f2- | awk '{print $1}' } # Print the package name from the given control file. apt_binary_name() { - apt_info "$1" Package + apt_info "$1" Package } # Print the version from the given control file. apt_binary_version() { - apt_info "$1" Version + apt_info "$1" Version } # Print the architecture from the given control file. apt_binary_arch() { - apt_info "$1" Architecture + apt_info "$1" Architecture } apt_binary_filesize() { - apt_info "$1" Size + apt_info "$1" Size } # Print the source name from the given control file. apt_binary_sourcename() { - SOURCE="$(apt_info "$1" Source)" - [ -z "$SOURCE" ] && SOURCE="$(apt_binary_name "$1")" - echo "$SOURCE" + SOURCE="$(apt_info "$1" Source)" + [ -z "$SOURCE" ] && SOURCE="$(apt_binary_name "$1")" + echo "$SOURCE" } # Print the prefix the given control file should use in the pool. apt_binary_prefix() { - apt_prefix "$(apt_binary_sourcename "$1")" + apt_prefix "$(apt_binary_sourcename "$1")" } # Print the name portion of a source package's pathname. apt_source_name() { - basename "$1" ".dsc" | cut -d_ -f1 + basename "$1" ".dsc" | cut -d_ -f1 } # Print the version portion of a source package's pathname. apt_source_version() { - basename "$1" ".dsc" | cut -d_ -f2 + basename "$1" ".dsc" | cut -d_ -f2 } # Print the original version portion of a source package's pathname. apt_source_origversion() { - apt_source_version "$1" | cut -d- -f1 + apt_source_version "$1" | cut -d- -f1 } # Print the prefix for a package name. apt_prefix() { - [ "$(echo "$1" | cut -c1-3)" = "lib" ] && C=4 || C=1 - echo "$1" | cut -c-$C + [ "$(echo "$1" | cut -c1-3)" = "lib" ] && C=4 || C=1 + echo "$1" | cut -c-$C } # Print the checksum portion of the normal checksumming programs' output. apt_md5() { - md5sum "$1" | cut -d" " -f1 + md5sum "$1" | cut -d" " -f1 } apt_sha1() { - sha1sum "$1" | cut -d" " -f1 + sha1sum "$1" | cut -d" " -f1 } apt_sha256() { - sha256sum "$1" | cut -d" " -f1 + sha256sum "$1" | cut -d" " -f1 } # Print the size of the given file. apt_filesize() { - stat -c%s "$1" + stat -c%s "$1" } # Setup the repository for the distro named in the first argument, # including all packages read from `stdin`. apt_cache() { - REL_DATE="$(LC_ALL=en_US date '+%a, %d %b %Y %H:%M:%S %Z')" - VALID_DATE="Tue, 30 Nov 2038 00:00:00 JST" - DIST="$1" - SUITE="${SUITE:-$DIST}" - - # Generate a timestamp to use in this build's directory name. - DATE="$(date +%Y%m%d%H%M%S%N)" - DISTCACHE="$VARCACHE/dists/$DIST-$DATE" - - # For a Debian archive, each distribution needs at least this directory - # structure in place. The directory for this build must not exist, - # otherwise this build would clobber a previous one. The `.refs` - # directory contains links to all the packages currently included in - # this distribution to enable cleaning by link count later. - mkdir -p "$DISTCACHE/.refs" - mkdir -p "$VARCACHE/pool/$DIST" - - # Work through every package that should be part of this distro. - while read PATHNAME - do - - # Extract the component, if present, from the package's pathname. - case "$PATHNAME" in - */*) COMP="${PATHNAME%%/*}" PACKAGE="${PATHNAME##*/}";; - *) COMP="main" PACKAGE="$PATHNAME";; - esac - - case "$PATHNAME" in - - # Binary packages. - *.deb) apt_cache_binary "$DIST" "$DISTCACHE" "$PATHNAME" "$COMP" "$PACKAGE";; - - # Source packages. The *.dsc file is considered the "entrypoint" - # and will find the associated *.orig.tar.gz, *.diff.gz, and/or + REL_DATE="$(LC_ALL=en_US date '+%a, %d %b %Y %H:%M:%S %Z')" + VALID_DATE="Tue, 30 Nov 2038 00:00:00 JST" + DIST="$1" + SUITE="${SUITE:-$DIST}" + + # Generate a timestamp to use in this build's directory name. + DATE="$(date +%Y%m%d%H%M%S%N)" + DISTCACHE="$VARCACHE/dists/$DIST-$DATE" + + # For a Debian archive, each distribution needs at least this directory + # structure in place. The directory for this build must not exist, + # otherwise this build would clobber a previous one. The `.refs` + # directory contains links to all the packages currently included in + # this distribution to enable cleaning by link count later. + mkdir -p "$DISTCACHE/.refs" + mkdir -p "$VARCACHE/pool/$DIST" + + # Work through every package that should be part of this distro. + while read PATHNAME + do + + # Extract the component, if present, from the package's pathname. + case "$PATHNAME" in + */*) COMP="${PATHNAME%%/*}" PACKAGE="${PATHNAME##*/}";; + *) COMP="main" PACKAGE="$PATHNAME";; + esac + + case "$PATHNAME" in + + # Binary packages. + *.deb) apt_cache_binary "$DIST" "$DISTCACHE" "$PATHNAME" "$COMP" "$PACKAGE";; + + # Source packages. The *.dsc file is considered the "entrypoint" + # and will find the associated *.orig.tar.gz, *.diff.gz, and/or # *.tar.gz as they are needed. - *.dsc) apt_cache_source "$DIST" "$DISTCACHE" "$PATHNAME" "$COMP" "$PACKAGE";; - *.debian.tar.gz|*.debian.tar.bz2|*.debian.tar.xz|*.debian.tar.lzma|*.diff.gz|*.orig.tar.gz|*.orig.tar.bz2|*.orig.tar.xz|*.orig.tar.lzma|*.tar.gz|*.tar.bz2|*.tar.xz|*.tar.lzma|*.deb-control|*.dsc-cached) ;; - - *) echo "# [freight] skipping extraneous file $PATHNAME" >&2;; - esac - done - COMPS="$(ls "$DISTCACHE")" - - # Build a `Release` file for each component and architecture. `gzip` - # the `Packages` file, too. - for COMP in $COMPS - do - # shellcheck disable=SC2153 - for ARCH in $ARCHS - do - cat >"$DISTCACHE/$COMP/binary-$ARCH/Release" <&2;; + esac + done + COMPS="$(ls "$DISTCACHE")" + + # Build a `Release` file for each component and architecture. `gzip` + # the `Packages` file, too. + for COMP in $COMPS + do + # shellcheck disable=SC2153 + for ARCH in $ARCHS + do + cat >"$DISTCACHE/$COMP/binary-$ARCH/Release" <"$DISTCACHE/$COMP/binary-$ARCH/Packages.gz" - done - if [ -d "$DISTCACHE/$COMP/source" ] - then - cat >"$DISTCACHE/$COMP/source/Release" <"$DISTCACHE/$COMP/binary-$ARCH/Packages.gz" + done + if [ -d "$DISTCACHE/$COMP/source" ] + then + cat >"$DISTCACHE/$COMP/source/Release" <"$DISTCACHE/$COMP/source/Sources.gz" - fi - done - - # Begin the top-level `Release` file with the lists of components - # and architectures present in this repository and the checksums - # of all the `Release` and `Packages.gz` files within. - { - cat <"$DISTCACHE/$COMP/source/Sources.gz" + fi + done + + # Begin the top-level `Release` file with the lists of components + # and architectures present in this repository and the checksums + # of all the `Release` and `Packages.gz` files within. + { + cat <&3 - echo " $(apt_sha1 "$DISTCACHE/$FILE" ) $SIZE $FILE" >&4 - echo " $(apt_sha256 "$DISTCACHE/$FILE" ) $SIZE $FILE" >&5 - done 3>"$TMP/md5sums" 4>"$TMP/sha1sums" 5>"$TMP/sha256sums" - echo "MD5Sum:" - cat "$TMP/md5sums" - echo "SHA1:" - cat "$TMP/sha1sums" - echo "SHA256:" - cat "$TMP/sha256sums" - - } >"$DISTCACHE/Release" - - # Sign the top-level `Release` file with `gpg`, for each key and - # concatenate signatures. - for GPGKEY in $GPG; do - # shellcheck disable=SC2046 - gpg -abs"$([ "$TTY" ] || echo " --no-tty")" --use-agent -u"$GPGKEY" \ - $([ "$GPG_PASSPHRASE_FILE" ] && echo " --batch --passphrase-fd 1 --passphrase-file $GPG_PASSPHRASE_FILE") \ - -o"$TMP/release_last_signature.gpg" "$DISTCACHE/Release" || { - cat <&3 + echo " $(apt_sha1 "$DISTCACHE/$FILE" ) $SIZE $FILE" >&4 + echo " $(apt_sha256 "$DISTCACHE/$FILE" ) $SIZE $FILE" >&5 + done 3>"$TMP/md5sums" 4>"$TMP/sha1sums" 5>"$TMP/sha256sums" + echo "MD5Sum:" + cat "$TMP/md5sums" + echo "SHA1:" + cat "$TMP/sha1sums" + echo "SHA256:" + cat "$TMP/sha256sums" + + } >"$DISTCACHE/Release" + + # Sign the top-level `Release` file with `gpg`, for each key and + # concatenate signatures. + for GPGKEY in $GPG; do + # shellcheck disable=SC2046 + gpg -abs"$([ "$TTY" ] || echo " --no-tty")" --use-agent -u"$GPGKEY" \ + $([ "$GPG_PASSPHRASE_FILE" ] && echo " --batch --passphrase-fd 1 --passphrase-file $GPG_PASSPHRASE_FILE") \ + -o"$TMP/release_last_signature.gpg" "$DISTCACHE/Release" || { + cat <> "$DISTCACHE"/Release.gpg - rm -f "$TMP"/release_last_signature.gpg - done - - # Generate `pubkey.gpg` containing the plaintext public key and - # `keyring.gpg` containing a complete GPG keyring containing only - # the appropriate public keys. `keyring.gpg` is appropriate for - # copying directly to `/etc/apt/trusted.gpg.d`. - mkdir -m700 -p "$TMP/gpg" - # shellcheck disable=SC2086 - gpg -q --export -a $GPG | - tee "$VARCACHE/pubkey.gpg" | - gpg -q --homedir "$TMP/gpg" --import - chmod 644 "$TMP/gpg/pubring.gpg" - mv "$TMP/gpg/pubring.gpg" "$VARCACHE/keyring.gpg" - - # Move the symbolic link for this distro to this build. - ln -s "$DIST-$DATE" "$DISTCACHE-" - OLD="$(readlink "$VARCACHE/dists/$DIST" || true)" - mv -T "$DISTCACHE-" "$VARCACHE/dists/$DIST" - [ -z "$OLD" ] || rm -rf "$VARCACHE/dists/$OLD" + rm -rf "$DISTCACHE" + exit 1 + } + cat "$TMP"/release_last_signature.gpg >> "$DISTCACHE"/Release.gpg + rm -f "$TMP"/release_last_signature.gpg + done + + # Generate `pubkey.gpg` containing the plaintext public key and + # `keyring.gpg` containing a complete GPG keyring containing only + # the appropriate public keys. `keyring.gpg` is appropriate for + # copying directly to `/etc/apt/trusted.gpg.d`. + mkdir -m700 -p "$TMP/gpg" + # shellcheck disable=SC2086 + gpg -q --export -a $GPG | + tee "$VARCACHE/pubkey.gpg" | + gpg -q --homedir "$TMP/gpg" --import + chmod 644 "$TMP/gpg/pubring.gpg" + mv "$TMP/gpg/pubring.gpg" "$VARCACHE/keyring.gpg" + + # Move the symbolic link for this distro to this build. + ln -s "$DIST-$DATE" "$DISTCACHE-" + OLD="$(readlink "$VARCACHE/dists/$DIST" || true)" + mv -T "$DISTCACHE-" "$VARCACHE/dists/$DIST" + [ -z "$OLD" ] || rm -rf "$VARCACHE/dists/$OLD" } # Clear the cached control files from the dist apt_clear_cache() { - # First remove the binary control cache - find "$VARLIB/apt/$DIST" -name '*-control' -print0 | xargs -0 --no-run-if-empty rm - # Next remove the source control cache - find "$VARLIB/apt/$DIST" -name '*-cached' -print0 | xargs -0 --no-run-if-empty rm + # First remove the binary control cache + find "$VARLIB/apt/$DIST" -name '*-control' -print0 | xargs -0 --no-run-if-empty rm + # Next remove the source control cache + find "$VARLIB/apt/$DIST" -name '*-cached' -print0 | xargs -0 --no-run-if-empty rm } # Add a binary package to the given dist and to the pool. apt_cache_binary() { - DIST="$1" - DISTCACHE="$2" - PATHNAME="$3" - COMP="$4" - PACKAGE="$5" - - # Verify this package by way of extracting its control information - # to be used throughout this iteration of the loop. - # Don't extract the deb archive each time. Stick the control file - # in the $VARLIB alongside the other package artifacts for easy - # use later. - if [ "$CACHE" = "on" ]; then - CONTROL="$VARLIB/apt/$DIST/$PATHNAME-control" - else - CONTROL="$TMP/DEBIAN/binary-control" - fi - # If caching is off or if the binary has changed size, this will generate the - # binary control file - if ! ( [ -e "$CONTROL" ] && \ - [ "$(apt_binary_filesize "$CONTROL")" -eq "$(apt_filesize "$VARLIB/apt/$DIST/$PATHNAME")" ] ); then - dpkg-deb -e "$VARLIB/apt/$DIST/$PATHNAME" "$TMP/DEBIAN" || { - echo "# [freight] skipping invalid Debian package $PATHNAME" >&2 - return - } - { - # Grab and augment the control file from this package. Remove - # `Size`, `MD5Sum`, etc. lines and replace them with newly - # generated values. Update it once when generating the - # cached control file. Add a Filename line that can be updated - # easily later with the real path. Strip out empty control fields - # as these might cause problems. - grep . "$TMP/DEBIAN/control" | - grep -E -v "^[A-Za-z-]+:\s+$" | - grep -v "^(Essential|Filename|MD5Sum|SHA1|SHA256|Size)" - cat <&2 + return + } + { + # Grab and augment the control file from this package. Remove + # `Size`, `MD5Sum`, etc. lines and replace them with newly + # generated values. Update it once when generating the + # cached control file. Add a Filename line that can be updated + # easily later with the real path. Strip out empty control fields + # as these might cause problems. + grep . "$TMP/DEBIAN/control" | + grep -E -v "^[A-Za-z-]+:\s+$" | + grep -v "^(Essential|Filename|MD5Sum|SHA1|SHA256|Size)" + cat < "$CONTROL" - fi - - # Create all architecture-specific directories. This will allow - # packages marked `all` to actually be placed in all architectures. - for ARCH in $ARCHS - do - mkdir -p "$DISTCACHE/$COMP/binary-$ARCH" - touch "$DISTCACHE/$COMP/binary-$ARCH/Packages" - done - - # Link or copy this package into this distro's `.refs` directory. - mkdir -p "$DISTCACHE/.refs/$COMP" - ln "$VARLIB/apt/$DIST/$PATHNAME" "$DISTCACHE/.refs/$COMP" || - cp "$VARLIB/apt/$DIST/$PATHNAME" "$DISTCACHE/.refs/$COMP" - - # Package properties. Remove the epoch from the version number - # in the package filename, as is customary. - ARCH="$(apt_binary_arch "$CONTROL")" - NAME="$(apt_binary_name "$CONTROL")" - VERSION="$(apt_binary_version "$CONTROL")" - PREFIX="$(apt_binary_prefix "$CONTROL")" - SOURCE="$(apt_binary_sourcename "$CONTROL")" - FILENAME="${NAME}_${VERSION##*:}_${ARCH}.deb" - - # Link this package into the pool. - POOL="pool/$DIST/$COMP/$PREFIX/$SOURCE" - mkdir -p "$VARCACHE/$POOL" - if [ ! -f "$VARCACHE/$POOL/$FILENAME" ] - then - if [ "$PACKAGE" != "$FILENAME" ] - then echo "# [freight] adding $PACKAGE to pool (as $FILENAME)" >&2 - else echo "# [freight] adding $PACKAGE to pool" >&2 - fi - ln "$DISTCACHE/.refs/$COMP/$PACKAGE" "$VARCACHE/$POOL/$FILENAME" - fi - - # Build a list of the one-or-more `Packages` files to append with - # this package's info. - if [ "$ARCH" = "all" ] - then FILES="$(find "$DISTCACHE/$COMP" -type f -name "Packages")" - else FILES="$DISTCACHE/$COMP/binary-$ARCH/Packages" - fi - - # Add the `Filename` field containing the path to the - # package, starting with `pool/`. - # shellcheck disable=SC2086 - sed "s,^Filename: FILENAME$,Filename: $POOL/$FILENAME,g" "$CONTROL" | - tee -a $FILES >/dev/null - - # Cleanup the extracted package - if [ -d "$TMP/DEBIAN" ]; then - rm -rf "$TMP/DEBIAN" - fi + echo + } > "$CONTROL" + fi + + # Create all architecture-specific directories. This will allow + # packages marked `all` to actually be placed in all architectures. + for ARCH in $ARCHS + do + mkdir -p "$DISTCACHE/$COMP/binary-$ARCH" + touch "$DISTCACHE/$COMP/binary-$ARCH/Packages" + done + + # Link or copy this package into this distro's `.refs` directory. + mkdir -p "$DISTCACHE/.refs/$COMP" + ln "$VARLIB/apt/$DIST/$PATHNAME" "$DISTCACHE/.refs/$COMP" || + cp "$VARLIB/apt/$DIST/$PATHNAME" "$DISTCACHE/.refs/$COMP" + + # Package properties. Remove the epoch from the version number + # in the package filename, as is customary. + ARCH="$(apt_binary_arch "$CONTROL")" + NAME="$(apt_binary_name "$CONTROL")" + VERSION="$(apt_binary_version "$CONTROL")" + PREFIX="$(apt_binary_prefix "$CONTROL")" + SOURCE="$(apt_binary_sourcename "$CONTROL")" + FILENAME="${NAME}_${VERSION##*:}_${ARCH}.deb" + + # Link this package into the pool. + POOL="pool/$DIST/$COMP/$PREFIX/$SOURCE" + mkdir -p "$VARCACHE/$POOL" + if [ ! -f "$VARCACHE/$POOL/$FILENAME" ] + then + if [ "$PACKAGE" != "$FILENAME" ] + then echo "# [freight] adding $PACKAGE to pool (as $FILENAME)" >&2 + else echo "# [freight] adding $PACKAGE to pool" >&2 + fi + ln "$DISTCACHE/.refs/$COMP/$PACKAGE" "$VARCACHE/$POOL/$FILENAME" + fi + + # Build a list of the one-or-more `Packages` files to append with + # this package's info. + if [ "$ARCH" = "all" ] + then FILES="$(find "$DISTCACHE/$COMP" -type f -name "Packages")" + else FILES="$DISTCACHE/$COMP/binary-$ARCH/Packages" + fi + + # Add the `Filename` field containing the path to the + # package, starting with `pool/`. + # shellcheck disable=SC2086 + sed "s,^Filename: FILENAME$,Filename: $POOL/$FILENAME,g" "$CONTROL" | + tee -a $FILES >/dev/null + + # Cleanup the extracted package + if [ -d "$TMP/DEBIAN" ]; then + rm -rf "$TMP/DEBIAN" + fi } @@ -344,130 +344,130 @@ EOF # *.diff.gz, and/or *.tar.gz will be found based on PATHNAME and associated # with the correct source package. apt_cache_source() { - DIST="$1" - DISTCACHE="$2" - PATHNAME="$3" - COMP="$4" - PACKAGE="$5" - - NAME="$(apt_source_name "$PATHNAME")" - VERSION="$(apt_source_version "$PATHNAME")" - ORIG_VERSION="$(apt_source_origversion "$PATHNAME")" - DIRNAME="$(dirname "$PATHNAME")" - DSC_FILENAME="${NAME}_${VERSION%*:}.dsc" - DEBTAR_GZ_FILENAME="${NAME}_${VERSION%*:}.debian.tar.gz" - DEBTAR_BZ2_FILENAME="${NAME}_${VERSION%*:}.debian.tar.bz2" - DEBTAR_XZ_FILENAME="${NAME}_${VERSION%*:}.debian.tar.xz" - DEBTAR_LZMA_FILENAME="${NAME}_${VERSION%*:}.debian.tar.lzma" - DIFFGZ_FILENAME="${NAME}_${VERSION%*:}.diff.gz" - ORIG_FILENAME="${NAME}_${ORIG_VERSION}.orig.tar.gz" - TAR_FILENAME="${NAME}_${VERSION%*:}.tar.gz" + DIST="$1" + DISTCACHE="$2" + PATHNAME="$3" + COMP="$4" + PACKAGE="$5" + + NAME="$(apt_source_name "$PATHNAME")" + VERSION="$(apt_source_version "$PATHNAME")" + ORIG_VERSION="$(apt_source_origversion "$PATHNAME")" + DIRNAME="$(dirname "$PATHNAME")" + DSC_FILENAME="${NAME}_${VERSION%*:}.dsc" + DEBTAR_GZ_FILENAME="${NAME}_${VERSION%*:}.debian.tar.gz" + DEBTAR_BZ2_FILENAME="${NAME}_${VERSION%*:}.debian.tar.bz2" + DEBTAR_XZ_FILENAME="${NAME}_${VERSION%*:}.debian.tar.xz" + DEBTAR_LZMA_FILENAME="${NAME}_${VERSION%*:}.debian.tar.lzma" + DIFFGZ_FILENAME="${NAME}_${VERSION%*:}.diff.gz" + ORIG_FILENAME="${NAME}_${ORIG_VERSION}.orig.tar.gz" + TAR_FILENAME="${NAME}_${VERSION%*:}.tar.gz" # Find which style of diff they're using. - if [ -f "$VARLIB/apt/$DIST/$DIRNAME/$DEBTAR_GZ_FILENAME" ] - then DIFF_FILENAME=${DEBTAR_GZ_FILENAME} - elif [ -f "$VARLIB/apt/$DIST/$DIRNAME/$DEBTAR_BZ2_FILENAME" ] - then DIFF_FILENAME=${DEBTAR_BZ2_FILENAME} - elif [ -f "$VARLIB/apt/$DIST/$DIRNAME/$DEBTAR_XZ_FILENAME" ] - then DIFF_FILENAME=${DEBTAR_XZ_FILENAME} - elif [ -f "$VARLIB/apt/$DIST/$DIRNAME/$DEBTAR_LZMA_FILENAME" ] - then DIFF_FILENAME=${DEBTAR_LZMA_FILENAME} - else DIFF_FILENAME=${DIFFGZ_FILENAME} - fi - - # Verify this package by ensuring the other necessary files are present. - [ -f "$VARLIB/apt/$DIST/$DIRNAME/$ORIG_FILENAME" -a -f "$VARLIB/apt/$DIST/$DIRNAME/$DIFF_FILENAME" -o -f "$VARLIB/apt/$DIST/$DIRNAME/$TAR_FILENAME" ] || { - echo "# [freight] skipping invalid Debian source package $PATHNAME" >&2 - return - } - - # Create the architecture-parallel source directory and manifest. - mkdir -p "$DISTCACHE/$COMP/source" - touch "$DISTCACHE/$COMP/source/Sources" - - # Link or copy this source package into this distro's `.refs` directory - # if it isn't already there (which can happen when two packages derive - # from the same original tarball). - mkdir -p "$DISTCACHE/.refs/$COMP" - for FILENAME in "$DSC_FILENAME" "$ORIG_FILENAME" "$DIFF_FILENAME" "$TAR_FILENAME" - do + if [ -f "$VARLIB/apt/$DIST/$DIRNAME/$DEBTAR_GZ_FILENAME" ] + then DIFF_FILENAME=${DEBTAR_GZ_FILENAME} + elif [ -f "$VARLIB/apt/$DIST/$DIRNAME/$DEBTAR_BZ2_FILENAME" ] + then DIFF_FILENAME=${DEBTAR_BZ2_FILENAME} + elif [ -f "$VARLIB/apt/$DIST/$DIRNAME/$DEBTAR_XZ_FILENAME" ] + then DIFF_FILENAME=${DEBTAR_XZ_FILENAME} + elif [ -f "$VARLIB/apt/$DIST/$DIRNAME/$DEBTAR_LZMA_FILENAME" ] + then DIFF_FILENAME=${DEBTAR_LZMA_FILENAME} + else DIFF_FILENAME=${DIFFGZ_FILENAME} + fi + + # Verify this package by ensuring the other necessary files are present. + [ -f "$VARLIB/apt/$DIST/$DIRNAME/$ORIG_FILENAME" -a -f "$VARLIB/apt/$DIST/$DIRNAME/$DIFF_FILENAME" -o -f "$VARLIB/apt/$DIST/$DIRNAME/$TAR_FILENAME" ] || { + echo "# [freight] skipping invalid Debian source package $PATHNAME" >&2 + return + } + + # Create the architecture-parallel source directory and manifest. + mkdir -p "$DISTCACHE/$COMP/source" + touch "$DISTCACHE/$COMP/source/Sources" + + # Link or copy this source package into this distro's `.refs` directory + # if it isn't already there (which can happen when two packages derive + # from the same original tarball). + mkdir -p "$DISTCACHE/.refs/$COMP" + for FILENAME in "$DSC_FILENAME" "$ORIG_FILENAME" "$DIFF_FILENAME" "$TAR_FILENAME" + do [ -f "$VARLIB/apt/$DIST/$DIRNAME/$FILENAME" ] || continue [ -f "$DISTCACHE/.refs/$COMP/$FILENAME" ] || ln "$VARLIB/apt/$DIST/$DIRNAME/$FILENAME" "$DISTCACHE/.refs/$COMP" || cp "$VARLIB/apt/$DIST/$DIRNAME/$FILENAME" "$DISTCACHE/.refs/$COMP" - done - - # Package properties. Remove the epoch from the version number - # in the package filename, as is customary. - - # Link this source package into the pool. - POOL="pool/$DIST/$COMP/$(apt_prefix "$NAME")/$NAME" - mkdir -p "$VARCACHE/$POOL" - for FILENAME in "$DSC_FILENAME" "$ORIG_FILENAME" "$DIFF_FILENAME" "$TAR_FILENAME" - do - if [ -f "$DISTCACHE/.refs/$COMP/$FILENAME" -a ! -f "$VARCACHE/$POOL/$FILENAME" ] - then - echo "# [freight] adding $FILENAME to pool" >&2 - ln "$DISTCACHE/.refs/$COMP/$FILENAME" "$VARCACHE/$POOL" - fi - done - - # Grab and augment the control fields from this source package. Remove - # and recalculate file checksums. Change the `Source` field to `Package`. - # Add the `Directory` field. Only do this if a cached copy does not exist. - if [ "$CACHE" = "on" ]; then - CONTROL="$VARLIB/apt/$DIST/$PATHNAME-cached" - else - CONTROL="$TMP/source-control" - fi - if ! [ -e "$CONTROL" ]; then - { - egrep "^[A-Z][^:]+: ." "$VARLIB/apt/$DIST/$PATHNAME" | - egrep -v "^(Version: GnuPG|Hash: )" | - sed "s/^Source:/Package:/" - echo "Directory: DIRECTORY" - echo "Files:" - for FILENAME in "$DSC_FILENAME" "$ORIG_FILENAME" "$DIFF_FILENAME" "$TAR_FILENAME" - do + done + + # Package properties. Remove the epoch from the version number + # in the package filename, as is customary. + + # Link this source package into the pool. + POOL="pool/$DIST/$COMP/$(apt_prefix "$NAME")/$NAME" + mkdir -p "$VARCACHE/$POOL" + for FILENAME in "$DSC_FILENAME" "$ORIG_FILENAME" "$DIFF_FILENAME" "$TAR_FILENAME" + do + if [ -f "$DISTCACHE/.refs/$COMP/$FILENAME" -a ! -f "$VARCACHE/$POOL/$FILENAME" ] + then + echo "# [freight] adding $FILENAME to pool" >&2 + ln "$DISTCACHE/.refs/$COMP/$FILENAME" "$VARCACHE/$POOL" + fi + done + + # Grab and augment the control fields from this source package. Remove + # and recalculate file checksums. Change the `Source` field to `Package`. + # Add the `Directory` field. Only do this if a cached copy does not exist. + if [ "$CACHE" = "on" ]; then + CONTROL="$VARLIB/apt/$DIST/$PATHNAME-cached" + else + CONTROL="$TMP/source-control" + fi + if ! [ -e "$CONTROL" ]; then + { + egrep "^[A-Z][^:]+: ." "$VARLIB/apt/$DIST/$PATHNAME" | + egrep -v "^(Version: GnuPG|Hash: )" | + sed "s/^Source:/Package:/" + echo "Directory: DIRECTORY" + echo "Files:" + for FILENAME in "$DSC_FILENAME" "$ORIG_FILENAME" "$DIFF_FILENAME" "$TAR_FILENAME" + do [ -f "$VARCACHE/$POOL/$FILENAME" ] || continue - SIZE="$(apt_filesize "$VARCACHE/$POOL/$FILENAME")" - MD5="$(apt_md5 "$VARCACHE/$POOL/$FILENAME")" - echo " $MD5 $SIZE $FILENAME" - done - echo "Checksums-Sha1:" - for FILENAME in "$DSC_FILENAME" "$ORIG_FILENAME" "$DIFF_FILENAME" "$TAR_FILENAME" - do + SIZE="$(apt_filesize "$VARCACHE/$POOL/$FILENAME")" + MD5="$(apt_md5 "$VARCACHE/$POOL/$FILENAME")" + echo " $MD5 $SIZE $FILENAME" + done + echo "Checksums-Sha1:" + for FILENAME in "$DSC_FILENAME" "$ORIG_FILENAME" "$DIFF_FILENAME" "$TAR_FILENAME" + do [ -f "$VARCACHE/$POOL/$FILENAME" ] || continue - SIZE="$(apt_filesize "$VARCACHE/$POOL/$FILENAME")" - SHA1="$(apt_sha1 "$VARCACHE/$POOL/$FILENAME")" - echo " $SHA1 $SIZE $FILENAME" - done - echo "Checksums-Sha256:" - for FILENAME in "$DSC_FILENAME" "$ORIG_FILENAME" "$DIFF_FILENAME" "$TAR_FILENAME" - do + SIZE="$(apt_filesize "$VARCACHE/$POOL/$FILENAME")" + SHA1="$(apt_sha1 "$VARCACHE/$POOL/$FILENAME")" + echo " $SHA1 $SIZE $FILENAME" + done + echo "Checksums-Sha256:" + for FILENAME in "$DSC_FILENAME" "$ORIG_FILENAME" "$DIFF_FILENAME" "$TAR_FILENAME" + do [ -f "$VARCACHE/$POOL/$FILENAME" ] || continue - SIZE="$(apt_filesize "$VARCACHE/$POOL/$FILENAME")" - SHA256="$(apt_sha256 "$VARCACHE/$POOL/$FILENAME")" - echo " $SHA256 $SIZE $FILENAME" - done - echo - } > "$CONTROL" - fi + SIZE="$(apt_filesize "$VARCACHE/$POOL/$FILENAME")" + SHA256="$(apt_sha256 "$VARCACHE/$POOL/$FILENAME")" + echo " $SHA256 $SIZE $FILENAME" + done + echo + } > "$CONTROL" + fi - sed "s,^Directory: DIRECTORY$,Directory: $POOL,g" "$CONTROL" | - tee -a "$DISTCACHE/$COMP/source/Sources" >/dev/null + sed "s,^Directory: DIRECTORY$,Directory: $POOL,g" "$CONTROL" | + tee -a "$DISTCACHE/$COMP/source/Sources" >/dev/null # Clean up the tmp space - if [ -f "$TMP/source-control" ]; then - rm "$TMP/source-control" - fi + if [ -f "$TMP/source-control" ]; then + rm "$TMP/source-control" + fi } # Clean up old packages in the pool. apt_clean() { - find "$VARCACHE/pool" -links 1 -type f -delete - find "$VARCACHE/pool" -type d -empty -delete + find "$VARCACHE/pool" -links 1 -type f -delete + find "$VARCACHE/pool" -type d -empty -delete } # vim: et:ts=4:sw=4 diff --git a/lib/freight/conf.sh b/lib/freight/conf.sh index f9b8d11..322f9b8 100644 --- a/lib/freight/conf.sh +++ b/lib/freight/conf.sh @@ -31,10 +31,10 @@ fi DIRNAME="$PWD" while true do - [ -f "$DIRNAME/etc/freight.conf" ] && . "$DIRNAME/etc/freight.conf" && break - [ -f "$DIRNAME/.freight.conf" ] && . "$DIRNAME/.freight.conf" && break - [ "$DIRNAME" = "/" ] && break - DIRNAME="$(dirname "$DIRNAME")" + [ -f "$DIRNAME/etc/freight.conf" ] && . "$DIRNAME/etc/freight.conf" && break + [ -f "$DIRNAME/.freight.conf" ] && . "$DIRNAME/.freight.conf" && break + [ "$DIRNAME" = "/" ] && break + DIRNAME="$(dirname "$DIRNAME")" done [ "$FREIGHT_CONF" -a -f "$FREIGHT_CONF" ] && . "$FREIGHT_CONF" if [ "$CONF" ] diff --git a/test/apt_add.bats b/test/apt_add.bats index d04393f..b9ee8fb 100644 --- a/test/apt_add.bats +++ b/test/apt_add.bats @@ -3,31 +3,31 @@ load freight_helpers setup() { - freight_init + freight_init } @test "freight-add adds package to distro main component" { - run freight_add ${FIXTURES}/test_1.0_all.deb apt/example - assert_success - assert_output "# [freight] added ${FIXTURES}/test_1.0_all.deb to apt/example" - test -e ${FREIGHT_LIB}/apt/example/test_1.0_all.deb + run freight_add ${FIXTURES}/test_1.0_all.deb apt/example + assert_success + assert_output "# [freight] added ${FIXTURES}/test_1.0_all.deb to apt/example" + test -e ${FREIGHT_LIB}/apt/example/test_1.0_all.deb } @test "freight-add adds package to a component" { - freight_add ${FIXTURES}/test_1.0_all.deb apt/example/comp - test -e ${FREIGHT_LIB}/apt/example/comp/test_1.0_all.deb + freight_add ${FIXTURES}/test_1.0_all.deb apt/example/comp + test -e ${FREIGHT_LIB}/apt/example/comp/test_1.0_all.deb } @test "freight-add adds package and hard link to multiple components" { - freight_add ${FIXTURES}/test_1.0_all.deb apt/example/comp apt/example/another - test -e ${FREIGHT_LIB}/apt/example/comp/test_1.0_all.deb - test -e ${FREIGHT_LIB}/apt/example/another/test_1.0_all.deb - test $(stat -c '%i' ${FREIGHT_LIB}/apt/example/comp/*.deb) -eq $(stat -c '%i' ${FREIGHT_LIB}/apt/example/another/*.deb) + freight_add ${FIXTURES}/test_1.0_all.deb apt/example/comp apt/example/another + test -e ${FREIGHT_LIB}/apt/example/comp/test_1.0_all.deb + test -e ${FREIGHT_LIB}/apt/example/another/test_1.0_all.deb + test $(stat -c '%i' ${FREIGHT_LIB}/apt/example/comp/*.deb) -eq $(stat -c '%i' ${FREIGHT_LIB}/apt/example/another/*.deb) } @test "freight-add detects duplicate package" { - freight_add ${FIXTURES}/test_1.0_all.deb apt/example - run freight_add ${FIXTURES}/test_1.0_all.deb apt/example - assert_success - assert_output "# [freight] apt/example already has ${FIXTURES}/test_1.0_all.deb" + freight_add ${FIXTURES}/test_1.0_all.deb apt/example + run freight_add ${FIXTURES}/test_1.0_all.deb apt/example + assert_success + assert_output "# [freight] apt/example already has ${FIXTURES}/test_1.0_all.deb" } diff --git a/test/apt_cache.bats b/test/apt_cache.bats index 710c97d..a508766 100644 --- a/test/apt_cache.bats +++ b/test/apt_cache.bats @@ -4,68 +4,68 @@ load freight_helpers load apt_helpers setup() { - freight_init - freight_add ${FIXTURES}/test_1.0_all.deb apt/example - freight_add ${FIXTURES}/test_1.0_all.deb apt/example/comp - configure_local_apt + freight_init + freight_add ${FIXTURES}/test_1.0_all.deb apt/example + freight_add ${FIXTURES}/test_1.0_all.deb apt/example/comp + configure_local_apt } @test "freight-cache builds distro Release file" { - freight_cache -v - test -e ${FREIGHT_CACHE}/dists/example/Release - egrep "^Components: comp main" ${FREIGHT_CACHE}/dists/example/Release + freight_cache -v + test -e ${FREIGHT_CACHE}/dists/example/Release + egrep "^Components: comp main" ${FREIGHT_CACHE}/dists/example/Release } @test "freight-cache builds per-component Release file" { - freight_cache -v - test -e ${FREIGHT_CACHE}/dists/example/comp/binary-amd64/Release - test -e ${FREIGHT_CACHE}/dists/example/main/binary-amd64/Release + freight_cache -v + test -e ${FREIGHT_CACHE}/dists/example/comp/binary-amd64/Release + test -e ${FREIGHT_CACHE}/dists/example/main/binary-amd64/Release } @test "freight-cache builds pool" { - freight_cache -v - test -e ${FREIGHT_CACHE}/pool/example/comp/t/test/test_1.0_all.deb - test -e ${FREIGHT_CACHE}/pool/example/main/t/test/test_1.0_all.deb + freight_cache -v + test -e ${FREIGHT_CACHE}/pool/example/comp/t/test/test_1.0_all.deb + test -e ${FREIGHT_CACHE}/pool/example/main/t/test/test_1.0_all.deb } @test "freight-cache generates valid Release.gpg signature" { - freight_cache -v - gpg --verify ${FREIGHT_CACHE}/dists/example/Release.gpg ${FREIGHT_CACHE}/dists/example/Release + freight_cache -v + gpg --verify ${FREIGHT_CACHE}/dists/example/Release.gpg ${FREIGHT_CACHE}/dists/example/Release } @test "freight-cache signs Release.gpg with two keys" { - sed -i 's/^GPG=.*/GPG="freight@example.com freight2@example.com"/' $FREIGHT_CONFIG - freight_cache -v - test $(grep -c BEGIN ${FREIGHT_CACHE}/dists/example/Release.gpg) -eq 2 - gpg --verify ${FREIGHT_CACHE}/dists/example/Release.gpg ${FREIGHT_CACHE}/dists/example/Release + sed -i 's/^GPG=.*/GPG="freight@example.com freight2@example.com"/' $FREIGHT_CONFIG + freight_cache -v + test $(grep -c BEGIN ${FREIGHT_CACHE}/dists/example/Release.gpg) -eq 2 + gpg --verify ${FREIGHT_CACHE}/dists/example/Release.gpg ${FREIGHT_CACHE}/dists/example/Release } @test "apt-get fetches package list" { - check_apt_support - freight_cache -v - echo "deb file://${FREIGHT_CACHE} example main" > ${TMPDIR}/apt/etc/apt/sources.list - apt-get -c ${FIXTURES}/apt.conf update - apt-cache -c ${FIXTURES}/apt.conf show test + check_apt_support + freight_cache -v + echo "deb file://${FREIGHT_CACHE} example main" > ${TMPDIR}/apt/etc/apt/sources.list + apt-get -c ${FIXTURES}/apt.conf update + apt-cache -c ${FIXTURES}/apt.conf show test } @test "freight-cache removes deleted packages from pool" { - freight_cache -v - test -e ${FREIGHT_CACHE}/pool/example/main/t/test/test_1.0_all.deb - rm -f ${FREIGHT_LIB}/apt/example/test_1.0_all.deb + freight_cache -v + test -e ${FREIGHT_CACHE}/pool/example/main/t/test/test_1.0_all.deb + rm -f ${FREIGHT_LIB}/apt/example/test_1.0_all.deb - run freight_cache -v - assert_success - assert_output "" - test ! -e ${FREIGHT_CACHE}/pool/example/main/t/test/test_1.0_all.deb + run freight_cache -v + assert_success + assert_output "" + test ! -e ${FREIGHT_CACHE}/pool/example/main/t/test/test_1.0_all.deb } @test "freight-cache --keep retains deleted packages in pool" { - freight_cache -v - test -e ${FREIGHT_CACHE}/pool/example/main/t/test/test_1.0_all.deb - rm -f ${FREIGHT_LIB}/apt/example/test_1.0_all.deb + freight_cache -v + test -e ${FREIGHT_CACHE}/pool/example/main/t/test/test_1.0_all.deb + rm -f ${FREIGHT_LIB}/apt/example/test_1.0_all.deb - run freight_cache -v --keep - assert_success - assert_output "" - test -e ${FREIGHT_CACHE}/pool/example/main/t/test/test_1.0_all.deb + run freight_cache -v --keep + assert_success + assert_output "" + test -e ${FREIGHT_CACHE}/pool/example/main/t/test/test_1.0_all.deb } diff --git a/test/apt_helpers.bash b/test/apt_helpers.bash index cd93dfe..dc007a7 100644 --- a/test/apt_helpers.bash +++ b/test/apt_helpers.bash @@ -1,12 +1,12 @@ # vim: et:ts=4:sw=4:ft=sh configure_local_apt() { - mkdir -p ${TMPDIR}/apt/etc/apt - mkdir -p ${TMPDIR}/apt/var/lib/apt - mkdir -p ${TMPDIR}/apt/var/cache/apt + mkdir -p ${TMPDIR}/apt/etc/apt + mkdir -p ${TMPDIR}/apt/var/lib/apt + mkdir -p ${TMPDIR}/apt/var/cache/apt } check_apt_support() { - type apt-get || skip "missing apt-get" - apt-get --version | grep Ver:.*deb || skip "missing apt-get deb support" + type apt-get || skip "missing apt-get" + apt-get --version | grep Ver:.*deb || skip "missing apt-get deb support" } diff --git a/test/freight_helpers.bash b/test/freight_helpers.bash index bdbf2cc..cdd5cf2 100644 --- a/test/freight_helpers.bash +++ b/test/freight_helpers.bash @@ -14,31 +14,31 @@ FREIGHT_LIB=${FREIGHT_HOME}/var/lib export GNUPGHOME=${TMPDIR}/gpg freight_init() { - gpg_init - rm -rf $FREIGHT_HOME - mkdir -p $FREIGHT_CACHE $FREIGHT_LIB - bin/freight init \ - -g freight@example.com \ - -c $FREIGHT_CONFIG \ - --libdir $FREIGHT_LIB \ - --cachedir $FREIGHT_CACHE \ - "$@" + gpg_init + rm -rf $FREIGHT_HOME + mkdir -p $FREIGHT_CACHE $FREIGHT_LIB + bin/freight init \ + -g freight@example.com \ + -c $FREIGHT_CONFIG \ + --libdir $FREIGHT_LIB \ + --cachedir $FREIGHT_CACHE \ + "$@" } freight_add() { - bin/freight add -c $FREIGHT_CONFIG "$@" + bin/freight add -c $FREIGHT_CONFIG "$@" } freight_cache() { - bin/freight cache -c $FREIGHT_CONFIG "$@" + bin/freight cache -c $FREIGHT_CONFIG "$@" } # Generates a GPG key for all tests, once only due to entropy required gpg_init() { - if [ ! -e $GNUPGHOME ]; then - mkdir -p $GNUPGHOME - chmod 0700 $GNUPGHOME - gpg --batch --gen-key test/fixtures/gpg.conf - gpg --batch --gen-key test/fixtures/gpg2.conf - fi + if [ ! -e $GNUPGHOME ]; then + mkdir -p $GNUPGHOME + chmod 0700 $GNUPGHOME + gpg --batch --gen-key test/fixtures/gpg.conf + gpg --batch --gen-key test/fixtures/gpg2.conf + fi } From 5066c59dac140b1a275e807fcee701da89c364f0 Mon Sep 17 00:00:00 2001 From: Brad Cowie Date: Wed, 23 Mar 2016 16:50:45 +1300 Subject: [PATCH 26/72] Add ability to configure digest algorithm used to sign repository. * Make default GPG message digest algorithm SHA512. * Add config parameter for setting the --personal-digest-preferences GPG option which lets us select SHA256 or SHA512 instead of SHA1. * Add support for SHA512 field in Release and Package files. --- bin/freight-cache | 10 +++++++++- etc/freight.conf.example | 7 +++++++ lib/freight/apt.sh | 20 ++++++++++++++++++-- man/man1/freight-cache.1 | 4 ++++ man/man1/freight-cache.1.ronn | 2 ++ man/man5/freight.5 | 4 ++++ man/man5/freight.5.ronn | 2 ++ 7 files changed, 46 insertions(+), 3 deletions(-) diff --git a/bin/freight-cache b/bin/freight-cache index 22c28ef..1a7d4da 100755 --- a/bin/freight-cache +++ b/bin/freight-cache @@ -4,11 +4,13 @@ # actual repositories that are suitable targets for `apt-get` (and maybe # more in the future). -#/ Usage: freight cache [-k] [-g ] [-p ] [-c ] [-v] [-h] [/][...] +#/ Usage: freight cache [-k] [-g ] [-p ] [-a ] [-c ] [-v] [-h] [/][...] #/ -k, --keep keep unreferenced versions of packages #/ -g , --gpg= GPG key to use, may be given multiple times #/ -p , #/ --passphrase-file= path to file containing the passphrase of the GPG key +#/ -a , +#/ --digest-algo= digest algorithm that GPG should use, e.g SHA512 #/ -c , --conf= config file to parse #/ -v, --verbose verbose mode #/ -h, --help show this help message @@ -47,6 +49,9 @@ do -p|--passphrase-file) GPG_PASSPHRASE_FILE="$2" shift 2;; -p*) GPG_PASSPHRASE_FILE="$(echo "$1" | cut -c"3-")" shift;; --passphrase-file=*) GPG_PASSPHRASE_FILE="$(echo "$1" | cut -c"19-")" shift;; + -a|--digest-algo) GPG_DIGEST_ALGO="$2" shift 2;; + -a*) GPG_DIGEST_ALGO="$(echo "$1" | cut -c"3-")" shift;; + --digest-algo=*) GPG_DIGEST_ALGO="$(echo "$1" | cut -c"15-")" shift;; -c|--conf) CONF="$2" shift 2;; -c*) CONF="$(echo "$1" | cut -c"3-")" shift;; --conf=*) CONF="$(echo "$1" | cut -c"8-")" shift;; @@ -64,6 +69,9 @@ LIB="$(cd "$(dirname "$(dirname "$0")")/lib/freight" && pwd)" # readable by the user running Freight. [ -z "$GPG_PASSPHRASE_FILE" -o -r "$GPG_PASSPHRASE_FILE" ] || echo "# [freight] could not read passphrase file: $GPG_PASSPHRASE_FILE." >&2 +# If `GPG_DIGEST_ALGO` is unset, force it to the freight default of SHA512 +[ -z "$GPG_DIGEST_ALGO" ] && GPG_DIGEST_ALGO="SHA512" + # Create a working directory on the same device as the Freight cache. mkdir -p "$VARCACHE" TMP="$(mktemp -d "$VARCACHE/work.$$.XXXXXXXXXX")" diff --git a/etc/freight.conf.example b/etc/freight.conf.example index 771336c..0e1bc50 100644 --- a/etc/freight.conf.example +++ b/etc/freight.conf.example @@ -21,6 +21,13 @@ CACHE="off" GPG="example@example.com" # GPG="example@example.com another@example.com" +# Message digest algorithm that GPG should use to sign the repository. +# It is not recommended to use SHA1 as new versions of `apt` will report +# that the repository is half-broken due to weak digest. +# +# SHA512 is the default +GPG_DIGEST_ALGO="SHA512" + # Whether to follow symbolic links in `$VARLIB` to produce extra components # in the cache directory (on) or not (off). SYMLINKS="off" diff --git a/lib/freight/apt.sh b/lib/freight/apt.sh index 082532d..cc0e8a4 100644 --- a/lib/freight/apt.sh +++ b/lib/freight/apt.sh @@ -69,6 +69,9 @@ apt_sha1() { apt_sha256() { sha256sum "$1" | cut -d" " -f1 } +apt_sha512() { + sha512sum "$1" | cut -d" " -f1 +} # Print the size of the given file. apt_filesize() { @@ -182,13 +185,16 @@ EOF echo " $(apt_md5 "$DISTCACHE/$FILE" ) $SIZE $FILE" >&3 echo " $(apt_sha1 "$DISTCACHE/$FILE" ) $SIZE $FILE" >&4 echo " $(apt_sha256 "$DISTCACHE/$FILE" ) $SIZE $FILE" >&5 - done 3>"$TMP/md5sums" 4>"$TMP/sha1sums" 5>"$TMP/sha256sums" + echo " $(apt_sha512 "$DISTCACHE/$FILE" ) $SIZE $FILE" >&6 + done 3>"$TMP/md5sums" 4>"$TMP/sha1sums" 5>"$TMP/sha256sums" 6>"$TMP/sha512sums" echo "MD5Sum:" cat "$TMP/md5sums" echo "SHA1:" cat "$TMP/sha1sums" echo "SHA256:" cat "$TMP/sha256sums" + echo "SHA512:" + cat "$TMP/sha512sums" } >"$DISTCACHE/Release" @@ -198,6 +204,7 @@ EOF # shellcheck disable=SC2046 gpg -abs"$([ "$TTY" ] || echo " --no-tty")" --use-agent -u"$GPGKEY" \ $([ "$GPG_PASSPHRASE_FILE" ] && echo " --batch --passphrase-fd 1 --passphrase-file $GPG_PASSPHRASE_FILE") \ + $([ "$GPG_DIGEST_ALGO" ] && echo " --personal-digest-preferences $GPG_DIGEST_ALGO") \ -o"$TMP/release_last_signature.gpg" "$DISTCACHE/Release" || { cat < "$CONTROL" fi diff --git a/man/man1/freight-cache.1 b/man/man1/freight-cache.1 index 6247662..2dca184 100644 --- a/man/man1/freight-cache.1 +++ b/man/man1/freight-cache.1 @@ -36,6 +36,10 @@ Use an alternate GPG key\. May be given multiple times\. Use an alternate file containing the GPG key passphrase\. This file should obviously be protected and only readable by the user running Freight\. . .TP +\fB\-a\fR \fIdigest algorithm\fR, \fB\-\-digest\-algo=\fR\fIdigest algorithm\fR +Message digest algorithm that GPG should use to sign the repository, e\.g SHA512 +. +.TP \fB\-c\fR \fIconf\fR, \fB\-\-conf=\fR\fIconf\fR Use an alternate configuration file\. . diff --git a/man/man1/freight-cache.1.ronn b/man/man1/freight-cache.1.ronn index ec994d8..26e4afe 100644 --- a/man/man1/freight-cache.1.ronn +++ b/man/man1/freight-cache.1.ronn @@ -23,6 +23,8 @@ From version 0.0.8 onwards, distros in an APT repository no longer share the con Use an alternate GPG key. May be given multiple times. * `-p` _passphrase file_, `--passphrase-file=`_passphrase file_: Use an alternate file containing the GPG key passphrase. This file should obviously be protected and only readable by the user running Freight. +* `-a` _digest algorithm_, `--digest-algo=`_digest algorithm_: + Message digest algorithm that GPG should use to sign the repository, e.g SHA512 * `-c` _conf_, `--conf=`_conf_: Use an alternate configuration file. * `-v`, `--verbose`: diff --git a/man/man5/freight.5 b/man/man5/freight.5 index b4e7eaa..44c87bb 100644 --- a/man/man5/freight.5 +++ b/man/man5/freight.5 @@ -44,6 +44,10 @@ The GPG key(s) to use\. This value must be set either in a configuration file or Pathname of a file containing the GPGP private key\'s passphrase\. This sets the \fB\-\-passphrase\-fd\fR and \fB\-\-passphrase\-file\fR options to \fBgpg\fR(1)\. The passphrase file can be set either in a configuration file or by using the \fB\-p\fR option to \fBfreight\-cache\fR(1)\. . .TP +\fBGPG_DIGEST_ALGO\fR +Message digest algorithm that GPG should use to sign the repository\. Apt is phasing out SHA1 so it is recommended to use SHA512 for most use\-cases\. This sets the \fB\-\-personal\-digest\-preferences\fR option to \fBgpg\fR(1)\. The digest algorithm can be set either in a configuration file or by using the \fB\-a\fR option to \fBfreight\-cache\fR(1)\. +. +.TP \fBSYMLINKS\fR \fIon\fR to follow symbolic links in \fBVARLIB\fR to produce extra components in the cache directory or \fIoff\fR to offer no special treatment\. . diff --git a/man/man5/freight.5.ronn b/man/man5/freight.5.ronn index 4a84c05..d46cdd5 100644 --- a/man/man5/freight.5.ronn +++ b/man/man5/freight.5.ronn @@ -23,6 +23,8 @@ The Freight configuration is a `source`d shell script that defines a few importa The GPG key(s) to use. This value must be set either in a configuration file or by using the `-g` option to `freight-cache`(1). Multiple keys can be given to sign the repository with more signatures. * `GPG_PASSPHRASE_FILE`: Pathname of a file containing the GPGP private key's passphrase. This sets the `--passphrase-fd` and `--passphrase-file` options to `gpg`(1). The passphrase file can be set either in a configuration file or by using the `-p` option to `freight-cache`(1). +* `GPG_DIGEST_ALGO`: + Message digest algorithm that GPG should use to sign the repository. Apt is phasing out SHA1 so it is recommended to use SHA512 for most use-cases. This sets the `--personal-digest-preferences` option to `gpg`(1). The digest algorithm can be set either in a configuration file or by using the `-a` option to `freight-cache`(1). * `SYMLINKS`: _on_ to follow symbolic links in `VARLIB` to produce extra components in the cache directory or _off_ to offer no special treatment. From 8bb4939a76abd03e64d3f1b662113d9e1afedc43 Mon Sep 17 00:00:00 2001 From: Dominic Cleal Date: Thu, 24 Mar 2016 09:29:08 +0000 Subject: [PATCH 27/72] Skip generation of binary Release files if not required Fixes #23 --- .gitignore | 2 +- lib/freight/apt.sh | 9 ++++-- test/apt_add.bats | 21 ++++++++++++++ test/apt_cache_source.bats | 40 +++++++++++++++++++++++++++ test/fixtures/source_1.0-1.dsc | 17 ++++++++++++ test/fixtures/source_1.0-1.tar.gz | Bin 0 -> 9977 bytes test/fixtures/source_1.0.orig.tar.gz | Bin 0 -> 105 bytes 7 files changed, 85 insertions(+), 4 deletions(-) create mode 100644 test/apt_cache_source.bats create mode 100644 test/fixtures/source_1.0-1.dsc create mode 100644 test/fixtures/source_1.0-1.tar.gz create mode 100644 test/fixtures/source_1.0.orig.tar.gz diff --git a/.gitignore b/.gitignore index 6f8cf2c..d0f031d 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,4 @@ etc/freight.conf var test/tmp -!test/fixtures/*.deb +!test/fixtures/* diff --git a/lib/freight/apt.sh b/lib/freight/apt.sh index cc0e8a4..e9f80f2 100644 --- a/lib/freight/apt.sh +++ b/lib/freight/apt.sh @@ -131,7 +131,9 @@ apt_cache() { # shellcheck disable=SC2153 for ARCH in $ARCHS do - cat >"$DISTCACHE/$COMP/binary-$ARCH/Release" <"$DISTCACHE/$COMP/binary-$ARCH/Release" <"$DISTCACHE/$COMP/binary-$ARCH/Packages.gz" + gzip -c "$DISTCACHE/$COMP/binary-$ARCH/Packages" \ + >"$DISTCACHE/$COMP/binary-$ARCH/Packages.gz" + fi done if [ -d "$DISTCACHE/$COMP/source" ] then diff --git a/test/apt_add.bats b/test/apt_add.bats index b9ee8fb..7ca10ff 100644 --- a/test/apt_add.bats +++ b/test/apt_add.bats @@ -31,3 +31,24 @@ setup() { assert_success assert_output "# [freight] apt/example already has ${FIXTURES}/test_1.0_all.deb" } + +@test "freight-add adds source .dsc files" { + run freight_add ${FIXTURES}/source_1.0-1.dsc apt/example + assert_success + assert_output "# [freight] added ${FIXTURES}/source_1.0-1.dsc to apt/example" + test -e ${FREIGHT_LIB}/apt/example/source_1.0-1.dsc +} + +@test "freight-add adds source .tar.gz files" { + run freight_add ${FIXTURES}/source_1.0-1.tar.gz apt/example + assert_success + assert_output "# [freight] added ${FIXTURES}/source_1.0-1.tar.gz to apt/example" + test -e ${FREIGHT_LIB}/apt/example/source_1.0-1.tar.gz +} + +@test "freight-add adds source .orig.tar.gz files" { + run freight_add ${FIXTURES}/source_1.0.orig.tar.gz apt/example + assert_success + assert_output "# [freight] added ${FIXTURES}/source_1.0.orig.tar.gz to apt/example" + test -e ${FREIGHT_LIB}/apt/example/source_1.0.orig.tar.gz +} diff --git a/test/apt_cache_source.bats b/test/apt_cache_source.bats new file mode 100644 index 0000000..34fca4e --- /dev/null +++ b/test/apt_cache_source.bats @@ -0,0 +1,40 @@ +# vim: et:ts=4:sw=4:ft=sh + +load freight_helpers +load apt_helpers + +setup() { + freight_init + configure_local_apt +} + +@test "freight-cache skips partial source packages" { + freight_add ${FIXTURES}/source_1.0-1.dsc apt/example + run freight_cache + assert_success + assert_output "# [freight] skipping invalid Debian source package source_1.0-1.dsc" +} + +@test "freight-cache builds source-only archive" { + freight_add ${FIXTURES}/source_1.0-1.dsc apt/example + freight_add ${FIXTURES}/source_1.0-1.tar.gz apt/example + freight_add ${FIXTURES}/source_1.0.orig.tar.gz apt/example + run freight_cache + assert_success + echo -e "# [freight] adding source_1.0-1.dsc to pool\n# [freight] adding source_1.0.orig.tar.gz to pool\n# [freight] adding source_1.0-1.tar.gz to pool" | assert_output + test -e ${FREIGHT_CACHE}/pool/example/main/s/source/source_1.0-1.dsc + test -e ${FREIGHT_CACHE}/pool/example/main/s/source/source_1.0-1.tar.gz + test -e ${FREIGHT_CACHE}/pool/example/main/s/source/source_1.0.orig.tar.gz +} + +@test "apt-get fetches source package list" { + check_apt_support + freight_add ${FIXTURES}/source_1.0-1.dsc apt/example + freight_add ${FIXTURES}/source_1.0-1.tar.gz apt/example + freight_add ${FIXTURES}/source_1.0.orig.tar.gz apt/example + freight_cache + + echo "deb-src file://${FREIGHT_CACHE} example main" > ${TMPDIR}/apt/etc/apt/sources.list + apt-get -c ${FIXTURES}/apt.conf update + apt-cache -c ${FIXTURES}/apt.conf showsrc source | grep "Package: source" +} diff --git a/test/fixtures/source_1.0-1.dsc b/test/fixtures/source_1.0-1.dsc new file mode 100644 index 0000000..3ca6bb9 --- /dev/null +++ b/test/fixtures/source_1.0-1.dsc @@ -0,0 +1,17 @@ +Format: 1.0 +Source: source +Binary: source +Architecture: any +Version: 1.0-1 +Maintainer: Freight +Homepage: +Standards-Version: 3.9.5 +Build-Depends: debhelper (>= 9) +Package-List: + source deb unknown optional arch=any +Checksums-Sha1: + 4459fbd51b13076ef5f21df77a4a68a48322adeb 9977 source_1.0-1.tar.gz +Checksums-Sha256: + dbb1d5069e4bb814493eb0ed3bb6a9b8a15b45a2bf7d1e04f95622007bef8d98 9977 source_1.0-1.tar.gz +Files: + 5af1440b5a785910a9a1a841139c6745 9977 source_1.0-1.tar.gz diff --git a/test/fixtures/source_1.0-1.tar.gz b/test/fixtures/source_1.0-1.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..6e8b16ad70b7d7b5d987089761bb4367913d2887 GIT binary patch literal 9977 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 Da}$eA literal 0 HcmV?d00001 diff --git a/test/fixtures/source_1.0.orig.tar.gz b/test/fixtures/source_1.0.orig.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..74d49cf26782b0ae8402ee903939d4de8c32d80a GIT binary patch literal 105 zcmb2|=3tn&>2nwZ^V@T~1)CjsSRJMoiQcGr7ht=tL9*xfcix4}!j4;J+nk-uWIL~L z=fcz1`rg!io^d?$ Date: Thu, 24 Mar 2016 11:24:09 +0100 Subject: [PATCH 28/72] bump version to 0.3.7 --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index a51aa47..3975a60 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ -VERSION=0.3.6 -BUILD=2 +VERSION=0.3.7 +BUILD=1 SH=dash From cf57ec13249eac94a7283492ed4caeafcd440a75 Mon Sep 17 00:00:00 2001 From: Dominic Cleal Date: Thu, 24 Mar 2016 12:34:16 +0000 Subject: [PATCH 29/72] Add link to freight-init man page --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 10a9c92..387826b 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,7 @@ There's also [French documentation](http://blog.valouille.fr/2014/03/creer-un-de * [`freight-add`(1)](http://freight-team.github.io/freight/freight-add.1.html) * [`freight-cache`(1)](http://freight-team.github.io/freight/freight-cache.1.html) * [`freight-clear-cache`(1)](http://freight-team.github.io/freight/freight-clear-cache.1.html) +* [`freight-init`(1)](http://freight-team.github.io/freight/freight-init.1.html) * [`freight`(5)](http://freight-team.github.io/freight/freight.5.html) ## Contribute From 010754c44758a62438cf091515f1e394a0edceb5 Mon Sep 17 00:00:00 2001 From: Ward Vandewege Date: Thu, 28 Jan 2016 11:04:16 -0500 Subject: [PATCH 30/72] Handle the scenario where $VARLIB is a symlink If $VARLIB (typically /var/lib/freight) is a symlink to another directory, freight-cache generates an invalid $MANAGER value. This patch fixes that. I also verified that the behavior is unchanged when $VARLIB is not a symlink. --- bin/freight-cache | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/freight-cache b/bin/freight-cache index 1a7d4da..52fb65f 100755 --- a/bin/freight-cache +++ b/bin/freight-cache @@ -88,7 +88,7 @@ cd "$VARLIB" if [ -z "$*" ] then DIRS="$( - find "$VARLIB" -mindepth 2 -maxdepth 2 -type d -printf "%P\n" | + find "$VARLIB"/ -mindepth 2 -maxdepth 2 -type d -printf "%P\n" | grep -v "^\\." | tr "\n" " " )" @@ -100,7 +100,7 @@ do # Parse the manager and distro out of the Freight library path. DIR="$(readlink -f "$DIR")" - DIR="${DIR##"$VARLIB/"}" + DIR="${DIR##"$(readlink -f "$VARLIB")/"}" MANAGER="$(dirname "$DIR")" DIST="$(basename "$DIR")" From 8b2b575e549922ee8561466cf94352d911c23bdd Mon Sep 17 00:00:00 2001 From: Dominic Cleal Date: Fri, 25 Mar 2016 15:46:14 +0000 Subject: [PATCH 31/72] Add tests for VARLIB being a symlink --- test/apt_add.bats | 7 +++++++ test/apt_cache.bats | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/test/apt_add.bats b/test/apt_add.bats index 7ca10ff..b3fc7b1 100644 --- a/test/apt_add.bats +++ b/test/apt_add.bats @@ -52,3 +52,10 @@ setup() { assert_output "# [freight] added ${FIXTURES}/source_1.0.orig.tar.gz to apt/example" test -e ${FREIGHT_LIB}/apt/example/source_1.0.orig.tar.gz } + +@test "freight-add handles VARLIB being a symlink" { + mv $FREIGHT_LIB ${FREIGHT_LIB}_real + ln -s ${FREIGHT_LIB}_real $FREIGHT_LIB + freight_add ${FIXTURES}/test_1.0_all.deb apt/example/comp + test -e ${FREIGHT_LIB}_real/apt/example/comp/test_1.0_all.deb +} diff --git a/test/apt_cache.bats b/test/apt_cache.bats index a508766..7f8ef18 100644 --- a/test/apt_cache.bats +++ b/test/apt_cache.bats @@ -69,3 +69,11 @@ setup() { assert_output "" test -e ${FREIGHT_CACHE}/pool/example/main/t/test/test_1.0_all.deb } + +@test "freight-cache handles VARLIB being a symlink" { + mv $FREIGHT_LIB ${FREIGHT_LIB}_real + ln -s ${FREIGHT_LIB}_real $FREIGHT_LIB + freight_cache + test -e ${FREIGHT_CACHE}/pool/example/comp/t/test/test_1.0_all.deb + test -e ${FREIGHT_CACHE}/pool/example/main/t/test/test_1.0_all.deb +} From 792c8b8d5b10dbe8bc6b8ebcf9ee80d964fdc08c Mon Sep 17 00:00:00 2001 From: Michael Moll Date: Tue, 29 Mar 2016 17:47:35 +0200 Subject: [PATCH 32/72] fix quoting for non-tty case closes GH-28 --- lib/freight/apt.sh | 2 +- test/apt_cache.bats | 5 +++++ test/freight_helpers.bash | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/freight/apt.sh b/lib/freight/apt.sh index e9f80f2..e665ebc 100644 --- a/lib/freight/apt.sh +++ b/lib/freight/apt.sh @@ -205,7 +205,7 @@ EOF # concatenate signatures. for GPGKEY in $GPG; do # shellcheck disable=SC2046 - gpg -abs"$([ "$TTY" ] || echo " --no-tty")" --use-agent -u"$GPGKEY" \ + gpg -abs$([ "$TTY" ] || echo " --no-tty") --use-agent -u"$GPGKEY" \ $([ "$GPG_PASSPHRASE_FILE" ] && echo " --batch --passphrase-fd 1 --passphrase-file $GPG_PASSPHRASE_FILE") \ $([ "$GPG_DIGEST_ALGO" ] && echo " --personal-digest-preferences $GPG_DIGEST_ALGO") \ -o"$TMP/release_last_signature.gpg" "$DISTCACHE/Release" || { diff --git a/test/apt_cache.bats b/test/apt_cache.bats index 7f8ef18..8aa2ad5 100644 --- a/test/apt_cache.bats +++ b/test/apt_cache.bats @@ -40,6 +40,11 @@ setup() { gpg --verify ${FREIGHT_CACHE}/dists/example/Release.gpg ${FREIGHT_CACHE}/dists/example/Release } +@test "freight-cache works without tty" { + run freight_cache_nohup -v + assert_success +} + @test "apt-get fetches package list" { check_apt_support freight_cache -v diff --git a/test/freight_helpers.bash b/test/freight_helpers.bash index cdd5cf2..b911ab8 100644 --- a/test/freight_helpers.bash +++ b/test/freight_helpers.bash @@ -33,6 +33,10 @@ freight_cache() { bin/freight cache -c $FREIGHT_CONFIG "$@" } +freight_cache_nohup() { + nohup bin/freight cache -c $FREIGHT_CONFIG "$@" +} + # Generates a GPG key for all tests, once only due to entropy required gpg_init() { if [ ! -e $GNUPGHOME ]; then From 82155beeab0c82b8bf3dec4de09a660d075d3d63 Mon Sep 17 00:00:00 2001 From: Dominic Cleal Date: Wed, 30 Mar 2016 08:24:23 +0100 Subject: [PATCH 33/72] Refresh freight-init man page Fix formatting of paths, fix missing supported arguments and fix names of existing libdir/cachedir args. --- man/man1/freight-init.1 | 34 +++++++++++++++++++++++++--------- man/man1/freight-init.1.ronn | 26 +++++++++++++++++--------- 2 files changed, 42 insertions(+), 18 deletions(-) diff --git a/man/man1/freight-init.1 b/man/man1/freight-init.1 index 3026afd..c3b69b5 100644 --- a/man/man1/freight-init.1 +++ b/man/man1/freight-init.1 @@ -7,30 +7,46 @@ \fBfreight\-init\fR \- initialize a Freight directory . .SH "SYNOPSIS" -\fBfreight init\fR [\fB\-l\fR \fIvarlib\fR] [\fB\-\-cache\fR \fIvarcache\fR] \fB\-g\fR \fIgpg\fR \fIdirname\fR +\fBfreight init\fR [\fB\-\-libdir\fR \fIvarlib\fR] [\fB\-\-cachedir\fR \fIvarcache\fR] [\fB\-\-archs\fR \fIarchs\fR] [\fB\-\-origin\fR \fIorigin\fR] [\fB\-\-label\fR \fIlabel\fR] [\fB\-v\fR] [\fB\-h\fR] \fB\-g\fR \fIgpg\fR \fIdirname\fR . .SH "DESCRIPTION" -\fBfreight\-init\fR will setup a directory to be used by Freight\. It will generate small wrappers around the original Freight commands\. Use \fB\./freight\-add\fR and \fB\./freight\-cache\fR to work against the \fBVARLIB\fR and \fBVARCACHE\fR given to \fBfreight init\fR\. +\fBfreight\-init\fR will setup a directory to be used by Freight\. It will generate small wrappers around the original Freight commands\. Use \fBfreight\-add\fR(1) and \fBfreight\-cache\fR(1) to work against the \fBVARLIB\fR and \fBVARCACHE\fR given to \fBfreight init\fR\. . .P -The benefit of using \fBfreight\-init\fR is, that all data is stored in one place and dont have to pass \fB\-c _conf_\fR option all the time\. +The benefit of using \fBfreight\-init\fR is to automate the setup of Freight and to configure all data to be stored in one directory\. . .P -Configuration is stored in \fB_dirname_/\.freight\.conf\fR\. +Configuration is stored in \fIdirname\fR\fB/etc/freight\.conf\fR\. . .SH "OPTIONS" . .TP -\fB\-g\fR \fIgpg\fR, \fB\-\-gpg=\fR\fIgpg\fR` +\fB\-g\fR \fIgpg\fR, \fB\-\-gpg=\fR\fIgpg\fR GPG key\. May be given multiple times\. . .TP -\fB\-l\fR \fIvarlib\fR, \fB\-\-varlib=\fR\fIvarlib\fB_\fR\fR -VARLIB directory to use\. Defaults todirname_/lib` +\fB\-\-libdir=\fR\fIvarlib\fR +VARLIB directory to use\. Defaults to \fIdirname\fR\fB/var/lib\fR . .TP -\fB\-\-varcache=\fR\fIvarcache\fB_\fR\fR -VARCACHE directory to use\. Defaults todirname_/cache` +\fB\-\-cachedir=\fR\fIvarcache\fR +VARCACHE directory to use\. Defaults to \fIdirname\fR\fB/var/cache\fR +. +.TP +\fB\-\-archs=\fR\fIarchs\fR +Architectures to generate archives for\. Defaults to \fBi386 amd64\fR +. +.TP +\fB\-\-origin=\fR\fIorigin\fR +Debian archive Origin field value\. Defaults to \fBFreight\fR +. +.TP +\fB\-\-label=\fR\fIlabel\fR +Debian archive Label field value\. Defaults to \fBFreight\fR +. +.TP +\fB\-\-suite=\fR\fIsuite\fR +Debian archive Suite field value\. . .TP \fB\-v\fR, \fB\-\-verbose\fR diff --git a/man/man1/freight-init.1.ronn b/man/man1/freight-init.1.ronn index 210d0e4..09f5ce0 100644 --- a/man/man1/freight-init.1.ronn +++ b/man/man1/freight-init.1.ronn @@ -3,24 +3,32 @@ freight-init(1) -- initialize a Freight directory ## SYNOPSIS -`freight init` [`-l` _varlib_] [`--cache` _varcache_] `-g` _gpg_ _dirname_ +`freight init` [`--libdir` _varlib_] [`--cachedir` _varcache_] [`--archs` _archs_] [`--origin` _origin_] [`--label` _label_] [`-v`] [`-h`] `-g` _gpg_ _dirname_ ## DESCRIPTION -`freight-init` will setup a directory to be used by Freight. It will generate small wrappers around the original Freight commands. Use `./freight-add` and `./freight-cache` to work against the `VARLIB` and `VARCACHE` given to `freight init`. +`freight-init` will setup a directory to be used by Freight. It will generate small wrappers around the original Freight commands. Use `freight-add`(1) and `freight-cache`(1) to work against the `VARLIB` and `VARCACHE` given to `freight init`. -The benefit of using `freight-init` is, that all data is stored in one place and dont have to pass `-c _conf_` option all the time. +The benefit of using `freight-init` is to automate the setup of Freight and to configure all data to be stored in one directory. -Configuration is stored in `_dirname_/.freight.conf`. +Configuration is stored in _dirname_`/etc/freight.conf`. ## OPTIONS -* `-g` _gpg_, `--gpg=`_gpg_`: +* `-g` _gpg_, `--gpg=`_gpg_: GPG key. May be given multiple times. -* `-l` _varlib_, `--varlib=`_varlib`_: - VARLIB directory to use. Defaults to `_dirname_/lib` -* `--varcache=`_varcache`_: - VARCACHE directory to use. Defaults to `_dirname_/cache` +* `--libdir=`_varlib_: + VARLIB directory to use. Defaults to _dirname_`/var/lib` +* `--cachedir=`_varcache_: + VARCACHE directory to use. Defaults to _dirname_`/var/cache` +* `--archs=`_archs_: + Architectures to generate archives for. Defaults to `i386 amd64` +* `--origin=`_origin_: + Debian archive Origin field value. Defaults to `Freight` +* `--label=`_label_: + Debian archive Label field value. Defaults to `Freight` +* `--suite=`_suite_: + Debian archive Suite field value. * `-v`, `--verbose`: Verbose mode. * `-h`, `--help`: From c537ecfa349c650ced6f6ebf8e7bb54559e29a4d Mon Sep 17 00:00:00 2001 From: Michael Moll Date: Wed, 30 Mar 2016 10:41:26 +0200 Subject: [PATCH 34/72] bump version to 0.3.8 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 3975a60..2c7e2e5 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION=0.3.7 +VERSION=0.3.8 BUILD=1 SH=dash From 0269d41cce78ea2b3fac976be486f64362b61515 Mon Sep 17 00:00:00 2001 From: Michael Moll Date: Thu, 14 Jul 2016 22:43:04 +0200 Subject: [PATCH 35/72] use UTC timezone for Date fields apt 1.3 does require that. --- lib/freight/apt.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/freight/apt.sh b/lib/freight/apt.sh index e665ebc..90fdc1b 100644 --- a/lib/freight/apt.sh +++ b/lib/freight/apt.sh @@ -81,8 +81,8 @@ apt_filesize() { # Setup the repository for the distro named in the first argument, # including all packages read from `stdin`. apt_cache() { - REL_DATE="$(LC_ALL=en_US date '+%a, %d %b %Y %H:%M:%S %Z')" - VALID_DATE="Tue, 30 Nov 2038 00:00:00 JST" + REL_DATE="$(LC_ALL=en_US date -u '+%a, %d %b %Y %H:%M:%S %Z')" + VALID_DATE="Tue, 30 Nov 2038 00:00:00 UTC" DIST="$1" SUITE="${SUITE:-$DIST}" From 9034ce4851b990da97bc5710a60aba8e8db4fae6 Mon Sep 17 00:00:00 2001 From: Philippe Poilbarbe Date: Tue, 13 Sep 2016 14:01:39 +0200 Subject: [PATCH 36/72] issue #37: Raising an error when adding al already registered package --- bin/freight-add | 5 +++++ man/man1/freight-add.1 | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/bin/freight-add b/bin/freight-add index b9fe6d4..f44f0ba 100755 --- a/bin/freight-add +++ b/bin/freight-add @@ -5,6 +5,7 @@ #/ Usage: freight add [-c ] [-v] [-h] /... #/ -c , --conf= config file to parse #/ -v, --verbose verbose mode +#/ -e, --add-error exit with error if package already added #/ -h, --help show this help message set -e @@ -20,6 +21,7 @@ do -c*) CONF="$(echo "$1" | cut -c"3-")" shift;; --conf=*) CONF="$(echo "$1" | cut -c"8-")" shift;; -v|--verbose) VERBOSE=1 shift;; + -e|--add-error) FREIGHT_ADD_ERROR="YES" shift;; -h|--help) usage 0;; -*) echo "# [freight] unknown switch: $1" >&2;; *) break;; @@ -73,6 +75,9 @@ add() { then echo "# [freight] $2 already has $3${4+" as "}$4" >&2 else cat "$TMP/ln" >&2 fi + if [ -n "$FREIGHT_ADD_ERROR" ] + then exit 2 + fi fi } diff --git a/man/man1/freight-add.1 b/man/man1/freight-add.1 index 22cac9d..033032e 100644 --- a/man/man1/freight-add.1 +++ b/man/man1/freight-add.1 @@ -26,6 +26,10 @@ Use an alternate configuration file\. Verbose mode\. . .TP +\fB\-e\fR, \fB\-\-add\-error\fR +Raises an error if the package to add is already registered\. +. +.TP \fB\-h\fR, \fB\-\-help\fR Show a help message\. . @@ -41,6 +45,10 @@ The default configuration files\. See \fBfreight\fR(5)\. \fBFREIGHT_CONF\fR The pathname of an alternate configuration file\. See \fBfreight\fR(5)\. . +.TP +\fBFREIGHT_ADD_ERROR\fR +If not empty acts as --add-error option\. +. .SH "THEME SONG" The New Pornographers \- "All the Old Showstoppers" . From 2e5828a87cc003e9bc1a94b3ca94b44ddbb34f89 Mon Sep 17 00:00:00 2001 From: Philippe Poilbarbe Date: Tue, 13 Sep 2016 15:05:49 +0200 Subject: [PATCH 37/72] Issue #37: Man are generated from .ronn files --- man/man1/freight-add.1 | 4 ++-- man/man1/freight-add.1.ronn | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/man/man1/freight-add.1 b/man/man1/freight-add.1 index 033032e..91e0dbb 100644 --- a/man/man1/freight-add.1 +++ b/man/man1/freight-add.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "FREIGHT\-ADD" "1" "March 2016" "" "Freight" +.TH "FREIGHT\-ADD" "1" "September 2016" "" "Freight" . .SH "NAME" \fBfreight\-add\fR \- add a package to Freight @@ -47,7 +47,7 @@ The pathname of an alternate configuration file\. See \fBfreight\fR(5)\. . .TP \fBFREIGHT_ADD_ERROR\fR -If not empty acts as --add-error option\. +If not empty acts as \-\-add\-error option\. . .SH "THEME SONG" The New Pornographers \- "All the Old Showstoppers" diff --git a/man/man1/freight-add.1.ronn b/man/man1/freight-add.1.ronn index 207285f..728c086 100644 --- a/man/man1/freight-add.1.ronn +++ b/man/man1/freight-add.1.ronn @@ -17,6 +17,8 @@ The package files are organized in the Freight library so `freight-cache`(1) has Use an alternate configuration file. * `-v`, `--verbose`: Verbose mode. +* `-e`, `--add-error`: + Raises an error if the package to add is already registered. * `-h`, `--help`: Show a help message. @@ -29,6 +31,8 @@ The package files are organized in the Freight library so `freight-cache`(1) has * `FREIGHT_CONF`: The pathname of an alternate configuration file. See `freight`(5). +* `FREIGHT_ADD_ERROR`: + If not empty acts as --add-error option. ## THEME SONG From 3692f3c168272ecd89b2a580fd44999f2078eb4d Mon Sep 17 00:00:00 2001 From: Philippe Poilbarbe Date: Thu, 15 Sep 2016 09:53:59 +0200 Subject: [PATCH 38/72] issue #37: Raising an error when adding al already registered package --- bin/freight-add | 5 +++++ man/man1/freight-add.1 | 10 +++++++++- man/man1/freight-add.1.ronn | 4 ++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/bin/freight-add b/bin/freight-add index b9fe6d4..f44f0ba 100755 --- a/bin/freight-add +++ b/bin/freight-add @@ -5,6 +5,7 @@ #/ Usage: freight add [-c ] [-v] [-h] /... #/ -c , --conf= config file to parse #/ -v, --verbose verbose mode +#/ -e, --add-error exit with error if package already added #/ -h, --help show this help message set -e @@ -20,6 +21,7 @@ do -c*) CONF="$(echo "$1" | cut -c"3-")" shift;; --conf=*) CONF="$(echo "$1" | cut -c"8-")" shift;; -v|--verbose) VERBOSE=1 shift;; + -e|--add-error) FREIGHT_ADD_ERROR="YES" shift;; -h|--help) usage 0;; -*) echo "# [freight] unknown switch: $1" >&2;; *) break;; @@ -73,6 +75,9 @@ add() { then echo "# [freight] $2 already has $3${4+" as "}$4" >&2 else cat "$TMP/ln" >&2 fi + if [ -n "$FREIGHT_ADD_ERROR" ] + then exit 2 + fi fi } diff --git a/man/man1/freight-add.1 b/man/man1/freight-add.1 index 22cac9d..91e0dbb 100644 --- a/man/man1/freight-add.1 +++ b/man/man1/freight-add.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "FREIGHT\-ADD" "1" "March 2016" "" "Freight" +.TH "FREIGHT\-ADD" "1" "September 2016" "" "Freight" . .SH "NAME" \fBfreight\-add\fR \- add a package to Freight @@ -26,6 +26,10 @@ Use an alternate configuration file\. Verbose mode\. . .TP +\fB\-e\fR, \fB\-\-add\-error\fR +Raises an error if the package to add is already registered\. +. +.TP \fB\-h\fR, \fB\-\-help\fR Show a help message\. . @@ -41,6 +45,10 @@ The default configuration files\. See \fBfreight\fR(5)\. \fBFREIGHT_CONF\fR The pathname of an alternate configuration file\. See \fBfreight\fR(5)\. . +.TP +\fBFREIGHT_ADD_ERROR\fR +If not empty acts as \-\-add\-error option\. +. .SH "THEME SONG" The New Pornographers \- "All the Old Showstoppers" . diff --git a/man/man1/freight-add.1.ronn b/man/man1/freight-add.1.ronn index 207285f..728c086 100644 --- a/man/man1/freight-add.1.ronn +++ b/man/man1/freight-add.1.ronn @@ -17,6 +17,8 @@ The package files are organized in the Freight library so `freight-cache`(1) has Use an alternate configuration file. * `-v`, `--verbose`: Verbose mode. +* `-e`, `--add-error`: + Raises an error if the package to add is already registered. * `-h`, `--help`: Show a help message. @@ -29,6 +31,8 @@ The package files are organized in the Freight library so `freight-cache`(1) has * `FREIGHT_CONF`: The pathname of an alternate configuration file. See `freight`(5). +* `FREIGHT_ADD_ERROR`: + If not empty acts as --add-error option. ## THEME SONG From 0bafaaab31ca867658a53c8d96800dd826412a3f Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Tue, 1 Nov 2016 20:26:07 +0100 Subject: [PATCH 39/72] This changes the destdir for fpm based builds from debian to deb. (#39) When trying to build a traditional debian package it is quite annoying that `make clean` removes the debian directory. --- Makefile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 2c7e2e5..bb39f47 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ mandir=${prefix}/share/man all: clean: - rm -rf *.deb debian man/man*/*.html test/tmp + rm -rf *.deb deb man/man*/*.html test/tmp find . -name '*~' -delete install: install-bin install-lib install-man install-sysconf @@ -52,15 +52,15 @@ uninstall-sysconf: rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(sysconfdir) || true build: - make install prefix=/usr sysconfdir=/etc DESTDIR=debian + make install prefix=/usr sysconfdir=/etc DESTDIR=deb fpm -s dir -t deb \ -n freight -v $(VERSION) --iteration $(BUILD) -a all \ -d coreutils -d dash -d dpkg -d gnupg -d grep \ -m "Richard Crowley " \ --url "https://github.com/freight-team/freight" \ --description "A modern take on the Debian archive." \ - -C debian . - make uninstall prefix=/usr sysconfdir=/etc DESTDIR=debian + -C deb . + make uninstall prefix=/usr sysconfdir=/etc DESTDIR=deb man: find man -name \*.ronn | xargs -n1 ronn --manual=Freight --style=toc @@ -96,4 +96,4 @@ test/tmp/bin/sh: test/tmp/bin check: test/tmp/bats test/tmp/bats-assert test/tmp/bin/sh PATH=test/tmp/bin/:$$PATH test/tmp/bats/bin/bats test/ -.PHONY: all install uninstall deb man gh-pages check +.PHONY: all clean install uninstall build man docs gh-pages check From 2c8654d1951c1124d72a30c43d72e1196437be80 Mon Sep 17 00:00:00 2001 From: Sjoerd Mullender Date: Tue, 19 Apr 2016 15:14:33 +0200 Subject: [PATCH 40/72] Look for correct extension to tar and diff files. closes GH-24 closes GH-32 --- lib/freight/apt.sh | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/lib/freight/apt.sh b/lib/freight/apt.sh index 90fdc1b..0b203b0 100644 --- a/lib/freight/apt.sh +++ b/lib/freight/apt.sh @@ -365,26 +365,19 @@ apt_cache_source() { VERSION="$(apt_source_version "$PATHNAME")" ORIG_VERSION="$(apt_source_origversion "$PATHNAME")" DIRNAME="$(dirname "$PATHNAME")" - DSC_FILENAME="${NAME}_${VERSION%*:}.dsc" - DEBTAR_GZ_FILENAME="${NAME}_${VERSION%*:}.debian.tar.gz" - DEBTAR_BZ2_FILENAME="${NAME}_${VERSION%*:}.debian.tar.bz2" - DEBTAR_XZ_FILENAME="${NAME}_${VERSION%*:}.debian.tar.xz" - DEBTAR_LZMA_FILENAME="${NAME}_${VERSION%*:}.debian.tar.lzma" - DIFFGZ_FILENAME="${NAME}_${VERSION%*:}.diff.gz" - ORIG_FILENAME="${NAME}_${ORIG_VERSION}.orig.tar.gz" - TAR_FILENAME="${NAME}_${VERSION%*:}.tar.gz" - - # Find which style of diff they're using. - if [ -f "$VARLIB/apt/$DIST/$DIRNAME/$DEBTAR_GZ_FILENAME" ] - then DIFF_FILENAME=${DEBTAR_GZ_FILENAME} - elif [ -f "$VARLIB/apt/$DIST/$DIRNAME/$DEBTAR_BZ2_FILENAME" ] - then DIFF_FILENAME=${DEBTAR_BZ2_FILENAME} - elif [ -f "$VARLIB/apt/$DIST/$DIRNAME/$DEBTAR_XZ_FILENAME" ] - then DIFF_FILENAME=${DEBTAR_XZ_FILENAME} - elif [ -f "$VARLIB/apt/$DIST/$DIRNAME/$DEBTAR_LZMA_FILENAME" ] - then DIFF_FILENAME=${DEBTAR_LZMA_FILENAME} - else DIFF_FILENAME=${DIFFGZ_FILENAME} - fi + DSC_FILENAME="${NAME}_${VERSION##*:}.dsc" + + for EXT in gz bz2 xz lzma; do + if [ -z "$ORIG_FILENAME" ] && [ -f "$VARLIB/apt/$DIST/$DIRNAME/${NAME}_${ORIG_VERSION}.orig.tar.$EXT" ] + then ORIG_FILENAME="${NAME}_${ORIG_VERSION}.orig.tar.$EXT" + fi + if [ -z "$DIFF_FILENAME" ] && [ -f "$VARLIB/apt/$DIST/$DIRNAME/${NAME}_${VERSION##*:}.diff.$EXT" ] + then DIFF_FILENAME="${NAME}_${VERSION##*:}.diff.$EXT" + fi + if [ -z "$TAR_FILENAME" ] && [ -f "$VARLIB/apt/$DIST/$DIRNAME/${NAME}_${VERSION##*:}.tar.$EXT" ] + then TAR_FILENAME="${NAME}_${VERSION##*:}.tar.$EXT" + fi + done # Verify this package by ensuring the other necessary files are present. [ -f "$VARLIB/apt/$DIST/$DIRNAME/$ORIG_FILENAME" -a -f "$VARLIB/apt/$DIST/$DIRNAME/$DIFF_FILENAME" -o -f "$VARLIB/apt/$DIST/$DIRNAME/$TAR_FILENAME" ] || { From 514777a0f0eea4d4870866e96cdad775d774d00d Mon Sep 17 00:00:00 2001 From: Michael Moll Date: Tue, 1 Nov 2016 21:06:19 +0100 Subject: [PATCH 41/72] bump version to 0.3.9 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index bb39f47..502ba83 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION=0.3.8 +VERSION=0.3.9 BUILD=1 SH=dash From 51628b24c5efedaa2f0579d0f7b2b2d4241dc5f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuli=20Sepp=C3=A4nen?= Date: Wed, 2 Nov 2016 12:11:27 +0200 Subject: [PATCH 42/72] Change freight apt repository URL to a non-deprecated one (#41) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 387826b..96fd14b 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ Serve `/var/cache/freight` via your favorite web server and install it as an APT ### From a Debian archive wget -O - https://swupdate.openvpn.net/repos/repo-public.gpg|sudo apt-key add - - echo "deb http://build.openvpn.net/freight_team $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/freight.list + echo "deb http://build.openvpn.net/debian/freight_team $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/freight.list sudo apt-get update sudo apt-get -y install freight From 8668a829b2b1556c04c0b9da3a609d6d65207b3b Mon Sep 17 00:00:00 2001 From: Michael Moll Date: Mon, 7 Nov 2016 23:08:23 +0100 Subject: [PATCH 43/72] Revert "Look for correct extension to tar and diff files." This reverts commit 2c8654d1951c1124d72a30c43d72e1196437be80. --- lib/freight/apt.sh | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/lib/freight/apt.sh b/lib/freight/apt.sh index 0b203b0..90fdc1b 100644 --- a/lib/freight/apt.sh +++ b/lib/freight/apt.sh @@ -365,19 +365,26 @@ apt_cache_source() { VERSION="$(apt_source_version "$PATHNAME")" ORIG_VERSION="$(apt_source_origversion "$PATHNAME")" DIRNAME="$(dirname "$PATHNAME")" - DSC_FILENAME="${NAME}_${VERSION##*:}.dsc" - - for EXT in gz bz2 xz lzma; do - if [ -z "$ORIG_FILENAME" ] && [ -f "$VARLIB/apt/$DIST/$DIRNAME/${NAME}_${ORIG_VERSION}.orig.tar.$EXT" ] - then ORIG_FILENAME="${NAME}_${ORIG_VERSION}.orig.tar.$EXT" - fi - if [ -z "$DIFF_FILENAME" ] && [ -f "$VARLIB/apt/$DIST/$DIRNAME/${NAME}_${VERSION##*:}.diff.$EXT" ] - then DIFF_FILENAME="${NAME}_${VERSION##*:}.diff.$EXT" - fi - if [ -z "$TAR_FILENAME" ] && [ -f "$VARLIB/apt/$DIST/$DIRNAME/${NAME}_${VERSION##*:}.tar.$EXT" ] - then TAR_FILENAME="${NAME}_${VERSION##*:}.tar.$EXT" - fi - done + DSC_FILENAME="${NAME}_${VERSION%*:}.dsc" + DEBTAR_GZ_FILENAME="${NAME}_${VERSION%*:}.debian.tar.gz" + DEBTAR_BZ2_FILENAME="${NAME}_${VERSION%*:}.debian.tar.bz2" + DEBTAR_XZ_FILENAME="${NAME}_${VERSION%*:}.debian.tar.xz" + DEBTAR_LZMA_FILENAME="${NAME}_${VERSION%*:}.debian.tar.lzma" + DIFFGZ_FILENAME="${NAME}_${VERSION%*:}.diff.gz" + ORIG_FILENAME="${NAME}_${ORIG_VERSION}.orig.tar.gz" + TAR_FILENAME="${NAME}_${VERSION%*:}.tar.gz" + + # Find which style of diff they're using. + if [ -f "$VARLIB/apt/$DIST/$DIRNAME/$DEBTAR_GZ_FILENAME" ] + then DIFF_FILENAME=${DEBTAR_GZ_FILENAME} + elif [ -f "$VARLIB/apt/$DIST/$DIRNAME/$DEBTAR_BZ2_FILENAME" ] + then DIFF_FILENAME=${DEBTAR_BZ2_FILENAME} + elif [ -f "$VARLIB/apt/$DIST/$DIRNAME/$DEBTAR_XZ_FILENAME" ] + then DIFF_FILENAME=${DEBTAR_XZ_FILENAME} + elif [ -f "$VARLIB/apt/$DIST/$DIRNAME/$DEBTAR_LZMA_FILENAME" ] + then DIFF_FILENAME=${DEBTAR_LZMA_FILENAME} + else DIFF_FILENAME=${DIFFGZ_FILENAME} + fi # Verify this package by ensuring the other necessary files are present. [ -f "$VARLIB/apt/$DIST/$DIRNAME/$ORIG_FILENAME" -a -f "$VARLIB/apt/$DIST/$DIRNAME/$DIFF_FILENAME" -o -f "$VARLIB/apt/$DIST/$DIRNAME/$TAR_FILENAME" ] || { From a84abc98d037baa415bac3fec8ec169a13e0f3c2 Mon Sep 17 00:00:00 2001 From: Michael Moll Date: Mon, 7 Nov 2016 23:09:14 +0100 Subject: [PATCH 44/72] bump version to 0.3.10 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 502ba83..ae1c66e 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION=0.3.9 +VERSION=0.3.10 BUILD=1 SH=dash From 4f412fa6daded0cac6b8f9b4f5c643343a9cb36f Mon Sep 17 00:00:00 2001 From: Stephen Ryan Date: Tue, 22 Nov 2016 09:19:21 +0000 Subject: [PATCH 45/72] Let install-man task work on second and subsequent attempts gzip would previously fail due to the existing man pages Fixes GH-44 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ae1c66e..210024b 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ install-lib: install-man: find man -type f -name \*.[12345678] -printf %P\\0 | xargs -0r -I__ install -m644 -D man/__ $(DESTDIR)$(mandir)/__ - find man -type f -name \*.[12345678] -printf %P\\0 | xargs -0r -I__ gzip $(DESTDIR)$(mandir)/__ + find man -type f -name \*.[12345678] -printf %P\\0 | xargs -0r -I__ gzip -f $(DESTDIR)$(mandir)/__ install-sysconf: find etc -type f -not -name freight.conf -printf %P\\0 | xargs -0r -I__ install -m644 -D etc/__ $(DESTDIR)$(sysconfdir)/__ From fb029798c8d3a0277ea01fa04339b69522d6600d Mon Sep 17 00:00:00 2001 From: Jeremy Teale Date: Mon, 13 Feb 2017 13:08:32 -0800 Subject: [PATCH 46/72] Prevent GPG >= 2.1 from using .kbx pubring format As described here[1], if pubring.gpg already exists, .kbx format will not be used. This fixes tests for new GPG versions that otherwise failed due to `pubring.gpg` not existing after `gpg --import` into `$TMP/gpg`. 1: https://www.gnupg.org/faq/whats-new-in-2.1.html closes GH-46 --- lib/freight/apt.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/freight/apt.sh b/lib/freight/apt.sh index 90fdc1b..c460a03 100644 --- a/lib/freight/apt.sh +++ b/lib/freight/apt.sh @@ -226,11 +226,13 @@ EOF # the appropriate public keys. `keyring.gpg` is appropriate for # copying directly to `/etc/apt/trusted.gpg.d`. mkdir -m700 -p "$TMP/gpg" + # Create `pubring.gpg` to prevent gpg version >= 2.1 from using the + # new `pubring.kbx` format during an initial `gpg --import`. + : > "$TMP/gpg/pubring.gpg" && chmod 644 "$TMP/gpg/pubring.gpg" # shellcheck disable=SC2086 gpg -q --export -a $GPG | tee "$VARCACHE/pubkey.gpg" | gpg -q --homedir "$TMP/gpg" --import - chmod 644 "$TMP/gpg/pubring.gpg" mv "$TMP/gpg/pubring.gpg" "$VARCACHE/keyring.gpg" # Move the symbolic link for this distro to this build. From 6968e488b2e33c01de75bcc47cfeb878937d7994 Mon Sep 17 00:00:00 2001 From: "David R. Bild" Date: Fri, 3 Mar 2017 19:19:03 -0600 Subject: [PATCH 47/72] Add NotAutomatic and ButAutomaticUpgrades to conf --- etc/freight.conf.example | 5 ++++- lib/freight/conf.sh | 7 ++++++- man/man5/freight.5 | 8 ++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/etc/freight.conf.example b/etc/freight.conf.example index 0e1bc50..d1b78d0 100644 --- a/etc/freight.conf.example +++ b/etc/freight.conf.example @@ -5,9 +5,12 @@ VARLIB="/var/lib/freight" VARCACHE="/var/cache/freight" -# Default `Origin` and `Label` fields for `Release` files. +# Default `Origin`, `Label`, `NotAutomatic`, and +# `ButAutomaticUpgrades` fields for `Release` files. ORIGIN="Freight" LABEL="Freight" +NOT_AUTOMATIC="no" +BUT_AUTOMATIC_UPGRADES="no" # Cache the control files after each run (on), or regenerate them every # time (off). diff --git a/lib/freight/conf.sh b/lib/freight/conf.sh index 322f9b8..a4681bc 100644 --- a/lib/freight/conf.sh +++ b/lib/freight/conf.sh @@ -9,11 +9,16 @@ VARCACHE="/var/cache/freight" # shellcheck disable=SC2034 ARCHS="i386 amd64" -# Default `Origin` and `Label` fields for `Release` files. +# Default `Origin`, `Label`, 'NotAutomatic`, and +# `ButAutomaticUpgrades` fields for `Release` files. # shellcheck disable=SC2034 ORIGIN="Freight" # shellcheck disable=SC2034 LABEL="Freight" +# shellcheck disable=SC2034 +NOT_AUTOMATIC="no" +# shellcheck disable=SC2034 +BUT_AUTOMATIC_UPGRADES="no" # shellcheck disable=SC2034 CACHE="off" diff --git a/man/man5/freight.5 b/man/man5/freight.5 index 44c87bb..9158226 100644 --- a/man/man5/freight.5 +++ b/man/man5/freight.5 @@ -32,6 +32,14 @@ The \fBOrigin\fR field in the Debian archive\. The \fBLabel\fR field in the Debian archive\. . .TP +\fBNOT_AUTOMATIC\fR +The \fBNotAutomatic\fR field in the Debian archive\. +. +.TP +\fBBUT_AUTOMATIC_UGPRADES\fR +The \fBButAutomaticUpgrades\fR field in the Debian archive\. +. +.TP \fBCACHE\fR \fIon\fR to cache package control files or \fIoff\fR to read them from the packages on each \fBfreight\-cache\fR(1) run\. . From fb4b6009bc9843e00ed430d4150c3cc62bcb7a06 Mon Sep 17 00:00:00 2001 From: "David R. Bild" Date: Fri, 3 Mar 2017 19:21:25 -0600 Subject: [PATCH 48/72] Include NotAutomatic and ButAutomaticUpgrades in Release files --- lib/freight/apt.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/freight/apt.sh b/lib/freight/apt.sh index c460a03..820c2bc 100644 --- a/lib/freight/apt.sh +++ b/lib/freight/apt.sh @@ -138,6 +138,8 @@ Archive: $SUITE Component: $COMP Origin: $ORIGIN Label: $LABEL +NotAutomatic: $NOT_AUTOMATIC +ButAutomaticUpgrades: $BUT_AUTOMATIC_UPGRADES Architecture: $ARCH Date: $REL_DATE Valid-Until: $VALID_DATE @@ -153,6 +155,8 @@ Archive: $SUITE Component: $COMP Origin: $ORIGIN Label: $LABEL +NotAutomatic: $NOT_AUTOMATIC +ButAutomaticUpgrades: $BUT_AUTOMATIC_UPGRADES Architecture: source Date: $REL_DATE Valid-Until: $VALID_DATE @@ -171,6 +175,8 @@ Origin: $ORIGIN Label: $LABEL Suite: $SUITE Codename: $DIST +NotAutomatic: $NOT_AUTOMATIC +ButAutomaticUpgrades: $BUT_AUTOMATIC_UPGRADES Components: $(echo "$COMPS" | tr \\n " ") Architectures: $ARCHS Date: $REL_DATE From e93551126fc7b7462f7f22183f9a35a2fe80f886 Mon Sep 17 00:00:00 2001 From: Vasily Date: Fri, 28 Apr 2017 15:22:11 +0300 Subject: [PATCH 49/72] Add the ability to build deb package the Debian way --- README.md | 7 +++---- debian/changelog | 5 +++++ debian/compat | 1 + debian/control | 11 +++++++++++ debian/rules | 10 ++++++++++ 5 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/control create mode 100755 debian/rules diff --git a/README.md b/README.md index 96fd14b..aba846b 100644 --- a/README.md +++ b/README.md @@ -50,12 +50,11 @@ Serve `/var/cache/freight` via your favorite web server and install it as an APT ### From a custom-made Debian package -First [install FPM](https://github.com/jordansissel/fpm). Then clone the freight -repository, build a package and install it: +You need `build-essential` package installed. Clone the freight repository, build a package and install it: git clone git://github.com/freight-team/freight.git - cd freight && make build - sudo dpkg -i freight_-_all.deb + cd freight && dpkg-buildpackage -uc -us -b + sudo dpkg -i ../freight_-_all.deb ### From Fedora/EPEL repositories diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..c7ddbe5 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +freight (0.3.10) UNRELEASED; urgency=low + + * Initial release. + + -- Vasily Laur Tue, 11 Apr 2017 14:46:08 +0000 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..ec63514 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +9 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..0b2f590 --- /dev/null +++ b/debian/control @@ -0,0 +1,11 @@ +Source: freight +Section: utils +Priority: extra +Maintainer: Freight team +Build-Depends: debhelper (>=9) +Homepage: https://github.com/freight-team/freight + +Package: freight +Architecture: all +Depends: gnupg +Description: A modern take on the Debian archive diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..6bec60f --- /dev/null +++ b/debian/rules @@ -0,0 +1,10 @@ +#!/usr/bin/make -f + +%: + dh $@ + +# hide next line to enable tests +override_dh_auto_test: ; + +override_dh_auto_install: + dh_auto_install -- prefix=/usr sysconfdir=/etc From de67c6eb5d6b30c2cb26920e91068f891830d58f Mon Sep 17 00:00:00 2001 From: Michael Moll Date: Fri, 28 Apr 2017 14:24:49 +0200 Subject: [PATCH 50/72] bump version to 0.3.11 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 210024b..1b4f4fc 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION=0.3.10 +VERSION=0.3.11 BUILD=1 SH=dash From b18e0e56ce19533f3c3de18c53036d6cba05f5e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuli=20Sepp=C3=A4nen?= Date: Thu, 18 May 2017 18:16:17 +0300 Subject: [PATCH 51/72] Add Debian changelog for freight 0.3.11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Samuli Seppänen --- debian/changelog | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/debian/changelog b/debian/changelog index c7ddbe5..9bf075c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,14 @@ +freight (0.3.11) stable; urgency=low + + * bump version to 0.3.11 (Michael Moll, de67c6e) + * Add the ability to build deb package the Debian way (Vasily, e935511) + * Include NotAutomatic and ButAutomaticUpgrades in Release files (David R. Bild, fb4b600) + * Add NotAutomatic and ButAutomaticUpgrades to conf (David R. Bild, 6968e48) + * Prevent GPG >= 2.1 from using .kbx pubring format (Jeremy Teale, fb02979) + * Let install-man task work on second and subsequent attempts (Stephen Ryan, 4f412fa) + + -- Samuli Seppänen Thu, 18 May 2017 15:00:00 +0000 + freight (0.3.10) UNRELEASED; urgency=low * Initial release. From a10f4a08f0e9e5e92617976192c189795073d9d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuli=20Sepp=C3=A4nen?= Date: Thu, 18 May 2017 18:16:32 +0300 Subject: [PATCH 52/72] Ignore files generated by dpkg-buildpackage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Samuli Seppänen --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index d0f031d..f1e755f 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,5 @@ etc/freight.conf var test/tmp !test/fixtures/* +debian/freight* +debian/files From 42d0067a9c38a2a4ba9485ca17a947ed245764cc Mon Sep 17 00:00:00 2001 From: Michael Moll Date: Wed, 23 Aug 2017 13:25:59 +0200 Subject: [PATCH 53/72] fix new shellcheck warnings closes GH-42 closes GH-43 --- bin/freight-add | 1 + bin/freight-cache | 3 ++- bin/freight-clear-cache | 1 + bin/freight-init | 2 +- lib/freight/apt.sh | 15 ++++++++------- lib/freight/conf.sh | 3 ++- 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/bin/freight-add b/bin/freight-add index f44f0ba..2698540 100755 --- a/bin/freight-add +++ b/bin/freight-add @@ -1,4 +1,5 @@ #!/usr/bin/env sh +# shellcheck disable=SC1090 # Add a package to the Freight library. diff --git a/bin/freight-cache b/bin/freight-cache index 52fb65f..000898b 100755 --- a/bin/freight-cache +++ b/bin/freight-cache @@ -1,4 +1,5 @@ #!/usr/bin/env sh +# shellcheck disable=SC1090 # Rebuild the Freight cache from the Freight library. The cache contains # actual repositories that are suitable targets for `apt-get` (and maybe @@ -67,7 +68,7 @@ LIB="$(cd "$(dirname "$(dirname "$0")")/lib/freight" && pwd)" # If `GPG_PASSPHRASE_FILE` is set the specified file should exist and be # readable by the user running Freight. -[ -z "$GPG_PASSPHRASE_FILE" -o -r "$GPG_PASSPHRASE_FILE" ] || echo "# [freight] could not read passphrase file: $GPG_PASSPHRASE_FILE." >&2 +[ -z "$GPG_PASSPHRASE_FILE" ] || [ -r "$GPG_PASSPHRASE_FILE" ] || echo "# [freight] could not read passphrase file: $GPG_PASSPHRASE_FILE." >&2 # If `GPG_DIGEST_ALGO` is unset, force it to the freight default of SHA512 [ -z "$GPG_DIGEST_ALGO" ] && GPG_DIGEST_ALGO="SHA512" diff --git a/bin/freight-clear-cache b/bin/freight-clear-cache index 192b150..157ba83 100755 --- a/bin/freight-clear-cache +++ b/bin/freight-clear-cache @@ -1,4 +1,5 @@ #!/usr/bin/env sh +# shellcheck disable=SC1090 # Clear the cache that is built up during freight-cache runs # so that it can be regenerated on the next freight-cache invocation. diff --git a/bin/freight-init b/bin/freight-init index bf6297d..2abc527 100755 --- a/bin/freight-init +++ b/bin/freight-init @@ -69,7 +69,7 @@ do esac done DIRNAME="$(cd "${1:-"."}" && pwd)" -[ -z "$GPG" -o -z "$DIRNAME" ] && usage 1 +[ -z "$GPG" ] || [ -z "$DIRNAME" ] && usage 1 # The default value for VARLIB and VARCACHE lies within DIRNAME but otherwise # follows the FHS style. diff --git a/lib/freight/apt.sh b/lib/freight/apt.sh index 820c2bc..306e975 100644 --- a/lib/freight/apt.sh +++ b/lib/freight/apt.sh @@ -4,7 +4,7 @@ fi # Fetch the given field from the package's control file. apt_info() { - egrep -i "^$2:" "$1" | cut -d: -f2- | awk '{print $1}' + grep -E -i "^$2:" "$1" | cut -d: -f2- | awk '{print $1}' } # Print the package name from the given control file. @@ -99,7 +99,7 @@ apt_cache() { mkdir -p "$VARCACHE/pool/$DIST" # Work through every package that should be part of this distro. - while read PATHNAME + while read -r PATHNAME do # Extract the component, if present, from the package's pathname. @@ -188,7 +188,7 @@ EOF # In the future, `Sources` may find a place here, too. find "$DISTCACHE" -mindepth 2 -type f -printf %P\\n | grep -v ^\\. | - while read FILE + while read -r FILE do SIZE="$(apt_filesize "$DISTCACHE/$FILE")" echo " $(apt_md5 "$DISTCACHE/$FILE" ) $SIZE $FILE" >&3 @@ -231,6 +231,7 @@ EOF # `keyring.gpg` containing a complete GPG keyring containing only # the appropriate public keys. `keyring.gpg` is appropriate for # copying directly to `/etc/apt/trusted.gpg.d`. + # shellcheck disable=SC2174 mkdir -m700 -p "$TMP/gpg" # Create `pubring.gpg` to prevent gpg version >= 2.1 from using the # new `pubring.kbx` format during an initial `gpg --import`. @@ -395,7 +396,7 @@ apt_cache_source() { fi # Verify this package by ensuring the other necessary files are present. - [ -f "$VARLIB/apt/$DIST/$DIRNAME/$ORIG_FILENAME" -a -f "$VARLIB/apt/$DIST/$DIRNAME/$DIFF_FILENAME" -o -f "$VARLIB/apt/$DIST/$DIRNAME/$TAR_FILENAME" ] || { + [ -f "$VARLIB/apt/$DIST/$DIRNAME/$ORIG_FILENAME" ] && [ -f "$VARLIB/apt/$DIST/$DIRNAME/$DIFF_FILENAME" ] || [ -f "$VARLIB/apt/$DIST/$DIRNAME/$TAR_FILENAME" ] || { echo "# [freight] skipping invalid Debian source package $PATHNAME" >&2 return } @@ -424,7 +425,7 @@ apt_cache_source() { mkdir -p "$VARCACHE/$POOL" for FILENAME in "$DSC_FILENAME" "$ORIG_FILENAME" "$DIFF_FILENAME" "$TAR_FILENAME" do - if [ -f "$DISTCACHE/.refs/$COMP/$FILENAME" -a ! -f "$VARCACHE/$POOL/$FILENAME" ] + if [ -f "$DISTCACHE/.refs/$COMP/$FILENAME" ] && ! [ -f "$VARCACHE/$POOL/$FILENAME" ] then echo "# [freight] adding $FILENAME to pool" >&2 ln "$DISTCACHE/.refs/$COMP/$FILENAME" "$VARCACHE/$POOL" @@ -441,8 +442,8 @@ apt_cache_source() { fi if ! [ -e "$CONTROL" ]; then { - egrep "^[A-Z][^:]+: ." "$VARLIB/apt/$DIST/$PATHNAME" | - egrep -v "^(Version: GnuPG|Hash: )" | + grep -E "^[A-Z][^:]+: ." "$VARLIB/apt/$DIST/$PATHNAME" | + grep -E -v "^(Version: GnuPG|Hash: )" | sed "s/^Source:/Package:/" echo "Directory: DIRECTORY" echo "Files:" diff --git a/lib/freight/conf.sh b/lib/freight/conf.sh index a4681bc..9a987b5 100644 --- a/lib/freight/conf.sh +++ b/lib/freight/conf.sh @@ -1,3 +1,4 @@ +# shellcheck disable=SC1090,SC1091 # Freight configuration. # Default directories for the Freight library and Freight cache. Your @@ -41,7 +42,7 @@ do [ "$DIRNAME" = "/" ] && break DIRNAME="$(dirname "$DIRNAME")" done -[ "$FREIGHT_CONF" -a -f "$FREIGHT_CONF" ] && . "$FREIGHT_CONF" +[ "$FREIGHT_CONF" ] && [ -f "$FREIGHT_CONF" ] && . "$FREIGHT_CONF" if [ "$CONF" ] then if [ -f "$CONF" ] From ba9f37e204ba9018bcc5af82a3a6171ea0aa85f6 Mon Sep 17 00:00:00 2001 From: Michael Moll Date: Wed, 23 Aug 2017 13:29:23 +0200 Subject: [PATCH 54/72] calculate size correctly --- lib/freight/apt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/freight/apt.sh b/lib/freight/apt.sh index 306e975..f93512e 100644 --- a/lib/freight/apt.sh +++ b/lib/freight/apt.sh @@ -75,7 +75,7 @@ apt_sha512() { # Print the size of the given file. apt_filesize() { - stat -c%s "$1" + stat -c%s "$(readlink -f "$1")" } # Setup the repository for the distro named in the first argument, From 78949f8e2cc1d02c25cdf2d5fcda860c4357b985 Mon Sep 17 00:00:00 2001 From: Dancho Penev Date: Fri, 13 Jan 2017 21:23:47 +0200 Subject: [PATCH 55/72] Suppress link error messages. --- lib/freight/apt.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/freight/apt.sh b/lib/freight/apt.sh index f93512e..69b09fb 100644 --- a/lib/freight/apt.sh +++ b/lib/freight/apt.sh @@ -316,7 +316,7 @@ EOF # Link or copy this package into this distro's `.refs` directory. mkdir -p "$DISTCACHE/.refs/$COMP" - ln "$VARLIB/apt/$DIST/$PATHNAME" "$DISTCACHE/.refs/$COMP" || + ln "$VARLIB/apt/$DIST/$PATHNAME" "$DISTCACHE/.refs/$COMP" > /dev/null 2>&1 || cp "$VARLIB/apt/$DIST/$PATHNAME" "$DISTCACHE/.refs/$COMP" # Package properties. Remove the epoch from the version number @@ -413,7 +413,7 @@ apt_cache_source() { do [ -f "$VARLIB/apt/$DIST/$DIRNAME/$FILENAME" ] || continue [ -f "$DISTCACHE/.refs/$COMP/$FILENAME" ] || - ln "$VARLIB/apt/$DIST/$DIRNAME/$FILENAME" "$DISTCACHE/.refs/$COMP" || + ln "$VARLIB/apt/$DIST/$DIRNAME/$FILENAME" "$DISTCACHE/.refs/$COMP" > /dev/null 2>&1 || cp "$VARLIB/apt/$DIST/$DIRNAME/$FILENAME" "$DISTCACHE/.refs/$COMP" done From 32ce114e485afd0fc0893f40fda7704f7b20835b Mon Sep 17 00:00:00 2001 From: Michael Moll Date: Wed, 13 Sep 2017 13:56:43 +0200 Subject: [PATCH 56/72] adjust .travis.yml after Travis updates --- .travis.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index ce2242f..6a2aa68 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,10 @@ sudo: required -dist: trusty env: - SH=dash - SH=bash before_script: - - sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu/ trusty-backports restricted main universe" - sudo apt-get -y update - - sudo apt-get -y install shellcheck rng-tools + - sudo apt-get -y install rng-tools # see https://github.com/travis-ci/travis-ci/issues/1913#issuecomment-53972361 - sudo rm -f /dev/random - sudo mknod -m 0666 /dev/random c 1 9 From a1af28b910c5ced198a6d1cdbd2c7a405d0d6f65 Mon Sep 17 00:00:00 2001 From: Michael Moll Date: Wed, 13 Sep 2017 14:03:40 +0200 Subject: [PATCH 57/72] Travis does provide haveged now --- .travis.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6a2aa68..5700ce6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,14 +2,6 @@ sudo: required env: - SH=dash - SH=bash -before_script: - - sudo apt-get -y update - - sudo apt-get -y install rng-tools -# see https://github.com/travis-ci/travis-ci/issues/1913#issuecomment-53972361 - - sudo rm -f /dev/random - - sudo mknod -m 0666 /dev/random c 1 9 - - echo HRNGDEVICE=/dev/urandom | sudo tee /etc/default/rng-tools - - sudo /etc/init.d/rng-tools restart script: - find bin lib -type f | xargs shellcheck -s sh - make check From 2d967bca60a5f89b2c6fcf899a88ad1c27846c90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuli=20Sepp=C3=A4nen?= Date: Thu, 26 Oct 2017 19:08:22 +0300 Subject: [PATCH 58/72] Document caveats when using GnuPG 2.x closes GH-72 --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index aba846b..ccb53b4 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,12 @@ Build the cache of all the files needed to be accepted as a Debian archive: freight cache +If your system has GnuPG 2.x make sure that a gpg-agent is running and that you +have installed a pinentry package (e.g. pinentry-curses) that suits your needs. +You may also need to set GPG_TTY environment variable like this: + + export GPG_TTY=$(tty) + Serve `/var/cache/freight` via your favorite web server and install it as an APT source: echo "deb http://example.com $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/example.list From de3c87538261cdf0b56cdd91b6b15607f78c5a3e Mon Sep 17 00:00:00 2001 From: Michael Moll Date: Thu, 5 Apr 2018 02:14:01 +0200 Subject: [PATCH 59/72] refactor multikey signing test --- .gitignore | 1 + test/apt_cache.bats | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index f1e755f..214166a 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ *.orig.tar.gz *.tar.gz *~ +.idea/ etc/freight.conf var test/tmp diff --git a/test/apt_cache.bats b/test/apt_cache.bats index 8aa2ad5..7d41325 100644 --- a/test/apt_cache.bats +++ b/test/apt_cache.bats @@ -36,8 +36,10 @@ setup() { @test "freight-cache signs Release.gpg with two keys" { sed -i 's/^GPG=.*/GPG="freight@example.com freight2@example.com"/' $FREIGHT_CONFIG freight_cache -v - test $(grep -c BEGIN ${FREIGHT_CACHE}/dists/example/Release.gpg) -eq 2 - gpg --verify ${FREIGHT_CACHE}/dists/example/Release.gpg ${FREIGHT_CACHE}/dists/example/Release + + gpg --status-fd 1 --verify ${FREIGHT_CACHE}/dists/example/Release.gpg ${FREIGHT_CACHE}/dists/example/Release >/tmp/verify.out + run grep -c GOODSIG /tmp/verify.out + assert_output "2" } @test "freight-cache works without tty" { From 12060a336cb717e9251a9b0623c425441e25ccc8 Mon Sep 17 00:00:00 2001 From: Michael Moll Date: Thu, 5 Apr 2018 00:26:12 +0200 Subject: [PATCH 60/72] refactor signing of the Release file --- lib/freight/apt.sh | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/lib/freight/apt.sh b/lib/freight/apt.sh index 69b09fb..b575328 100644 --- a/lib/freight/apt.sh +++ b/lib/freight/apt.sh @@ -207,25 +207,26 @@ EOF } >"$DISTCACHE/Release" - # Sign the top-level `Release` file with `gpg`, for each key and - # concatenate signatures. + # compose one gpg parameter string with all GPG keys + USERKEYS="" for GPGKEY in $GPG; do - # shellcheck disable=SC2046 - gpg -abs$([ "$TTY" ] || echo " --no-tty") --use-agent -u"$GPGKEY" \ - $([ "$GPG_PASSPHRASE_FILE" ] && echo " --batch --passphrase-fd 1 --passphrase-file $GPG_PASSPHRASE_FILE") \ - $([ "$GPG_DIGEST_ALGO" ] && echo " --personal-digest-preferences $GPG_DIGEST_ALGO") \ - -o"$TMP/release_last_signature.gpg" "$DISTCACHE/Release" || { - cat <> "$DISTCACHE"/Release.gpg - rm -f "$TMP"/release_last_signature.gpg - done + rm -rf "$DISTCACHE" + exit 1 + } # Generate `pubkey.gpg` containing the plaintext public key and # `keyring.gpg` containing a complete GPG keyring containing only From 0a8c99a761e08e1aac8fd702338afe75f6d892a7 Mon Sep 17 00:00:00 2001 From: Michael Moll Date: Thu, 5 Apr 2018 02:34:59 +0200 Subject: [PATCH 61/72] create InRelease file closes GH-76 closes GH-77 --- lib/freight/apt.sh | 9 +++++++-- test/apt_cache.bats | 13 ++++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/lib/freight/apt.sh b/lib/freight/apt.sh index b575328..2b7214f 100644 --- a/lib/freight/apt.sh +++ b/lib/freight/apt.sh @@ -214,11 +214,16 @@ EOF done # Sign the top-level `Release` file with `gpg` - # shellcheck disable=SC2046 disable=SC2086 + # shellcheck disable=SC2046 disable=SC2086 disable=SC2015 gpg -abs$([ "$TTY" ] || echo " --no-tty") --use-agent ${USERKEYS} \ $([ "$GPG_PASSPHRASE_FILE" ] && echo " --batch --passphrase-fd 1 --passphrase-file $GPG_PASSPHRASE_FILE") \ $([ "$GPG_DIGEST_ALGO" ] && echo " --personal-digest-preferences $GPG_DIGEST_ALGO") \ - -o"$DISTCACHE/Release.gpg" "$DISTCACHE/Release" || { + -o"$DISTCACHE/Release.gpg" "$DISTCACHE/Release" && + # Create/Sign the top-level `InRelease` file with `gpg` + gpg --clearsign$([ "$TTY" ] || echo " --no-tty") --use-agent ${USERKEYS} \ + $([ "$GPG_PASSPHRASE_FILE" ] && echo " --batch --passphrase-fd 1 --passphrase-file $GPG_PASSPHRASE_FILE") \ + $([ "$GPG_DIGEST_ALGO" ] && echo " --personal-digest-preferences $GPG_DIGEST_ALGO") \ + -o"$DISTCACHE/InRelease" "$DISTCACHE/Release" || { cat </tmp/verify.out run grep -c GOODSIG /tmp/verify.out assert_output "2" + + gpg --status-fd 1 --verify ${FREIGHT_CACHE}/dists/example/InRelease >/tmp/verify.out + run grep -c GOODSIG /tmp/verify.out + assert_output "2" } @test "freight-cache works without tty" { From 105c1dc6e00f6a9c4fdbf611c8042024012dc2e6 Mon Sep 17 00:00:00 2001 From: Stanislaw Klekot Date: Thu, 20 Oct 2016 17:34:25 +0200 Subject: [PATCH 62/72] Unrecognized switches caused infinite loop in all the commands. --- bin/freight-add | 2 +- bin/freight-cache | 2 +- bin/freight-clear-cache | 2 +- bin/freight-init | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/freight-add b/bin/freight-add index 2698540..03b24b4 100755 --- a/bin/freight-add +++ b/bin/freight-add @@ -24,7 +24,7 @@ do -v|--verbose) VERBOSE=1 shift;; -e|--add-error) FREIGHT_ADD_ERROR="YES" shift;; -h|--help) usage 0;; - -*) echo "# [freight] unknown switch: $1" >&2;; + -*) echo "# [freight] unknown switch: $1" >&2; usage 1;; *) break;; esac done diff --git a/bin/freight-cache b/bin/freight-cache index 000898b..b5072f3 100755 --- a/bin/freight-cache +++ b/bin/freight-cache @@ -58,7 +58,7 @@ do --conf=*) CONF="$(echo "$1" | cut -c"8-")" shift;; -v|--verbose) VERBOSE=1 shift;; -h|--help) usage 0;; - -*) echo "# [freight] unknown switch: $1" >&2;; + -*) echo "# [freight] unknown switch: $1" >&2; usage 1;; *) break;; esac done diff --git a/bin/freight-clear-cache b/bin/freight-clear-cache index 157ba83..2aa9e5a 100755 --- a/bin/freight-clear-cache +++ b/bin/freight-clear-cache @@ -23,7 +23,7 @@ do --conf=*) CONF="$(echo "$1" | cut -c"8-")" shift;; -v|--verbose) VERBOSE=1 shift;; -h|--help) usage 0;; - -*) echo "# [freight] unknown switch: $1" >&2;; + -*) echo "# [freight] unknown switch: $1" >&2; usage 1;; *) break;; esac done diff --git a/bin/freight-init b/bin/freight-init index 2abc527..606e436 100755 --- a/bin/freight-init +++ b/bin/freight-init @@ -64,7 +64,7 @@ do --suite=*) SUITE="$(echo "$1" | cut -c"9-")" shift;; -v|--verbose) VERBOSE=1 shift;; -h|--help) usage 0;; - -*) echo "# [freight] unknown switch: $1" >&2;; + -*) echo "# [freight] unknown switch: $1" >&2; usage 1;; *) break;; esac done From 92dc0e2f43b751340ce6c7031f4e4612ed36c9fb Mon Sep 17 00:00:00 2001 From: Michael Moll Date: Tue, 10 Apr 2018 20:43:03 +0200 Subject: [PATCH 63/72] use shfmt and add it to travis --- .travis.yml | 2 + README.md | 8 ++- bin/freight-add | 59 ++++++++--------- bin/freight-cache | 61 +++++++++--------- bin/freight-clear-cache | 30 ++++----- bin/freight-init | 55 ++++++++-------- lib/freight/apt.sh | 139 +++++++++++++++++----------------------- lib/freight/conf.sh | 12 ++-- 8 files changed, 176 insertions(+), 190 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5700ce6..34b11be 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,8 @@ env: - SH=bash script: - find bin lib -type f | xargs shellcheck -s sh + - shfmt -i 4 -ci -p -l -s -w lib/ bin/ + - git diff --exit-code - make check notifications: irc: "chat.freenode.net#freight" diff --git a/README.md b/README.md index ccb53b4..6cd70f3 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ Serve `/var/cache/freight` via your favorite web server and install it as an APT ### From a Debian archive wget -O - https://swupdate.openvpn.net/repos/repo-public.gpg|sudo apt-key add - - echo "deb http://build.openvpn.net/debian/freight_team $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/freight.list + echo "deb http://build.openvpn.net/debian/freight_team $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/freight.list sudo apt-get update sudo apt-get -y install freight @@ -91,8 +91,12 @@ Freight is [BSD-licensed](https://github.com/freight-team/freight/blob/master/LI * Issue tracker: * Wiki: +### Static analysis and code style + +[Shellcheck](https://www.shellcheck.net/) and [shfmt](https://github.com/mvdan/sh) are used to ensure consistency, please see the Travis configuration for the actual tests. + ### Test suite -The Freight test suite can be executed by running `make check` from any git checkout of this repository. git and GnuPG are required for most tests, and extended tests require apt. +The Freight test suite can be executed by running `make check` from any git checkout of this repository. git and GnuPG are required for most tests, and extended tests require apt. Contributions should include a new test case where possible by extending one or more of the `test/*.bats` files. diff --git a/bin/freight-add b/bin/freight-add index 03b24b4..dd89828 100755 --- a/bin/freight-add +++ b/bin/freight-add @@ -15,17 +15,19 @@ usage() { grep "^#/" "$0" | cut -c"4-" >&2 exit "$1" } -while [ "$#" -gt 0 ] -do +while [ "$#" -gt 0 ]; do case "$1" in - -c|--conf) CONF="$2" shift 2;; - -c*) CONF="$(echo "$1" | cut -c"3-")" shift;; - --conf=*) CONF="$(echo "$1" | cut -c"8-")" shift;; - -v|--verbose) VERBOSE=1 shift;; - -e|--add-error) FREIGHT_ADD_ERROR="YES" shift;; - -h|--help) usage 0;; - -*) echo "# [freight] unknown switch: $1" >&2; usage 1;; - *) break;; + -c | --conf) CONF="$2" shift 2 ;; + -c*) CONF="$(echo "$1" | cut -c"3-")" shift ;; + --conf=*) CONF="$(echo "$1" | cut -c"8-")" shift ;; + -v | --verbose) VERBOSE=1 shift ;; + -e | --add-error) FREIGHT_ADD_ERROR="YES" shift ;; + -h | --help) usage 0 ;; + -*) + echo "# [freight] unknown switch: $1" >&2 + usage 1 + ;; + *) break ;; esac done @@ -35,14 +37,14 @@ done # Binary packages have only one but source packages require two or three. # When the last of these is found, the remaining arguments are each assumed # to be `/` pairs for this (source) package. -while [ "$#" -gt 0 ] -do +while [ "$#" -gt 0 ]; do case "$1" in - *.deb|*.dsc|*.orig.tar.gz|*.orig.tar.bz2|*.orig.tar.xz|*.orig.tar.lzma|*.diff.gz|*.debian.tar.gz|*.debian.tar.bz2|*.debian.tar.xz|*.debian.tar.lzma|*.tar.gz|*.tar.bz2|*.tar.xz|*.tar.lzma) + *.deb | *.dsc | *.orig.tar.gz | *.orig.tar.bz2 | *.orig.tar.xz | *.orig.tar.lzma | *.diff.gz | *.debian.tar.gz | *.debian.tar.bz2 | *.debian.tar.xz | *.debian.tar.lzma | *.tar.gz | *.tar.bz2 | *.tar.xz | *.tar.lzma) # shellcheck disable=SC2153 - PATHNAMES="$PATHNAMES $1" shift;; - *.build|*.changes) shift;; - *) break;; + PATHNAMES="$PATHNAMES $1" shift + ;; + *.build | *.changes) shift ;; + *) break ;; esac done [ -z "$PATHNAMES" ] && usage 1 @@ -55,8 +57,7 @@ mkdir -p "$VARLIB" TMP="$(mktemp -d "$VARLIB/freight.$$.XXXXXXXXXX")" # shellcheck disable=SC2064 trap "rm -rf \"$TMP\"" EXIT INT TERM -for PATHNAME in $PATHNAMES -do +for PATHNAME in $PATHNAMES; do cp "$PATHNAME" "$TMP/" done @@ -69,15 +70,12 @@ cd "$VARLIB" # PATHNAME. The first two are given fairly directly to ln(1); the final one # is used to create appropriate success or failure messages. add() { - if ln "$TMP/$1" "$2/$1" 2>"$TMP/ln" - then echo "# [freight] added $3 to $2${4+" as "}$4" >&2 + if ln "$TMP/$1" "$2/$1" 2>"$TMP/ln"; then echo "# [freight] added $3 to $2${4+" as "}$4" >&2 else - if grep -q "File exists" "$TMP/ln" - then echo "# [freight] $2 already has $3${4+" as "}$4" >&2 + if grep -q "File exists" "$TMP/ln"; then echo "# [freight] $2 already has $3${4+" as "}$4" >&2 else cat "$TMP/ln" >&2 fi - if [ -n "$FREIGHT_ADD_ERROR" ] - then exit 2 + if [ -n "$FREIGHT_ADD_ERROR" ]; then exit 2 fi fi } @@ -85,14 +83,12 @@ add() { # Hard link this package into every `/` given in `$@`. # These links will later be used to compile the `Release` and `Packages` # files in the Freight cache. -for PATHNAME in $PATHNAMES -do +for PATHNAME in $PATHNAMES; do FILENAME="$(basename "$PATHNAME")" - for DIRNAME in "$@" - do + for DIRNAME in "$@"; do mkdir -p "$DIRNAME" case "$FILENAME" in - *_*_*.deb) add "$FILENAME" "$DIRNAME" "$PATHNAME";; + *_*_*.deb) add "$FILENAME" "$DIRNAME" "$PATHNAME" ;; *.deb) . "$(dirname "$(dirname "$0")")/lib/freight/apt.sh" dpkg-deb -I "$TMP/$FILENAME" "control" >"$TMP/$FILENAME-control" @@ -103,8 +99,9 @@ do )_$( apt_binary_arch "$TMP/$FILENAME-control" ).deb" - add "$FILENAME" "$DIRNAME" "$PATHNAME" "$DEBNAME";; - *) add "$FILENAME" "$DIRNAME" "$PATHNAME";; + add "$FILENAME" "$DIRNAME" "$PATHNAME" "$DEBNAME" + ;; + *) add "$FILENAME" "$DIRNAME" "$PATHNAME" ;; esac done done diff --git a/bin/freight-cache b/bin/freight-cache index b5072f3..f1d78a6 100755 --- a/bin/freight-cache +++ b/bin/freight-cache @@ -8,7 +8,7 @@ #/ Usage: freight cache [-k] [-g ] [-p ] [-a ] [-c ] [-v] [-h] [/][...] #/ -k, --keep keep unreferenced versions of packages #/ -g , --gpg= GPG key to use, may be given multiple times -#/ -p , +#/ -p , #/ --passphrase-file= path to file containing the passphrase of the GPG key #/ -a , #/ --digest-algo= digest algorithm that GPG should use, e.g SHA512 @@ -22,44 +22,49 @@ usage() { grep "^#/" "$0" | cut -c"4-" >&2 exit "$1" } -while [ "$#" -gt 0 ] -do +while [ "$#" -gt 0 ]; do case "$1" in - -k|--keep) KEEP=1 shift;; - -g|--gpg) + -k | --keep) KEEP=1 shift ;; + -g | --gpg) if [ -z "$GPG" ]; then GPG=$2 else GPG="$GPG $2" fi - shift 2;; + shift 2 + ;; -g*) if [ -z "$GPG" ]; then GPG=$(echo "$1" | cut -c"3-") else GPG="$GPG $(echo "$1" | cut -c"3-")" fi - shift;; + shift + ;; --gpg=*) if [ -z "$GPG" ]; then GPG=$(echo "$1" | cut -c"7-") else GPG="$GPG $(echo "$1" | cut -c"7-")" fi - shift;; - -p|--passphrase-file) GPG_PASSPHRASE_FILE="$2" shift 2;; - -p*) GPG_PASSPHRASE_FILE="$(echo "$1" | cut -c"3-")" shift;; - --passphrase-file=*) GPG_PASSPHRASE_FILE="$(echo "$1" | cut -c"19-")" shift;; - -a|--digest-algo) GPG_DIGEST_ALGO="$2" shift 2;; - -a*) GPG_DIGEST_ALGO="$(echo "$1" | cut -c"3-")" shift;; - --digest-algo=*) GPG_DIGEST_ALGO="$(echo "$1" | cut -c"15-")" shift;; - -c|--conf) CONF="$2" shift 2;; - -c*) CONF="$(echo "$1" | cut -c"3-")" shift;; - --conf=*) CONF="$(echo "$1" | cut -c"8-")" shift;; - -v|--verbose) VERBOSE=1 shift;; - -h|--help) usage 0;; - -*) echo "# [freight] unknown switch: $1" >&2; usage 1;; - *) break;; + shift + ;; + -p | --passphrase-file) GPG_PASSPHRASE_FILE="$2" shift 2 ;; + -p*) GPG_PASSPHRASE_FILE="$(echo "$1" | cut -c"3-")" shift ;; + --passphrase-file=*) GPG_PASSPHRASE_FILE="$(echo "$1" | cut -c"19-")" shift ;; + -a | --digest-algo) GPG_DIGEST_ALGO="$2" shift 2 ;; + -a*) GPG_DIGEST_ALGO="$(echo "$1" | cut -c"3-")" shift ;; + --digest-algo=*) GPG_DIGEST_ALGO="$(echo "$1" | cut -c"15-")" shift ;; + -c | --conf) CONF="$2" shift 2 ;; + -c*) CONF="$(echo "$1" | cut -c"3-")" shift ;; + --conf=*) CONF="$(echo "$1" | cut -c"8-")" shift ;; + -v | --verbose) VERBOSE=1 shift ;; + -h | --help) usage 0 ;; + -*) + echo "# [freight] unknown switch: $1" >&2 + usage 1 + ;; + *) break ;; esac done @@ -86,18 +91,16 @@ mkdir -p "$VARLIB" cd "$VARLIB" # Rebuild each distro serially. -if [ -z "$*" ] -then +if [ -z "$*" ]; then DIRS="$( find "$VARLIB"/ -mindepth 2 -maxdepth 2 -type d -printf "%P\n" | - grep -v "^\\." | - tr "\n" " " + grep -v '^\.' | + tr "\n" " " )" else DIRS=$* fi -for DIR in $DIRS -do +for DIR in $DIRS; do # Parse the manager and distro out of the Freight library path. DIR="$(readlink -f "$DIR")" @@ -115,8 +118,8 @@ do . "$LIB/$MANAGER.sh" SORT="$(sort -V <"/dev/null" 2>"/dev/null" && echo "sort -V" || echo "sort")" find $FIND_L "$DIR" -type "f" -printf "%P\n" 2>"/dev/null" | - eval "$SORT" | - eval "${MANAGER}_cache" "$DIST" + eval "$SORT" | + eval "${MANAGER}_cache" "$DIST" # Clean up old packages as dictated by the manager. if [ -z "$KEEP" ]; then diff --git a/bin/freight-clear-cache b/bin/freight-clear-cache index 2aa9e5a..96a9190 100755 --- a/bin/freight-clear-cache +++ b/bin/freight-clear-cache @@ -15,16 +15,18 @@ usage() { grep "^#/" "$0" | cut -c"4-" >&2 exit "$1" } -while [ "$#" -gt 0 ] -do +while [ "$#" -gt 0 ]; do case "$1" in - -c|--conf) CONF="$2" shift 2;; - -c*) CONF="$(echo "$1" | cut -c"3-")" shift;; - --conf=*) CONF="$(echo "$1" | cut -c"8-")" shift;; - -v|--verbose) VERBOSE=1 shift;; - -h|--help) usage 0;; - -*) echo "# [freight] unknown switch: $1" >&2; usage 1;; - *) break;; + -c | --conf) CONF="$2" shift 2 ;; + -c*) CONF="$(echo "$1" | cut -c"3-")" shift ;; + --conf=*) CONF="$(echo "$1" | cut -c"8-")" shift ;; + -v | --verbose) VERBOSE=1 shift ;; + -h | --help) usage 0 ;; + -*) + echo "# [freight] unknown switch: $1" >&2 + usage 1 + ;; + *) break ;; esac done @@ -43,18 +45,16 @@ mkdir -p "$VARLIB" cd "$VARLIB" # Rebuild each distro serially. -if [ -z "$*" ] -then +if [ -z "$*" ]; then DIRS="$( find "$VARLIB" -mindepth 2 -maxdepth 2 -type d -printf "%P\n" | - grep -v "^\\." | - tr "\n" " " + grep -v '^\.' | + tr "\n" " " )" else DIRS=$* fi -for DIR in $DIRS -do +for DIR in $DIRS; do # Parse the manager and distro out of the Freight library path. DIR="$(readlink -f "$DIR")" diff --git a/bin/freight-init b/bin/freight-init index 606e436..867d74e 100755 --- a/bin/freight-init +++ b/bin/freight-init @@ -23,49 +23,54 @@ usage() { grep "^#/" "$0" | cut -c"4-" >&2 exit "$1" } -while [ "$#" -gt 0 ] -do +while [ "$#" -gt 0 ]; do case "$1" in - -g|--gpg) + -g | --gpg) if [ -z "$GPG" ]; then GPG=$2 else GPG="$GPG $2" fi - shift 2;; + shift 2 + ;; -g*) if [ -z "$GPG" ]; then GPG=$(echo "$1" | cut -c"3-") else GPG="$GPG $(echo "$1" | cut -c"3-")" fi - shift;; + shift + ;; --gpg=*) if [ -z "$GPG" ]; then GPG=$(echo "$1" | cut -c"7-") else GPG="$GPG $(echo "$1" | cut -c"7-")" fi - shift;; - -c|--conf) CONF="$2" shift 2;; - -c*) CONF="$(echo "$1" | cut -c"3-")" shift;; - --conf=*) CONF="$(echo "$1" | cut -c"8-")" shift;; - --libdir) VARLIB="$2" shift 2;; - --libdir=*) VARLIB="$(echo "$1" | cut -c"10-")" shift;; - --cachedir) VARCACHE="$2" shift 2;; - --cachedir=*) VARCACHE="$(echo "$1" | cut -c"12-")" shift;; - --archs) ARCHS="$2" shift 2;; - --archs=*) ARCHS="$(echo "$1" | cut -c"9-")" shift;; - --origin) ORIGIN="$2" shift 2;; - --origin=*) ORIGIN="$(echo "$1" | cut -c"10-")" shift;; - --label) LABEL="$2" shift 2;; - --label=*) LABEL="$(echo "$1" | cut -c"9-")" shift;; - --suite) SUITE="$2" shift 2;; - --suite=*) SUITE="$(echo "$1" | cut -c"9-")" shift;; - -v|--verbose) VERBOSE=1 shift;; - -h|--help) usage 0;; - -*) echo "# [freight] unknown switch: $1" >&2; usage 1;; - *) break;; + shift + ;; + -c | --conf) CONF="$2" shift 2 ;; + -c*) CONF="$(echo "$1" | cut -c"3-")" shift ;; + --conf=*) CONF="$(echo "$1" | cut -c"8-")" shift ;; + --libdir) VARLIB="$2" shift 2 ;; + --libdir=*) VARLIB="$(echo "$1" | cut -c"10-")" shift ;; + --cachedir) VARCACHE="$2" shift 2 ;; + --cachedir=*) VARCACHE="$(echo "$1" | cut -c"12-")" shift ;; + --archs) ARCHS="$2" shift 2 ;; + --archs=*) ARCHS="$(echo "$1" | cut -c"9-")" shift ;; + --origin) ORIGIN="$2" shift 2 ;; + --origin=*) ORIGIN="$(echo "$1" | cut -c"10-")" shift ;; + --label) LABEL="$2" shift 2 ;; + --label=*) LABEL="$(echo "$1" | cut -c"9-")" shift ;; + --suite) SUITE="$2" shift 2 ;; + --suite=*) SUITE="$(echo "$1" | cut -c"9-")" shift ;; + -v | --verbose) VERBOSE=1 shift ;; + -h | --help) usage 0 ;; + -*) + echo "# [freight] unknown switch: $1" >&2 + usage 1 + ;; + *) break ;; esac done DIRNAME="$(cd "${1:-"."}" && pwd)" diff --git a/lib/freight/apt.sh b/lib/freight/apt.sh index 2b7214f..b5fd9ab 100644 --- a/lib/freight/apt.sh +++ b/lib/freight/apt.sh @@ -1,5 +1,5 @@ if tty -s; then - TTY="1" + TTY="1" fi # Fetch the given field from the package's control file. @@ -99,40 +99,36 @@ apt_cache() { mkdir -p "$VARCACHE/pool/$DIST" # Work through every package that should be part of this distro. - while read -r PATHNAME - do + while read -r PATHNAME; do # Extract the component, if present, from the package's pathname. case "$PATHNAME" in - */*) COMP="${PATHNAME%%/*}" PACKAGE="${PATHNAME##*/}";; - *) COMP="main" PACKAGE="$PATHNAME";; + */*) COMP="${PATHNAME%%/*}" PACKAGE="${PATHNAME##*/}" ;; + *) COMP="main" PACKAGE="$PATHNAME" ;; esac case "$PATHNAME" in # Binary packages. - *.deb) apt_cache_binary "$DIST" "$DISTCACHE" "$PATHNAME" "$COMP" "$PACKAGE";; + *.deb) apt_cache_binary "$DIST" "$DISTCACHE" "$PATHNAME" "$COMP" "$PACKAGE" ;; # Source packages. The *.dsc file is considered the "entrypoint" # and will find the associated *.orig.tar.gz, *.diff.gz, and/or # *.tar.gz as they are needed. - *.dsc) apt_cache_source "$DIST" "$DISTCACHE" "$PATHNAME" "$COMP" "$PACKAGE";; - *.debian.tar.gz|*.debian.tar.bz2|*.debian.tar.xz|*.debian.tar.lzma|*.diff.gz|*.orig.tar.gz|*.orig.tar.bz2|*.orig.tar.xz|*.orig.tar.lzma|*.tar.gz|*.tar.bz2|*.tar.xz|*.tar.lzma|*.deb-control|*.dsc-cached) ;; + *.dsc) apt_cache_source "$DIST" "$DISTCACHE" "$PATHNAME" "$COMP" "$PACKAGE" ;; + *.debian.tar.gz | *.debian.tar.bz2 | *.debian.tar.xz | *.debian.tar.lzma | *.diff.gz | *.orig.tar.gz | *.orig.tar.bz2 | *.orig.tar.xz | *.orig.tar.lzma | *.tar.gz | *.tar.bz2 | *.tar.xz | *.tar.lzma | *.deb-control | *.dsc-cached) ;; - *) echo "# [freight] skipping extraneous file $PATHNAME" >&2;; + *) echo "# [freight] skipping extraneous file $PATHNAME" >&2 ;; esac done COMPS="$(ls "$DISTCACHE")" # Build a `Release` file for each component and architecture. `gzip` # the `Packages` file, too. - for COMP in $COMPS - do + for COMP in $COMPS; do # shellcheck disable=SC2153 - for ARCH in $ARCHS - do - if [ -d "$DISTCACHE/$COMP/binary-$ARCH" ] - then + for ARCH in $ARCHS; do + if [ -d "$DISTCACHE/$COMP/binary-$ARCH" ]; then cat >"$DISTCACHE/$COMP/binary-$ARCH/Release" <"$DISTCACHE/$COMP/binary-$ARCH/Packages.gz" fi done - if [ -d "$DISTCACHE/$COMP/source" ] - then + if [ -d "$DISTCACHE/$COMP/source" ]; then cat >"$DISTCACHE/$COMP/source/Release" <&3 - echo " $(apt_sha1 "$DISTCACHE/$FILE" ) $SIZE $FILE" >&4 - echo " $(apt_sha256 "$DISTCACHE/$FILE" ) $SIZE $FILE" >&5 - echo " $(apt_sha512 "$DISTCACHE/$FILE" ) $SIZE $FILE" >&6 - done 3>"$TMP/md5sums" 4>"$TMP/sha1sums" 5>"$TMP/sha256sums" 6>"$TMP/sha512sums" + grep -v ^\\. | + while read -r FILE; do + SIZE="$(apt_filesize "$DISTCACHE/$FILE")" + echo " $(apt_md5 "$DISTCACHE/$FILE") $SIZE $FILE" >&3 + echo " $(apt_sha1 "$DISTCACHE/$FILE") $SIZE $FILE" >&4 + echo " $(apt_sha256 "$DISTCACHE/$FILE") $SIZE $FILE" >&5 + echo " $(apt_sha512 "$DISTCACHE/$FILE") $SIZE $FILE" >&6 + done 3>"$TMP/md5sums" 4>"$TMP/sha1sums" 5>"$TMP/sha256sums" 6>"$TMP/sha512sums" echo "MD5Sum:" cat "$TMP/md5sums" echo "SHA1:" @@ -219,11 +213,11 @@ EOF $([ "$GPG_PASSPHRASE_FILE" ] && echo " --batch --passphrase-fd 1 --passphrase-file $GPG_PASSPHRASE_FILE") \ $([ "$GPG_DIGEST_ALGO" ] && echo " --personal-digest-preferences $GPG_DIGEST_ALGO") \ -o"$DISTCACHE/Release.gpg" "$DISTCACHE/Release" && - # Create/Sign the top-level `InRelease` file with `gpg` - gpg --clearsign$([ "$TTY" ] || echo " --no-tty") --use-agent ${USERKEYS} \ - $([ "$GPG_PASSPHRASE_FILE" ] && echo " --batch --passphrase-fd 1 --passphrase-file $GPG_PASSPHRASE_FILE") \ - $([ "$GPG_DIGEST_ALGO" ] && echo " --personal-digest-preferences $GPG_DIGEST_ALGO") \ - -o"$DISTCACHE/InRelease" "$DISTCACHE/Release" || { + # Create/Sign the top-level `InRelease` file with `gpg` + gpg --clearsign$([ "$TTY" ] || echo " --no-tty") --use-agent ${USERKEYS} \ + $([ "$GPG_PASSPHRASE_FILE" ] && echo " --batch --passphrase-fd 1 --passphrase-file $GPG_PASSPHRASE_FILE") \ + $([ "$GPG_DIGEST_ALGO" ] && echo " --personal-digest-preferences $GPG_DIGEST_ALGO") \ + -o"$DISTCACHE/InRelease" "$DISTCACHE/Release" || { cat <= 2.1 from using the # new `pubring.kbx` format during an initial `gpg --import`. - : > "$TMP/gpg/pubring.gpg" && chmod 644 "$TMP/gpg/pubring.gpg" + : >"$TMP/gpg/pubring.gpg" && chmod 644 "$TMP/gpg/pubring.gpg" # shellcheck disable=SC2086 gpg -q --export -a $GPG | - tee "$VARCACHE/pubkey.gpg" | - gpg -q --homedir "$TMP/gpg" --import + tee "$VARCACHE/pubkey.gpg" | + gpg -q --homedir "$TMP/gpg" --import mv "$TMP/gpg/pubring.gpg" "$VARCACHE/keyring.gpg" # Move the symbolic link for this distro to this build. @@ -284,8 +278,8 @@ apt_cache_binary() { fi # If caching is off or if the binary has changed size, this will generate the # binary control file - if ! ( [ -e "$CONTROL" ] && \ - [ "$(apt_binary_filesize "$CONTROL")" -eq "$(apt_filesize "$VARLIB/apt/$DIST/$PATHNAME")" ] ); then + if ! ([ -e "$CONTROL" ] && + [ "$(apt_binary_filesize "$CONTROL")" -eq "$(apt_filesize "$VARLIB/apt/$DIST/$PATHNAME")" ]); then dpkg-deb -e "$VARLIB/apt/$DIST/$PATHNAME" "$TMP/DEBIAN" || { echo "# [freight] skipping invalid Debian package $PATHNAME" >&2 return @@ -298,8 +292,8 @@ apt_cache_binary() { # easily later with the real path. Strip out empty control fields # as these might cause problems. grep . "$TMP/DEBIAN/control" | - grep -E -v "^[A-Za-z-]+:\s+$" | - grep -v "^(Essential|Filename|MD5Sum|SHA1|SHA256|SHA512|Size)" + grep -E -v "^[A-Za-z-]+:\s+$" | + grep -v "^(Essential|Filename|MD5Sum|SHA1|SHA256|SHA512|Size)" cat < "$CONTROL" + echo + } >"$CONTROL" fi # Create all architecture-specific directories. This will allow # packages marked `all` to actually be placed in all architectures. - for ARCH in $ARCHS - do + for ARCH in $ARCHS; do mkdir -p "$DISTCACHE/$COMP/binary-$ARCH" touch "$DISTCACHE/$COMP/binary-$ARCH/Packages" done # Link or copy this package into this distro's `.refs` directory. mkdir -p "$DISTCACHE/.refs/$COMP" - ln "$VARLIB/apt/$DIST/$PATHNAME" "$DISTCACHE/.refs/$COMP" > /dev/null 2>&1 || - cp "$VARLIB/apt/$DIST/$PATHNAME" "$DISTCACHE/.refs/$COMP" + ln "$VARLIB/apt/$DIST/$PATHNAME" "$DISTCACHE/.refs/$COMP" >/dev/null 2>&1 || + cp "$VARLIB/apt/$DIST/$PATHNAME" "$DISTCACHE/.refs/$COMP" # Package properties. Remove the epoch from the version number # in the package filename, as is customary. @@ -337,10 +330,8 @@ EOF # Link this package into the pool. POOL="pool/$DIST/$COMP/$PREFIX/$SOURCE" mkdir -p "$VARCACHE/$POOL" - if [ ! -f "$VARCACHE/$POOL/$FILENAME" ] - then - if [ "$PACKAGE" != "$FILENAME" ] - then echo "# [freight] adding $PACKAGE to pool (as $FILENAME)" >&2 + if [ ! -f "$VARCACHE/$POOL/$FILENAME" ]; then + if [ "$PACKAGE" != "$FILENAME" ]; then echo "# [freight] adding $PACKAGE to pool (as $FILENAME)" >&2 else echo "# [freight] adding $PACKAGE to pool" >&2 fi ln "$DISTCACHE/.refs/$COMP/$PACKAGE" "$VARCACHE/$POOL/$FILENAME" @@ -348,8 +339,7 @@ EOF # Build a list of the one-or-more `Packages` files to append with # this package's info. - if [ "$ARCH" = "all" ] - then FILES="$(find "$DISTCACHE/$COMP" -type f -name "Packages")" + if [ "$ARCH" = "all" ]; then FILES="$(find "$DISTCACHE/$COMP" -type f -name "Packages")" else FILES="$DISTCACHE/$COMP/binary-$ARCH/Packages" fi @@ -357,7 +347,7 @@ EOF # package, starting with `pool/`. # shellcheck disable=SC2086 sed "s,^Filename: FILENAME$,Filename: $POOL/$FILENAME,g" "$CONTROL" | - tee -a $FILES >/dev/null + tee -a $FILES >/dev/null # Cleanup the extracted package if [ -d "$TMP/DEBIAN" ]; then @@ -390,14 +380,10 @@ apt_cache_source() { TAR_FILENAME="${NAME}_${VERSION%*:}.tar.gz" # Find which style of diff they're using. - if [ -f "$VARLIB/apt/$DIST/$DIRNAME/$DEBTAR_GZ_FILENAME" ] - then DIFF_FILENAME=${DEBTAR_GZ_FILENAME} - elif [ -f "$VARLIB/apt/$DIST/$DIRNAME/$DEBTAR_BZ2_FILENAME" ] - then DIFF_FILENAME=${DEBTAR_BZ2_FILENAME} - elif [ -f "$VARLIB/apt/$DIST/$DIRNAME/$DEBTAR_XZ_FILENAME" ] - then DIFF_FILENAME=${DEBTAR_XZ_FILENAME} - elif [ -f "$VARLIB/apt/$DIST/$DIRNAME/$DEBTAR_LZMA_FILENAME" ] - then DIFF_FILENAME=${DEBTAR_LZMA_FILENAME} + if [ -f "$VARLIB/apt/$DIST/$DIRNAME/$DEBTAR_GZ_FILENAME" ]; then DIFF_FILENAME=${DEBTAR_GZ_FILENAME} + elif [ -f "$VARLIB/apt/$DIST/$DIRNAME/$DEBTAR_BZ2_FILENAME" ]; then DIFF_FILENAME=${DEBTAR_BZ2_FILENAME} + elif [ -f "$VARLIB/apt/$DIST/$DIRNAME/$DEBTAR_XZ_FILENAME" ]; then DIFF_FILENAME=${DEBTAR_XZ_FILENAME} + elif [ -f "$VARLIB/apt/$DIST/$DIRNAME/$DEBTAR_LZMA_FILENAME" ]; then DIFF_FILENAME=${DEBTAR_LZMA_FILENAME} else DIFF_FILENAME=${DIFFGZ_FILENAME} fi @@ -415,12 +401,11 @@ apt_cache_source() { # if it isn't already there (which can happen when two packages derive # from the same original tarball). mkdir -p "$DISTCACHE/.refs/$COMP" - for FILENAME in "$DSC_FILENAME" "$ORIG_FILENAME" "$DIFF_FILENAME" "$TAR_FILENAME" - do + for FILENAME in "$DSC_FILENAME" "$ORIG_FILENAME" "$DIFF_FILENAME" "$TAR_FILENAME"; do [ -f "$VARLIB/apt/$DIST/$DIRNAME/$FILENAME" ] || continue [ -f "$DISTCACHE/.refs/$COMP/$FILENAME" ] || - ln "$VARLIB/apt/$DIST/$DIRNAME/$FILENAME" "$DISTCACHE/.refs/$COMP" > /dev/null 2>&1 || - cp "$VARLIB/apt/$DIST/$DIRNAME/$FILENAME" "$DISTCACHE/.refs/$COMP" + ln "$VARLIB/apt/$DIST/$DIRNAME/$FILENAME" "$DISTCACHE/.refs/$COMP" >/dev/null 2>&1 || + cp "$VARLIB/apt/$DIST/$DIRNAME/$FILENAME" "$DISTCACHE/.refs/$COMP" done # Package properties. Remove the epoch from the version number @@ -429,10 +414,8 @@ apt_cache_source() { # Link this source package into the pool. POOL="pool/$DIST/$COMP/$(apt_prefix "$NAME")/$NAME" mkdir -p "$VARCACHE/$POOL" - for FILENAME in "$DSC_FILENAME" "$ORIG_FILENAME" "$DIFF_FILENAME" "$TAR_FILENAME" - do - if [ -f "$DISTCACHE/.refs/$COMP/$FILENAME" ] && ! [ -f "$VARCACHE/$POOL/$FILENAME" ] - then + for FILENAME in "$DSC_FILENAME" "$ORIG_FILENAME" "$DIFF_FILENAME" "$TAR_FILENAME"; do + if [ -f "$DISTCACHE/.refs/$COMP/$FILENAME" ] && ! [ -f "$VARCACHE/$POOL/$FILENAME" ]; then echo "# [freight] adding $FILENAME to pool" >&2 ln "$DISTCACHE/.refs/$COMP/$FILENAME" "$VARCACHE/$POOL" fi @@ -449,49 +432,45 @@ apt_cache_source() { if ! [ -e "$CONTROL" ]; then { grep -E "^[A-Z][^:]+: ." "$VARLIB/apt/$DIST/$PATHNAME" | - grep -E -v "^(Version: GnuPG|Hash: )" | - sed "s/^Source:/Package:/" + grep -E -v "^(Version: GnuPG|Hash: )" | + sed "s/^Source:/Package:/" echo "Directory: DIRECTORY" echo "Files:" - for FILENAME in "$DSC_FILENAME" "$ORIG_FILENAME" "$DIFF_FILENAME" "$TAR_FILENAME" - do + for FILENAME in "$DSC_FILENAME" "$ORIG_FILENAME" "$DIFF_FILENAME" "$TAR_FILENAME"; do [ -f "$VARCACHE/$POOL/$FILENAME" ] || continue SIZE="$(apt_filesize "$VARCACHE/$POOL/$FILENAME")" MD5="$(apt_md5 "$VARCACHE/$POOL/$FILENAME")" echo " $MD5 $SIZE $FILENAME" done echo "Checksums-Sha1:" - for FILENAME in "$DSC_FILENAME" "$ORIG_FILENAME" "$DIFF_FILENAME" "$TAR_FILENAME" - do + for FILENAME in "$DSC_FILENAME" "$ORIG_FILENAME" "$DIFF_FILENAME" "$TAR_FILENAME"; do [ -f "$VARCACHE/$POOL/$FILENAME" ] || continue SIZE="$(apt_filesize "$VARCACHE/$POOL/$FILENAME")" SHA1="$(apt_sha1 "$VARCACHE/$POOL/$FILENAME")" echo " $SHA1 $SIZE $FILENAME" done echo "Checksums-Sha256:" - for FILENAME in "$DSC_FILENAME" "$ORIG_FILENAME" "$DIFF_FILENAME" "$TAR_FILENAME" - do + for FILENAME in "$DSC_FILENAME" "$ORIG_FILENAME" "$DIFF_FILENAME" "$TAR_FILENAME"; do [ -f "$VARCACHE/$POOL/$FILENAME" ] || continue SIZE="$(apt_filesize "$VARCACHE/$POOL/$FILENAME")" SHA256="$(apt_sha256 "$VARCACHE/$POOL/$FILENAME")" echo " $SHA256 $SIZE $FILENAME" done echo "Checksums-Sha512:" - for FILENAME in "$DSC_FILENAME" "$ORIG_FILENAME" "$DIFF_FILENAME" "$TAR_FILENAME" - do + for FILENAME in "$DSC_FILENAME" "$ORIG_FILENAME" "$DIFF_FILENAME" "$TAR_FILENAME"; do [ -f "$VARCACHE/$POOL/$FILENAME" ] || continue SIZE="$(apt_filesize "$VARCACHE/$POOL/$FILENAME")" SHA512="$(apt_sha512 "$VARCACHE/$POOL/$FILENAME")" echo " $SHA512 $SIZE $FILENAME" done echo - } > "$CONTROL" + } >"$CONTROL" fi sed "s,^Directory: DIRECTORY$,Directory: $POOL,g" "$CONTROL" | - tee -a "$DISTCACHE/$COMP/source/Sources" >/dev/null + tee -a "$DISTCACHE/$COMP/source/Sources" >/dev/null -# Clean up the tmp space + # Clean up the tmp space if [ -f "$TMP/source-control" ]; then rm "$TMP/source-control" fi diff --git a/lib/freight/conf.sh b/lib/freight/conf.sh index 9a987b5..07bdaaa 100644 --- a/lib/freight/conf.sh +++ b/lib/freight/conf.sh @@ -29,24 +29,20 @@ SYMLINKS="off" # Source all existing configuration files from lowest- to highest-priority. PREFIX="$(dirname "$(dirname "$0")")" -if [ "$PREFIX" = "/usr" ] -then [ -f "/etc/freight.conf" ] && . "/etc/freight.conf" +if [ "$PREFIX" = "/usr" ]; then [ -f "/etc/freight.conf" ] && . "/etc/freight.conf" else [ -f "$PREFIX/etc/freight.conf" ] && . "$PREFIX/etc/freight.conf" fi [ -f "$HOME/.freight.conf" ] && . "$HOME/.freight.conf" DIRNAME="$PWD" -while true -do +while true; do [ -f "$DIRNAME/etc/freight.conf" ] && . "$DIRNAME/etc/freight.conf" && break [ -f "$DIRNAME/.freight.conf" ] && . "$DIRNAME/.freight.conf" && break [ "$DIRNAME" = "/" ] && break DIRNAME="$(dirname "$DIRNAME")" done [ "$FREIGHT_CONF" ] && [ -f "$FREIGHT_CONF" ] && . "$FREIGHT_CONF" -if [ "$CONF" ] -then - if [ -f "$CONF" ] - then . "$CONF" +if [ "$CONF" ]; then + if [ -f "$CONF" ]; then . "$CONF" else echo "# [freight] $CONF does not exist" >&2 exit 1 From 60b526343479b4bdc7bb56bd0029fae5cc9efbd3 Mon Sep 17 00:00:00 2001 From: Hiroaki Nakamura Date: Thu, 26 Apr 2018 14:43:28 +0900 Subject: [PATCH 64/72] Support gpg2 in freight cache passphrase file option --- lib/freight/apt.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/freight/apt.sh b/lib/freight/apt.sh index b5fd9ab..f8b8cd5 100644 --- a/lib/freight/apt.sh +++ b/lib/freight/apt.sh @@ -207,15 +207,22 @@ EOF USERKEYS="$USERKEYS$(printf %s "-u$GPGKEY") " done + # Check if gpg supports --pinentry loopback option + # See https://wiki.archlinux.org/index.php/GnuPG#Unattended_passphrase + PINENTRY_LOOPBACK="" + [ "$GPG_PASSPHRASE_FILE" ] && + gpg --no-tty --pinentry-mode loopback --list-keys >/dev/null 2>&1 && + PINENTRY_LOOPBACK=" --pinentry-mode loopback" + # Sign the top-level `Release` file with `gpg` # shellcheck disable=SC2046 disable=SC2086 disable=SC2015 gpg -abs$([ "$TTY" ] || echo " --no-tty") --use-agent ${USERKEYS} \ - $([ "$GPG_PASSPHRASE_FILE" ] && echo " --batch --passphrase-fd 1 --passphrase-file $GPG_PASSPHRASE_FILE") \ + $([ "$GPG_PASSPHRASE_FILE" ] && echo " --batch$PINENTRY_LOOPBACK --passphrase-fd 1 --passphrase-file $GPG_PASSPHRASE_FILE") \ $([ "$GPG_DIGEST_ALGO" ] && echo " --personal-digest-preferences $GPG_DIGEST_ALGO") \ -o"$DISTCACHE/Release.gpg" "$DISTCACHE/Release" && # Create/Sign the top-level `InRelease` file with `gpg` gpg --clearsign$([ "$TTY" ] || echo " --no-tty") --use-agent ${USERKEYS} \ - $([ "$GPG_PASSPHRASE_FILE" ] && echo " --batch --passphrase-fd 1 --passphrase-file $GPG_PASSPHRASE_FILE") \ + $([ "$GPG_PASSPHRASE_FILE" ] && echo " --batch$PINENTRY_LOOPBACK --passphrase-fd 1 --passphrase-file $GPG_PASSPHRASE_FILE") \ $([ "$GPG_DIGEST_ALGO" ] && echo " --personal-digest-preferences $GPG_DIGEST_ALGO") \ -o"$DISTCACHE/InRelease" "$DISTCACHE/Release" || { cat < Date: Thu, 31 May 2018 08:43:40 +0200 Subject: [PATCH 65/72] bump version to 0.3.12 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 1b4f4fc..d956d43 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION=0.3.11 +VERSION=0.3.12 BUILD=1 SH=dash From ab5a7abf05e4bceee4784e164a08ecdff1e023c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuli=20Sepp=C3=A4nen?= Date: Mon, 4 Jun 2018 09:09:51 +0300 Subject: [PATCH 66/72] Mention that the GnuPG 2.x workaround should not be needed on 0.3.12+ --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6cd70f3..265726f 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,8 @@ Build the cache of all the files needed to be accepted as a Debian archive: If your system has GnuPG 2.x make sure that a gpg-agent is running and that you have installed a pinentry package (e.g. pinentry-curses) that suits your needs. -You may also need to set GPG_TTY environment variable like this: +On freight 0.3.11 and older you may also need to set the GPG_TTY environment +variable like this: export GPG_TTY=$(tty) From f49ea6c59881caaa9355d3bb55f5cec474a87de1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuli=20Sepp=C3=A4nen?= Date: Mon, 4 Jun 2018 08:51:16 +0300 Subject: [PATCH 67/72] Add Debian changelog for version 0.3.12 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Samuli Seppänen --- debian/changelog | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/debian/changelog b/debian/changelog index 9bf075c..579ee33 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,21 @@ +freight (0.3.12) stable; urgency=low + + * bump version to 0.3.12 (Michael Moll, 6f31de8) + * Support gpg2 in freight cache passphrase file option (Hiroaki Nakamura, 60b5263) + * use shfmt and add it to travis (Michael Moll, 92dc0e2) + * Unrecognized switches caused infinite loop in all the commands. (Stanislaw Klekot, 105c1dc) + * create InRelease file (Michael Moll, 0a8c99a) + * refactor signing of the Release file (Michael Moll, 12060a3) + * refactor multikey signing test (Michael Moll, de3c875) + * Document caveats when using GnuPG 2.x (Samuli Seppänen, 2d967bc) + * Travis does provide haveged now (Michael Moll, a1af28b) + * adjust .travis.yml after Travis updates (Michael Moll, 32ce114) + * Suppress link error messages. (Dancho Penev, 78949f8) + * calculate size correctly (Michael Moll, ba9f37e) + * fix new shellcheck warnings (Michael Moll, 42d0067) + + -- Samuli Seppänen Mon, 4 Jun 2018 06:00:00 +0000 + freight (0.3.11) stable; urgency=low * bump version to 0.3.11 (Michael Moll, de67c6e) From dab1dbeace63a4eb2e2fc5798f2d9856bb0dac58 Mon Sep 17 00:00:00 2001 From: Stuart Williams Date: Thu, 19 Jul 2018 12:21:41 +0100 Subject: [PATCH 68/72] Support 'ddeb' file extension --- bin/freight-add | 8 ++++---- lib/freight/apt.sh | 4 ++-- man/man1/freight-add.1 | 2 +- man/man1/freight-add.1.ronn | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/bin/freight-add b/bin/freight-add index dd89828..b60bb2a 100755 --- a/bin/freight-add +++ b/bin/freight-add @@ -39,7 +39,7 @@ done # to be `/` pairs for this (source) package. while [ "$#" -gt 0 ]; do case "$1" in - *.deb | *.dsc | *.orig.tar.gz | *.orig.tar.bz2 | *.orig.tar.xz | *.orig.tar.lzma | *.diff.gz | *.debian.tar.gz | *.debian.tar.bz2 | *.debian.tar.xz | *.debian.tar.lzma | *.tar.gz | *.tar.bz2 | *.tar.xz | *.tar.lzma) + *.deb | *.ddeb | *.dsc | *.orig.tar.gz | *.orig.tar.bz2 | *.orig.tar.xz | *.orig.tar.lzma | *.diff.gz | *.debian.tar.gz | *.debian.tar.bz2 | *.debian.tar.xz | *.debian.tar.lzma | *.tar.gz | *.tar.bz2 | *.tar.xz | *.tar.lzma) # shellcheck disable=SC2153 PATHNAMES="$PATHNAMES $1" shift ;; @@ -88,8 +88,8 @@ for PATHNAME in $PATHNAMES; do for DIRNAME in "$@"; do mkdir -p "$DIRNAME" case "$FILENAME" in - *_*_*.deb) add "$FILENAME" "$DIRNAME" "$PATHNAME" ;; - *.deb) + *_*_*.deb | *_*_*.ddeb) add "$FILENAME" "$DIRNAME" "$PATHNAME" ;; + *.deb | *.ddeb) . "$(dirname "$(dirname "$0")")/lib/freight/apt.sh" dpkg-deb -I "$TMP/$FILENAME" "control" >"$TMP/$FILENAME-control" DEBNAME="$( @@ -98,7 +98,7 @@ for PATHNAME in $PATHNAMES; do apt_binary_version "$TMP/$FILENAME-control" )_$( apt_binary_arch "$TMP/$FILENAME-control" - ).deb" + ).${FILENAME##*.}" add "$FILENAME" "$DIRNAME" "$PATHNAME" "$DEBNAME" ;; *) add "$FILENAME" "$DIRNAME" "$PATHNAME" ;; diff --git a/lib/freight/apt.sh b/lib/freight/apt.sh index f8b8cd5..45be33d 100644 --- a/lib/freight/apt.sh +++ b/lib/freight/apt.sh @@ -110,7 +110,7 @@ apt_cache() { case "$PATHNAME" in # Binary packages. - *.deb) apt_cache_binary "$DIST" "$DISTCACHE" "$PATHNAME" "$COMP" "$PACKAGE" ;; + *.deb | *.ddeb) apt_cache_binary "$DIST" "$DISTCACHE" "$PATHNAME" "$COMP" "$PACKAGE" ;; # Source packages. The *.dsc file is considered the "entrypoint" # and will find the associated *.orig.tar.gz, *.diff.gz, and/or @@ -332,7 +332,7 @@ EOF VERSION="$(apt_binary_version "$CONTROL")" PREFIX="$(apt_binary_prefix "$CONTROL")" SOURCE="$(apt_binary_sourcename "$CONTROL")" - FILENAME="${NAME}_${VERSION##*:}_${ARCH}.deb" + FILENAME="${NAME}_${VERSION##*:}_${ARCH}.${PATHNAME##*.}" # Link this package into the pool. POOL="pool/$DIST/$COMP/$PREFIX/$SOURCE" diff --git a/man/man1/freight-add.1 b/man/man1/freight-add.1 index 91e0dbb..ef569d2 100644 --- a/man/man1/freight-add.1 +++ b/man/man1/freight-add.1 @@ -10,7 +10,7 @@ \fBfreight add\fR [\fB\-c\fR \fIconf\fR] [\fB\-v\fR] [\fB\-h\fR] \fIpackage\fR \fImanager\fR/\fIdistro\fR[/\fIcomponent\fR][\.\.\.] . .SH "DESCRIPTION" -\fBfreight\-add\fR registers \fIpackage\fR with one or more \fImanager\fR/\fIdistro\fR[/\fIcomponent\fR] pairs (or triples)\. Currently, \fBapt\fR is the only supported \fImanager\fR and \fIpackage\fR must be one of \fI*\.deb\fR, \fI*\.dsc *\.debian\.tar\.gz *\.orig\.tar\.gz\fR, \fI*\.dsc *\.diff\.gz *\.orig\.tar\.gz\fR, or \fI*\.dsc *\.tar\.gz\fR\. \fIdistro\fR may be any arbitrary value but is best suited to naming a particular version of the target operating system (for example, "wheezy" or "precise")\. \fIcomponent\fR is optional and for \fBapt\fR defaults to \fBmain\fR\. +\fBfreight\-add\fR registers \fIpackage\fR with one or more \fImanager\fR/\fIdistro\fR[/\fIcomponent\fR] pairs (or triples)\. Currently, \fBapt\fR is the only supported \fImanager\fR and \fIpackage\fR must be one of \fI*\.deb\fR, \fI*\.ddeb\fR, \fI*\.dsc *\.debian\.tar\.gz *\.orig\.tar\.gz\fR, \fI*\.dsc *\.diff\.gz *\.orig\.tar\.gz\fR, or \fI*\.dsc *\.tar\.gz\fR\. \fIdistro\fR may be any arbitrary value but is best suited to naming a particular version of the target operating system (for example, "wheezy" or "precise")\. \fIcomponent\fR is optional and for \fBapt\fR defaults to \fBmain\fR\. . .P The package files are organized in the Freight library so \fBfreight\-cache\fR(1) has an easy time of creating package repositories for each \fImanager\fR/\fIdistro\fR[/\fIcomponent\fR] later\. diff --git a/man/man1/freight-add.1.ronn b/man/man1/freight-add.1.ronn index 728c086..6ca4ecf 100644 --- a/man/man1/freight-add.1.ronn +++ b/man/man1/freight-add.1.ronn @@ -7,7 +7,7 @@ freight-add(1) -- add a package to Freight ## DESCRIPTION -`freight-add` registers _package_ with one or more _manager_/_distro_[/_component_] pairs (or triples). Currently, `apt` is the only supported _manager_ and _package_ must be one of _\*.deb_, _\*.dsc \*.debian.tar.gz \*.orig.tar.gz_, _\*.dsc \*.diff.gz \*.orig.tar.gz_, or _\*.dsc \*.tar.gz_. _distro_ may be any arbitrary value but is best suited to naming a particular version of the target operating system (for example, "wheezy" or "precise"). _component_ is optional and for `apt` defaults to `main`. +`freight-add` registers _package_ with one or more _manager_/_distro_[/_component_] pairs (or triples). Currently, `apt` is the only supported _manager_ and _package_ must be one of _\*.deb_, _\*.ddeb_, _\*.dsc \*.debian.tar.gz \*.orig.tar.gz_, _\*.dsc \*.diff.gz \*.orig.tar.gz_, or _\*.dsc \*.tar.gz_. _distro_ may be any arbitrary value but is best suited to naming a particular version of the target operating system (for example, "wheezy" or "precise"). _component_ is optional and for `apt` defaults to `main`. The package files are organized in the Freight library so `freight-cache`(1) has an easy time of creating package repositories for each _manager_/_distro_[/_component_] later. From bc1d80c3a5f8187c961663c3501bdc06c1f9fe9a Mon Sep 17 00:00:00 2001 From: Michael Moll Date: Sun, 21 Oct 2018 23:11:42 +0200 Subject: [PATCH 69/72] Reformat with newer shfmt version Also, fix one SC2235 found with a newer shellcheck version --- bin/freight-add | 12 ++++++++---- lib/freight/apt.sh | 31 ++++++++++++++++++++----------- lib/freight/conf.sh | 9 ++++++--- 3 files changed, 34 insertions(+), 18 deletions(-) diff --git a/bin/freight-add b/bin/freight-add index dd89828..324ee19 100755 --- a/bin/freight-add +++ b/bin/freight-add @@ -70,12 +70,16 @@ cd "$VARLIB" # PATHNAME. The first two are given fairly directly to ln(1); the final one # is used to create appropriate success or failure messages. add() { - if ln "$TMP/$1" "$2/$1" 2>"$TMP/ln"; then echo "# [freight] added $3 to $2${4+" as "}$4" >&2 + if ln "$TMP/$1" "$2/$1" 2>"$TMP/ln"; then + echo "# [freight] added $3 to $2${4+" as "}$4" >&2 else - if grep -q "File exists" "$TMP/ln"; then echo "# [freight] $2 already has $3${4+" as "}$4" >&2 - else cat "$TMP/ln" >&2 + if grep -q "File exists" "$TMP/ln"; then + echo "# [freight] $2 already has $3${4+" as "}$4" >&2 + else + cat "$TMP/ln" >&2 fi - if [ -n "$FREIGHT_ADD_ERROR" ]; then exit 2 + if [ -n "$FREIGHT_ADD_ERROR" ]; then + exit 2 fi fi } diff --git a/lib/freight/apt.sh b/lib/freight/apt.sh index f8b8cd5..c4c3de7 100644 --- a/lib/freight/apt.sh +++ b/lib/freight/apt.sh @@ -285,8 +285,8 @@ apt_cache_binary() { fi # If caching is off or if the binary has changed size, this will generate the # binary control file - if ! ([ -e "$CONTROL" ] && - [ "$(apt_binary_filesize "$CONTROL")" -eq "$(apt_filesize "$VARLIB/apt/$DIST/$PATHNAME")" ]); then + if ! { [ -e "$CONTROL" ] && + [ "$(apt_binary_filesize "$CONTROL")" -eq "$(apt_filesize "$VARLIB/apt/$DIST/$PATHNAME")" ]; }; then dpkg-deb -e "$VARLIB/apt/$DIST/$PATHNAME" "$TMP/DEBIAN" || { echo "# [freight] skipping invalid Debian package $PATHNAME" >&2 return @@ -338,16 +338,20 @@ EOF POOL="pool/$DIST/$COMP/$PREFIX/$SOURCE" mkdir -p "$VARCACHE/$POOL" if [ ! -f "$VARCACHE/$POOL/$FILENAME" ]; then - if [ "$PACKAGE" != "$FILENAME" ]; then echo "# [freight] adding $PACKAGE to pool (as $FILENAME)" >&2 - else echo "# [freight] adding $PACKAGE to pool" >&2 + if [ "$PACKAGE" != "$FILENAME" ]; then + echo "# [freight] adding $PACKAGE to pool (as $FILENAME)" >&2 + else + echo "# [freight] adding $PACKAGE to pool" >&2 fi ln "$DISTCACHE/.refs/$COMP/$PACKAGE" "$VARCACHE/$POOL/$FILENAME" fi # Build a list of the one-or-more `Packages` files to append with # this package's info. - if [ "$ARCH" = "all" ]; then FILES="$(find "$DISTCACHE/$COMP" -type f -name "Packages")" - else FILES="$DISTCACHE/$COMP/binary-$ARCH/Packages" + if [ "$ARCH" = "all" ]; then + FILES="$(find "$DISTCACHE/$COMP" -type f -name "Packages")" + else + FILES="$DISTCACHE/$COMP/binary-$ARCH/Packages" fi # Add the `Filename` field containing the path to the @@ -387,11 +391,16 @@ apt_cache_source() { TAR_FILENAME="${NAME}_${VERSION%*:}.tar.gz" # Find which style of diff they're using. - if [ -f "$VARLIB/apt/$DIST/$DIRNAME/$DEBTAR_GZ_FILENAME" ]; then DIFF_FILENAME=${DEBTAR_GZ_FILENAME} - elif [ -f "$VARLIB/apt/$DIST/$DIRNAME/$DEBTAR_BZ2_FILENAME" ]; then DIFF_FILENAME=${DEBTAR_BZ2_FILENAME} - elif [ -f "$VARLIB/apt/$DIST/$DIRNAME/$DEBTAR_XZ_FILENAME" ]; then DIFF_FILENAME=${DEBTAR_XZ_FILENAME} - elif [ -f "$VARLIB/apt/$DIST/$DIRNAME/$DEBTAR_LZMA_FILENAME" ]; then DIFF_FILENAME=${DEBTAR_LZMA_FILENAME} - else DIFF_FILENAME=${DIFFGZ_FILENAME} + if [ -f "$VARLIB/apt/$DIST/$DIRNAME/$DEBTAR_GZ_FILENAME" ]; then + DIFF_FILENAME=${DEBTAR_GZ_FILENAME} + elif [ -f "$VARLIB/apt/$DIST/$DIRNAME/$DEBTAR_BZ2_FILENAME" ]; then + DIFF_FILENAME=${DEBTAR_BZ2_FILENAME} + elif [ -f "$VARLIB/apt/$DIST/$DIRNAME/$DEBTAR_XZ_FILENAME" ]; then + DIFF_FILENAME=${DEBTAR_XZ_FILENAME} + elif [ -f "$VARLIB/apt/$DIST/$DIRNAME/$DEBTAR_LZMA_FILENAME" ]; then + DIFF_FILENAME=${DEBTAR_LZMA_FILENAME} + else + DIFF_FILENAME=${DIFFGZ_FILENAME} fi # Verify this package by ensuring the other necessary files are present. diff --git a/lib/freight/conf.sh b/lib/freight/conf.sh index 07bdaaa..8630b03 100644 --- a/lib/freight/conf.sh +++ b/lib/freight/conf.sh @@ -29,8 +29,10 @@ SYMLINKS="off" # Source all existing configuration files from lowest- to highest-priority. PREFIX="$(dirname "$(dirname "$0")")" -if [ "$PREFIX" = "/usr" ]; then [ -f "/etc/freight.conf" ] && . "/etc/freight.conf" -else [ -f "$PREFIX/etc/freight.conf" ] && . "$PREFIX/etc/freight.conf" +if [ "$PREFIX" = "/usr" ]; then + [ -f "/etc/freight.conf" ] && . "/etc/freight.conf" +else + [ -f "$PREFIX/etc/freight.conf" ] && . "$PREFIX/etc/freight.conf" fi [ -f "$HOME/.freight.conf" ] && . "$HOME/.freight.conf" DIRNAME="$PWD" @@ -42,7 +44,8 @@ while true; do done [ "$FREIGHT_CONF" ] && [ -f "$FREIGHT_CONF" ] && . "$FREIGHT_CONF" if [ "$CONF" ]; then - if [ -f "$CONF" ]; then . "$CONF" + if [ -f "$CONF" ]; then + . "$CONF" else echo "# [freight] $CONF does not exist" >&2 exit 1 From d110d7d6835319e8657596aa7cc4c7ce4ea794ac Mon Sep 17 00:00:00 2001 From: Michael Moll Date: Tue, 19 Mar 2019 20:36:58 +0100 Subject: [PATCH 70/72] use xenial for travis tests --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 34b11be..e34a0c2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,3 +9,4 @@ script: - make check notifications: irc: "chat.freenode.net#freight" +dist: xenial From df4f2d91d644cde74324efe502845bb1c3adc430 Mon Sep 17 00:00:00 2001 From: Ben Tyger <988950+hydrian@users.noreply.github.com> Date: Mon, 11 May 2020 13:37:28 -0400 Subject: [PATCH 71/72] Added missing symlink requirement Added follow symlink requirement to the webserver configuration. Some web servers (Apache) don't allow it by default. --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 265726f..83c30ae 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,8 @@ Serve `/var/cache/freight` via your favorite web server and install it as an APT sudo apt-get update sudo apt-get -y install foobar +Make sure your webserver is configured to follow symlinks inside of the hosted directory. + ## Installation ### From source From 6535b316d919d566162931e6bce9de3026ce2441 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuli=20Sepp=C3=A4nen?= Date: Wed, 4 Nov 2020 15:07:24 +0200 Subject: [PATCH 72/72] Add changelog for 0.3.13 --- debian/changelog | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/debian/changelog b/debian/changelog index 579ee33..756c1a4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,13 @@ +freight (0.3.13) stable; urgency=low + + * Merge pull request #90 from stuwil/ddeb_support (Samuli Seppänen, 6baefb5) + * Added missing symlink requirement (Ben Tyger, df4f2d9) + * use xenial for travis tests (Michael Moll, d110d7d) + * Reformat with newer shfmt version (Michael Moll, bc1d80c) + * Support 'ddeb' file extension (Stuart Williams, dab1dbe) + + -- Samuli Seppänen Wed, 4 Nov 2020 13:05:00 +0000 + freight (0.3.12) stable; urgency=low * bump version to 0.3.12 (Michael Moll, 6f31de8)