mirror of the now-defunct rocklinux.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

142 lines
3.7 KiB

  1. #!/bin/bash
  2. #
  3. # Commands in isofs.txt files:
  4. #
  5. # EVERY from to Put this on every disk
  6. # DISK1 from to Put this on the 1st disk
  7. # SINGLE from to Put it on any disk
  8. # SPLIT from to You may split it up over many disks
  9. #
  10. # BOOT boot-options Add this mkisofs options for 1st disk
  11. #
  12. # If you want to add multiple 'BOOT' lines, use the tag-name 'BOOTx' for
  13. # the 2nd and all further lines.
  14. #
  15. # SCRIPT script-name args Run given script for each image
  16. #
  17. # Intended for image post-processing. The first attached argument is the CD
  18. # number and the second the image file.
  19. #
  20. cleanup () {
  21. # Cleanup used for EXIT
  22. umount $mountpoint
  23. rmdir -p $mountpoint
  24. losetup -d $loopdevice
  25. }
  26. eval `grep rockver scripts/parse-config`
  27. if [ $# -eq 0 ] ; then
  28. echo
  29. echo "Usage: $0 [ -size MB ] [ -mkdebug ] [-prefix FS-Prefix] [-fs filesystem] Config"
  30. echo
  31. echo "E.g.: $0 -prefix my myconfig"
  32. echo "this will leave you with a file 'my_linux' (the kernel) and a file"
  33. echo "'my_rootfs' (the file system). Just start it with ./linux"
  34. echo
  35. exit 1
  36. fi
  37. src=0; mkdebug=0; fssize=0; full=0;
  38. filesystem="reiserfs"
  39. while true ; do
  40. case "$1" in
  41. -size)
  42. fssize=$2 ; shift ; shift ;;
  43. -mkdebug)
  44. mkdebug=1 ; shift ;;
  45. -fs)
  46. filesystem=$2; shift; shift ;;
  47. -prefix)
  48. ufsprefix=$2; shift; shift ;;
  49. -full)
  50. full=1; shift ;;
  51. -* | '')
  52. $0 ; exit 1 ;;
  53. *)
  54. cfg=$1 ; shift ; break ;;
  55. esac
  56. done
  57. if [ ! "x$ufsprefix" = "x" ]; then fsprefix=${ufsprefix}_; else fsprefix=""; fi
  58. if [ -f ${fsprefix}rootfs -o -f ${fsprefix}linux ]; then
  59. echo "Sorry, there exists a file with the same name, please make sure"
  60. echo "that no ${fsprefix}linux and no ${fsprefix}rootfs exist here."
  61. exit 1
  62. fi
  63. # get the build id
  64. if [ ! -d config/$cfg ]; then
  65. echo "I cannot find the selected Config '$cfg'!"
  66. exit 1
  67. fi
  68. buildid="`grep '^export ROCKCFG_ID=' config/$cfg/config | cut -f2 -d\'`"
  69. if [ ! -d build/$buildid ]; then
  70. echo "I cannot find the build for the Config '$cfg' (build/$buildid)"
  71. exit 1;
  72. fi
  73. # check if there is a kernel executable
  74. if [ ! -f build/$buildid/boot/linux -o "x" = "x$(grep UMLPATCH=\'1\' config/$cfg/config)" ]; then
  75. echo "I cannot find the executable kernel, "
  76. echo "or it seems that the UML Patch was not applied to the kernel."
  77. exit 1;
  78. fi
  79. # calculate the default disk size as all packages of that config + 1/3 of the same
  80. if [ $fssize = 0 ]; then
  81. echo "Calculating optimal image size, may take some time ..."
  82. cfssize=$(cd build/$buildid; du -sm --exclude ROCK | awk '{print $1;}';cd $OLDPWD)
  83. echo "All packages consume $cfssize MB"
  84. freespace=$(( $cfssize / 3 ))
  85. fssize=$(( $cfssize + $freespace ))
  86. echo "Therefore I propose a fs size of $fssize, that leaves you $freespace MB of free space."
  87. fi
  88. # check if there is enough disk space
  89. hereiskbfree=$(df -P $PWD | tail -n 1 | awk '{ print $4; }')
  90. hereismbfree=$(( $hereiskbfree / 1024 ))
  91. if [ $hereismbfree -lt $fssize ]; then
  92. echo "Sorry, you have only $hereismbfree MB free here, "
  93. echo "that is not enough for a rootfs of $fssize MB."
  94. exit 1
  95. fi
  96. # create the empty rootfs file
  97. dd if=/dev/zero of=${fsprefix}rootfs seek=${fssize} count=1 bs=1M
  98. trap 'cleanup' EXIT
  99. # find a free loop device
  100. for i in `ls /dev/loop/*`; do
  101. echo $i
  102. losetup $i ${fsprefix}rootfs
  103. if [ $? = 0 ]; then
  104. loopdevice=$i
  105. break
  106. fi
  107. done
  108. # make a filesystem
  109. yes | mkfs -t $filesystem $loopdevice
  110. # loop-mount the file
  111. mountpoint=${fsprefix}rootfs_mnt
  112. mkdir -p $mountpoint
  113. mount -t $filesystem $loopdevice $mountpoint
  114. # install all
  115. echo "Installing files, may take some time..."
  116. if [ $full = 1 ]; then
  117. for i in build/$buildid/*; do
  118. if [ $i = "build/$buildid/ROCK" ]; then continue; fi
  119. cp -rp $i $mountpoint
  120. done
  121. fi
  122. # Copy the executable kernel
  123. cp $mountpoint/boot/linux ${fsprefix}linux