@@ -29,32 +29,40 @@ Arguments:
29
29
clean - Remove all the old versions saved in format .XXXX
30
30
cleanall - Remove all the versions, including the last one"
31
31
32
- GIT_ROOT =` pwd`
32
+ PKG_ROOT =` pwd`
33
33
architecture=` arch`
34
+ ARCH_NAME=$( dpkg --print-architecture)
35
+ repo_name=fledge
36
+ skip_build=0
34
37
35
- for i in " $@ "
36
- do
37
- case " $i " in
38
+ while getopts " :hcasb:" opt; do
39
+ case " $opt " in
38
40
clean)
39
- if [ -d " ${GIT_ROOT } /packages/Debian/build" ]; then
41
+ if [ -d " ${PKG_ROOT } /packages/Debian/build" ]; then
40
42
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
43
+ find " ${PKG_ROOT } /packages/Debian/build/${architecture} " -maxdepth 2 | grep ' .*\.[0-9][0-9][0-9][0-9]' | xargs rm -rf
42
44
echo " Done."
43
45
else
44
46
echo " No build folder, skipping clean"
45
47
fi
46
48
exit 0
47
49
;;
48
50
cleanall)
49
- if [ -d " ${GIT_ROOT } /packages/Debian/build" ]; then
51
+ if [ -d " ${PKG_ROOT } /packages/Debian/build" ]; then
50
52
echo -n " Cleaning the build folder..."
51
- rm -rf ${GIT_ROOT } /packages/Debian/build
53
+ rm -rf ${PKG_ROOT } /packages/Debian/build
52
54
echo " Done."
53
55
else
54
56
echo " No build folder, skipping cleanall"
55
57
fi
56
58
exit 0
57
59
;;
60
+ s)
61
+ skip_build=1
62
+ ;;
63
+ b)
64
+ branch=$OPTARG
65
+ ;;
58
66
help)
59
67
echo " ${usage} "
60
68
exit 1
66
74
esac
67
75
done
68
76
77
+ #
78
+ # Clones/updates Git repository
79
+ #
80
+ if [[ $skip_build == 0 ]]; then
81
+ cd /tmp
82
+ if [ -d " ${repo_name} " ]; then
83
+ echo WARNING: Repository ${repo_name} already exists, using the existing copy
84
+ (cd ${repo_name} ; git fetch --all; git pull ; git checkout " $branch " )
85
+ else
86
+ git clone -b " $branch " https://github.com/fledge-iot/${repo_name} .git
87
+ fi
88
+
89
+ GIT_ROOT=/tmp/" ${repo_name} "
90
+ cd ${GIT_ROOT}
91
+
92
+ git_tag_info=$( cd ${GIT_ROOT} && git describe --tags) && commit_count=$( echo ${git_tag_info} | cut -d- -f2)
93
+ fi
94
+
95
+ #
96
+ # Builds Fledge
97
+ #
98
+ if [[ $skip_build == 0 ]]; then
99
+ cd ${GIT_ROOT}
100
+ echo " Git log details for Fledge..."
101
+ git --no-pager log -1
102
+
103
+ if [ " ${ARCH_NAME} " = " armhf" ]; then
104
+ sudo ./requirements.sh
105
+ sed -i ' s/python_build python_requirements_user/python_build # python_requirements_user/g' Makefile
106
+ sed -i ' /python_requirements \\/d' Makefile
107
+ fi
108
+ echo " install fledge"
109
+ if [ " ${ARCH_NAME} " = " armhf" ]; then
110
+ cd ${GIT_ROOT} && sudo make install USE_PIP_CACHE=yes && export FLEDGE_ROOT=/usr/local/fledge
111
+ else
112
+ sudo ./requirements.sh
113
+ cd ${GIT_ROOT} && sudo make install && export FLEDGE_ROOT=/usr/local/fledge
114
+ fi
115
+ fi
116
+
69
117
# Check FLEDGE_ROOT
70
118
if [ -z ${FLEDGE_ROOT+x} ]; then
71
119
# Set FLEDGE_ROOT as the default directory
@@ -79,13 +127,12 @@ if [ -z ${FLEDGE_ROOT+x} ]; then
79
127
fi
80
128
81
129
version=` cat ${FLEDGE_ROOT} /VERSION | tr -d ' ' | grep ' fledge_version=' | head -1 | sed -e ' s/\(.*\)=\(.*\)/\2/g' `
82
- BUILD_ROOT=" ${GIT_ROOT} /packages/Debian/build/${architecture} "
83
-
130
+ BUILD_ROOT=" ${PKG_ROOT} /packages/Debian/build/${architecture} "
84
131
# Final package name
85
- package_name= " fledge- ${ version} -${architecture} "
132
+ if [[ $skip_build == 0 ]] && ([[ ${branch} != " main " ]] && [[ ! ${branch} =~ ^[0-9]+ \. [0-9]+ \. [0-9]+RC ]] && [[ ! ${branch} =~ ^v[0-9]+ \. [0-9]+ \. [0-9]+ ]]) ; then package_name= " fledge_ ${ version} -${commit_count} _ ${ architecture}" ; version= ${git_tag_info : 1} ; else package_name= " fledge_ ${version} _ ${architecture} " ; fi
86
133
87
134
# Print the summary of findings
88
- echo " The package root directory is : ${GIT_ROOT } "
135
+ echo " The package root directory is : ${PKG_ROOT } "
89
136
echo " The Fledge directory is : ${FLEDGE_ROOT} "
90
137
echo " The Fledge version is : ${version} "
91
138
echo " The package will be built in : ${BUILD_ROOT} "
@@ -115,9 +162,10 @@ mkdir "${package_name}"
115
162
# First with files common to all pla
116
163
echo -n " Populating the package and updating version in control file..."
117
164
cd " ${package_name} "
118
- cp -R ${GIT_ROOT } /packages/Debian/common/* .
119
- cp -R ${GIT_ROOT } /packages/Debian/${architecture} /* .
165
+ cp -R ${PKG_ROOT } /packages/Debian/common/* .
166
+ cp -R ${PKG_ROOT } /packages/Debian/${architecture} /* .
120
167
sed -i " s/Version: 1.0.0/Version: ${version} /g" DEBIAN/control
168
+ if [[ $skip_build == 0 ]] && ([[ ${branch} = " main" ]] || [[ ${branch} =~ ^[0-9]+\. [0-9]+\. [0-9]+RC ]] || [[ ${branch} =~ ^v[0-9]+\. [0-9]+\. [0-9]+ ]]); then echo " Build: ${git_tag_info: 1} " >> DEBIAN/control; fi
121
169
mkdir -p usr/local/fledge
122
170
cd usr/local/fledge
123
171
cp -R ${FLEDGE_ROOT} /* .
@@ -139,10 +187,10 @@ rm -rf var
139
187
# Add customised files
140
188
# echo -n "Adding Fledge customization..."
141
189
142
- # cp -R ${GIT_ROOT }/share/* share/postgresql/.
190
+ # cp -R ${PKG_ROOT }/share/* share/postgresql/.
143
191
# cd ${BUILD_ROOT}/${package_name}/usr/local/fledge/plugins/storage/postgres
144
192
# mkdir bin
145
- # cp ${GIT_ROOT }/scripts/* bin/.
193
+ # cp ${PKG_ROOT }/scripts/* bin/.
146
194
# echo "Done."
147
195
148
196
# Build the package
0 commit comments