-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add cross-compile and cross-package creation script
- Loading branch information
1 parent
11e398f
commit 8e1e51f
Showing
8 changed files
with
123 additions
and
138 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
#!/bin/bash | ||
|
||
VERSION=0.8.0 | ||
|
||
# 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 |