| 1 | #!/bin/bashscip-shell filesystem . . `/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 | |
| 7 | set -e |
| 8 | |
| 9 | if [[ -z "$1" || -z "$2" ]] ; then |
| 10 | echoscip-shell system . . echo. "usage: $0 path-to-XEN_ROOT xen-version" |
| 11 | exit 1 |
| 12 | fi |
| 13 | |
| 14 | xenroot="$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. |
| 18 | v=(${2/-/ }) |
| 19 | version=${v[0]} |
| 20 | release="${v[1]:-0}${PKG_RELEASE:+.$PKG_RELEASE}" |
| 21 | |
| 22 | cd $xenroot |
| 23 | |
| 24 | # Prepare the directory to package |
| 25 | cd dist |
| 26 | rmscip-shell system . . rm. -rf rpm |
| 27 | |
| 28 | # Fill in the rpm boilerplate |
| 29 | mkdirscip-shell system . . mkdir. -p rpm/{BUILD,RPMS,SOURCES,SPECS,SRPMS} |
| 30 | catscip-shell system . . cat. >rpm/SPECS/xen.spec <<EOF |
| 31 | Summary: Xen development build, version $version |
| 32 | Name: xen$PKG_SUFFIX |
| 33 | Version: $version |
| 34 | Release: $release |
| 35 | License: GPL |
| 36 | Group: System/Hypervisor |
| 37 | URL: https://xenbits.xenproject.org/git-http/xen.git |
| 38 | |
| 39 | BuildRoot: %{_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 |
| 45 | This package contains the Xen hypervisor and associated tools, built |
| 46 | from a source tree. It is not a fully packaged and supported Xen, just |
| 47 | the output of a xen "make dist" wrapped in an .rpm to make it easy to |
| 48 | uninstall. |
| 49 | |
| 50 | %build |
| 51 | |
| 52 | %install |
| 53 | rm -rf %buildroot |
| 54 | mkdir -p %buildroot |
| 55 | pushd %_xenroot |
| 56 | dist/install.sh %buildroot |
| 57 | |
| 58 | rm -f dist/filesystem.txt |
| 59 | rm -f dist/directories.txt |
| 60 | rm -f dist/files.txt |
| 61 | find %buildroot -type d | sed 's|^%buildroot||' | sort > dist/directories.txt |
| 62 | find %buildroot -type f | sed 's|^%buildroot||' | sort > dist/files.txt |
| 63 | find %buildroot -type l | sed 's|^%buildroot||' | sort >> dist/files.txt |
| 64 | if rpm -ql filesystem > dist/filesystem.txt |
| 65 | then |
| 66 | while read |
| 67 | do |
| 68 | sed -i "s|^\${REPLY}$||" dist/directories.txt |
| 69 | done < dist/filesystem.txt |
| 70 | fi |
| 71 | sed 's|^|%%dir |' dist/directories.txt >> dist/files.txt |
| 72 | popd |
| 73 | |
| 74 | %clean |
| 75 | rm -rf %buildroot |
| 76 | |
| 77 | %files -f %_xenroot/dist/files.txt |
| 78 | %defattr(-,root,root,-) |
| 79 | |
| 80 | %post |
| 81 | EOF |
| 82 | |
| 83 | # Package it up |
| 84 | rpmbuild --define "_xenroot $xenroot" --define "_topdir $PWD/rpm" -bb rpm/SPECS/xen.spec |
| 85 | |
| 86 | # Tidy up after ourselves |
| 87 | mvscip-shell system . . mv. rpm/RPMS/*/*.rpm . |
| 88 | rmscip-shell system . . rm. -rf rpm |