]> xenbits.xensource.com Git - raisin.git/commitdiff
Use rpm and deb to install and uninstall the components on the system
authorStefano Stabellini <stefano.stabellini@eu.citrix.com>
Tue, 31 Mar 2015 17:48:50 +0000 (17:48 +0000)
committerStefano Stabellini <stefano.stabellini@eu.citrix.com>
Wed, 1 Apr 2015 14:51:57 +0000 (14:51 +0000)
Rather than copying files to / and manually maintain a list of installed
files, simply repackage the content of INST_DIR into a deb or rpm.
Install the simple package use dpkg or rpm.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
README
common-functions.sh
mkdeb [new file with mode: 0755]
mkrpm [new file with mode: 0755]
raise.sh
unraise.sh

diff --git a/README b/README
index 3658857a3e9cb740a5b48f91fa53b614fbe47e89..f18db4c3f3494de32fc908aa58bb7e63df0bbf8f 100644 (file)
--- a/README
+++ b/README
@@ -18,7 +18,8 @@ Set your configuration parameters in the "config" file, then run
 ./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:
 
@@ -26,12 +27,16 @@ 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 =
@@ -53,12 +58,11 @@ git clones, builds and installs the new component under DESTDIR
 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.
index df88f676f12629845c5c45bcf6936318a11c46db..c67650c35520353c69cab16da737ef5387a818d7 100644 (file)
@@ -183,3 +183,39 @@ function for_each_component () {
         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
+}
diff --git a/mkdeb b/mkdeb
new file mode 100755 (executable)
index 0000000..fd147a7
--- /dev/null
+++ b/mkdeb
@@ -0,0 +1,65 @@
+#!/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
diff --git a/mkrpm b/mkrpm
new file mode 100755 (executable)
index 0000000..47e1814
--- /dev/null
+++ b/mkrpm
@@ -0,0 +1,63 @@
+#!/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
index 64530355e6d86c7659d775441402735f89fd9a99..9d743e4b40137101094144ac3a5070cc5c35389d 100755 (executable)
--- a/raise.sh
+++ b/raise.sh
@@ -43,21 +43,23 @@ done
 
 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
index 88d49cc656081b4abe45bf50579bb17c91ecbff9..3b49f052bf02adaecce79de9a00d2707a165e408 100755 (executable)
@@ -10,23 +10,8 @@ source common-functions.sh
 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"
-