File kiwi-instsource-plugins-openSUSE-12-1.diff of Package kiwi-instsource-plugins-openSUSE-12-1

Index: KIWILiveTreePlugin.pm
===================================================================
--- KIWILiveTreePlugin.pm.orig
+++ KIWILiveTreePlugin.pm
@@ -109,16 +109,6 @@ sub new
 }
 # /constructor
 
-sub logandrename($$$$)
-{
-  my $this = shift;
-  my $dname = shift;
-  my $oname = shift;
-  my $nname = shift;
-  $this->logMsg("I", "Renaming $dname/$oname to $dname/$nname");
-  rename("$dname/$oname", "$dname/$nname") || die "no such file!";
-}
-
 # returns: number of patched gfxboot files
 sub execute
 {
@@ -141,24 +131,22 @@ sub execute
     return $retval;
   }
 
-  my $x11cd = undef;
-  find( sub { if (m/kiwi-profiled-livecd-kde.i586.iso/) { $x11cd = $File::Find::name; }  }, $this->handler()->collect()->basedir());
-  if (!$x11cd) {
+  my $medium = $this->collect()->productData()->getVar("MEDIUM_NAME");
+  my $cd = undef;
+  find( sub { if (m/.iso/) { $cd = $File::Find::name; }  }, $this->handler()->collect()->basedir());
+  if (!$cd) {
 	$this->logMsg("E", "Initial CD not found\n");
 	exit(1);
   }
-  print "$x11cd\n";
-  my $dname = dirname($x11cd);
-  print "$dname\n";
-  my $base = basename($dname);
-  $base =~ s,openSUSE-Live-Tree-i586-x86_64,,;
-
-  #logandrename($this, $dname, "kiwi-profiled-livecd-x11.i586.iso", "openSUSE-X11-LiveCD-i686-$base.iso");
-  #logandrename($this, $dname, "kiwi-profiled-livecd-x11.x86_64.iso", "openSUSE-X11-LiveCD-x86_64-$base.iso");
-  logandrename($this, $dname, "kiwi-profiled-livecd-kde.i586.iso", "openSUSE-KDE-LiveCD-i686$base.iso");
-  logandrename($this, $dname, "kiwi-profiled-livecd-kde.x86_64.iso", "openSUSE-KDE-LiveCD-x86_64$base.iso");
-  logandrename($this, $dname, "kiwi-profiled-livecd-gnome.i586.iso", "openSUSE-GNOME-LiveCD-i686$base.iso");
-  logandrename($this, $dname, "kiwi-profiled-livecd-gnome.x86_64.iso", "openSUSE-GNOME-LiveCD-x86_64$base.iso");
+  $this->logMsg("I", "$cd $medium");
+  my $dname = dirname($cd);
+  $this->logMsg("I", "$dname");
+
+  my $nname = "$medium.iso";
+  $nname =~ s,-i586-,-i686-,;
+
+  $this->logMsg("I", "Renaming $cd to $dname/$nname");
+  rename($cd, "$dname/$nname") || $this->logMsg("E", "could not rename $cd");
 
   return $retval;
 }
Index: KIWIDescrPlugin.pm
===================================================================
--- KIWIDescrPlugin.pm.orig
+++ KIWIDescrPlugin.pm
@@ -230,6 +230,25 @@ sub executeDir
 	 return 1;
      }
   }
+  # one more time for english to insert possible EULAs
+  my $cmd = "/usr/bin/translate_packages.pl en < $targetdir/packages.en > $targetdir/packages.en.new && mv $targetdir/packages.en.new $targetdir/packages.en";
+  my $data = qx( $cmd );
+  if($? >> 8) {
+     $this->logMsg("E", "Calling <translate_packages.pl en > failed:\n$data\n");
+     return 1;
+  }
+
+  if (-x "/usr/bin/extract-appdata-icons" && -s "$targetdir/appdata.xml") {
+     my $cmd = "/usr/bin/extract-appdata-icons $targetdir/appdata.xml $targetdir";
+     my $data = qx( $cmd );
+     if($? >> 8) {
+       $this->logMsg("E", "Calling <extract-appdata-icons $targetdir/appdata.xml $targetdir> failed:\n$data\n");
+       return 1;
+     }
+     if($this->{m_compress} =~ m{yes}i) {
+         system("gzip", "--rsyncable", "$targetdir/appdata.xml");
+     }
+  }
 
   if($this->{m_compress} =~ m{yes}i) {
       foreach my $pfile(glob("$targetdir/packages*")) {
Index: KIWIPromoDVDPlugin.ini
===================================================================
--- /dev/null
+++ KIWIPromoDVDPlugin.ini
@@ -0,0 +1,5 @@
+[base]
+name = KIWIPromoDVDPlugin
+order = 7
+defaultenable = 1
+
Index: KIWIPromoDVDPlugin.pm
===================================================================
--- /dev/null
+++ KIWIPromoDVDPlugin.pm
@@ -0,0 +1,149 @@
+################################################################
+# Copyright (c) 2012 SUSE
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program (see the file LICENSE); if not, write to the
+# Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+#
+################################################################
+
+#================
+# FILE          : KIWIPromoDVDPlugin.pm
+#----------------
+# PROJECT       : OpenSUSE Build-Service
+# COPYRIGHT     : (c) 2012 SUSE LINUX Products GmbH, Germany
+#               :
+# AUTHOR        : Stephan Kulow <coolo@suse.de>
+#               :
+# BELONGS TO    : Operating System images
+#               :
+# DESCRIPTION   : Module patching mini iso builds
+#               :
+# STATUS        : Development
+#----------------
+
+package KIWIPromoDVDPlugin;
+
+use strict;
+
+use base "KIWIBasePlugin";
+use Data::Dumper;
+use Config::IniFiles;
+use File::Find;
+use File::Basename;
+
+
+sub new
+{
+  # ...
+  # Create a new KIWIPromoDVDPlugin object
+  # ---
+  my $class   = shift;
+  my $handler = shift;
+  my $config  = shift;
+
+  my $this = new KIWIBasePlugin($handler);
+  bless ($this, $class);
+
+  $config =~ m{(.*)/([^/]+)$};
+  my $configpath = $1;
+  my $configfile = $2;
+  if(not defined($configpath) or not defined($configfile)) {
+    $this->logMsg("E", "wrong parameters in plugin initialisation\n");
+    return undef;
+  }
+
+  ## now gather all necessary information from the inifile:
+  #===
+  # Issue: why duplicate code here? Why not put it into the base class?
+  # Answer: Each plugin may have different options. Some only need a target filename,
+  # whilst some others may need much more. I don't want to specify a complicated framework
+  # for the plugin, it shall just be a simple straightforward way to get information
+  # into the plugin. The idea is that the people who decide on the metadata write
+  # the plugin, and therefore damn well know what it needs and what not.
+  # I'm definitely not bothering PMs with Yet Another File Specification (tm)
+  #---
+
+  ## plugin content:
+  #-----------------
+  #[base]
+  #name = KIWIEulaPlugin
+  #order = 3
+  #defaultenable = 1
+  #
+  #[target]
+  #targetfile = content
+  #targetdir = $PRODUCT_DIR
+  #media = (list of numbers XOR "all")
+  #
+  my $ini = new Config::IniFiles( -file => "$configpath/$configfile" );
+  my $name	= $ini->val('base', 'name'); # scalar value
+  my $order	= $ini->val('base', 'order'); # scalar value
+  my $enable	= $ini->val('base', 'defaultenable'); # scalar value
+
+  # if any of those isn't set, complain!
+  if(not defined($name)
+     or not defined($order)
+     or not defined($enable)
+    ) {
+    $this->logMsg("E", "Plugin ini file <$config> seems broken!\n");
+    return undef;
+  }
+
+  $this->name($name);
+  $this->order($order);
+  if($enable != 0) {
+    $this->ready(1);
+  }
+  return $this;
+}
+# /constructor
+
+# returns: number of patched gfxboot files
+sub execute
+{
+  my $this = shift;
+  if(not ref($this)) {
+    return undef;
+  }
+  my $retval = 0;
+  # sanity check:
+  if($this->{m_ready} == 0) {
+    return $retval;
+  }
+
+  my $ismini = $this->collect()->productData()->getVar("FLAVOR");
+  if(not defined($ismini)) {
+    $this->logMsg("W", "FLAVOR not set?");
+    return $retval;
+  }
+  if($ismini !~ m{dvd-promo}i) {
+    return $retval;
+  }
+
+  my $medium = $this->collect()->productData()->getVar("MEDIUM_NAME");
+  find( sub { 
+     if (m/initrd.liv/) { 
+       my $cd = $File::Find::name; 
+       system("mkdir -p boot; echo $medium > boot/mbrid");
+       system("echo boot/mbrid | cpio --create --format=newc --quiet | gzip -9 -f >> $cd");
+       system("rm boot/mbrid; rmdir boot");
+       $this->logMsg("I", "updated $cd");
+      }  
+     }, $this->handler()->collect()->basedir());
+
+  return $retval;
+}
+
+1;
+
Index: KIWIFinishEFIPlugin.ini
===================================================================
--- /dev/null
+++ KIWIFinishEFIPlugin.ini
@@ -0,0 +1,5 @@
+[base]
+name = KIWIFinishEFIPlugin
+order = 10
+defaultenable = 1
+
Index: KIWIFinishEFIPlugin.pm
===================================================================
--- /dev/null
+++ KIWIFinishEFIPlugin.pm
@@ -0,0 +1,144 @@
+################################################################
+# Copyright (c) 2012 SUSE
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program (see the file LICENSE); if not, write to the
+# Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+#
+################################################################
+
+#================
+# FILE          : KIWIFinishEFIPlugin.pm
+#----------------
+# PROJECT       : OpenSUSE Build-Service
+# COPYRIGHT     : (c) 2012 SUSE LINUX Products GmbH, Germany
+#               :
+# AUTHOR        : Stephan Kulow <coolo@suse.de>
+#               :
+# BELONGS TO    : Operating System images
+#               :
+# DESCRIPTION   : Module patching mini iso builds
+#               :
+# STATUS        : Development
+#----------------
+
+package KIWIFinishEFIPlugin;
+
+use strict;
+
+use base "KIWIBasePlugin";
+use Data::Dumper;
+use Config::IniFiles;
+use File::Find;
+use File::Basename;
+use KIWIQX qw (qxx);
+
+
+sub new
+{
+  # ...
+  # Create a new KIWIFinishEFIPlugin object
+  # ---
+  my $class   = shift;
+  my $handler = shift;
+  my $config  = shift;
+
+  my $this = new KIWIBasePlugin($handler);
+  bless ($this, $class);
+
+  $config =~ m{(.*)/([^/]+)$};
+  my $configpath = $1;
+  my $configfile = $2;
+  if(not defined($configpath) or not defined($configfile)) {
+    $this->logMsg("E", "wrong parameters in plugin initialisation\n");
+    return undef;
+  }
+
+  ## now gather all necessary information from the inifile:
+  #===
+  # Issue: why duplicate code here? Why not put it into the base class?
+  # Answer: Each plugin may have different options. Some only need a target filename,
+  # whilst some others may need much more. I don't want to specify a complicated framework
+  # for the plugin, it shall just be a simple straightforward way to get information
+  # into the plugin. The idea is that the people who decide on the metadata write
+  # the plugin, and therefore damn well know what it needs and what not.
+  # I'm definitely not bothering PMs with Yet Another File Specification (tm)
+  #---
+
+  ## plugin content:
+  #-----------------
+  #[base]
+  #name = KIWIEulaPlugin
+  #order = 3
+  #defaultenable = 1
+  #
+  #[target]
+  #targetfile = content
+  #targetdir = $PRODUCT_DIR
+  #media = (list of numbers XOR "all")
+  #
+  my $ini = new Config::IniFiles( -file => "$configpath/$configfile" );
+  my $name	= $ini->val('base', 'name'); # scalar value
+  my $order	= $ini->val('base', 'order'); # scalar value
+  my $enable	= $ini->val('base', 'defaultenable'); # scalar value
+
+  # if any of those isn't set, complain!
+  if(not defined($name)
+     or not defined($order)
+     or not defined($enable)
+    ) {
+    $this->logMsg("E", "Plugin ini file <$config> seems broken!\n");
+    return undef;
+  }
+
+  $this->name($name);
+  $this->order($order);
+  if($enable != 0) {
+    $this->ready(1);
+  }
+  return $this;
+}
+# /constructor
+
+# returns: number of patched gfxboot files
+sub execute
+{
+  my $this = shift;
+  if(not ref($this)) {
+    return undef;
+  }
+  my $retval = 0;
+  # sanity check:
+  if($this->{m_ready} == 0) {
+    return $retval;
+  }
+  my $cd = 1;
+
+  my %type;
+  %type = %{$this->collect()->{m_xml}->getImageTypeAndAttributes_legacy()};
+  my $firmware = $type{firmware};
+  if ($firmware eq "efi" || $firmware eq "uefi") {
+    my $dir = $this->collect()->basesubdirs()->{$cd};
+
+    my $efi = "$dir/boot/x86_64/efi";
+    $this->logMsg("I", "creating $efi");
+    qxx("dd if=/dev/zero of=$efi bs=1M count=4");
+    qxx("/usr/sbin/mkdosfs -n 'BOOT' $efi");
+    qxx("mcopy -Do -s -i $efi $dir/EFI ::");
+  }
+
+  return $retval;
+}
+
+1;
+
Index: KIWIMiniIsoPlugin.pm
===================================================================
--- KIWIMiniIsoPlugin.pm.orig
+++ KIWIMiniIsoPlugin.pm
@@ -41,6 +41,7 @@ use Data::Dumper;
 use Config::IniFiles;
 use File::Find;
 
+use KIWIQX qw (qxx);
 
 sub new
 {
@@ -225,6 +226,29 @@ sub execute
     close(F);
     $retval++;
   }
+
+  my $grubcfg = $this->collect()->basesubdirs()->{1} . "/EFI/BOOT/grub.cfg";
+  if ( -f $grubcfg ) {
+    $this->logMsg("I", "editing <$grubcfg>");
+    open(IN, $grubcfg) || die "oops";
+    open(OUT, ">", "$grubcfg.new") || die "can't open output";
+    while( <IN> ) {
+      my $line = $_;
+      chomp $line;
+      $this->logMsg("I", "-$line");
+      $line =~ s,(linuxefi /boot/x86_64/loader/linux),$1 install=$repoloc,;
+      $this->logMsg("I", "+$line");
+      print OUT "$line\n";
+    }
+    close(OUT);
+    close(IN); 
+    qxx("diff -u $grubcfg $grubcfg.new");
+    rename("$grubcfg.new", $grubcfg);
+  } else {
+    $this->logMsg("I", "no grub.cfg at <$grubcfg>");
+  }
+ 
+
   return $retval;
 }
 
openSUSE Build Service is sponsored by