forked from CosmicFusion/fedora-amdgpu-pro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mock-builder.sh
executable file
·65 lines (51 loc) · 1.63 KB
/
mock-builder.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
#!/bin/sh
if [[ -z $1 ]]; then
echo "-------------------------------------"
echo "Usage: <package-name> <architecture>"
echo "-------------------------------------"
echo "You must specify a package name and an architecture."
echo "Achitecture options are \"32\" for 32 bit and \"64\" for 64 bit"
echo "-------------------------------------"
echo "64 bit package names are:"
ls x86_64/ | sed 's/ /\n/g'
echo "-------------------------------------"
echo "32 bit package names are:"
ls i686/ | sed 's/.i686//g'
exit 1
fi
# install some build dependencies
sudo dnf -y install mock pykickstart fedpkg libvirt
# add current user to 'mock' build group
sudo usermod -a -G mock $USER
# turn selinux off if it's enabled
# sudo setenforce 0
# make a destination folder for our packages
mkdir -p packages
# enter the repository of the package to build:
if [[ "$2" == "32" ]]; then
BUILDARCH="i386"
cd i686/$1.i686
else
BUILDARCH="x86_64"
cd x86_64/$1
fi
# create a fedora srpm from the spec sheet
rpmbuild -bs --define "_srcrpmdir $(pwd)" --undefine=_disable_source_fetch *.spec
# build the package
mock -r /etc/mock/fedora-40-$BUILDARCH.cfg --enable-network --rebuild *.src.rpm
# cleanup our source rpm
rm *.src.rpm
# move the package to our main folder
cd ../../
if [[ "$BUILDARCH" == "i386" ]]; then
sudo mv /var/lib/mock/fedora-40-i686/result/*.rpm packages/
else
sudo mv /var/lib/mock/fedora-40-$BUILDARCH/result/*.rpm packages/
fi
# cleanup our source rpm (again)
rm packages/*.src.rpm
# re-enable selinux if needed
# sudo setenforce 1
# cleanup
mock -r /etc/mock/fedora-40-x86_64.cfg --scrub=all
mock -r /etc/mock/fedora-40-i386.cfg --scrub=all