diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2012-02-14 23:55:14 +0400 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2012-02-14 23:55:14 +0400 |
commit | a677850ad6f94d03ab2805b1d1a4c28e6be01c11 (patch) | |
tree | 6918fe604e348d1a24402a61bef7bcde17e620b7 | |
parent | 4e4bac54d5cb392c9853f5e565281f44c3843c17 (diff) | |
download | live-a677850ad6f94d03ab2805b1d1a4c28e6be01c11.tar.gz |
VERY dirty solutions, but LiveCD does boot!
-rwxr-xr-x | find-usr | 41 | ||||
-rwxr-xr-x | protostar | 159 |
2 files changed, 129 insertions, 71 deletions
@@ -1,25 +1,46 @@ -#!/bin/bash +#!/sbin/sh set -e set -u -MOUNTPOINT="/.cdrom" +MOUNTPOINT="/cdrom" +USR='USR_IMG' -drives=$(iostat -xnr | awk -F, '{print $NF}') +# First, remount / read-write to update /dev +mount -o remount / -for d in $drives; do - dfile="/dev/dsk/${d}s2" +# Second, update /dev +devfsadm -C -c disk + +# Now, search removable media for $USR +found='no' +for dfile in /dev/removable-media/dsk/*s2; do + # dfile="/dev/dsk/${d}" if [ -e "$dfile" ]; then echo "Probing \`$dfile' ..." if mount -F hsfs -o ro "$dfile" "${MOUNTPOINT}" ; then - echo "Successfully mounted." - ls -lh "${MOUNTPOINT}" - umount "${MOUNTPOINT}" - exit 0 + if [ -f "${MOUNTPOINT}/${USR}" ]; then + found='yes' + echo "Found ${USR}" + break + else + echo "${USR} not found" + umount "${MOUNTPOINT}" + fi else - echo "mount failed." + echo "Failed to mount \`$dfile'" fi fi done +if [ "$found" != 'yes' ]; then + echo "$USR not found" + exit 1 +fi + + +usrlofidev=`lofiadm -a "${MOUNTPOINT}/${USR}"` +echo "Mounting \`${MOUNTPOINT}/${USR}' on /usr using \`$usrlofidev' ..." +mount -F hsfs -o ro -O $usrlofidev /usr + exit 0 @@ -1,7 +1,4 @@ -#!/usr/bin/bash - -# TODO: -# 2. Find and mount usr.lzma +#!/bin/bash set -e @@ -12,28 +9,29 @@ TMP="${TMP:-/tmp}" DATE=$(date '+%Y-%m-%d-%H%M') DIST="${DIST:-bok}" REPO="${REPO:-http://apt.osdyson.org}" -BOOTARCH_SIZE="${BOOTARCH_SIZE:-300}" # Megabytes +REPO="file:///repo/" + +# We will search for usr archive on CD: +USR_IMG=usr.img.$(echo $DATE | md5sum | cut -f1 -d ' ') ISONAME="${ISONAME:-dyson-${DIST}-${DATE}}.iso" ROOT="${TMP}/ROOT" -BOOTARCH_FILE="${ROOT}/boot_archive" -BOOTARCH="${ROOT}/boot_archive.mount" +BOOTARCH="${ROOT}/boot_archive" if [ -z "${ROOT}" ] || [ "${ROOT}" = / ]; then echo "WTF? Bad root: \`${ROOT}'" >&2 exit 1 fi - +echo "Preparing base system (debootstrap)..." debootstrap \ --no-check-gpg \ - --exclude=syslogd,bootadm \ - --include=illumos-grub,illumos-kernel \ + --exclude=syslogd,gawk \ + --include=illumos-grub,illumos-kernel,ufsutils \ "${DIST}" \ "${ROOT}" \ - "${REPO}" - + "${REPO}" >/dev/null # This stuff does not make sense for LiveCD: rm -rf "${ROOT}"/var/lib/dpkg/info @@ -41,6 +39,7 @@ rm -rf "${ROOT}"/var/cache/* rm -rf "${ROOT}"/etc/cron.* rm -rf "${ROOT}"/var/log/* rm -rf "${ROOT}"/var/adm/* +rm -rf "${ROOT}"/usr/share/doc/* devfsadm -r "${ROOT}" @@ -52,9 +51,10 @@ cat <<VFSTAB > $ROOT/etc/vfstab /proc - /proc proc - no - ctfs - /system/contract ctfs - no - objfs - /system/object objfs - no - -sharefs - /etc/dfs/sharetab sharefs - no - +sharefs - /etc/dfs/sharetab sharefs - no - fd - /dev/fd fd - no - swap - /tmp tmpfs - yes - +/devices/ramdisk:a - / ufs 1 no rw,nologging VFSTAB @@ -65,101 +65,138 @@ touch "${ROOT}/etc/hostname.e1000g0" touch "${ROOT}/etc/dhcp.e1000g0" echo '127.0.0.1 localhost loghost' > "${ROOT}/etc/inet/hosts" +# Hack to know root password: +sed -i '/^root/d' $ROOT/etc/shadow +grep root /etc/shadow >> $ROOT/etc/shadow + +# Script to find and mount usr.lzma: +sed "s/USR_IMG/$USR_IMG/" "find-usr" > "${ROOT}/lib/svc/method/find-usr" +chmod +x "${ROOT}/lib/svc/method/find-usr" +sed -i '/readvfstab "\/usr"/i bash /lib/svc/method/find-usr >/dev/msglog 2>&1' \ + "${ROOT}/lib/svc/method/fs-root" + +# WE DON"T NEED BOOTARCHIVE ON LIVECD. +# Thank you! +sed -i '/if \[ -f "${UPDATEFILE}" \]; then/ i exit $SMF_EXIT_OK' \ + "${ROOT}/lib/svc/method/fs-usr" echo "Importing manifests..." -rm "${ROOT}/lib/svc/manifest/system/early-manifest-import.xml" || true +rm "${ROOT}/lib/svc/manifest/system/early-manifest-import.xml" +#rm "${ROOT}/lib/svc/manifest/system/manifest-import.xml" bash "${ROOT}/lib/svc/method/manifest-import" \ -f "${ROOT}/etc/svc/repository.db" \ -d "${ROOT}/lib/svc/manifest" -echo "Making boot archive..." -rm -f "${BOOTARCH_FILE}" -dd if=/dev/zero of="${BOOTARCH_FILE}" bs=1M count="${BOOTARCH_SIZE}" -lofidev=$(lofiadm -a "${BOOTARCH_FILE}") -rlofidev="${lofidev/lofi/rlofi}" -yes | newfs -m 0 "${rlofidev}" mkdir -p "${BOOTARCH}" -mount -o nologging "${lofidev}" "${BOOTARCH}" - -( cd "${BOOTARCH}" -mkdir -p mnt proc tmp usr var/run .cdrom -chmod 1777 tmp -chmod 0555 proc -ln -sf usr/bin bin -ln -sf var/run run -) +mkdir -p "${BOOTARCH}/usr" +mkdir -p "${BOOTARCH}/cdrom" ( cd "${ROOT}" -cp -rP --preserve=timestamps,links \ - boot \ - dev \ - devices \ - etc \ - kernel \ - lib \ - platform \ - root \ - sbin \ - system \ - var \ - "${BOOTARCH}" - -rm -rf \ +# List here files or directories which +# should be *moved* to boot archive. +# Caution: files from /usr require +# special treating: see below. +tar --remove-files -c -f - \ + boot/solaris/devicedb/master \ + bin \ dev \ devices \ etc \ + home \ kernel \ lib \ + media \ mnt \ + opt \ proc \ root \ run \ sbin \ + srv \ system \ tmp \ - var + var \ +| tar xf - -C "${BOOTARCH}" -find platform -type f -a ! -name unix | xargs rm -f +# same, but keep source +tar -c -f - \ + platform \ + usr/bin/bash \ + usr/bin/cat \ + usr/bin/dash \ + usr/bin/ls \ + usr/bin/sh \ + usr/lib/fs \ + usr/lib/devfsadm \ + usr/sbin \ +| tar xf - -C "${BOOTARCH}" + + +# We need only kernel itself for GRUB. +# BTW, kernel should be in boot archive as well (WTF?) +find platform -type f -a ! -name unix -delete ) -umount "${BOOTARCH}" -lofiadm -d "${BOOTARCH_FILE}" -rmdir "${BOOTARCH}" -gzip -9 -f "${BOOTARCH_FILE}" -mv "${BOOTARCH_FILE}.gz" "${ROOT}/boot/" +find "${BOOTARCH}" > bootarch.list +echo "Making boot archive..." +sync; sync -echo "Making usr archive..." -( cd "${ROOT}" +if false; then +genisoimage \ + -o "${ROOT}/boot/boot_archive" \ + -N -l -R -U \ + -allow-multidot \ + -quiet -no-iso-translate -cache-inodes -d -D \ + -V "root" \ + "${BOOTARCH}" +else + size=$(du -s -m "${BOOTARCH}" | cut -f1) + dd if=/dev/zero of="${ROOT}/boot/boot_archive" bs=1M count="$size" + lofidev=$(lofiadm -a "${ROOT}/boot/boot_archive") + rlofidev="${lofidev/lofi/rlofi}" + yes | newfs -m 0 "${rlofidev}" + mkdir -p "${ROOT}/boot/boot_archive.mount" + mount "${lofidev}" "${ROOT}/boot/boot_archive.mount" + mv "${BOOTARCH}"/* "${ROOT}/boot/boot_archive.mount"/ + umount "${ROOT}/boot/boot_archive.mount" + lofiadm -d "${lofidev}" + rmdir "${BOOTARCH}" + rmdir "${ROOT}/boot/boot_archive.mount" +fi +gzip -9 -f "${ROOT}/boot/boot_archive" + +echo "Making usr archive..." # usr will be mounted from usr.lzma: -rm -f usr.lzma genisoimage \ - -o usr.lzma \ + -o "${ROOT}/${USR_IMG}" \ -N -l -R -U \ -allow-multidot \ -quiet -no-iso-translate -cache-inodes -d -D \ -V "usr" \ - usr + "${ROOT}/usr" + +rm -rf "${ROOT}/usr" +lofiadm -C lzma "${ROOT}/${USR_IMG}" -rm -rf usr -lofiadm -C lzma usr.lzma -) +echo "Configuring GRUB..." cat <<GRUB > "${ROOT}/boot/grub/menu.lst" default=0 timeout=3 splashimage=/boot/grub/splash.xpm.gz foreground=ffffff background=215ECA -title Dyson Live (amd64) - kernel$ /platform/i86pc/kernel/amd64/unix -k +title Hello! + kernel$ /platform/i86pc/kernel/amd64/unix -k -m verbose module$ /boot/boot_archive.gz GRUB +echo "Making final ${ISONAME}..." genisoimage \ -o "${ISONAME}" \ -b boot/grub/stage2_eltorito \ |