94076c26f75c5adea910dcbc9249fe6f9177d3b6
[pharos-tools.git] / validator / rpm / buildasroot.sh
1 #! /usr/bin/env bash
2 # Builds the pharosvalidator package as root (it must be built as root)
3 # then copies the finished package to /tmp. The script can either be called
4 # as root or with sudo
5
6 tarball=pharos-validator-1.tar.gz
7 specfile=pharosvalidator.spec
8 arch=x86_64
9
10 if [ "$(id -u)" != 0 ]; then
11         echo "This script must be run as root (or with sudo)"
12         exit 1
13 fi;
14
15 rpmdev-setuptree
16
17 cp "$specfile" ~/rpmbuild/SPECS/
18
19 # Prepare the "source package" for the rpm build process using .spec file
20 pushd ../../
21 tar -cvf "$tarball" pharos-validator
22 cp "$tarball" ~/rpmbuild/SOURCES
23 popd
24
25
26 cd ~/rpmbuild/
27
28 rpmlint SPECS/"$specfile"
29 printf "\n\nRPM BUILD PROCESS\n\n"
30 rpmbuild -ba SPECS/"$specfile"
31
32 cp -rfv RPMS/"$arch"/* /tmp/