bootdisk: installer-functions (HEAD) [malekith]

PLD CVS pld-cvs-commit w pld.org.pl
Pon, 29 Lip 2002, 13:06:16 CEST


Module name:	bootdisk
Changes by:	malekith	02/07/29 13:06:14

Modified files:
	installer-functions

Log message:
- new functions:
  - has_rpm()
  - parse_boot_loader_entry()
  - is_mini_iso()
  - count_cpus()
  - is_smp()

Index: installer-functions
===================================================================
RCS file: /cvsroot/bootdisk/batch-installer/installer-functions,v
diff -d -u -r1.51 -r1.52
--- installer-functions	2002/04/06 11:44:43	1.51
+++ installer-functions	2002/07/29 11:06:13	1.52
@@ -171,8 +171,16 @@
     fi
 }
 
-add_rpm () {
+has_rpm () {
   if grep -q "^${1}\$" $pkgsfile ; then
+    return 0
+  else
+    return 1
+  fi
+}
+
+add_rpm () {
+  if has_rpm $1 ; then
     : ok
   else
     # check to see if there is final newline in the file...
@@ -499,6 +507,67 @@
 
 load_var () { 
   eval "$1=\`cat /tmp/saved-var-$1\`"
+}
+
+# usage: eval $(parse_boot_loader_entry "$ble")
+parse_boot_loader_entry () {
+  entry="$1"
+  echo "$entry" | (
+    kernel=
+    initrd=
+    IFS=:
+    case "$entry" in
+      linux:*:*:*:* )
+	read kind label kernel initrd root
+        ;;
+      linux:*:*:* )
+        read kind label kernel root
+	;;
+      bsd:* | dos:* )
+	read kind label root
+	;;
+      * )
+	kind=evil
+	root=
+	label=
+	;;
+    esac
+    echo "img_os=$kind img_label=$label img_root=$root img_initrd=$initrd"
+    echo "img_kernel=$kernel"
+  )
+}
+
+is_mini_iso () {
+  case "$source" in
+    cdrom )
+      if test -f /src/pld-*-MINI ; then
+        return 0
+      fi
+      ;;
+  esac
+  return 1
+}
+
+count_cpus () {
+  if echo "$pkgs_cpus" | grep -q '^[0-9][0-9]*$' ; then
+    echo $pkgs_cpus
+  else
+    # uh... there is no wc on bootdisk
+    echo $(grep '^processor[ 	]*:' /proc/cpuinfo | (
+      count=0
+      while read LINE ; do
+        count=$(($count+1))
+      done
+      echo $count))
+  fi
+}
+
+is_smp () {
+  if [ $(count_cpus) -gt 1 ] ; then
+    return 0
+  else
+    return 1
+  fi
 }
 
 export ASH_REPORT_EFLAG=1



Więcej informacji o liście dyskusyjnej pld-installer