summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--scripts/mk-rescueimage.ppc141
2 files changed, 146 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 9069f1ac7..312e38578 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-01-05 Jeremy Katz <katzj@redhat.com>
+
+ * scripts/mk-rescueimage.ppc: Add ppc rescue image script from
+ jkeating (#177003)
+
2006-01-05 David Cantrell <dcantrell@redhat.com>
* iw/progress_gui.py (InstallProgressWindow_NEW.getScreen): Realign
diff --git a/scripts/mk-rescueimage.ppc b/scripts/mk-rescueimage.ppc
new file mode 100644
index 000000000..c9d90493f
--- /dev/null
+++ b/scripts/mk-rescueimage.ppc
@@ -0,0 +1,141 @@
+#!/usr/bin/python
+#
+# mk-rescueimage.ppc - builds a rescue image from an existing tree
+# which can be converted into a yaboot bootable
+# iso and used as a sysadmin rescue image.
+#
+#
+# Usage: mk-rescueimage.ppc <src-tree> <dest-dir> <productname>
+#
+# the rescue image will be created as <dest-dir>/ppc-rescueimage
+#
+
+import os
+import sys
+import string
+
+def usage():
+ print "usage: mk-rescueimage.ppc <toplevel> <dest-dir> <productname> [<productpath>]"
+ sys.exit(0)
+
+
+if len(sys.argv) < 5:
+ usage()
+ sys.exit(1)
+
+if not os.access("%s/ppc" % (sys.argv[2],), os.F_OK):
+ print "ERROR - Destination directory %s does not contain a ppc directory!" % (sys.argv[2],)
+ sys.exit(1)
+
+srcdir = sys.argv[1]
+destdir = sys.argv[2]+"/ppc-rescueimage"
+productname = sys.argv[3]
+
+if len(sys.argv) > 4:
+ productpath = sys.argv[4]
+
+# clean and create destination directory
+os.system("rm -rf %s" % (destdir,))
+os.system("mkdir %s" % (destdir,))
+
+# copy documentation
+for pat in ["*eula*", "*EULA*", "README*", "RELEASE*", "GPL", "RPM-*"]:
+ os.system("cp -p %s/%s %s/ 2>/dev/null" % (srcdir, pat, destdir))
+
+# cp yaboot files
+os.system("cp -a %s/ppc %s/" % (srcdir, destdir))
+os.system("cp -a %s/etc %s/" % (srcdir, destdir))
+
+# cp stage image
+os.system("mkdir -p %s/%s/base" % (destdir, productpath))
+os.system("cp -a %s/%s/base/stage2.img %s/%s/base" % (srcdir, productpath, destdir, productpath))
+
+for arch in ("ppc32", "ppc64"):
+ # munge various yaboot configs to have a default of rescue mode
+ cfgfile = open("%s/ppc/%s/yaboot.conf" % (destdir, arch), "r")
+ cfglines = cfgfile.readlines()
+ cfgfile.close()
+
+ # backup old one
+ os.system("cp %s/ppc/%s/yaboot.conf %s/ppc/%s/yaboot.conf.backup" % (destdir, arch, destdir, arch))
+
+ cfgfile = open("%s/ppc/%s/yaboot.conf" % (destdir, arch), "w+")
+ fndit = 0
+ for l in cfglines:
+ if string.find(l, "Welcome") != -1:
+ cfgfile.write(l.replace("installer", "rescue"))
+ continue
+ if string.find(l, "default=") != -1:
+ cfgfile.write("default=rescue\n")
+ continue
+ # see if we're into the stanza now
+ elif string.find(l, "image=") != -1:
+ fndit = 1
+ # build up the rescue stanza based on whats in the
+ # default stanza as we echo it out
+ rescuestanza = l + " label=rescue\n"
+ # if we fall through then write it out
+ cfgfile.write(l)
+ else:
+ # we're writing out the matching stanza - if we hit the append
+ # line put rescue on the end of it, otherwise just echo line
+ if fndit:
+ if string.find(l, "read-only") != -1:
+ rescuestanza = rescuestanza + l + " append=rescue\n"
+ else:
+ if not string.find(l, "label=") != -1:
+ rescuestanza = rescuestanza + l
+ cfgfile.write(l)
+
+ if fndit:
+ cfgfile.write('\n' + rescuestanza)
+
+ cfgfile.close()
+
+ if not fndit:
+ print "Could not find default stanza, did not modify yaboot.conf"
+ os.system("mv -f %s/ppc/%s/yaboot.conf.backup %s/ppc/%s/yaboot.conf" % (destdir, arch, destdir, arch))
+ else:
+ os.system("rm -f %s/ppc/%s/yaboot.conf.backup" % (destdir, arch))
+
+# Modify top level yaboot to indicate rescue CD instead of install CD
+#
+
+cfgfile = open("%s/etc/yaboot.conf" % (destdir,), "r")
+cfglines = cfgfile.readlines()
+cfgfile.close()
+
+cfgfile = open("%s/etc/yaboot.conf" % (destdir,), "w")
+
+origlines = ''
+rescuelines = ''
+
+# do some inline replacements of text
+for l in cfglines:
+ if l.find("init-message") != -1:
+ entry = cfglines.index(l)
+ cfglines[entry] = cfglines[entry].replace("installer", "rescue")
+ cfglines[entry] = cfglines[entry].replace("linux32", "rescue32")
+ continue
+ if l.find("default=") != -1:
+ cfglines[cfglines.index(l)] = l.replace("linux", "rescue")
+ continue
+ if l.find("image=/ppc/ppc64") != -1:
+ origlines = cfglines[cfglines.index(l):]
+ break
+
+# create a big string that is easier to do replacements on
+for l in origlines:
+ rescuelines += l
+
+# Do replacements on the big string
+rescuelines = rescuelines.replace("label=linux64", "label=rescue64")
+rescuelines = rescuelines.replace("alias=linux", "alias=rescue")
+rescuelines = rescuelines.replace("label=linux32", "label=rescue32")
+rescuelines = rescuelines.replace("read-only", "read-only\n append=rescue")
+
+for l in cfglines:
+ cfgfile.write(l)
+
+cfgfile.write('\n' + rescuelines)
+