Browse Source

Drop $sources support and default with $BASE_PATH to $WORKSPACE

The support for $sources was introduced before $BASE_PATH was
available and kept as alternative to provide even more
flexibility. BASE_PATH is the way to go and there's no reason to
support $sources any longer, especially since it makes the code
more confusing than necessary. Therefore let's get rid of
$sources and finally point BASE_PATH to $WORKSPACE by default. If
$sources is still set then inform the user about it.

closes #14
merge-requests/109/head
Michael Prokop 10 years ago
parent
commit
24ad13fa51
  1. 6
      README.org
  2. 75
      scripts/build-and-provide-package

6
README.org

@ -125,7 +125,6 @@ In the "/Build/" section add a build step "/Execute shell/" using:
REPOS="${JOB_NAME%-binaries*}"
/usr/bin/generate-reprepro-codename "${REPOS}"
export BASE_PATH="${WORKSPACE}"
/usr/bin/build-and-provide-package
#+END_EXAMPLE
@ -203,9 +202,7 @@ Then you should get test reports for your Debian packages based on lintian's out
+ /release/: install Debian package in repository name as specified via "$release" instead of the default (being $REPOS), see "/Can I collect multiple Debian packages in one single repository?/" in the FAQ section for further details.
+ /sources/: use specified directory as base directory for locating Debian source files. Useful if you use a customized "Target directory" in the "Copy artifacts from another project" configuration and do not want to/can't use /BASE_PATH/. (Note: this variable might get removed soon. It's NOT identical to /BASE_PATH/, this is a known issue.)
+ /BASE_PATH/: use specified directory as base directory for further actions. Just set it to "${WORKSPACE}" if you don't have a customized "Target directory" in the "Copy artifacts from another project" configuration, otherwise adopt as necessary. (Note: not identical to /sources/, this is a known issue.)
+ /BASE_PATH/: use specified directory as base directory for further actions. Just set it to "${WORKSPACE}" if you don't have a customized "Target directory" in the "Copy artifacts from another project" configuration, otherwise adopt as necessary.
+ /BUILD_ONLY/: execute the steps building Debian binary package(s) but skip the repository setup/inclusion steps (useful for building the package(s) on slave nodes and including the result on a different node later then)
@ -308,7 +305,6 @@ sudo /usr/bin/generate-reprepro-codename "${REPOS}"
export BUILD_ONLY=true
export SUDO_CMD=sudo
export BASE_PATH="${WORKSPACE}"
/usr/bin/build-and-provide-package
#+END_EXAMPLE

75
scripts/build-and-provide-package

@ -48,11 +48,6 @@ bailout() {
[ -n "${1:-}" ] && EXIT="${1}" || EXIT=0
[ -n "${2:-}" ] && echo "$2" >&2
if [ -n "${sources:-}" ] && [ "${sources:-}" != "unset" ] ; then
echo "*** Removing sources file. ***"
rm -f "${sources}/"*
fi
echo "*** Getting rid of files in $WORKSPACE/binaries/ to avoid problems in next run. ***"
rm -f "$WORKSPACE"/binaries/*
@ -75,15 +70,12 @@ identify_package_name() {
}
set_base_path() {
# when BASE_PATH is set in the build step then don't assume a default,
# this is useful when building on slave nodes, being used like:
# export BASE_PATH="$WORKSPACE/${JOB_NAME%-binaries/*}-source/"
# when BASE_PATH is set in the build step then don't default to $WORKSPACE
if [ -n "${BASE_PATH:-}" ] ; then
echo "*** Using provided ${BASE_PATH} as BASE_PATH ***"
else
BASE_PATH="${WORKSPACE}"
echo "*** Using \$WORKSPACE [$BASE_PATH] as default BASE_PATH ***"
echo "*** Using \$WORKSPACE [$BASE_PATH] as default for BASE_PATH ***"
fi
}
@ -105,52 +97,33 @@ build_info() {
}
identify_sourcefile() {
if [ -n "${sources:-}" ]; then
echo "*** Variable \$sources set, using it for locating source files. ***"
if [ -z "${distribution:-}" ]; then
sourcefile=$(echo "${sources}/"*.dsc)
else
sourcefile=$(echo "${sources}/distribution=${distribution}/"*.dsc)
fi
if [ -n "${sources:-}" ] ; then
echo "*** WARNING: sources variable [$sources] is set, please use BASE_PATH variable instead ***"
echo "*** If \$sources is unrelated to build-and-provide-package you can ignore this warning ***"
fi
if [ "$sourcefile" = 'sources/*.dsc' ] ; then
bailout 1 "Error: no sourcefile (*.dsc) found. Exiting."
fi
echo "*** Identifying newest package version ***"
newest_version="0"
case "$sourcefile" in
*\ *) echo "*** Multiple source files (*.dsc) present in $(pwd): ***"
ls -la "${sources}/"
bailout 1 "Error: Please re-run source job to force clean rebuild."
;;
esac
p="$(basename $sourcefile .dsc)"
newest_version="${p#*_}"
SOURCE_PACKAGE="*" # FIXME: SOURCE_PACKAGE is used by identify_build_type
else
sources="unset"
echo "*** Identifying newest package version ***"
newest_version="0"
for file in "${BASE_PATH}/"*.dsc ; do
SOURCE_PACKAGE="$(awk '/^Source: / {print $2}' $file)"
p="$(basename $file .dsc)"
if [ "$p" = '*' ] ; then
bailout 1 "Error: No source package found (forgot to configure source files deployment?)"
fi
cur_version="${p#*_}"
if dpkg --compare-versions "${cur_version}" gt "${newest_version}" ; then
newest_version="${cur_version}"
else
base_version="${cur_version}"
fi
done
for file in "${BASE_PATH}/"*.dsc ; do
SOURCE_PACKAGE="$(awk '/^Source: / {print $2}' $file)"
p="$(basename $file .dsc)"
if [ "$p" = '*' ] ; then
bailout 1 "Error: No source package found (forgot to configure source files deployment?)"
fi
cur_version="${p#*_}"
if dpkg --compare-versions "${cur_version}" gt "${newest_version}" ; then
newest_version="${cur_version}"
else
base_version="${cur_version}"
fi
done
echo "*** Found package version $newest_version ***"
echo "*** Found package version $newest_version ***"
sourcefile="${BASE_PATH}/${SOURCE_PACKAGE}"_*"${newest_version}".dsc
fi
sourcefile="${BASE_PATH}/${SOURCE_PACKAGE}"_*"${newest_version}".dsc
echo "*** Using $sourcefile (version: ${newest_version}) [sources: $sources]"
echo "*** Using $sourcefile (version: ${newest_version})"
}
dist_and_arch_settings() {

Loading…
Cancel
Save