summaryrefslogtreecommitdiff
path: root/linux/deb/02-fs-spring-boot-kamal/build.sh
diff options
context:
space:
mode:
authorKamal Wickramanayake <kamal@inbox.lk>2026-05-23 16:07:26 +0530
committerKamal Wickramanayake <kamal@inbox.lk>2026-05-23 16:07:26 +0530
commit161707cc2eab1d76a15684ef105bf1e2ecca154d (patch)
tree8db86611eaaeda22977d8ac71af0843ffc8a4aa5 /linux/deb/02-fs-spring-boot-kamal/build.sh
parented1837534a0a9a1ab8f8291cff73be031a5d493b (diff)
Added a Spring Boot app packaged deb file creation sample project to linux/deb directory
Diffstat (limited to 'linux/deb/02-fs-spring-boot-kamal/build.sh')
-rwxr-xr-xlinux/deb/02-fs-spring-boot-kamal/build.sh36
1 files changed, 36 insertions, 0 deletions
diff --git a/linux/deb/02-fs-spring-boot-kamal/build.sh b/linux/deb/02-fs-spring-boot-kamal/build.sh
new file mode 100755
index 0000000..bd2fc95
--- /dev/null
+++ b/linux/deb/02-fs-spring-boot-kamal/build.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+# Define a function that sends messages to stderr.
+errcho() {
+ echo "$@" 1>&2;
+}
+
+# Check if fakeroot command is available
+if ! command -v fakeroot > /dev/null 2>&1; then
+ errcho "[ERROR] fakeroot command not found. Install the fakeroot package.";
+ exit 1
+fi
+
+# Check if dpkg-deb command is available
+if ! command -v dpkg-deb > /dev/null 2>&1; then
+ errcho "[ERROR] dpkg-deb command not found. dpkg package contains it. Are you not running this script on a Debian based system?";
+ exit 1
+fi
+
+# Get the directory of this script
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+
+# Check if the spring boot jar is in the correct location
+if [ ! -f $DIR/package/opt/fs-spring-boot-kamal/app/fs-spring-boot-kamal.jar ]; then
+ errcho "[ERROR] Jar file missing: $DIR/package/opt/fs-spring-boot-kamal/app/fs-spring-boot-kamal.jar"
+ errcho "[ERROR] Run this build script only after placing the jar file in that location."
+ exit 1
+fi
+
+# Remove the deb files found inside DIR. Prompt the user before deleting.
+if ls $DIR/*.deb 1> /dev/null 2>&1; then
+ rm -i $DIR/*.deb
+fi
+
+# Build the deb package
+fakeroot dpkg-deb --build $DIR/package $DIR