1#!/bin/bash
2#
3# mkrpm: package the dist/install output of a Xen build in an .rpm
4#
5# Takes 2 arguments, the path to the dist directory and the version
6
7set -e
8
9if [[ -z "$1" || -z "$2" ]] ; then
10  echo "usage: $0 path-to-XEN_ROOT xen-version"
11  exit 1
12fi
13
14xenroot="$1"
15
16# rpmbuild doesn't like dashes in the version; break it down into
17# version and release.  Default to "0" if there isn't a release.
18v=(${2/-/ })
19version=${v[0]}
20release="${v[1]:-0}${PKG_RELEASE:+.$PKG_RELEASE}"
21
22cd $xenroot
23
24# Prepare the directory to package
25cd dist
26rm -rf rpm
27
28# Fill in the rpm boilerplate
29mkdir -p rpm/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
30cat >rpm/SPECS/xen.spec <<EOF
31Summary: Xen development build, version $version
32Name: xen$PKG_SUFFIX
33Version: $version
34Release: $release
35License: GPL
36Group:   System/Hypervisor
37URL: http://xenbits.xenproject.org/xen.git
38
39BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
40%define __spec_install_post /usr/lib/rpm/brp-compress || :
41%define debug_package %{nil}
42
43%description
44This package contains the Xen hypervisor and associated tools, built
45from a source tree.  It is not a fully packaged and supported Xen, just
46the output of a xen "make dist" wrapped in an .rpm to make it easy to
47uninstall.
48
49%build
50
51%install
52rm -rf \$RPM_BUILD_ROOT
53mkdir -p \$RPM_BUILD_ROOT
54cd %{_xenroot}
55dist/install.sh \$RPM_BUILD_ROOT/
56
57cd \$RPM_BUILD_ROOT
58
59%clean
60rm -rf \$RPM_BUILD_ROOT
61
62%files
63%defattr(-,root,root,-)
64/*
65
66%post
67EOF
68
69# Package it up
70rpmbuild --define "_xenroot $xenroot" --define "_topdir $PWD/rpm" -bb rpm/SPECS/xen.spec
71
72# Tidy up after ourselves
73mv rpm/RPMS/*/*.rpm .
74rm -rf rpm
75