#!/bin/bash # # mkrpm: package the dist/install output of a Xen build in an .rpm # # Takes 2 arguments, the path to the dist directory and the version set -e if [[ -z "$1" || -z "$2" ]] ; then echo "usage: $0 path-to-XEN_ROOT xen-version" exit 1 fi xenroot="$1" # rpmbuild doesn't like dashes in the version; break it down into # version and release. Default to "0" if there isn't a release. v=(${2/-/ }) version=${v[0]} release="${v[1]:-0}${PKG_RELEASE:+.$PKG_RELEASE}" cd $xenroot # Prepare the directory to package cd dist rm -rf rpm # Fill in the rpm boilerplate mkdir -p rpm/{BUILD,RPMS,SOURCES,SPECS,SRPMS} cat >rpm/SPECS/xen.spec < dist/directories.txt find %buildroot -type f | sed 's|^%buildroot||' | sort > dist/files.txt find %buildroot -type l | sed 's|^%buildroot||' | sort >> dist/files.txt if rpm -ql filesystem > dist/filesystem.txt then while read do sed -i "s|^\${REPLY}$||" dist/directories.txt done < dist/filesystem.txt fi sed 's|^|%%dir |' dist/directories.txt >> dist/files.txt popd %clean rm -rf %buildroot %files -f %_xenroot/dist/files.txt %defattr(-,root,root,-) %post EOF # Package it up rpmbuild --define "_xenroot $xenroot" --define "_topdir $PWD/rpm" -bb rpm/SPECS/xen.spec # Tidy up after ourselves mv rpm/RPMS/*/*.rpm . rm -rf rpm