-
Notifications
You must be signed in to change notification settings - Fork 1
/
rpmbuilder.sh
executable file
·78 lines (63 loc) · 1.67 KB
/
rpmbuilder.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
#!/bin/bash
set -e
PWD=$(pwd)
BUILDROOT=$(mktemp -p $PWD -d rpmbuilder.XXX )
SPEC_FILE="$BUILDROOT/SPECS/$(basename $INPUT_SPEC)"
install_packages () {
yum install -y $INPUT_PACKAGES
}
populate_build_tree () {
echo "%_topdir $BUILDROOT" > $HOME/.rpmmacros
rpmdev-setuptree
cp $INPUT_SPEC $SPEC_FILE
if [[ -v INPUT_SOURCE_DIR && -d $INPUT_SOURCE_DIR ]]; then
cp -R $INPUT_SOURCE_DIR/* $BUILDROOT/SOURCES/
fi
}
run_spectool () {
spectool -g -R $SPEC_FILE
}
install_build_dependencies () {
yum-builddep -y $SPEC_FILE
}
build_spec () {
rpmbuild -$INPUT_BUILD_TYPE $SPEC_FILE
}
clean_and_copy () {
mkdir -p $INPUT_OUTPUT_DIR
find $BUILDROOT/RPMS -type f -name '*.rpm' -exec cp -v {} $INPUT_OUTPUT_DIR \;
find $BUILDROOT/SRPMS -type f -name '*.rpm' -exec cp -v {} $INPUT_OUTPUT_DIR \;
rm -rf $BUILDROOT
echo "::set-output name=rpm_files::$(find $INPUT_OUTPUT_DIR -type f -name '*.rpm' |xargs)"
}
if [[ ! -v INPUT_SPEC ]]; then
echo "::error Specfile not defined"
exit 1
fi
if [[ ! -f "$INPUT_SPEC" ]]; then
echo "::error Specfile does not exist"
exit 1
fi
echo "::group::Installing packages"
if [[ -v INPUT_PACKAGES ]]; then
install_packages
fi
echo "::endgroup::"
echo "::group::Populating build tree"
populate_build_tree
echo "::endgroup::"
echo "::group::Running spectool"
if [[ -v INPUT_SPECTOOL ]]; then
run_spectool
fi
echo "::endgroup::"
echo "::group::Installing build dependencies"
install_build_dependencies
echo "::endgroup::"
echo "::group::Running rpmbuild"
build_spec
echo "::endgroup::"
echo "::group::Copying RPM files and removing buildroot"
clean_and_copy
echo "::endgroup::"
rm -rf $BUILDROOT