Skip to content

Commit 55f5ee3

Browse files
Merge pull request #43 from foglamp/FOGL-3044
FOGL-3044 foglamp make_deb derived without passing an architecture argument
2 parents 71118c4 + 811992d commit 55f5ee3

File tree

4 files changed

+70
-91
lines changed

4 files changed

+70
-91
lines changed

README.rst

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,29 @@ Internal Structure
1717

1818
The repository contains the following set of files:
1919

20-
- Files named with **make_** prefix, such as ``make_deb``, are the shell scripts used to build the package. The scripts accept the architecture to build as argument (currently *x86* and *arm*).
20+
- Files named with **make_** prefix, such as ``make_deb``, ``make_rpm``, are the shell scripts used to build the package. The script runs as per the architecture to build.
2121
- The **packages** folder contains the list package types to build. It contains *Debian* and *rpmbuild*, latter for RedHat/Centos RPM creation.
2222

23-
- Inside the *packages/Debian* folder, we have the **architecture** folders, plus a *common* folder containing files that are common to all the architectures. The architectures that we provide at the moment are *armhf* and *x86_64*.
23+
- Inside the *packages/Debian* folder, we have the **architecture** folders, plus a *common* folder containing files that are common to all the architectures. The architectures that we provide at the moment are *aarch64*, *armv7l* and *x86_64*.
2424

25-
- Inside the architecture folder we have the DEBIAN folder, which contains all the Debian-based files, i.e. control, pre/post inst/rm, needed for the creation of the package.
25+
- Inside the architecture folder we have the DEBIAN folder, which contains only control file
26+
- Inside the common folder we have the DEBIAN folder, which contains pre/post inst/rm, needed for the creation of the package.
2627

27-
- After the first build, the *packages/Debian* will also contain a **build** folder. This folder contains a copy of what will be used to build the package (in a directory with the same name of the package) and the package itself.
28+
- After the first build, the *packages/Debian* will also contain a **build/architecture** folder. This folder contains a copy of what will be used to build the package (in a directory with the same name of the package) and the package itself.
2829

29-
- In the *build* folder, folders and files that have a sequence number are a previous package build.
30+
- In the *build/architecture* folder, folders and files that have a sequence number are a previous package build.
3031

3132

3233
The make_deb Script
3334
===================
3435

3536
.. code-block:: console
3637
37-
$ ./make_deb --help
38-
make_deb {x86|arm} [clean|cleanall]
38+
$ ./make_deb help
39+
make_deb [help|clean|cleanall]
3940
This script is used to create the Debian package of FogLAMP
4041
Arguments:
41-
x86 - Build an x86_64 package
42-
arm - Build an armv7l package
42+
help - Display this help text
4343
clean - Remove all the old versions saved in format .XXXX
4444
cleanall - Remove all the versions, including the last one
4545
$
@@ -59,60 +59,59 @@ Building a Debian Package
5959
=========================
6060

6161
First, make sure that FogLAMP is properly installed via ``make install`` somewhere on your environment (default is */usr/local/foglamp*).
62-
Next, select the architecture to use, *x86* or *arm*.
63-
Finally, run the ``make_deb`` command:
62+
Finally, run the ``make_deb`` command and it will make as per ``arch``:
6463

6564
.. code-block:: console
6665
67-
$ ./make_deb x86
66+
$ ./make_deb
6867
The package root directory is : /home/foglamp/foglamp-pkg
6968
The FogLAMP directory is : /usr/local/foglamp
70-
The FogLAMP version is : 1.2
71-
The package will be built in : /home/foglamp/foglamp-pkg/packages/Debian/build
69+
The FogLAMP version is : 1.6.0
70+
The package will be built in : /home/foglamp/foglamp-pkg/packages/Debian/build/x86_64
7271
The architecture is set as : x86_64
73-
The package name is : foglamp-1.2-x86_64
72+
The package name is : foglamp-1.6.0-x86_64
7473
7574
Populating the package...Done.
7675
Building the new package...
77-
dpkg-deb: building package 'foglamp' in 'foglamp-1.2-x86_64.deb'.
76+
dpkg-deb: building package 'foglamp' in 'foglamp-1.6.0-x86_64.deb'.
7877
Building Complete.
7978
$
8079
8180
The result will be:
8281

8382
.. code-block:: console
8483
85-
$ ls -l packages/Debian/build/
84+
$ ls -l packages/Debian/build/x86_64
8685
total 564
87-
drwxrwxr-x 4 foglamp foglamp 4096 Mar 23 17:35 foglamp-1.2-x86_64
88-
-rw-r--r-- 1 foglamp foglamp 572742 Mar 23 17:35 foglamp-1.2-x86_64.deb
86+
drwxrwxr-x 4 foglamp foglamp 4096 Mar 23 17:35 foglamp-1.6.0-x86_64
87+
-rw-r--r-- 1 foglamp foglamp 572742 Mar 23 17:35 foglamp-1.6.0-x86_64.deb
8988
$
9089
9190
If you execute the ``make_deb`` command again, you will see:
9291

9392
.. code-block:: console
9493
95-
$ ./make_deb x86
94+
$ ./make_deb
9695
The package root directory is : /home/foglamp/foglamp-pkg
9796
The FogLAMP directory is : /usr/local/foglamp
98-
The FogLAMP version is : 1.2
99-
The package will be built in : /home/foglamp/foglamp-pkg/packages/Debian/build
97+
The FogLAMP version is : 1.6.0
98+
The package will be built in : /home/foglamp/foglamp-pkg/packages/Debian/build/x86_64
10099
The architecture is set as : x86_64
101-
The package name is : foglamp-1.2-x86_64
100+
The package name is : foglamp-1.6.0-x86_64
102101
103-
Saving the old working environment as foglamp-1.2-x86_64.0001
102+
Saving the old working environment as foglamp-1.6.0-x86_64.0001
104103
Populating the package...Done.
105-
Saving the old package as foglamp-1.2-x86_64.deb.0001
104+
Saving the old package as foglamp-1.6.0-x86_64.deb.0001
106105
Building the new package...
107-
dpkg-deb: building package 'foglamp' in 'foglamp-1.2-x86_64.deb'.
106+
dpkg-deb: building package 'foglamp' in 'foglamp-1.6.0-x86_64.deb'.
108107
Building Complete.
109108
$
110-
$ ls -l packages/Debian/build/
109+
$ ls -l packages/Debian/build/x86_64
111110
total 1128
112-
drwxrwxr-x 4 foglamp foglamp 4096 Mar 23 17:53 foglamp-1.2-x86_64
113-
drwxrwxr-x 4 foglamp foglamp 4096 Mar 23 17:35 foglamp-1.2-x86_64.0001
114-
-rw-r--r-- 1 foglamp foglamp 573080 Mar 23 17:54 foglamp-1.2-x86_64.deb
115-
-rw-r--r-- 1 foglamp foglamp 572742 Mar 23 17:35 foglamp-1.2-x86_64.deb.0001
111+
drwxrwxr-x 4 foglamp foglamp 4096 Mar 23 17:53 foglamp-1.6.0-x86_64
112+
drwxrwxr-x 4 foglamp foglamp 4096 Mar 23 17:35 foglamp-1.6.0-x86_64.0001
113+
-rw-r--r-- 1 foglamp foglamp 573080 Mar 23 17:54 foglamp-1.6.0-x86_64.deb
114+
-rw-r--r-- 1 foglamp foglamp 572742 Mar 23 17:35 foglamp-1.6.0-x86_64.deb.0001
116115
$
117116
118117
... where the previous build is now marked with the suffix *.0001*.

make_deb

Lines changed: 40 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -22,69 +22,49 @@
2222

2323
set -e
2424

25-
GIT_ROOT=`pwd` # The script must be executed from the root git directory
26-
27-
architecture="none"
28-
usage="$(basename "$0") {x86|arm|coral} [clean|cleanall]
25+
usage="$(basename "$0") [help|clean|cleanall]
2926
This script is used to create the Debian package of FogLAMP
3027
Arguments:
31-
x86 - Build an x86_64 package
32-
arm - Build an armv7l package
33-
coral - Build package for Google Coral board
28+
help - Display this help text
3429
clean - Remove all the old versions saved in format .XXXX
3530
cleanall - Remove all the versions, including the last one"
3631

37-
if [ $# -gt 0 ]
38-
then
39-
for i in "$@"
40-
do
41-
case "$i" in
42-
x86)
43-
architecture="x86_64"
44-
shift
45-
;;
46-
arm)
47-
architecture="armhf"
48-
shift
49-
;;
50-
coral)
51-
architecture="arm64"
52-
shift
53-
;;
54-
clean)
55-
echo -n "Cleaning the build folder from older versions..."
56-
find "${GIT_ROOT}/packages/Debian/build" -maxdepth 1 | grep '.*\.[0-9][0-9][0-9][0-9]' | xargs rm -rf
57-
echo "Done."
58-
shift
59-
;;
60-
cleanall)
61-
if [ -d "${GIT_ROOT}/packages/Debian/build" ]; then
62-
echo -n "Cleaning the build folder..."
63-
rm -rf ${GIT_ROOT}/packages/Debian/build/*
64-
echo "Done."
65-
else
66-
echo "No build folder, skipping cleanall"
67-
fi
68-
shift
69-
;;
70-
--help)
71-
echo "${usage}"
72-
exit 1
73-
;;
74-
*)
75-
echo "Unrecognized option: $i"
76-
exit 1
77-
;;
78-
esac
79-
done
80-
else
81-
echo "See help and select the architecture to use, *x86* or *arm*"
82-
fi
83-
84-
# If the architecture has not been defined, then the script is complete
85-
if [[ "$architecture" == "none" ]]; then
86-
exit 0
87-
fi
32+
GIT_ROOT=`pwd`
33+
architecture=`arch`
34+
35+
for i in "$@"
36+
do
37+
case "$i" in
38+
clean)
39+
if [ -d "${GIT_ROOT}/packages/Debian/build" ]; then
40+
echo -n "Cleaning the build folder from older versions..."
41+
find "${GIT_ROOT}/packages/Debian/build/${architecture}" -maxdepth 2 | grep '.*\.[0-9][0-9][0-9][0-9]' | xargs rm -rf
42+
echo "Done."
43+
else
44+
echo "No build folder, skipping clean"
45+
fi
46+
exit 0
47+
;;
48+
cleanall)
49+
if [ -d "${GIT_ROOT}/packages/Debian/build" ]; then
50+
echo -n "Cleaning the build folder..."
51+
rm -rf ${GIT_ROOT}/packages/Debian/build
52+
echo "Done."
53+
else
54+
echo "No build folder, skipping cleanall"
55+
fi
56+
exit 0
57+
;;
58+
help)
59+
echo "${usage}"
60+
exit 1
61+
;;
62+
*)
63+
echo "Unrecognized option: $i"
64+
exit 1
65+
;;
66+
esac
67+
done
8868

8969
# Check FOGLAMP_ROOT
9070
if [ -z ${FOGLAMP_ROOT+x} ]; then
@@ -99,7 +79,7 @@ if [ -z ${FOGLAMP_ROOT+x} ]; then
9979
fi
10080

10181
version=`cat ${FOGLAMP_ROOT}/VERSION | tr -d ' ' | grep 'foglamp_version=' | head -1 | sed -e 's/\(.*\)=\(.*\)/\2/g'`
102-
BUILD_ROOT="${GIT_ROOT}/packages/Debian/build"
82+
BUILD_ROOT="${GIT_ROOT}/packages/Debian/build/${architecture}"
10383

10484
# Final package name
10585
package_name="foglamp-${version}-${architecture}"
@@ -137,7 +117,7 @@ echo -n "Populating the package and updating version in control file..."
137117
cd "${package_name}"
138118
cp -R ${GIT_ROOT}/packages/Debian/common/* .
139119
cp -R ${GIT_ROOT}/packages/Debian/${architecture}/* .
140-
sed -i "s/Version: 1.0.0/Version: $version/g" DEBIAN/control
120+
sed -i "s/Version: 1.0.0/Version: ${version}/g" DEBIAN/control
141121
mkdir -p usr/local/foglamp
142122
cd usr/local/foglamp
143123
cp -R ${FOGLAMP_ROOT}/* .
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)