X-Git-Url: https://git.arvados.org/arvados-dev.git/blobdiff_plain/a4e96f869530a93545582f5a21ec0e6caa20bcd9..e88afb9fdcdd8b9659ad68021987fd71269d7ff4:/jenkins/run-library.sh diff --git a/jenkins/run-library.sh b/jenkins/run-library.sh index f07397f..69ebb08 100755 --- a/jenkins/run-library.sh +++ b/jenkins/run-library.sh @@ -2,6 +2,11 @@ # A library of functions shared by the various scripts in this directory. +# This is the timestamp about when we merged changed to include licenses +# with Arvados packages. We use it as a heuristic to add revisions for +# older packages. +LICENSE_PACKAGE_TS=20151208015500 + debug_echo () { echo "$@" >"$STDOUT_IF_DEBUG" } @@ -66,6 +71,49 @@ handle_ruby_gem() { fi } +# Usage: package_go_binary services/foo arvados-foo "Compute foo to arbitrary precision" +package_go_binary() { + local src_path="$1"; shift + local prog="$1"; shift + local description="$1"; shift + local license_file=${1:-agpl-3.0.txt}; shift + + debug_echo "package_go_binary $src_path as $prog" + + local basename="${src_path##*/}" + + mkdir -p "$GOPATH/src/git.curoverse.com" + ln -sfn "$WORKSPACE" "$GOPATH/src/git.curoverse.com/arvados.git" + + cd "$GOPATH/src/git.curoverse.com/arvados.git/$src_path" + local version=$(version_from_git) + local timestamp=$(timestamp_from_git) + + # If the command imports anything from the Arvados SDK, bump the + # version number and build a new package whenever the SDK changes. + if grep -qr git.curoverse.com/arvados .; then + cd "$GOPATH/src/git.curoverse.com/arvados.git/sdk/go" + if [[ $(timestamp_from_git) -gt "$timestamp" ]]; then + version=$(version_from_git) + fi + fi + + cd $WORKSPACE/packages/$TARGET + go get "git.curoverse.com/arvados.git/$src_path" + fpm_build "$GOPATH/bin/$basename=/usr/bin/$prog" "$prog" 'Curoverse, Inc.' dir "$version" "--url=https://arvados.org" "--license=GNU Affero General Public License, version 3.0" "--description=$description" "$WORKSPACE/$license_file=/usr/share/doc/$prog/$license_file" +} + +default_iteration() { + local package_name=$1; shift + local package_version=$1; shift + local iteration=1 + if [[ $package_version =~ ^0\.1\.([0-9]{14})(\.|$) ]] && \ + [[ ${BASH_REMATCH[1]} -le $LICENSE_PACKAGE_TS ]]; then + iteration=2 + fi + echo $iteration +} + # Build packages for everything fpm_build () { # The package source. Depending on the source type, this can be a @@ -125,6 +173,9 @@ fpm_build () { if [[ "$VERSION" != "" ]]; then COMMAND_ARR+=('-v' "$VERSION") fi + # We can always add an --iteration here. If another one is specified in $@, + # that will take precedence, as desired. + COMMAND_ARR+=(--iteration "$(default_iteration "$PACKAGE" "$VERSION")") # Append remaining function arguments directly to fpm's command line. for i; do @@ -183,3 +234,12 @@ fpm_verify () { echo "Error building package for $1:\n $FPM_RESULTS" fi } + +install_package() { + PACKAGES=$@ + if [[ "$FORMAT" == "deb" ]]; then + $SUDO apt-get install $PACKAGES --yes + elif [[ "$FORMAT" == "rpm" ]]; then + $SUDO yum -q -y install $PACKAGES + fi +}