X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/2774e45aba64557259fc35155c62988449a8dc72..a344ad38e66d12b94aa7bc3a53f64c343e6fc0e6:/build/run-library.sh diff --git a/build/run-library.sh b/build/run-library.sh index e0b7a0b974..f09071cee7 100755 --- a/build/run-library.sh +++ b/build/run-library.sh @@ -10,6 +10,8 @@ # older packages. LICENSE_PACKAGE_TS=20151208015500 +librarydir=`dirname "$(readlink -f "$0")"` + if [[ -z "$ARVADOS_BUILDING_VERSION" ]]; then RAILS_PACKAGE_ITERATION=1 else @@ -40,27 +42,24 @@ EOF format_last_commit_here() { local format="$1"; shift - TZ=UTC git log -n1 --first-parent "--format=format:$format" . + local dir="${1:-.}"; shift + TZ=UTC git log -n1 --first-parent "--format=format:$format" "$dir" } version_from_git() { # Output the version being built, or if we're building a # dev/prerelease, output a version number based on the git log for - # the current working directory. + # the given $subdir. + local minorversion="$1"; shift # unused + local subdir="$1"; shift if [[ -n "$ARVADOS_BUILDING_VERSION" ]]; then echo "$ARVADOS_BUILDING_VERSION" return fi - local git_ts git_hash prefix - if [[ -n "$1" ]] ; then - prefix="$1" - else - prefix="0.1" - fi - - declare $(format_last_commit_here "git_ts=%ct git_hash=%h") - ARVADOS_BUILDING_VERSION="$(git tag -l |sort -V -r |head -n1).$(date -ud "@$git_ts" +%Y%m%d%H%M%S)" + local git_ts git_hash + declare $(format_last_commit_here "git_ts=%ct git_hash=%h" "$subdir") + ARVADOS_BUILDING_VERSION="$($librarydir/version-at-commit.sh $git_hash)" echo "$ARVADOS_BUILDING_VERSION" } @@ -73,7 +72,8 @@ nohash_version_from_git() { } timestamp_from_git() { - format_last_commit_here "%ct" + local subdir="$1"; shift + format_last_commit_here "%ct" "$subdir" } handle_python_package () { @@ -104,33 +104,36 @@ handle_ruby_gem() { } calculate_go_package_version() { + # $__returnvar has the nameref attribute set, which means it is a reference + # to another variable that is passed in as the first argument to this function. + # see https://www.gnu.org/software/bash/manual/html_node/Shell-Parameters.html local -n __returnvar="$1"; shift - local src_path="$1"; shift - - 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" && "$GOPATH/bin/govendor" sync -v) + local oldpwd="$PWD" - cd "$GOPATH/src/git.curoverse.com/arvados.git/$src_path" - local version="$(version_from_git)" - local timestamp="$(timestamp_from_git)" + cd "$WORKSPACE" + go mod download # Update the version number and build a new package if the vendor # bundle has changed, or the command imports anything from the # Arvados SDK and the SDK has changed. - declare -a checkdirs=(vendor) - if grep -qr git.curoverse.com/arvados .; then + declare -a checkdirs=(go.mod go.sum) + while [ -n "$1" ]; do + checkdirs+=("$1") + shift + done + if grep -qr git.arvados.org/arvados .; then checkdirs+=(sdk/go lib) fi + local timestamp=0 for dir in ${checkdirs[@]}; do - cd "$GOPATH/src/git.curoverse.com/arvados.git/$dir" - ts="$(timestamp_from_git)" + cd "$WORKSPACE" + ts="$(timestamp_from_git "$dir")" if [[ "$ts" -gt "$timestamp" ]]; then - version=$(version_from_git) + version=$(version_from_git "" "$dir") timestamp="$ts" fi done - + cd "$oldpwd" __returnvar="$version" } @@ -161,7 +164,7 @@ package_go_binary() { return 1 fi - go get -ldflags "-X main.version=${go_package_version}" "git.curoverse.com/arvados.git/$src_path" + go get -ldflags "-X git.arvados.org/arvados.git/lib/cmd.version=${go_package_version} -X main.version=${go_package_version}" "git.arvados.org/arvados.git/$src_path" local -a switches=() systemd_unit="$WORKSPACE/${src_path}/${prog}.service" @@ -206,6 +209,20 @@ _build_rails_package_scripts() { done } +rails_package_version() { + local pkgname="$1"; shift + local srcdir="$1"; shift + if [[ -n "$ARVADOS_BUILDING_VERSION" ]]; then + echo "$ARVADOS_BUILDING_VERSION" + return + fi + local version="$(version_from_git)" + if [ $pkgname = "arvados-api-server" -o $pkgname = "arvados-workbench" ] ; then + calculate_go_package_version version cmd/arvados-server "$srcdir" + fi + echo $version +} + test_rails_package_presence() { local pkgname="$1"; shift local srcdir="$1"; shift @@ -218,7 +235,7 @@ test_rails_package_presence() { cd $srcdir - local version="$(version_from_git)" + local version="$(rails_package_version "$pkgname" "$srcdir")" cd $tmppwd @@ -232,6 +249,9 @@ get_complete_package_name() { set +e trap 'set -e' RETURN fi + # $__returnvar has the nameref attribute set, which means it is a reference + # to another variable that is passed in as the first argument to this function. + # see https://www.gnu.org/software/bash/manual/html_node/Shell-Parameters.html local -n __returnvar="$1"; shift local pkgname="$1"; shift local version="$1"; shift @@ -293,7 +313,9 @@ test_package_presence() { # sure it gets picked up by the test and/or upload steps. # Get the list of packages from the repos - if [[ "$FORMAT" == "deb" ]]; then + if [[ "$FORCE_BUILD" == "1" ]]; then + echo "Package $full_pkgname build forced with --force-build, building" + elif [[ "$FORMAT" == "deb" ]]; then declare -A dd dd[debian9]=stretch dd[debian10]=buster @@ -306,11 +328,11 @@ test_package_presence() { repo_subdir=${pkgname:0:1} fi - repo_pkg_list=$(curl -s -o - http://apt.arvados.org/pool/${D}/main/${repo_subdir}/) - echo ${repo_pkg_list} |grep -q ${full_pkgname} + repo_pkg_list=$(curl -s -o - http://apt.arvados.org/pool/${D}-dev/main/${repo_subdir}/${pkgname}/) + echo "${repo_pkg_list}" |grep -q ${full_pkgname} if [ $? -eq 0 ] ; then echo "Package $full_pkgname exists upstream, not rebuilding, downloading instead!" - curl -s -o "$WORKSPACE/packages/$TARGET/${full_pkgname}" http://apt.arvados.org/pool/${D}/main/${repo_subdir}/${full_pkgname} + curl -s -o "$WORKSPACE/packages/$TARGET/${full_pkgname}" http://apt.arvados.org/pool/${D}-dev/main/${repo_subdir}/${pkgname}/${full_pkgname} return 1 elif test -f "$WORKSPACE/packages/$TARGET/processed/${full_pkgname}" ; then echo "Package $full_pkgname exists, not rebuilding!" @@ -347,7 +369,7 @@ handle_rails_package() { local srcdir="$1"; shift cd "$srcdir" local license_path="$1"; shift - local version="$(version_from_git)" + local version="$(rails_package_version "$pkgname" "$srcdir")" echo "$version" >package-build.version local scripts_dir="$(mktemp --tmpdir -d "$pkgname-XXXXXXXX.scripts")" && \ (