diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2012-02-12 19:23:20 +0400 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2012-02-12 19:23:20 +0400 |
commit | 4e4bac54d5cb392c9853f5e565281f44c3843c17 (patch) | |
tree | 34dd477931d9eab22d29f07b115433369504dfc0 /protostar | |
download | live-4e4bac54d5cb392c9853f5e565281f44c3843c17.tar.gz |
Initial import, protostar creates ISO, but it cannot mount usr yet, find-usr searchs media for usr image
Diffstat (limited to 'protostar')
-rwxr-xr-x | protostar | 181 |
1 files changed, 181 insertions, 0 deletions
diff --git a/protostar b/protostar new file mode 100755 index 0000000..85bc87b --- /dev/null +++ b/protostar @@ -0,0 +1,181 @@ +#!/usr/bin/bash + +# TODO: +# 2. Find and mount usr.lzma + + +set -e +set -u + +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 + +ISONAME="${ISONAME:-dyson-${DIST}-${DATE}}.iso" + +ROOT="${TMP}/ROOT" +BOOTARCH_FILE="${ROOT}/boot_archive" +BOOTARCH="${ROOT}/boot_archive.mount" + +if [ -z "${ROOT}" ] || [ "${ROOT}" = / ]; then + echo "WTF? Bad root: \`${ROOT}'" >&2 + exit 1 +fi + + +debootstrap \ + --no-check-gpg \ + --exclude=syslogd,bootadm \ + --include=illumos-grub,illumos-kernel \ + "${DIST}" \ + "${ROOT}" \ + "${REPO}" + + +# This stuff does not make sense for LiveCD: +rm -rf "${ROOT}"/var/lib/dpkg/info +rm -rf "${ROOT}"/var/cache/* +rm -rf "${ROOT}"/etc/cron.* +rm -rf "${ROOT}"/var/log/* +rm -rf "${ROOT}"/var/adm/* + +devfsadm -r "${ROOT}" + +cat <<VFSTAB > $ROOT/etc/vfstab +#device device mount FS fsck mount mount +#to mount to fsck point type pass at boot options +# +/devices - /devices devfs - no - +/proc - /proc proc - no - +ctfs - /system/contract ctfs - no - +objfs - /system/object objfs - no - +sharefs - /etc/dfs/sharetab sharefs - no - +fd - /dev/fd fd - no - +swap - /tmp tmpfs - yes - + +VFSTAB + +echo 'export LD_NOVERSION=1' >> $ROOT/etc/profile + +echo 'dyson-live' > "${ROOT}/etc/nodename" +touch "${ROOT}/etc/hostname.e1000g0" +touch "${ROOT}/etc/dhcp.e1000g0" +echo '127.0.0.1 localhost loghost' > "${ROOT}/etc/inet/hosts" + + +echo "Importing manifests..." +rm "${ROOT}/lib/svc/manifest/system/early-manifest-import.xml" || true +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 +) + +( cd "${ROOT}" + +cp -rP --preserve=timestamps,links \ + boot \ + dev \ + devices \ + etc \ + kernel \ + lib \ + platform \ + root \ + sbin \ + system \ + var \ + "${BOOTARCH}" + +rm -rf \ + dev \ + devices \ + etc \ + kernel \ + lib \ + mnt \ + proc \ + root \ + run \ + sbin \ + system \ + tmp \ + var + +find platform -type f -a ! -name unix | xargs rm -f +) + +umount "${BOOTARCH}" +lofiadm -d "${BOOTARCH_FILE}" +rmdir "${BOOTARCH}" +gzip -9 -f "${BOOTARCH_FILE}" +mv "${BOOTARCH_FILE}.gz" "${ROOT}/boot/" + + +echo "Making usr archive..." +( cd "${ROOT}" + +# usr will be mounted from usr.lzma: +rm -f usr.lzma +genisoimage \ + -o usr.lzma \ + -N -l -R -U \ + -allow-multidot \ + -quiet -no-iso-translate -cache-inodes -d -D \ + -V "usr" \ + usr + +rm -rf usr +lofiadm -C lzma usr.lzma +) + +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 + module$ /boot/boot_archive.gz + +GRUB + +genisoimage \ + -o "${ISONAME}" \ + -b boot/grub/stage2_eltorito \ + -c .catalog \ + -no-emul-boot \ + -boot-load-size 4 \ + -boot-info-table \ + -N -l -R -U \ + -allow-multidot \ + -no-iso-translate \ + -cache-inodes \ + -d -D \ + -V "${ISONAME}" \ + "${ROOT}" + +ls -lh "${ISONAME}" + +exit 0 + |