2121# Flag to show help text
2222show_help=false
2323
24+ # Workspace path
25+ workspace_path=" "
26+
2427# Using remote git repository variables
2528use_remote=false
2629git_remote=" "
@@ -65,6 +68,16 @@ while [ -n "$1" ]; do
6568 fi
6669 ;;
6770
71+ --workspace-path)
72+ if [ -n " $workspace_path " ]; then
73+ echo " Error: you have already entered value for --workspace-path"
74+ exit 1
75+ else
76+ workspace_path=$2
77+ shift 2
78+ fi
79+ ;;
80+
6881 -h | --help)
6982 if [ $show_help = true ]; then
7083 echo " Error: you have already entered -h, --help"
8598
8699set -- $PKG_ARGS
87100
101+ # use '/mnt/build/cloudstack' as default workspace path
102+ if [ -z " $workspace_path " ]; then
103+ workspace_path=" /mnt/build/cloudstack"
104+ fi
105+
88106# Both of --git-remote AND --git-ref must be specified at the same time
89107if [ $use_remote = true ]; then
90108 if [ -z " $git_remote " -o -z " $git_ref " ]; then
99117# 2) cloudstack directory is NOT provided and git remote and ref are provided
100118#
101119# Any combination of the above situations is invalid.
102- if [ -d " /mnt/build/cloudstack " ]; then
120+ if [ -d " ${workspace_path} " ]; then
103121 if [ $use_remote = true ]; then
104122 if [ $remove_first = false ]; then
105- echo " Error: Could not clone remote git repository, '/mnt/build/cloudstack ' exists"
123+ echo " Error: Could not clone remote git repository, '${workspace_path} ' exists"
106124 exit 1
107125 else
108- echo " Removing /mnt/build/cloudstack ..."
109- rm -rf /mnt/build/cloudstack
126+ echo " Removing ${workspace_path} ..."
127+ rm -rf ${workspace_path}
110128 echo -e " \n--------\n"
111129 fi
112130 fi
113131else
114132 if [ $use_remote = false ]; then
115- echo " Could not find '/mnt/build/cloudstack '"
133+ echo " Could not find '${workspace_path} '"
116134 exit 1
117135 fi
118136fi
@@ -156,9 +174,9 @@ echo -e "\n--------\n"
156174# Clone the remote provided git repo and ref
157175if [ $use_remote = true ]; then
158176 echo " Cloning $git_remote ..."
159- git clone --quiet --depth=50 $git_remote /mnt/build/cloudstack
177+ git clone --quiet --depth=50 $git_remote ${workspace_path}
160178
161- cd /mnt/build/cloudstack
179+ cd ${workspace_path}
162180
163181 echo " Fetching $git_ref ..."
164182 git fetch --quiet origin +$git_ref :
@@ -170,14 +188,14 @@ if [ $use_remote = true ]; then
170188fi
171189
172190# Make sure build-deb.sh script exists before going any further
173- if [ ! -f " /mnt/build/cloudstack /packaging/build-deb.sh" ]; then
174- echo " Could not find '/mnt/build/cloudstack /packaging/build-deb.sh'"
191+ if [ ! -f " ${workspace_path} /packaging/build-deb.sh" ]; then
192+ echo " Could not find '${workspace_path} /packaging/build-deb.sh'"
175193 exit 1
176194fi
177195
178196# convert LONG flags to SHORT flags for anything prior 4.12.x.x
179197echo " Detecting CloudStack version ..."
180- pom_version=$( cd /mnt/build/cloudstack ; mvn -q -Dexec.executable=" echo" -Dexec.args=' ${project.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.3.1:exec)
198+ pom_version=$( cd ${workspace_path} ; mvn -q -Dexec.executable=" echo" -Dexec.args=' ${project.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.3.1:exec)
181199echo " ${pom_version} "
182200major_version=$( echo ${pom_version} | cut -d. -f1)
183201minor_version=$( echo ${pom_version} | cut -d. -f2)
@@ -189,10 +207,10 @@ if [ $major_version -lt 4 ] || [ $major_version -eq 4 -a $minor_version -lt 12 ]
189207 fi
190208fi
191209
192- # Show help, both from docker-entrypoint.sh and /mnt/build/cloudstack /packaging/build-deb.sh
210+ # Show help, both from docker-entrypoint.sh and ${workspace_path} /packaging/build-deb.sh
193211if [ $show_help = true ]; then
194212 if [ -n " $HELP_ARG " ]; then
195- help=$( cd /mnt/build/cloudstack /packaging; bash -x ./build-deb.sh $HELP_ARG )
213+ help=$( cd ${workspace_path} /packaging; bash -x ./build-deb.sh $HELP_ARG )
196214 else
197215 help=" "
198216 fi
@@ -205,7 +223,8 @@ packaging script on in.
205223Optional arguments:
206224 --git-remote string Set the git remote repository to clone (must be set together with \` --git-ref\` ) (default: none)
207225 --git-ref string Set the ref from remote repository to check out (must be set together with \` --git-remote\` ) (default: none)
208- --remove-first Remove existing \` /mnt/build/cloudstack\` directory before cloning (default: false)
226+ --remove-first Remove existing \` ${workspace_path} \` directory before cloning (default: false)
227+ --workspace-path string Set the directory path of workspace to work with (default: \` /mnt/build/cloudstack\` )
209228
210229Other arguments:
211230 -h, --help Display this help message and exit
226245function adjust_owner() {
227246 # if both set then change the owner
228247 if [ -n " ${USER_ID} " -a -z " ${USER_GID} " ]; then
229- chown -R ${USER_ID} /mnt/build/cloudstack
248+ chown -R ${USER_ID} ${workspace_path}
230249 elif [ -n " ${USER_ID} " -a -n " ${USER_GID} " ]; then
231- chown -R ${USER_ID} :${USER_GID} /mnt/build/cloudstack
250+ chown -R ${USER_ID} :${USER_GID} ${workspace_path}
232251 fi
233252}
234253
235254{
236- cd /mnt/build/cloudstack /packaging
255+ cd ${workspace_path} /packaging
237256
238257 # do the packaging
239258 bash -x ./build-deb.sh $@ && {
240- mkdir -p /mnt/build/cloudstack /dist/debbuild/DEBS
259+ mkdir -p ${workspace_path} /dist/debbuild/DEBS
241260
242- cp /mnt/build/ cloudstack-* .deb /mnt/build/cloudstack /dist/debbuild/DEBS
243- cp /mnt/build/ cloudstack_* .changes /mnt/build/cloudstack /dist/debbuild/DEBS
261+ cp ${workspace_path} /../ cloudstack-* .deb ${workspace_path} /dist/debbuild/DEBS
262+ cp ${workspace_path} /../ cloudstack_* .changes ${workspace_path} /dist/debbuild/DEBS
244263
245264 adjust_owner
246265 }
0 commit comments