From b183931cf573fc1ccb1ee936b850187dbef2fa00 Mon Sep 17 00:00:00 2001 From: Lee Whalen Date: Sat, 28 Feb 2015 20:44:28 -0800 Subject: [PATCH 1/3] 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 From 2591c768e7d59b9f1b7a55ff615589893eb2a556 Mon Sep 17 00:00:00 2001 From: Lee Whalen Date: Sun, 1 Mar 2015 14:37:07 -0800 Subject: [PATCH 2/3] Fixing issues with Makefile per PR feedback --- Makefile | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 8be8a43..ce681a2 100644 --- a/Makefile +++ b/Makefile @@ -61,32 +61,35 @@ lock-rpm: unlock-rpm: sudo yum versionlock clear -# Add other package types here. +# +# DEB builds +# + 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: +packages-deb-debug: @echo BUILD: - @PKGRELEASE=99 make packages + @PKGRELEASE=99 make packages-deb @echo ITEMS TO BE PACKAGED: find ~/debbuild-$(PKGNAME)/installroot -type f @echo ITEMS ACTUALLY IN PACKAGE: - @rpm -qpl $$(cat ~/debbuild-$(PKGNAME)/bin-packages.txt) + @dpkg --contents $$(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) +# Add other package types here. # # System Test: # - 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 ; + @export PATH=~/gitwork/blackbox/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/local/bin ; tools/confidence_test.sh 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 From 6e32500adc24d55dca1a1304299639bb4ecfca8f Mon Sep 17 00:00:00 2001 From: Lee Whalen Date: Sun, 1 Mar 2015 14:58:09 -0800 Subject: [PATCH 3/3] Mangling Makefile to make better sense - generates .deb inputfile list from the RPM list, and does so for each run of 'make packages-deb' --- Makefile | 8 +++++-- tools/mk_deb_fpmdir.stack_blackbox.txt | 29 +++++++++++++------------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index ce681a2..5447707 100644 --- a/Makefile +++ b/Makefile @@ -25,6 +25,10 @@ packages: packages-rpm tools/mk_macports.vcs_blackbox.txt: tools/mk_rpm_fpmdir.stack_blackbox.txt sed -e 's@/usr/blackbox/bin/@bin/@g' -e '/profile.d-usrblackbox.sh/d' $@ +# Make mk_deb_fpmdir.vcs_blackbox.txt from mk_rpm_fpmdir.stack_blackbox.txt: +tools/mk_deb_fpmdir.stack_blackbox.txt: tools/mk_rpm_fpmdir.stack_blackbox.txt + sed -e 's@/usr/blackbox/bin/@/usr/bin/@g' -e '/profile.d-usrblackbox.sh/d' $@ + check-destdir: ifndef DESTDIR $(error DESTDIR is undefined) @@ -65,10 +69,10 @@ unlock-rpm: # DEB builds # -packages-deb: +packages-deb: tools/mk_deb_fpmdir.stack_blackbox.txt 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-deb-debug: +packages-deb-debug: tools/mk_deb_fpmdir.stack_blackbox.txt @echo BUILD: @PKGRELEASE=99 make packages-deb @echo ITEMS TO BE PACKAGED: diff --git a/tools/mk_deb_fpmdir.stack_blackbox.txt b/tools/mk_deb_fpmdir.stack_blackbox.txt index de4731e..3e0b752 100644 --- a/tools/mk_deb_fpmdir.stack_blackbox.txt +++ b/tools/mk_deb_fpmdir.stack_blackbox.txt @@ -1,15 +1,14 @@ -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 +exec /usr/bin/_blackbox_common.sh ../bin/_blackbox_common.sh +exec /usr/bin/_stack_lib.sh ../bin/_stack_lib.sh +exec /usr/bin/blackbox_addadmin ../bin/blackbox_addadmin +exec /usr/bin/blackbox_cat ../bin/blackbox_cat +exec /usr/bin/blackbox_edit ../bin/blackbox_edit +exec /usr/bin/blackbox_edit_end ../bin/blackbox_edit_end +exec /usr/bin/blackbox_edit_start ../bin/blackbox_edit_start +exec /usr/bin/blackbox_initialize ../bin/blackbox_initialize +exec /usr/bin/blackbox_postdeploy ../bin/blackbox_postdeploy +exec /usr/bin/blackbox_register_new_file ../bin/blackbox_register_new_file +exec /usr/bin/blackbox_removeadmin ../bin/blackbox_removeadmin +exec /usr/bin/blackbox_shred_all_files ../bin/blackbox_shred_all_files +exec /usr/bin/blackbox_update_all_files ../bin/blackbox_update_all_files +exec /usr/bin/blackbox_list_files ../bin/blackbox_list_files