This repository has been archived by the owner on Jul 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathpackage-el8.sh
executable file
·65 lines (53 loc) · 2.04 KB
/
package-el8.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
#!/usr/bin/env bash
# Copyright (C) 2021 Joshua Boudreau <[email protected]>
#
# This file is part of Cockpit Samba Manager.
#
# Cockpit Samba Manager is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Cockpit Samba Manager is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Cockpit Samba Manager. If not, see <https://www.gnu.org/licenses/>.
if [[ "$#" == 1 && "$1" == "clean" ]]; then
rm -rf dist/tmp
rm -rf dist/el8
exit 0
fi
command -v docker > /dev/null 2>&1 || {
echo "Please install docker.";
exit 1;
}
# if docker image DNE, build it
if [[ "$(docker images -q cockpit-samba-manager-el8-builder 2> /dev/null)" == "" ]]; then
docker build -t cockpit-samba-manager-el8-builder - < docker/el8
res=$?
if [ $res -ne 0 ]; then
echo "Building docker image failed."
exit $res
fi
fi
mkdir -p dist/{el8,tmp}
SOURCE_DIR_NAME=cockpit-samba-manager-$(grep Version el/cockpit-samba-manager.spec --color=never | awk '{print $2}')
SOURCE_DIR=dist/tmp/$SOURCE_DIR_NAME
mkdir -p $SOURCE_DIR
make DESTDIR=$SOURCE_DIR install
pushd $SOURCE_DIR/..
tar -czvf $SOURCE_DIR_NAME.tar.gz $SOURCE_DIR_NAME
popd
# build rpm from source tar and place it dist/el8 by mirroring dist/el8 to rpmbuild/RPMS
docker run -u $(id -u):$(id -g) -w /home/rpm/rpmbuild -it -v$(pwd)/dist/tmp:/home/rpm/rpmbuild/SOURCES -v$(pwd)/dist/el8:/home/rpm/rpmbuild/RPMS -v$(pwd)/el:/home/rpm/rpmbuild/SPECS --rm cockpit-samba-manager-el8-builder rpmbuild -ba SPECS/cockpit-samba-manager.spec
res=$?
if [ $res -ne 0 ]; then
echo "Packaging failed."
exit $res
fi
rm -rf dist/tmp
echo "rpm is in dist/el8/"
exit 0