diff --git a/xCAT-server/share/xcat/install/sle/compute.pkglist b/xCAT-server/share/xcat/install/sle/compute.pkglist
deleted file mode 120000
index 0e114f64f..000000000
--- a/xCAT-server/share/xcat/install/sle/compute.pkglist
+++ /dev/null
@@ -1 +0,0 @@
-compute.sle15.pkglist
\ No newline at end of file
diff --git a/xCAT-server/share/xcat/install/sle/compute.tmpl b/xCAT-server/share/xcat/install/sle/compute.tmpl
deleted file mode 120000
index 357788ec3..000000000
--- a/xCAT-server/share/xcat/install/sle/compute.tmpl
+++ /dev/null
@@ -1 +0,0 @@
-compute.sle15.tmpl
\ No newline at end of file
diff --git a/xCAT-server/share/xcat/install/sle/compute.sle15.pkglist b/xCAT-server/share/xcat/install/sles/compute.sle15.pkglist
similarity index 100%
rename from xCAT-server/share/xcat/install/sle/compute.sle15.pkglist
rename to xCAT-server/share/xcat/install/sles/compute.sle15.pkglist
diff --git a/xCAT-server/share/xcat/install/sle/compute.sle15.tmpl b/xCAT-server/share/xcat/install/sles/compute.sle15.tmpl
similarity index 100%
rename from xCAT-server/share/xcat/install/sle/compute.sle15.tmpl
rename to xCAT-server/share/xcat/install/sles/compute.sle15.tmpl
diff --git a/xCAT-server/share/xcat/install/sles/service.sle15.pkglist b/xCAT-server/share/xcat/install/sles/service.sle15.pkglist
new file mode 100644
index 000000000..23c37900d
--- /dev/null
+++ b/xCAT-server/share/xcat/install/sles/service.sle15.pkglist
@@ -0,0 +1,22 @@
+@base
+@x11
+openssl
+ntp
+rsync
+nmap
+perl-DBI
+vsftpd
+perl-IO-Tty
+perl-Expect
+perl-SNMP
+unixODBC
+perl-Net-DNS
+perl-DBD-mysql
+mariadb-client
+libmysqlclient18
+# The following rpms are available on the SLES SDK
+# You will need to locate and make these rpms available in your zypper
+# repository for service node installs and uncomment the following lines:
+#MyODBC-unixODBC
+#perl-DBD-Pg
+
diff --git a/xCAT-server/share/xcat/install/sles/service.sle15.ppc64le.otherpkgs.pkglist b/xCAT-server/share/xcat/install/sles/service.sle15.ppc64le.otherpkgs.pkglist
new file mode 100644
index 000000000..096209962
--- /dev/null
+++ b/xCAT-server/share/xcat/install/sles/service.sle15.ppc64le.otherpkgs.pkglist
@@ -0,0 +1,2 @@
+xcat/xcat-core/xCATsn
+xcat/xcat-dep/sles12/ppc64le/goconserver
diff --git a/xCAT-server/share/xcat/install/sles/service.sle15.tmpl b/xCAT-server/share/xcat/install/sles/service.sle15.tmpl
new file mode 100644
index 000000000..bf5a3764a
--- /dev/null
+++ b/xCAT-server/share/xcat/install/sles/service.sle15.tmpl
@@ -0,0 +1,91 @@
+
+
+
+
+
+ true
+ true
+ #XCATVAR:PERSKCMDLINE#
+ false
+ false
+ mbr
+
+
+
+ GMT
+ #TABLE:site:key=timezone:value#
+
+
+ english-us
+
+ en_US
+
+ false
+ false
+ false
+ true
+
+
+ non
+
+
+ true
+ true
+ true
+
+
+
+
+
+ XCATPARTITIONHOOK
+ true
+
+
+
+
+
+
+ #INCLUDE_DEFAULT_PTRNLIST_S#
+
+
+ #INCLUDE_DEFAULT_PKGLIST_S#
+
+
+
+
+
+
+ root
+ #CRYPT:passwd:key=system,username=root:password#
+ true
+
+
+
+
+
+
+ true
+ true
+ local
+ linux
+
+
+
+ dhcp
+ eth0
+ onboot
+
+
+ true
+
+ false
+
+
+
+
+ #INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/pre.sles#
+ #INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/chroot.sles#
+ #INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/post.sles11#
+
+
+
diff --git a/xCAT-server/share/xcat/install/sles/service.sle15.x86_64.otherpkgs.pkglist b/xCAT-server/share/xcat/install/sles/service.sle15.x86_64.otherpkgs.pkglist
new file mode 100644
index 000000000..a9d86fded
--- /dev/null
+++ b/xCAT-server/share/xcat/install/sles/service.sle15.x86_64.otherpkgs.pkglist
@@ -0,0 +1,2 @@
+xcat/xcat-core/xCATsn
+xcat/xcat-dep/sles12/x86_64/goconserver
diff --git a/xCAT-server/share/xcat/netboot/sle/dracut_033/check b/xCAT-server/share/xcat/netboot/sle/dracut_033/check
deleted file mode 100755
index d7cc89ce0..000000000
--- a/xCAT-server/share/xcat/netboot/sle/dracut_033/check
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-[ "$1" = "-d" ] && echo network
-exit 0
diff --git a/xCAT-server/share/xcat/netboot/sle/dracut_033/install.netboot b/xCAT-server/share/xcat/netboot/sle/dracut_033/install.netboot
deleted file mode 100755
index d82e9502c..000000000
--- a/xCAT-server/share/xcat/netboot/sle/dracut_033/install.netboot
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/sh
-echo $drivers
-dracut_install wget tar cpio gzip modprobe touch echo cut wc xz
-dracut_install grep ip hostname awk egrep grep dirname expr
-dracut_install mount.nfs
-dracut_install parted mke2fs bc mkswap swapon chmod
-inst "$moddir/xcat-updateflag" "/tmp/updateflag"
-inst "$moddir/xcatroot" "/sbin/xcatroot"
-inst_hook cmdline 10 "$moddir/xcat-cmdline.sh"
diff --git a/xCAT-server/share/xcat/netboot/sle/dracut_033/install.statelite b/xCAT-server/share/xcat/netboot/sle/dracut_033/install.statelite
deleted file mode 100755
index 1ef4a721a..000000000
--- a/xCAT-server/share/xcat/netboot/sle/dracut_033/install.statelite
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-echo $drivers
-dracut_install wget cpio gzip modprobe wc touch echo cut
-dracut_install grep ip hostname awk egrep grep dirname expr
-dracut_install parted mke2fs bc mkswap swapon chmod
-inst "$moddir/xcat-updateflag" "/tmp/updateflag"
-inst_hook pre-mount 5 "$moddir/xcat-premount.sh"
-inst_hook pre-pivot 5 "$moddir/xcat-prepivot.sh"
diff --git a/xCAT-server/share/xcat/netboot/sle/dracut_033/installkernel b/xCAT-server/share/xcat/netboot/sle/dracut_033/installkernel
deleted file mode 100755
index 7902ce5f7..000000000
--- a/xCAT-server/share/xcat/netboot/sle/dracut_033/installkernel
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/bash
-instmods nfs sunrpc
diff --git a/xCAT-server/share/xcat/netboot/sle/dracut_033/patch/syslog/module-setup.sh b/xCAT-server/share/xcat/netboot/sle/dracut_033/patch/syslog/module-setup.sh
deleted file mode 100755
index 386a3a40b..000000000
--- a/xCAT-server/share/xcat/netboot/sle/dracut_033/patch/syslog/module-setup.sh
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/bin/bash
-# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
-# ex: ts=8 sw=4 sts=4 et filetype=sh
-
-check() {
- # do not add this module by default
- return 255
-}
-
-depends() {
- return 0
-}
-
-install() {
- local _i
- local _installs
- if type -P rsyslogd >/dev/null; then
- _installs="rsyslogd"
- inst_libdir_file rsyslog/lmnet.so rsyslog/imklog.so rsyslog/imuxsock.so
- elif type -P syslogd >/dev/null; then
- _installs="syslogd"
- elif type -P syslog-ng >/dev/null; then
- _installs="syslog-ng"
- else
- derror "Could not find any syslog binary although the syslogmodule" \
- "is selected to be installed. Please check."
- fi
- if [ -n "$_installs" ]; then
- inst_multiple cat $_installs
- inst_hook cmdline 90 "$moddir/parse-syslog-opts.sh"
- inst_hook pre-udev 61 "$moddir/syslog-genrules.sh"
- inst_hook cleanup 99 "$moddir/syslog-cleanup.sh"
- inst_simple "$moddir/rsyslogd-start.sh" /sbin/rsyslogd-start
- inst_simple "$moddir/rsyslogd-stop.sh" /sbin/rsyslogd-stop
- mkdir -m 0755 -p ${initdir}/etc/templates
- inst_simple "${moddir}/rsyslog.conf" /etc/templates/rsyslog.conf
- fi
- dracut_install logger
- dracut_need_initqueue
-}
-
diff --git a/xCAT-server/share/xcat/netboot/sle/dracut_033/patch/syslog/rsyslogd-start.sh b/xCAT-server/share/xcat/netboot/sle/dracut_033/patch/syslog/rsyslogd-start.sh
deleted file mode 100755
index 9589af436..000000000
--- a/xCAT-server/share/xcat/netboot/sle/dracut_033/patch/syslog/rsyslogd-start.sh
+++ /dev/null
@@ -1,51 +0,0 @@
-#!/bin/sh
-# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
-# ex: ts=8 sw=4 sts=4 et filetype=sh
-
-# Triggered by udev and starts rsyslogd with bootparameters
-
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
-
-rsyslog_config() {
- local server=$1
- shift
- local syslog_template=$1
- shift
- local filters=$*
- local filter=
- local confline=
-
- cat $syslog_template
-
-# for filter in $filters; do
-# echo "${filter} @${server}"
-# done
-
-
- if [ -n "$filters" ];then
- confline="${filters}";
- else
- confline="*.*"
- fi
-
- if [ -n "$server" ];then
- confline="$confline @${server}"
- else
- confline="$confline /var/log/messages"
- fi
-
- echo "$confline"
-# echo "*.* /tmp/syslog"
-}
-
-[ -f /tmp/syslog.server ] && read server < /tmp/syslog.server
-[ -f /tmp/syslog.filters ] && read filters < /tmp/syslog.filters
-[ -z "$filters" ] && filters="kern.*"
-[ -f /tmp/syslog.conf ] && read conf < /tmp/syslog.conf
-[ -z "$conf" ] && conf="/etc/rsyslog.conf" && echo "$conf" > /tmp/syslog.conf
-
-template=/etc/templates/rsyslog.conf
-if [ -n "$server" ]; then
- rsyslog_config "$server" "$template" "$filters" > $conf
- rsyslogd -i /var/run/syslogd.pid
-fi
diff --git a/xCAT-server/share/xcat/netboot/sle/dracut_033/patch/syslog/syslog-genrules.sh b/xCAT-server/share/xcat/netboot/sle/dracut_033/patch/syslog/syslog-genrules.sh
deleted file mode 100755
index 09a58c574..000000000
--- a/xCAT-server/share/xcat/netboot/sle/dracut_033/patch/syslog/syslog-genrules.sh
+++ /dev/null
@@ -1,97 +0,0 @@
-#!/bin/sh
-# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
-# ex: ts=8 sw=4 sts=4 et filetype=sh
-
-# Creates the syslog udev rules to be triggered when interface becomes online.
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
-
-detect_syslog() {
- syslogtype=""
- if [ -e /sbin/rsyslogd ]; then
- syslogtype="rsyslogd"
- elif [ -e /sbin/syslogd ]; then
- syslogtype="syslogd"
- elif [ /sbin/syslog-ng ]; then
- syslogtype="syslog-ng"
- else
- warn "Could not find any syslog binary although the syslogmodule is selected to be installed. Please check."
- fi
- echo "$syslogtype"
- [ -n "$syslogtype" ]
-}
-
-#the initqueue.sh shipped does not support --online option and
-#there are some problem when processing --onetime option
-#implement a patched initqueue function here, named initqueue_enhanced
-initqueue_enhanced() {
- local onetime=
- local qname=
- local unique=
- local name=
- local env=
- while [ $# -gt 0 ]; do
- case "$1" in
- --onetime)
- onetime="yes";;
- --settled)
- qname="/settled";;
- --finished)
- qname="/finished";;
- --timeout)
- qname="/timeout";;
- --online)
- qname="/online";;
- --unique)
- unique="yes";;
- --name)
- name="$2";shift;;
- --env)
- env="$2"; shift;;
- *)
- break;;
- esac
- shift
- done
-
- local job=
- if [ -z "$unique" ]; then
- job="${name}$$"
- else
- job="${name:-$1}"
- job=${job##*/}
- fi
-
- local exe=
- exe=$1
- shift
-
- [ -x "$exe" ] || exe=$(command -v $exe)
- if [ -z "$exe" ] ; then
- echo "Invalid command"
- return 1
- fi
-
- {
- [ -n "$env" ] && echo "$env"
- echo "$exe $@"
- [ -n "$onetime" ] && echo "[ -e $hookdir/initqueue${qname}/${job}.sh ] && rm -f -- $hookdir/initqueue${qname}/${job}.sh"
- } > "/tmp/$$-${job}.sh"
-
- mv -f "/tmp/$$-${job}.sh" "$hookdir/initqueue${qname}/${job}.sh"
- [ -z "$qname" ] && >> $hookdir/initqueue/work
-
- return 0
-}
-
-[ -f /tmp/syslog.type ] && read syslogtype < /tmp/syslog.type
-if [ -z "$syslogtype" ]; then
- syslogtype=$(detect_syslog)
- echo $syslogtype > /tmp/syslog.type
-fi
-if [ -e "/sbin/${syslogtype}-start" ]; then
- #printf 'ACTION=="online", SUBSYSTEM=="net", RUN+="/sbin/initqueue --onetime /sbin/'${syslogtype}'-start $env{INTERFACE}"\n' > /etc/udev/rules.d/70-syslog.rules
- #printf 'ATTR{operstate}!="down", SUBSYSTEM=="net", RUN+="/sbin/initqueue --onetime /sbin/'${syslogtype}'-start $env{INTERFACE}"\n' > /etc/udev/rules.d/70-syslog.rules
- initqueue_enhanced --online --onetime /sbin/${syslogtype}-start
-else
- warn "syslog-genrules: Could not find binary to start syslog of type \"$syslogtype\". Syslog will not be started."
-fi
diff --git a/xCAT-server/share/xcat/netboot/sle/dracut_033/xcat-cmdline.sh b/xCAT-server/share/xcat/netboot/sle/dracut_033/xcat-cmdline.sh
deleted file mode 100644
index 80d088557..000000000
--- a/xCAT-server/share/xcat/netboot/sle/dracut_033/xcat-cmdline.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-root=1
-rootok=1
-netroot=xcat
-echo '[ -e $NEWROOT/proc ]' > $hookdir/initqueue/finished/xcatroot.sh
diff --git a/xCAT-server/share/xcat/netboot/sle/dracut_033/xcat-premount.sh b/xCAT-server/share/xcat/netboot/sle/dracut_033/xcat-premount.sh
deleted file mode 100644
index 40c1dbbe5..000000000
--- a/xCAT-server/share/xcat/netboot/sle/dracut_033/xcat-premount.sh
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/bin/sh
-#script to update nodelist.nodestatus during provision
-
-MASTER=`echo $XCAT |awk -F: '{print $1}'`
-
-getarg nonodestatus
-NODESTATUS=$?
-
-XCATIPORT="$(getarg XCATIPORT=)"
-if [ $? -ne 0 ]; then
-XCATIPORT="3002"
-fi
-
-
-
-if [ $NODESTATUS -ne 0 ];then
-/tmp/updateflag $MASTER $XCATIPORT "installstatus netbooting"
-fi
diff --git a/xCAT-server/share/xcat/netboot/sle/dracut_033/xcat-prepivot.sh b/xCAT-server/share/xcat/netboot/sle/dracut_033/xcat-prepivot.sh
deleted file mode 100755
index 039990ab4..000000000
--- a/xCAT-server/share/xcat/netboot/sle/dracut_033/xcat-prepivot.sh
+++ /dev/null
@@ -1,173 +0,0 @@
-#!/bin/sh
-NEWROOT=/sysroot
-SERVER=${SERVER%%/*}
-SERVER=${SERVER%:}
-RWDIR=.statelite
-if [ ! -z $STATEMNT ]; then #btw, uri style might have left future options other than nfs open, will u se // to detect uri in the future I guess
- SNAPSHOTSERVER=${STATEMNT%:*}
- SNAPSHOTROOT=${STATEMNT#*/}
- #echo $SNAPSHOTROOT
- #echo $SNAPSHOTSERVER
- # may be that there is not server and just a directory.
- if [ -z $SNAPSHOTROOT ]; then
- SNAPSHOTROOT=$SNAPSHOTSERVER
- SNAPSHOTSERVER=
- fi
-fi
-
-echo Setting up Statelite
-mkdir -p $NEWROOT
-
-# now we need to mount the rest of the system. This is the read/write portions
-# echo Mounting snapshot directories
-
-MAXTRIES=7
-ITER=0
-if [ ! -e "$NEWROOT/$RWDIR" ]; then
- echo ""
- echo "This NFS root directory doesn't have a /$RWDIR directory for me to mount a rw filesystem. You'd better create it... "
- echo ""
- /bin/sh
-fi
-
-if [ ! -e "$NEWROOT/etc/init.d/statelite" ]; then
- echo ""
- echo "$NEWROOT/etc/init.d/statelite doesn't exist. Perhaps you didn't create this image with th e -m statelite mode"
- echo ""
- /bin/sh
-fi
-
-mount -t tmpfs rw $NEWROOT/$RWDIR
-mkdir -p $NEWROOT/$RWDIR/tmpfs
-ME=`hostname`
-if [ ! -z $NODE ]; then
- ME=$NODE
-fi
-
-# mount the SNAPSHOT directory here for persistent use.
-if [ ! -z $SNAPSHOTSERVER ]; then
- mkdir -p $NEWROOT/$RWDIR/persistent
- MAXTRIES=5
- ITER=0
- if [ -z $MNTOPTS ]; then
- MNT_OPTIONS="nolock,rsize=32768,tcp,nfsvers=3,timeo=14"
- else
- MNT_OPTIONS=$MNTOPTS
- fi
- while ! mount $SNAPSHOTSERVER:/$SNAPSHOTROOT $NEWROOT/$RWDIR/persistent -o $MNT_OPTIONS; do
- ITER=$(( ITER + 1 ))
- if [ "$ITER" == "$MAXTRIES" ]; then
- echo "Your are dead, rpower $ME boot to play again."
- echo "Possible problems:
-1. $SNAPSHOTSERVER is not exporting $SNAPSHOTROOT ?
-2. Is DNS set up? Maybe that's why I can't mount $SNAPSHOTSERVER."
- /bin/sh
- exit
- fi
- RS= $(( $RANDOM % 20 ))
- echo "Trying again in $RS seconds..."
- sleep $RS
- done
-
- # create directory which is named after my node name
- mkdir -p $NEWROOT/$RWDIR/persistent/$ME
- ITER=0
- # umount current persistent mount
- while ! umount -l $NEWROOT/$RWDIR/persistent; do
- ITER=$(( ITER + 1 ))
- if [ "$ITER" == "$MAXTRIES" ]; then
- echo "Your are dead, rpower $ME boot to play again."
- echo "Cannot umount $NEWROOT/$RWDIR/persistent."
- /bin/sh
- exit
- fi
- RS= $(( $RANDOM % 20 ))
- echo "Trying again in $RS seconds..."
- sleep $RS
- done
-
- # mount persistent to server:/rootpath/nodename
- ITER=0
- while ! mount $SNAPSHOTSERVER:/$SNAPSHOTROOT/$ME $NEWROOT/$RWDIR/persistent -o $MNT_OPTIONS; do
- ITER=$(( ITER + 1 ))
- if [ "$ITER" == "$MAXTRIES" ]; then
- echo "Your are dead, rpower $ME boot to play again."
- echo "Possible problems: cannot mount to $SNAPSHOTSERVER:/$SNAPSHOTROOT/$ME."
- /bin/sh
- exit
- fi
- RS= $(( $RANDOM % 20 ))
- echo "Trying again in $RS seconds..."
- sleep $RS
- done
-fi
-
-# TODO: handle the dhclient/resolv.conf/ntp, etc
-echo "Get to enable localdisk"
-$NEWROOT/etc/init.d/localdisk
-$NEWROOT/etc/init.d/statelite
-READONLY=yes
-export READONLY
-fastboot=yes
-export fastboot
-keep_old_ip=yes
-export keep_old_ip
-mount -n --bind /dev $NEWROOT/dev
-mount -n --bind /proc $NEWROOT/proc
-mount -n --bind /sys $NEWROOT/sys
-
-function getdevfrommac() {
- boothwaddr=$1
- ip link show | while read line
- do
- dev=`echo $line | egrep "^[0-9]+: [0-9A-Za-z]+" | cut -d ' ' -f 2 | cut -d ':' -f 1`
- if [ "X$dev" != "X" ]; then
- devname=$dev
- fi
-
- if [ "X$devname" != "X" ]; then
- hwaddr=`echo $line | egrep "^[ ]*link" | awk '{print $2}'`
- if [ "X$hwaddr" = "X$boothwaddr" ]; then
- echo $devname
- fi
- fi
- done
-}
-
-bootif=$(ls /tmp/net.*.conf|sed -e s/.*net\.// -e s/\.conf//)
-cat < $NEWROOT/etc/sysconfig/network/ifcfg-$bootif
-BOOTPROTO='dhcp'
-STARTMODE='auto'
-EOF
-
-if [ ! -z "$ifname" ]; then
- MACX=${ifname#*:}
- ETHX=${ifname%:$MACX*}
-elif [ ! -z "$netdev" ]; then
- ETHX=$netdev
- MACX=`ip link show $netdev | grep ether | awk '{print $2}'`
-elif [ ! -z "$BOOTIF" ]; then
- MACX=$BOOTIF
- ETHX=$(getdevfrommac $BOOTIF)
-fi
-
-if [ ! -z "$MACX" ] && [ ! -z "$ETHX" ]; then
- if [ ! -e $NEWROOT/etc/sysconfig/network/ifcfg-$ETHX ]; then
- touch $NEWROOT/etc/sysconfig/network/ifcfg-$ETHX
- fi
- echo "DEVICE=$ETHX" > $NEWROOT/etc/sysconfig/network/ifcfg-$ETHX
- echo "BOOTPROTO=dhcp" >> $NEWROOT/etc/sysconfig/network/ifcfg-$ETHX
- echo "HWADDR=$MACX" >> $NEWROOT/etc/sysconfig/network/ifcfg-$ETHX
- echo "ONBOOT=yes" >> $NEWROOT/etc/sysconfig/network/ifcfg-$ETHX
-fi
-
-cp /etc/resolv.conf "$NEWROOT/etc/"
-
-if [ -d "$NEWROOT/etc/sysconfig" -a ! -e "$NEWROOT/etc/sysconfig/selinux" ]; then
- echo "SELINUX=disabled" >> "$NEWROOT/etc/sysconfig/selinux"
-fi
-
-# inject new exit_if_exists
-echo 'settle_exit_if_exists="--exit-if-exists=/dev/root"; rm "$job"' > $hookdir/initqueue/xcat.sh
-# force udevsettle to break
-> $hookdir/initqueue/work
diff --git a/xCAT-server/share/xcat/netboot/sle/dracut_033/xcatroot b/xCAT-server/share/xcat/netboot/sle/dracut_033/xcatroot
deleted file mode 100755
index ba8bb019a..000000000
--- a/xCAT-server/share/xcat/netboot/sle/dracut_033/xcatroot
+++ /dev/null
@@ -1,341 +0,0 @@
-#!/bin/sh
-
-
-NEWROOT=$3
-RWDIR=.statelite
-XCATMASTER=$XCAT
-
-. /lib/dracut-lib.sh
-rootlimit="$(getarg rootlimit=)"
-
-
-getarg nonodestatus
-NODESTATUS=$?
-
-MASTER=`echo $XCATMASTER |awk -F: '{print $1}'`
-XCATIPORT="$(getarg XCATIPORT=)"
-if [ $? -ne 0 ]; then
-XCATIPORT="3002"
-fi
-
-xcatdebugmode="$(getarg xcatdebugmode=)"
-
-[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "running xcatroot...."
-
-[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "MASTER=$MASTER XCATIPORT=$XCATIPORT"
-
-if [ $NODESTATUS -ne 0 ];then
-[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "nodestatus: netbooting,reporting..."
-/tmp/updateflag $MASTER $XCATIPORT "installstatus netbooting"
-fi
-
-if [ ! -z "$imgurl" ]; then
- if [ xhttp = x${imgurl%%:*} ]; then
- NFS=0
- FILENAME=${imgurl##*/}
- while [ ! -r "$FILENAME" ]; do
- [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "downloading $imgurl...."
- echo Getting $imgurl...
- if ! wget -nv $imgurl; then
- [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "downloading $imgurl failed,retrying...."
- rm -f $FILENAME
- sleep 27
- fi
- done
- elif [ xnfs = x${imgurl%%:*} ]; then
- NFS=1
- SERVER=${imgurl#nfs:}
- SERVER=${SERVER#/}
- SERVER=${SERVER#/}
- ROOTDIR=$SERVER
- SERVER=${SERVER%%/*}
- SERVER=${SERVER%:}
- ROOTDIR=/${ROOTDIR#*/}
- fi
-fi
-#echo 0 > /proc/sys/vm/zone_reclaim_mode #Avoid kernel bug
-
-if [ -r /rootimg.sfs ]; then
- echo Setting up squashfs with ram overlay.
- mknod /dev/loop0 b 7 0
- mkdir -p /ro
- mkdir -p /rw
- mount -t squashfs /rootimg.sfs /ro
- mount -t tmpfs rw /rw
- mount -t aufs -o dirs=/rw:/ro mergedroot $NEWROOT
- mkdir -p $NEWROOT/ro
- mkdir -p $NEWROOT/rw
- mount --move /ro $NEWROOT/ro
- mount --move /rw $NEWROOT/rw
-elif [ -r /rootimg.cpio.gz ] || [ -r /rootimg.cpio.xz ]; then
- [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "rootimg downloaded,setting up RAM-root tmpfs...."
- echo Setting up RAM-root tmpfs.
- if [ -z $rootlimit ];then
- mount -t tmpfs -o mode=755 rootfs $NEWROOT
- else
- mount -t tmpfs -o mode=755,size=$rootlimit rootfs $NEWROOT
- fi
-
- cd $NEWROOT
- [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Extracting root filesystem:"
- echo -n "Extracting root filesystem:"
- if [ -r /rootimg.cpio.gz ]; then
- if [ -x /bin/cpio ]; then
- gzip -cd /rootimg.cpio.gz |/bin/cpio -idum
- else
- gzip -cd /rootimg.cpio.gz |cpio -idum
- fi
- elif [ -r /rootimg.cpio.xz ]; then
- if [ -x /bin/cpio ]; then
- xz -cd /rootimg.cpio.xz |/bin/cpio -idum
- else
- xz -cd /rootimg.cpio.xz |cpio -idum
- fi
- fi
- [ -x $NEWROOT/etc/init.d/localdisk ] && $NEWROOT/etc/init.d/localdisk
- [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Done...."
- echo Done
-elif [ -r /rootimg.tar.gz ] || [ -r /rootimg.tar.xz ]; then
- [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "rootimg downloaded,setting up RAM-root tmpfs...."
- echo Setting up RAM-root tmpfs.
- if [ -z $rootlimit ];then
- mount -t tmpfs -o mode=755 rootfs $NEWROOT
- else
- mount -t tmpfs -o mode=755,size=$rootlimit rootfs $NEWROOT
- fi
-
- cd $NEWROOT
- [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Extracting root filesystem:"
- echo -n "Extracting root filesystem:"
- if [ -r /rootimg.tar.gz ]; then
- tar --selinux --xattrs-include='*' -zxf /rootimg.tar.gz
- if [ $? -ne 0 ]; then
- tar -zxf /rootimg.tar.gz
- fi
- elif [ -r /rootimg.tar.xz ]; then
- tar --selinux --xattrs-include='*' -Jxf /rootimg.tar.xz
- if [ $? -ne 0 ]; then
- tar -Jxf /rootimg.tar.xz
- fi
- fi
- $NEWROOT/etc/init.d/localdisk
- [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Done...."
- echo Done
-elif [ -r /rootimg-statelite.gz ]; then
- echo Setting up RAM-root tmpfs for statelite mode.
-
- if [ -z $rootlimit];then
- mount -t tmpfs -o mode=755 rootfs $NEWROOT
- else
- mount -t tmpfs -o mode=755,size=$rootlimit rootfs $NEWROOT
- fi
-
- cd $NEWROOT
- echo -n "Extracting root filesystem:"
- if [ -x /bin/cpio ]; then
- gzip -cd /rootimg-statelite.gz |/bin/cpio -idum
- else
- gzip -cd /rootimg-statelite.gz |cpio -idum
- fi
- echo Done
- # then, the statelite staffs will be processed
- echo Setting up Statelite
- modprobe nfs
- MAXTRIES=7
- ITER=0
- if [ ! -e "$NEWROOT/$RWDIR" ]; then
- echo ""
- echo "The /$RWDIR directory doesn't exist in the rootimg... "
- echo ""
- /bin/sh
- fi
-
- if [ ! -e "$NEWROOT/etc/init.d/statelite" ]; then
- echo ""
- echo "$NEWROOT/etc/init.d/statelite doesn't exist... "
- echo ""
- /bin/sh
- fi
-
- mount -t tmpfs rw $NEWROOT/$RWDIR
- mkdir -p $NEWROOT/$RWDIR/tmpfs
- ME=`hostname`
- if [ ! -z $NODE ]; then
- ME=$NODE
- fi
-
-
- # mount the SNAPSHOT directory here for persistent use.
- if [ ! -z $STATEMNT ]; then
- SNAPSHOTSERVER=${STATEMNT%:*}
- SNAPSHOTROOT=${STATEMNT#*/}
- if [ -z $SNAPSHOTROOT ]; then
- SNAPSHOTROOT=$SNAPSHOTSERVER
- SNAPSHOTSERVER=
- fi
- fi
-
- if [ ! -z $SNAPSHOTSERVER ]; then
- mkdir -p $NEWROOT/$RWDIR/persistent
- MAXTRIES=5
- ITER=0
- if [ -z $MNTOPTS ]; then
- MNT_OPTIONS="nolock,rsize=32768,tcp,nfsvers=3,timeo=14"
- else
- MNT_OPTIONS=$MNTOPTS
- fi
- while ! mount $SNAPSHOTSERVER:/$SNAPSHOTROOT $NEWROOT/$RWDIR/persistent -o $MNT_OPTIONS; do
- ITER=$(( ITER + 1 ))
- if [ "$ITER" == "$MAXTRIES" ]; then
- echo "You are dead, rpower $ME boot to play again."
- echo "Possible problems:
-1. $SNAPSHOTSERVER is not exporting $SNAPSHOTROOT ?
-2. Is DNS set up? Maybe that's why I can't mount $SNAPSHOTSERVER."
- /bin/sh
- exit
- fi
- RS=$(( $RANDOM % 20 ))
- echo "Trying again in $RS seconds ..."
- sleep $RS
- done
-
- # create directory which is named after my node name
- mkdir -p $NEWROOT/$RWDIR/persistent/$ME
- ITER=0
- # umount current persistent mount
- while ! umount -l $NEWROOT/$RWDIR/persistent; do
- ITER=$(( ITER + 1 ))
- if [ "$ITER" == "$MAXTRIES" ]; then
- echo "Your are dead, rpower $ME boot to play again."
- echo "Cannot umount $NEWROOT/$RWDIR/persistent."
- /bin/sh
- exit
- fi
- RS= $(( $RANDOM % 20 ))
- echo "Trying again in $RS seconds..."
- sleep $RS
- done
-
- # mount persistent to server:/rootpath/nodename
- ITER=0
- while ! mount $SNAPSHOTSERVER:/$SNAPSHOTROOT/$ME $NEWROOT/$RWDIR/persistent -o $MNT_OPTIONS; do
- ITER=$(( ITER + 1 ))
- if [ "$ITER" == "$MAXTRIES" ]; then
- echo "Your are dead, rpower $ME boot to play again."
- echo "Possible problems: cannot mount to $SNAPSHOTSERVER:/$SNAPSHOTROOT/$ME."
- /bin/sh
- exit
- fi
- RS= $(( $RANDOM % 20 ))
- echo "Trying again in $RS seconds..."
- sleep $RS
- done
- fi
-
- $NEWROOT/etc/init.d/localdisk
- $NEWROOT/etc/init.d/statelite
- fastboot=yes
- export fastboot
- keep_old_ip=yes
- export keep_old_ip
-
- mount -n --bind /dev $NEWROOT/dev
- mount -n --bind /proc $NEWROOT/proc
- mount -n --bind /sys $NEWROOT/sys
-
-else
- [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Failed to download image, panicing in 5..."
- echo -n Failed to download image, panicing in 5...
- for i in 4 3 2 1 0; do
- /bin/sleep 1
- [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "$i..."
- echo -n $i...
- done
-
- [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "You're dead. rpower nodename reset to play again."
- [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "* Did you packimage with -m cpio, -m squashfs, or -m nfs?"
- [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "* If using -m squashfs did you include aufs.ko with geninitrd? e.g.: -n tg3,squashfs,aufs,loop"
- [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "If using -m nfs did you export NFS and sync rootimg? And did you include the aufs and nfs modules in the proper order: e.g.: -n tg3,aufs,loop,sunrpc,lockd,nfs_acl,nfs"
- echo
- echo "You're dead. rpower nodename reset to play again.
-
-* Did you packimage with -m cpio, -m squashfs, or -m nfs?
-* If using -m squashfs did you include aufs.ko with geninitrd?
- e.g.: -n tg3,squashfs,aufs,loop
-* If using -m nfs did you export NFS and sync rootimg? And
- did you include the aufs and nfs modules in the proper order:
- e.g.: -n tg3,aufs,loop,sunrpc,lockd,nfs_acl,nfs
-
-"
- /bin/dash
- exit
-fi
-cd /
-
-function getdevfrommac() {
- boothwaddr=$1
- ip link show | while read line
- do
- dev=`echo $line | egrep "^[0-9]+: [0-9A-Za-z]+" | cut -d ' ' -f 2 | cut -d ':' -f 1`
- if [ "X$dev" != "X" ]; then
- devname=$dev
- fi
-
- if [ "X$devname" != "X" ]; then
- hwaddr=`echo $line | egrep "^[ ]*link" | awk '{print $2}'`
- if [ "X$hwaddr" = "X$boothwaddr" ]; then
- echo $devname
- fi
- fi
- done
-}
-
-
-if [ -z $STATEMNT ]; then
- bootif=$(ls /tmp/net.*.conf|sed -e s/.*net\.// -e s/\.conf//)
- cat < $NEWROOT/etc/sysconfig/network/ifcfg-$bootif
-BOOTPROTO='dhcp'
-STARTMODE='auto'
-EOF
-
- if [ ! -z "$ifname" ]; then
- MACX=${ifname#*:}
- ETHX=${ifname%:$MACX*}
- elif [ ! -z "$netdev" ]; then
- ETHX=$netdev
- MACX=`ip link show $netdev | grep ether | awk '{print $2}'`
- elif [ ! -z "$BOOTIF" ]; then
- MACX=$BOOTIF
- ETHX=$(getdevfrommac $BOOTIF)
- fi
-
- if [ ! -z "$MACX" ] && [ ! -z "$ETHX" ]; then
- if [ ! -e $NEWROOT/etc/sysconfig/network/ifcfg-$ETHX ]; then
- [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "creating $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX"
- touch $NEWROOT/etc/sysconfig/network/ifcfg-$ETHX
- fi
- [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "writing $NEWROOT/etc/sysconfig/network-scripts/ifcfg-$ETHX: DEVICE=$ETHX;BOOTPROTO=dhcp;HWADDR=$MACX;ONBOOT=yes"
- echo "DEVICE=$ETHX" > $NEWROOT/etc/sysconfig/network/ifcfg-$ETHX
- echo "BOOTPROTO=dhcp" >> $NEWROOT/etc/sysconfig/network/ifcfg-$ETHX
- echo "HWADDR=$MACX" >> $NEWROOT/etc/sysconfig/network/ifcfg-$ETHX
- echo "ONBOOT=yes" >> $NEWROOT/etc/sysconfig/network/ifcfg-$ETHX
- fi
-fi
-
-[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "saving $NEWROOT/etc/resolv.conf"
-cp /etc/resolv.conf "$NEWROOT/etc/"
-
-if [ -d "$NEWROOT/etc/sysconfig" -a ! -e "$NEWROOT/etc/sysconfig/selinux" ]; then
- [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "disable selinux ..."
- echo "SELINUX=disabled" >> "$NEWROOT/etc/sysconfig/selinux"
-fi
-
-[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "setting hostname..."
-echo `hostname` > $NEWROOT/etc/hostname
-
-[ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "exiting xcatroot..."
-
-# inject new exit_if_exists
-echo 'settle_exit_if_exists="--exit-if-exists=/dev/root"; rm "$job"' > $hookdir/initqueue/xcat.sh
-# force udevsettle to break
-> $hookdir/initqueue/work
diff --git a/xCAT-server/share/xcat/netboot/sle/genimage b/xCAT-server/share/xcat/netboot/sle/genimage
deleted file mode 100755
index 5df177836..000000000
--- a/xCAT-server/share/xcat/netboot/sle/genimage
+++ /dev/null
@@ -1,2441 +0,0 @@
-#!/usr/bin/env perl
-BEGIN
-{
- $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat';
-}
-use lib "$::XCATROOT/lib/perl";
-
-use File::Basename;
-use File::Path;
-use File::Copy qw/copy cp mv move/;
-use File::Find;
-use Getopt::Long;
-use Cwd qw(realpath);
-use File::Temp qw/mkdtemp/;
-
-use FindBin;
-use lib "$FindBin::Bin/../imgutils";
-use imgutils;
-
-#use strict;
-Getopt::Long::Configure("bundling");
-Getopt::Long::Configure("pass_through");
-
-my $dracutmode; #Indicate whether this is a dracut style initrd
-my $dracutdir = "dracut"; # The default directory name of dracut
-my $dracutver;
-my $prinic; #TODO be flexible on node primary nic
-my $othernics; #TODO be flexible on node primary nic
-my $netdriver;
-my @yumdirs;
-my $arch;
-my %libhash;
-my @filestoadd;
-my $profile;
-my $osver;
-my $pathtofiles = dirname($0);
-my $fullpath = realpath($pathtofiles);
-my $name = basename($0);
-my $onlyinitrd = 0;
-
-#that this method of calling genimage is no longer used
-if ($name =~ /geninitrd/) {
- $onlyinitrd = 1;
-}
-my $rootlimit;
-my $tmplimit;
-my $installroot = "/install";
-my $kerneldir;
-my $kernelver = "";
-my $basekernelver;
-my $customdir = $fullpath;
-$customdir =~ s/.*share\/xcat/$installroot\/custom/;
-my $imagename;
-my $pkglist;
-my $srcdir;
-my $destdir;
-my $srcdir_otherpkgs;
-my $otherpkglist;
-my $postinstall_filename;
-my $rootimg_dir;
-my $mode;
-my $permission; #the permission works only for statelite mode currently
-my $krpmver;
-my $tempfile;
-my $prompt;
-my $timezone; #the TIMEZONE of the stateless and statelite node
-my $ignorekernelchk;
-my $noupdate;
-
-sub xdie {
- system("rm -rf /tmp/xcatinitrd.$$");
- die @_;
-}
-
-#-- fetch current version form CVS (overwrite locally changed versions)
-# if (opendir(CVS,"$pathtofiles/CVS")){
-# close CVS;
-# my $cvsout = qx/cd $pathtofiles; cvs update -C 2>&1/;
-# chomp $cvsout;
-# if ( $cvsout ne "cvs update: Updating ." ) {
-# print "Difference of local copy from CVS detected\n";
-# print $cvsout,"\n";
-# print "Trying to re-run $name\n";
-# print("$pathtofiles/$name ",join(" ",@ARGV),"\n");
-# exec("$pathtofiles/$name",@ARGV);
-# }
-# }
-
-
-$SIG{INT} = $SIG{TERM} = sub { xdie "Interrupted" };
-GetOptions(
- 'a=s' => \$arch,
- 'p=s' => \$profile,
- 'o=s' => \$osver,
- 'n=s' => \$netdriver,
- 'i=s' => \$prinic,
- 'r=s' => \$othernics,
- 'l=s' => \$rootlimit,
- 't=s' => \$tmplimit,
- 'k=s' => \$kernelver,
- 'g=s' => \$krpmver,
- 'permission=s' => \$permission,
- 'kerneldir=s' => \$kerneldir,
- 'timezone=s' => \$timezone,
- 'tempfile=s' => \$tempfile, #internal flag
- 'pkglist=s' => \$pkglist, #internal flag
- 'srcdir=s' => \$srcdir, #internal flag
- 'otherpkgdir=s' => \$srcdir_otherpkgs, #internal flag
- 'otherpkglist=s' => \$otherpkglist, #internal flag
- 'postinstall=s' => \$postinstall_filename, #internal flag
- 'rootimgdir=s' => \$destdir, #internal flag
- 'driverupdatesrc=s' => \$driverupdatesrc, #internal flag
- 'interactive' => \$prompt,
- 'onlyinitrd' => \$onlyinitrd,
- 'ignorekernelchk' => \$ignorekernelchk,
- 'noupdate' => \$noupdate,
-);
-
-if (@ARGV > 0) {
- $imagename = $ARGV[0];
-}
-
-
-my %updates_os = (); # the hash for updating osimage table
-my %updates = (); # the hash for updating linuximage table
-
-
-$permission = "755" unless ($permission);
-$updates{'permission'} = $permission if ($tempfile);
-
-unless ($arch) {
- $arch = `uname -m`;
- chomp($arch);
- $arch = "x86" if ($arch =~ /i.86$/);
-}
-
-$srcdir = "$installroot/$osver/$arch" unless ($srcdir);
-$updates{'pkgdir'} = $srcdir if ($tempfile);
-
-#$srcdir = $srcdir . "/1";
-
-$srcdir_otherpkgs = "$installroot/post/otherpkgs/$osver/$arch" unless ($srcdir_otherpkgs);
-#$updates{'otherpkgdir'} = $srcdir_otherpkgs if ($tempfile);
-
-$destdir = "$installroot/netboot/$osver/$arch/$profile" unless ($destdir);
-$updates{'rootimgdir'} = $destdir if ($tempfile);
-
-$rootimg_dir = "$destdir/rootimg";
-
-if ($kernelver && (!$krpmver)) {
- print "The -g flag for the rpm version of kernel packages needs to be specified when kernel version has been specified.\n";
- exit 1;
-}
-$kerneldir = "$installroot/kernels" unless ($kerneldir); # the default directory for 3rd-party kernel is "$installroot/kernels";
-
-#$updates{'kerneldir'} = $kerneldir if ($tempfile);
-
-unless ($osver and $profile) {
- usage();
- exit 1;
-}
-my @ndrivers;
-
-if ($netdriver) {
- foreach (split /,/, $netdriver) {
- if (/^allupdate$/) {
- next;
- }
- unless (/\.ko$/) {
- s/$/.ko/;
- }
- next if (/^$/);
-
- # Do not include qeth module here
- # This module is included later on
- unless ($_ =~ m/qeth/i) {
- push @ndrivers, $_;
- }
- }
-
- if (($updates{'netdrivers'} ne $netdriver) and $tempfile) {
- $updates{'netdrivers'} = $netdriver;
- }
-}
-
-# Add the default driver list
-if ($arch eq 'x86' or $arch eq 'x86_64') {
- push @ndrivers, qw/tg3 bnx2 bnx2x e1000 e1000e virtio_net virtio_balloon igb mlx4_en be2net/;
-} elsif ($arch eq 'ppc64') {
- push @ndrivers, qw/tg3 e1000 e1000e igb ibmveth ehea be2net/;
-} elsif ($arch eq "s390x") {
- push @ndrivers, qw/qdio ccwgroup qeth qeth_l2 qeth_l3/;
-}
-
-foreach (@ndrivers) {
- unless (/\.ko$/) {
- s/$/.ko/;
- }
-}
-
-unless (grep /af_packet/, @ndrivers) {
- unshift(@ndrivers, "af_packet.ko");
-}
-
-my $osver_host;
-if (`grep VERSION /etc/os-release` =~ /VERSION = (\d+)/) {
- $osver_host = $1;
-} else {
- $osver_host = 11;
-}
-
-unless ($onlyinitrd) {
-
- # now, let's handle the extra packages
- unless ($imagename) {
- $otherpkglist = imgutils::get_profile_def_filename($osver, $profile, $arch, $customdir, "otherpkgs.pkglist");
- unless ($otherpkglist) { $otherpkglist = imgutils::get_profile_def_filename($osver, $profile, $arch, $pathtofiles, "otherpkgs.pkglist"); }
- $updates{'otherpkglist'} = $otherpkglist if ($tempfile and $otherpkglist);
- }
- my %extra_hash = ();
- %extra_hash = imgutils::get_package_names($otherpkglist) if ($otherpkglist);
-
-
- # prepare the chroot environment for the root image
-
- mkpath "$rootimg_dir/etc";
- mkpath "$rootimg_dir/dev";
-
- #system "mount -o bind /dev $rootimg_dir/dev";
- unless (-e "$rootimg_dir/dev/zero") {
- system "mknod $rootimg_dir/dev/zero c 1 5";
- }
- unless (-e "$rootimg_dir/dev/null") {
- system "mknod $rootimg_dir/dev/null c 1 3"; #that's neccessary for SLES11
- }
-
- unless (-e "$rootimg_dir/dev/random") {
- system "mknod $rootimg_dir/dev/random c 1 8"; #that's neccessary for SLES11
- }
- unless (-e "$rootimg_dir/dev/urandom") {
- system "mknod $rootimg_dir/dev/urandom c 1 9"; #that's neccessary for SLES11
- }
-
- for (my $i = 0 ; $i <= 12 ; $i++)
- {
- unless (-e "$rootimg_dir/dev/tty$i") {
- system "mknod $rootimg_dir/dev/tty$i c 4 $i"; #that's neccessary for SLES11
- }
- }
-
- open($fd, ">>", "$rootimg_dir/etc/fstab"); # TODO: is it necessary?
- print $fd "#Dummy fstab for rpm postscripts to see\n";
- close($fd);
-
- my $non_interactive;
- if (!$prompt) { $non_interactive = "--non-interactive --no-gpg-checks --gpg-auto-import-keys"; }
-
- if ($osver_host >= 11) { #zypper in SLES11 is different
-
- system("rm -rf $rootimg_dir/etc/zypp/repos.d/$osver-*.repo");
- my @pkgdirs = split(",", $srcdir);
- my $dir;
- my $i = 0;
-
- # To support multiple paths for osimage.pkgdir
- foreach $dir (@pkgdirs) {
- my $ddir = $dir;
- if (-d "$dir/1") {
- $ddir .= "/1";
- }
- system("zypper -R $rootimg_dir $non_interactive ar file:$ddir $osver-$i");
- $i++;
- if (-d "$dir/2") {
- $ddir = $dir . "/2";
- system("zypper -R $rootimg_dir $non_interactive ar file:$ddir $osver-$i");
- $i++;
- }
- }
-
- #if(-e "$rootimg_dir/etc/zypp/repos.d/$osver.repo") {
- # system("rm -rf $rootimg_dir/etc/zypp/repos.d/$osver.repo");
- #}
- #system("zypper -R $rootimg_dir $non_interactive ar file:$srcdir $osver");
- #if(-e "$rootimg_dir/etc/zypp/repos.d/${osver}sdk.repo") {
- # system("rm -rf $rootimg_dir/etc/zypp/repos.d/${osver}sdk.repo");
- #}
- if (opendir(SRCDIR, "$installroot/$osver/$arch/")) {
- while (my $tmpfile = readdir(SRCDIR)) {
- if ($tmpfile =~ m/^sdk/) {
- my $srcdir_sdk = "$installroot/$osver/$arch/${tmpfile}";
- if (-d "$srcdir_sdk") {
- system("zypper -R $rootimg_dir $non_interactive ar file:$srcdir_sdk ${osver}${tmpfile}");
- }
- }
- }
- }
- } else {
- $srcdir = $srcdir . "/1";
- system("zypper -R $rootimg_dir $non_interactive sa file:$srcdir");
- }
-
- # Add the rep for kernel packages
- if ($kernelver) {
- if (!-d $kerneldir) {
- print "Cannot find the directory for the kernel at $kerneldir.\n";
- exit 1;
- }
- if ($osver_host >= 11) {
- if (-e "$rootimg_dir/etc/zypp/repos.d/$kernelver.repo") {
- system("rm -rf $rootimg_dir/etc/zypp/repos.d/$kernelver.repo");
- }
- system("zypper -R $rootimg_dir $non_interactive ar file:$kerneldir $kernelver");
- } else {
- system("zypper -R $rootimg_dir $non_interactive sa file:$kerneldir");
- }
- }
-
- #remove the old repository for extra packages
- if ($osver_host >= 11) {
- my $result = `zypper -R $rootimg_dir $non_interactive lr |grep otherpkg|cut -f2 -d '|'|tr "\n" " "`;
- if ($result =~ /\S/) {
- system("zypper -R $rootimg_dir $non_interactive rr $result");
- }
- } else {
- my $result = `zypper -R $rootimg_dir $non_interactive sl |grep otherpkg|cut -f2 -d '|'|tr "\n" " "`;
- if ($result =~ /\S/) {
- system("zypper -R $rootimg_dir $non_interactive sd $result");
- }
- }
-
- #add the new repository for extra packages
- my %extrapkgnames;
- if ($osver_host >= 11) { #SLES11
- if (-e "$rootimg_dir/etc/zypp/repos.d/otherpkg.repo") {
- system("rm -rf $rootimg_dir/etc/zypp/repos.d/otherpkg.repo");
- }
- }
- my $index = 1;
- my $pass;
- foreach $pass (sort { $a <=> $b } (keys(%extra_hash))) {
- foreach (keys(%{ $extra_hash{$pass} })) {
-
- if ($_ eq "INCLUDEBAD") {
- print "Unable to open the following pkglist files:\n" . join("\n", @{ $extra_hash{$pass}{INCLUDEBAD} });
- exit 1;
- }
-
- if (($_ eq "PRE_REMOVE") || ($_ eq "POST_REMOVE") || ($_ eq "ENVLIST")) { next; }
- my $whole_path = "$srcdir_otherpkgs/$_";
- if (-r "$srcdir_otherpkgs/$_/repodata/repomd.xml") {
- if ($osver_host >= 11) {
- system("zypper -R $rootimg_dir $non_interactive ar file:$srcdir_otherpkgs/$_ otherpkg$index");
- } else {
- system("zypper -R $rootimg_dir $non_interactive sa file:$srcdir_otherpkgs/$_");
- }
- } else {
- if ($osver_host >= 11) {
- system("zypper -R $rootimg_dir $non_interactive ar -t Plaindir file:$srcdir_otherpkgs/$_ otherpkg$index");
- } else {
- system("zypper -R $rootimg_dir $non_interactive sa -t Plaindir file:$srcdir_otherpkgs/$_");
- }
- }
- $index++;
-
- my $pa = $extra_hash{$pass}{$_};
- $extrapkgnames{$pass} .= " " . join(' ', @$pa);
- }
- }
-
- #-- add custom repositories to the image
- #TODO: should we add the support to otherpkgs for this? we have too many list files and it seems only SLES supports this
- # not sure, but it is convenient
- my $repolist;
- $repolist = imgutils::get_profile_def_filename($osver, $profile, $arch, $customdir, "repolist");
- unless ($repolist) {
- $repolist = imgutils::get_profile_def_filename($osver, $profile, $arch, $pathtofiles, "repolist");
- }
-
- if (-r "$repolist") {
- print "Reading custom repositories\n";
- open($repoconfig, "<", "$repolist");
- while (<$repoconfig>) {
- chomp;
- next if /^\s*#/;
- my ($repotype, $repourl, $repoalias) = split m/\|/;
- if ($osver_host >= 11) {
- system("zypper -R $rootimg_dir $non_interactive ar $repourl $repoalias");
- } else {
- system("zypper -R $rootimg_dir $non_interactive sa $repourl $repoalias");
- }
- }
- }
-
- # Refresh the zypper cache in case there is still old data out there
- system("zypper -R $rootimg_dir $non_interactive refresh");
-
- #my $yumcmd = "yum -y -c /tmp/genimage.$$.yum.conf --installroot=$rootimg_dir --disablerepo=* ";
- #$yumcmd .= "install ";
- #mkpath("$rootimg_dir/var/lib/yum");
- mkpath("$rootimg_dir/etc/");
- my $passwdfile;
- open($passwdfile, ">", "$rootimg_dir/etc/passwd");
- print $passwdfile "root:x:0:0:root:/root:/bin/bash\n";
- my $yumcmd;
- if ($osver_host < 11) {
- $yumcmd = "zypper -R $rootimg_dir $non_interactive install ";
- } else {
- $yumcmd = "zypper -R $rootimg_dir $non_interactive install -l --no-recommends "; #add -l for SLES11
- }
-
- #install packages from pkglist file
- my $pkgnames;
- unless ($imagename) {
- $pkglist = imgutils::get_profile_def_filename($osver, $profile, $arch, $customdir, "pkglist");
- unless ($pkglist) { $pkglist = imgutils::get_profile_def_filename($osver, $profile, $arch, $pathtofiles, "pkglist"); }
- }
-
- if ($pkglist) {
- $updates{'pkglist'} = $pkglist if ($tempfile);
- } else {
- print "Unable to find package list for $profile!";
- exit 1;
- }
-
- my %pkg_hash = imgutils::get_package_names($pkglist);
- my $index = 1;
- foreach $pass (sort { $a <=> $b } (keys(%pkg_hash))) {
- $pkgnames = "";
- $group_pkgnames = "";
- foreach (keys(%{ $pkg_hash{$pass} })) {
-
- if ($_ eq "INCLUDEBAD") {
- print "Unable to open the following pkglist files:\n" . join("\n", @{ $pkg_hash{$pass}{INCLUDEBAD} });
- exit 1;
- }
-
- if (($_ eq "PRE_REMOVE") || ($_ eq "POST_REMOVE") || ($_ eq "ENVLIST")) { next; }
- my $pa = $pkg_hash{$pass}{$_};
-
- # replace the kernel package with the name has the specific version
- my @npa = ();
- my @npa_group = ();
- foreach my $p (@$pa) {
- if ($p =~ /^kernel/ && $kernelver) {
-
- # get all files in $srcdir and $kerneldir
- my @alldirs = ("$srcdir", "$kerneldir");
- my @allrpms = ();
- foreach my $dir (@alldirs) {
- my @files = `find $dir -name *.rpm`;
- push @allrpms, @files;
- }
- my @kernelpkgs = ();
- if ($p =~ /^kernel$/) {
- @kernelpkgs = ("kernel-default", "kernel-default-base");
- } elsif ($p =~ /^kernel-ppc64$/) {
- @kernelpkgs = ($p, $p . "-base");
- } else {
- @kernelpkgs = ($p);
- }
- foreach my $kern (@kernelpkgs) {
- my @rpm = grep /$kern-$krpmver/, @allrpms;
- if (!@rpm) {
- print "Cannot find the kernel package with the versioin $krpmver.\n";
- exit 1;
- }
- my $kernelname = "$kern-" . $krpmver;
- push @npa, $kernelname;
- }
- } else {
- if ($p =~ s/^@//)
- {
- push @npa_group, $p;
- }
- else
- {
- push @npa, $p;
- }
- }
- }
- if (@npa) {
- $pkgnames .= " " . join(' ', @npa);
- }
- if (@npa_group) {
- $group_pkgnames .= " " . join(' ', @npa_group);
- }
- }
- my $envlist;
- if (exists $pkg_hash{$pass}{ENVLIST}) {
- $envlist = join(' ', @{ $pkg_hash{$pass}{ENVLIST} });
- }
- if ($pkgnames)
- {
- print "$envlist $yumcmd $pkgnames\n";
- $rc = system("$envlist $yumcmd $pkgnames");
- $rc = $rc >> 8;
- if (($rc) && ($rc != '104')) {
- print "zypper invocation failed with rc: $rc\n";
- exit 1;
- }
- }
- if ($group_pkgnames)
- {
- print "$envlist $yumcmd -t pattern $group_pkgnames\n";
- $rc = system("$envlist $yumcmd -t pattern $group_pkgnames");
- $rc = $rc >> 8;
- if (($rc) && ($rc != '104')) {
- print "zypper invocation failed with rc: $rc\n";
- exit 1;
- }
- }
- }
-
- foreach $pass (sort { $a <=> $b } (keys(%extra_hash))) {
-
- my $index = 1;
-
- #remove the old repository for extra packages
- if ($osver_host >= 11) {
- my $result = `zypper -R $rootimg_dir $non_interactive lr |grep otherpkg|cut -f2 -d '|'|tr "\n" " "`;
- if ($result =~ /\S/) {
- system("zypper -R $rootimg_dir $non_interactive rr $result");
- }
- } else {
- my $result = `zypper -R $rootimg_dir $non_interactive sl |grep otherpkg|cut -f2 -d '|'|tr "\n" " "`;
- if ($result =~ /\S/) {
- system("zypper -R $rootimg_dir $non_interactive sd $result");
- }
- }
-
- foreach (keys(%{ $extra_hash{$pass} })) {
- if (($_ eq "PRE_REMOVE") || ($_ eq "POST_REMOVE") || ($_ eq "ENVLIST")) { next; }
- if (-r "$srcdir_otherpkgs/$_/repodata/repomd.xml") {
- if ($osver_host >= 11) {
- system("zypper -R $rootimg_dir $non_interactive ar file:$srcdir_otherpkgs/$_ otherpkg$index");
- } else {
- system("zypper -R $rootimg_dir $non_interactive sa file:$srcdir_otherpkgs/$_");
- }
- } else {
- if ($osver_host >= 11) {
- system("zypper -R $rootimg_dir $non_interactive ar -t Plaindir file:$srcdir_otherpkgs/$_ otherpkg$index");
- } else {
- system("zypper -R $rootimg_dir $non_interactive sa -t Plaindir file:$srcdir_otherpkgs/$_");
- }
- }
- $index++;
- }
-
- # Refresh the zypper cache in case there is still old data out there
- system("zypper -R $rootimg_dir $non_interactive refresh");
-
- #remove the packages that are specified in the otherpkgs.list files with leading '-'
- my $envlist;
- if (exists $extra_hash{$pass}{ENVLIST}) {
- $envlist = join(' ', @{ $extra_hash{$pass}{ENVLIST} });
- }
-
- my $yumcmd_remove = "zypper -R $rootimg_dir $non_interactive remove ";
- if (exists($extra_hash{$pass}{'PRE_REMOVE'})) {
- my $pa = $extra_hash{$pass}{'PRE_REMOVE'};
- my $rm_packges = join(' ', @$pa);
- if ($rm_packges) {
- print "$envlist $yumcmd_remove $rm_packges";
- $rc = system("$envlist $yumcmd_remove $rm_packges");
- }
- }
-
-
- #add extra packages in the list
- if ($extrapkgnames{$pass}) {
- print "$envlist $yumcmd $extrapkgnames{$pass}\n";
- $rc = system("$envlist $yumcmd $extrapkgnames{$pass}");
- $rc = $rc >> 8;
- if (($rc) && ($rc != '104')) {
- print "zypper invocation failed with rc: $rc\n";
- exit 1;
- }
- }
-
- #remove the packages that are specified in the otherpkgs.list files with leading '--'
- if (exists($extra_hash{$pass}{'POST_REMOVE'})) {
- my $pa = $extra_hash{$pass}{'POST_REMOVE'};
- my $rm_packges = join(' ', @$pa);
- if ($rm_packges) {
- print "$envlist $yumcmd_remove $rm_packges";
- $rc = system("$envlist $yumcmd_remove $rm_packges");
- }
- }
-
- if (!$noupdate) {
-
- # run zypper update to update any installed rpms
- # needed when running genimage again after updating software in repositories
- my $yumcmd_update;
- if ($osver_host >= 11) {
- $yumcmd_update = "zypper -R $rootimg_dir $non_interactive update ";
- } else {
- $yumcmd_update = "zypper -R $rootimg_dir $non_interactive update ";
- }
- $rc = system("$yumcmd_update");
- }
- }
-
- #remove the old repository for extra packages
- if ($osver_host >= 11) {
- my $result = `zypper -R $rootimg_dir $non_interactive lr |grep otherpkg|cut -f2 -d '|'|tr "\n" " "`;
- if ($result =~ /\S/) {
- system("zypper -R $rootimg_dir $non_interactive rr $result");
- }
- } else {
- my $result = `zypper -R $rootimg_dir $non_interactive sl |grep otherpkg|cut -f2 -d '|'|tr "\n" " "`;
- if ($result =~ /\S/) {
- system("zypper -R $rootimg_dir $non_interactive sd $result");
- }
- }
-
- # ignore any return code
-
- postscripts(); #run 'postscripts'
-}
-unlink "/tmp/genimage.$$.yum.conf";
-
-# added dracut mode
-if ((-d "$rootimg_dir/usr/share/dracut") or (-d "$rootimg_dir/usr/lib/dracut")) {
- $dracutmode = 1;
-
- # get dracut version
- $dracutver = `chroot $rootimg_dir rpm -qi dracut | awk '/Version/{print \$3}' | awk -F. '{print \$1}'`;
- chomp($dracutver);
- if ($dracutver =~ /^\d\d\d$/) {
- if ($dracutver >= "033") {
- $dracutdir = "dracut_033";
- } else {
- $dracutdir = "dracut"; # The default directory
- }
- }
- print "Enter the dracut mode. Dracut version: $dracutver. Dracut directory: $dracutdir.\n";
-}
-
-# default to the first kernel found in the install image if nothing specified explicitly.
-# A more accurate guess than whatever the image build server happens to be running
-# If specified, that takes precedence.
-# If image has one, that is used
-# If all else fails, resort to uname -r like this script did before
-
-if (-e "$rootimg_dir/boot/vmlinux") {
- $basekernelver = basename(readlink "$rootimg_dir/boot/vmlinux");
- if ($basekernelver eq "vmlinux") {
- $basekernelver = "";
- } else {
- $basekernelver =~ s/vmlinu.-//;
- $basekernelver =~ s/image-//;
- }
-}
-
-unless ($basekernelver) {
- my @KVERS = <$rootimg_dir/boot/vmlinu[xz]-*>;
-
- # The kernel name is different on s390x, e.g. image-2.6.32.9-0.5-default
- @KVERS = <$rootimg_dir/boot/image-*> if $arch eq "s390x";
- foreach (@KVERS) {
- s/vmlinu.-//;
- s/image-//;
- }
- unless (scalar @KVERS) {
- @KVERS = <$rootimg_dir/lib/modules/*>;
- }
- if (scalar @KVERS) {
- foreach my $kver (@KVERS) {
- unless ($kver =~ m/.gz$/) {
- $basekernelver = basename($kver);
- last;
- }
- }
- }
-
- @KVERS = <$rootimg_dir/lib/modules/*> unless (scalar @KVERS);
- $basekernelver = basename(pop @KVERS) if (scalar @KVERS);
- $basekernelver = `uname -r` unless ($basekernelver);
-}
-
-$kernelver = $basekernelver unless ($kernelver);
-chomp $kernelver;
-
-#$updates{kernelver} = $kernelver if ($tempfile);
-
-# copy the kernel to $destdir
-if (-e "$rootimg_dir/boot/vmlinux-$kernelver") {
- copy("$rootimg_dir/boot/vmlinux-$kernelver", "$destdir/kernel");
-} elsif (-e "$rootimg_dir/boot/vmlinuz-$kernelver") {
- copy("$rootimg_dir/boot/vmlinuz-$kernelver", "$destdir/kernel");
-} elsif (-e "$rootimg_dir/boot/image-$kernelver") {
- copy("$rootimg_dir/boot/image-$kernelver", "$destdir/kernel");
-} else {
- xdie "couldn't find the kernel file matched $kernelver in $rootimg_dir/boot !";
-}
-
-#-- run postinstall script
-unless ($imagename) {
- $postinstall_filename = imgutils::get_profile_def_filename($osver, $profile, $arch, $customdir, "postinstall");
- unless ($postinstall_filename) {
- $postinstall_filename = imgutils::get_profile_def_filename($osver, $profile, $arch, $pathtofiles, "postinstall");
- }
-}
-
-if ($postinstall_filename) {
-
- #print "postinstall_filename=$postinstall_filename\n";
-
- #For Mellonax IB script. In diskless image, the uname -r not returning the rootimg level,
- #because the "uname -r" only returns the version of the kernel in use
- #create a temporary uname script. for every flag except for -r, it should just call the real
- #uname with the same flags and return that info.
- if (!(-e "$rootimg_dir/bin/orig_uname")) {
- system("mv $rootimg_dir/bin/uname $rootimg_dir/bin/orig_uname");
- }
- my $tmpuname;
- open($tmpuname, ">", "$rootimg_dir/bin/uname");
- print $tmpuname <>$tempfile");
- if ($imagename) {
- if (keys(%updates) > 0) {
- print FILE "The output for table updates starts here\n";
- print FILE "table::linuximage\n";
- print FILE "imagename::$imagename\n";
- my @a = %updates;
- print FILE join('::', @a) . "\n";
- print FILE "The output for table updates ends here\n";
- }
- } else {
- $updates_os{'profile'} = $profile;
- $updates_os{'imagetype'} = 'linux';
- $updates_os{'provmethod'} = 'netboot';
- $updates_os{'osname'} = 'Linux';
- $updates_os{'osvers'} = $osver;
- $updates_os{'osdistroname'} = 'sle'; # not used currently
- $updates_os{'osarch'} = $arch;
-
- # update the imagename for stateless
- print FILE "The output for table updates starts here\n";
- print FILE "table::osimage\n";
- print FILE "imagename::$osver-$arch-netboot-$profile\n";
- my @a = %updates_os;
- print FILE join('::', @a) . "\n";
- print FILE "The output for table updates ends here\n";
-
- print FILE "The output for table updates starts here\n";
- print FILE "table::linuximage\n";
- print FILE "imagename::$osver-$arch-netboot-$profile\n";
- my @a = %updates;
- print FILE join('::', @a) . "\n";
- print FILE "The output for table updates ends here\n";
-
- # update the imagename for statelite
- $updates_os{'provmethod'} = 'statelite';
- print FILE "The output for table updates starts here\n";
- print FILE "table::osimage\n";
- print FILE "imagename::$osver-$arch-statelite-$profile\n";
- my @a = %updates_os;
- print FILE join('::', @a) . "\n";
- print FILE "The output for table updates ends here\n";
-
- print FILE "The output for table updates starts here\n";
- print FILE "table::linuximage\n";
- print FILE "imagename::$osver-$arch-statelite-$profile\n";
- my @a = %updates;
- print FILE join('::', @a) . "\n";
- print FILE "The output for table updates ends here\n";
- }
- close FILE;
-}
-
-#END
-
-
-
-mkpath "$rootimg_dir/.statelite"; # create place for NFS mounts;
-mkpath "$rootimg_dir/.sllocal/localmnt"; # create place for localdisk mount
-mkpath "$rootimg_dir/.sllocal/log"; # create place for localdisk log
-
-mkpath "$rootimg_dir/root/.ssh"; # create place for NFS mounts for ssh; #TODO is necessary?
-
-# this script will get the directories;
-# TODO: it seems it is re-copied in liteimg.pm
-unless (-r "$pathtofiles/../add-on/statelite/rc.statelite") {
- print "Can't find $pathtofiles/../add-on/statelite/rc.statelite!\n";
- exit;
-}
-system("cp $pathtofiles/../add-on/statelite/rc.statelite $rootimg_dir/etc/init.d/statelite");
-system("cp $pathtofiles/../add-on/statelite/rc.localdisk $rootimg_dir/etc/init.d/localdisk");
-
-# added dracutmode
-unless ($dracutmode) { #in dracut mode, we delegate all this activity
- unless (-l "$rootimg_dir/var/lib/dhclient") {
- mkpath "$rootimg_dir/var/lib/dhclient/";
- system("touch $rootimg_dir/var/lib/dhclient/dhclient-$prinic.leases");
- }
-
- unless (-l "$rootimg_dir/var/lib/dhcp") {
- mkpath "$rootimg_dir/var/lib/dhcp/";
- system("touch $rootimg_dir/var/lib/dhcp/dhclient-$prinic.leases");
- }
-}
-
-
-# the dhcp client information stores in the directory "/var/lib/dhcpcd/"
-unless (-l "$rootimg_dir/var/lib/dhcpcd") {
- mkpath "$rootimg_dir/var/lib/dhcpcd/";
- system("touch $rootimg_dir/var/lib/dhcpcd/dhcpcd-$prinic.info");
-}
-
-#keyctl moved to /bin for newer release
-system("cd $rootimg_dir/usr/bin/; ln -s ../../bin/keyctl $rootimg_dir/usr/bin/keyctl");
-
-# which is different from the Redhat family
-
-# some rpms mounts the imageroot/proc on the /proc, need to release it,
-# otherwise got kernal panic when installing
-# sometimes, the proc fs is not mounted, so one warning/error message will display,
-# and I add one check point here.
-my $MFD;
-open MFD, "/proc/mounts";
-my @lines = ;
-close MFD;
-
-my $ret = grep m{$rootimg_dir/proc}, @lines;
-if ($ret > 0) {
- system("umount -l $rootimg_dir/proc");
-}
-
-# Load driver update disk, and copy them to the root image
-my @dd_drivers = &load_dd();
-
-# Push the drivers into the @ndrivers base on the order
-my @new_order = ();
-foreach my $dd (@dd_drivers) {
- unless (grep { $_ eq $dd } @ndrivers) {
- push @new_order, $dd;
- }
- print "Added driver $dd from driver update disk or driver rpm\n";
-}
-
-if (@new_order) {
- @ndrivers = (@new_order, @ndrivers);
-}
-
-# add drivers for local disk support
-push @ndrivers, ("ext3.ko", "ext4.ko", "virtio_pci.ko", "virtio_blk.ko", "libata.ko", "scsi_mod.ko", "scsi_dh.ko", "ahci.ko", "megaraid_sas.ko", "sd_mod.ko");
-
-if ($osver_host >= 12) {
- push @ndrivers, ("ibmvscsi.ko");
-} else { # for sles11 or lower
- push @ndrivers, ("ibmvscsic.ko", "ata_piix.ko", "pcieport.ko");
-}
-
-if (-f "$rootimg_dir/lib/modules/$kernelver/kernel/drivers/net/ethernet/mellanox/mlx4/mlx4_en.ko") {
- for (@ndrivers) {
- s/mlx_en/mlx4_en/;
- }
-}
-
-open($moddeps, "<", "$rootimg_dir/lib/modules/$kernelver/modules.dep");
-my @moddeps = <$moddeps>;
-my @checkdeps = @ndrivers;
-while (scalar @checkdeps) {
- my $driver = pop @checkdeps;
- my @lines = grep /\/$driver:/, @moddeps;
- foreach (@lines) {
- chomp;
- s/.*://;
- s/^\s*//;
- my @deps = split /\s+/, $_;
- if ($driver =~ /libcrc32c.ko/) {
- push @deps, 'crc32c.ko';
- }
- my $dep;
- foreach $dep (@deps) {
- $dep =~ s/.*\///;
- unless (grep { $_ eq $dep } @ndrivers) { #only add if not added
- print "Added $dep as an autodetected dependency\n";
- }
- unshift(@checkdeps, $dep); #recursively check dependencies
- unshift(@ndrivers, $dep);
- }
- }
-}
-close($moddeps);
-
-#remove the duplicated drivers
-my @fulldrivers;
-foreach my $dn (@ndrivers) {
- unless (grep { $_ eq $dn } @fulldrivers) {
- push @fulldrivers, $dn;
- }
-}
-@ndrivers = @fulldrivers;
-
-# before mkinitrd, run depmod to generate the modules.dep
-system("chroot $rootimg_dir depmod $kernelver");
-
-if ($dracutmode) {
- mkinitrd_dracut("stateless");
- mkinitrd_dracut("statelite");
-} else {
- my @drivers; # backup of @ndrivers
- push @drivers, @ndrivers;
- mkinitrd("statelite");
- @ndrivers = ();
- push @ndrivers, @drivers;
- mkinitrd("stateless");
-}
-print "It is safe to ignore message 'Failed to connect to bus: No such file or directory' that may have appeared above one or more times.\n";
-
-sub getlibs {
- my $file = shift;
- my $liblist = `chroot $rootimg_dir ldd $file`;
- if ($liblist =~ /not a dynamic executable/) {
- return;
- }
- my @libs = split /\n/, $liblist;
- my @return;
- foreach (@libs) {
- unless (/=>/) {
- (my $wjnk, my $lib, my $jnk) = split /\s+/, $_, 3;
- $lib =~ s/^\///;
- $libhash{$lib} = 1;
- next;
- }
- (my $temp1, my $temp2) = split />/, $_, 2;
- (my $whitespace, $temp1, $temp2) = split /\s+/, $temp2, 4;
- unless ($temp1 =~ /\//) {
- next;
- }
- $temp1 =~ s/^\///;
- $libhash{$temp1} = 1;
- }
-}
-
-#added dracut
-sub mkinitrd_dracut {
- my ($mode) = @_; # the mode is for statelite or stateless
-
- my $dracutmoduledir = "$rootimg_dir/usr/share/dracut/modules.d/";
- if ((!-d $dracutmoduledir) and (-d "$rootimg_dir/usr/lib/dracut/modules.d/"))
- {
- $dracutmoduledir = "$rootimg_dir/usr/lib/dracut/modules.d/";
- }
-
- if ($dracutver >= "033") {
-
- my $perm = (stat("$fullpath/$dracutdir/patch/syslog/module-setup.sh"))[2];
- cp("$fullpath/$dracutdir/patch/syslog/module-setup.sh", $dracutmoduledir . "98syslog/");
- chmod($perm & 07777, $dracutmoduledir . "98syslog/" . "module-setup.sh");
-
- $perm = (stat("$fullpath/$dracutdir/patch/syslog/rsyslogd-start.sh"))[2];
- cp("$fullpath/$dracutdir/patch/syslog/rsyslogd-start.sh", $dracutmoduledir . "98syslog/");
- chmod($perm & 07777, $dracutmoduledir . "98syslog/" . "rsyslogd-start.sh");
-
- $perm = (stat("$fullpath/$dracutdir/patch/syslog/syslog-genrules.sh"))[2];
- cp("$fullpath/$dracutdir/patch/syslog/syslog-genrules.sh", $dracutmoduledir . "98syslog/");
- chmod($perm & 07777, $dracutmoduledir . "98syslog/" . "syslog-genrules.sh");
-
- }
-
- my $dracutmpath = $dracutmoduledir . "97xcat/";
- mkpath($dracutmpath);
-
- my $perm = (stat("$fullpath/$dracutdir/check"))[2];
- cp("$fullpath/$dracutdir/check", $dracutmpath);
- chmod($perm & 07777, "$dracutmpath/check");
-
- foreach (@ndrivers) { s/\.ko$//; }
-
- # Add drivers to support local disk
- push @ndrivers, "ext3";
- push @ndrivers, "ext4";
-
- #remove the duplicated drivers
- my @fulldrivers;
- foreach my $dn (@ndrivers) {
- unless (grep { $_ eq $dn } @fulldrivers) {
- push @fulldrivers, $dn;
- }
- }
- @ndrivers = @fulldrivers;
-
- my $add_drivers = join(' ', @ndrivers);
- print "Try to load drivers: $add_drivers to initrd.\n";
- my $DRACUTCONF;
-
- if ($mode eq "statelite") {
-
- # for statelite
- cp("$fullpath/$dracutdir/install.statelite", "$dracutmpath/install");
- $perm = (stat("$fullpath/$dracutdir/install.statelite"))[2];
- chmod($perm & 07777, "$dracutmpath/install");
-
- cp("$installroot/postscripts/updateflag.awk", "$dracutmpath/xcat-updateflag");
- $perm = (stat("$installroot/postscripts/updateflag.awk"))[2];
- chmod($perm & 07777, "$dracutmpath/xcat-updateflag");
-
- cp("$fullpath/$dracutdir/xcat-prepivot.sh", $dracutmpath);
- $perm = (stat("$fullpath/$dracutdir/xcat-prepivot.sh"))[2];
- chmod($perm & 07777, "$dracutmpath/xcat-prepivot.sh");
-
- cp("$fullpath/$dracutdir/xcat-premount.sh", $dracutmpath);
- $perm = (stat("$fullpath/$dracutdir/xcat-premount.sh"))[2];
- chmod($perm & 07777, "$dracutmpath/xcat-premount.sh");
-
- #update etc/dracut.conf
- open($DRACUTCONF, '>', "$rootimg_dir/etc/dracut.conf");
- if (-d glob($dracutmoduledir . "[0-9]*fadump")) {
- print $DRACUTCONF qq{dracutmodules+="xcat nfs base network kernel-modules lvm fadump"\n};
- }
- else {
- print $DRACUTCONF qq{dracutmodules+="xcat nfs base network kernel-modules lvm"\n};
- }
- print $DRACUTCONF qq{add_drivers+="$add_drivers"\n};
- print $DRACUTCONF qq{filesystems+="nfs"\n};
- close $DRACUTCONF;
- } elsif ($mode eq "stateless") {
- cp("$fullpath/$dracutdir/install.netboot", "$dracutmpath/install");
- $perm = (stat("$fullpath/$dracutdir/install.netboot"))[2];
- chmod($perm & 07777, "$dracutmpath/install");
-
- cp("$fullpath/$dracutdir/xcat-cmdline.sh", "$dracutmpath/");
- $perm = (stat("$fullpath/$dracutdir/xcat-cmdline.sh"))[2];
- chmod($perm & 07777, "$dracutmpath/xcat-cmdline.sh");
-
- cp("$installroot/postscripts/updateflag.awk", "$dracutmpath/xcat-updateflag");
- $perm = (stat("$installroot/postscripts/updateflag.awk"))[2];
- chmod($perm & 07777, "$dracutmpath/xcat-updateflag");
- if ($prinic) {
- my $optspec;
- open($optspec, '>>', "$dracutmpath/xcat-cmdline.sh");
- print $optspec "PRINIC=$prinic\n";
- close $optspec;
- }
-
- cp("$fullpath/$dracutdir/xcatroot", "$dracutmpath/");
- $perm = (stat("$fullpath/$dracutdir/xcatroot"))[2];
- chmod($perm & 07777, "$dracutmpath/xcatroot");
-
- cp("$fullpath/$dracutdir/installkernel", "$dracutmpath/");
- $perm = (stat("$fullpath/$dracutdir/installkernel"))[2];
- chmod($perm & 07777, "$dracutmpath/installkernel");
-
- # update etc/dracut.conf
- open($DRACUTCONF, '>', "$rootimg_dir/etc/dracut.conf");
- if (-d glob($dracutmoduledir . "[0-9]*fadump")) {
- print $DRACUTCONF qq{dracutmodules+="xcat nfs base network kernel-modules lvm fadump syslog"\n};
- }
- else {
- print $DRACUTCONF qq{dracutmodules+="xcat nfs base network kernel-modules lvm syslog"\n};
- }
- print $DRACUTCONF qq{add_drivers+="$add_drivers"\n};
- close $DRACUTCONF;
- } else {
- xdie "the mode: $mode is not supported by genimage";
- }
-
- my $additional_options = undef;
- if ($rootlimit)
- {
- open(my $ETC_CMDLINE, ">", "$rootimg_dir/tmp/cmdline");
- print $ETC_CMDLINE qq{rootlimit=$rootlimit\n};
- close $ETC_CMDLINE;
- $additional_options = qq{--include /tmp/cmdline /etc/cmdline};
- }
-
- # force the dracut run in non-hostonly mode for dracut higher than version 033
- if ($dracutver > "033") {
- $additional_options .= " -N";
- }
-
- #if "pigz" is available in the rootimg, use "pigz" instead of "gzip"
- my $compress = qx(chroot $rootimg_dir bash -c "type -p pigz"|tr -d "\n");
- if ($compress) {
-
- #take the online cpu numerber as the pigz processes number
- my $processnum = qx(lscpu -p=cpu --online|grep -v '#'|wc -l|tr -d "\n");
- $additional_options .= " --compress \"$compress -p $processnum \"";
- }
-
- print "\nchroot $rootimg_dir dracut $additional_options -f /tmp/initrd.$$.gz $kernelver\n";
- !system("chroot $rootimg_dir dracut $additional_options -f /tmp/initrd.$$.gz $kernelver")
- or die("Error: failed to generate the initial ramdisk for $mode.\n");
- print "the initial ramdisk for $mode is generated successfully.\n";
- move("$rootimg_dir/tmp/initrd.$$.gz", "$destdir/initrd-$mode.gz");
-}
-
-
-sub mkinitrd {
- my ($mode) = @_; # statelite or stateless
-
- if ($mode eq "statelite") {
-
- # additional modules needed on s390x
- push @ndrivers, qw{qdio.ko ccwgroup.ko qeth.ko qeth_l2.ko qeth_l3.ko} if ($arch eq "s390x");
-
- # for nfs
- my @modlist = qw{sunrpc.ko lockd.ko nfs_acl.ko fscache.ko auth_rpcgss.ko exportfs.ko nfsd.ko nfs.ko};
- unshift(@ndrivers, @modlist);
- }
-
- mkpath("/tmp/xcatinitrd.$$/bin");
- symlink("bin", "/tmp/xcatinitrd.$$/sbin");
- mkpath("/tmp/xcatinitrd.$$/usr/bin");
- mkpath("/tmp/xcatinitrd.$$/usr/sbin");
- mkpath("/tmp/xcatinitrd.$$/usr/lib");
- mkpath("/tmp/xcatinitrd.$$/usr/lib64");
- mkpath("/tmp/xcatinitrd.$$/lib/firmware");
- mkpath("/tmp/xcatinitrd.$$/tmp");
- mkpath("/tmp/xcatinitrd.$$/var/run");
- mkpath("/tmp/xcatinitrd.$$/lib64/firmware");
- mkpath("/tmp/xcatinitrd.$$/lib/power6"); #SLES10
- mkpath("/tmp/xcatinitrd.$$/lib/power7"); #SLES10
- mkpath("/tmp/xcatinitrd.$$/lib/mkinitrd/bin");
- mkpath("/tmp/xcatinitrd.$$/proc");
- mkpath("/tmp/xcatinitrd.$$/sys");
- mkpath("/tmp/xcatinitrd.$$/dev/mapper");
- mkpath("/tmp/xcatinitrd.$$/sysroot");
- mkpath("/tmp/xcatinitrd.$$/etc/ld.so.conf.d");
- mkpath("/tmp/xcatinitrd.$$/var/lib/dhcpcd");
- my $inifile;
- open($inifile, ">", "/tmp/xcatinitrd.$$/init");
- print $inifile "#!/bin/bash\n";
-
- # copied from genimage for rh
- # add some functions
- print $inifile < <\\ \\____/ | \\ |
- /__/\\_ \\\\______ /\\____|__ /____|
- \\/ \\/ \\/
-'
- echo -e "\$RESET"
-}
-
-
-EOS1
-
- print $inifile "mount -t proc /proc /proc\n";
- print $inifile "mount -t sysfs /sys /sys\n";
- print $inifile "mount -o mode=0755 -t tmpfs /dev /dev\n";
- print $inifile "mkdir /dev/pts\n";
- print $inifile "mount -t devpts -o gid=5,mode=620 /dev/pts /dev/pts\n";
- print $inifile "mkdir /dev/shm\n";
- print $inifile "mkdir /dev/mapper\n";
-
- print $inifile "mknod /dev/random c 1 8\n";
- print $inifile "mknod /dev/urandom c 1 9\n";
- print $inifile "mknod /dev/null c 1 3\n";
- print $inifile "mknod /dev/zero c 1 5\n";
- print $inifile "mknod /dev/systty c 4 0\n";
- print $inifile "mknod /dev/tty c 5 0\n";
- print $inifile "mknod /dev/console c 5 1\n";
- print $inifile "mknod /dev/ptmx c 5 2\n";
- print $inifile "mknod /dev/rtc c 10 135\n";
- print $inifile "mknod /dev/tty0 c 4 0\n";
- print $inifile "mknod /dev/tty1 c 4 1\n";
- print $inifile "mknod /dev/tty2 c 4 2\n";
- print $inifile "mknod /dev/tty3 c 4 3\n";
- print $inifile "mknod /dev/tty4 c 4 4\n";
- print $inifile "mknod /dev/tty5 c 4 5\n";
- print $inifile "mknod /dev/tty6 c 4 6\n";
- print $inifile "mknod /dev/tty7 c 4 7\n";
- print $inifile "mknod /dev/tty8 c 4 8\n";
- print $inifile "mknod /dev/tty9 c 4 9\n";
- print $inifile "mknod /dev/tty10 c 4 10\n";
- print $inifile "mknod /dev/tty11 c 4 11\n";
- print $inifile "mknod /dev/tty12 c 4 12\n";
- print $inifile "mknod /dev/ttyS0 c 4 64\n";
- print $inifile "mknod /dev/ttyS1 c 4 65\n";
- print $inifile "mknod /dev/ttyS2 c 4 66\n";
- print $inifile "mknod /dev/ttyS3 c 4 67\n";
-
- # Install modules before starting udev
- # because networking modules (qeth/qeth_l2/qeth_l3) are needed
- foreach (@ndrivers) {
- print $inifile "insmod /lib/$_\n";
- }
-
- # Start udev
- print $inifile < /dev/null && export DEBUG=1\n";
- }
-
- print $inifile < /tmp/ifcfg-\$IFACE
-
-ip addr add dev lo 127.0.0.1/8
-ip link set lo up
-
-
-XCATMASTER=`echo \$XCATSERVER|awk -F: '{print \$1}'`
-
-if [ -z \$XCATIPORT ]; then
- XCATIPORT="3002"
-fi
-
-if [ \$NODESTATUS != 'n' ]; then
- /tmp/updateflag \$XCATMASTER \$XCATIPORT "installstatus netbooting"
-fi
-
-cd /
-for i in `cat /proc/cmdline`; do
- KEY=`echo \$i |awk -F= '{print \$1}'`
- if [ "\$KEY" == 'imgurl' ]; then
- VALUE=`echo \$i |awk -F= '{print \$2}'`
- if [ "http" == "`echo \$VALUE|awk -F: '{print \$1}'`" ]; then
- #NOTE needs FT retry code to scale
- #NOTE: should prob have max count
- FILENAME=`echo \$VALUE|awk -F/ '{print \$NF}'`
- while [ ! -r "\$FILENAME" ]; do
- echo Getting \$VALUE...
- if ! wget \$VALUE; then
- sleep 5 #should be random, exponential for scale
- rm -f \$FILENAME
- fi
- done
- fi
- elif [[ "\$KEY" == NFSROOT ]]; then # for NFSROOT
- NFSROOT=1
- VALUE=`echo \$i |awk -F= '{print \$2}'`
- SERVER=`echo \$VALUE|awk -F: '{print \$1}'`
- ROOTDIR=`echo \$VALUE|awk -F/ '{for(i=2;i<=NF;i++) printf "/%s",\$i}'`
- elif [ "\$KEY" == 'STATEMNT' ]; then
- STATELITE=1
- VALUE=`echo \$i |awk -F= '{print \$2}'`
- # VALUE may be null
- if [ ! -z \$VALUE ]; then
- SNAPSHOTSERVER=`echo \$VALUE|awk -F: '{print \$1}'`
- SNAPSHOTROOT=`echo \$VALUE|awk -F/ '{for(i=2;i<=NF;i++) printf "/%s",\$i}'`
- # may be that there is not server and just a directory.
- if [ -z \$SNAPSHOTROOT ]; then
- SNAPSHOTROOT=\$SNAPSHOTSERVER
- SNAPSHOTSERVER=
- fi
- fi
- elif [ "\$KEY" == 'NODE' ]; then
- NODENAME=`echo \$i |awk -F= '{print \$2}'`
- fi
-done
-
-# show xCAT logo
-fancydisplay
-
-# Statelite code is here
-if [ "\$STATELITE" = "1" ]; then
- echo Setting up Statelite
- mknod /dev/loop0 b 7 0
- mkdir -p \$NEWROOT
- MAXTRIES=15
- ITER=0
- ME=`hostname`
- if [ ! -z "$NODENAME" ]; then
- ME=$NODENAME
- fi
- if [ "\$NFSROOT" = "1" ]; then
- while ! mount.nfs \${SERVER}:\${ROOTDIR}/rootimg \$NEWROOT -r -n -o nolock,rsize=32768,tcp,nfsvers=3,timeo=14; do
- ITER=\$(expr \$ITER + 1)
- if [ "\$ITER" = "\$MAXTRIES" ]; then
- echo "You're dead. rpower \$ME boot to play again."
- echo "Possible problems:
-1. This initrd wan't created for the statelite node?
-2. IS DNS set up? Maybe that's why I can't mount \${SERVER}.
-3. The nfs modules aren't set right in this initial ramdisk?"
- shell
- exit
- fi
- echo -e "\${RED}Couldn't mount \$SERVER:\$ROOTDIR on \$NEWROOT \$RESET"
- RS=\$(expr \$RANDOM % 30)
- echo -e "Trying again in \$RS seconds"
- sleep \$RS
- done
- else
- # for statelite mode on top of the ramdisk
-EOMS
-
- print $inifile "if [ -r /rootimg-statelite.gz ]; then \n";
- print $inifile "echo Setting up RAM-root tmpfs.\n";
- if ($rootlimit) {
- print $inifile " mount -o size=$rootlimit,mode=755 -t tmpfs rootfs \$NEWROOT \n";
- } else {
- print $inifile " mount -o mode=755 -t tmpfs rootfs \$NEWROOT \n";
- }
-
- print $inifile </dev/null && shell
- mount -t tmpfs rw -o mode=$permission \$NEWROOT/\$RWDIR
- mkdir -p \$NEWROOT/\$RWDIR/tmpfs
-
- #mount the /root/.ssh, it needs more strict permission in order for ssh work
- #if [ ! -e "\$NEWROOT/root/.ssh" ]
- #then
- # mkdir -p \$NEWROOT/root/.ssh
- #fi
- #mount -t tmpfs -o mode=755 ssh \$NEWROOT/root/.ssh
-
- # mount the SNAPSHOT directory here for persistent use.
- if [ ! -z \$SNAPSHOTSERVER ]
- then
- mkdir -p \$NEWROOT/\$RWDIR/persistent
- MAXTRIES=5
- ITER=0
- while ! mount \$SNAPSHOTSERVER:\$SNAPSHOTROOT \$NEWROOT/\$RWDIR/persistent -o nolock,\$XCATMNTOPTS
- do
- ITER=\$(expr \$ITER + 1)
- if [ "\$ITER" == "\$MAXTRIES" ]
- then
- echo "You're dead. rpower \$ME boot to play again."
- echo "Possible problems:
-1. \$SNAPSHOTSERVER is not exporting \$SNAPSHOTROOT ?
-2. Is DNS set up? Maybe that's why I can't mount \$SNAPSHOTSERVER."
- shell
- exit
- fi
- echo -e "\${RED}Hmmm... Can't mount \$SNAPSHOTSERVER:\$SNAPSHOTROOT. \${NORMAL} \$XCATMNTOPTS"
- RS=`expr \$RANDOM % 20`
- echo -e "Trying again in \$RS seconds"
- sleep \$RS
- done
-
- # create directory which is named after my node name
- mkdir -p \$NEWROOT/\$RWDIR/persistent/\$ME
- ITER=0
- # umount current persistent mount
- while ! umount -l \$NEWROOT/\$RWDIR/persistent; do
- ITER=\$(( ITER + 1 ))
- if [ "\$ITER" == "\$MAXTRIES" ]; then
- echo "Your are dead, rpower \$ME boot to play again."
- echo "Cannot umount \$NEWROOT/\$RWDIR/persistent."
- /bin/sh
- exit
- fi
- RS= \$(( \$RANDOM % 20 ))
- echo "Trying again in \$RS seconds..."
- sleep \$RS
- done
-
- # mount persistent to server:/rootpath/nodename
- ITER=0
- while ! mount \$SNAPSHOTSERVER:/\$SNAPSHOTROOT/\$ME \$NEWROOT/\$RWDIR/persistent -o nolock,\$XCATMNTOPTS; do
- ITER=\$(( ITER + 1 ))
- if [ "\$ITER" == "\$MAXTRIES" ]; then
- echo "Your are dead, rpower \$ME boot to play again."
- echo "Possible problems: cannot mount to \$SNAPSHOTSERVER:/\$SNAPSHOTROOT/\$ME."
- /bin/sh
- exit
- fi
- RS= \$(( \$RANDOM % 20 ))
- echo "Trying again in \$RS seconds..."
- sleep \$RS
- done
- fi
-
- grep '\\(shell\\)' /proc/cmdline >/dev/null && shell
-
- # have to preserve the initial DHCP request. So we link it.
- # SLES uses different file to store DHCP info
- if [ ! -d \$NEWROOT/\$RWDIR/tmpfs/var/lib/dhcpcd ]
- then
- mkdir -p \$NEWROOT/\$RWDIR/tmpfs/var/lib/dhcpcd
- fi
- cp -fp /var/lib/dhcpcd/dhcpcd-\$IFACE.info \${NEWROOT}/\${RWDIR}/tmpfs/var/lib/dhcpcd/dhcpcd-\$IFACE.info
-
- [ -e /etc/ntp.conf ] && mkdir -p \$NEWROOT/\$RWDIR/tmpfs/etc && cp /etc/ntp.conf \$NEWROOT/\$RWDIR/tmpfs/etc/
-
- [ -e /etc/resolv.conf ] && mkdir -p \$NEWROOT/\$RWDIR/tmpfs/etc && cp /etc/resolv.conf \$NEWROOT/\$RWDIR/tmpfs/etc/
-
- # now that everything is mounted, lets do this
- # hmmm, apparently I'm checking this twice... so I'd better
- # be really sure the file is there.
- while [ ! -e \$NEWROOT/etc/init.d/statelite ]
- do
- echo "\$NEWROOT/etc/init.d/statelite does not exist in image!"
- shell
- done
-
- # try to configure the local disk
- \$NEWROOT/etc/init.d/localdisk
-
- # do all the mounts:
- \$NEWROOT/etc/init.d/statelite
-EOMS
-
- # udevd needed by s390x for networking
- # but for other type of machine, udevd will affect the start of devices which detected
- # after the chroot, so kill it before the switching root
- if ($arch ne "s390x") {
- print $inifile "\n killall -9 udevd\n";
- }
-
- print $inifile < /dev/null && shell
-
- echo 0x100 > /proc/sys/kernel/real-root-dev
- export keep_old_ip=yes
- export fastboot=yes
- export READONLY=yes
- grep '\\(shell\\)' /proc/cmdline >/dev/null && shell
- mount -n --bind /dev /sysroot/dev
- umount /sys
- umount /proc
-
- # sles use the standard utility to chroot
- if ! exec /usr/bin/chroot \$NEWROOT /sbin/init
- then
- echo ""
- echo -e "\${RED}Couldn't chroot. Something must be wrong with NFS root image.\${RESET}"
- shell
- fi
- exit
-fi
-# end NFSROOT/Statelite code
-
-if [ -r /rootimg.sfs ]; then
- echo Setting up squashfs with ram overlay.
- mknod /dev/loop0 b 7 0
- mkdir -p /ro
- mkdir -p /rw
- mount -t squashfs /rootimg.sfs /ro
- mount -t tmpfs rw /rw
- mount -t aufs -o dirs=/rw:/ro mergedroot /sysroot
- mkdir -p /sysroot/ro
- mkdir -p /sysroot/rw
- mount --move /ro /sysroot/ro
- mount --move /rw /sysroot/rw
-EOMS
- print $inifile "elif [ -r /rootimg.cpio.gz ] || [ -r /rootimg.cpio.xz ]; then\n";
- print $inifile "echo Setting up RAM-root tmpfs.\n";
- if ($rootlimit) {
- print $inifile " mount -o size=$rootlimit,mode=755 -t tmpfs rootfs \$NEWROOT\n";
- } else {
- print $inifile " mount -o mode=755 -t tmpfs rootfs \$NEWROOT\n";
- }
- print $inifile " cd /sysroot\n";
- print $inifile " echo -n \"Extracting root filesystem:\"\n";
- print $inifile " if [ -r /rootimg.cpio.gz ]; then\n";
- print $inifile " if [ -x /bin/cpio ]; then\n";
- print $inifile " zcat /rootimg.cpio.gz |/bin/cpio -idum\n";
- print $inifile " else\n";
- print $inifile " zcat /rootimg.cpio.gz |cpio -idum\n";
- print $inifile " fi\n";
- print $inifile " elif [ -r /rootimg.cpio.xz ]; then\n";
- print $inifile " if [ -x /bin/cpio ]; then\n";
- print $inifile " xz -cd /rootimg.cpio.xz |/bin/cpio -idum\n";
- print $inifile " else\n";
- print $inifile " xz -cd /rootimg.cpio.xz |cpio -idum\n";
- print $inifile " fi\n";
- print $inifile " fi\n";
- print $inifile " echo Done\n";
- print $inifile "elif [ -r /rootimg.tar.gz ] || [ -r /rootimg.tar.xz ]; then\n";
- print $inifile " echo Setting up RAM-root tmpfs.\n";
-
- if ($rootlimit) {
- print $inifile " mount -o \"size=$rootlimit,mode=755\" -t tmpfs rootfs \$NEWROOT\n";
- } else {
- print $inifile " mount -o mode=755 -t tmpfs rootfs \$NEWROOT\n";
- }
- print $inifile " cd \$NEWROOT\n";
- print $inifile " echo -n \"Extracting root filesystem:\"\n";
- print $inifile " if [ -r /rootimg.tar.gz ]; then\n";
- print $inifile " tar --selinux --xattrs-include='*' -zxf /rootimg.tar.gz\n";
- print $inifile " if [ \$? -ne 0 ]; then\n";
- print $inifile " tar -zxf /rootimg.tar.gz\n";
- print $inifile " fi\n";
- print $inifile " elif [ -r /rootimg.tar.xz ]; then\n";
- print $inifile " tar --selinux --xattrs-include='*' -Jxf /rootimg.tar.xz\n";
- print $inifile " if [ \$? -ne 0 ]; then\n";
- print $inifile " tar -Jxf /rootimg.tar.xz\n";
- print $inifile " fi\n";
- print $inifile " fi\n";
- print $inifile " echo Done\n";
- print $inifile "else\n";
- print $inifile " echo -n Failed to download image, panicing in 5...\n";
- print $inifile " for i in 4 3 2 1 0; do\n";
- print $inifile " /bin/sleep 1\n";
- print $inifile " echo -n \$i...\n";
- print $inifile " done\n";
- print $inifile " echo\n";
- print $inifile <" . "/tmp/xcatinitrd.$$/bin/netstart");
- print $inifile "#!/bin/bash \n";
- if ($osver_host == 10) {
- print $inifile "dhcpcd \${1}\n";
- } else { # for sles11 or higher
- # -p is used to keep the network connection during the shutdown. Used for nfs-based statelite shutdown
- print $inifile "dhcpcd \${1} -p\n";
- }
-
- #-- Bring other NICs up in /bin/netstart in initrd for NIC failover
- foreach (split /,/, $othernics) {
- if (/^$/) { next; }
- print $inifile "dhcpcd $_\n";
- }
-
- print $inifile <> /etc/HOSTNAME
-END
-
- close($inifile);
-
- #if "nonodestatus" specified,do not update the nodestatus
- system("mkdir -p /tmp/xcatinitrd.$$/tmp/");
- cp("$installroot/postscripts/updateflag.awk","/tmp/xcatinitrd.$$/tmp/updateflag");
- $perm = (stat("$installroot/postscripts/updateflag.awk"))[2];
- chmod($perm & 07777, "/tmp/xcatinitrd.$$/tmp/updateflag");
-
- chmod(0755, "/tmp/xcatinitrd.$$/init");
- chmod(0755, "/tmp/xcatinitrd.$$/bin/netstart");
-
- @filestoadd = ();
- foreach (@ndrivers) {
- if (-f "$customdir/$_") {
- push @filestoadd, [ $_, "lib/$_" ];
- } elsif (-f "$pathtofiles/$_") {
- push @filestoadd, [ $_, "lib/$_" ];
- }
- }
- if ($mode eq "statelite") {
- foreach ("sbin/ifconfig", "usr/bin/clear", "usr/bin/touch", "usr/bin/cut", "usr/bin/rm", "bin/hostname", "usr/bin/egrep", "bin/ln", "bin/ls", "usr/bin/dirname", "usr/bin/expr", "usr/bin/chroot", "usr/bin/grep", "bin/cpio", "bin/sleep", "bin/mount", "bin/umount", "sbin/dhcpcd", "bin/bash", "sbin/insmod", "bin/mkdir", "bin/mknod", "sbin/ip", "bin/cat", "usr/bin/awk", "usr/bin/wget", "bin/cp", "usr/bin/cpio", "usr/bin/zcat", "usr/bin/gzip", "lib/mkinitrd/bin/run-init", "usr/bin/uniq", "usr/bin/sed", "usr/bin/wc", "bin/sed", "sbin/udevd", "usr/bin/readlink", "usr/sbin/parted", "sbin/mke2fs", "sbin/mkswap", "sbin/swapon", "bin/chmod", "usr/bin/bc", "usr/bin/xz", "usr/bin/gzip", "bin/tar") {
- getlibs($_);
- push @filestoadd, $_;
- }
- if ($osver_host >= 11) {
- foreach ("sbin/mount.nfs", "sbin/umount.nfs", "sbin/udevadm") {
- getlibs($_);
- push @filestoadd, $_;
- }
- }
-
- } else {
- foreach ("sbin/ifconfig", "usr/bin/clear", "usr/bin/touch", "usr/bin/grep", "usr/bin/egrep", "bin/cpio", "bin/sleep", "bin/mount", "sbin/dhcpcd", "bin/bash", "sbin/insmod", "bin/mkdir", "bin/mknod", "sbin/ip", "bin/cat", "usr/bin/awk", "usr/bin/wget", "bin/cp", "usr/bin/cpio", "usr/bin/zcat", "usr/bin/gzip", "lib/mkinitrd/bin/run-init", "usr/bin/uniq", "usr/bin/sed", "sbin/udevd", "usr/bin/readlink", "usr/bin/expr", "usr/sbin/parted", "sbin/mke2fs", "sbin/mkswap", "sbin/swapon", "bin/chmod", "usr/bin/bc", "usr/bin/xz", "usr/bin/gzip", "bin/tar") {
- getlibs($_);
- push @filestoadd, $_;
- }
- if ($osver_host >= 11) {
- getlibs("sbin/udevadm");
- push @filestoadd, "sbin/udevadm";
- }
- }
-
- if ($arch =~ /64/) {
- push @filestoadd, "lib64/libnss_dns.so.2";
- push @filestoadd, "lib64/libnss_files.so.2";
- }
- else {
- push @filestoadd, "lib/libnss_dns.so.2";
- push @filestoadd, "lib/libnss_files.so.2";
- }
-
- # cross-platfrom support on power6&7 etc
- # ldd can't handle such one scenario: mn is power6, the target platform is power7
- if ($arch =~ /ppc64/) {
- system("cp -a -r $rootimg_dir/lib64/* /tmp/xcatinitrd.$$/lib64/");
- }
-
-
- push @filestoadd, keys %libhash;
-
- find(\&isnetdriver, <$rootimg_dir/lib/modules/$kernelver/*>);
- my $pathonrootimage = "$rootimg_dir/tmpfiles";
- my $pathinrootimage = "/tmpfiles";
- mkpath($pathonrootimage);
- foreach (@filestoadd) {
- if (ref($_)) {
-
- #print "$_->[0], $_->[1]\n";
- my $srcfile = $_->[0];
- system("chroot $rootimg_dir cp $srcfile $pathinrootimage");
- my $srcpath = "$pathonrootimage/" . basename($_->[0]);
- if (-f "$customdir/" . $_->[0]) {
- $srcpath = "$customdir/" . $_->[0];
- } elsif (-f "$pathtofiles/" . $_->[0]) {
- $srcpath = "$pathtofiles/" . $_->[0];
- }
- mkpath(dirname("/tmp/xcatinitrd.$$/" . $_->[1]));
- copy($srcpath, "/tmp/xcatinitrd.$$/" . $_->[1]);
- chmod 0755, "/tmp/xcatinitrd.$$/" . $_->[1];
- } else {
-
- #print "$_\n";
- system("chroot $rootimg_dir cp $_ $pathinrootimage");
- my $srcpath = "$pathonrootimage/" . basename($_);
- if (-f "$customdir/$_") {
- $srcpath = "$customdir/$_";
- } elsif (-f "$pathtofiles/$_") {
- $srcpath = "$pathtofiles/$_";
- }
- mkpath(dirname("/tmp/xcatinitrd.$$/$_"));
- copy("$srcpath", "/tmp/xcatinitrd.$$/$_");
- chmod 0755, "/tmp/xcatinitrd.$$/" . $_;
- }
- }
- rmtree($pathonrootimage);
-
- #copy conf files needed by nfs mount in sles11.2
- if ($osver_host >= 11)
- {
- system("cp -r $rootimg_dir/etc/protocols /tmp/xcatinitrd.$$/etc/");
- system("cp -r $rootimg_dir/etc/netconfig /tmp/xcatinitrd.$$/etc/");
- }
-
-
- # Copy udev libraries
- system("mkdir -p /tmp/xcatinitrd.$$/etc/udev");
- system("mkdir -p /tmp/xcatinitrd.$$/lib/firmware");
- system("cp -r $rootimg_dir/etc/udev/* /tmp/xcatinitrd.$$/etc/udev");
- system("cp -r $rootimg_dir/bin/uname /tmp/xcatinitrd.$$/bin/");
- if (-d "$rootimg_dir/lib/firmware/") {
- system("cp -r $rootimg_dir/lib/firmware/* /tmp/xcatinitrd.$$/lib/firmware");
- }
- system("cp -r $rootimg_dir/usr/bin/killall /tmp/xcatinitrd.$$/usr/bin");
-
- # Copy rules for network adapter
- #my $name = `cat /etc/sysconfig/network/ifcfg-$prinic | grep NAME`;
- #my $nic = '';
- #if ($name =~ m/(\d+\.\d+\.\d+)/g) {
- # $nic = $&;
- #}
-
- # Somehow checking for *$nic.rules does not work
- #if ( -f "/etc/udev/rules.d/*$nic.rules" ) {
- # system("cp -r /etc/udev/rules.d/*$nic.rules /tmp/xcatinitrd.$$/etc/udev/rules.d");
- #}
- #if ( -f "/etc/udev/rules.d/*persistent-net.rules" ) {
- # system("cp -r /etc/udev/rules.d/*persistent-net.rules /tmp/xcatinitrd.$$/etc/udev/rules.d");
- #}
-
- system("mkdir -p /tmp/xcatinitrd.$$/lib/udev");
- system("cp -r $rootimg_dir/lib/udev/* /tmp/xcatinitrd.$$/lib/udev");
-
- #copy("$rootimg_dir/lib/modules/*d","/tmp/xcatinitrd.$$/$_");
- system("cd /tmp/xcatinitrd.$$/bin/; ln -sf bash sh"); #neccessary for SLES11
- if ($mode eq "statelite") {
- system("cd /tmp/xcatinitrd.$$;find .|cpio -H newc -o|gzip -9 -c - > $destdir/initrd-statelite.gz");
- print "The initial ramdisk for statelite has been generated successfully!\n";
- } else {
- system("cd /tmp/xcatinitrd.$$;find .|cpio -H newc -o|gzip -9 -c - > $destdir/initrd-stateless.gz");
- print "The initial ramdisk for stateless has been generated successfully!\n";
- }
- system("rm -rf /tmp/xcatinitrd.$$");
-
-}
-
-sub isyumdir {
- if ($File::Find::name =~ /\/repodata$/) {
- my $location = $File::Find::name;
- $location =~ s/\/repodata$//;
- push @yumdirs, $location;
- }
-}
-
-sub isnetdriver {
- foreach (@ndrivers) {
- if ($File::Find::name =~ /\/$_/) {
- my $filetoadd = $File::Find::name;
- $filetoadd =~ s!$rootimg_dir!!;
- push @filestoadd, [ $filetoadd, "lib/$_" ];
- print "Added driver $_ to initrd\n";
- }
- }
-}
-
-
-
-
-
-
-
-sub postscripts { # TODO: customized postscripts
- generic_post();
- unless (-d "$rootimg_dir/opt/xcat/") {
- mkdir "$rootimg_dir/opt/xcat/";
- }
- copy("$installroot/postscripts/xcatdsklspost", "$rootimg_dir/opt/xcat/"); #TODO: it is not used in stateless
- chmod '0755', "$rootimg_dir/opt/xcat/xcatdsklspost";
-}
-
-sub generic_post { # This function is meant to leave the image in a state approximating a normal install
- my $cfgfile;
-
- #modify /etc/sysconfig/clock in the image:HWCLOCK="--local", TIMEZONE=site:timezone
- if ($timezone) {
- if (-e "$rootimg_dir/etc/sysconfig/clock") {
- system("sed -i '" . 's!\(TIMEZONE=\).*!\1' . "\"$timezone\"!" . "' $rootimg_dir/etc/sysconfig/clock");
- }
- system("chroot $rootimg_dir zic -l $timezone");
- }
-
- if (-e "$rootimg_dir/etc/sysconfig/clock") {
- system("sed -i 's!\\(HWCLOCK=\\).*!\\1\"--localtime\"!' $rootimg_dir/etc/sysconfig/clock");
- }
- if (-e "$rootimg_dir/etc/sysconfig/network/dhcp") {
- system("sed -i 's!^DHCLIENT_SET_HOSTNAME=\\\"no\\\"!DHCLIENT_SET_HOSTNAME=\\\"yes\\\"!' $rootimg_dir/etc/sysconfig/network/dhcp");
- }
-
- unlink("$rootimg_dir/dev/null");
- system("mknod $rootimg_dir/dev/null c 1 3");
- open($cfgfile, ">", "$rootimg_dir/etc/fstab");
- print $cfgfile "devpts /dev/pts devpts gid=5,mode=620 0 0\n";
- print $cfgfile "tmpfs /dev/shm tmpfs defaults 0 0\n";
- print $cfgfile "proc /proc proc defaults 0 0\n";
- print $cfgfile "sysfs /sys sysfs defaults 0 0\n";
- if ($tmplimit) {
- print $cfgfile "tmpfs /tmp tmpfs defaults,size=$tmplimit 0 2\n";
- print $cfgfile "tmpfs /var/tmp tmpfs defaults,size=$tmplimit 0 2\n";
- } else {
- print $cfgfile "tmpfs /tmp tmpfs defaults,size=10m 0 2\n";
- print $cfgfile "tmpfs /var/tmp tmpfs defaults,size=10m 0 2\n";
- }
-
- my $rootfs_name = $profile . "_" . $arch;
- print $cfgfile "$rootfs_name / tmpfs rw 0 1\n";
-
- close($cfgfile);
-
- open($cfgfile, ">", "$rootimg_dir/etc/sysconfig/network");
- print $cfgfile "NETWORKING=yes\n";
- close($cfgfile);
-
- open($cfgfile, ">", "$rootimg_dir/etc/resolv.conf");
- print $cfgfile "#Dummy resolv.conf to make boot cleaner";
- close($cfgfile);
-
- # Create the ifcfg-x file for diskless node. But keep the ONBOOT=no
- # to skip the break of nfs-based boot
- if ($prinic) {
- open($cfgfile, ">", "$rootimg_dir/etc/sysconfig/network/ifcfg-$prinic");
- print $cfgfile "ONBOOT=no\nBOOTPROTO=dhcp\nDEVICE=$prinic\nSTARTMODE=auto\n";
- close($cfgfile);
- }
-
- foreach (split /,/, $othernics) {
- next if (/^$/);
- open($cfgfile, ">", "$rootimg_dir/etc/sysconfig/network/ifcfg-$_");
- print $cfgfile "ONBOOT=yes\nBOOTPROTO=dhcp\nDEVICE=$_\nSTARTMODE=auto\n";
- close($cfgfile);
- }
-
- # securetty not needed on s390x
- if ($arch ne "s390x") {
- open($cfgfile, ">>", "$rootimg_dir/etc/securetty");
- print $cfgfile "ttyS0\n";
- print $cfgfile "ttyS1\n";
- print $cfgfile "console\n";
- close($cfgfile);
- }
-
- my @passwd;
- open($cfgfile, "<", "$rootimg_dir/etc/passwd");
- @passwd = <$cfgfile>;
- close($cfgfile);
- open($cfgfile, ">", "$rootimg_dir/etc/passwd");
- foreach (@passwd) {
- if (/^root:/) {
- s/^root:\*/root:x/;
- }
- print $cfgfile $_;
- }
- close($cfgfile);
- foreach (<$rootimg_dir/etc/skel/.*>) {
- next if (basename($_) eq '.' or basename($_) eq '..');
- copy $_, "$rootimg_dir/root/";
- }
-
- # gettyset is not found on s390x
- if ($arch ne "s390x") {
- open($cfgfile, ">", "$rootimg_dir/etc/init.d/gettyset");
- print $cfgfile "#!/bin/bash\n";
- print $cfgfile "### BEGIN INIT INFO\n";
- print $cfgfile "# Provides: gettyset\n";
- print $cfgfile "# Required-Start: sshd\n";
- print $cfgfile "# Required-Stop:\n";
- print $cfgfile "# Default-Start: 3\n";
- print $cfgfile "# Default-Stop: 0 1 2 6\n";
- print $cfgfile "# Short-Description: gettyset\n";
- print $cfgfile "# Description:\n";
- print $cfgfile "### END INIT INFO\n";
- print $cfgfile "VERS=`grep VERSION /etc/SuSE-release`\n";
- print $cfgfile "if [ -n \"\$VERS\" ]; then\n";
- print $cfgfile " VERNUM=`echo \$VERS|awk -F= \'{print \$2}\'|sed -e \'s/ //g\'`\n";
- print $cfgfile "fi\n";
- print $cfgfile "if [ \"\$VERNUM\" -gt 10 ]; then\n";
- print $cfgfile " exit\n";
- print $cfgfile "fi\n";
- print $cfgfile "\n";
- print $cfgfile "for i in `cat /proc/cmdline`; do\n";
- print $cfgfile ' KEY=`echo $i|cut -d= -f 1`' . "\n";
- print $cfgfile " if [ \"\$KEY\" == \"console\" -a \"\$i\" != \"console=tty0\" ]; then\n";
- print $cfgfile " VALUE=`echo \$i | cut -d= -f 2`\n";
- print $cfgfile " COTTY=`echo \$VALUE|cut -d, -f 1`\n";
- print $cfgfile " COSPEED=`echo \$VALUE|cut -d, -f 2|cut -dn -f 1`\n";
- print $cfgfile " if echo \$VALUE | grep n8r; then\n";
- print $cfgfile " FLOWFLAG=\"-h\"\n";
- print $cfgfile " fi\n";
- print $cfgfile " echo xco:2345:respawn:/sbin/agetty \$FLOWFLAG \$COTTY \$COSPEED xterm >> /etc/inittab\n";
- print $cfgfile " init q\n";
- print $cfgfile " fi\n";
- print $cfgfile "done\n";
- print $cfgfile "/etc/init.d/boot.localnet start\n";
-
- close($cfgfile);
- chmod(0755, "$rootimg_dir/etc/init.d/gettyset");
- }
-
- system("mkdir -p $rootimg_dir/opt/xcat");
- copy("$installroot/postscripts/xcatpostinit", "$rootimg_dir/opt/xcat/xcatpostinit");
- chmod(0755, "$rootimg_dir/opt/xcat/xcatpostinit");
- copy("$installroot/postscripts/xcatpostinit.service", "$rootimg_dir/usr/lib/systemd/system/xcatpostinit.service");
-
- #
- # set certain system services to start on boot, if the file exists in /etc/init.d as a script,
- # use insserv to start it. If not, assume that the service is controlled by systemctl
- #
- # note: insserv is passed the -f option to ignore the dependency on sles10.4
- #
- print "[genimage] setting services to start at boot time...\n";
- my @services;
- push @services, qw/sshd network gettyset xcatpostinit/;
-
- foreach my $service (@services) {
- my $cmd = "chroot $rootimg_dir ";
- $cmd = $cmd . "systemctl enable $service.service";
- system("$cmd");
- }
-
- #
- # Check if .depend.start file exists. For SLES12 and later OS, this does not apply
- #
- if (-r '$rootimg_dir/etc/init.d/.depend.start') {
- my $rc = system("grep sshd $rootimg_dir/etc/init.d/.depend.start | grep TARGETS");
- if ($rc) {
- system("sed -i '" . 's/^\(TARGETS = .*\)$/\1 sshd/' . "' $rootimg_dir/etc/init.d/.depend.start");
- system("ln -s ../sshd $rootimg_dir/etc/init.d/rc3.d/S20sshd");
- }
- my $rc = system("grep gettyset $rootimg_dir/etc/init.d/.depend.start | grep TARGETS");
- if ($rc) {
- system("sed -i '" . 's/^\(TARGETS = .*\)$/\1 gettyset/' . "' $rootimg_dir/etc/init.d/.depend.start");
- system("ln -s ../gettyset $rootimg_dir/etc/init.d/rc3.d/S60gettyset");
- }
- }
-}
-
-
-my $driver_name;
-my $real_path;
-
-sub get_path ()
-{
- if ($File::Find::name =~ /\/$driver_name/) {
- $real_path = $File::Find::name;
- }
-}
-
-my @all_real_path;
-
-sub get_all_path ()
-{
- if ($File::Find::name =~ /\/$driver_name/) {
- push @all_real_path, $File::Find::name;
- }
-}
-
-# Load driver disk and driver rpm to the initrd
-# Get the driver disk or driver rpm from the osimage.driverupdatesrc
-# The valid value: dud:/install/dud/dd.img,rpm:/install/rpm/d.rpm, if missing the tag: 'dud'/'rpm'
-# the 'rpm' is default.
-#
-# If cannot find the driver disk from osimage.driverupdatesrc, will try to search driver disk
-# from /install/driverdisk//
-#
-# For driver rpm, the driver list will be gotten from osimage.netdrivers. If not set, copy all the drivers from driver
-# rpm to the initrd.
-#
-# Return the driver names by loading order
-
-sub load_dd()
-{
- my @dd_list;
- my @rpm_list;
- my @driver_list;
-
- my $Injectalldriver;
- my @rpm_drivers;
-
- # Parse the parameters to the the source of Driver update disk and Driver rpm, and driver list as well
- if ($driverupdatesrc) {
- my @srcs = split(',', $driverupdatesrc);
- foreach my $src (@srcs) {
- if ($src =~ /dud:(.*)/i) {
- push @dd_list, $1;
- } elsif ($src =~ /rpm:(.*)/i) {
- push @rpm_list, $1;
- } else {
- push @rpm_list, $src;
- }
- }
- }
- if (!@dd_list) {
-
- # get Driver update disk from the default path if not specified in osimage
- # check the Driver Update Disk images, it can be .img or .iso
- if (-d "$installroot/driverdisk/$osver/$arch") {
- @dd_list = `find $installroot/driverdisk/$osver/$arch -type f`;
- }
- }
-
- foreach (split /,/, $netdriver) {
- if (/^allupdate$/) {
- $Injectalldriver = 1;
- next;
- }
- unless (/\.ko$/) {
- s/$/.ko/;
- }
- push @driver_list, $_;
- }
-
- chomp(@dd_list);
- chomp(@rpm_list);
-
- unless (@dd_list || (@rpm_list && ($Injectalldriver || @driver_list))) {
- return ();
- }
-
- # Create the work space, it should be cleaned at end of genimage
- my $dd_dir = mkdtemp("/tmp/ddtmpXXXXXXX");
- mkpath "$dd_dir/mnt";
- mkpath "$dd_dir/mods";
-
- my @dd_drivers = (); #driver names
-
- # Load drivers from each Driver Disk
- # For multiple dd, if want to make it has order, rename the dd with a number
- # ahead of the name like 0_xx, 1_xx
- foreach my $dd (sort(@dd_list)) {
- my $rc = system("mount -o loop $dd $dd_dir/mnt");
- if ($rc) {
- print "mount the Driver Disk $dd failed.\n";
- next;
- }
-
- mkpath "$dd_dir/full";
-
- # Copy out the drivers
- opendir(DIR, "$dd_dir/mnt") || die "Cannot open dir $dd_dir/mnt";
- while (my $dir = readdir(DIR)) {
- if ($dir =~ /^\./) { next; }
-
- # Every driver update disk can have multiple directories, each directory
- # has the directory format like /linux/[distribution]/[architechture]-[version]/
- # If the directory name is numeric, then it will be used as order to load the
- # the dirviers inside.
- # For the directory name which is not numeric, copy them to directory 0. It will be
- # loaled first.
- if ($dir !~ /^\d*$/) {
- mkpath "$dd_dir/full/0";
- system("cp -rf $dd_dir/mnt/$dir $dd_dir/full/0");
- } else {
- system("cp -rf $dd_dir/mnt/$dir $dd_dir/full/");
- }
- }
- closedir(DIR);
-
- # Get all the kernel modules base on the order of directory name.
-
- # The structure of dd: /linux/[distribution]/[architechture]-[version]/
-
- # The supported arch: i386, ia64, ppc, ppc64, s390, s390x sparc or x86_64.
- my $darch = $arch;
- if ($darch =~ /^x86$/) {
- $darch = "i386";
- }
-
- # If the version is os version. If the os is "sles11.1", the possible os version
- # could be "sles11.1", "11.1", "11", "sles11"
- my @distro = ($osver);
- my $distro1 = $osver;
- $distro1 =~ s/[^\d]*//;
- push @distro, $distro1;
- my $distro2 = $distro1;
- $distro2 =~ s/\..*//;
- push @distro, $distro2;
- my $distro3 = $osver;
- $distro3 =~ s/\..*//;
- push @distro, $distro3;
-
- opendir(FDIR, "$dd_dir/full") || die "Cannot open dir $dd_dir/full";
- my @fulldir = readdir(FDIR);
- closedir(FDIR);
-
- # Create the directory for drivers from driver disk
- if (!-d "$rootimg_dir/lib/modules/$kernelver/kernel/drivers/driverdisk") {
- mkpath "$rootimg_dir/lib/modules/$kernelver/kernel/drivers/driverdisk";
- }
-
- # Copy the drivers to the root image and get the driver loading order
- foreach my $dir (sort(@fulldir)) {
- if ($dir =~ /^\./) { next; }
- my $vdir;
- foreach (@distro) {
- if (-d "$dd_dir/full/$dir/linux/suse/$darch-$_") {
- $vdir = "$dd_dir/full/$dir/linux/suse/$darch-$_";
- }
- }
- if (!$vdir) { next; }
-
- # Use the module_order if it has
- if (-f "$vdir/modules/module.order") {
- open(ORDER, "<", "$vdir/modules/module.order");
- while (my $file = ) {
- chomp($file);
- if (-f "$vdir/modules/$file") {
- $driver_name = $file;
- $real_path = "";
- find(\&get_path, <$rootimg_dir/lib/modules/$kernelver/*>);
- if ($real_path eq "") {
- system("cp $vdir/modules/$file $rootimg_dir/lib/modules/$kernelver/kernel/drivers/driverdisk");
- } else {
- system("cp $vdir/modules/$file $real_path");
- }
-
- push @dd_drivers, $file;
- }
- }
- } else {
- opendir(MDIR, "$vdir/modules") || die "Cannot open dir $vdir/modules";
- while (my $file = readdir(MDIR)) {
- if (-f "$vdir/modules/$file" && $file =~ /\.ko/) {
- $driver_name = $file;
- $real_path = "";
- find(\&get_path, <$rootimg_dir/lib/modules/$kernelver/*>);
- if ($real_path eq "") {
- system("cp $vdir/modules/$file $rootimg_dir/lib/modules/$kernelver/kernel/drivers/driverdisk");
- } else {
- system("cp $vdir/modules/$file $real_path");
- }
-
- push @dd_drivers, $file;
- }
- }
- }
- }
-
- rmtree "$dd_dir/full";
-
- my $rc = system("umount -f $dd_dir/mnt");
- if ($rc) {
- print "umount the directory $dd_dir/mnt failed\n";
- exit 1;
- }
- }
-
- # Loading the drivers from rpm packages
- if (@rpm_list && ($Injectalldriver || @driver_list)) {
-
- # Extract the files from rpm to the tmp dir
- mkpath "$dd_dir/rpm";
- foreach my $rpm (@rpm_list) {
- if (-r $rpm) {
- if (system("cd $dd_dir/rpm; rpm2cpio $rpm | cpio -idum")) {
- print "Error: Cannot extract the files from the rpm $rpm.\n";
- }
- } else {
- print "Error: Cannot read the rpm $rpm.\n";
- }
- }
-
- # To skip the conflict of files that some rpm uses the xxx.ko.new as the name of the driver
- # Change it back to xxx.ko here
- $driver_name = "\*ko.new";
- @all_real_path = ();
- find(\&get_all_path, <$dd_dir/rpm/*>);
- foreach my $file (@all_real_path) {
- my $newname = $file;
- $newname =~ s/\.new$//;
- if (system("mv -f $file $newname")) {
- print "Error: Could not rename $file\n";
-
- }
- }
-
- # Copy the firmware to the rootimage
- if (-d "$dd_dir/rpm/lib/firmware") {
- system("cp -rf $dd_dir/rpm/lib/firmware $rootimg_dir/lib");
- }
-
- # if $ignorekernelchk is specified, copy all driver files to target kernel dir
- if ($ignorekernelchk) {
- my @kernelpath4vrpm = <$dd_dir/rpm/lib/modules/*>;
- foreach my $path (@kernelpath4vrpm) {
- if ($path eq "$dd_dir/rpm/lib/modules/$kernelver") {
- next;
- }
-
- unless (-d "$dd_dir/rpm/lib/modules/$kernelver") {
- mkpath "$dd_dir/rpm/lib/modules/$kernelver";
- }
- system("/bin/cp -rf $path/* $dd_dir/rpm/lib/modules/$kernelver");
- }
- }
-
- # Copy the drivers to the rootimage
- if (-d "$dd_dir/rpm/lib/modules/$kernelver") {
-
- #mkpath "$rootimg_dir/lib/modules/$kernelver/updates/";
- if (@driver_list) {
- foreach my $driver (@driver_list) {
- $driver_name = $driver;
- $real_path = "";
- find(\&get_path, <$dd_dir/rpm/lib/modules/$kernelver/*>);
- if ($real_path && $real_path =~ m!$dd_dir/rpm(/lib/modules/$kernelver/.*?)[^\/]*$!) {
-
- # remove the old one if existing
- @all_real_path = ();
- find(\&get_all_path, <$rootimg_dir/lib/modules/$kernelver/*>);
- foreach (@all_real_path) {
- if (-r $_) {
- unlink($_);
- }
- }
-
- if (!-d "$rootimg_dir$1") {
- mkpath "$rootimg_dir$1";
- }
- system("cp -rf $real_path $rootimg_dir$1");
- push @rpm_drivers, $driver;
- } else {
- print "Warning: cannot find the driver $driver from the driver rpms\n";
- }
- }
- } elsif ($Injectalldriver) {
-
- # copy all the drviers to the rootimage
- $driver_name = "\*\.ko";
- @all_real_path = ();
- find(\&get_all_path, <$dd_dir/rpm/lib/modules/$kernelver/*>);
- my @all_drivers = @all_real_path;
- foreach my $new_driver (@all_drivers) {
- if (basename($new_driver) =~ /\.ko$/) {
-
- # remove the old one if existing
- $driver_name = basename($new_driver);
- @all_real_path = ();
- find(\&get_all_path, <$rootimg_dir/lib/modules/$kernelver/*>);
- foreach my $old_driver (@all_real_path) {
- if (-r $old_driver) {
- unlink($old_driver);
- }
- }
- push @rpm_drivers, basename($new_driver);
- }
- }
-
- system("cp -rf $dd_dir/rpm/lib/modules/$kernelver $rootimg_dir/lib/modules/");
- }
- } else {
- print "Warning: cannot find the kernel $kernelver from drvier rpms\n";
- }
-
- push @dd_drivers, @rpm_drivers;
- }
-
- # Generate the dependency relationship
- system("chroot '$rootimg_dir' depmod $kernelver");
-
- # Clean the env
- rmtree "$dd_dir";
-
- return @dd_drivers;
-}
-
-sub usage {
- print 'Usage: genimage -o [-a ] -p -i -n [-r ] [-k ] [-g ] [-l rootlimitsize] [--permission ] [--interactive]' . "\n";
- print " --permission is used for statelite only\n";
- print "Examples:\n";
- print " genimage -i eth0 -n tg3 -o sles11 -p compute\n";
- print " genimage -i eth0 -r eth1,eth2 -n tg3,bnx2 -o sles11 -p compute --interactive\n";
- print " genimage -i eth0 -n tg3,bnx2 -o sles11 -p compute\n";
- print " genimage -i eth0 -n tg3,bnx2 -o sles11 -p compute --permission 777\n";
- return 0;
-}
-
diff --git a/xCAT-server/share/xcat/netboot/sle/geninitrd b/xCAT-server/share/xcat/netboot/sle/geninitrd
deleted file mode 100755
index baf3746f6..000000000
--- a/xCAT-server/share/xcat/netboot/sle/geninitrd
+++ /dev/null
@@ -1,2437 +0,0 @@
-#!/usr/bin/env perl
-BEGIN
-{
- $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat';
-}
-use lib "$::XCATROOT/lib/perl";
-
-use File::Basename;
-use File::Path;
-use File::Copy qw/copy cp mv move/;
-use File::Find;
-use Getopt::Long;
-use Cwd qw(realpath);
-use File::Temp qw/mkdtemp/;
-
-use FindBin;
-use lib "$FindBin::Bin/../imgutils";
-use imgutils;
-
-#use strict;
-Getopt::Long::Configure("bundling");
-Getopt::Long::Configure("pass_through");
-
-my $dracutmode; #Indicate whether this is a dracut style initrd
-my $dracutdir = "dracut"; # The default directory name of dracut
-my $dracutver;
-my $prinic; #TODO be flexible on node primary nic
-my $othernics; #TODO be flexible on node primary nic
-my $netdriver;
-my @yumdirs;
-my $arch;
-my %libhash;
-my @filestoadd;
-my $profile;
-my $osver;
-my $pathtofiles = dirname($0);
-my $fullpath = realpath($pathtofiles);
-my $name = basename($0);
-my $onlyinitrd = 0;
-
-#that this method of calling genimage is no longer used
-if ($name =~ /geninitrd/) {
- $onlyinitrd = 1;
-}
-my $rootlimit;
-my $tmplimit;
-my $installroot = "/install";
-my $kerneldir;
-my $kernelver = "";
-my $basekernelver;
-my $customdir = $fullpath;
-$customdir =~ s/.*share\/xcat/$installroot\/custom/;
-my $imagename;
-my $pkglist;
-my $srcdir;
-my $destdir;
-my $srcdir_otherpkgs;
-my $otherpkglist;
-my $postinstall_filename;
-my $rootimg_dir;
-my $mode;
-my $permission; #the permission works only for statelite mode currently
-my $krpmver;
-my $tempfile;
-my $prompt;
-my $timezone; #the TIMEZONE of the stateless and statelite node
-my $ignorekernelchk;
-my $noupdate;
-
-sub xdie {
- system("rm -rf /tmp/xcatinitrd.$$");
- die @_;
-}
-
-#-- fetch current version form CVS (overwrite locally changed versions)
-# if (opendir(CVS,"$pathtofiles/CVS")){
-# close CVS;
-# my $cvsout = qx/cd $pathtofiles; cvs update -C 2>&1/;
-# chomp $cvsout;
-# if ( $cvsout ne "cvs update: Updating ." ) {
-# print "Difference of local copy from CVS detected\n";
-# print $cvsout,"\n";
-# print "Trying to re-run $name\n";
-# print("$pathtofiles/$name ",join(" ",@ARGV),"\n");
-# exec("$pathtofiles/$name",@ARGV);
-# }
-# }
-
-
-$SIG{INT} = $SIG{TERM} = sub { xdie "Interrupted" };
-GetOptions(
- 'a=s' => \$arch,
- 'p=s' => \$profile,
- 'o=s' => \$osver,
- 'n=s' => \$netdriver,
- 'i=s' => \$prinic,
- 'r=s' => \$othernics,
- 'l=s' => \$rootlimit,
- 't=s' => \$tmplimit,
- 'k=s' => \$kernelver,
- 'g=s' => \$krpmver,
- 'permission=s' => \$permission,
- 'kerneldir=s' => \$kerneldir,
- 'timezone=s' => \$timezone,
- 'tempfile=s' => \$tempfile, #internal flag
- 'pkglist=s' => \$pkglist, #internal flag
- 'srcdir=s' => \$srcdir, #internal flag
- 'otherpkgdir=s' => \$srcdir_otherpkgs, #internal flag
- 'otherpkglist=s' => \$otherpkglist, #internal flag
- 'postinstall=s' => \$postinstall_filename, #internal flag
- 'rootimgdir=s' => \$destdir, #internal flag
- 'driverupdatesrc=s' => \$driverupdatesrc, #internal flag
- 'interactive' => \$prompt,
- 'onlyinitrd' => \$onlyinitrd,
- 'ignorekernelchk' => \$ignorekernelchk,
- 'noupdate' => \$noupdate,
-);
-
-if (@ARGV > 0) {
- $imagename = $ARGV[0];
-}
-
-
-my %updates_os = (); # the hash for updating osimage table
-my %updates = (); # the hash for updating linuximage table
-
-
-$permission = "755" unless ($permission);
-$updates{'permission'} = $permission if ($tempfile);
-
-unless ($arch) {
- $arch = `uname -m`;
- chomp($arch);
- $arch = "x86" if ($arch =~ /i.86$/);
-}
-
-$srcdir = "$installroot/$osver/$arch" unless ($srcdir);
-$updates{'pkgdir'} = $srcdir if ($tempfile);
-
-#$srcdir = $srcdir . "/1";
-
-$srcdir_otherpkgs = "$installroot/post/otherpkgs/$osver/$arch" unless ($srcdir_otherpkgs);
-#$updates{'otherpkgdir'} = $srcdir_otherpkgs if ($tempfile);
-
-$destdir = "$installroot/netboot/$osver/$arch/$profile" unless ($destdir);
-$updates{'rootimgdir'} = $destdir if ($tempfile);
-
-$rootimg_dir = "$destdir/rootimg";
-
-if ($kernelver && (!$krpmver)) {
- print "The -g flag for the rpm version of kernel packages needs to be specified when kernel version has been specified.\n";
- exit 1;
-}
-$kerneldir = "$installroot/kernels" unless ($kerneldir); # the default directory for 3rd-party kernel is "$installroot/kernels";
-
-#$updates{'kerneldir'} = $kerneldir if ($tempfile);
-
-unless ($osver and $profile) {
- usage();
- exit 1;
-}
-my @ndrivers;
-
-if ($netdriver) {
- foreach (split /,/, $netdriver) {
- if (/^allupdate$/) {
- next;
- }
- unless (/\.ko$/) {
- s/$/.ko/;
- }
- next if (/^$/);
-
- # Do not include qeth module here
- # This module is included later on
- unless ($_ =~ m/qeth/i) {
- push @ndrivers, $_;
- }
- }
-
- if (($updates{'netdrivers'} ne $netdriver) and $tempfile) {
- $updates{'netdrivers'} = $netdriver;
- }
-}
-
-# Add the default driver list
-if ($arch eq 'x86' or $arch eq 'x86_64') {
- push @ndrivers, qw/tg3 bnx2 bnx2x e1000 e1000e virtio_net virtio_balloon igb mlx4_en be2net/;
-} elsif ($arch eq 'ppc64') {
- push @ndrivers, qw/tg3 e1000 e1000e igb ibmveth ehea be2net/;
-} elsif ($arch eq "s390x") {
- push @ndrivers, qw/qdio ccwgroup qeth qeth_l2 qeth_l3/;
-}
-
-foreach (@ndrivers) {
- unless (/\.ko$/) {
- s/$/.ko/;
- }
-}
-
-unless (grep /af_packet/, @ndrivers) {
- unshift(@ndrivers, "af_packet.ko");
-}
-
-my $osver_host;
-if (`grep VERSION /etc/os-release` =~ /VERSION = (\d+)/) {
- $osver_host = $1;
-} else {
- $osver_host = 11;
-}
-
-unless ($onlyinitrd) {
-
- # now, let's handle the extra packages
- unless ($imagename) {
- $otherpkglist = imgutils::get_profile_def_filename($osver, $profile, $arch, $customdir, "otherpkgs.pkglist");
- unless ($otherpkglist) { $otherpkglist = imgutils::get_profile_def_filename($osver, $profile, $arch, $pathtofiles, "otherpkgs.pkglist"); }
- $updates{'otherpkglist'} = $otherpkglist if ($tempfile and $otherpkglist);
- }
- my %extra_hash = ();
- %extra_hash = imgutils::get_package_names($otherpkglist) if ($otherpkglist);
-
-
- # prepare the chroot environment for the root image
-
- mkpath "$rootimg_dir/etc";
- mkpath "$rootimg_dir/dev";
-
- #system "mount -o bind /dev $rootimg_dir/dev";
- unless (-e "$rootimg_dir/dev/zero") {
- system "mknod $rootimg_dir/dev/zero c 1 5";
- }
- unless (-e "$rootimg_dir/dev/null") {
- system "mknod $rootimg_dir/dev/null c 1 3"; #that's neccessary for SLES11
- }
-
- unless (-e "$rootimg_dir/dev/random") {
- system "mknod $rootimg_dir/dev/random c 1 8"; #that's neccessary for SLES11
- }
- unless (-e "$rootimg_dir/dev/urandom") {
- system "mknod $rootimg_dir/dev/urandom c 1 9"; #that's neccessary for SLES11
- }
-
- for (my $i = 0 ; $i <= 12 ; $i++)
- {
- unless (-e "$rootimg_dir/dev/tty$i") {
- system "mknod $rootimg_dir/dev/tty$i c 4 $i"; #that's neccessary for SLES11
- }
- }
-
- open($fd, ">>", "$rootimg_dir/etc/fstab"); # TODO: is it necessary?
- print $fd "#Dummy fstab for rpm postscripts to see\n";
- close($fd);
-
- my $non_interactive;
- if (!$prompt) { $non_interactive = "--non-interactive --no-gpg-checks --gpg-auto-import-keys"; }
-
- if ($osver_host >= 11) { #zypper in SLES11 is different
-
- system("rm -rf $rootimg_dir/etc/zypp/repos.d/$osver-*.repo");
- my @pkgdirs = split(",", $srcdir);
- my $dir;
- my $i = 0;
-
- # To support multiple paths for osimage.pkgdir
- foreach $dir (@pkgdirs) {
- my $ddir = $dir;
- if (-d "$dir/1") {
- $ddir .= "/1";
- }
- system("zypper -R $rootimg_dir $non_interactive ar file:$ddir $osver-$i");
- $i++;
- if (-d "$dir/2") {
- $ddir = $dir . "/2";
- system("zypper -R $rootimg_dir $non_interactive ar file:$ddir $osver-$i");
- $i++;
- }
- }
-
- #if(-e "$rootimg_dir/etc/zypp/repos.d/$osver.repo") {
- # system("rm -rf $rootimg_dir/etc/zypp/repos.d/$osver.repo");
- #}
- #system("zypper -R $rootimg_dir $non_interactive ar file:$srcdir $osver");
- #if(-e "$rootimg_dir/etc/zypp/repos.d/${osver}sdk.repo") {
- # system("rm -rf $rootimg_dir/etc/zypp/repos.d/${osver}sdk.repo");
- #}
- if (opendir(SRCDIR, "$installroot/$osver/$arch/")) {
- while (my $tmpfile = readdir(SRCDIR)) {
- if ($tmpfile =~ m/^sdk/) {
- my $srcdir_sdk = "$installroot/$osver/$arch/${tmpfile}";
- if (-d "$srcdir_sdk") {
- system("zypper -R $rootimg_dir $non_interactive ar file:$srcdir_sdk ${osver}${tmpfile}");
- }
- }
- }
- }
- } else {
- $srcdir = $srcdir . "/1";
- system("zypper -R $rootimg_dir $non_interactive sa file:$srcdir");
- }
-
- # Add the rep for kernel packages
- if ($kernelver) {
- if (!-d $kerneldir) {
- print "Cannot find the directory for the kernel at $kerneldir.\n";
- exit 1;
- }
- if ($osver_host >= 11) {
- if (-e "$rootimg_dir/etc/zypp/repos.d/$kernelver.repo") {
- system("rm -rf $rootimg_dir/etc/zypp/repos.d/$kernelver.repo");
- }
- system("zypper -R $rootimg_dir $non_interactive ar file:$kerneldir $kernelver");
- } else {
- system("zypper -R $rootimg_dir $non_interactive sa file:$kerneldir");
- }
- }
-
- #remove the old repository for extra packages
- if ($osver_host >= 11) {
- my $result = `zypper -R $rootimg_dir $non_interactive lr |grep otherpkg|cut -f2 -d '|'|tr "\n" " "`;
- if ($result =~ /\S/) {
- system("zypper -R $rootimg_dir $non_interactive rr $result");
- }
- } else {
- my $result = `zypper -R $rootimg_dir $non_interactive sl |grep otherpkg|cut -f2 -d '|'|tr "\n" " "`;
- if ($result =~ /\S/) {
- system("zypper -R $rootimg_dir $non_interactive sd $result");
- }
- }
-
- #add the new repository for extra packages
- my %extrapkgnames;
- if ($osver_host >= 11) { #SLES11
- if (-e "$rootimg_dir/etc/zypp/repos.d/otherpkg.repo") {
- system("rm -rf $rootimg_dir/etc/zypp/repos.d/otherpkg.repo");
- }
- }
- my $index = 1;
- my $pass;
- foreach $pass (sort { $a <=> $b } (keys(%extra_hash))) {
- foreach (keys(%{ $extra_hash{$pass} })) {
-
- if ($_ eq "INCLUDEBAD") {
- print "Unable to open the following pkglist files:\n" . join("\n", @{ $extra_hash{$pass}{INCLUDEBAD} });
- exit 1;
- }
-
- if (($_ eq "PRE_REMOVE") || ($_ eq "POST_REMOVE") || ($_ eq "ENVLIST")) { next; }
- my $whole_path = "$srcdir_otherpkgs/$_";
- if (-r "$srcdir_otherpkgs/$_/repodata/repomd.xml") {
- if ($osver_host >= 11) {
- system("zypper -R $rootimg_dir $non_interactive ar file:$srcdir_otherpkgs/$_ otherpkg$index");
- } else {
- system("zypper -R $rootimg_dir $non_interactive sa file:$srcdir_otherpkgs/$_");
- }
- } else {
- if ($osver_host >= 11) {
- system("zypper -R $rootimg_dir $non_interactive ar -t Plaindir file:$srcdir_otherpkgs/$_ otherpkg$index");
- } else {
- system("zypper -R $rootimg_dir $non_interactive sa -t Plaindir file:$srcdir_otherpkgs/$_");
- }
- }
- $index++;
-
- my $pa = $extra_hash{$pass}{$_};
- $extrapkgnames{$pass} .= " " . join(' ', @$pa);
- }
- }
-
- #-- add custom repositories to the image
- #TODO: should we add the support to otherpkgs for this? we have too many list files and it seems only SLES supports this
- # not sure, but it is convenient
- my $repolist;
- $repolist = imgutils::get_profile_def_filename($osver, $profile, $arch, $customdir, "repolist");
- unless ($repolist) {
- $repolist = imgutils::get_profile_def_filename($osver, $profile, $arch, $pathtofiles, "repolist");
- }
-
- if (-r "$repolist") {
- print "Reading custom repositories\n";
- open($repoconfig, "<", "$repolist");
- while (<$repoconfig>) {
- chomp;
- next if /^\s*#/;
- my ($repotype, $repourl, $repoalias) = split m/\|/;
- if ($osver_host >= 11) {
- system("zypper -R $rootimg_dir $non_interactive ar $repourl $repoalias");
- } else {
- system("zypper -R $rootimg_dir $non_interactive sa $repourl $repoalias");
- }
- }
- }
-
- # Refresh the zypper cache in case there is still old data out there
- system("zypper -R $rootimg_dir $non_interactive refresh");
-
- #my $yumcmd = "yum -y -c /tmp/genimage.$$.yum.conf --installroot=$rootimg_dir --disablerepo=* ";
- #$yumcmd .= "install ";
- #mkpath("$rootimg_dir/var/lib/yum");
- mkpath("$rootimg_dir/etc/");
- my $passwdfile;
- open($passwdfile, ">", "$rootimg_dir/etc/passwd");
- print $passwdfile "root:x:0:0:root:/root:/bin/bash\n";
- my $yumcmd;
- if ($osver_host < 11) {
- $yumcmd = "zypper -R $rootimg_dir $non_interactive install ";
- } else {
- $yumcmd = "zypper -R $rootimg_dir $non_interactive install -l --no-recommends "; #add -l for SLES11
- }
-
- #install packages from pkglist file
- my $pkgnames;
- unless ($imagename) {
- $pkglist = imgutils::get_profile_def_filename($osver, $profile, $arch, $customdir, "pkglist");
- unless ($pkglist) { $pkglist = imgutils::get_profile_def_filename($osver, $profile, $arch, $pathtofiles, "pkglist"); }
- }
-
- if ($pkglist) {
- $updates{'pkglist'} = $pkglist if ($tempfile);
- } else {
- print "Unable to find package list for $profile!";
- exit 1;
- }
-
- my %pkg_hash = imgutils::get_package_names($pkglist);
- my $index = 1;
- foreach $pass (sort { $a <=> $b } (keys(%pkg_hash))) {
- $pkgnames = "";
- $group_pkgnames = "";
- foreach (keys(%{ $pkg_hash{$pass} })) {
-
- if ($_ eq "INCLUDEBAD") {
- print "Unable to open the following pkglist files:\n" . join("\n", @{ $pkg_hash{$pass}{INCLUDEBAD} });
- exit 1;
- }
-
- if (($_ eq "PRE_REMOVE") || ($_ eq "POST_REMOVE") || ($_ eq "ENVLIST")) { next; }
- my $pa = $pkg_hash{$pass}{$_};
-
- # replace the kernel package with the name has the specific version
- my @npa = ();
- my @npa_group = ();
- foreach my $p (@$pa) {
- if ($p =~ /^kernel/ && $kernelver) {
-
- # get all files in $srcdir and $kerneldir
- my @alldirs = ("$srcdir", "$kerneldir");
- my @allrpms = ();
- foreach my $dir (@alldirs) {
- my @files = `find $dir -name *.rpm`;
- push @allrpms, @files;
- }
- my @kernelpkgs = ();
- if ($p =~ /^kernel$/) {
- @kernelpkgs = ("kernel-default", "kernel-default-base");
- } elsif ($p =~ /^kernel-ppc64$/) {
- @kernelpkgs = ($p, $p . "-base");
- } else {
- @kernelpkgs = ($p);
- }
- foreach my $kern (@kernelpkgs) {
- my @rpm = grep /$kern-$krpmver/, @allrpms;
- if (!@rpm) {
- print "Cannot find the kernel package with the versioin $krpmver.\n";
- exit 1;
- }
- my $kernelname = "$kern-" . $krpmver;
- push @npa, $kernelname;
- }
- } else {
- if ($p =~ s/^@//)
- {
- push @npa_group, $p;
- }
- else
- {
- push @npa, $p;
- }
- }
- }
- if (@npa) {
- $pkgnames .= " " . join(' ', @npa);
- }
- if (@npa_group) {
- $group_pkgnames .= " " . join(' ', @npa_group);
- }
- }
- my $envlist;
- if (exists $pkg_hash{$pass}{ENVLIST}) {
- $envlist = join(' ', @{ $pkg_hash{$pass}{ENVLIST} });
- }
- if ($pkgnames)
- {
- print "$envlist $yumcmd $pkgnames\n";
- $rc = system("$envlist $yumcmd $pkgnames");
- $rc = $rc >> 8;
- if (($rc) && ($rc != '104')) {
- print "zypper invocation failed with rc: $rc\n";
- exit 1;
- }
- }
- if ($group_pkgnames)
- {
- print "$envlist $yumcmd -t pattern $group_pkgnames\n";
- $rc = system("$envlist $yumcmd -t pattern $group_pkgnames");
- $rc = $rc >> 8;
- if (($rc) && ($rc != '104')) {
- print "zypper invocation failed with rc: $rc\n";
- exit 1;
- }
- }
- }
-
- foreach $pass (sort { $a <=> $b } (keys(%extra_hash))) {
-
- my $index = 1;
-
- #remove the old repository for extra packages
- if ($osver_host >= 11) {
- my $result = `zypper -R $rootimg_dir $non_interactive lr |grep otherpkg|cut -f2 -d '|'|tr "\n" " "`;
- if ($result =~ /\S/) {
- system("zypper -R $rootimg_dir $non_interactive rr $result");
- }
- } else {
- my $result = `zypper -R $rootimg_dir $non_interactive sl |grep otherpkg|cut -f2 -d '|'|tr "\n" " "`;
- if ($result =~ /\S/) {
- system("zypper -R $rootimg_dir $non_interactive sd $result");
- }
- }
-
- foreach (keys(%{ $extra_hash{$pass} })) {
- if (($_ eq "PRE_REMOVE") || ($_ eq "POST_REMOVE") || ($_ eq "ENVLIST")) { next; }
- if (-r "$srcdir_otherpkgs/$_/repodata/repomd.xml") {
- if ($osver_host >= 11) {
- system("zypper -R $rootimg_dir $non_interactive ar file:$srcdir_otherpkgs/$_ otherpkg$index");
- } else {
- system("zypper -R $rootimg_dir $non_interactive sa file:$srcdir_otherpkgs/$_");
- }
- } else {
- if ($osver_host >= 11) {
- system("zypper -R $rootimg_dir $non_interactive ar -t Plaindir file:$srcdir_otherpkgs/$_ otherpkg$index");
- } else {
- system("zypper -R $rootimg_dir $non_interactive sa -t Plaindir file:$srcdir_otherpkgs/$_");
- }
- }
- $index++;
- }
-
- # Refresh the zypper cache in case there is still old data out there
- system("zypper -R $rootimg_dir $non_interactive refresh");
-
- #remove the packages that are specified in the otherpkgs.list files with leading '-'
- my $envlist;
- if (exists $extra_hash{$pass}{ENVLIST}) {
- $envlist = join(' ', @{ $extra_hash{$pass}{ENVLIST} });
- }
-
- my $yumcmd_remove = "zypper -R $rootimg_dir $non_interactive remove ";
- if (exists($extra_hash{$pass}{'PRE_REMOVE'})) {
- my $pa = $extra_hash{$pass}{'PRE_REMOVE'};
- my $rm_packges = join(' ', @$pa);
- if ($rm_packges) {
- print "$envlist $yumcmd_remove $rm_packges";
- $rc = system("$envlist $yumcmd_remove $rm_packges");
- }
- }
-
-
- #add extra packages in the list
- if ($extrapkgnames{$pass}) {
- print "$envlist $yumcmd $extrapkgnames{$pass}\n";
- $rc = system("$envlist $yumcmd $extrapkgnames{$pass}");
- $rc = $rc >> 8;
- if (($rc) && ($rc != '104')) {
- print "zypper invocation failed with rc: $rc\n";
- exit 1;
- }
- }
-
- #remove the packages that are specified in the otherpkgs.list files with leading '--'
- if (exists($extra_hash{$pass}{'POST_REMOVE'})) {
- my $pa = $extra_hash{$pass}{'POST_REMOVE'};
- my $rm_packges = join(' ', @$pa);
- if ($rm_packges) {
- print "$envlist $yumcmd_remove $rm_packges";
- $rc = system("$envlist $yumcmd_remove $rm_packges");
- }
- }
-
- if (!$noupdate) {
-
- # run zypper update to update any installed rpms
- # needed when running genimage again after updating software in repositories
- my $yumcmd_update;
- if ($osver_host >= 11) {
- $yumcmd_update = "zypper -R $rootimg_dir $non_interactive update ";
- } else {
- $yumcmd_update = "zypper -R $rootimg_dir $non_interactive update ";
- }
- $rc = system("$yumcmd_update");
- }
- }
-
- #remove the old repository for extra packages
- if ($osver_host >= 11) {
- my $result = `zypper -R $rootimg_dir $non_interactive lr |grep otherpkg|cut -f2 -d '|'|tr "\n" " "`;
- if ($result =~ /\S/) {
- system("zypper -R $rootimg_dir $non_interactive rr $result");
- }
- } else {
- my $result = `zypper -R $rootimg_dir $non_interactive sl |grep otherpkg|cut -f2 -d '|'|tr "\n" " "`;
- if ($result =~ /\S/) {
- system("zypper -R $rootimg_dir $non_interactive sd $result");
- }
- }
-
- # ignore any return code
-
- postscripts(); #run 'postscripts'
-}
-unlink "/tmp/genimage.$$.yum.conf";
-
-# added dracut mode
-if ((-d "$rootimg_dir/usr/share/dracut") or (-d "$rootimg_dir/usr/lib/dracut")) {
- $dracutmode = 1;
-
- # get dracut version
- $dracutver = `chroot $rootimg_dir rpm -qi dracut | awk '/Version/{print \$3}' | awk -F. '{print \$1}'`;
- chomp($dracutver);
- if ($dracutver =~ /^\d\d\d$/) {
- if ($dracutver >= "033") {
- $dracutdir = "dracut_033";
- } else {
- $dracutdir = "dracut"; # The default directory
- }
- }
- print "Enter the dracut mode. Dracut version: $dracutver. Dracut directory: $dracutdir.\n";
-}
-
-# default to the first kernel found in the install image if nothing specified explicitly.
-# A more accurate guess than whatever the image build server happens to be running
-# If specified, that takes precedence.
-# If image has one, that is used
-# If all else fails, resort to uname -r like this script did before
-
-if (-e "$rootimg_dir/boot/vmlinux") {
- $basekernelver = basename(readlink "$rootimg_dir/boot/vmlinux");
- if ($basekernelver eq "vmlinux") {
- $basekernelver = "";
- } else {
- $basekernelver =~ s/vmlinu.-//;
- $basekernelver =~ s/image-//;
- }
-}
-
-unless ($basekernelver) {
- my @KVERS = <$rootimg_dir/boot/vmlinu[xz]-*>;
-
- # The kernel name is different on s390x, e.g. image-2.6.32.9-0.5-default
- @KVERS = <$rootimg_dir/boot/image-*> if $arch eq "s390x";
- foreach (@KVERS) {
- s/vmlinu.-//;
- s/image-//;
- }
- unless (scalar @KVERS) {
- @KVERS = <$rootimg_dir/lib/modules/*>;
- }
- if (scalar @KVERS) {
- foreach my $kver (@KVERS) {
- unless ($kver =~ m/.gz$/) {
- $basekernelver = basename($kver);
- last;
- }
- }
- }
-
- @KVERS = <$rootimg_dir/lib/modules/*> unless (scalar @KVERS);
- $basekernelver = basename(pop @KVERS) if (scalar @KVERS);
- $basekernelver = `uname -r` unless ($basekernelver);
-}
-
-$kernelver = $basekernelver unless ($kernelver);
-chomp $kernelver;
-
-#$updates{kernelver} = $kernelver if ($tempfile);
-
-# copy the kernel to $destdir
-if (-e "$rootimg_dir/boot/vmlinux-$kernelver") {
- copy("$rootimg_dir/boot/vmlinux-$kernelver", "$destdir/kernel");
-} elsif (-e "$rootimg_dir/boot/vmlinuz-$kernelver") {
- copy("$rootimg_dir/boot/vmlinuz-$kernelver", "$destdir/kernel");
-} elsif (-e "$rootimg_dir/boot/image-$kernelver") {
- copy("$rootimg_dir/boot/image-$kernelver", "$destdir/kernel");
-} else {
- xdie "couldn't find the kernel file matched $kernelver in $rootimg_dir/boot !";
-}
-
-#-- run postinstall script
-unless ($imagename) {
- $postinstall_filename = imgutils::get_profile_def_filename($osver, $profile, $arch, $customdir, "postinstall");
- unless ($postinstall_filename) {
- $postinstall_filename = imgutils::get_profile_def_filename($osver, $profile, $arch, $pathtofiles, "postinstall");
- }
-}
-
-if ($postinstall_filename) {
-
- #print "postinstall_filename=$postinstall_filename\n";
-
- #For Mellonax IB script. In diskless image, the uname -r not returning the rootimg level,
- #because the "uname -r" only returns the version of the kernel in use
- #create a temporary uname script. for every flag except for -r, it should just call the real
- #uname with the same flags and return that info.
- if (!(-e "$rootimg_dir/bin/orig_uname")) {
- system("mv $rootimg_dir/bin/uname $rootimg_dir/bin/orig_uname");
- }
- my $tmpuname;
- open($tmpuname, ">", "$rootimg_dir/bin/uname");
- print $tmpuname <>$tempfile");
- if ($imagename) {
- if (keys(%updates) > 0) {
- print FILE "The output for table updates starts here\n";
- print FILE "table::linuximage\n";
- print FILE "imagename::$imagename\n";
- my @a = %updates;
- print FILE join('::', @a) . "\n";
- print FILE "The output for table updates ends here\n";
- }
- } else {
- $updates_os{'profile'} = $profile;
- $updates_os{'imagetype'} = 'linux';
- $updates_os{'provmethod'} = 'netboot';
- $updates_os{'osname'} = 'Linux';
- $updates_os{'osvers'} = $osver;
- $updates_os{'osdistroname'} = 'sle'; # not used currently
- $updates_os{'osarch'} = $arch;
-
- # update the imagename for stateless
- print FILE "The output for table updates starts here\n";
- print FILE "table::osimage\n";
- print FILE "imagename::$osver-$arch-netboot-$profile\n";
- my @a = %updates_os;
- print FILE join('::', @a) . "\n";
- print FILE "The output for table updates ends here\n";
-
- print FILE "The output for table updates starts here\n";
- print FILE "table::linuximage\n";
- print FILE "imagename::$osver-$arch-netboot-$profile\n";
- my @a = %updates;
- print FILE join('::', @a) . "\n";
- print FILE "The output for table updates ends here\n";
-
- # update the imagename for statelite
- $updates_os{'provmethod'} = 'statelite';
- print FILE "The output for table updates starts here\n";
- print FILE "table::osimage\n";
- print FILE "imagename::$osver-$arch-statelite-$profile\n";
- my @a = %updates_os;
- print FILE join('::', @a) . "\n";
- print FILE "The output for table updates ends here\n";
-
- print FILE "The output for table updates starts here\n";
- print FILE "table::linuximage\n";
- print FILE "imagename::$osver-$arch-statelite-$profile\n";
- my @a = %updates;
- print FILE join('::', @a) . "\n";
- print FILE "The output for table updates ends here\n";
- }
- close FILE;
-}
-
-#END
-
-
-
-mkpath "$rootimg_dir/.statelite"; # create place for NFS mounts;
-mkpath "$rootimg_dir/.sllocal/localmnt"; # create place for localdisk mount
-mkpath "$rootimg_dir/.sllocal/log"; # create place for localdisk log
-
-mkpath "$rootimg_dir/root/.ssh"; # create place for NFS mounts for ssh; #TODO is necessary?
-
-# this script will get the directories;
-# TODO: it seems it is re-copied in liteimg.pm
-unless (-r "$pathtofiles/../add-on/statelite/rc.statelite") {
- print "Can't find $pathtofiles/../add-on/statelite/rc.statelite!\n";
- exit;
-}
-system("cp $pathtofiles/../add-on/statelite/rc.statelite $rootimg_dir/etc/init.d/statelite");
-system("cp $pathtofiles/../add-on/statelite/rc.localdisk $rootimg_dir/etc/init.d/localdisk");
-
-# added dracutmode
-unless ($dracutmode) { #in dracut mode, we delegate all this activity
- unless (-l "$rootimg_dir/var/lib/dhclient") {
- mkpath "$rootimg_dir/var/lib/dhclient/";
- system("touch $rootimg_dir/var/lib/dhclient/dhclient-$prinic.leases");
- }
-
- unless (-l "$rootimg_dir/var/lib/dhcp") {
- mkpath "$rootimg_dir/var/lib/dhcp/";
- system("touch $rootimg_dir/var/lib/dhcp/dhclient-$prinic.leases");
- }
-}
-
-
-# the dhcp client information stores in the directory "/var/lib/dhcpcd/"
-unless (-l "$rootimg_dir/var/lib/dhcpcd") {
- mkpath "$rootimg_dir/var/lib/dhcpcd/";
- system("touch $rootimg_dir/var/lib/dhcpcd/dhcpcd-$prinic.info");
-}
-
-#keyctl moved to /bin for newer release
-system("cd $rootimg_dir/usr/bin/; ln -s ../../bin/keyctl $rootimg_dir/usr/bin/keyctl");
-
-# which is different from the Redhat family
-
-# some rpms mounts the imageroot/proc on the /proc, need to release it,
-# otherwise got kernal panic when installing
-# sometimes, the proc fs is not mounted, so one warning/error message will display,
-# and I add one check point here.
-my $MFD;
-open MFD, "/proc/mounts";
-my @lines = ;
-close MFD;
-
-my $ret = grep m{$rootimg_dir/proc}, @lines;
-if ($ret > 0) {
- system("umount -l $rootimg_dir/proc");
-}
-
-# Load driver update disk, and copy them to the root image
-my @dd_drivers = &load_dd();
-
-# Push the drivers into the @ndrivers base on the order
-my @new_order = ();
-foreach my $dd (@dd_drivers) {
- unless (grep { $_ eq $dd } @ndrivers) {
- push @new_order, $dd;
- }
- print "Added driver $dd from driver update disk or driver rpm\n";
-}
-
-if (@new_order) {
- @ndrivers = (@new_order, @ndrivers);
-}
-
-# add drivers for local disk support
-push @ndrivers, ("ext3.ko", "ext4.ko", "virtio_pci.ko", "virtio_blk.ko", "libata.ko", "scsi_mod.ko", "scsi_dh.ko", "ahci.ko", "megaraid_sas.ko", "sd_mod.ko");
-
-if ($osver_host >= 12) {
- push @ndrivers, ("ibmvscsi.ko");
-} else { # for sles11 or lower
- push @ndrivers, ("ibmvscsic.ko", "ata_piix.ko", "pcieport.ko");
-}
-
-if (-f "$rootimg_dir/lib/modules/$kernelver/kernel/drivers/net/ethernet/mellanox/mlx4/mlx4_en.ko") {
- for (@ndrivers) {
- s/mlx_en/mlx4_en/;
- }
-}
-
-open($moddeps, "<", "$rootimg_dir/lib/modules/$kernelver/modules.dep");
-my @moddeps = <$moddeps>;
-my @checkdeps = @ndrivers;
-while (scalar @checkdeps) {
- my $driver = pop @checkdeps;
- my @lines = grep /\/$driver:/, @moddeps;
- foreach (@lines) {
- chomp;
- s/.*://;
- s/^\s*//;
- my @deps = split /\s+/, $_;
- if ($driver =~ /libcrc32c.ko/) {
- push @deps, 'crc32c.ko';
- }
- my $dep;
- foreach $dep (@deps) {
- $dep =~ s/.*\///;
- unless (grep { $_ eq $dep } @ndrivers) { #only add if not added
- print "Added $dep as an autodetected dependency\n";
- }
- unshift(@checkdeps, $dep); #recursively check dependencies
- unshift(@ndrivers, $dep);
- }
- }
-}
-close($moddeps);
-
-#remove the duplicated drivers
-my @fulldrivers;
-foreach my $dn (@ndrivers) {
- unless (grep { $_ eq $dn } @fulldrivers) {
- push @fulldrivers, $dn;
- }
-}
-@ndrivers = @fulldrivers;
-
-# before mkinitrd, run depmod to generate the modules.dep
-system("chroot $rootimg_dir depmod $kernelver");
-
-if ($dracutmode) {
- mkinitrd_dracut("stateless");
- mkinitrd_dracut("statelite");
-} else {
- my @drivers; # backup of @ndrivers
- push @drivers, @ndrivers;
- mkinitrd("statelite");
- @ndrivers = ();
- push @ndrivers, @drivers;
- mkinitrd("stateless");
-}
-print "It is safe to ignore message 'Failed to connect to bus: No such file or directory' that may have appeared above one or more times.\n";
-
-sub getlibs {
- my $file = shift;
- my $liblist = `chroot $rootimg_dir ldd $file`;
- if ($liblist =~ /not a dynamic executable/) {
- return;
- }
- my @libs = split /\n/, $liblist;
- my @return;
- foreach (@libs) {
- unless (/=>/) {
- (my $wjnk, my $lib, my $jnk) = split /\s+/, $_, 3;
- $lib =~ s/^\///;
- $libhash{$lib} = 1;
- next;
- }
- (my $temp1, my $temp2) = split />/, $_, 2;
- (my $whitespace, $temp1, $temp2) = split /\s+/, $temp2, 4;
- unless ($temp1 =~ /\//) {
- next;
- }
- $temp1 =~ s/^\///;
- $libhash{$temp1} = 1;
- }
-}
-
-#added dracut
-sub mkinitrd_dracut {
- my ($mode) = @_; # the mode is for statelite or stateless
-
- my $dracutmoduledir = "$rootimg_dir/usr/share/dracut/modules.d/";
- if ((!-d $dracutmoduledir) and (-d "$rootimg_dir/usr/lib/dracut/modules.d/"))
- {
- $dracutmoduledir = "$rootimg_dir/usr/lib/dracut/modules.d/";
- }
-
- if ($dracutver >= "033") {
-
- my $perm = (stat("$fullpath/$dracutdir/patch/syslog/module-setup.sh"))[2];
- cp("$fullpath/$dracutdir/patch/syslog/module-setup.sh", $dracutmoduledir . "98syslog/");
- chmod($perm & 07777, $dracutmoduledir . "98syslog/" . "module-setup.sh");
-
- $perm = (stat("$fullpath/$dracutdir/patch/syslog/rsyslogd-start.sh"))[2];
- cp("$fullpath/$dracutdir/patch/syslog/rsyslogd-start.sh", $dracutmoduledir . "98syslog/");
- chmod($perm & 07777, $dracutmoduledir . "98syslog/" . "rsyslogd-start.sh");
-
- $perm = (stat("$fullpath/$dracutdir/patch/syslog/syslog-genrules.sh"))[2];
- cp("$fullpath/$dracutdir/patch/syslog/syslog-genrules.sh", $dracutmoduledir . "98syslog/");
- chmod($perm & 07777, $dracutmoduledir . "98syslog/" . "syslog-genrules.sh");
-
- }
-
- my $dracutmpath = $dracutmoduledir . "97xcat/";
- mkpath($dracutmpath);
-
- my $perm = (stat("$fullpath/$dracutdir/check"))[2];
- cp("$fullpath/$dracutdir/check", $dracutmpath);
- chmod($perm & 07777, "$dracutmpath/check");
-
- foreach (@ndrivers) { s/\.ko$//; }
-
- # Add drivers to support local disk
- push @ndrivers, "ext3";
- push @ndrivers, "ext4";
-
- #remove the duplicated drivers
- my @fulldrivers;
- foreach my $dn (@ndrivers) {
- unless (grep { $_ eq $dn } @fulldrivers) {
- push @fulldrivers, $dn;
- }
- }
- @ndrivers = @fulldrivers;
-
- my $add_drivers = join(' ', @ndrivers);
- print "Try to load drivers: $add_drivers to initrd.\n";
- my $DRACUTCONF;
-
- if ($mode eq "statelite") {
-
- # for statelite
- cp("$fullpath/$dracutdir/install.statelite", "$dracutmpath/install");
- $perm = (stat("$fullpath/$dracutdir/install.statelite"))[2];
- chmod($perm & 07777, "$dracutmpath/install");
-
- cp("$installroot/postscripts/updateflag.awk", "$dracutmpath/xcat-updateflag");
- $perm = (stat("$installroot/postscripts/updateflag.awk"))[2];
- chmod($perm & 07777, "$dracutmpath/xcat-updateflag");
-
- cp("$fullpath/$dracutdir/xcat-prepivot.sh", $dracutmpath);
- $perm = (stat("$fullpath/$dracutdir/xcat-prepivot.sh"))[2];
- chmod($perm & 07777, "$dracutmpath/xcat-prepivot.sh");
-
- cp("$fullpath/$dracutdir/xcat-premount.sh", $dracutmpath);
- $perm = (stat("$fullpath/$dracutdir/xcat-premount.sh"))[2];
- chmod($perm & 07777, "$dracutmpath/xcat-premount.sh");
-
- #update etc/dracut.conf
- open($DRACUTCONF, '>', "$rootimg_dir/etc/dracut.conf");
- if (-d glob($dracutmoduledir . "[0-9]*fadump")) {
- print $DRACUTCONF qq{dracutmodules+="xcat nfs base network kernel-modules lvm fadump"\n};
- }
- else {
- print $DRACUTCONF qq{dracutmodules+="xcat nfs base network kernel-modules lvm"\n};
- }
- print $DRACUTCONF qq{add_drivers+="$add_drivers"\n};
- print $DRACUTCONF qq{filesystems+="nfs"\n};
- close $DRACUTCONF;
- } elsif ($mode eq "stateless") {
- cp("$fullpath/$dracutdir/install.netboot", "$dracutmpath/install");
- $perm = (stat("$fullpath/$dracutdir/install.netboot"))[2];
- chmod($perm & 07777, "$dracutmpath/install");
-
- cp("$fullpath/$dracutdir/xcat-cmdline.sh", "$dracutmpath/");
- $perm = (stat("$fullpath/$dracutdir/xcat-cmdline.sh"))[2];
- chmod($perm & 07777, "$dracutmpath/xcat-cmdline.sh");
-
- cp("$installroot/postscripts/updateflag.awk", "$dracutmpath/xcat-updateflag");
- $perm = (stat("$installroot/postscripts/updateflag.awk"))[2];
- chmod($perm & 07777, "$dracutmpath/xcat-updateflag");
- if ($prinic) {
- my $optspec;
- open($optspec, '>>', "$dracutmpath/xcat-cmdline.sh");
- print $optspec "PRINIC=$prinic\n";
- close $optspec;
- }
-
- cp("$fullpath/$dracutdir/xcatroot", "$dracutmpath/");
- $perm = (stat("$fullpath/$dracutdir/xcatroot"))[2];
- chmod($perm & 07777, "$dracutmpath/xcatroot");
-
- cp("$fullpath/$dracutdir/installkernel", "$dracutmpath/");
- $perm = (stat("$fullpath/$dracutdir/installkernel"))[2];
- chmod($perm & 07777, "$dracutmpath/installkernel");
-
- # update etc/dracut.conf
- open($DRACUTCONF, '>', "$rootimg_dir/etc/dracut.conf");
- if (-d glob($dracutmoduledir . "[0-9]*fadump")) {
- print $DRACUTCONF qq{dracutmodules+="xcat nfs base network kernel-modules lvm fadump syslog"\n};
- }
- else {
- print $DRACUTCONF qq{dracutmodules+="xcat nfs base network kernel-modules lvm syslog"\n};
- }
- print $DRACUTCONF qq{add_drivers+="$add_drivers"\n};
- close $DRACUTCONF;
- } else {
- xdie "the mode: $mode is not supported by genimage";
- }
-
- my $additional_options = undef;
- if ($rootlimit)
- {
- open(my $ETC_CMDLINE, ">", "$rootimg_dir/tmp/cmdline");
- print $ETC_CMDLINE qq{rootlimit=$rootlimit\n};
- close $ETC_CMDLINE;
- $additional_options = qq{--include /tmp/cmdline /etc/cmdline};
- }
-
- # force the dracut run in non-hostonly mode for dracut higher than version 033
- if ($dracutver > "033") {
- $additional_options .= " -N";
- }
-
- #if "pigz" is available in the rootimg, use "pigz" instead of "gzip"
- my $compress = qx(chroot $rootimg_dir bash -c "type -p pigz"|tr -d "\n");
- if ($compress) {
-
- #take the online cpu numerber as the pigz processes number
- my $processnum = qx(lscpu -p=cpu --online|grep -v '#'|wc -l|tr -d "\n");
- $additional_options .= " --compress \"$compress -p $processnum \"";
- }
-
- print "\nchroot $rootimg_dir dracut $additional_options -f /tmp/initrd.$$.gz $kernelver\n";
- !system("chroot $rootimg_dir dracut $additional_options -f /tmp/initrd.$$.gz $kernelver")
- or die("Error: failed to generate the initial ramdisk for $mode.\n");
- print "the initial ramdisk for $mode is generated successfully.\n";
- move("$rootimg_dir/tmp/initrd.$$.gz", "$destdir/initrd-$mode.gz");
-}
-
-
-sub mkinitrd {
- my ($mode) = @_; # statelite or stateless
-
- if ($mode eq "statelite") {
-
- # additional modules needed on s390x
- push @ndrivers, qw{qdio.ko ccwgroup.ko qeth.ko qeth_l2.ko qeth_l3.ko} if ($arch eq "s390x");
-
- # for nfs
- my @modlist = qw{sunrpc.ko lockd.ko nfs_acl.ko fscache.ko auth_rpcgss.ko exportfs.ko nfsd.ko nfs.ko};
- unshift(@ndrivers, @modlist);
- }
-
- mkpath("/tmp/xcatinitrd.$$/bin");
- symlink("bin", "/tmp/xcatinitrd.$$/sbin");
- mkpath("/tmp/xcatinitrd.$$/usr/bin");
- mkpath("/tmp/xcatinitrd.$$/usr/sbin");
- mkpath("/tmp/xcatinitrd.$$/usr/lib");
- mkpath("/tmp/xcatinitrd.$$/usr/lib64");
- mkpath("/tmp/xcatinitrd.$$/lib/firmware");
- mkpath("/tmp/xcatinitrd.$$/tmp");
- mkpath("/tmp/xcatinitrd.$$/var/run");
- mkpath("/tmp/xcatinitrd.$$/lib64/firmware");
- mkpath("/tmp/xcatinitrd.$$/lib/power6"); #SLES10
- mkpath("/tmp/xcatinitrd.$$/lib/power7"); #SLES10
- mkpath("/tmp/xcatinitrd.$$/lib/mkinitrd/bin");
- mkpath("/tmp/xcatinitrd.$$/proc");
- mkpath("/tmp/xcatinitrd.$$/sys");
- mkpath("/tmp/xcatinitrd.$$/dev/mapper");
- mkpath("/tmp/xcatinitrd.$$/sysroot");
- mkpath("/tmp/xcatinitrd.$$/etc/ld.so.conf.d");
- mkpath("/tmp/xcatinitrd.$$/var/lib/dhcpcd");
- my $inifile;
- open($inifile, ">", "/tmp/xcatinitrd.$$/init");
- print $inifile "#!/bin/bash\n";
-
- # copied from genimage for rh
- # add some functions
- print $inifile < <\\ \\____/ | \\ |
- /__/\\_ \\\\______ /\\____|__ /____|
- \\/ \\/ \\/
-'
- echo -e "\$RESET"
-}
-
-
-EOS1
-
- print $inifile "mount -t proc /proc /proc\n";
- print $inifile "mount -t sysfs /sys /sys\n";
- print $inifile "mount -o mode=0755 -t tmpfs /dev /dev\n";
- print $inifile "mkdir /dev/pts\n";
- print $inifile "mount -t devpts -o gid=5,mode=620 /dev/pts /dev/pts\n";
- print $inifile "mkdir /dev/shm\n";
- print $inifile "mkdir /dev/mapper\n";
-
- print $inifile "mknod /dev/random c 1 8\n";
- print $inifile "mknod /dev/urandom c 1 9\n";
- print $inifile "mknod /dev/null c 1 3\n";
- print $inifile "mknod /dev/zero c 1 5\n";
- print $inifile "mknod /dev/systty c 4 0\n";
- print $inifile "mknod /dev/tty c 5 0\n";
- print $inifile "mknod /dev/console c 5 1\n";
- print $inifile "mknod /dev/ptmx c 5 2\n";
- print $inifile "mknod /dev/rtc c 10 135\n";
- print $inifile "mknod /dev/tty0 c 4 0\n";
- print $inifile "mknod /dev/tty1 c 4 1\n";
- print $inifile "mknod /dev/tty2 c 4 2\n";
- print $inifile "mknod /dev/tty3 c 4 3\n";
- print $inifile "mknod /dev/tty4 c 4 4\n";
- print $inifile "mknod /dev/tty5 c 4 5\n";
- print $inifile "mknod /dev/tty6 c 4 6\n";
- print $inifile "mknod /dev/tty7 c 4 7\n";
- print $inifile "mknod /dev/tty8 c 4 8\n";
- print $inifile "mknod /dev/tty9 c 4 9\n";
- print $inifile "mknod /dev/tty10 c 4 10\n";
- print $inifile "mknod /dev/tty11 c 4 11\n";
- print $inifile "mknod /dev/tty12 c 4 12\n";
- print $inifile "mknod /dev/ttyS0 c 4 64\n";
- print $inifile "mknod /dev/ttyS1 c 4 65\n";
- print $inifile "mknod /dev/ttyS2 c 4 66\n";
- print $inifile "mknod /dev/ttyS3 c 4 67\n";
-
- # Install modules before starting udev
- # because networking modules (qeth/qeth_l2/qeth_l3) are needed
- foreach (@ndrivers) {
- print $inifile "insmod /lib/$_\n";
- }
-
- # Start udev
- print $inifile < /dev/null && export DEBUG=1\n";
- }
-
- print $inifile < /tmp/ifcfg-\$IFACE
-
-ip addr add dev lo 127.0.0.1/8
-ip link set lo up
-
-
-XCATMASTER=`echo \$XCATSERVER|awk -F: '{print \$1}'`
-
-if [ -z \$XCATIPORT ]; then
- XCATIPORT="3002"
-fi
-
-if [ \$NODESTATUS != 'n' ]; then
- /tmp/updateflag \$XCATMASTER \$XCATIPORT "installstatus netbooting"
-fi
-
-cd /
-for i in `cat /proc/cmdline`; do
- KEY=`echo \$i |awk -F= '{print \$1}'`
- if [ "\$KEY" == 'imgurl' ]; then
- VALUE=`echo \$i |awk -F= '{print \$2}'`
- if [ "http" == "`echo \$VALUE|awk -F: '{print \$1}'`" ]; then
- #NOTE needs FT retry code to scale
- #NOTE: should prob have max count
- FILENAME=`echo \$VALUE|awk -F/ '{print \$NF}'`
- while [ ! -r "\$FILENAME" ]; do
- echo Getting \$VALUE...
- if ! wget \$VALUE; then
- sleep 5 #should be random, exponential for scale
- rm -f \$FILENAME
- fi
- done
- fi
- elif [[ "\$KEY" == NFSROOT ]]; then # for NFSROOT
- NFSROOT=1
- VALUE=`echo \$i |awk -F= '{print \$2}'`
- SERVER=`echo \$VALUE|awk -F: '{print \$1}'`
- ROOTDIR=`echo \$VALUE|awk -F/ '{for(i=2;i<=NF;i++) printf "/%s",\$i}'`
- elif [ "\$KEY" == 'STATEMNT' ]; then
- STATELITE=1
- VALUE=`echo \$i |awk -F= '{print \$2}'`
- # VALUE may be null
- if [ ! -z \$VALUE ]; then
- SNAPSHOTSERVER=`echo \$VALUE|awk -F: '{print \$1}'`
- SNAPSHOTROOT=`echo \$VALUE|awk -F/ '{for(i=2;i<=NF;i++) printf "/%s",\$i}'`
- # may be that there is not server and just a directory.
- if [ -z \$SNAPSHOTROOT ]; then
- SNAPSHOTROOT=\$SNAPSHOTSERVER
- SNAPSHOTSERVER=
- fi
- fi
- elif [ "\$KEY" == 'NODE' ]; then
- NODENAME=`echo \$i |awk -F= '{print \$2}'`
- fi
-done
-
-# show xCAT logo
-fancydisplay
-
-# Statelite code is here
-if [ "\$STATELITE" = "1" ]; then
- echo Setting up Statelite
- mknod /dev/loop0 b 7 0
- mkdir -p \$NEWROOT
- MAXTRIES=15
- ITER=0
- ME=`hostname`
- if [ ! -z "$NODENAME" ]; then
- ME=$NODENAME
- fi
- if [ "\$NFSROOT" = "1" ]; then
- while ! mount.nfs \${SERVER}:\${ROOTDIR}/rootimg \$NEWROOT -r -n -o nolock,rsize=32768,tcp,nfsvers=3,timeo=14; do
- ITER=\$(expr \$ITER + 1)
- if [ "\$ITER" = "\$MAXTRIES" ]; then
- echo "You're dead. rpower \$ME boot to play again."
- echo "Possible problems:
-1. This initrd wan't created for the statelite node?
-2. IS DNS set up? Maybe that's why I can't mount \${SERVER}.
-3. The nfs modules aren't set right in this initial ramdisk?"
- shell
- exit
- fi
- echo -e "\${RED}Couldn't mount \$SERVER:\$ROOTDIR on \$NEWROOT \$RESET"
- RS=\$(expr \$RANDOM % 30)
- echo -e "Trying again in \$RS seconds"
- sleep \$RS
- done
- else
- # for statelite mode on top of the ramdisk
-EOMS
-
- print $inifile "if [ -r /rootimg-statelite.gz ]; then \n";
- print $inifile "echo Setting up RAM-root tmpfs.\n";
- if ($rootlimit) {
- print $inifile " mount -o size=$rootlimit,mode=755 -t tmpfs rootfs \$NEWROOT \n";
- } else {
- print $inifile " mount -o mode=755 -t tmpfs rootfs \$NEWROOT \n";
- }
-
- print $inifile </dev/null && shell
- mount -t tmpfs rw -o mode=$permission \$NEWROOT/\$RWDIR
- mkdir -p \$NEWROOT/\$RWDIR/tmpfs
-
- #mount the /root/.ssh, it needs more strict permission in order for ssh work
- #if [ ! -e "\$NEWROOT/root/.ssh" ]
- #then
- # mkdir -p \$NEWROOT/root/.ssh
- #fi
- #mount -t tmpfs -o mode=755 ssh \$NEWROOT/root/.ssh
-
- # mount the SNAPSHOT directory here for persistent use.
- if [ ! -z \$SNAPSHOTSERVER ]
- then
- mkdir -p \$NEWROOT/\$RWDIR/persistent
- MAXTRIES=5
- ITER=0
- while ! mount \$SNAPSHOTSERVER:\$SNAPSHOTROOT \$NEWROOT/\$RWDIR/persistent -o nolock,\$XCATMNTOPTS
- do
- ITER=\$(expr \$ITER + 1)
- if [ "\$ITER" == "\$MAXTRIES" ]
- then
- echo "You're dead. rpower \$ME boot to play again."
- echo "Possible problems:
-1. \$SNAPSHOTSERVER is not exporting \$SNAPSHOTROOT ?
-2. Is DNS set up? Maybe that's why I can't mount \$SNAPSHOTSERVER."
- shell
- exit
- fi
- echo -e "\${RED}Hmmm... Can't mount \$SNAPSHOTSERVER:\$SNAPSHOTROOT. \${NORMAL} \$XCATMNTOPTS"
- RS=`expr \$RANDOM % 20`
- echo -e "Trying again in \$RS seconds"
- sleep \$RS
- done
-
- # create directory which is named after my node name
- mkdir -p \$NEWROOT/\$RWDIR/persistent/\$ME
- ITER=0
- # umount current persistent mount
- while ! umount -l \$NEWROOT/\$RWDIR/persistent; do
- ITER=\$(( ITER + 1 ))
- if [ "\$ITER" == "\$MAXTRIES" ]; then
- echo "Your are dead, rpower \$ME boot to play again."
- echo "Cannot umount \$NEWROOT/\$RWDIR/persistent."
- /bin/sh
- exit
- fi
- RS= \$(( \$RANDOM % 20 ))
- echo "Trying again in \$RS seconds..."
- sleep \$RS
- done
-
- # mount persistent to server:/rootpath/nodename
- ITER=0
- while ! mount \$SNAPSHOTSERVER:/\$SNAPSHOTROOT/\$ME \$NEWROOT/\$RWDIR/persistent -o nolock,\$XCATMNTOPTS; do
- ITER=\$(( ITER + 1 ))
- if [ "\$ITER" == "\$MAXTRIES" ]; then
- echo "Your are dead, rpower \$ME boot to play again."
- echo "Possible problems: cannot mount to \$SNAPSHOTSERVER:/\$SNAPSHOTROOT/\$ME."
- /bin/sh
- exit
- fi
- RS= \$(( \$RANDOM % 20 ))
- echo "Trying again in \$RS seconds..."
- sleep \$RS
- done
- fi
-
- grep '\\(shell\\)' /proc/cmdline >/dev/null && shell
-
- # have to preserve the initial DHCP request. So we link it.
- # SLES uses different file to store DHCP info
- if [ ! -d \$NEWROOT/\$RWDIR/tmpfs/var/lib/dhcpcd ]
- then
- mkdir -p \$NEWROOT/\$RWDIR/tmpfs/var/lib/dhcpcd
- fi
- cp -fp /var/lib/dhcpcd/dhcpcd-\$IFACE.info \${NEWROOT}/\${RWDIR}/tmpfs/var/lib/dhcpcd/dhcpcd-\$IFACE.info
-
- [ -e /etc/ntp.conf ] && mkdir -p \$NEWROOT/\$RWDIR/tmpfs/etc && cp /etc/ntp.conf \$NEWROOT/\$RWDIR/tmpfs/etc/
-
- [ -e /etc/resolv.conf ] && mkdir -p \$NEWROOT/\$RWDIR/tmpfs/etc && cp /etc/resolv.conf \$NEWROOT/\$RWDIR/tmpfs/etc/
-
- # now that everything is mounted, lets do this
- # hmmm, apparently I'm checking this twice... so I'd better
- # be really sure the file is there.
- while [ ! -e \$NEWROOT/etc/init.d/statelite ]
- do
- echo "\$NEWROOT/etc/init.d/statelite does not exist in image!"
- shell
- done
-
- # try to configure the local disk
- \$NEWROOT/etc/init.d/localdisk
-
- # do all the mounts:
- \$NEWROOT/etc/init.d/statelite
-EOMS
-
- # udevd needed by s390x for networking
- # but for other type of machine, udevd will affect the start of devices which detected
- # after the chroot, so kill it before the switching root
- if ($arch ne "s390x") {
- print $inifile "\n killall -9 udevd\n";
- }
-
- print $inifile < /dev/null && shell
-
- echo 0x100 > /proc/sys/kernel/real-root-dev
- export keep_old_ip=yes
- export fastboot=yes
- export READONLY=yes
- grep '\\(shell\\)' /proc/cmdline >/dev/null && shell
- mount -n --bind /dev /sysroot/dev
- umount /sys
- umount /proc
-
- # sles use the standard utility to chroot
- if ! exec /usr/bin/chroot \$NEWROOT /sbin/init
- then
- echo ""
- echo -e "\${RED}Couldn't chroot. Something must be wrong with NFS root image.\${RESET}"
- shell
- fi
- exit
-fi
-# end NFSROOT/Statelite code
-
-if [ -r /rootimg.sfs ]; then
- echo Setting up squashfs with ram overlay.
- mknod /dev/loop0 b 7 0
- mkdir -p /ro
- mkdir -p /rw
- mount -t squashfs /rootimg.sfs /ro
- mount -t tmpfs rw /rw
- mount -t aufs -o dirs=/rw:/ro mergedroot /sysroot
- mkdir -p /sysroot/ro
- mkdir -p /sysroot/rw
- mount --move /ro /sysroot/ro
- mount --move /rw /sysroot/rw
-EOMS
- print $inifile "elif [ -r /rootimg.cpio.gz ] || [ -r /rootimg.cpio.xz ]; then\n";
- print $inifile "echo Setting up RAM-root tmpfs.\n";
- if ($rootlimit) {
- print $inifile " mount -o size=$rootlimit,mode=755 -t tmpfs rootfs \$NEWROOT\n";
- } else {
- print $inifile " mount -o mode=755 -t tmpfs rootfs \$NEWROOT\n";
- }
- print $inifile " cd /sysroot\n";
- print $inifile " echo -n \"Extracting root filesystem:\"\n";
- print $inifile " if [ -r /rootimg.cpio.gz ]; then\n";
- print $inifile " if [ -x /bin/cpio ]; then\n";
- print $inifile " zcat /rootimg.cpio.gz |/bin/cpio -idum\n";
- print $inifile " else\n";
- print $inifile " zcat /rootimg.cpio.gz |cpio -idum\n";
- print $inifile " fi\n";
- print $inifile " elif [ -r /rootimg.cpio.xz ]; then\n";
- print $inifile " if [ -x /bin/cpio ]; then\n";
- print $inifile " xz -cd /rootimg.cpio.xz |/bin/cpio -idum\n";
- print $inifile " else\n";
- print $inifile " xz -cd /rootimg.cpio.xz |cpio -idum\n";
- print $inifile " fi\n";
- print $inifile " fi\n";
- print $inifile " echo Done\n";
- print $inifile "elif [ -r /rootimg.tar.gz ] || [ -r /rootimg.tar.xz ]; then\n";
- print $inifile " echo Setting up RAM-root tmpfs.\n";
-
- if ($rootlimit) {
- print $inifile " mount -o \"size=$rootlimit,mode=755\" -t tmpfs rootfs \$NEWROOT\n";
- } else {
- print $inifile " mount -o mode=755 -t tmpfs rootfs \$NEWROOT\n";
- }
- print $inifile " cd \$NEWROOT\n";
- print $inifile " echo -n \"Extracting root filesystem:\"\n";
- print $inifile " if [ -r /rootimg.tar.gz ]; then\n";
- print $inifile " tar --selinux --xattrs-include='*' -zxf /rootimg.tar.gz\n";
- print $inifile " if [ \$? -ne 0 ]; then\n";
- print $inifile " tar -zxf /rootimg.tar.gz\n";
- print $inifile " fi\n";
- print $inifile " elif [ -r /rootimg.tar.xz ]; then\n";
- print $inifile " tar --selinux --xattrs-include='*' -Jxf /rootimg.tar.xz\n";
- print $inifile " if [ \$? -ne 0 ]; then\n";
- print $inifile " tar -Jxf /rootimg.tar.xz\n";
- print $inifile " fi\n";
- print $inifile " fi\n";
- print $inifile " echo Done\n";
- print $inifile "else\n";
- print $inifile " echo -n Failed to download image, panicing in 5...\n";
- print $inifile " for i in 4 3 2 1 0; do\n";
- print $inifile " /bin/sleep 1\n";
- print $inifile " echo -n \$i...\n";
- print $inifile " done\n";
- print $inifile " echo\n";
- print $inifile <" . "/tmp/xcatinitrd.$$/bin/netstart");
- print $inifile "#!/bin/bash \n";
- if ($osver_host == 10) {
- print $inifile "dhcpcd \${1}\n";
- } else { # for sles11 or higher
- # -p is used to keep the network connection during the shutdown. Used for nfs-based statelite shutdown
- print $inifile "dhcpcd \${1} -p\n";
- }
-
- #-- Bring other NICs up in /bin/netstart in initrd for NIC failover
- foreach (split /,/, $othernics) {
- if (/^$/) { next; }
- print $inifile "dhcpcd $_\n";
- }
-
- print $inifile <> /etc/HOSTNAME
-END
-
- close($inifile);
-
- #if "nonodestatus" specified,do not update the nodestatus
- system("mkdir -p /tmp/xcatinitrd.$$/tmp/");
- cp("$installroot/postscripts/updateflag.awk","/tmp/xcatinitrd.$$/tmp/updateflag");
- $perm = (stat("$installroot/postscripts/updateflag.awk"))[2];
- chmod($perm & 07777, "/tmp/xcatinitrd.$$/tmp/updateflag");
-
- chmod(0755, "/tmp/xcatinitrd.$$/init");
- chmod(0755, "/tmp/xcatinitrd.$$/bin/netstart");
-
- @filestoadd = ();
- foreach (@ndrivers) {
- if (-f "$customdir/$_") {
- push @filestoadd, [ $_, "lib/$_" ];
- } elsif (-f "$pathtofiles/$_") {
- push @filestoadd, [ $_, "lib/$_" ];
- }
- }
- if ($mode eq "statelite") {
- foreach ("sbin/ifconfig", "usr/bin/clear", "usr/bin/touch", "usr/bin/cut", "usr/bin/rm", "bin/hostname", "usr/bin/egrep", "bin/ln", "bin/ls", "usr/bin/dirname", "usr/bin/expr", "usr/bin/chroot", "usr/bin/grep", "bin/cpio", "bin/sleep", "bin/mount", "bin/umount", "sbin/dhcpcd", "bin/bash", "sbin/insmod", "bin/mkdir", "bin/mknod", "sbin/ip", "bin/cat", "usr/bin/awk", "usr/bin/wget", "bin/cp", "usr/bin/cpio", "usr/bin/zcat", "usr/bin/gzip", "lib/mkinitrd/bin/run-init", "usr/bin/uniq", "usr/bin/sed", "usr/bin/wc", "bin/sed", "sbin/udevd", "usr/bin/readlink", "usr/sbin/parted", "sbin/mke2fs", "sbin/mkswap", "sbin/swapon", "bin/chmod", "usr/bin/bc", "usr/bin/xz", "usr/bin/gzip", "bin/tar") {
- getlibs($_);
- push @filestoadd, $_;
- }
- if ($osver_host >= 11) {
- foreach ("sbin/mount.nfs", "sbin/umount.nfs", "sbin/udevadm") {
- getlibs($_);
- push @filestoadd, $_;
- }
- }
-
- } else {
- foreach ("sbin/ifconfig", "usr/bin/clear", "usr/bin/touch", "usr/bin/grep", "usr/bin/egrep", "bin/cpio", "bin/sleep", "bin/mount", "sbin/dhcpcd", "bin/bash", "sbin/insmod", "bin/mkdir", "bin/mknod", "sbin/ip", "bin/cat", "usr/bin/awk", "usr/bin/wget", "bin/cp", "usr/bin/cpio", "usr/bin/zcat", "usr/bin/gzip", "lib/mkinitrd/bin/run-init", "usr/bin/uniq", "usr/bin/sed", "sbin/udevd", "usr/bin/readlink", "usr/bin/expr", "usr/sbin/parted", "sbin/mke2fs", "sbin/mkswap", "sbin/swapon", "bin/chmod", "usr/bin/bc", "usr/bin/xz", "usr/bin/gzip", "bin/tar") {
- getlibs($_);
- push @filestoadd, $_;
- }
- if ($osver_host >= 11) {
- getlibs("sbin/udevadm");
- push @filestoadd, "sbin/udevadm";
- }
- }
-
- if ($arch =~ /64/) {
- push @filestoadd, "lib64/libnss_dns.so.2";
- push @filestoadd, "lib64/libnss_files.so.2";
- }
- else {
- push @filestoadd, "lib/libnss_dns.so.2";
- push @filestoadd, "lib/libnss_files.so.2";
- }
-
- # cross-platfrom support on power6&7 etc
- # ldd can't handle such one scenario: mn is power6, the target platform is power7
- if ($arch =~ /ppc64/) {
- system("cp -a -r $rootimg_dir/lib64/* /tmp/xcatinitrd.$$/lib64/");
- }
-
-
- push @filestoadd, keys %libhash;
-
- find(\&isnetdriver, <$rootimg_dir/lib/modules/$kernelver/*>);
- my $pathonrootimage = "$rootimg_dir/tmpfiles";
- my $pathinrootimage = "/tmpfiles";
- mkpath($pathonrootimage);
- foreach (@filestoadd) {
- if (ref($_)) {
-
- #print "$_->[0], $_->[1]\n";
- my $srcfile = $_->[0];
- system("chroot $rootimg_dir cp $srcfile $pathinrootimage");
- my $srcpath = "$pathonrootimage/" . basename($_->[0]);
- if (-f "$customdir/" . $_->[0]) {
- $srcpath = "$customdir/" . $_->[0];
- } elsif (-f "$pathtofiles/" . $_->[0]) {
- $srcpath = "$pathtofiles/" . $_->[0];
- }
- mkpath(dirname("/tmp/xcatinitrd.$$/" . $_->[1]));
- copy($srcpath, "/tmp/xcatinitrd.$$/" . $_->[1]);
- chmod 0755, "/tmp/xcatinitrd.$$/" . $_->[1];
- } else {
-
- #print "$_\n";
- system("chroot $rootimg_dir cp $_ $pathinrootimage");
- my $srcpath = "$pathonrootimage/" . basename($_);
- if (-f "$customdir/$_") {
- $srcpath = "$customdir/$_";
- } elsif (-f "$pathtofiles/$_") {
- $srcpath = "$pathtofiles/$_";
- }
- mkpath(dirname("/tmp/xcatinitrd.$$/$_"));
- copy("$srcpath", "/tmp/xcatinitrd.$$/$_");
- chmod 0755, "/tmp/xcatinitrd.$$/" . $_;
- }
- }
- rmtree($pathonrootimage);
-
- #copy conf files needed by nfs mount in sles11.2
- if ($osver_host >= 11)
- {
- system("cp -r $rootimg_dir/etc/protocols /tmp/xcatinitrd.$$/etc/");
- system("cp -r $rootimg_dir/etc/netconfig /tmp/xcatinitrd.$$/etc/");
- }
-
-
- # Copy udev libraries
- system("mkdir -p /tmp/xcatinitrd.$$/etc/udev");
- system("mkdir -p /tmp/xcatinitrd.$$/lib/firmware");
- system("cp -r $rootimg_dir/etc/udev/* /tmp/xcatinitrd.$$/etc/udev");
- system("cp -r $rootimg_dir/bin/uname /tmp/xcatinitrd.$$/bin/");
- if (-d "$rootimg_dir/lib/firmware/") {
- system("cp -r $rootimg_dir/lib/firmware/* /tmp/xcatinitrd.$$/lib/firmware");
- }
- system("cp -r $rootimg_dir/usr/bin/killall /tmp/xcatinitrd.$$/usr/bin");
-
- # Copy rules for network adapter
- #my $name = `cat /etc/sysconfig/network/ifcfg-$prinic | grep NAME`;
- #my $nic = '';
- #if ($name =~ m/(\d+\.\d+\.\d+)/g) {
- # $nic = $&;
- #}
-
- # Somehow checking for *$nic.rules does not work
- #if ( -f "/etc/udev/rules.d/*$nic.rules" ) {
- # system("cp -r /etc/udev/rules.d/*$nic.rules /tmp/xcatinitrd.$$/etc/udev/rules.d");
- #}
- #if ( -f "/etc/udev/rules.d/*persistent-net.rules" ) {
- # system("cp -r /etc/udev/rules.d/*persistent-net.rules /tmp/xcatinitrd.$$/etc/udev/rules.d");
- #}
-
- system("mkdir -p /tmp/xcatinitrd.$$/lib/udev");
- system("cp -r $rootimg_dir/lib/udev/* /tmp/xcatinitrd.$$/lib/udev");
-
- #copy("$rootimg_dir/lib/modules/*d","/tmp/xcatinitrd.$$/$_");
- system("cd /tmp/xcatinitrd.$$/bin/; ln -sf bash sh"); #neccessary for SLES11
- if ($mode eq "statelite") {
- system("cd /tmp/xcatinitrd.$$;find .|cpio -H newc -o|gzip -9 -c - > $destdir/initrd-statelite.gz");
- print "The initial ramdisk for statelite has been generated successfully!\n";
- } else {
- system("cd /tmp/xcatinitrd.$$;find .|cpio -H newc -o|gzip -9 -c - > $destdir/initrd-stateless.gz");
- print "The initial ramdisk for stateless has been generated successfully!\n";
- }
- system("rm -rf /tmp/xcatinitrd.$$");
-
-}
-
-sub isyumdir {
- if ($File::Find::name =~ /\/repodata$/) {
- my $location = $File::Find::name;
- $location =~ s/\/repodata$//;
- push @yumdirs, $location;
- }
-}
-
-sub isnetdriver {
- foreach (@ndrivers) {
- if ($File::Find::name =~ /\/$_/) {
- my $filetoadd = $File::Find::name;
- $filetoadd =~ s!$rootimg_dir!!;
- push @filestoadd, [ $filetoadd, "lib/$_" ];
- print "Added driver $_ to initrd\n";
- }
- }
-}
-
-
-
-
-
-
-
-sub postscripts { # TODO: customized postscripts
- generic_post();
- unless (-d "$rootimg_dir/opt/xcat/") {
- mkdir "$rootimg_dir/opt/xcat/";
- }
- copy("$installroot/postscripts/xcatdsklspost", "$rootimg_dir/opt/xcat/"); #TODO: it is not used in stateless
- chmod '0755', "$rootimg_dir/opt/xcat/xcatdsklspost";
-}
-
-sub generic_post { # This function is meant to leave the image in a state approximating a normal install
- my $cfgfile;
-
- #modify /etc/sysconfig/clock in the image:HWCLOCK="--local", TIMEZONE=site:timezone
- if ($timezone) {
- if (-e "$rootimg_dir/etc/sysconfig/clock") {
- system("sed -i '" . 's!\(TIMEZONE=\).*!\1' . "\"$timezone\"!" . "' $rootimg_dir/etc/sysconfig/clock");
- }
- system("chroot $rootimg_dir zic -l $timezone");
- }
-
- if (-e "$rootimg_dir/etc/sysconfig/clock") {
- system("sed -i 's!\\(HWCLOCK=\\).*!\\1\"--localtime\"!' $rootimg_dir/etc/sysconfig/clock");
- }
-
- unlink("$rootimg_dir/dev/null");
- system("mknod $rootimg_dir/dev/null c 1 3");
- open($cfgfile, ">", "$rootimg_dir/etc/fstab");
- print $cfgfile "devpts /dev/pts devpts gid=5,mode=620 0 0\n";
- print $cfgfile "tmpfs /dev/shm tmpfs defaults 0 0\n";
- print $cfgfile "proc /proc proc defaults 0 0\n";
- print $cfgfile "sysfs /sys sysfs defaults 0 0\n";
- if ($tmplimit) {
- print $cfgfile "tmpfs /tmp tmpfs defaults,size=$tmplimit 0 2\n";
- print $cfgfile "tmpfs /var/tmp tmpfs defaults,size=$tmplimit 0 2\n";
- } else {
- print $cfgfile "tmpfs /tmp tmpfs defaults,size=10m 0 2\n";
- print $cfgfile "tmpfs /var/tmp tmpfs defaults,size=10m 0 2\n";
- }
-
- my $rootfs_name = $profile . "_" . $arch;
- print $cfgfile "$rootfs_name / tmpfs rw 0 1\n";
-
- close($cfgfile);
-
- open($cfgfile, ">", "$rootimg_dir/etc/sysconfig/network");
- print $cfgfile "NETWORKING=yes\n";
- close($cfgfile);
-
- open($cfgfile, ">", "$rootimg_dir/etc/resolv.conf");
- print $cfgfile "#Dummy resolv.conf to make boot cleaner";
- close($cfgfile);
-
- # Create the ifcfg-x file for diskless node. But keep the ONBOOT=no
- # to skip the break of nfs-based boot
- if ($prinic) {
- open($cfgfile, ">", "$rootimg_dir/etc/sysconfig/network/ifcfg-$prinic");
- print $cfgfile "ONBOOT=no\nBOOTPROTO=dhcp\nDEVICE=$prinic\nSTARTMODE=auto\n";
- close($cfgfile);
- }
-
- foreach (split /,/, $othernics) {
- next if (/^$/);
- open($cfgfile, ">", "$rootimg_dir/etc/sysconfig/network/ifcfg-$_");
- print $cfgfile "ONBOOT=yes\nBOOTPROTO=dhcp\nDEVICE=$_\nSTARTMODE=auto\n";
- close($cfgfile);
- }
-
- # securetty not needed on s390x
- if ($arch ne "s390x") {
- open($cfgfile, ">>", "$rootimg_dir/etc/securetty");
- print $cfgfile "ttyS0\n";
- print $cfgfile "ttyS1\n";
- print $cfgfile "console\n";
- close($cfgfile);
- }
-
- my @passwd;
- open($cfgfile, "<", "$rootimg_dir/etc/passwd");
- @passwd = <$cfgfile>;
- close($cfgfile);
- open($cfgfile, ">", "$rootimg_dir/etc/passwd");
- foreach (@passwd) {
- if (/^root:/) {
- s/^root:\*/root:x/;
- }
- print $cfgfile $_;
- }
- close($cfgfile);
- foreach (<$rootimg_dir/etc/skel/.*>) {
- next if (basename($_) eq '.' or basename($_) eq '..');
- copy $_, "$rootimg_dir/root/";
- }
-
- # gettyset is not found on s390x
- if ($arch ne "s390x") {
- open($cfgfile, ">", "$rootimg_dir/etc/init.d/gettyset");
- print $cfgfile "#!/bin/bash\n";
- print $cfgfile "### BEGIN INIT INFO\n";
- print $cfgfile "# Provides: gettyset\n";
- print $cfgfile "# Required-Start: sshd\n";
- print $cfgfile "# Required-Stop:\n";
- print $cfgfile "# Default-Start: 3\n";
- print $cfgfile "# Default-Stop: 0 1 2 6\n";
- print $cfgfile "# Short-Description: gettyset\n";
- print $cfgfile "# Description:\n";
- print $cfgfile "### END INIT INFO\n";
- print $cfgfile "VERS=`grep VERSION /etc/SuSE-release`\n";
- print $cfgfile "if [ -n \"\$VERS\" ]; then\n";
- print $cfgfile " VERNUM=`echo \$VERS|awk -F= \'{print \$2}\'|sed -e \'s/ //g\'`\n";
- print $cfgfile "fi\n";
- print $cfgfile "if [ \"\$VERNUM\" -gt 10 ]; then\n";
- print $cfgfile " exit\n";
- print $cfgfile "fi\n";
- print $cfgfile "\n";
- print $cfgfile "for i in `cat /proc/cmdline`; do\n";
- print $cfgfile ' KEY=`echo $i|cut -d= -f 1`' . "\n";
- print $cfgfile " if [ \"\$KEY\" == \"console\" -a \"\$i\" != \"console=tty0\" ]; then\n";
- print $cfgfile " VALUE=`echo \$i | cut -d= -f 2`\n";
- print $cfgfile " COTTY=`echo \$VALUE|cut -d, -f 1`\n";
- print $cfgfile " COSPEED=`echo \$VALUE|cut -d, -f 2|cut -dn -f 1`\n";
- print $cfgfile " if echo \$VALUE | grep n8r; then\n";
- print $cfgfile " FLOWFLAG=\"-h\"\n";
- print $cfgfile " fi\n";
- print $cfgfile " echo xco:2345:respawn:/sbin/agetty \$FLOWFLAG \$COTTY \$COSPEED xterm >> /etc/inittab\n";
- print $cfgfile " init q\n";
- print $cfgfile " fi\n";
- print $cfgfile "done\n";
- print $cfgfile "/etc/init.d/boot.localnet start\n";
-
- close($cfgfile);
- chmod(0755, "$rootimg_dir/etc/init.d/gettyset");
- }
-
- copy("$installroot/postscripts/xcatpostinit", "$rootimg_dir/etc/init.d/xcatpostinit");
- chmod(0755, "$rootimg_dir/etc/init.d/xcatpostinit");
- copy("$installroot/postscripts/xcatpostinit.service", "$rootimg_dir/usr/lib/systemd/system/xcatpostinit.service");
-
- #
- # set certain system services to start on boot, if the file exists in /etc/init.d as a script,
- # use insserv to start it. If not, assume that the service is controlled by systemctl
- #
- # note: insserv is passed the -f option to ignore the dependency on sles10.4
- #
- print "[genimage] setting services to start at boot time...\n";
- my @services;
- push @services, qw/sshd network gettyset xcatpostinit/;
-
- foreach my $service (@services) {
- my $cmd = "chroot $rootimg_dir ";
- $cmd = $cmd . "systemctl enable $service.service";
- system("$cmd");
- }
-
- #
- # Check if .depend.start file exists. For SLES12 and later OS, this does not apply
- #
- if (-r '$rootimg_dir/etc/init.d/.depend.start') {
- my $rc = system("grep sshd $rootimg_dir/etc/init.d/.depend.start | grep TARGETS");
- if ($rc) {
- system("sed -i '" . 's/^\(TARGETS = .*\)$/\1 sshd/' . "' $rootimg_dir/etc/init.d/.depend.start");
- system("ln -s ../sshd $rootimg_dir/etc/init.d/rc3.d/S20sshd");
- }
- my $rc = system("grep gettyset $rootimg_dir/etc/init.d/.depend.start | grep TARGETS");
- if ($rc) {
- system("sed -i '" . 's/^\(TARGETS = .*\)$/\1 gettyset/' . "' $rootimg_dir/etc/init.d/.depend.start");
- system("ln -s ../gettyset $rootimg_dir/etc/init.d/rc3.d/S60gettyset");
- }
- }
-}
-
-
-my $driver_name;
-my $real_path;
-
-sub get_path ()
-{
- if ($File::Find::name =~ /\/$driver_name/) {
- $real_path = $File::Find::name;
- }
-}
-
-my @all_real_path;
-
-sub get_all_path ()
-{
- if ($File::Find::name =~ /\/$driver_name/) {
- push @all_real_path, $File::Find::name;
- }
-}
-
-# Load driver disk and driver rpm to the initrd
-# Get the driver disk or driver rpm from the osimage.driverupdatesrc
-# The valid value: dud:/install/dud/dd.img,rpm:/install/rpm/d.rpm, if missing the tag: 'dud'/'rpm'
-# the 'rpm' is default.
-#
-# If cannot find the driver disk from osimage.driverupdatesrc, will try to search driver disk
-# from /install/driverdisk//
-#
-# For driver rpm, the driver list will be gotten from osimage.netdrivers. If not set, copy all the drivers from driver
-# rpm to the initrd.
-#
-# Return the driver names by loading order
-
-sub load_dd()
-{
- my @dd_list;
- my @rpm_list;
- my @driver_list;
-
- my $Injectalldriver;
- my @rpm_drivers;
-
- # Parse the parameters to the the source of Driver update disk and Driver rpm, and driver list as well
- if ($driverupdatesrc) {
- my @srcs = split(',', $driverupdatesrc);
- foreach my $src (@srcs) {
- if ($src =~ /dud:(.*)/i) {
- push @dd_list, $1;
- } elsif ($src =~ /rpm:(.*)/i) {
- push @rpm_list, $1;
- } else {
- push @rpm_list, $src;
- }
- }
- }
- if (!@dd_list) {
-
- # get Driver update disk from the default path if not specified in osimage
- # check the Driver Update Disk images, it can be .img or .iso
- if (-d "$installroot/driverdisk/$osver/$arch") {
- @dd_list = `find $installroot/driverdisk/$osver/$arch -type f`;
- }
- }
-
- foreach (split /,/, $netdriver) {
- if (/^allupdate$/) {
- $Injectalldriver = 1;
- next;
- }
- unless (/\.ko$/) {
- s/$/.ko/;
- }
- push @driver_list, $_;
- }
-
- chomp(@dd_list);
- chomp(@rpm_list);
-
- unless (@dd_list || (@rpm_list && ($Injectalldriver || @driver_list))) {
- return ();
- }
-
- # Create the work space, it should be cleaned at end of genimage
- my $dd_dir = mkdtemp("/tmp/ddtmpXXXXXXX");
- mkpath "$dd_dir/mnt";
- mkpath "$dd_dir/mods";
-
- my @dd_drivers = (); #driver names
-
- # Load drivers from each Driver Disk
- # For multiple dd, if want to make it has order, rename the dd with a number
- # ahead of the name like 0_xx, 1_xx
- foreach my $dd (sort(@dd_list)) {
- my $rc = system("mount -o loop $dd $dd_dir/mnt");
- if ($rc) {
- print "mount the Driver Disk $dd failed.\n";
- next;
- }
-
- mkpath "$dd_dir/full";
-
- # Copy out the drivers
- opendir(DIR, "$dd_dir/mnt") || die "Cannot open dir $dd_dir/mnt";
- while (my $dir = readdir(DIR)) {
- if ($dir =~ /^\./) { next; }
-
- # Every driver update disk can have multiple directories, each directory
- # has the directory format like /linux/[distribution]/[architechture]-[version]/
- # If the directory name is numeric, then it will be used as order to load the
- # the dirviers inside.
- # For the directory name which is not numeric, copy them to directory 0. It will be
- # loaled first.
- if ($dir !~ /^\d*$/) {
- mkpath "$dd_dir/full/0";
- system("cp -rf $dd_dir/mnt/$dir $dd_dir/full/0");
- } else {
- system("cp -rf $dd_dir/mnt/$dir $dd_dir/full/");
- }
- }
- closedir(DIR);
-
- # Get all the kernel modules base on the order of directory name.
-
- # The structure of dd: /linux/[distribution]/[architechture]-[version]/
-
- # The supported arch: i386, ia64, ppc, ppc64, s390, s390x sparc or x86_64.
- my $darch = $arch;
- if ($darch =~ /^x86$/) {
- $darch = "i386";
- }
-
- # If the version is os version. If the os is "sles11.1", the possible os version
- # could be "sles11.1", "11.1", "11", "sles11"
- my @distro = ($osver);
- my $distro1 = $osver;
- $distro1 =~ s/[^\d]*//;
- push @distro, $distro1;
- my $distro2 = $distro1;
- $distro2 =~ s/\..*//;
- push @distro, $distro2;
- my $distro3 = $osver;
- $distro3 =~ s/\..*//;
- push @distro, $distro3;
-
- opendir(FDIR, "$dd_dir/full") || die "Cannot open dir $dd_dir/full";
- my @fulldir = readdir(FDIR);
- closedir(FDIR);
-
- # Create the directory for drivers from driver disk
- if (!-d "$rootimg_dir/lib/modules/$kernelver/kernel/drivers/driverdisk") {
- mkpath "$rootimg_dir/lib/modules/$kernelver/kernel/drivers/driverdisk";
- }
-
- # Copy the drivers to the root image and get the driver loading order
- foreach my $dir (sort(@fulldir)) {
- if ($dir =~ /^\./) { next; }
- my $vdir;
- foreach (@distro) {
- if (-d "$dd_dir/full/$dir/linux/suse/$darch-$_") {
- $vdir = "$dd_dir/full/$dir/linux/suse/$darch-$_";
- }
- }
- if (!$vdir) { next; }
-
- # Use the module_order if it has
- if (-f "$vdir/modules/module.order") {
- open(ORDER, "<", "$vdir/modules/module.order");
- while (my $file = ) {
- chomp($file);
- if (-f "$vdir/modules/$file") {
- $driver_name = $file;
- $real_path = "";
- find(\&get_path, <$rootimg_dir/lib/modules/$kernelver/*>);
- if ($real_path eq "") {
- system("cp $vdir/modules/$file $rootimg_dir/lib/modules/$kernelver/kernel/drivers/driverdisk");
- } else {
- system("cp $vdir/modules/$file $real_path");
- }
-
- push @dd_drivers, $file;
- }
- }
- } else {
- opendir(MDIR, "$vdir/modules") || die "Cannot open dir $vdir/modules";
- while (my $file = readdir(MDIR)) {
- if (-f "$vdir/modules/$file" && $file =~ /\.ko/) {
- $driver_name = $file;
- $real_path = "";
- find(\&get_path, <$rootimg_dir/lib/modules/$kernelver/*>);
- if ($real_path eq "") {
- system("cp $vdir/modules/$file $rootimg_dir/lib/modules/$kernelver/kernel/drivers/driverdisk");
- } else {
- system("cp $vdir/modules/$file $real_path");
- }
-
- push @dd_drivers, $file;
- }
- }
- }
- }
-
- rmtree "$dd_dir/full";
-
- my $rc = system("umount -f $dd_dir/mnt");
- if ($rc) {
- print "umount the directory $dd_dir/mnt failed\n";
- exit 1;
- }
- }
-
- # Loading the drivers from rpm packages
- if (@rpm_list && ($Injectalldriver || @driver_list)) {
-
- # Extract the files from rpm to the tmp dir
- mkpath "$dd_dir/rpm";
- foreach my $rpm (@rpm_list) {
- if (-r $rpm) {
- if (system("cd $dd_dir/rpm; rpm2cpio $rpm | cpio -idum")) {
- print "Error: Cannot extract the files from the rpm $rpm.\n";
- }
- } else {
- print "Error: Cannot read the rpm $rpm.\n";
- }
- }
-
- # To skip the conflict of files that some rpm uses the xxx.ko.new as the name of the driver
- # Change it back to xxx.ko here
- $driver_name = "\*ko.new";
- @all_real_path = ();
- find(\&get_all_path, <$dd_dir/rpm/*>);
- foreach my $file (@all_real_path) {
- my $newname = $file;
- $newname =~ s/\.new$//;
- if (system("mv -f $file $newname")) {
- print "Error: Could not rename $file\n";
-
- }
- }
-
- # Copy the firmware to the rootimage
- if (-d "$dd_dir/rpm/lib/firmware") {
- system("cp -rf $dd_dir/rpm/lib/firmware $rootimg_dir/lib");
- }
-
- # if $ignorekernelchk is specified, copy all driver files to target kernel dir
- if ($ignorekernelchk) {
- my @kernelpath4vrpm = <$dd_dir/rpm/lib/modules/*>;
- foreach my $path (@kernelpath4vrpm) {
- if ($path eq "$dd_dir/rpm/lib/modules/$kernelver") {
- next;
- }
-
- unless (-d "$dd_dir/rpm/lib/modules/$kernelver") {
- mkpath "$dd_dir/rpm/lib/modules/$kernelver";
- }
- system("/bin/cp -rf $path/* $dd_dir/rpm/lib/modules/$kernelver");
- }
- }
-
- # Copy the drivers to the rootimage
- if (-d "$dd_dir/rpm/lib/modules/$kernelver") {
-
- #mkpath "$rootimg_dir/lib/modules/$kernelver/updates/";
- if (@driver_list) {
- foreach my $driver (@driver_list) {
- $driver_name = $driver;
- $real_path = "";
- find(\&get_path, <$dd_dir/rpm/lib/modules/$kernelver/*>);
- if ($real_path && $real_path =~ m!$dd_dir/rpm(/lib/modules/$kernelver/.*?)[^\/]*$!) {
-
- # remove the old one if existing
- @all_real_path = ();
- find(\&get_all_path, <$rootimg_dir/lib/modules/$kernelver/*>);
- foreach (@all_real_path) {
- if (-r $_) {
- unlink($_);
- }
- }
-
- if (!-d "$rootimg_dir$1") {
- mkpath "$rootimg_dir$1";
- }
- system("cp -rf $real_path $rootimg_dir$1");
- push @rpm_drivers, $driver;
- } else {
- print "Warning: cannot find the driver $driver from the driver rpms\n";
- }
- }
- } elsif ($Injectalldriver) {
-
- # copy all the drviers to the rootimage
- $driver_name = "\*\.ko";
- @all_real_path = ();
- find(\&get_all_path, <$dd_dir/rpm/lib/modules/$kernelver/*>);
- my @all_drivers = @all_real_path;
- foreach my $new_driver (@all_drivers) {
- if (basename($new_driver) =~ /\.ko$/) {
-
- # remove the old one if existing
- $driver_name = basename($new_driver);
- @all_real_path = ();
- find(\&get_all_path, <$rootimg_dir/lib/modules/$kernelver/*>);
- foreach my $old_driver (@all_real_path) {
- if (-r $old_driver) {
- unlink($old_driver);
- }
- }
- push @rpm_drivers, basename($new_driver);
- }
- }
-
- system("cp -rf $dd_dir/rpm/lib/modules/$kernelver $rootimg_dir/lib/modules/");
- }
- } else {
- print "Warning: cannot find the kernel $kernelver from drvier rpms\n";
- }
-
- push @dd_drivers, @rpm_drivers;
- }
-
- # Generate the dependency relationship
- system("chroot '$rootimg_dir' depmod $kernelver");
-
- # Clean the env
- rmtree "$dd_dir";
-
- return @dd_drivers;
-}
-
-sub usage {
- print 'Usage: genimage -o [-a ] -p -i -n [-r ] [-k ] [-g ] [-l rootlimitsize] [--permission ] [--interactive]' . "\n";
- print " --permission is used for statelite only\n";
- print "Examples:\n";
- print " genimage -i eth0 -n tg3 -o sles11 -p compute\n";
- print " genimage -i eth0 -r eth1,eth2 -n tg3,bnx2 -o sles11 -p compute --interactive\n";
- print " genimage -i eth0 -n tg3,bnx2 -o sles11 -p compute\n";
- print " genimage -i eth0 -n tg3,bnx2 -o sles11 -p compute --permission 777\n";
- return 0;
-}
-
diff --git a/xCAT-server/share/xcat/netboot/sle/compute.sle15.x86_64.exlist b/xCAT-server/share/xcat/netboot/sles/compute.sle15.exlist
similarity index 100%
rename from xCAT-server/share/xcat/netboot/sle/compute.sle15.x86_64.exlist
rename to xCAT-server/share/xcat/netboot/sles/compute.sle15.exlist
diff --git a/xCAT-server/share/xcat/netboot/sles/compute.sle15.pkglist b/xCAT-server/share/xcat/netboot/sles/compute.sle15.pkglist
new file mode 100644
index 000000000..ead89aa5e
--- /dev/null
+++ b/xCAT-server/share/xcat/netboot/sles/compute.sle15.pkglist
@@ -0,0 +1,48 @@
+aaa_base
+coreutils
+bash
+dbus
+wicked
+device-mapper
+dracut
+nfs-kernel-server
+keyutils
+lvm2
+openssl
+dhcp-client
+openssh
+procps
+psmisc
+wget
+sysconfig
+rsyslog
+vim
+rsync
+timezone
+bc
+ntp
+gzip
+e2fsprogs
+parted
+binutils
+tar
+open-iscsi
+curl
+plymouth
+btrfsprogs
+cryptsetup
+dmraid
+mdadm
+multipath-tools
+gpg2
+which
+cifs-utils
+open-lldp
+fcoe-utils
+util-linux-systemd
+plymouth-dracut
+udev
+kernel-default
+kernel-firmware
+adaptec-firmware
+xz
diff --git a/xCAT-server/share/xcat/netboot/sle/compute.sle15.x86_64.postinstall b/xCAT-server/share/xcat/netboot/sles/compute.sle15.postinstall
similarity index 100%
rename from xCAT-server/share/xcat/netboot/sle/compute.sle15.x86_64.postinstall
rename to xCAT-server/share/xcat/netboot/sles/compute.sle15.postinstall
diff --git a/xCAT-server/share/xcat/netboot/sle/compute.sle15.x86_64.pkglist b/xCAT-server/share/xcat/netboot/sles/compute.sle15.x86_64.pkglist
similarity index 92%
rename from xCAT-server/share/xcat/netboot/sle/compute.sle15.x86_64.pkglist
rename to xCAT-server/share/xcat/netboot/sles/compute.sle15.x86_64.pkglist
index cd5830aaf..93fbcf9b5 100644
--- a/xCAT-server/share/xcat/netboot/sle/compute.sle15.x86_64.pkglist
+++ b/xCAT-server/share/xcat/netboot/sles/compute.sle15.x86_64.pkglist
@@ -1,6 +1,10 @@
aaa_base
coreutils
bash
+dbus
+wicked
+device-mapper
+dracut
nfs-kernel-server
keyutils
lvm2
diff --git a/xCAT-server/share/xcat/netboot/sles/dracut_033/install.netboot b/xCAT-server/share/xcat/netboot/sles/dracut_033/install.netboot
index 79f85312e..d98aa6c54 100755
--- a/xCAT-server/share/xcat/netboot/sles/dracut_033/install.netboot
+++ b/xCAT-server/share/xcat/netboot/sles/dracut_033/install.netboot
@@ -1,7 +1,7 @@
#!/bin/sh
echo $drivers
dracut_install wget tar cpio gzip modprobe touch echo cut wc xz
-dracut_install grep ifconfig hostname awk egrep grep dirname expr
+dracut_install grep ifconfig ip hostname awk egrep grep dirname expr
dracut_install mount.nfs
dracut_install parted mke2fs bc mkswap swapon chmod
inst "$moddir/xcat-updateflag" "/tmp/updateflag"
diff --git a/xCAT-server/share/xcat/netboot/sles/dracut_033/install.statelite b/xCAT-server/share/xcat/netboot/sles/dracut_033/install.statelite
index 2c00d3ec8..ccbdc49cf 100755
--- a/xCAT-server/share/xcat/netboot/sles/dracut_033/install.statelite
+++ b/xCAT-server/share/xcat/netboot/sles/dracut_033/install.statelite
@@ -1,7 +1,7 @@
#!/bin/sh
echo $drivers
dracut_install wget cpio gzip modprobe wc touch echo cut
-dracut_install grep ifconfig hostname awk egrep grep dirname expr logger
+dracut_install grep ifconfig ip hostname awk egrep grep dirname expr logger
dracut_install parted mke2fs bc mkswap swapon chmod
inst "$moddir/xcat-updateflag" "/tmp/updateflag"
inst_hook pre-mount 5 "$moddir/xcat-premount.sh"
diff --git a/xCAT-server/share/xcat/netboot/sles/genimage b/xCAT-server/share/xcat/netboot/sles/genimage
index 5e241ea7d..c4ace26c9 100755
--- a/xCAT-server/share/xcat/netboot/sles/genimage
+++ b/xCAT-server/share/xcat/netboot/sles/genimage
@@ -264,11 +264,17 @@ unless ($onlyinitrd) {
# To support multiple paths for osimage.pkgdir
foreach $dir (@pkgdirs) {
+ my $ddir = $dir;
if (-d "$dir/1") {
- $dir .= "/1";
+ $ddir .= "/1";
}
- system("zypper -R $rootimg_dir $non_interactive ar file:$dir $osver-$i");
+ system("zypper -R $rootimg_dir $non_interactive ar file:$ddir $osver-$i");
$i++;
+ if (-d "$dir/2") {
+ $ddir = $dir . "/2";
+ system("zypper -R $rootimg_dir $non_interactive ar file:$ddir $osver-$i");
+ $i++;
+ }
}
#if(-e "$rootimg_dir/etc/zypp/repos.d/$osver.repo") {
diff --git a/xCAT-server/share/xcat/netboot/sle/service.sle15.x86_64.otherpkgs.pkglist b/xCAT-server/share/xcat/netboot/sles/service.sle15.otherpkgs.pkglist
similarity index 100%
rename from xCAT-server/share/xcat/netboot/sle/service.sle15.x86_64.otherpkgs.pkglist
rename to xCAT-server/share/xcat/netboot/sles/service.sle15.otherpkgs.pkglist
diff --git a/xCAT-server/share/xcat/netboot/sle/service.sle15.pkglist b/xCAT-server/share/xcat/netboot/sles/service.sle15.pkglist
similarity index 100%
rename from xCAT-server/share/xcat/netboot/sle/service.sle15.pkglist
rename to xCAT-server/share/xcat/netboot/sles/service.sle15.pkglist
diff --git a/xCAT-server/share/xcat/netboot/sle/service.sle15.postinstall b/xCAT-server/share/xcat/netboot/sles/service.sle15.postinstall
similarity index 100%
rename from xCAT-server/share/xcat/netboot/sle/service.sle15.postinstall
rename to xCAT-server/share/xcat/netboot/sles/service.sle15.postinstall
diff --git a/xCAT-server/share/xcat/netboot/sles/service.sle15.x86_64.otherpkgs.pkglist b/xCAT-server/share/xcat/netboot/sles/service.sle15.x86_64.otherpkgs.pkglist
new file mode 100644
index 000000000..7fe170d23
--- /dev/null
+++ b/xCAT-server/share/xcat/netboot/sles/service.sle15.x86_64.otherpkgs.pkglist
@@ -0,0 +1,3 @@
+-perl-doc
+xcat/xcat-core/xCATsn
+xcat/xcat-dep/sles12/x86_64/conserver-xcat