Repository: rcrowley/freight Branch: master Commit: 2fdb0fbd60f9 Files: 27 Total size: 55.1 KB Directory structure: gitextract_xftas1zo/ ├── .gitignore ├── LICENSE ├── Makefile ├── NOTES ├── README.md ├── bin/ │ ├── freight │ ├── freight-add │ ├── freight-cache │ ├── freight-clear-cache │ └── freight-init ├── etc/ │ ├── bash_completion.d/ │ │ └── freight │ ├── freight.conf.example │ └── profile.d/ │ └── freight.sh ├── lib/ │ └── freight/ │ ├── apt.sh │ └── conf.sh └── man/ ├── man1/ │ ├── freight-add.1 │ ├── freight-add.1.ronn │ ├── freight-cache.1 │ ├── freight-cache.1.ronn │ ├── freight-clear-cache.1 │ ├── freight-clear-cache.1.ronn │ ├── freight-init.1 │ ├── freight-init.1.ronn │ ├── freight.1 │ └── freight.1.ronn └── man5/ ├── freight.5 └── freight.5.ronn ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ *.swp *.html *.deb *.dsc *.debian.tar.gz *.diff.gz *.orig.tar.gz *.tar.gz *~ etc/freight.conf var ================================================ FILE: LICENSE ================================================ Copyright 2010 Richard Crowley. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY RICHARD CROWLEY ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RICHARD CROWLEY OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. The views and conclusions contained in the software and documentation are those of the authors and should not be interpreted as representing official policies, either expressed or implied, of Richard Crowley. ================================================ FILE: Makefile ================================================ VERSION=0.3.5 BUILD=1 prefix=/usr/local bindir=${prefix}/bin libdir=${prefix}/lib sysconfdir=${prefix}/etc mandir=${prefix}/share/man all: clean: rm -rf *.deb debian man/man*/*.html find . -name '*~' -delete install: install-bin install-lib install-man install-sysconf install-bin: find bin -type f -printf %P\\0 | xargs -0r -I__ install -D bin/__ $(DESTDIR)$(bindir)/__ install-lib: find lib -type f -printf %P\\0 | xargs -0r -I__ install -m644 -D lib/__ $(DESTDIR)$(libdir)/__ 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)/__ install-sysconf: find etc -type f -not -name freight.conf -printf %P\\0 | xargs -0r -I__ install -m644 -D etc/__ $(DESTDIR)$(sysconfdir)/__ uninstall: uninstall-bin uninstall-lib uninstall-man uninstall-sysconf uninstall-bin: find bin -type f -printf %P\\0 | xargs -0r -I__ rm -f $(DESTDIR)$(bindir)/__ rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(bindir) || true uninstall-lib: find lib -type f -printf %P\\0 | xargs -0r -I__ rm -f $(DESTDIR)$(libdir)/__ find lib -depth -mindepth 1 -type d -printf %P\\0 | xargs -0r -I__ rmdir $(DESTDIR)$(libdir)/__ || true rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(libdir) || true uninstall-man: find man -type f -name \*.[12345678] -printf %P\\0 | xargs -0r -I__ rm -f $(DESTDIR)$(mandir)/__.gz find man -depth -mindepth 1 -type d -printf %P\\0 | xargs -0r -I__ rmdir $(DESTDIR)$(mandir)/__ || true rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(mandir) || true uninstall-sysconf: find etc -type f -printf %P\\0 | xargs -0r -I__ rm -f $(DESTDIR)$(sysconfdir)/__ find etc -depth -mindepth 1 -type d -printf %P\\0 | xargs -0r -I__ rmdir $(DESTDIR)$(sysconfdir)/__ || true rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(sysconfdir) || true build: make install prefix=/usr sysconfdir=/etc DESTDIR=debian 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/rcrowley/freight" \ --description "A modern take on the Debian archive." \ -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 docs: for SH in $$(find bin lib -type f -not -name \*.html); do \ shocco $$SH >$$SH.html; \ done gh-pages: man mkdir -p gh-pages find man -name \*.html | xargs -I__ mv __ gh-pages/ git checkout -q gh-pages cp -R gh-pages/* ./ rm -rf gh-pages git add . git commit -m "Rebuilt manual." git push origin gh-pages git checkout -q master .PHONY: all install uninstall deb deploy man gh-pages ================================================ FILE: NOTES ================================================ Store repositories in a root as /var/lib/freight///. "Compile" to /var/cache/freight. freight-add /... Copy and hard link into place in each / If you do backups, make sure to use the -H option to rsync(1). Don't have to copy if we're on the same device. (Optionally) remove files from each distro that start with "_". freight-cache /... Sort the packages in each distro. Build a Packages file for each architecture mentioned. Grab the control file from each package. Augment it with Size, MD5Sum, SHA1, SHA256, and Filename. Make sure Package is first, Version is second, and Description is last. gzip every Packages file. Build the Release file for each architecture mentioned. Build the Release file with the checksums for each contained Release and Packages file. gpg sign the Release file. Default directories? /var/lib/freight// /var/cache/freight///{dists,pool} For Debian-style, all that's important is the dists/ hierarchy? ================================================ FILE: README.md ================================================ # Freight A modern take on the Debian archive. ## 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: GPG="example@example.com" Add packages to particular distros: freight add foobar_1.2.3-1_all.deb apt/squeeze apt/lucid apt/natty Build the cache of all the files needed to be accepted as a Debian archive: freight cache 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 sudo wget -O /etc/apt/trusted.gpg.d/example.gpg http://example.com/keyring.gpg sudo apt-get update sudo apt-get -y install foobar ## Installation ### From source git clone git://github.com/rcrowley/freight.git cd freight && make && sudo make install ### 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 sudo apt-get update sudo apt-get -y install freight ### 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). yum -y install freight ## Documentation * [Debian packaging for busy people](http://rcrowley.org/articles/packaging.html) There's also [French documentation](http://blog.valouille.fr/2014/03/creer-un-depot-debian-signe-avec-freight/) assembled by Valérian Beaudoin. ## 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) ## Contribute Freight is [BSD-licensed](https://github.com/rcrowley/freight/blob/master/LICENSE) * Source code: * Issue tracker: * Wiki: ================================================ FILE: bin/freight ================================================ #!/bin/sh # `freight` dispatches to `freight-*` commands. 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 ] && { shift exec $COMMAND "$@" } # Be helpful in this case since no subcommand was found. echo "Usage: $(basename $0) [...]" >&2 echo "Common commands: add cache init" >&2 echo "See all available commands by typing \"$(basename $0)-\"" >&2 exit 1 ================================================ FILE: bin/freight-add ================================================ #!/bin/sh # Add a package to the Freight library. #/ Usage: freight add [-c ] [-v] [-h] /... #/ -c , --conf= config file to parse #/ -v, --verbose verbose mode #/ -h, --help show this help message set -e usage() { 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 done . "$(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. # When the last of these is found, the remaining arguments are each assumed # to be `/` pairs for this (source) package. while [ "$#" -gt 0 ] do case "$1" in *.deb|*.dsc|*.orig.tar.gz|*.diff.gz|*.debian.tar.gz|*.tar.gz) PATHNAMES="$PATHNAMES $1" shift;; *.build|*.changes) shift;; *) break;; esac done [ -z "$PATHNAMES" ] && usage 1 [ -z "$*" ] && usage 1 # Create a working directory on the same device as the Freight library and # copy this package there. This used to be a link but is now a copy because # later Freight commands will rely on the link count being reduced to one. mkdir -p "$VARLIB" TMP="$(mktemp -d "$VARLIB/freight.$$.XXXXXXXXXX")" trap "rm -rf \"$TMP\"" EXIT INT TERM for PATHNAME in $PATHNAMES do cp "$PATHNAME" "$TMP/" done # Enter the Freight library directory so that items in `$@` may be given as # absolute paths or as partial paths of the form `/` that # are ultimately taken relative to the Freight library. cd "$VARLIB" # Add a file to the Freight library. The arguments are FILENAME, DIRNAME, and # 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 else if grep -q "File exists" "$TMP/ln" then echo "# [freight] $2 already has $3${4+" as "}$4" >&2 else cat "$TMP/ln" >&2 fi fi } # 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 FILENAME="$(basename "$PATHNAME")" for DIRNAME in "$@" do mkdir -p "$DIRNAME" case "$FILENAME" in *_*_*.deb) add "$FILENAME" "$DIRNAME" "$PATHNAME";; *.deb) . "$(dirname "$(dirname "$0")")/lib/freight/apt.sh" dpkg-deb -I "$TMP/$FILENAME" "control" >"$TMP/$FILENAME-control" DEBNAME="$( apt_binary_name "$TMP/$FILENAME-control" )_$( apt_binary_version "$TMP/$FILENAME-control" )_$( apt_binary_arch "$TMP/$FILENAME-control" ).deb" add "$FILENAME" "$DIRNAME" "$PATHNAME" "$DEBNAME";; *) add "$FILENAME" "$DIRNAME" "$PATHNAME";; esac done done ================================================ FILE: bin/freight-cache ================================================ #!/bin/sh # Rebuild the Freight cache from the Freight library. The cache contains # actual repositories that are suitable targets for `apt-get` (and maybe # more in the future). #/ Usage: freight cache [-k] [-g ] [-p ] [-c ] [-v] [-h] [/][...] #/ -k, --keep keep unreferenced versions of packages #/ -g , --gpg= GPG key to use #/ -p , #/ --passphrase-file= path to file containing the passphrase of the GPG key #/ -c , --conf= config file to parse #/ -v, --verbose verbose mode #/ -h, --help show this help message set -e usage() { grep "^#/" "$0" | cut -c"4-" >&2 exit "$1" } 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;; -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)" . "$LIB/conf.sh" # 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 # Create a working directory on the same device as the Freight cache. mkdir -p "$VARCACHE" TMP="$(mktemp -d "$VARCACHE/work.$$.XXXXXXXXXX")" trap "rm -rf \"$TMP\"" EXIT INT TERM # Enter the Freight library directory so that items in `$@` may be given as # absolute paths or as partial paths of the form `/` that # are ultimately taken relative to the Freight library. mkdir -p "$VARLIB" 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" " " )" else 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")" # 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" # Clean up old packages as dictated by the manager. [ -z "$KEEP" ] && eval "${MANAGER}_clean" done ================================================ FILE: bin/freight-clear-cache ================================================ #!/bin/sh # Clear the cache that is built up during freight-cache runs # so that it can be regenerated on the next freight-cache invocation. #/ Usage: freight clear-cache [-c ] [-v] [-h] [/][...] #/ -c , --conf= config file to parse #/ -v, --verbose verbose mode #/ -h, --help show this help message set -e usage() { 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 done . "$(dirname "$(dirname "$0")")/lib/freight/conf.sh" # Create a working directory on the same device as the Freight cache. mkdir -p "$VARCACHE" TMP="$(mktemp -d "$VARCACHE/work.$$.XXXXXXXXXX")" trap "rm -rf \"$TMP\"" EXIT INT TERM # Enter the Freight library directory so that items in `$@` may be given as # absolute paths or as partial paths of the form `/` that # are ultimately taken relative to the Freight library. mkdir -p "$VARLIB" 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" " " )" else 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")" # From here the process is customized on a per-manager basis. . "$(dirname "$(dirname "$0")")/lib/freight/$MANAGER.sh" eval "${MANAGER}_clear_cache" "$DIST" done ================================================ FILE: bin/freight-init ================================================ #!/bin/sh # Initialize a Freight directory (similar to git init). #/ Usage: freight init -g [--libdir=] [--cachedir=] [--archs=] [--origin=] [--label=