build_package.sh: pass new package version to {pre,post}build scripts

Signed-off-by: 's avatarDiego Giovane Pasqualin <dpasqualin@c3sl.ufpr.br>
parent b42394a6
......@@ -35,20 +35,27 @@ function copyDoc() {
cp "$COPYING" "$copyDir"
}
# Update the package ($1) version based on $kind ($2), where $kind can be
# revision, minor, or major.
function updatePackageVersion () {
# Return package ($1) current version
function getPackageCurrentVersion() {
local pkg=$1
local controlFile="$REPOROOT/$pkg/package/DEBIAN/control"
version=$(grep "^Version:" $controlFile | awk '{print $2}')
echo $version
}
# Generate a new version of the package ($1) based on $kind ($2), where $kind
# can be revision, minor, or major.
function generateNewPackageVersion () {
local pkg=$1
local kind=$2
local controlFile="$REPOROOT/$pkg/package/DEBIAN/control"
local version=""
local newVersion=""
local major=""
local minor=""
local revision=""
version=$(grep "^Version:" $controlFile | awk '{print $2}')
version=$(getPackageCurrentVersion $pkg)
major=$(echo $version | cut -d. -f1)
minor=$(echo $version | cut -d. -f2)
......@@ -71,6 +78,16 @@ function updatePackageVersion () {
newVersion="${major}.${minor}.${revision}"
echo $newVersion
}
# Update the package ($1) control file with it's new version ($2).
function updatePackageVersion() {
local pkg=$1
local newVersion=$2
local controlFile="$REPOROOT/$pkg/package/DEBIAN/control"
sed -i -e "s/Version:.*/Version: $newVersion/" $controlFile
}
......@@ -144,11 +161,17 @@ if test -z "$KIND"; then
KIND="revision"
fi
if "$UPDATEVERSION" = true; then
newVersion=$(generateNewPackageVersion "$PKG" "$KIND")
else
newVersion=$(getPackageCurrentVersion "$PKG")
fi
# Run prebuild script
prebuild="$REPOROOT/$PKG/prebuild"
if test -x "$prebuild"; then
echo "Running prebuild script..."
if ! $prebuild; then
if ! $prebuild $newVersion; then
echo "ERROR while running prebuild script."
exit 5
fi
......@@ -159,7 +182,7 @@ copyDoc "$PKG"
# Update Version
if test "$UPDATEVERSION" = "true"; then
updatePackageVersion "$PKG" "$KIND"
updatePackageVersion "$PKG" "$newVersion"
fi
# Build Package
......@@ -172,7 +195,7 @@ fi
postbuild="$REPOROOT/$PKG/postbuild"
if test -x "$postbuild"; then
echo "Running postbuild script..."
if ! $postbuild; then
if ! $postbuild $newVersion; then
echo "ERROR while running postbuild script."
exit 7
fi
......
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