Commit 070e19dc authored by Thomas Haller's avatar Thomas Haller

contrib/build: cleanup build.sh script and improve build_clean.sh

Signed-off-by: Thomas Haller's avatarThomas Haller <thaller@redhat.com>
parent 78570431
#!/bin/bash
set -vx
#set -vx
die() {
echo "$*" >&2
......@@ -67,9 +67,15 @@ VERSION="${VERSION:-$(get_version || die "Could not read $VERSION")}"
COMMIT="${COMMIT:-$(git rev-parse --verify HEAD | sed 's/^\(.\{10\}\).*/\1/' || die "Error reading HEAD revision")}"
USERNAME="${USERNAME:-"$(git config user.name) <$(git config user.email)>"}"
SPECFILE="$(abs_path "$SPECFILE" "$SCRIPTDIR/NetworkManager.spec")"
_SOURCE="$SOURCE"
SOURCE="$(abs_path "$SOURCE" "$(ls -1 "$GITDIR/NetworkManager-$VERSION"*.tar* 2>/dev/null | head -n1)")"
[[ -f "$SOURCE" ]] || die "could not find source ${_SOURCE:-$GITDIR/NetworkManager-$VERSION*.tar*} . Did you execute \`make dist\`? Otherwise set \$SOURCE variable"
SOURCE_NETWORKMANAGER_CONF="$(abs_path "$SOURCE_NETWORKMANAGER_CONF" "$SCRIPTDIR/NetworkManager.conf")"
SOURCE_SERVER_CONF="$(abs_path "$SOURCE_SERVER_CONF" "$SCRIPTDIR/00-server.conf")"
TEMP="$(mktemp -d "$SCRIPTDIR/NetworkManager.$DATE.XXXXXX")"
TEMPBASE="$(basename "$TEMP")"
LOG "UUID=$UUID"
LOG "VERSION=$VERSION"
LOG "RELEASE_VERSION=$RELEASE_VERSION"
......@@ -79,10 +85,7 @@ LOG "SPECFILE=$SPECFILE"
LOG "SOURCE=$SOURCE"
LOG "SOURCE_NETWORKMANAGER_CONF=$SOURCE_NETWORKMANAGER_CONF"
LOG "SOURCE_SERVER_CONF=$SOURCE_SERVER_CONF"
TEMP="$(mktemp -d "$SCRIPTDIR/NetworkManager.$DATE.XXXXXX")"
TEMPBASE="$(basename "$TEMP")"
echo "BASEDIR=$TEMP"
LOG "BASEDIR=$TEMP"
ln -snf "$TEMPBASE" ./latest0
ln "$BUILDLOG" "$TEMPBASE/build.log"
......@@ -98,9 +101,9 @@ cp "$SOURCE_SERVER_CONF" "$TEMP/SOURCES/00-server.conf" || die "Could not copy s
write_changelog
sed -e "s/__VERSION__/$VERSION/g" \
-e "s/__RELEASE_VERSION__/$RELEASE_VERSION/g" \
-e "s/__COMMIT__/$COMMIT/g" \
-e "s/__SOURCE1__/$(basename "$SOURCE")/g" \
-e "s/__RELEASE_VERSION__/$RELEASE_VERSION/g" \
"$SPECFILE" |
sed -e "/^__CHANGELOG__$/ \
{
......@@ -110,7 +113,16 @@ sed -e "/^__CHANGELOG__$/ \
rpmbuild --define "_topdir $TEMP" -ba "$TEMPSPEC" || die "ERROR: rpmbuild FAILED"
ls -la "$TEMP"/RPMS/*/*.rpm "$TEMP"/SRPMS/*.rpm
ln -snf "$TEMPBASE" ./latest
TEMP_LATEST="$(readlink -f .)"/latest
LOG
LOG
LOG "Finished with success."
LOG
LOG "See \"$TEMP_LATEST/\" which symlinks to \"$TEMPBASE\""
LOG
LOG "Result:"
ls -dla "$TEMP_LATEST" "$(dirname "$TEMP_LATEST")/$TEMPBASE/" "$TEMP_LATEST"/RPMS/*/ "$TEMP_LATEST"/RPMS/*/*.rpm "$TEMP_LATEST"/SRPMS/ "$TEMP_LATEST"/SRPMS/*.rpm | sed 's/^/ /'
......@@ -6,9 +6,11 @@ die() {
exit 1
}
# copy output also to logfile
LOG() {
echo "$*"
usage() {
echo "USAGE: $0 [-h|--help|-?|help]"
echo
echo "Does all the steps from a clean working directory to an RPM of NetworkManager"
echo
}
......@@ -21,16 +23,49 @@ GITDIR="$(cd "$SCRIPTDIR" && git rev-parse --show-toplevel || die "Could not get
cd "$GITDIR" || die "could not change to $GITDIR"
# check for a clean working directory.
# We ignore the /contrib directory, because this is where the automation
# scripts and the build results will be.
if [[ "x$(git clean -ndx | grep '^Would remove contrib/.*$' -v)" != x ]]; then
die "The working copy is not clean. Refuse to run. Try git clean -e /contrib -dx -n"
IGNORE_DIRTY=0
GIT_CLEAN=0
for A; do
case "$A" in
-h|--help|-\?|help)
usage
exit 0
;;
-f|--force)
IGNORE_DIRTY=1
;;
-c|--clean)
GIT_CLEAN=1
;;
*)
usage
die "Unexpected argument \"$A\""
;;
esac
done
if [[ $GIT_CLEAN == 1 ]]; then
git clean -fdx :/
fi
if [[ $IGNORE_DIRTY != 1 ]]; then
# check for a clean working directory.
# We ignore the /contrib directory, because this is where the automation
# scripts and the build results will be.
if [[ "x$(git clean -ndx | grep '^Would remove contrib/.*$' -v)" != x ]]; then
die "The working directory is not clean. Refuse to run. Try git clean -e /contrib -dx -n"
fi
if [[ "x$(git status --porcelain)" != x ]]; then
die "The working directory has local changes. Refuse to run. Try $0 --force"
fi
fi
./autogen.sh --enable-gtk-doc || die "Error autogen.sh"
make -j 10 || die "Error make"
make distcheck || die "Error make distcheck"
"$SCRIPTDIR"/build.sh
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment