From fcc4547542f4f95a26c75df1d1b92df99a9e4960 Mon Sep 17 00:00:00 2001 From: Josh Cepek Date: Thu, 12 Dec 2013 12:29:29 -0600 Subject: [PATCH] Add build-dist packaging script; update Building docs This initial packaging script creates a release-ready tarball for Unix-alikes. Windows support will be added in a separate commit. Signed-off-by: Josh Cepek --- build/Building.md | 38 +++++++-------- build/build-dist.sh | 116 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 133 insertions(+), 21 deletions(-) create mode 100755 build/build-dist.sh diff --git a/build/Building.md b/build/Building.md index 7ed546e..0d05084 100644 --- a/build/Building.md +++ b/build/Building.md @@ -1,38 +1,34 @@ Building Easy-RSA 3 === -Until a formal buildscript is available, this document serves as the build -reference. Note that Windows builds require external binary files from the -unxutils and mksh/Win32 projects which are not included in the Easy-RSA source -tree. +This document serves as the packaging reference. -Basic Builds +Using the buildscript --- -This build sequence applies to all platforms, including Windows. +build/build-dist.sh prepares a release-ready tarball from the current source +tree. Ensure a clean checkout (remove your left-over temp files) and verify +release changes are in order: -1. Checkout the release tag of interest + * ChangeLog updated for version, date, & feature changes + * Release-tag prepared in git -2. Create a target directory named EasyRSA-3.x.y (matching the release version) +When ready, set a match version on the tarball & inside dir with: -3. Copy the `easyrsa3/*` structure to the target dir root (not named easyrsa3) + ./build/build-dist.sh --version=3.2.1 -4. Copy the following files/dirs into the target dir: - - * `Licensing/` - * `doc/` - * `COPYING` - * `ChangeLog` - * `README.quickstart.md` - -5. For Windows, continue to `Windows Build Extras`. Otherwise, tar up the target - directory for release distribution. +For development use, omitting the --version param creates by default a +`git-development` version. Windows Build Extras --- -Windows has additional build steps to provide a suitable POSIX environment. -Starting with a basic build dir from earlier, proceed as follows. +When the build-script is updated to support Windows, this section will be +updated to match. + +Note that Windows builds require external binary files from the unxutils and +mksh/Win32 projects which are not included in the Easy-RSA source tree. Starting +with a basic build dir from earlier, proceed as follows. 1. Copy everything from `distro/windows/` into the target dir root. Make sure that text files follow the Windows EOL convention (CR+LF) -- a git checkout diff --git a/build/build-dist.sh b/build/build-dist.sh new file mode 100755 index 0000000..6b42813 --- /dev/null +++ b/build/build-dist.sh @@ -0,0 +1,116 @@ +#!/bin/sh + +# Easy-RSA 3 distribution packager: +# creates ready-to-use tarball files for Unixes + +# operational defaults (CLI processing overrides) +VERSION="git-development" +PRODUCT="EasyRSA" +DIST_ROOT="dist-staging" +SRC_ROOT="." +BIN_DEST="." + +usage() { + echo "build-dist options:" + echo + echo " --version=X set version string, default=git-development" + echo " --dist-root=X set DIST_ROOT, default=dist-staging" + echo " --src-root=X set SRC_ROOT for git src dir, default=." + echo " --bin-dest=X set BIN_DEST where to put tar/zip, default=." + echo + echo " --dist-clean rm -rf the DIST_ROOT w/out prompts" + + exit +} + +die() { + echo "build-dist ERROR:" + echo "$1" + exit "${2:-1}" +} + +note() { echo "build-dist NOTE: $1"; } + +# ask before dangerous things +confirm() { + [ "$2" ] && return + echo "$1" + printf " y/n: " + read r + [ "$r" = "y" ] || die "user abort" +} + +# main handling entry, run after options parsing: +main() { + PV="$PRODUCT-$VERSION" + + dist_clean + stage_files + make_tar +} + +# prep DIST_ROOT +dist_clean() { + if [ -e "$DIST_ROOT" ]; then + confirm "Remove existing DIST_ROOT at: '$DIST_ROOT' ?" \ + "$DISTCLEAN" + rm -rf "$DIST_ROOT" || die "dist_clean failed to rm" + fi + mkdir -p "$DIST_ROOT" || die "dist_clean failed to mkdir" +} + +# file stager +stage_files() { + # Copy files into $PV, starting with easyrsa3 as the initial root dir + src_files="easyrsa3/ Licensing/ doc/ COPYING ChangeLog README.quickstart.md" + for f in $src_files + do + cp -a "$SRC_ROOT/$f" "$DIST_ROOT/$PV" || die "failed to copy $f" + done + + # files not included + rm "$DIST_ROOT/$PV/doc/TODO" || die "failed rm TODO" +} + +make_tar() { + (cd "$DIST_ROOT"; tar cz "$PV") > "$BIN_DEST/${PV}.tgz" || die "tar failed" + note "tarball created at: $BIN_DEST/${PV}.tgz" +} + +# parse CLI options: +while [ -n "$1" ] +do + cmd="${1%%=*}" + val="${1#*=}" + [ "$1" = "$cmd" ] && val= + case "$cmd" in + --version) + [ -z "$val" ] && die "empty $cmd not allowed" + VERSION="$val" + ;; + --dist-root) + [ -z "$val" ] && die "empty $cmd not allowed" + DIST_ROOT="$val" + ;; + --src-root) + [ -z "$val" ] && die "empty $cmd not allowed" + SRC_ROOT="$val" + ;; + --bin-dest) + [ -z "$val" ] && die "empty $cmd not allowed" + BIN_DEST="$val" + ;; + --dist-clean) + DISTCLEAN=1 + ;; + help|-h|--help|-help) + usage + ;; + *) + die "Unknown option: $1" + ;; + esac + shift +done + +main