Skip to content

Commit 18938d7

Browse files
authored
Merge branch 'develop' into FOGL-1499
2 parents 62021b2 + bcc5513 commit 18938d7

File tree

2 files changed

+135
-83
lines changed

2 files changed

+135
-83
lines changed

make_deb

Lines changed: 61 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -22,56 +22,85 @@
2222

2323
set -e
2424

25-
usage="$(basename "$0") [help|clean|cleanall]
26-
This script is used to create the Debian package of Fledge
27-
Arguments:
28-
help - Display this help text
29-
clean - Remove all the old versions saved in format .XXXX
30-
cleanall - Remove all the versions, including the last one"
31-
32-
PKG_ROOT=`pwd`
33-
architecture=`arch`
25+
usage="$(basename "$0") [-h] [-c] [-a] [-s] [-b branch]
26+
This script is used to create the Debian package of Fledge.
27+
Options:
28+
-h - Display this help text
29+
-c - Clean old versions, removing packages saved in the format .XXXX (but keep the latest version)
30+
-a - Clean all versions, including the latest one (removes everything in the build directory)
31+
-s - Skip the build process (useful if the build is already done or needs to be skipped for testing)
32+
-b - Specify the branch name to use for the build (required argument following -b)"
33+
34+
PKG_ROOT=$(pwd)
35+
architecture=$(arch)
3436
ARCH_NAME=$(dpkg --print-architecture)
3537
repo_name=fledge
3638
skip_build=0
3739

38-
while getopts ":hcasb:" opt; do
39-
case "$opt" in
40-
clean)
40+
# Function to check if an option is valid
41+
is_valid_option() {
42+
case "$1" in
43+
-h | -c | -a | -s | -b) return 0 ;; # Valid options
44+
*) return 1 ;; # Invalid option
45+
esac
46+
}
47+
48+
# Parse the options
49+
while [[ $# -gt 0 ]]; do
50+
# Check if the current option is valid using the is_valid_option function
51+
if ! is_valid_option "$1"; then
52+
echo "Unrecognized option: $1"
53+
echo "$usage"
54+
exit 1
55+
fi
56+
57+
case "$1" in
58+
-c) # Option for 'clean'
4159
if [ -d "${PKG_ROOT}/packages/Debian/build" ]; then
42-
echo -n "Cleaning the build folder from older versions..."
43-
find "${PKG_ROOT}/packages/Debian/build/${architecture}" -maxdepth 2 | grep '.*\.[0-9][0-9][0-9][0-9]' | xargs rm -rf
44-
echo "Done."
60+
echo -n "Cleaning the build folder from older versions..."
61+
find "${PKG_ROOT}/packages/Debian/build/${architecture}" -maxdepth 2 | grep '.*\.[0-9][0-9][0-9][0-9]' | xargs rm -rf
62+
echo "Done."
4563
else
46-
echo "No build folder, skipping clean"
64+
echo "No build folder, skipping clean"
4765
fi
4866
exit 0
4967
;;
50-
cleanall)
68+
-a) # Option for 'cleanall'
69+
echo "Cleaning all..."
5170
if [ -d "${PKG_ROOT}/packages/Debian/build" ]; then
52-
echo -n "Cleaning the build folder..."
53-
rm -rf ${PKG_ROOT}/packages/Debian/build
54-
echo "Done."
71+
echo -n "Cleaning the build folder..."
72+
rm -rf ${PKG_ROOT}/packages/Debian/build
73+
echo "Done."
5574
else
56-
echo "No build folder, skipping cleanall"
75+
echo "No build folder, skipping cleanall"
5776
fi
5877
exit 0
5978
;;
60-
s)
79+
-s) # Option for 'skip_build'
6180
skip_build=1
81+
shift
82+
;;
83+
-b) # Option for 'branch'
84+
if [[ -z "$2" || "$2" =~ ^- ]]; then
85+
echo "Option -b requires a branch argument."
86+
echo "$usage"
87+
exit 1
88+
fi
89+
branch=$2
90+
shift 2
6291
;;
63-
b)
64-
branch=$OPTARG
92+
-h) # Option for 'help'
93+
echo "$usage"
94+
exit 0
6595
;;
66-
help)
67-
echo "${usage}"
68-
exit 1
96+
--) # End of options
97+
shift
98+
break
6999
;;
70-
*)
71-
echo "Unrecognized option: $i"
72-
exit 1
73-
;;
74-
esac
100+
*) # Positional arguments (not options)
101+
break
102+
;;
103+
esac
75104
done
76105

77106
#

make_rpm

Lines changed: 74 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -32,57 +32,80 @@ skip_build=0 # 1=skip Git repo extraction and Fledge build
3232
os_name=$(grep -o '^NAME=.*' /etc/os-release | cut -f2 -d\" | sed 's/"//g')
3333
os_version=$(grep -o '^VERSION_ID=.*' /etc/os-release | cut -f2 -d\" | sed 's/"//g')
3434

35-
usage="$(basename "$0") [-h] [-c] [-a] [-s] [-b <branch>]
36-
This script is used to create the RPM package of Fledge
37-
38-
Arguments:
39-
-h - Display this help text
40-
-c - Remove all the old versions saved in format .XXXX
41-
-a - Remove all the versions, including the last one
42-
-s - Skip Fledge building using the binaries already available
43-
-b - Branch to base package on"
44-
45-
while getopts ":hcasb:" opt; do
46-
case "$opt" in
47-
h)
48-
echo "${usage}"
49-
exit 0
50-
;;
51-
c)
52-
if [ -d "${GIT_ROOT}/packages/RPM/build" ]; then
53-
echo -n "Cleaning the build folder from older versions..."
54-
find "${PKG_ROOT}/packages/RPM/build/BUILDROOT" -maxdepth 1 | grep '.*\.[0-9][0-9][0-9][0-9]' | sudo xargs rm -rf
55-
find "${PKG_ROOT}/packages/RPM/build/RPMS/${architecture}" -maxdepth 1 | grep '.*\.[0-9][0-9][0-9][0-9]' | sudo xargs rm -rf
56-
echo "Done."
57-
else
58-
echo "No build folder, skipping clean old versions"
59-
fi
60-
exit 0
61-
;;
62-
a)
63-
if [ -d "${PKG_ROOT}/packages/RPM/build" ]; then
64-
echo -n "Cleaning the build folder..."
65-
sudo rm -rf ${PKG_ROOT}/packages/RPM/build/*
66-
echo "Done."
67-
else
68-
echo "No build folder, skipping cleanall"
69-
fi
70-
exit 0
71-
;;
72-
s)
73-
skip_build=1
74-
;;
75-
b)
76-
branch=$OPTARG
77-
;;
78-
\?)
79-
echo "Invalid option -$OPTARG"
80-
exit 1
81-
;;
82-
:)
83-
echo "-$OPTARG requires an argument"
84-
exit 1
35+
usage="$(basename "$0") [-h] [-c] [-a] [-s] [-b branch]
36+
This script is used to create the RPM package of Fledge.
37+
Options:
38+
-h - Display this help text
39+
-c - Clean old versions, removing packages saved in the format .XXXX (but keep the latest version)
40+
-a - Clean all versions, including the latest one (removes everything in the build directory)
41+
-s - Skip the build process (useful if the build is already done or needs to be skipped for testing)
42+
-b - Specify the branch name to use for the build (required argument following -b)"
43+
44+
# Function to check if an option is valid
45+
is_valid_option() {
46+
case "$1" in
47+
-h | -c | -a | -s | -b) return 0 ;; # Valid options
48+
*) return 1 ;; # Invalid option
8549
esac
50+
}
51+
52+
# Parse the options
53+
while [[ $# -gt 0 ]]; do
54+
# Check if the current option is valid using the is_valid_option function
55+
if ! is_valid_option "$1"; then
56+
echo "Unrecognized option: $1"
57+
echo "$usage"
58+
exit 1
59+
fi
60+
61+
case "$1" in
62+
-c) # Option for 'clean'
63+
if [ -d "${GIT_ROOT}/packages/RPM/build" ]; then
64+
echo -n "Cleaning the build folder from older versions..."
65+
find "${PKG_ROOT}/packages/RPM/build/BUILDROOT" -maxdepth 1 | grep '.*\.[0-9][0-9][0-9][0-9]' | sudo xargs rm -rf
66+
find "${PKG_ROOT}/packages/RPM/build/RPMS/${architecture}" -maxdepth 1 | grep '.*\.[0-9][0-9][0-9][0-9]' | sudo xargs rm -rf
67+
echo "Done."
68+
else
69+
echo "No build folder, skipping clean old versions"
70+
fi
71+
exit 0
72+
;;
73+
-a) # Option for 'cleanall'
74+
echo "Cleaning all..."
75+
if [ -d "${PKG_ROOT}/packages/RPM/build" ]; then
76+
echo -n "Cleaning the build folder..."
77+
sudo rm -rf ${PKG_ROOT}/packages/RPM/build/*
78+
echo "Done."
79+
else
80+
echo "No build folder, skipping cleanall"
81+
fi
82+
exit 0
83+
;;
84+
-s) # Option for 'skip_build'
85+
skip_build=1
86+
shift
87+
;;
88+
-b) # Option for 'branch'
89+
if [[ -z "$2" || "$2" =~ ^- ]]; then
90+
echo "Option -b requires a branch argument."
91+
echo "$usage"
92+
exit 1
93+
fi
94+
branch=$2
95+
shift 2
96+
;;
97+
-h) # Option for 'help'
98+
echo "$usage"
99+
exit 0
100+
;;
101+
--) # End of options
102+
shift
103+
break
104+
;;
105+
*) # Positional arguments (not options)
106+
break
107+
;;
108+
esac
86109
done
87110

88111
if [ ! -f packages/RPM/SPECS/fledge.spec ] ; then
@@ -211,7 +234,7 @@ if [ -d "${package_name}" ]; then
211234
fi
212235
mkdir "${package_name}"
213236

214-
# Populate the package directory with Debian files
237+
# Populate the package directory with RPM files
215238
# First with files common to all pla
216239
echo -n "Populating the package and updating version in control file..."
217240
cd "${package_name}"

0 commit comments

Comments
 (0)