Skip to content
Snippets Groups Projects
Commit 675c078e authored by Diego Giovane Pasqualin's avatar Diego Giovane Pasqualin
Browse files

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

parent b42394a6
Branches
No related tags found
No related merge requests found
...@@ -35,20 +35,27 @@ function copyDoc() { ...@@ -35,20 +35,27 @@ function copyDoc() {
cp "$COPYING" "$copyDir" cp "$COPYING" "$copyDir"
} }
# Update the package ($1) version based on $kind ($2), where $kind can be # Return package ($1) current version
# revision, minor, or major. function getPackageCurrentVersion() {
function updatePackageVersion () { 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 pkg=$1
local kind=$2 local kind=$2
local controlFile="$REPOROOT/$pkg/package/DEBIAN/control"
local version="" local version=""
local newVersion="" local newVersion=""
local major="" local major=""
local minor="" local minor=""
local revision="" local revision=""
version=$(grep "^Version:" $controlFile | awk '{print $2}') version=$(getPackageCurrentVersion $pkg)
major=$(echo $version | cut -d. -f1) major=$(echo $version | cut -d. -f1)
minor=$(echo $version | cut -d. -f2) minor=$(echo $version | cut -d. -f2)
...@@ -71,6 +78,16 @@ function updatePackageVersion () { ...@@ -71,6 +78,16 @@ function updatePackageVersion () {
newVersion="${major}.${minor}.${revision}" 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 sed -i -e "s/Version:.*/Version: $newVersion/" $controlFile
} }
...@@ -144,11 +161,17 @@ if test -z "$KIND"; then ...@@ -144,11 +161,17 @@ if test -z "$KIND"; then
KIND="revision" KIND="revision"
fi fi
if "$UPDATEVERSION" = true; then
newVersion=$(generateNewPackageVersion "$PKG" "$KIND")
else
newVersion=$(getPackageCurrentVersion "$PKG")
fi
# Run prebuild script # Run prebuild script
prebuild="$REPOROOT/$PKG/prebuild" prebuild="$REPOROOT/$PKG/prebuild"
if test -x "$prebuild"; then if test -x "$prebuild"; then
echo "Running prebuild script..." echo "Running prebuild script..."
if ! $prebuild; then if ! $prebuild $newVersion; then
echo "ERROR while running prebuild script." echo "ERROR while running prebuild script."
exit 5 exit 5
fi fi
...@@ -159,7 +182,7 @@ copyDoc "$PKG" ...@@ -159,7 +182,7 @@ copyDoc "$PKG"
# Update Version # Update Version
if test "$UPDATEVERSION" = "true"; then if test "$UPDATEVERSION" = "true"; then
updatePackageVersion "$PKG" "$KIND" updatePackageVersion "$PKG" "$newVersion"
fi fi
# Build Package # Build Package
...@@ -172,7 +195,7 @@ fi ...@@ -172,7 +195,7 @@ fi
postbuild="$REPOROOT/$PKG/postbuild" postbuild="$REPOROOT/$PKG/postbuild"
if test -x "$postbuild"; then if test -x "$postbuild"; then
echo "Running postbuild script..." echo "Running postbuild script..."
if ! $postbuild; then if ! $postbuild $newVersion; then
echo "ERROR while running postbuild script." echo "ERROR while running postbuild script."
exit 7 exit 7
fi fi
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment