From b183931cf573fc1ccb1ee936b850187dbef2fa00 Mon Sep 17 00:00:00 2001 From: Lee Whalen Date: Sat, 28 Feb 2015 20:44:28 -0800 Subject: [PATCH] adding rudimentary debian package building support --- Makefile | 20 ++++++- tools/mk_deb_fpmdir | 76 ++++++++++++++++++++++++++ tools/mk_deb_fpmdir.stack_blackbox.txt | 15 +++++ 3 files changed, 110 insertions(+), 1 deletion(-) create mode 100755 tools/mk_deb_fpmdir create mode 100644 tools/mk_deb_fpmdir.stack_blackbox.txt diff --git a/Makefile b/Makefile index 718b319..8be8a43 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,7 @@ PKGNAME=stack_blackbox all: @echo 'Menu:' @echo ' make packages Make RPM packages' + @echo ' make packages-deb Make DEB packages' @echo ' make install (incomplete)' install: @@ -61,6 +62,22 @@ unlock-rpm: sudo yum versionlock clear # Add other package types here. +packages-deb: + cd tools && PKGRELEASE="$${PKGRELEASE}" PKGDESCRIPTION="Safely store secrets in git/hg/svn repos using GPG encryption" ./mk_deb_fpmdir stack_blackbox mk_deb_fpmdir.stack_blackbox.txt + +packages-rpm-debug: + @echo BUILD: + @PKGRELEASE=99 make packages + @echo ITEMS TO BE PACKAGED: + find ~/debbuild-$(PKGNAME)/installroot -type f + @echo ITEMS ACTUALLY IN PACKAGE: + @rpm -qpl $$(cat ~/debbuild-$(PKGNAME)/bin-packages.txt) + +local-deb: + @PKGRELEASE=1 make packages + -@sudo dpkg -e $(PKGNAME) + sudo dpkg -i $$(cat ~/rpmbuild-$(PKGNAME)/bin-packages.txt) + # # System Test: @@ -69,6 +86,7 @@ unlock-rpm: confidence: @if [[ -e ~/.gnupg ]]; then echo ERROR: '~/.gnupg should not exist. If it does, bugs may polute your .gnupg configuration. If the code has no bugs everything will be fine. Do you feel lucky?'; false ; fi @if which >/dev/null gpg-agent ; then pkill gpg-agent ; rm -rf /tmp/tmp.* ; fi - @export PATH=~/gitwork/blackbox/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/local/bin ; tools/confidence_test.sh + @export PATH=~/gitwork/blackbox/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin ; + cd ~/gitwork/blackbox && tools/confidence_test.sh @if which >/dev/null gpg-agent ; then pkill gpg-agent ; fi @if [[ -e ~/.gnupg ]]; then echo ERROR: '~/.gnupg was created which means the scripts might be poluting GnuPG configuration. Fix this bug.'; false ; fi diff --git a/tools/mk_deb_fpmdir b/tools/mk_deb_fpmdir new file mode 100755 index 0000000..31e4ec3 --- /dev/null +++ b/tools/mk_deb_fpmdir @@ -0,0 +1,76 @@ +#! /usr/bin/env bash + +# Use fpm to package up files into a DEB . + +# Usage: +# mk_deb_fpmdir PACKAGENAME MANIFEST1 MANIFEST2 ... + +# Example: +# Make a package foopkg manifest.txt +# Where "manifest.txt" contains: +# exec /usr/bin/stack_makefqdn misc/stack_makefqdn.py +# exec /usr/bin/bar bar/bar.sh +# read /usr/man/man1/bar.1 bar/bar.1.man +# 0444 /etc/foo.conf bar/foo.conf + +set -e + +# Parameters for this DEB: +PACKAGENAME=${1?"First arg must be the package name."} +shift + +# Defaults that can be overridden: +# All packages are 1.0 unless otherwise specifed: +: ${PKGVERSION:=1.0} ; +# If there is no iteration setting, assume "1": +: ${PKGRELEASE:=1} +# If there is no epoch, assume 0 +: ${PKGEPOCH:=0} + +# The DEB is output here: (should be a place that can be wiped) +OUTPUTDIR="${HOME}/debbuild-$PACKAGENAME" +# The TeamCity templates expect to find the list of artifacts here: +DEB_BIN_LIST="${OUTPUTDIR}/bin-packages.txt" + +# -- Now the real work can be done. + +# Clean the output dir. +rm -rf "$OUTPUTDIR" +mkdir -p "$OUTPUTDIR/installroot" + +# Copy the files into place: +set -o pipefail # Error out if any manifest is not found. +cat """$@""" | while read -a arr ; do + PERM="${arr[0]}" + case $PERM in + \#*) continue ;; # Skip comments. + exec) PERM=0755 ;; + read) PERM=0744 ;; + *) ;; + esac + DST="$OUTPUTDIR/installroot/${arr[1]}" + SRC="${arr[2]}" + if [[ $SRC == "cmd/"* || $SRC == *"/cmd/"* ]]; then + ( cd $(dirname "$SRC" ) && go build -a -v ) + fi + install -D -T -b -m "$PERM" -T "$SRC" "$DST" +done + +# Build the DEB: +cd "$OUTPUTDIR" && fpm -s dir -t deb \ + -a x86_64 \ + -n "${PACKAGENAME}" \ + --epoch "${PKGEPOCH}" \ + --version "${PKGVERSION}" \ + --iteration "${PKGRELEASE}" \ + ${PKGDESCRIPTION:+ --description="${PKGDESCRIPTION}"} \ + ${PKGVENDOR:+ --vendor="${PKGVENDOR}"} \ + -C "$OUTPUTDIR/installroot" \ + . + +# TeamCity templates for DEBS expect to find +# the list of all packages created in bin-packages.txt. +# Generate that list: +find "$OUTPUTDIR" -maxdepth 1 -name '*.deb' >"$DEB_BIN_LIST" +# Output it for debugging purposes: +cat "$DEB_BIN_LIST" diff --git a/tools/mk_deb_fpmdir.stack_blackbox.txt b/tools/mk_deb_fpmdir.stack_blackbox.txt new file mode 100644 index 0000000..de4731e --- /dev/null +++ b/tools/mk_deb_fpmdir.stack_blackbox.txt @@ -0,0 +1,15 @@ +read /etc/profile.d/usrblackbox.sh profile.d-usrblackbox.sh +exec /usr/blackbox/bin/_blackbox_common.sh ../bin/_blackbox_common.sh +exec /usr/blackbox/bin/_stack_lib.sh ../bin/_stack_lib.sh +exec /usr/blackbox/bin/blackbox_addadmin ../bin/blackbox_addadmin +exec /usr/blackbox/bin/blackbox_cat ../bin/blackbox_cat +exec /usr/blackbox/bin/blackbox_edit ../bin/blackbox_edit +exec /usr/blackbox/bin/blackbox_edit_end ../bin/blackbox_edit_end +exec /usr/blackbox/bin/blackbox_edit_start ../bin/blackbox_edit_start +exec /usr/blackbox/bin/blackbox_initialize ../bin/blackbox_initialize +exec /usr/blackbox/bin/blackbox_postdeploy ../bin/blackbox_postdeploy +exec /usr/blackbox/bin/blackbox_register_new_file ../bin/blackbox_register_new_file +exec /usr/blackbox/bin/blackbox_removeadmin ../bin/blackbox_removeadmin +exec /usr/blackbox/bin/blackbox_shred_all_files ../bin/blackbox_shred_all_files +exec /usr/blackbox/bin/blackbox_update_all_files ../bin/blackbox_update_all_files +exec /usr/blackbox/bin/blackbox_list_files ../bin/blackbox_list_files