summaryrefslogtreecommitdiff
path: root/centos7/generate-warewulf-packages.sh
blob: 1b824112689beaf180a3b51764cf49f35d5cb106 (plain)
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
83
84
#!/usr/bin/env bash
#
# Generated from:
# https://github.com/warewulf/warewulf3/blob/development/.circleci/config.yml
#

set -x

SRCDIR=~/warewulf3
RPMDIR=~/rpmbuild
VERSION="3.7-0"
ARCH=$(uname -m)
cd $SRCDIR
GITVERSION=$(git show -s --pretty=format:%h)
DIST=$(rpm --eval '%{dist}')

# Dependencies
if ! rpm -qi xz-devel > /dev/null; then
	yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
	rpmkeys --import /etc/pki/rpm-gpg/RPM-GPG-KEY-*
	yum -y --exclude=systemtap --exclude=subversion install @development binutils-aarch64-linux-gnu device-mapper-devel gcc-aarch64-linux-gnu libacl-devel libattr-devel libuuid-devel openssl-devel perl-CGI perl-Compress-Raw-Bzip2 perl-Compress-Raw-Zlib perl-DBD-MySQL perl-DBI perl-Digest perl-Digest-MD5 perl-IO-Compress perl-Net-Daemon perl-PlRPC perl-Sys-Syslog perl-Test-Simple xz-devel gcc-x86_64-linux-gnu
  rpm -e --nodeps warewulf-cluster-ohpc warewulf-vnfs-ohpc warewulf-provision-server-ohpc warewulf-provision-ohpc warewulf-common-ohpc
fi

# Functions
rpm_name () {
	local NAME="$1"
	local LARCH="$2"
	if [ -x ${LARCH} ]; then
		LARCH=${ARCH}
	fi
	echo ${RPMDIR}/RPMS/${LARCH}/warewulf-${NAME}-${VERSION}.${GITVERSION}${DIST}.${LARCH}.rpm
}
build_rpm () {
	local NAME="$1"
	local OPTS="$2"
	cd $SRCDIR/$NAME
	./autogen.sh
	make dist-gzip
	rpmbuild -D "_sourcedir $PWD" -ba $OPTS ./warewulf-$NAME.spec
}

# Common
RPM=$(rpm_name "common" "noarch")
if [ ! -f $RPM ]; then
	build_rpm common
fi
rpm -e --nodeps warewulf-common
yum -y install $RPM

# Cluster
RPM=$(rpm_name "cluster")
if [ ! -f $RPM ]; then
	build_rpm cluster
fi
rpm -e --nodeps warewulf-cluster
yum -y install $RPM

# IPMI
RPM=$(rpm_name "ipmi")
if [ ! -f $RPM ]; then
	build_rpm ipmi
fi
rpm -e --nodeps warewulf-ipmi
yum -y install $RPM

# Provision
RPM=$(rpm_name "provision")
if [ ! -f $RPM ]; then
	#TODO: pass option: -D "cross_compile 1"
  #TODO: pass option: -D "mflags -j$(/usr/bin/getconf _NPROCESSORS_ONLN)"
	build_rpm provision
fi
rpm -e --nodeps warewulf-provision warewulf-provision-server
yum -y install $RPM
yum -y install $(rpm_name "provision-server")

# VNFS
RPM=$(rpm_name "vnfs" "noarch")
if [ ! -f $RPM ]; then
	build_rpm vnfs
fi
rpm -e --nodeps warewulf-vnfs
yum -y install $RPM