-
Notifications
You must be signed in to change notification settings - Fork 15
/
release-version.sh
120 lines (88 loc) · 2.75 KB
/
release-version.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/bin/bash
VERSION=1.0.4
# First cross compiler
# Create obj/ folder it not exist
mkdir -p obj
# Architectures
ARCHS=("x86_64-linux-gnu" "aarch64-linux-gnu")
for ARCH in "${ARCHS[@]}"
do
gprbuild powerjoular.gpr --target=$ARCH
mkdir -p ./binary/$ARCH
cp ./obj/powerjoular ./binary/$ARCH/
done
# Create packages folder
rm -rf packages
mkdir -p packages
# Create deb packages
# Create deb temporary folder
mkdir -p deb-temp
cd deb-temp
DEBIAN_ARCHITECTURES=("amd64" "arm64")
for DEB_ARCH in "${DEBIAN_ARCHITECTURES[@]}"
do
# Create a new directory structure for architecture
rm -rf $DEB_ARCH
mkdir -p $DEB_ARCH/powerjoular/usr/bin
mkdir -p $DEB_ARCH/powerjoular/etc/systemd/system
mkdir -p $DEB_ARCH/powerjoular/DEBIAN/
chmod 755 $DEB_ARCH
# Copy precompiled binaries to bin directory
if [[ $DEB_ARCH = "amd64" ]]
then
cp ../binary/x86_64-linux-gnu/powerjoular $DEB_ARCH/powerjoular/usr/bin
elif [[ $DEB_ARCH = "arm64" ]]
then
cp ../binary/aarch64-linux-gnu/powerjoular $DEB_ARCH/powerjoular/usr/bin
fi
# Copy systemd service files
cp ../systemd/powerjoular.service $DEB_ARCH/powerjoular/etc/systemd/system/
# Create the control
cat << EOL > $DEB_ARCH/powerjoular/DEBIAN/control
Package: powerjoular
Version: $VERSION
Maintainer: Adel Noureddine
Architecture: $DEB_ARCH
Description: PowerJoular allows monitoring power consumption of multiple platforms and processes.
EOL
cd $DEB_ARCH
# Creating a .deb package
dpkg-deb --build powerjoular
mv powerjoular.deb ../../packages/powerjoular_${VERSION}_${DEB_ARCH}.deb
cd ..
done
# Remove temp folder
cd ..
rm -rf deb-temp
# Create rpm packages
RPM_ARCHITECTURES=("x86_64" "arm64")
# Create rpm temporary folder
mkdir -p rpm-temp
cd rpm-temp
for RPM_ARCH in "${RPM_ARCHITECTURES[@]}"
do
# Create a new directory structure for architecture
rm -rf $RPM_ARCH
mkdir -p $RPM_ARCH
# Prepare the RPM build environment
mkdir -p $RPM_ARCH/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
cp ../installer/powerjoular.spec $RPM_ARCH/rpmbuild/SPECS/
# Copy the sources accordingly
if [[ $RPM_ARCH = "x86_64" ]]
then
cp ../binary/x86_64-linux-gnu/powerjoular $RPM_ARCH/rpmbuild/SOURCES/
elif [[ $RPM_ARCH = "arm64" ]]
then
cp ../binary/aarch64-linux-gnu/powerjoular $RPM_ARCH/rpmbuild/SOURCES/
fi
cp ../systemd/powerjoular.service $RPM_ARCH/rpmbuild/SOURCES/
# Build the RPM package
cd $RPM_ARCH
rpmbuild -ba rpmbuild/SPECS/powerjoular.spec --define "_topdir $(pwd)/rpmbuild" --target $RPM_ARCH
# Move the created RPM to packages
find rpmbuild/RPMS/ -name '*.rpm' -exec mv {} ../../packages/ \;
cd ..
done
# Remove temp folder
cd ..
rm -rf rpm-temp