Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions helpers/build_packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ Usage: $0 [OPTION]..."
-v, --version build droid-hal-version
-i, --mic build image
-b, --build=PKG build one package (PKG can include path)
-r, --revision=REV optionally used with -m
build package version from a specific git tag or commit hash
-s, --spec=SPEC optionally used with -m or -b
can be supplied multiple times to build multiple .spec files at once
-D, --do-not-install
Expand All @@ -59,7 +61,7 @@ EOF
exit 1
}

OPTIONS=$(getopt -o hdcm::gvib:s:DonN -l help,droid-hal,configs,mw::,gg,version,mic,build:,spec:,do-not-install,offline,no-delete,no-auto-version -- "$@")
OPTIONS=$(getopt -o hdcm::gvib:r:s:DonN -l help,droid-hal,configs,mw::,gg,version,mic,build:,revision:,spec:,do-not-install,offline,no-delete,no-auto-version -- "$@")

if [ $? -ne 0 ]; then
echo "getopt error"
Expand Down Expand Up @@ -98,6 +100,11 @@ while true; do
*) BUILDPKG_PATH=$2;;
esac
shift;;
-r|--revision) BUILDREV=1
case "$2" in
*) BUILDREV_ARGS="-r $2";;
esac
shift;;
-s|--spec) BUILDSPEC=1
case "$2" in
*) BUILDSPEC_FILE+=("$2");;
Expand Down Expand Up @@ -228,10 +235,10 @@ if [ "$BUILDMW" = "1" ]; then
# No point in asking when only one mw package is being built
BUILDMW_QUIET=1
if [ -z "$BUILDSPEC_FILE" ]; then
buildmw -u "$BUILDMW_REPO" || die
buildmw -u "$BUILDMW_REPO" $BUILDREV_ARGS || die
else
# Supply all given spec files from $BUILDSPEC_FILE array prefixed with "-s"
buildmw -u "$BUILDMW_REPO" "${BUILDSPEC_FILE[@]/#/-s }" || die
buildmw -u "$BUILDMW_REPO" "${BUILDSPEC_FILE[@]/#/-s }" $BUILDREV_ARGS || die
fi
elif [ -n "$manifest" ] &&
grep -ql hybris/mw $manifest; then
Expand Down
16 changes: 13 additions & 3 deletions helpers/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -205,22 +205,25 @@ buildmw() {
# git repo is already present in $ANDROID_ROOT/external/* and
# re-use that one.
# -b Branch to use. If none supplied, use default.
# -r Git revision to use. Can either be a tag or a commit hash.
# -s .spec file to use. Can be supplied multiple times.
# If empty, will use all .spec files from $PKG/rpm/*.
# -N Tell mb2 to not fix the version inside a spec file.

local GIT_URL=""
local GIT_BRANCH=""
local GIT_REVISION=""
local MW_BUILDSPEC=""
# Use global override, if defined
local NO_AUTO_VERSION=$NO_AUTO_VERSION
# This is important for getopt or it will fail on the second invocation!
local OPTIND
while getopts 'u:b:s:N' _flag
while getopts 'u:b:r:s:N' _flag
do
case "${_flag}" in
u) GIT_URL="$OPTARG" ;;
b) GIT_BRANCH="-b $OPTARG" ;;
r) GIT_REVISION="$OPTARG" ;;
s) MW_BUILDSPEC+="$OPTARG " ;;
N) NO_AUTO_VERSION=--no-fix-version ;;
*) echo "buildmw(): Unexpected option $_flag"; exit 1; ;;
Expand Down Expand Up @@ -264,8 +267,15 @@ buildmw() {

pushd $PKG > /dev/null || die
if [[ "$BUILDOFFLINE" = "" && "$PKG" != *"-localbuild" ]]; then
minfo "pulling updates..."
git pull >>$LOG 2>&1|| die "pulling of updates failed"
if [ -z "$GIT_REVISION" ]; then
minfo "pulling updates..."
git pull --recurse-submodules >>$LOG 2>&1|| die "pulling of updates failed"
else
git diff-index --quiet HEAD -- || die "Package $PKG has uncommitted changes, please commit first, refusing to reset version"
minfo "setting version to $GIT_REVISION..."
git fetch >>$LOG 2>&1
git reset --hard $GIT_REVISION --recurse-submodules >>$LOG 2>&1|| die "version reset failed"
fi
fi
fi

Expand Down