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 _binary_payload w1.gzdio
41%define __spec_install_post /usr/lib/rpm/brp-compress || :
42%define debug_package %{nil}
43
44%description
45This package contains the Xen hypervisor and associated tools, built
46from a source tree.  It is not a fully packaged and supported Xen, just
47the output of a xen "make dist" wrapped in an .rpm to make it easy to
48uninstall.
49
50%build
51
52%install
53rm -rf \$RPM_BUILD_ROOT
54mkdir -p \$RPM_BUILD_ROOT
55cd %{_xenroot}
56dist/install.sh \$RPM_BUILD_ROOT/
57
58cd \$RPM_BUILD_ROOT
59
60%clean
61rm -rf \$RPM_BUILD_ROOT
62
63%files
64%defattr(-,root,root,-)
65/*
66
67%post
68EOF
69
70# Package it up
71rpmbuild --define "_xenroot $xenroot" --define "_topdir $PWD/rpm" -bb rpm/SPECS/xen.spec
72
73# Tidy up after ourselves
74mv rpm/RPMS/*/*.rpm .
75rm -rf rpm
76