-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
executable file
·83 lines (63 loc) · 3.32 KB
/
build.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
#!/bin/sh
### preparation
spec=./obs-studio.spec
if [ "$1" == "frel" ] && [ "$2" != "" ]; then
frel=$2
echo "Fedora Release version specified. Using $frel."
else
frel=$(rpm -E %fedora)
echo "No Fedora Release version specified. Using default $frel."
fi;
if [ "$1" == "all" ]; then
echo "Building for Fedora Release $(($frel - 1)), $frel, and $(($frel + 1))."
./build.sh frel $(($frel - 1))
./build.sh frel $(($frel + 1))
./build.sh $2
exit
fi;
# delimited by spaces, every space is a new "field" for cut, hence field 9 for the version/release
mver=$(cat $spec | grep Version\: | cut -d" " -f9)
rver=$(cat $spec | grep Release\: | cut -d" " -f9 | sed -e 's/%{?dist}//')
# insert the client IDs and Hashes from obs-secrets file
if [[ -f "./obs-secrets" ]]; then
echo "obs-secrets exists"
if [[ $(cat "./obs-secrets" | grep TWITCH_CLIENTID) ]]; then
sed --in-place "s/-DTWITCH_CLIENTID='.*'/-DTWITCH_CLIENTID='$(cat "./obs-secrets"| grep TWITCH_CLIENTID | cut -d' ' -f2)'/" $spec
sed --in-place "s/-DTWITCH_HASH='.*'/-DTWITCH_HASH='$(cat "./obs-secrets"| grep TWITCH_HASH | cut -d' ' -f2)'/" $spec
fi
if [[ $(cat "./obs-secrets" | grep RESTREAM_CLIENTID) ]]; then
sed --in-place "s/-DRESTREAM_CLIENTID='.*'/-DRESTREAM_CLIENTID='$(cat "./obs-secrets"| grep RESTREAM_CLIENTID | cut -d' ' -f2)'/" $spec
sed --in-place "s/-DRESTREAM_HASH='.*'/-DRESTREAM_HASH='$(cat "./obs-secrets"| grep RESTREAM_HASH | cut -d' ' -f2)'/" $spec
fi
if [[ $(cat "./obs-secrets" | grep YOUTUBE_CLIENTID) ]]; then
sed --in-place "s/-DYOUTUBE_CLIENTID='.*'/-DYOUTUBE_CLIENTID='$(cat "./obs-secrets"| grep -w YOUTUBE_CLIENTID | cut -d' ' -f2)'/" $spec
sed --in-place "s/-DYOUTUBE_CLIENTID_HASH='.*'/-DYOUTUBE_CLIENTID_HASH='$(cat "./obs-secrets"| grep -w YOUTUBE_CLIENTID_HASH | cut -d' ' -f2)'/" $spec
sed --in-place "s/-DYOUTUBE_SECRET='.*'/-DYOUTUBE_SECRET='$(cat "./obs-secrets"| grep -w YOUTUBE_SECRET | cut -d' ' -f2)'/" $spec
sed --in-place "s/-DYOUTUBE_SECRET_HASH='.*'/-DYOUTUBE_SECRET_HASH='$(cat "./obs-secrets"| grep -w YOUTUBE_SECRET_HASH | cut -d' ' -f2)'/" $spec
fi
fi
set -x
### build phase
rm ./f_downloads/obs-studio-*.tar.gz
tar --exclude-vcs -czf ./f_downloads/obs-studio-$mver.tar.gz ./obs-studio
spectool -g $spec --directory ./f_downloads
rm -rf ./f_upload/$frel/
mock -r fedora-$frel-x86_64-rpmfusion_free --sources=./f_downloads --spec=$spec --resultdir=./f_upload/$frel/
pushd ./f_upload/$frel
sha512sum obs-studio-$mver-$rver.fc$frel.x86_64.rpm obs-studio-libs-$mver-$rver.fc$frel.x86_64.rpm > obs-studio-$mver-$rver.fc$frel.sha512
if [ "$1" == "install" ]; then
sudo dnf install obs-studio-$mver-$rver.fc$frel.x86_64.rpm obs-studio-libs-$mver-$rver.fc$frel.x86_64.rpm
fi
popd
set +x
### clean up client secrets
# can always do this with the .* quantifier
sed --in-place "s/-DTWITCH_CLIENTID='.*'/-DTWITCH_CLIENTID=''/" $spec
sed --in-place "s/-DTWITCH_HASH='.*'/-DTWITCH_HASH=''/" $spec
sed --in-place "s/-DRESTREAM_CLIENTID='.*'/-DRESTREAM_CLIENTID=''/" $spec
sed --in-place "s/-DRESTREAM_HASH='.*'/-DRESTREAM_HASH=''/" $spec
sed --in-place "s/-DYOUTUBE_CLIENTID='.*'/-DYOUTUBE_CLIENTID=''/" $spec
sed --in-place "s/-DYOUTUBE_CLIENTID_HASH='.*'/-DYOUTUBE_CLIENTID_HASH=''/" $spec
sed --in-place "s/-DYOUTUBE_SECRET='.*'/-DYOUTUBE_SECRET=''/" $spec
sed --in-place "s/-DYOUTUBE_SECRET_HASH='.*'/-DYOUTUBE_SECRET_HASH=''/" $spec
echo "All done!"