summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2014-05-31 15:31:42 +0200
committerThomas Haller <thaller@redhat.com>2014-05-31 19:27:42 +0200
commit070e19dc3181502e4aa88cfd13ced8622838cbd4 (patch)
tree194d1ff06afa13ce8d7cbce7a90261bfc0d2daab
parent785704319563e69b0e0831510c35e9fc13ace956 (diff)
downloadNetworkManager-070e19dc3181502e4aa88cfd13ced8622838cbd4.tar.gz
contrib/build: cleanup build.sh script and improve build_clean.sh
Signed-off-by: Thomas Haller <thaller@redhat.com>
-rwxr-xr-xcontrib/fedora/rpm/build.sh28
-rwxr-xr-xcontrib/fedora/rpm/build_clean.sh51
2 files changed, 63 insertions, 16 deletions
diff --git a/contrib/fedora/rpm/build.sh b/contrib/fedora/rpm/build.sh
index f266ff25c4..68439a4ada 100755
--- a/contrib/fedora/rpm/build.sh
+++ b/contrib/fedora/rpm/build.sh
@@ -1,6 +1,6 @@
#!/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/^/ /'
+
diff --git a/contrib/fedora/rpm/build_clean.sh b/contrib/fedora/rpm/build_clean.sh
index 89505e8946..af3465fe41 100755
--- a/contrib/fedora/rpm/build_clean.sh
+++ b/contrib/fedora/rpm/build_clean.sh
@@ -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
+