-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathrebuild.sh
executable file
·126 lines (104 loc) · 3.8 KB
/
rebuild.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/usr/bin/env bash
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
. "${SCRIPTDIR}/bin/includes/bashcolors.sh"
. "${SCRIPTDIR}/bin/includes/logging.sh"
. "${SCRIPTDIR}/bin/includes/fetchSource.sh"
. "${SCRIPTDIR}/bin/includes/compareOutput.sh"
. "${SCRIPTDIR}/bin/includes/rebuildToolMvn.sh"
. "${SCRIPTDIR}/bin/includes/rebuildToolSbt.sh"
. "${SCRIPTDIR}/bin/includes/rebuildToolGradle.sh"
. "${SCRIPTDIR}/bin/includes/displayResult.sh"
# ----------------------------------------------------------------------------------------------------
buildspec=$1
if [ -z "${buildspec}" ]
then
fatal "usage: rebuild.sh <file>.buildspec [staging|snapshot]"
fi
if [ -n "$2" ]
then
referenceRepo=https://repository.apache.org/content/repositories/$2/
fi
echo -e "Rebuilding from buildspec \033[1m${buildspec}\033[0m"
. ${buildspec} || fatal "could not source ${buildspec}"
# The defaults when unspecified
DEFAULT_locale="en_US"
DEFAULT_timezone="UTC"
DEFAULT_umask=0002
DEFAULT_referenceRepo="https://repo.maven.apache.org/maven2/"
DEFAULT_oci_engine="docker"
DEFAULT_docker_build_opts=""
DEFAULT_podman_build_opts="--format docker"
DEFAULT_docker_run_opts=""
DEFAULT_podman_run_opts="--userns=keep-id"
DEFAULT_oci_engine_volumeflags=""
DEFAULT_oci_engine_build_opts="$([[ 'docker' == ${RB_OCI_ENGINE:-$DEFAULT_oci_engine} ]] && echo $DEFAULT_docker_build_opts || echo $DEFAULT_podman_build_opts)"
DEFAULT_oci_engine_run_opts="$([[ 'docker' == ${RB_OCI_ENGINE:-$DEFAULT_oci_engine} ]] && echo $DEFAULT_docker_run_opts || echo $DEFAULT_podman_run_opts)"
echo "| 1. rebuild what binaries?"
displayOptional "referenceRepo" "$DEFAULT_referenceRepo"
displayMandatory "groupId"
displayMandatory "artifactId"
displayMandatory "version"
echo "| 2. from which sources?"
if [ -z "${sourceDistribution}" ]
then
displayMandatory "gitRepo"
displayMandatory "gitTag"
else
displayMandatory "sourceDistribution"
fi
echo "| 3. with which rebuild environment?"
displayMandatory "tool"
displayMandatory "jdk"
displayOptional "toolchains"
displayMandatory "newline"
displayOptional "timezone" "$DEFAULT_timezone"
displayOptional "locale" "$DEFAULT_locale"
displayOptional "umask" "$DEFAULT_umask"
displayOptional "os"
displayOptional "arch"
echo "| 4. how?"
displayMandatory "command"
[ -n "${RB_SHELL}" ] && RB_OCI_ENGINE="interactive shell"
displayOptional "RB_OCI_ENGINE" "$DEFAULT_oci_engine"
displayOptional "execBefore"
displayOptional "execAfter"
echo "| 5. expected results?"
displayMandatory "buildinfo"
displayOptional "diffoscope"
displayOptional "issue"
[ -z "${timezone}" ] && timezone=$DEFAULT_timezone
[ -z "${locale}" ] && locale=$DEFAULT_locale
[ -z "${umask}" ] && umask=$DEFAULT_umask
[ -z "${RB_OCI_ENGINE}" ] && export RB_OCI_ENGINE=$DEFAULT_oci_engine
[ -z "${RB_OCI_ENGINE_BUILD_OPTS}" ] && export RB_OCI_ENGINE_BUILD_OPTS=$DEFAULT_oci_engine_build_opts
[ -z "${RB_OCI_ENGINE_RUN_OPTS}" ] && export RB_OCI_ENGINE_RUN_OPTS=$DEFAULT_oci_engine_run_opts
[ -z "${RB_OCI_VOLUME_FLAGS}" ] && export RB_OCI_VOLUME_FLAGS=$DEFAULT_oci_engine_volume_flags
base="$SCRIPTDIR"
pushd "$(dirname ${buildspec})" >/dev/null || fatal "Could not move into ${buildspec}"
echo
# set umask for the script execution itself because Git updates are better with target umask
umask $umask
export MVN_UMASK=${umask}
fetchSource
[ -n "$execBefore" ] && info "executing before command: $execBefore" && eval "$execBefore"
echo
case ${tool} in
mvn*)
rebuildToolMvn
;;
sbt)
rebuildToolSbt
;;
gradle)
rebuildToolGradle
;;
*)
fatal "build tool not yet supported: ${tool}"
esac
echo
displayResult
displayOptional "os"
displayOptional "arch"
[ -n "$execAfter" ] && info "executing after command: $execAfter" && eval "$execAfter"
#git reset --hard
popd > /dev/null || fatal "Unable to return to starting directory"