File: build.sh

package info (click to toggle)
obs-command-source 0.5.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 284 kB
  • sloc: ansic: 400; python: 80; sh: 75; makefile: 21; cpp: 16
file content (49 lines) | stat: -rwxr-xr-x 1,502 bytes parent folder | download | duplicates (2)
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
#! /bin/bash

set -ex

docker_image="$1"
rpmbuild="$2"

PLUGIN_NAME=$(awk '/^project\(/{print gensub(/project\(([^ ()]*).*/, "\\1", 1, $0)}' CMakeLists.txt)
PLUGIN_NAME_FEDORA="$(sed -e 's/^obs-/obs-studio-plugin-/' <<< "$PLUGIN_NAME")"
eval $(git describe --tag --always --long | awk '
BEGIN {
	VERSION="unknown";
	RELEASE=0;
}
{
	if (match($0, /^(.*)-([0-9]*)-g[0-9a-f]*$/, aa)) {
		VERSION = aa[1]
		RELEASE = aa[2]
	}
}
END {
	VERSION = gensub(/-(alpha|beta|rc)/, "~\\1", 1, VERSION);
	gsub(/["'\''-]/, ".", VERSION);
	printf("VERSION='\''%s'\'' RELEASE=%d\n", VERSION, RELEASE + 1);
}')

rm -rf $rpmbuild
mkdir -p $rpmbuild/{BUILD,BUILDROOT,SRPMS,SOURCES,SPECS,RPMS}
rpmbuild="$(cd $rpmbuild && pwd -P)"
chmod a+w $rpmbuild/{BUILD,BUILDROOT,SRPMS,RPMS}
test -x /usr/sbin/selinuxenabled && /usr/sbin/selinuxenabled && chcon -Rt container_file_t $rpmbuild

# Prepare files
sed \
	-e "s/@PLUGIN_NAME@/$PLUGIN_NAME/g" \
	-e "s/@PLUGIN_NAME_FEDORA@/$PLUGIN_NAME_FEDORA/g" \
	-e "s/@VERSION@/$VERSION/g" \
	-e "s/@RELEASE@/$RELEASE/g" \
	< ci/plugin.spec \
	> $rpmbuild/SPECS/$PLUGIN_NAME_FEDORA.spec

git archive --format=tar --prefix=$PLUGIN_NAME_FEDORA-$VERSION/ HEAD | bzip2 > $rpmbuild/SOURCES/$PLUGIN_NAME_FEDORA-$VERSION.tar.bz2

docker run -v $rpmbuild:/home/rpm/rpmbuild $docker_image bash -c "
sudo dnf builddep -y ~/rpmbuild/SPECS/$PLUGIN_NAME_FEDORA.spec &&
sudo chown 0.0 ~/rpmbuild/SOURCES/* &&
sudo chown 0.0 ~/rpmbuild/SPECS/* &&
rpmbuild -ba ~/rpmbuild/SPECS/$PLUGIN_NAME_FEDORA.spec
"