1
+ #! /bin/bash
2
+
3
+ # Default values for architecture
4
+ DIRECTORY_ARCH=" x64" # Default directory name
5
+ BINARY_ARCH=" x86_64" # Default binary name
6
+ RPM_ARCH=" x86_64" # Default RPM architecture
7
+
8
+ # Parse command-line arguments
9
+ while getopts " d:b:" opt; do
10
+ case $opt in
11
+ d) DIRECTORY_ARCH=" $OPTARG " ;; # Set the directory architecture
12
+ b) BINARY_ARCH=" $OPTARG " ;; # Set the binary architecture
13
+ * )
14
+ echo " Usage: $0 [-d directory_arch] [-b binary_arch]"
15
+ exit 1
16
+ ;;
17
+ esac
18
+ done
19
+ RPM_ARCH=$BINARY_ARCH
20
+
21
+ # Normalize architecture names for RPM
22
+ if [ " $RPM_ARCH " == " arm64" ]; then
23
+ RPM_ARCH=" aarch64"
24
+ fi
1
25
# Read version from pubspec
2
26
SETONIX_VERSION_REGEX=" version:\s(.+)\+(.+)"
3
27
[[ $( grep -E " ${SETONIX_VERSION_REGEX} " pubspec.yaml) =~ ${SETONIX_VERSION_REGEX} ]]
4
28
SETONIX_VERSION=" ${BASH_REMATCH[1]} "
29
+
5
30
# Replace - with ~ to match RPM versioning
6
31
RPM_VERSION=$( echo $SETONIX_VERSION | sed ' s/-/~/g' )
7
32
CURRENT_DIR=$( pwd)
8
- echo " Building Setonix $RPM_VERSION "
33
+ echo " Building Setonix $RPM_VERSION for $DIRECTORY_ARCH /$BINARY_ARCH ($RPM_ARCH )"
34
+
35
+ # Clean and set up build directories
9
36
rm -rf build/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
10
37
mkdir -p build/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
38
+
11
39
# Copy files
12
40
cp linux/rpm/linwood-setonix.spec build/SPECS/linwood-setonix.spec
13
- cp -r build/linux/x64 /release/bundle build/SOURCES/linwood-setonix-$RPM_VERSION
41
+ cp -r build/linux/${DIRECTORY_ARCH} /release/bundle build/SOURCES/linwood-setonix-$RPM_VERSION
14
42
chmod 755 build/SOURCES/linwood-setonix-$RPM_VERSION /setonix
15
43
mv build/SOURCES/linwood-setonix-$RPM_VERSION /setonix build/SOURCES/linwood-setonix-$RPM_VERSION /linwood-setonix
16
44
cp linux/rpm/linwood-setonix.desktop build/SOURCES/linwood-setonix-$RPM_VERSION /linwood-setonix.desktop
17
- # Change second line of spec file Version: to match version
45
+
46
+ # Update .spec file with the correct version
18
47
sed -i " 2s/.*/Version: $RPM_VERSION /" build/SPECS/linwood-setonix.spec
19
- # Create tar
48
+
49
+ # Create tarball
20
50
cd build/SOURCES/
21
51
# Fix .so files using patchelf
22
52
cd linwood-setonix-$RPM_VERSION /lib
23
53
for file in * .so; do
24
- PATCHELF_OUTPUT=$( patchelf --print-rpath $file )
54
+ PATCHELF_OUTPUT=$( patchelf --print-rpath " $file " )
25
55
echo " Checking $file : $PATCHELF_OUTPUT "
26
56
# Skip file if PATCHELF_OUTPUT does not contain CURRENT_DIR
27
57
if [[ ! $PATCHELF_OUTPUT =~ $CURRENT_DIR ]]; then
28
58
echo " Skipping $file "
29
59
continue
30
60
fi
31
61
echo " Fixing $file "
32
- patchelf --set-rpath ' $ORIGIN' $file
62
+ patchelf --set-rpath ' $ORIGIN' " $file "
33
63
done
34
64
cd ../../
35
65
tar --create --file linwood-setonix-$RPM_VERSION .tar.gz linwood-setonix-$RPM_VERSION
36
66
cd ../../
67
+
37
68
# Build RPM
38
69
QA_RPATHS=$[ 0x0001| 0x0010 ] rpmbuild -bb build/SPECS/linwood-setonix.spec --define " _topdir $( pwd) /build"
39
- # Copy RPM to build folder
40
- cp build/RPMS/x86_64/linwood-setonix-* .rpm build/linwood-setonix-linux-x86_64.rpm
70
+
71
+ # Copy the RPM to the build folder
72
+ cp build/RPMS/${RPM_ARCH} /linwood-setonix-* .rpm build/linwood-setonix-linux-${BINARY_ARCH} .rpm
0 commit comments