./raise.sh
Go and grab a coffee. When the script completes, you'll have a full
-Xen system installation under DESTDIR.
+Xen system installation under DESTDIR and a deb or rpm package
+(depending on your distro) containing all the necessary binaries.
raise.sh takes care of:
- installing all the dependencies needed to build each components (requires sudo)
- building them
- installing them under DESTDIR (the "dist" sub-directory by default)
+- creating a deb or rpm package with all the content
raise.sh can optionally perform the installation under / and fully
configure the system for you. If you want this behaviour run
./raise.sh -i
+raise.sh performs the installation by installing the deb or rpm package,
+hence it can be easily uninstalled by unraise.sh or manually by the
+user.
= Adding new components =
cleans the build
* component_configure
-The component has already been installed under /, now configure the
-system for it
+The component has already been installed, now configure the system for
+it
* component_unconfigure
-The component has already been uninstalled from /, now remove the
-configuration
+The component has already been uninstalled, now remove the configuration
These functions are called by raise.sh automatically if the component is
enabled in the config.
fi
done
}
+
+function build_package() {
+ if test $DISTRO = "Debian"
+ then
+ ./mkdeb "$1"
+ elif test $DISTRO = "Fedora"
+ then
+ ./mkrpm "$1"
+ else
+ echo "Don't know how to create packages for $DISTRO"
+ fi
+}
+
+function install_package() {
+ if test $DISTRO = "Debian"
+ then
+ $SUDO dpkg -i "$1".deb
+ elif test $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 test $DISTRO = "Debian"
+ then
+ $SUDO dpkg -r "$1"
+ elif test $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
+#
+# 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 test -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
+
+# Debian doesn't use /usr/lib64 for 64-bit libraries
+if test -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 test -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
+
+%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
mkdir -p "$INST_DIR" &>/dev/null
install_dependencies git
+if test $DISTRO = "Fedora"
+then
+ install_dependencies rpm-build
+fi
# build and install under $DESTDIR
for_each_component clean
for_each_component build
+build_package xen-system
+
if test -z "$INST" || test "$INST" -eq 0
then
exit 0
fi
-# install under /
-TMPFILE=`mktemp`
-cd "$INST_DIR"
-find . > $TMPFILE
-$SUDO mv -f $TMPFILE /var/log/raisin.log
-$SUDO cp -ar * / || true
+
+install_package xen-system
# configure
for_each_component configure
common_init
for_each_component clean
-for_each_component unconfigure
-for i in `cat /var/log/raisin.log 2>/dev/null`
-do
- if test ! -d /"$i"
- then
- rm -f /"$i"
- fi
-done
-for i in `cat /var/log/raisin.log 2>/dev/null`
-do
- if test -d /"$i"
- then
- rmdir --ignore-fail-on-non-empty /"$i" &> /dev/null || true
- fi
-done
+uninstall_package xen-system
+for_each_component unconfigure
-rm -rf /var/log/raisin.log
rm -rf "$INST_DIR"
-