]> xenbits.xensource.com Git - people/dariof/xen-tools.git/commitdiff
Move examples from debian/examples to examples
authorAxel Beckert <abe@deuxchevaux.org>
Thu, 17 Jan 2013 16:50:43 +0000 (17:50 +0100)
committerAxel Beckert <abe@deuxchevaux.org>
Thu, 17 Jan 2013 16:51:16 +0000 (17:51 +0100)
debian/changelog
debian/examples/setup-kernel-initrd [deleted file]
debian/examples/update-modules [deleted file]
debian/rules
examples/setup-kernel-initrd [new file with mode: 0755]
examples/update-modules [new file with mode: 0755]

index be970787c7a1f39b9a687a1001bdf331de95b609..d1a6bad50f78a3070fe4be4cba0875eafbbc1113 100644 (file)
@@ -15,6 +15,7 @@ xen-tools (4.4~dev-1) UNRELEASED; urgency=low
     - Preliminary support for xl toolstack
     - xen-create-image: Consistently use runCommand() instead of system()
     - Makefile accepts DESTDIR=…
+    - Move examples from debian/examples to examples.
   * Add debian/gbp.conf to be able to to build xen-tools with
     git-buildpackage.
   * debian/rules: Don't mention (generated) upstream changelog explicitly,
diff --git a/debian/examples/setup-kernel-initrd b/debian/examples/setup-kernel-initrd
deleted file mode 100755 (executable)
index 9a9a6f3..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-#!/bin/sh
-#
-#  This script is designed to setup the kernel and ramdisk inside
-# the xen-tools configuration file; and also update any stored values
-# in any pre-generated Xen guests.
-#
-#  This is useful if you have upgraded your Xen kernel.
-#
-# Steve
-# --
-#
-
-
-
-
-#
-#  Find the kernel to use, and the ramdisk, unless they are specified
-# in the environment.
-#
-if [ -z "${kernel}" ]; then
-    kernel=`ls -1 /boot| grep ^vm| grep -v syms| grep xen | sort -r| head -n 1`
-    kernel="/boot/${kernel}"
-fi
-if [ -z "${ramdisk}" ]; then
-    ramdisk=`ls -1 /boot| grep ^init| grep xen| sort -r| head -n 1`
-    ramdisk="/boot/${ramdisk}"
-fi
-
-
-#
-#  Abort if we didn't find a kernel / ramdisk
-#
-if [ -z "${kernel}" ]; then
-    echo "Failed to find Xen kernel."
-    exit
-fi
-if [ -z "${ramdisk}" ]; then
-    echo "Failed to find Xen ramdisk."
-    exit
-fi
-
-
-#
-#  Show what we're going to do - and prompt for confirmation.
-#
-cat <<EOF
-
-  Updating xen-tools configuration file, and all Xen guests with:
-
-    kernel  : ${kernel}
-    ramdisk : ${ramdisk}
-
-  Press enter to continue, or Ctrl-c to abort.
-
-EOF
-read __dummy
-
-
-
-#
-#  Update the xen-tools configuration file.
-#
-perl -pi -e "s|^\s*kernel\s*=(.*)|kernel = ${kernel}|" /etc/xen-tools/xen-tools.conf
-perl -pi -e "s|^\s*initrd\s*=(.*)|initrd = ${ramdisk}|" /etc/xen-tools/xen-tools.conf
-
-
-
-
-
-#
-#  Now modify each of the Xen guest configuration files beneath /etc/xen.
-#
-for i in /etc/xen/*.cfg; do
-    
-    # test that the file exists - ie. glob succeeded.
-    if [ -e $i ]; then
-                
-        #
-        #  Upgrade kernel + ramdisk
-        #
-        perl -pi -e "s|^\s*kernel\s*=(.*)|kernel = '${kernel}'|" $i
-        perl -pi -e "s|^\s*ramdisk\s*=(.*)|ramdisk = '${ramdisk}'|" $i
-
-    fi
-
-done
-
diff --git a/debian/examples/update-modules b/debian/examples/update-modules
deleted file mode 100755 (executable)
index 38e1317..0000000
+++ /dev/null
@@ -1,233 +0,0 @@
-#!/usr/bin/perl
-#
-#  This code is intended to update the modules installed within each
-# Xen guest domain to the named version.
-#
-#  It should be fairly safe, but I make no promises - hence why this
-# is an example.
-#
-# Steve
-# --
-#
-
-use strict;
-use warnings;
-
-use File::Path qw/ rmtree  /;
-use File::Temp qw/ tempdir /;
-
-
-my $modules = shift;
-if ( ! defined( $modules ) )
-{
-    print <<EOF;
-
- Usage: $0 <modules>
-
-  eg: $0 2.6.18.xx|/usr/lib/modules/nn.nn.nn-xen
-
-EOF
-  exit;
-}
-
-
-#
-#  Make sure the path is fully qualified.
-#
-if ( $modules !~ /^[\/\\]/ )
-{
-    $modules = "/lib/modules/" . $modules;
-}
-
-
-#
-#  Make sure the module directory exists.
-#
-if ( ! -d $modules )
-{
-    print "The modules directory $modules doesn't exist.\n";
-    exit;
-}
-
-
-#
-#  OK now we have the modules so we need to:
-#
-#  0.  Read our configuration file.
-#  1.  Find each xen guest.
-#  2.  Ensure it isn't running (TODO)
-#  3.  Mount the disk image.
-#  4.  Remove existing modules, and copy in the specified ones.
-#
-#
-
-
-my %CONFIG;
-readConfigurationFile( "/etc/xen-tools/xen-tools.conf" );
-
-
-foreach my $guest ( findGuests() )
-{
-    print "Attempting to update guest: $guest\n";
-
-    #
-    #  Create a temporary directory to mount the disk upon.
-    #
-    my $tmp = tempdir( CLEANUP => 1 );
-
-    #
-    # Mount the disk.
-    #
-    if ( $CONFIG{'dir'} )
-    {
-        # The loopback image.
-        my $img =  $CONFIG{'dir'} . "/domains/" . $guest . "/disk.img";
-        system( "mount -o loop $img $tmp" );
-    }
-    elsif ( $CONFIG{'lvm'} )
-    {
-        # The LVM volume
-        my $img = "/dev/" . $CONFIG{'lvm'} . "/$guest-disk";
-        system( "mount $img $tmp" );
-    }
-    else
-    {
-        print "Unhandled disk format - can't mount\n";
-        next;
-    }
-
-
-    #
-    #  We've got it mounted.
-    #
-    print "\tMounted disk image.\n";
-
-    # make sure we have a directory
-    if ( ! -d $tmp . "/lib/modules" )
-    {
-        print "\tMissing modules.  Skipping\n";
-        next;
-    }
-    #
-    #  Remove the existing module directories.
-    #
-    `rm -rf  $tmp/lib/modules`;
-    mkdir $tmp . "/lib/modules";
-    print "\tRemoved existing modules\n";
-
-    #
-    #  Copy existing directory.
-    #
-    if ( -d $tmp . "/lib/modules" )
-    {
-        `cp -R $modules $tmp/lib/modules/`;
-        print "\tCopied over $modules\n";
-    }
-    else
-    {
-        print "No module directory .. weirdness\n";
-    }
-
-    #
-    #  Unmount
-    #
-    system( "umount $tmp" );
-    print "\tUnmounted disk image.\n\n";
-}
-
-
-
-
-=begin doc
-
-  Find each xen guest upon the system.
-
-=end doc
-
-=cut
-
-sub findGuests
-{
-    my @results;
-
-    #
-    #  Assume xen-tools.
-    #
-    foreach my $file ( glob( "/etc/xen/*.cfg" ) )
-    {
-        #
-        #  Find the name.
-        #
-        open( INPUT, "<" , $file );
-        foreach my $line ( <INPUT> )
-        {
-            chomp( $line );
-            if ( $line =~ /name\s*=\s*['"]([^'"]+)["']/ )
-            {
-                push @results, $1;
-            }
-        }
-        close( INPUT );
-    }
-    return( sort( @results ) );
-}
-
-
-
-
-=begin doc
-
-  Read the configuration file specified.
-
-=end doc
-
-=cut
-
-sub readConfigurationFile
-{
-    my ($file) = ( @_ );
-
-    open( FILE, "<", $file ) or die "Cannot read file '$file' - $!";
-
-    my $line       = "";
-
-    while (defined($line = <FILE>) )
-    {
-        chomp $line;
-        if ($line =~ s/\\$//)
-        {
-            $line .= <FILE>;
-            redo unless eof(FILE);
-        }
-
-        # Skip lines beginning with comments
-        next if ( $line =~ /^([ \t]*)\#/ );
-
-        # Skip blank lines
-        next if ( length( $line ) < 1 );
-
-        # Strip trailing comments.
-        if ( $line =~ /(.*)\#(.*)/ )
-        {
-            $line = $1;
-        }
-
-        # Find variable settings
-        if ( $line =~ /([^=]+)=([^\n]+)/ )
-        {
-            my $key = $1;
-            my $val = $2;
-
-            # Strip leading and trailing whitespace.
-            $key =~ s/^\s+//;
-            $key =~ s/\s+$//;
-            $val =~ s/^\s+//;
-            $val =~ s/\s+$//;
-
-            # Store value.
-            $CONFIG{ $key } = $val;
-        }
-    }
-
-    close( FILE );
-}
index 07f9c5dc212722d0b12800fc1f0253bb6a39260b..fe290bc1e0464ab59ab3283980ad34ab8eed63ca 100755 (executable)
@@ -41,7 +41,7 @@ binary-indep: build install
        dh_testdir
        dh_testroot
        dh_install
-       dh_installexamples debian/examples/setup-kernel-initrd debian/examples/update-modules
+       dh_installexamples examples/setup-kernel-initrd examples/update-modules
        dh_installchangelogs
        dh_installdocs
        dh_compress
diff --git a/examples/setup-kernel-initrd b/examples/setup-kernel-initrd
new file mode 100755 (executable)
index 0000000..9a9a6f3
--- /dev/null
@@ -0,0 +1,87 @@
+#!/bin/sh
+#
+#  This script is designed to setup the kernel and ramdisk inside
+# the xen-tools configuration file; and also update any stored values
+# in any pre-generated Xen guests.
+#
+#  This is useful if you have upgraded your Xen kernel.
+#
+# Steve
+# --
+#
+
+
+
+
+#
+#  Find the kernel to use, and the ramdisk, unless they are specified
+# in the environment.
+#
+if [ -z "${kernel}" ]; then
+    kernel=`ls -1 /boot| grep ^vm| grep -v syms| grep xen | sort -r| head -n 1`
+    kernel="/boot/${kernel}"
+fi
+if [ -z "${ramdisk}" ]; then
+    ramdisk=`ls -1 /boot| grep ^init| grep xen| sort -r| head -n 1`
+    ramdisk="/boot/${ramdisk}"
+fi
+
+
+#
+#  Abort if we didn't find a kernel / ramdisk
+#
+if [ -z "${kernel}" ]; then
+    echo "Failed to find Xen kernel."
+    exit
+fi
+if [ -z "${ramdisk}" ]; then
+    echo "Failed to find Xen ramdisk."
+    exit
+fi
+
+
+#
+#  Show what we're going to do - and prompt for confirmation.
+#
+cat <<EOF
+
+  Updating xen-tools configuration file, and all Xen guests with:
+
+    kernel  : ${kernel}
+    ramdisk : ${ramdisk}
+
+  Press enter to continue, or Ctrl-c to abort.
+
+EOF
+read __dummy
+
+
+
+#
+#  Update the xen-tools configuration file.
+#
+perl -pi -e "s|^\s*kernel\s*=(.*)|kernel = ${kernel}|" /etc/xen-tools/xen-tools.conf
+perl -pi -e "s|^\s*initrd\s*=(.*)|initrd = ${ramdisk}|" /etc/xen-tools/xen-tools.conf
+
+
+
+
+
+#
+#  Now modify each of the Xen guest configuration files beneath /etc/xen.
+#
+for i in /etc/xen/*.cfg; do
+    
+    # test that the file exists - ie. glob succeeded.
+    if [ -e $i ]; then
+                
+        #
+        #  Upgrade kernel + ramdisk
+        #
+        perl -pi -e "s|^\s*kernel\s*=(.*)|kernel = '${kernel}'|" $i
+        perl -pi -e "s|^\s*ramdisk\s*=(.*)|ramdisk = '${ramdisk}'|" $i
+
+    fi
+
+done
+
diff --git a/examples/update-modules b/examples/update-modules
new file mode 100755 (executable)
index 0000000..38e1317
--- /dev/null
@@ -0,0 +1,233 @@
+#!/usr/bin/perl
+#
+#  This code is intended to update the modules installed within each
+# Xen guest domain to the named version.
+#
+#  It should be fairly safe, but I make no promises - hence why this
+# is an example.
+#
+# Steve
+# --
+#
+
+use strict;
+use warnings;
+
+use File::Path qw/ rmtree  /;
+use File::Temp qw/ tempdir /;
+
+
+my $modules = shift;
+if ( ! defined( $modules ) )
+{
+    print <<EOF;
+
+ Usage: $0 <modules>
+
+  eg: $0 2.6.18.xx|/usr/lib/modules/nn.nn.nn-xen
+
+EOF
+  exit;
+}
+
+
+#
+#  Make sure the path is fully qualified.
+#
+if ( $modules !~ /^[\/\\]/ )
+{
+    $modules = "/lib/modules/" . $modules;
+}
+
+
+#
+#  Make sure the module directory exists.
+#
+if ( ! -d $modules )
+{
+    print "The modules directory $modules doesn't exist.\n";
+    exit;
+}
+
+
+#
+#  OK now we have the modules so we need to:
+#
+#  0.  Read our configuration file.
+#  1.  Find each xen guest.
+#  2.  Ensure it isn't running (TODO)
+#  3.  Mount the disk image.
+#  4.  Remove existing modules, and copy in the specified ones.
+#
+#
+
+
+my %CONFIG;
+readConfigurationFile( "/etc/xen-tools/xen-tools.conf" );
+
+
+foreach my $guest ( findGuests() )
+{
+    print "Attempting to update guest: $guest\n";
+
+    #
+    #  Create a temporary directory to mount the disk upon.
+    #
+    my $tmp = tempdir( CLEANUP => 1 );
+
+    #
+    # Mount the disk.
+    #
+    if ( $CONFIG{'dir'} )
+    {
+        # The loopback image.
+        my $img =  $CONFIG{'dir'} . "/domains/" . $guest . "/disk.img";
+        system( "mount -o loop $img $tmp" );
+    }
+    elsif ( $CONFIG{'lvm'} )
+    {
+        # The LVM volume
+        my $img = "/dev/" . $CONFIG{'lvm'} . "/$guest-disk";
+        system( "mount $img $tmp" );
+    }
+    else
+    {
+        print "Unhandled disk format - can't mount\n";
+        next;
+    }
+
+
+    #
+    #  We've got it mounted.
+    #
+    print "\tMounted disk image.\n";
+
+    # make sure we have a directory
+    if ( ! -d $tmp . "/lib/modules" )
+    {
+        print "\tMissing modules.  Skipping\n";
+        next;
+    }
+    #
+    #  Remove the existing module directories.
+    #
+    `rm -rf  $tmp/lib/modules`;
+    mkdir $tmp . "/lib/modules";
+    print "\tRemoved existing modules\n";
+
+    #
+    #  Copy existing directory.
+    #
+    if ( -d $tmp . "/lib/modules" )
+    {
+        `cp -R $modules $tmp/lib/modules/`;
+        print "\tCopied over $modules\n";
+    }
+    else
+    {
+        print "No module directory .. weirdness\n";
+    }
+
+    #
+    #  Unmount
+    #
+    system( "umount $tmp" );
+    print "\tUnmounted disk image.\n\n";
+}
+
+
+
+
+=begin doc
+
+  Find each xen guest upon the system.
+
+=end doc
+
+=cut
+
+sub findGuests
+{
+    my @results;
+
+    #
+    #  Assume xen-tools.
+    #
+    foreach my $file ( glob( "/etc/xen/*.cfg" ) )
+    {
+        #
+        #  Find the name.
+        #
+        open( INPUT, "<" , $file );
+        foreach my $line ( <INPUT> )
+        {
+            chomp( $line );
+            if ( $line =~ /name\s*=\s*['"]([^'"]+)["']/ )
+            {
+                push @results, $1;
+            }
+        }
+        close( INPUT );
+    }
+    return( sort( @results ) );
+}
+
+
+
+
+=begin doc
+
+  Read the configuration file specified.
+
+=end doc
+
+=cut
+
+sub readConfigurationFile
+{
+    my ($file) = ( @_ );
+
+    open( FILE, "<", $file ) or die "Cannot read file '$file' - $!";
+
+    my $line       = "";
+
+    while (defined($line = <FILE>) )
+    {
+        chomp $line;
+        if ($line =~ s/\\$//)
+        {
+            $line .= <FILE>;
+            redo unless eof(FILE);
+        }
+
+        # Skip lines beginning with comments
+        next if ( $line =~ /^([ \t]*)\#/ );
+
+        # Skip blank lines
+        next if ( length( $line ) < 1 );
+
+        # Strip trailing comments.
+        if ( $line =~ /(.*)\#(.*)/ )
+        {
+            $line = $1;
+        }
+
+        # Find variable settings
+        if ( $line =~ /([^=]+)=([^\n]+)/ )
+        {
+            my $key = $1;
+            my $val = $2;
+
+            # Strip leading and trailing whitespace.
+            $key =~ s/^\s+//;
+            $key =~ s/\s+$//;
+            $val =~ s/^\s+//;
+            $val =~ s/\s+$//;
+
+            # Store value.
+            $CONFIG{ $key } = $val;
+        }
+    }
+
+    close( FILE );
+}