+++ /dev/null
-#!/usr/bin/env bash
-
-# Executed once at the beginning of the script
-function common_init() {
- export BASEDIR=`pwd`
- export GIT=${GIT-git}
- export SUDO=${SUDO-sudo}
- export MAKE=${MAKE-make}
- export PREFIX=${PREFIX-/usr}
- export INST_DIR=${DESTDIR-dist}
-
- INST_DIR=`readlink -f $INST_DIR`
-
- # execution
- if [[ $EUID -eq 0 ]]
- then
- export SUDO=""
- elif [[ ! -f `which sudo 2>/dev/null` ]]
- then
- echo "Raisin requires sudo to install build dependencies for you."
- echo "Please install sudo, then run this script again."
- exit 1
- fi
-
- if [[ -z "$BASH_VERSINFO" || ${BASH_VERSINFO[0]} -lt 3 ||
- (${BASH_VERSINFO[0]} -eq 3 && ${BASH_VERSINFO[1]} -lt 2) ]]
- then
- echo "Raisin requires BASH 3.2 or newer."
- exit 1
- fi
-
- get_distro
- get_arch
-
- for f in `cat "$BASEDIR"/components/series`
- do
- source "$BASEDIR"/components/"$f"
- done
-}
-
-function get_distro() {
- if [[ -x "`which lsb_release 2>/dev/null`" ]]
- then
- os_VENDOR=`lsb_release -i -s`
- os_RELEASE=`lsb_release -r -s`
- os_CODENAME=`lsb_release -c -s`
- os_UPDATE=""
- elif [[ -r /etc/redhat-release ]]
- then
- # Red Hat Enterprise Linux Server release 5.5 (Tikanga)
- # Red Hat Enterprise Linux Server release 7.0 Beta (Maipo)
- # CentOS release 5.5 (Final)
- # CentOS Linux release 6.0 (Final)
- # Fedora release 16 (Verne)
- # XenServer release 6.2.0-70446c (xenenterprise)
- os_CODENAME=""
- for r in "Red Hat" "CentOS" "Fedora" "XenServer"; do
- os_VENDOR="$r"
- if [[ -n "`grep -i \"$r\" /etc/redhat-release`" ]]
- then
- ver=`sed -e 's/^.* \([0-9].*\) (\(.*\)).*$/\1\|\2/' /etc/redhat-release`
- os_CODENAME=${ver#*|}
- os_RELEASE=${ver%|*}
- os_UPDATE=${os_RELEASE##*.}
- os_RELEASE=${os_RELEASE%.*}
- break
- fi
- done
- elif [[ -r /etc/SuSE-release ]]
- then
- for r in "openSUSE" "SUSE Linux"
- do
- os_VENDOR="$r"
-
- if [[ -n "`grep -i \"$r\" /etc/SuSE-release`" ]]
- then
- os_CODENAME=`grep "CODENAME = " /etc/SuSE-release | \
- sed 's:.* = ::g'`
- os_RELEASE=`grep "VERSION = " /etc/SuSE-release | \
- sed 's:.* = ::g'`
- os_UPDATE=`grep "PATCHLEVEL = " /etc/SuSE-release | \
- sed 's:.* = ::g'`
- break
- fi
- done
- # If lsb_release is not installed, we should be able to detect Debian OS
- elif [[ -f /etc/debian_version && `cat /proc/version` =~ "Debian" ]]
- then
- os_VENDOR="Debian"
- os_CODENAME=`awk '/VERSION=/' /etc/os-release | sed 's/VERSION=//' | \
- sed -r 's/\"|\(|\)//g' | awk '{print $2}'`
- os_RELEASE=`awk '/VERSION_ID=/' /etc/os-release | sed 's/VERSION_ID=//' \
- | sed 's/\"//g'`
- fi
-
- # Simply distro version string
- case "$os_VENDOR" in
- "Debian"* | "Ubuntu"* | "LinuxMint"* )
- DISTRO="Debian"
- ;;
- "SUSE"* )
- DISTRO="SUSE"
- ;;
- "OpenSUSE"* | "openSUSE"* )
- DISTRO="openSUSE"
- ;;
- "Red"* | "CentOS"* )
- DISTRO="CentOS"
- ;;
- *)
- DISTRO=$os_VENDOR
- ;;
- esac
-
- export os_VENDOR os_RELEASE os_UPDATE os_CODENAME
- export DISTRO
-}
-
-function get_arch() {
- export ARCH=`uname -m | sed -e s/i.86/x86_32/ -e s/i86pc/x86_32/ -e \
- s/amd64/x86_64/ -e s/armv7.*/arm32/ -e s/armv8.*/arm64/ \
- -e s/aarch64/arm64/`
-}
-
-function install_dependencies() {
- if [[ "$NO_DEPS" && "$NO_DEPS" -eq 1 ]]
- then
- echo "Not installing any dependencies, as requested."
- echo "Depency list: $*"
- return 0
- fi
- case $DISTRO in
- "Debian" )
- $SUDO apt-get install -y $*
- ;;
- "Fedora" )
- $SUDO yum install -y $*
- ;;
- * )
- echo "I don't know how to install dependencies on $DISTRO"
- ;;
- esac
-}
-
-function start_initscripts() {
- while [[ $# -ge 1 ]]
- do
- case $DISTRO in
- "Debian" )
- $SUDO update-rc.d $1 defaults || echo "Couldn't set $1 to start"
- ;;
- "Fedora" )
- $SUDO chkconfig --add $1 || echo "Couldn't set $1 to start"
- ;;
- * )
- echo "I don't know how to start initscripts on $DISTRO"
- return 1
- ;;
- esac
- shift 1
- done
-}
-
-function stop_initscripts() {
- while [[ $# -ge 1 ]]
- do
- case $DISTRO in
- "Debian" )
- $SUDO update-rc.d $1 remove || echo "Couldn't remove $1 from init"
- ;;
- "Fedora" )
- $SUDO chkconfig --del $1 || echo "Couldn't remove $1 from init"
- ;;
- * )
- echo "I don't know how to start initscripts on $DISTRO"
- return 1
- ;;
- esac
- shift 1
- done
-}
-
-function for_each_component () {
- for component in `cat "$BASEDIR"/components/series`
- do
- capital=`echo $component | tr '[:lower:]' '[:upper:]'`
- if eval [[ ! -z \$"$capital"_UPSTREAM_REVISION ]]
- then
- "$component"_"$1"
- fi
- done
-}
-
-function build_package() {
- if [[ $DISTRO = "Debian" ]]
- then
- ./mkdeb "$1"
- elif [[ $DISTRO = "Fedora" ]]
- then
- ./mkrpm "$1"
- else
- echo "Don't know how to create packages for $DISTRO"
- fi
-}
-
-function install_package() {
- if [[ $DISTRO = "Debian" ]]
- then
- $SUDO dpkg -i "$1".deb
- elif [[ $DISTRO = "Fedora" ]]
- then
- $SUDO rpm -i --force "$1"-`git show --oneline | head -1 | cut -d " " -f 1`-0.$ARCH.rpm
- else
- echo "Don't know how to install packages on $DISTRO"
- fi
-}
-
-function uninstall_package() {
- if [[ $DISTRO = "Debian" ]]
- then
- $SUDO dpkg -r "$1"
- elif [[ $DISTRO = "Fedora" ]]
- then
- $SUDO rpm -e "$1"
- else
- echo "Don't know how to uninstall packages on $DISTRO"
- fi
-}
#!/usr/bin/env bash
source "$BASEDIR"/config
-source "$BASEDIR"/common-functions.sh
+source "$BASEDIR"/scripts/common-functions.sh
function _grub_install_dependencies() {
cd "$BASEDIR"
rm -f memdisk.tar
tar cf memdisk.tar -C data grub.cfg
- ./git-checkout.sh $GRUB_UPSTREAM_URL $GRUB_UPSTREAM_REVISION grub-dir
+ ./scripts/git-checkout.sh $GRUB_UPSTREAM_URL $GRUB_UPSTREAM_REVISION grub-dir
cd grub-dir
./autogen.sh
## GRUB32
#!/usr/bin/env bash
source "$BASEDIR"/config
-source "$BASEDIR"/common-functions.sh
+source "$BASEDIR"/scripts/common-functions.sh
function _libvirt_install_dependencies() {
_libvirt_install_dependencies
cd "$BASEDIR"
- ./git-checkout.sh $LIBVIRT_UPSTREAM_URL $LIBVIRT_UPSTREAM_REVISION libvirt-dir
+ ./scripts/git-checkout.sh $LIBVIRT_UPSTREAM_URL $LIBVIRT_UPSTREAM_REVISION libvirt-dir
cd libvirt-dir
CFLAGS="-I$INST_DIR/$PREFIX/include" \
LDFLAGS="-L$INST_DIR/$PREFIX/lib -Wl,-rpath-link=$INST_DIR/$PREFIX/lib" \
#!/usr/bin/env bash
source "$BASEDIR"/config
-source "$BASEDIR"/common-functions.sh
+source "$BASEDIR"/scripts/common-functions.sh
function _xen_install_dependencies() {
_xen_install_dependencies
cd "$BASEDIR"
- ./git-checkout.sh $XEN_UPSTREAM_URL $XEN_UPSTREAM_REVISION xen-dir
+ ./scripts/git-checkout.sh $XEN_UPSTREAM_URL $XEN_UPSTREAM_REVISION xen-dir
cd xen-dir
./configure --prefix=$PREFIX
$MAKE
+++ /dev/null
-#!/usr/bin/env bash
-
-if [[ $# -lt 3 ]]
-then
- echo "Usage: $0 <tree> <tag> <dir>"
- exit 1
-fi
-
-TREE=$1
-TAG=$2
-DIR=$3
-
-set -e
-
-if [[ ! -d $DIR-remote ]]
-then
- rm -rf $DIR-remote $DIR-remote.tmp
- mkdir -p $DIR-remote.tmp; rmdir $DIR-remote.tmp
- $GIT clone $TREE $DIR-remote.tmp
- if [[ "$TAG" ]]
- then
- cd $DIR-remote.tmp
- $GIT branch -D dummy >/dev/null 2>&1 ||:
- $GIT checkout -b dummy $TAG
- cd ..
- fi
- mv $DIR-remote.tmp $DIR-remote
-fi
-rm -f $DIR
-ln -sf $DIR-remote $DIR
+++ /dev/null
-#!/usr/bin/env bash
-#
-# mkdeb: package $INST_DIR output in a .deb
-#
-# Takes 1 argument: the package name
-# It relies on ARCH and INST_DIR being set correctly
-
-set -e
-
-if [[ -z "$1" ]]
-then
- echo "usage: $0 package_name"
- exit 1
-fi
-
-name=$1
-
-# map the architecture, if necessary
-case "$ARCH" in
- x86_32|x86_32p) arch=i386 ;;
- x86_64) arch=amd64 ;;
- arm32) arch=armhf ;;
- arm64) arch=$ARCH;;
- *) echo "Unknown ARCH $ARCH" >&2
- exit 1
- ;;
-esac
-
-# Prepare the directory to package
-rm -rf deb
-cp -a "$INST_DIR" deb
-mkdir -p deb/opt/raisin
-cp -r data deb/opt/raisin
-cp -r components deb/opt/raisin
-cp common-functions.sh config git-checkout.sh raise.sh unraise.sh deb/opt/raisin
-
-
-# Debian doesn't use /usr/lib64 for 64-bit libraries
-if [[ -d deb/usr/lib64 ]]
-then
- cp -a deb/usr/lib64/* deb/usr/lib/
- rm -rf deb/usr/lib64
-fi
-
-# Fill in the debian boilerplate
-mkdir -p deb/DEBIAN
-cat >deb/DEBIAN/control <<EOF
-Package: $name
-Source: raisin
-Version: $(git show --oneline | head -1 | cut -d " " -f 1)
-Architecture: $arch
-Maintainer: Unmaintained snapshot
-Section: admin
-Priority: optional
-Installed-Size: $(du -ks deb | cut -f1)
-Description: Raisin build
- Warning: This is a custom build of Xen, Libvirt and other
- components; it is not an officially supported Debian package.
- It is just the output of a raish.sh wrapped in a .deb
- to make it easy to update and uninstall.
-EOF
-# Find all /etc files and add them to conffiles
-find deb/etc -type f -printf /etc/%P\\n >deb/DEBIAN/conffiles
-
-
-# Package it up
-chown -R root:root deb
-dpkg --build deb $name.deb
-
-# Tidy up after ourselves
-rm -rf deb
+++ /dev/null
-#!/usr/bin/env bash
-#
-# mkrpm: package INST_DIR in an .rpm
-#
-# Takes 1 argument: the package name
-# It relies on ARCH and INST_DIR being set correctly
-
-set -e
-
-if [[ -z "$1" ]]
-then
- echo "usage: $0 package_name"
- exit 1
-fi
-
-name="$1"
-
-# Prepare the directory to package
-rm -rf rpm
-
-# Fill in the rpm boilerplate
-mkdir -p rpm/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
-cat >rpm/SPECS/xen.spec <<EOF
-Summary: Raisin build
-Name: $name
-Version: $(git show --oneline | head -1 | cut -d " " -f 1)
-Release: 0
-License: GPL
-Group: System/Hypervisor
-URL: http://xenbits.xenproject.org/sstabellini/raisin.git
-
-%description
-This package contains the Xen hypervisor, LibVirt and associated tools,
-built from source. It is not a fully packaged and supported Xen and
-related components, just the output of Raisin wrapped in an .rpm to make
-it easy to uninstall.
-
-%build
-
-%install
-rm -rf \$RPM_BUILD_ROOT
-mkdir -p \$RPM_BUILD_ROOT
-cp -ar "$INST_DIR"/* \$RPM_BUILD_ROOT
-mkdir -p \$RPM_BUILD_ROOT/opt/raisin
-cp -r "$BASEDIR"/data \$RPM_BUILD_ROOT/opt/raisin
-cp -r "$BASEDIR"/components \$RPM_BUILD_ROOT/opt/raisin
-cp "$BASEDIR"/common-functions.sh \$RPM_BUILD_ROOT/opt/raisin
-cp "$BASEDIR"/config \$RPM_BUILD_ROOT/opt/raisin
-cp "$BASEDIR"/git-checkout.sh \$RPM_BUILD_ROOT/opt/raisin
-cp "$BASEDIR"/raise.sh \$RPM_BUILD_ROOT/opt/raisin
-cp "$BASEDIR"/unraise.sh \$RPM_BUILD_ROOT/opt/raisin
-
-%clean
-
-%post
-/sbin/ldconfig
-
-%postun
-/sbin/ldconfig
-
-%files
-%defattr(-,root,root,-)
-/*
-EOF
-
-# Package it up
-rpmbuild --define "_topdir $BASEDIR/rpm" -bb rpm/SPECS/xen.spec
-
-# Tidy up after ourselves
-mv rpm/RPMS/*/*.rpm .
-rm -rf rpm
set -e
source config
-source common-functions.sh
+source scripts/common-functions.sh
_help() {
echo "Usage: ./build.sh <options> <command>"
--- /dev/null
+#!/usr/bin/env bash
+
+# Executed once at the beginning of the script
+function common_init() {
+ export BASEDIR=`pwd`
+ export GIT=${GIT-git}
+ export SUDO=${SUDO-sudo}
+ export MAKE=${MAKE-make}
+ export PREFIX=${PREFIX-/usr}
+ export INST_DIR=${DESTDIR-dist}
+
+ INST_DIR=`readlink -f $INST_DIR`
+
+ # execution
+ if [[ $EUID -eq 0 ]]
+ then
+ export SUDO=""
+ elif [[ ! -f `which sudo 2>/dev/null` ]]
+ then
+ echo "Raisin requires sudo to install build dependencies for you."
+ echo "Please install sudo, then run this script again."
+ exit 1
+ fi
+
+ if [[ -z "$BASH_VERSINFO" || ${BASH_VERSINFO[0]} -lt 3 ||
+ (${BASH_VERSINFO[0]} -eq 3 && ${BASH_VERSINFO[1]} -lt 2) ]]
+ then
+ echo "Raisin requires BASH 3.2 or newer."
+ exit 1
+ fi
+
+ get_distro
+ get_arch
+
+ for f in `cat "$BASEDIR"/components/series`
+ do
+ source "$BASEDIR"/components/"$f"
+ done
+}
+
+function get_distro() {
+ if [[ -x "`which lsb_release 2>/dev/null`" ]]
+ then
+ os_VENDOR=`lsb_release -i -s`
+ os_RELEASE=`lsb_release -r -s`
+ os_CODENAME=`lsb_release -c -s`
+ os_UPDATE=""
+ elif [[ -r /etc/redhat-release ]]
+ then
+ # Red Hat Enterprise Linux Server release 5.5 (Tikanga)
+ # Red Hat Enterprise Linux Server release 7.0 Beta (Maipo)
+ # CentOS release 5.5 (Final)
+ # CentOS Linux release 6.0 (Final)
+ # Fedora release 16 (Verne)
+ # XenServer release 6.2.0-70446c (xenenterprise)
+ os_CODENAME=""
+ for r in "Red Hat" "CentOS" "Fedora" "XenServer"; do
+ os_VENDOR="$r"
+ if [[ -n "`grep -i \"$r\" /etc/redhat-release`" ]]
+ then
+ ver=`sed -e 's/^.* \([0-9].*\) (\(.*\)).*$/\1\|\2/' /etc/redhat-release`
+ os_CODENAME=${ver#*|}
+ os_RELEASE=${ver%|*}
+ os_UPDATE=${os_RELEASE##*.}
+ os_RELEASE=${os_RELEASE%.*}
+ break
+ fi
+ done
+ elif [[ -r /etc/SuSE-release ]]
+ then
+ for r in "openSUSE" "SUSE Linux"
+ do
+ os_VENDOR="$r"
+
+ if [[ -n "`grep -i \"$r\" /etc/SuSE-release`" ]]
+ then
+ os_CODENAME=`grep "CODENAME = " /etc/SuSE-release | \
+ sed 's:.* = ::g'`
+ os_RELEASE=`grep "VERSION = " /etc/SuSE-release | \
+ sed 's:.* = ::g'`
+ os_UPDATE=`grep "PATCHLEVEL = " /etc/SuSE-release | \
+ sed 's:.* = ::g'`
+ break
+ fi
+ done
+ # If lsb_release is not installed, we should be able to detect Debian OS
+ elif [[ -f /etc/debian_version && `cat /proc/version` =~ "Debian" ]]
+ then
+ os_VENDOR="Debian"
+ os_CODENAME=`awk '/VERSION=/' /etc/os-release | sed 's/VERSION=//' | \
+ sed -r 's/\"|\(|\)//g' | awk '{print $2}'`
+ os_RELEASE=`awk '/VERSION_ID=/' /etc/os-release | sed 's/VERSION_ID=//' \
+ | sed 's/\"//g'`
+ fi
+
+ # Simply distro version string
+ case "$os_VENDOR" in
+ "Debian"* | "Ubuntu"* | "LinuxMint"* )
+ DISTRO="Debian"
+ ;;
+ "SUSE"* )
+ DISTRO="SUSE"
+ ;;
+ "OpenSUSE"* | "openSUSE"* )
+ DISTRO="openSUSE"
+ ;;
+ "Red"* | "CentOS"* )
+ DISTRO="CentOS"
+ ;;
+ *)
+ DISTRO=$os_VENDOR
+ ;;
+ esac
+
+ export os_VENDOR os_RELEASE os_UPDATE os_CODENAME
+ export DISTRO
+}
+
+function get_arch() {
+ export ARCH=`uname -m | sed -e s/i.86/x86_32/ -e s/i86pc/x86_32/ -e \
+ s/amd64/x86_64/ -e s/armv7.*/arm32/ -e s/armv8.*/arm64/ \
+ -e s/aarch64/arm64/`
+}
+
+function install_dependencies() {
+ if [[ "$NO_DEPS" && "$NO_DEPS" -eq 1 ]]
+ then
+ echo "Not installing any dependencies, as requested."
+ echo "Depency list: $*"
+ return 0
+ fi
+ case $DISTRO in
+ "Debian" )
+ $SUDO apt-get install -y $*
+ ;;
+ "Fedora" )
+ $SUDO yum install -y $*
+ ;;
+ * )
+ echo "I don't know how to install dependencies on $DISTRO"
+ ;;
+ esac
+}
+
+function start_initscripts() {
+ while [[ $# -ge 1 ]]
+ do
+ case $DISTRO in
+ "Debian" )
+ $SUDO update-rc.d $1 defaults || echo "Couldn't set $1 to start"
+ ;;
+ "Fedora" )
+ $SUDO chkconfig --add $1 || echo "Couldn't set $1 to start"
+ ;;
+ * )
+ echo "I don't know how to start initscripts on $DISTRO"
+ return 1
+ ;;
+ esac
+ shift 1
+ done
+}
+
+function stop_initscripts() {
+ while [[ $# -ge 1 ]]
+ do
+ case $DISTRO in
+ "Debian" )
+ $SUDO update-rc.d $1 remove || echo "Couldn't remove $1 from init"
+ ;;
+ "Fedora" )
+ $SUDO chkconfig --del $1 || echo "Couldn't remove $1 from init"
+ ;;
+ * )
+ echo "I don't know how to start initscripts on $DISTRO"
+ return 1
+ ;;
+ esac
+ shift 1
+ done
+}
+
+function for_each_component () {
+ for component in `cat "$BASEDIR"/components/series`
+ do
+ capital=`echo $component | tr '[:lower:]' '[:upper:]'`
+ if eval [[ ! -z \$"$capital"_UPSTREAM_REVISION ]]
+ then
+ "$component"_"$1"
+ fi
+ done
+}
+
+function build_package() {
+ if [[ $DISTRO = "Debian" ]]
+ then
+ ./scripts/mkdeb "$1"
+ elif [[ $DISTRO = "Fedora" ]]
+ then
+ ./scripts/mkrpm "$1"
+ else
+ echo "Don't know how to create packages for $DISTRO"
+ fi
+}
+
+function install_package() {
+ if [[ $DISTRO = "Debian" ]]
+ then
+ $SUDO dpkg -i "$1".deb
+ elif [[ $DISTRO = "Fedora" ]]
+ then
+ $SUDO rpm -i --force "$1"-`git show --oneline | head -1 | cut -d " " -f 1`-0.$ARCH.rpm
+ else
+ echo "Don't know how to install packages on $DISTRO"
+ fi
+}
+
+function uninstall_package() {
+ if [[ $DISTRO = "Debian" ]]
+ then
+ $SUDO dpkg -r "$1"
+ elif [[ $DISTRO = "Fedora" ]]
+ then
+ $SUDO rpm -e "$1"
+ else
+ echo "Don't know how to uninstall packages on $DISTRO"
+ fi
+}
--- /dev/null
+#!/usr/bin/env bash
+
+if [[ $# -lt 3 ]]
+then
+ echo "Usage: $0 <tree> <tag> <dir>"
+ exit 1
+fi
+
+TREE=$1
+TAG=$2
+DIR=$3
+
+set -e
+
+if [[ ! -d $DIR-remote ]]
+then
+ rm -rf $DIR-remote $DIR-remote.tmp
+ mkdir -p $DIR-remote.tmp; rmdir $DIR-remote.tmp
+ $GIT clone $TREE $DIR-remote.tmp
+ if [[ "$TAG" ]]
+ then
+ cd $DIR-remote.tmp
+ $GIT branch -D dummy >/dev/null 2>&1 ||:
+ $GIT checkout -b dummy $TAG
+ cd ..
+ fi
+ mv $DIR-remote.tmp $DIR-remote
+fi
+rm -f $DIR
+ln -sf $DIR-remote $DIR
--- /dev/null
+#!/usr/bin/env bash
+#
+# mkdeb: package $INST_DIR output in a .deb
+#
+# Takes 1 argument: the package name
+# It relies on ARCH and INST_DIR being set correctly
+
+set -e
+
+if [[ -z "$1" ]]
+then
+ echo "usage: $0 package_name"
+ exit 1
+fi
+
+name=$1
+
+cd "$BASEDIR"
+
+# map the architecture, if necessary
+case "$ARCH" in
+ x86_32|x86_32p) arch=i386 ;;
+ x86_64) arch=amd64 ;;
+ arm32) arch=armhf ;;
+ arm64) arch=$ARCH;;
+ *) echo "Unknown ARCH $ARCH" >&2
+ exit 1
+ ;;
+esac
+
+# Prepare the directory to package
+rm -rf deb
+cp -a "$INST_DIR" deb
+mkdir -p deb/opt/raisin
+cp -r data deb/opt/raisin
+cp -r components deb/opt/raisin
+cp -r scripts deb/opt/raisin
+cp config raise.sh unraise.sh deb/opt/raisin
+
+
+# Debian doesn't use /usr/lib64 for 64-bit libraries
+if [[ -d deb/usr/lib64 ]]
+then
+ cp -a deb/usr/lib64/* deb/usr/lib/
+ rm -rf deb/usr/lib64
+fi
+
+# Fill in the debian boilerplate
+mkdir -p deb/DEBIAN
+cat >deb/DEBIAN/control <<EOF
+Package: $name
+Source: raisin
+Version: $(git show --oneline | head -1 | cut -d " " -f 1)
+Architecture: $arch
+Maintainer: Unmaintained snapshot
+Section: admin
+Priority: optional
+Installed-Size: $(du -ks deb | cut -f1)
+Description: Raisin build
+ Warning: This is a custom build of Xen, Libvirt and other
+ components; it is not an officially supported Debian package.
+ It is just the output of a raish.sh wrapped in a .deb
+ to make it easy to update and uninstall.
+EOF
+# Find all /etc files and add them to conffiles
+find deb/etc -type f -printf /etc/%P\\n >deb/DEBIAN/conffiles
+
+
+# Package it up
+chown -R root:root deb
+dpkg --build deb $name.deb
+
+# Tidy up after ourselves
+rm -rf deb
--- /dev/null
+#!/usr/bin/env bash
+#
+# mkrpm: package INST_DIR in an .rpm
+#
+# Takes 1 argument: the package name
+# It relies on ARCH and INST_DIR being set correctly
+
+set -e
+
+if [[ -z "$1" ]]
+then
+ echo "usage: $0 package_name"
+ exit 1
+fi
+
+name="$1"
+
+cd "$BASEDIR"
+
+# Prepare the directory to package
+rm -rf rpm
+
+# Fill in the rpm boilerplate
+mkdir -p rpm/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
+cat >rpm/SPECS/xen.spec <<EOF
+Summary: Raisin build
+Name: $name
+Version: $(git show --oneline | head -1 | cut -d " " -f 1)
+Release: 0
+License: GPL
+Group: System/Hypervisor
+URL: http://xenbits.xenproject.org/sstabellini/raisin.git
+
+%description
+This package contains the Xen hypervisor, LibVirt and associated tools,
+built from source. It is not a fully packaged and supported Xen and
+related components, just the output of Raisin wrapped in an .rpm to make
+it easy to uninstall.
+
+%build
+
+%install
+rm -rf \$RPM_BUILD_ROOT
+mkdir -p \$RPM_BUILD_ROOT
+cp -ar "$INST_DIR"/* \$RPM_BUILD_ROOT
+mkdir -p \$RPM_BUILD_ROOT/opt/raisin
+cp -r "$BASEDIR"/data \$RPM_BUILD_ROOT/opt/raisin
+cp -r "$BASEDIR"/components \$RPM_BUILD_ROOT/opt/raisin
+cp -r "$BASEDIR"/scripts \$RPM_BUILD_ROOT/opt/raisin
+cp "$BASEDIR"/config \$RPM_BUILD_ROOT/opt/raisin
+cp "$BASEDIR"/raise.sh \$RPM_BUILD_ROOT/opt/raisin
+cp "$BASEDIR"/unraise.sh \$RPM_BUILD_ROOT/opt/raisin
+
+%clean
+
+%post
+/sbin/ldconfig
+
+%postun
+/sbin/ldconfig
+
+%files
+%defattr(-,root,root,-)
+/*
+EOF
+
+# Package it up
+rpmbuild --define "_topdir $BASEDIR/rpm" -bb rpm/SPECS/xen.spec
+
+# Tidy up after ourselves
+mv rpm/RPMS/*/*.rpm .
+rm -rf rpm
set -e
source config
-source common-functions.sh
+source scripts/common-functions.sh
# start execution