From 9fc9e2a1a11b0edada38cb501fefe4f58aa414ac Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 23 Sep 2007 14:46:36 +0200 Subject: Adding live-initramfs 1.87.2-1. --- bin/casper-getty | 15 - bin/casper-login | 6 - bin/casper-preseed | 19 - bin/casper-reconfigure | 52 --- bin/casper-snapshot | 299 ------------- bin/live-getty | 20 + bin/live-login | 12 + bin/live-md5check/Makefile | 9 + bin/live-md5check/live-md5check.c | 270 ++++++++++++ bin/live-md5check/md5.c | 381 ++++++++++++++++ bin/live-md5check/md5.h | 91 ++++ bin/live-preseed | 19 + bin/live-reconfigure | 52 +++ bin/live-snapshot | 299 +++++++++++++ casper-md5check/Makefile | 9 - casper-md5check/casper-md5check.c | 270 ------------ casper-md5check/md5.c | 381 ---------------- casper-md5check/md5.h | 91 ---- casper.conf | 8 - caspermon/GNOME_PythonAppletCasper.server | 30 -- caspermon/caspermon-applet | 75 ---- caspermon/caspermond | 9 - conf/live.conf | 9 + debian/changelog | 6 + debian/copyright | 2 +- debian/dirs | 2 +- debian/examples | 2 +- debian/init | 12 +- debian/install | 10 +- debian/links | 4 +- debian/manpage/casper-snapshot.1 | 70 --- debian/manpage/casper.7 | 84 ---- debian/manpages | 2 +- debian/rules | 13 +- doc/ChangeLog | 28 ++ hooks/casper | 75 ---- hooks/live | 75 ++++ manpages/live-initramfs.7 | 84 ++++ manpages/live-snapshot.1 | 70 +++ scripts/casper | 549 ------------------------ scripts/casper-bottom/01integrity_check | 18 - scripts/casper-bottom/02_timezone | 21 - scripts/casper-bottom/05mountpoints | 27 -- scripts/casper-bottom/10adduser | 66 --- scripts/casper-bottom/12fstab | 31 -- scripts/casper-bottom/13swap | 44 -- scripts/casper-bottom/14locales | 63 --- scripts/casper-bottom/15autologin | 62 --- scripts/casper-bottom/18hostname | 38 -- scripts/casper-bottom/19keyboard | 70 --- scripts/casper-bottom/20xconfig | 61 --- scripts/casper-bottom/22gnome_panel_data | 34 -- scripts/casper-bottom/22screensaver | 30 -- scripts/casper-bottom/23etc_modules | 30 -- scripts/casper-bottom/23networking | 107 ----- scripts/casper-bottom/24preseed | 50 --- scripts/casper-bottom/25configure_init | 58 --- scripts/casper-bottom/30accessibility | 106 ----- scripts/casper-bottom/31disable_update_notifier | 34 -- scripts/casper-bottom/32disable_hibernation | 36 -- scripts/casper-bottom/33enable_apport_crashes | 28 -- scripts/casper-bottom/34disable_kwallet | 25 -- scripts/casper-bottom/35fix_language_selector | 32 -- scripts/casper-bottom/40install_driver_updates | 40 -- scripts/casper-bottom/41apt_cdrom | 24 -- scripts/casper-functions | 21 - scripts/casper-helpers | 197 --------- scripts/casper-premount/10driver_updates | 163 ------- scripts/live | 549 ++++++++++++++++++++++++ scripts/live-bottom/01integrity_check | 18 + scripts/live-bottom/02_timezone | 21 + scripts/live-bottom/05mountpoints | 27 ++ scripts/live-bottom/10adduser | 66 +++ scripts/live-bottom/12fstab | 31 ++ scripts/live-bottom/13swap | 44 ++ scripts/live-bottom/14locales | 63 +++ scripts/live-bottom/15autologin | 62 +++ scripts/live-bottom/18hostname | 38 ++ scripts/live-bottom/19keyboard | 70 +++ scripts/live-bottom/20xconfig | 61 +++ scripts/live-bottom/22gnome_panel_data | 34 ++ scripts/live-bottom/22screensaver | 30 ++ scripts/live-bottom/23etc_modules | 30 ++ scripts/live-bottom/23networking | 107 +++++ scripts/live-bottom/24preseed | 50 +++ scripts/live-bottom/25configure_init | 58 +++ scripts/live-bottom/30accessibility | 106 +++++ scripts/live-bottom/31disable_update_notifier | 34 ++ scripts/live-bottom/32disable_hibernation | 36 ++ scripts/live-bottom/33enable_apport_crashes | 28 ++ scripts/live-bottom/34disable_kwallet | 25 ++ scripts/live-bottom/35fix_language_selector | 32 ++ scripts/live-bottom/40install_driver_updates | 40 ++ scripts/live-bottom/41apt_cdrom | 24 ++ scripts/live-functions | 21 + scripts/live-helpers | 197 +++++++++ scripts/live-premount/10driver_updates | 163 +++++++ 97 files changed, 3514 insertions(+), 3581 deletions(-) delete mode 100755 bin/casper-getty delete mode 100755 bin/casper-login delete mode 100755 bin/casper-preseed delete mode 100755 bin/casper-reconfigure delete mode 100755 bin/casper-snapshot create mode 100755 bin/live-getty create mode 100755 bin/live-login create mode 100644 bin/live-md5check/Makefile create mode 100644 bin/live-md5check/live-md5check.c create mode 100644 bin/live-md5check/md5.c create mode 100644 bin/live-md5check/md5.h create mode 100755 bin/live-preseed create mode 100755 bin/live-reconfigure create mode 100755 bin/live-snapshot delete mode 100644 casper-md5check/Makefile delete mode 100644 casper-md5check/casper-md5check.c delete mode 100644 casper-md5check/md5.c delete mode 100644 casper-md5check/md5.h delete mode 100644 casper.conf delete mode 100644 caspermon/GNOME_PythonAppletCasper.server delete mode 100755 caspermon/caspermon-applet delete mode 100644 caspermon/caspermond create mode 100644 conf/live.conf delete mode 100644 debian/manpage/casper-snapshot.1 delete mode 100644 debian/manpage/casper.7 delete mode 100755 hooks/casper create mode 100755 hooks/live create mode 100644 manpages/live-initramfs.7 create mode 100644 manpages/live-snapshot.1 delete mode 100755 scripts/casper delete mode 100755 scripts/casper-bottom/01integrity_check delete mode 100755 scripts/casper-bottom/02_timezone delete mode 100755 scripts/casper-bottom/05mountpoints delete mode 100755 scripts/casper-bottom/10adduser delete mode 100755 scripts/casper-bottom/12fstab delete mode 100755 scripts/casper-bottom/13swap delete mode 100755 scripts/casper-bottom/14locales delete mode 100755 scripts/casper-bottom/15autologin delete mode 100755 scripts/casper-bottom/18hostname delete mode 100755 scripts/casper-bottom/19keyboard delete mode 100755 scripts/casper-bottom/20xconfig delete mode 100755 scripts/casper-bottom/22gnome_panel_data delete mode 100755 scripts/casper-bottom/22screensaver delete mode 100755 scripts/casper-bottom/23etc_modules delete mode 100755 scripts/casper-bottom/23networking delete mode 100755 scripts/casper-bottom/24preseed delete mode 100755 scripts/casper-bottom/25configure_init delete mode 100755 scripts/casper-bottom/30accessibility delete mode 100755 scripts/casper-bottom/31disable_update_notifier delete mode 100755 scripts/casper-bottom/32disable_hibernation delete mode 100755 scripts/casper-bottom/33enable_apport_crashes delete mode 100755 scripts/casper-bottom/34disable_kwallet delete mode 100755 scripts/casper-bottom/35fix_language_selector delete mode 100755 scripts/casper-bottom/40install_driver_updates delete mode 100755 scripts/casper-bottom/41apt_cdrom delete mode 100644 scripts/casper-functions delete mode 100644 scripts/casper-helpers delete mode 100755 scripts/casper-premount/10driver_updates create mode 100755 scripts/live create mode 100755 scripts/live-bottom/01integrity_check create mode 100755 scripts/live-bottom/02_timezone create mode 100755 scripts/live-bottom/05mountpoints create mode 100755 scripts/live-bottom/10adduser create mode 100755 scripts/live-bottom/12fstab create mode 100755 scripts/live-bottom/13swap create mode 100755 scripts/live-bottom/14locales create mode 100755 scripts/live-bottom/15autologin create mode 100755 scripts/live-bottom/18hostname create mode 100755 scripts/live-bottom/19keyboard create mode 100755 scripts/live-bottom/20xconfig create mode 100755 scripts/live-bottom/22gnome_panel_data create mode 100755 scripts/live-bottom/22screensaver create mode 100755 scripts/live-bottom/23etc_modules create mode 100755 scripts/live-bottom/23networking create mode 100755 scripts/live-bottom/24preseed create mode 100755 scripts/live-bottom/25configure_init create mode 100755 scripts/live-bottom/30accessibility create mode 100755 scripts/live-bottom/31disable_update_notifier create mode 100755 scripts/live-bottom/32disable_hibernation create mode 100755 scripts/live-bottom/33enable_apport_crashes create mode 100755 scripts/live-bottom/34disable_kwallet create mode 100755 scripts/live-bottom/35fix_language_selector create mode 100755 scripts/live-bottom/40install_driver_updates create mode 100755 scripts/live-bottom/41apt_cdrom create mode 100644 scripts/live-functions create mode 100644 scripts/live-helpers create mode 100755 scripts/live-premount/10driver_updates diff --git a/bin/casper-getty b/bin/casper-getty deleted file mode 100755 index f885fa9..0000000 --- a/bin/casper-getty +++ /dev/null @@ -1,15 +0,0 @@ -#! /bin/sh - -autologin=1 -for opt in "$@" ; do - if [ "$opt" = "-l" -o "$opt" = "-n" ] ; then - autologin=0 - fi -done - -if [ "$autologin" = "1" ] ; then - exec /sbin/getty -n -l /sbin/casper-login $* -else - exec /sbin/getty $* -fi - diff --git a/bin/casper-login b/bin/casper-login deleted file mode 100755 index e6a4173..0000000 --- a/bin/casper-login +++ /dev/null @@ -1,6 +0,0 @@ -#! /bin/sh - -USERNAME=root -[ -f /etc/casper.conf ] && . /etc/casper.conf -exec /bin/login -f $USERNAME - diff --git a/bin/casper-preseed b/bin/casper-preseed deleted file mode 100755 index c0c76eb..0000000 --- a/bin/casper-preseed +++ /dev/null @@ -1,19 +0,0 @@ -#! /bin/sh -set -e -PATH=/usr/sbin:/usr/bin:/sbin:/bin - -root="$1" -question="$2" -value="$3" -seen="$4" -[ "$seen" ] || seen=true - -if ! (echo "SET $question $value"; echo "FSET $question seen $seen") | chroot "$1" debconf-communicate -fnoninteractive casper >/dev/null; then - chroot "$1" debconf-communicate -fnoninteractive casper >/dev/null </dev/null) || version="" - -if [ -z "$version" ]; then - echo >&2 "$0: package '$package' is not installed" - exit 0 -fi - -runcommandinroot "$root" dpkg-reconfigure -fnoninteractive --no-reload "$package" - -exit 0 diff --git a/bin/casper-snapshot b/bin/casper-snapshot deleted file mode 100755 index e912493..0000000 --- a/bin/casper-snapshot +++ /dev/null @@ -1,299 +0,0 @@ -#! /bin/bash - -# casper-snapshot - utility to manage Debian Live systems snapshots -# -# This program mount a device (fallback to /tmpfs under /mnt/snapshot -# and save the /cow (or a different dir) filesystem in it for reusing -# in another casper session. Look at manpage for more info. -# -# Copyright (C) 2006 Marco Amadori -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -# -# On Debian systems, the complete text of the GNU General Public License -# can be found in /usr/share/common-licenses/GPL file. - -PROGRAM="`basename $0`" -VERSION=0.0.1 - - -# Source casper conf -if [ -e /etc/casper.conf ]; then - . /etc/casper.conf -else - USERNAME=$(cat /etc/passwd | grep "999" | cut -f1 -d ':') - HOSTNAME=$(hostname) - BUILD_SYSTEM="Debian" -fi - -export USERNAME USERFULLNAME HOSTNAME BUILD_SYSTEM - -# Source helper functions -helpers="/usr/share/initramfs-tools/scripts/casper-helpers" -if [ -e "${helpers}" ]; then - . "${helpers}" -else - echo "Error: I cannot found helper functions \"${helpers}\"." - exit 1 -fi - -# Define LSB log_* functions. -# Depend on lsb-base (>= 3.0-6) to ensure that this file is present. -. /lib/lsb/init-functions - -MOUNTP="" -COW="" -DEV="" -DEST="" -TYPE="" -DESKTOP_LINK="" - -Header () -{ - echo "${PROGRAM} - utility to do Debian Live snapshots" - echo - echo "Usage: ${PROGRAM} [-c|--cow DIRECTORY] [-d|--device DEVICE] [-o|--output FILE] [-t|--type TYPE]" - echo "Usage: ${PROGRAM} [-r|--resync-string STRING]" - echo "Usage: ${PROGRAM} [-h|--help]" - echo "Usage: ${PROGRAM} [-u|--usage]" - echo "Usage: ${PROGRAM} [-v|--version]" -} - -Usage () -{ - MESSAGE=${1} - Header - echo - echo "Try \"${PROGRAM} --help\" for more information." - if [ ! -z "${MESSAGE}" ]; then - echo -e "${MESSAGE}" - exit 1 - else - exit 0 - fi -} - -Help () -{ - Header - echo - echo "Options:" - echo " -c, --cow: specifies the copy on write directory (default: /cow)." - echo " -d, --device: specifies the output snapshot device (default: none)." - echo " -o, --output: specifies the output image file (default: $type dependent)." - echo " -r, --resync-string: internally used to resync previous made snapshots." - echo " -t, --type: specifies the snapshot type between \"squashfs\", \"ext2\" or \"cpio\".gz archive (default: cpio)" - echo -e "\nLook at casper-snapshot(1) man page for more information." - exit 0 -} - -Version () -{ - echo "${PROGRAM}, version ${VERSION}" - echo - echo "Copyright (C) 2006 Marco Amadori " - echo - echo "This program is free software; you can redistribute it and/or modify" - echo "it under the terms of the GNU General Public License as published by" - echo "the Free Software Foundation; either version 2 of the License, or" - echo "(at your option) any later version." - echo - echo "This program is distributed in the hope that it will be useful," - echo "but WITHOUT ANY WARRANTY; without even the implied warranty of" - echo "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the" - echo "GNU General Public License for more details." - echo - echo "You should have received a copy of the GNU General Public License" - echo "along with this program; if not, write to the Free Software" - echo "Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA" - echo - echo "On Debian systems, the complete text of the GNU General Public License" - echo "can be found in /usr/share/common-licenses/GPL file." - echo - echo "Homepage: " - exit 0 -} - -Do_snapshot () -{ - case "${TYPE}" in - squashfs) - echo "./tmp/exclude_list" > /tmp/exclude_list - ( cd "${COW}" && find . -name '*.wh.*' >> /tmp/exclude_list ) - mksquashfs "${COW}" "${DEST}" -ef /tmp/exclude_list || exit 1 - rm /tmp/exclude_list - ;; - cpio) - ( cd "${COW}" && find . -path '*.wh.*' -prune -o -print0 | cpio --quiet -o0 -H newc | gzip -9c > "${DEST}" ) || exit 1 - ;; - ext2) - DU_DIM="`du -ks ${COW} | cut -f1`" - REAL_DIM="`expr ${DU_DIM} + ${DU_DIM} / 20`" # Just 5% more to be sure, need something more sophistcated here... - genext2fs --size-in-blocks=${REAL_DIM} --reserved-blocks=0 --root="${COW}" "${DEST}" || exit 1 - ;; - *) - echo "Internal error." - exit 1 - ;; - esac -} - -Is_same_mount () -{ - dir1="`Base_path $1`" - dir2="`Base_path $2`" - if [ "${dir1}" == "${dir2}" ]; then - return 0 - else - return 1 - fi -} - -Parse_args () -{ - # Parse command line - ARGS="$1" - ARGUMENTS="`getopt --longoptions cow:,device:,output,resync-string:,type:,help,usage,version --name=${PROGRAM} --options c:d:o:t:r:,h,u,v --shell sh -- ${ARGS}`" - - if [ "$?" != "0" ]; then - echo "Terminating." >&2 - exit 1 - fi - - eval set -- "${ARGUMENTS}" - - while true; do - case "$1" in - -c|--cow) - SNAP_COW="$2"; shift 2 ;; - -d|--device) - SNAP_DEV="$2"; shift 2 ;; - -o|--output) - SNAP_OUTPUT="$2"; shift 2 ;; - -t|--type) - SNAP_TYPE="$2"; shift 2 ;; - -r|--resync-string) - SNAP_RSTRING="$2"; break ;; - -h|--help) - Help; shift ;; - -u|--usage) - Usage ; shift ;; - -v|--version) - Version; shift ;; - --) - shift; break ;; - *) - echo "Internal error."; exit 1 ;; - esac - done -} - -Mount_device () -{ - dev="$1" - - if [ ! -d "${MOUNTP}" ]; then - mkdir -p "${MOUNTP}" - fi - - if [ -z "${dev}" ]; then - # create a temp - mount -t tmpfs -o rw tmpfs "${MOUNTP}" - if [ ! -L /home/$USERNAME/Desktop/casper-snapshot ]; then - ln -s "${MOUNTP}" /home/$USERNAME/Desktop/casper-snapshot - fi - else - if [ -b "${dev}" ] ; then - try_mount "${dev}" "${MOUNTP}" rw - fi - fi -} - -Defaults () -{ - MOUNTP="/mnt/casper-snapshot" - COW="/cow" - DEV="" - DEST="${MOUNTP}/casper-sn.cpio.gz" - TYPE="cpio" - DESKTOP_LINK=/home/$USERNAME/Desktop/casper-snapshot - - if [ -n "${SNAP_RSTRING}" ]; then - COW=$(echo "${SNAP_RSTRING}" | cut -f1 -d ':') - DEV=$(echo "${SNAP_RSTRING}" | cut -f2 -d ':') - DEST=$(echo "${SNAP_RSTRING}" | cut -f3 -d ':') - - case "${DEST}" in - *.cpio.gz) - TYPE="cpio" ;; - *.squashfs) - TYPE="squashfs" ;; - "") - TYPE="ext2" ;; - *.ext2) - TYPE="ext2" ;; - *) - Usage "Unregognized String" ;; - esac - else - DEF_COW="/cow" - # Bad options handling - if [ -z "${SNAP_COW}" ]; then - COW="${DEF_COW}" - else - COW="${SNAP_COW}" - fi - - case "${SNAP_TYPE}" in - "cpio"|"squashfs"|"ext2") - TYPE="${SNAP_TYPE}" - ;; - "") - TYPE="cpio" ;; - *) - Usage "Error: unrecognized snapshot type" - ;; - esac - #if [ -d - #if Is_same_mount - fi - - # check vars - if [ ! -d "${COW}" ]; then - Usage "Error: ${COW} is not a directory" - fi - - Mount_device $DEV - -} - -Clean () -{ - if [ -n "$DEV" ]; then - umount "${MOUNTP}" - rmdir "${MOUNTP}" - rm - fi -} - -Main () -{ - Parse_args "$@" - Defaults - Do_snapshot - Clean -} - -Main "$@" diff --git a/bin/live-getty b/bin/live-getty new file mode 100755 index 0000000..6781ea5 --- /dev/null +++ b/bin/live-getty @@ -0,0 +1,20 @@ +#!/bin/sh + +set -e + +AUTOLOGIN="1" + +for ARGUMENT in "${@}" +do + if [ "${ARGUMENT}" = "-l" ] || [ "${ARGUMENT}" = "-n" ] + then + AUTOLOGIN="0" + fi +done + +if [ "${AUTOLOGIN}" = "1" ] +then + exec /sbin/getty -n -l /sbin/live-login ${*} +else + exec /sbin/getty ${*} +fi diff --git a/bin/live-login b/bin/live-login new file mode 100755 index 0000000..c2cc5a1 --- /dev/null +++ b/bin/live-login @@ -0,0 +1,12 @@ +#!/bin/sh + +set -e + +USERNAME="root" + +if [ -f /etc/live.conf ] +then + . /etc/live.conf +fi + +exec /bin/login -f "${USERNAME}" diff --git a/bin/live-md5check/Makefile b/bin/live-md5check/Makefile new file mode 100644 index 0000000..51e42b9 --- /dev/null +++ b/bin/live-md5check/Makefile @@ -0,0 +1,9 @@ + +CC=gcc +LDFLAGS=-lm +CFLAGS=$(getconf LFS_CFLAGS) -Wall -O2 + +live-md5check: live-md5check.c md5.c + +clean: + rm -f *.o live-md5check diff --git a/bin/live-md5check/live-md5check.c b/bin/live-md5check/live-md5check.c new file mode 100644 index 0000000..8dfd577 --- /dev/null +++ b/bin/live-md5check/live-md5check.c @@ -0,0 +1,270 @@ +/* casper-md5check - a tool to check md5sums and talk to usplash + (C) Canonical Ltd 2006 + Written by Tollef Fog Heen + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + USA. */ + +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define USPLASH_FIFO "/dev/.initramfs/usplash_fifo" +#define MAXTRIES 5 +#include "md5.h" +#define DEBUG + +int write_and_retry(int fd, char *s) { + int try = 0, ret = 0; + char *end; + +#ifdef DEBUG + fprintf(stderr, "-> %s\n", s); +#endif + + end = s + strlen(s)+1; + + ret = write(fd, s, end - s); + while (s + ret < end && try < MAXTRIES) { + sleep(1); + s += ret; + ret = write(fd, s, strlen(s)+1); + try++; + } + return (s+ret == end ? 0 : 1); +} + +void usplash_timeout(int fd, int timeout) { + char *s; + + asprintf(&s, "TIMEOUT %d", timeout); + + write_and_retry(fd, s); + + free(s); + +} + +void usplash_failure(int fd, char *format, ...) { + char *s, *s1; + va_list argp; + + va_start(argp, format); + vasprintf(&s, format, argp); + va_end(argp); + + asprintf(&s1, "FAILURE %s", s); + + write_and_retry(fd, s1); + + free(s); + free(s1); +} + +void usplash_text(int fd, char *format, ...) { + char *s, *s1; + va_list argp; + + va_start(argp, format); + vasprintf(&s, format, argp); + va_end(argp); + + asprintf(&s1, "TEXT %s", s); + + write_and_retry(fd, s1); + + free(s); + free(s1); +} + +void usplash_urgent(int fd, char *format, ...) { + char *s, *s1; + va_list argp; + + va_start(argp, format); + vasprintf(&s, format, argp); + va_end(argp); + + asprintf(&s1, "TEXT-URGENT %s", s); + + write_and_retry(fd, s1); + + free(s); + free(s1); +} + + +void usplash_success(int fd, char *format, ...) { + char *s, *s1; + va_list argp; + + va_start(argp, format); + vasprintf(&s, format, argp); + va_end(argp); + + asprintf(&s1, "SUCCESS %s", s); + + write_and_retry(fd, s1); + + free(s); + free(s1); +} + +void usplash_progress(int fd, int progress) { + static int prevprogress = -1; + char *s; + + if (progress == prevprogress) + return; + prevprogress = progress; + + asprintf(&s, "PROGRESS %d", progress); + + write_and_retry(fd, s); + + free(s); +} + +int set_nocanonical_tty(int fd) { + struct termios t; + + if (tcgetattr(fd, &t) == -1) { + perror("tcgetattr"); + } + t.c_lflag &= ~ICANON; + t.c_cc[VMIN] = 1; + t.c_cc[VTIME] = 0; + return tcsetattr(fd, TCSANOW, &t); +} + +int main(int argc, char **argv) { + + int pipe_fd, check_fd; + int failed = 0; + + FILE *md5_file; + md5_state_t state; + md5_byte_t digest[16]; + char hex_output[16*2 + 1]; + char *checksum, *checkfile; + ssize_t tsize, csize; + + tsize = 0; + csize = 0; + + if (argc != 3) { + fprintf(stderr,"Wrong number of arguments\n"); + fprintf(stderr,"%s \n", argv[0]); + exit(1); + } + + if (chdir(argv[1]) != 0) { + perror("chdir"); + exit(1); + } + + pipe_fd = open(USPLASH_FIFO, O_WRONLY|O_NONBLOCK); + + if (pipe_fd == -1) { + /* We can't really do anything useful here */ + perror("Opening pipe"); + exit(1); + } + + + usplash_progress(pipe_fd, 0); + usplash_urgent(pipe_fd, "Checking integrity, this may take some time"); + md5_file = fopen(argv[2], "r"); + if (!md5_file) { + perror("fopen md5_file"); + exit(1); + } + while (fscanf(md5_file, "%as %as", &checksum, &checkfile) == 2) { + struct stat statbuf; + + if (stat(checkfile, &statbuf) == 0) { + tsize += statbuf.st_size; + } + + free(checksum); + free(checkfile); + } + + rewind(md5_file); + while (fscanf(md5_file, "%as %as", &checksum, &checkfile) == 2) { + char buf[BUFSIZ]; + ssize_t rsize; + int i; + + md5_init(&state); + + usplash_text(pipe_fd, "Checking %s", checkfile); + + check_fd = open(checkfile, O_RDONLY); + if (check_fd < 0) { + usplash_timeout(pipe_fd, 300); + usplash_failure(pipe_fd, "%s", strerror(errno)); + sleep(10); + } + + rsize = read(check_fd, buf, sizeof(buf)); + + while (rsize > 0) { + csize += rsize; + usplash_progress(pipe_fd, floorl(100*((long double)csize)/tsize)); + + md5_append(&state, (const md5_byte_t *)buf, rsize); + rsize = read(check_fd, buf, sizeof(buf)); + } + + close(check_fd); + md5_finish(&state, digest); + + for (i = 0; i < 16; i++) + sprintf(hex_output + i * 2, "%02x", digest[i]); + + if (strncmp(hex_output, checksum, strlen(hex_output)) == 0) { + usplash_success(pipe_fd, "OK"); + } else { + usplash_failure(pipe_fd, "mismatch"); + failed++; + } + free(checksum); + free(checkfile); + } + if (failed) { + usplash_urgent(pipe_fd, "Check finished: errors found in %d files!", failed); + } else { + usplash_urgent(pipe_fd, "Check finished: no errors found"); + } + usplash_urgent(pipe_fd, "Press any key to reboot your system"); + usplash_timeout(pipe_fd, 86400); + set_nocanonical_tty(0); + getchar(); + reboot(LINUX_REBOOT_CMD_RESTART); + return 0; + +} diff --git a/bin/live-md5check/md5.c b/bin/live-md5check/md5.c new file mode 100644 index 0000000..c35d96c --- /dev/null +++ b/bin/live-md5check/md5.c @@ -0,0 +1,381 @@ +/* + Copyright (C) 1999, 2000, 2002 Aladdin Enterprises. All rights reserved. + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + L. Peter Deutsch + ghost@aladdin.com + + */ +/* $Id: md5.c,v 1.6 2002/04/13 19:20:28 lpd Exp $ */ +/* + Independent implementation of MD5 (RFC 1321). + + This code implements the MD5 Algorithm defined in RFC 1321, whose + text is available at + http://www.ietf.org/rfc/rfc1321.txt + The code is derived from the text of the RFC, including the test suite + (section A.5) but excluding the rest of Appendix A. It does not include + any code or documentation that is identified in the RFC as being + copyrighted. + + The original and principal author of md5.c is L. Peter Deutsch + . Other authors are noted in the change history + that follows (in reverse chronological order): + + 2002-04-13 lpd Clarified derivation from RFC 1321; now handles byte order + either statically or dynamically; added missing #include + in library. + 2002-03-11 lpd Corrected argument list for main(), and added int return + type, in test program and T value program. + 2002-02-21 lpd Added missing #include in test program. + 2000-07-03 lpd Patched to eliminate warnings about "constant is + unsigned in ANSI C, signed in traditional"; made test program + self-checking. + 1999-11-04 lpd Edited comments slightly for automatic TOC extraction. + 1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5). + 1999-05-03 lpd Original version. + */ + +#include "md5.h" +#include + +#undef BYTE_ORDER /* 1 = big-endian, -1 = little-endian, 0 = unknown */ +#ifdef ARCH_IS_BIG_ENDIAN +# define BYTE_ORDER (ARCH_IS_BIG_ENDIAN ? 1 : -1) +#else +# define BYTE_ORDER 0 +#endif + +#define T_MASK ((md5_word_t)~0) +#define T1 /* 0xd76aa478 */ (T_MASK ^ 0x28955b87) +#define T2 /* 0xe8c7b756 */ (T_MASK ^ 0x173848a9) +#define T3 0x242070db +#define T4 /* 0xc1bdceee */ (T_MASK ^ 0x3e423111) +#define T5 /* 0xf57c0faf */ (T_MASK ^ 0x0a83f050) +#define T6 0x4787c62a +#define T7 /* 0xa8304613 */ (T_MASK ^ 0x57cfb9ec) +#define T8 /* 0xfd469501 */ (T_MASK ^ 0x02b96afe) +#define T9 0x698098d8 +#define T10 /* 0x8b44f7af */ (T_MASK ^ 0x74bb0850) +#define T11 /* 0xffff5bb1 */ (T_MASK ^ 0x0000a44e) +#define T12 /* 0x895cd7be */ (T_MASK ^ 0x76a32841) +#define T13 0x6b901122 +#define T14 /* 0xfd987193 */ (T_MASK ^ 0x02678e6c) +#define T15 /* 0xa679438e */ (T_MASK ^ 0x5986bc71) +#define T16 0x49b40821 +#define T17 /* 0xf61e2562 */ (T_MASK ^ 0x09e1da9d) +#define T18 /* 0xc040b340 */ (T_MASK ^ 0x3fbf4cbf) +#define T19 0x265e5a51 +#define T20 /* 0xe9b6c7aa */ (T_MASK ^ 0x16493855) +#define T21 /* 0xd62f105d */ (T_MASK ^ 0x29d0efa2) +#define T22 0x02441453 +#define T23 /* 0xd8a1e681 */ (T_MASK ^ 0x275e197e) +#define T24 /* 0xe7d3fbc8 */ (T_MASK ^ 0x182c0437) +#define T25 0x21e1cde6 +#define T26 /* 0xc33707d6 */ (T_MASK ^ 0x3cc8f829) +#define T27 /* 0xf4d50d87 */ (T_MASK ^ 0x0b2af278) +#define T28 0x455a14ed +#define T29 /* 0xa9e3e905 */ (T_MASK ^ 0x561c16fa) +#define T30 /* 0xfcefa3f8 */ (T_MASK ^ 0x03105c07) +#define T31 0x676f02d9 +#define T32 /* 0x8d2a4c8a */ (T_MASK ^ 0x72d5b375) +#define T33 /* 0xfffa3942 */ (T_MASK ^ 0x0005c6bd) +#define T34 /* 0x8771f681 */ (T_MASK ^ 0x788e097e) +#define T35 0x6d9d6122 +#define T36 /* 0xfde5380c */ (T_MASK ^ 0x021ac7f3) +#define T37 /* 0xa4beea44 */ (T_MASK ^ 0x5b4115bb) +#define T38 0x4bdecfa9 +#define T39 /* 0xf6bb4b60 */ (T_MASK ^ 0x0944b49f) +#define T40 /* 0xbebfbc70 */ (T_MASK ^ 0x4140438f) +#define T41 0x289b7ec6 +#define T42 /* 0xeaa127fa */ (T_MASK ^ 0x155ed805) +#define T43 /* 0xd4ef3085 */ (T_MASK ^ 0x2b10cf7a) +#define T44 0x04881d05 +#define T45 /* 0xd9d4d039 */ (T_MASK ^ 0x262b2fc6) +#define T46 /* 0xe6db99e5 */ (T_MASK ^ 0x1924661a) +#define T47 0x1fa27cf8 +#define T48 /* 0xc4ac5665 */ (T_MASK ^ 0x3b53a99a) +#define T49 /* 0xf4292244 */ (T_MASK ^ 0x0bd6ddbb) +#define T50 0x432aff97 +#define T51 /* 0xab9423a7 */ (T_MASK ^ 0x546bdc58) +#define T52 /* 0xfc93a039 */ (T_MASK ^ 0x036c5fc6) +#define T53 0x655b59c3 +#define T54 /* 0x8f0ccc92 */ (T_MASK ^ 0x70f3336d) +#define T55 /* 0xffeff47d */ (T_MASK ^ 0x00100b82) +#define T56 /* 0x85845dd1 */ (T_MASK ^ 0x7a7ba22e) +#define T57 0x6fa87e4f +#define T58 /* 0xfe2ce6e0 */ (T_MASK ^ 0x01d3191f) +#define T59 /* 0xa3014314 */ (T_MASK ^ 0x5cfebceb) +#define T60 0x4e0811a1 +#define T61 /* 0xf7537e82 */ (T_MASK ^ 0x08ac817d) +#define T62 /* 0xbd3af235 */ (T_MASK ^ 0x42c50dca) +#define T63 0x2ad7d2bb +#define T64 /* 0xeb86d391 */ (T_MASK ^ 0x14792c6e) + + +static void +md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/) +{ + md5_word_t + a = pms->abcd[0], b = pms->abcd[1], + c = pms->abcd[2], d = pms->abcd[3]; + md5_word_t t; +#if BYTE_ORDER > 0 + /* Define storage only for big-endian CPUs. */ + md5_word_t X[16]; +#else + /* Define storage for little-endian or both types of CPUs. */ + md5_word_t xbuf[16]; + const md5_word_t *X; +#endif + + { +#if BYTE_ORDER == 0 + /* + * Determine dynamically whether this is a big-endian or + * little-endian machine, since we can use a more efficient + * algorithm on the latter. + */ + static const int w = 1; + + if (*((const md5_byte_t *)&w)) /* dynamic little-endian */ +#endif +#if BYTE_ORDER <= 0 /* little-endian */ + { + /* + * On little-endian machines, we can process properly aligned + * data without copying it. + */ + if (!((data - (const md5_byte_t *)0) & 3)) { + /* data are properly aligned */ + X = (const md5_word_t *)data; + } else { + /* not aligned */ + memcpy(xbuf, data, 64); + X = xbuf; + } + } +#endif +#if BYTE_ORDER == 0 + else /* dynamic big-endian */ +#endif +#if BYTE_ORDER >= 0 /* big-endian */ + { + /* + * On big-endian machines, we must arrange the bytes in the + * right order. + */ + const md5_byte_t *xp = data; + int i; + +# if BYTE_ORDER == 0 + X = xbuf; /* (dynamic only) */ +# else +# define xbuf X /* (static only) */ +# endif + for (i = 0; i < 16; ++i, xp += 4) + xbuf[i] = xp[0] + (xp[1] << 8) + (xp[2] << 16) + (xp[3] << 24); + } +#endif + } + +#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32 - (n)))) + + /* Round 1. */ + /* Let [abcd k s i] denote the operation + a = b + ((a + F(b,c,d) + X[k] + T[i]) <<< s). */ +#define F(x, y, z) (((x) & (y)) | (~(x) & (z))) +#define SET(a, b, c, d, k, s, Ti)\ + t = a + F(b,c,d) + X[k] + Ti;\ + a = ROTATE_LEFT(t, s) + b + /* Do the following 16 operations. */ + SET(a, b, c, d, 0, 7, T1); + SET(d, a, b, c, 1, 12, T2); + SET(c, d, a, b, 2, 17, T3); + SET(b, c, d, a, 3, 22, T4); + SET(a, b, c, d, 4, 7, T5); + SET(d, a, b, c, 5, 12, T6); + SET(c, d, a, b, 6, 17, T7); + SET(b, c, d, a, 7, 22, T8); + SET(a, b, c, d, 8, 7, T9); + SET(d, a, b, c, 9, 12, T10); + SET(c, d, a, b, 10, 17, T11); + SET(b, c, d, a, 11, 22, T12); + SET(a, b, c, d, 12, 7, T13); + SET(d, a, b, c, 13, 12, T14); + SET(c, d, a, b, 14, 17, T15); + SET(b, c, d, a, 15, 22, T16); +#undef SET + + /* Round 2. */ + /* Let [abcd k s i] denote the operation + a = b + ((a + G(b,c,d) + X[k] + T[i]) <<< s). */ +#define G(x, y, z) (((x) & (z)) | ((y) & ~(z))) +#define SET(a, b, c, d, k, s, Ti)\ + t = a + G(b,c,d) + X[k] + Ti;\ + a = ROTATE_LEFT(t, s) + b + /* Do the following 16 operations. */ + SET(a, b, c, d, 1, 5, T17); + SET(d, a, b, c, 6, 9, T18); + SET(c, d, a, b, 11, 14, T19); + SET(b, c, d, a, 0, 20, T20); + SET(a, b, c, d, 5, 5, T21); + SET(d, a, b, c, 10, 9, T22); + SET(c, d, a, b, 15, 14, T23); + SET(b, c, d, a, 4, 20, T24); + SET(a, b, c, d, 9, 5, T25); + SET(d, a, b, c, 14, 9, T26); + SET(c, d, a, b, 3, 14, T27); + SET(b, c, d, a, 8, 20, T28); + SET(a, b, c, d, 13, 5, T29); + SET(d, a, b, c, 2, 9, T30); + SET(c, d, a, b, 7, 14, T31); + SET(b, c, d, a, 12, 20, T32); +#undef SET + + /* Round 3. */ + /* Let [abcd k s t] denote the operation + a = b + ((a + H(b,c,d) + X[k] + T[i]) <<< s). */ +#define H(x, y, z) ((x) ^ (y) ^ (z)) +#define SET(a, b, c, d, k, s, Ti)\ + t = a + H(b,c,d) + X[k] + Ti;\ + a = ROTATE_LEFT(t, s) + b + /* Do the following 16 operations. */ + SET(a, b, c, d, 5, 4, T33); + SET(d, a, b, c, 8, 11, T34); + SET(c, d, a, b, 11, 16, T35); + SET(b, c, d, a, 14, 23, T36); + SET(a, b, c, d, 1, 4, T37); + SET(d, a, b, c, 4, 11, T38); + SET(c, d, a, b, 7, 16, T39); + SET(b, c, d, a, 10, 23, T40); + SET(a, b, c, d, 13, 4, T41); + SET(d, a, b, c, 0, 11, T42); + SET(c, d, a, b, 3, 16, T43); + SET(b, c, d, a, 6, 23, T44); + SET(a, b, c, d, 9, 4, T45); + SET(d, a, b, c, 12, 11, T46); + SET(c, d, a, b, 15, 16, T47); + SET(b, c, d, a, 2, 23, T48); +#undef SET + + /* Round 4. */ + /* Let [abcd k s t] denote the operation + a = b + ((a + I(b,c,d) + X[k] + T[i]) <<< s). */ +#define I(x, y, z) ((y) ^ ((x) | ~(z))) +#define SET(a, b, c, d, k, s, Ti)\ + t = a + I(b,c,d) + X[k] + Ti;\ + a = ROTATE_LEFT(t, s) + b + /* Do the following 16 operations. */ + SET(a, b, c, d, 0, 6, T49); + SET(d, a, b, c, 7, 10, T50); + SET(c, d, a, b, 14, 15, T51); + SET(b, c, d, a, 5, 21, T52); + SET(a, b, c, d, 12, 6, T53); + SET(d, a, b, c, 3, 10, T54); + SET(c, d, a, b, 10, 15, T55); + SET(b, c, d, a, 1, 21, T56); + SET(a, b, c, d, 8, 6, T57); + SET(d, a, b, c, 15, 10, T58); + SET(c, d, a, b, 6, 15, T59); + SET(b, c, d, a, 13, 21, T60); + SET(a, b, c, d, 4, 6, T61); + SET(d, a, b, c, 11, 10, T62); + SET(c, d, a, b, 2, 15, T63); + SET(b, c, d, a, 9, 21, T64); +#undef SET + + /* Then perform the following additions. (That is increment each + of the four registers by the value it had before this block + was started.) */ + pms->abcd[0] += a; + pms->abcd[1] += b; + pms->abcd[2] += c; + pms->abcd[3] += d; +} + +void +md5_init(md5_state_t *pms) +{ + pms->count[0] = pms->count[1] = 0; + pms->abcd[0] = 0x67452301; + pms->abcd[1] = /*0xefcdab89*/ T_MASK ^ 0x10325476; + pms->abcd[2] = /*0x98badcfe*/ T_MASK ^ 0x67452301; + pms->abcd[3] = 0x10325476; +} + +void +md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes) +{ + const md5_byte_t *p = data; + int left = nbytes; + int offset = (pms->count[0] >> 3) & 63; + md5_word_t nbits = (md5_word_t)(nbytes << 3); + + if (nbytes <= 0) + return; + + /* Update the message length. */ + pms->count[1] += nbytes >> 29; + pms->count[0] += nbits; + if (pms->count[0] < nbits) + pms->count[1]++; + + /* Process an initial partial block. */ + if (offset) { + int copy = (offset + nbytes > 64 ? 64 - offset : nbytes); + + memcpy(pms->buf + offset, p, copy); + if (offset + copy < 64) + return; + p += copy; + left -= copy; + md5_process(pms, pms->buf); + } + + /* Process full blocks. */ + for (; left >= 64; p += 64, left -= 64) + md5_process(pms, p); + + /* Process a final partial block. */ + if (left) + memcpy(pms->buf, p, left); +} + +void +md5_finish(md5_state_t *pms, md5_byte_t digest[16]) +{ + static const md5_byte_t pad[64] = { + 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + }; + md5_byte_t data[8]; + int i; + + /* Save the length before padding. */ + for (i = 0; i < 8; ++i) + data[i] = (md5_byte_t)(pms->count[i >> 2] >> ((i & 3) << 3)); + /* Pad to 56 bytes mod 64. */ + md5_append(pms, pad, ((55 - (pms->count[0] >> 3)) & 63) + 1); + /* Append the length. */ + md5_append(pms, data, 8); + for (i = 0; i < 16; ++i) + digest[i] = (md5_byte_t)(pms->abcd[i >> 2] >> ((i & 3) << 3)); +} diff --git a/bin/live-md5check/md5.h b/bin/live-md5check/md5.h new file mode 100644 index 0000000..698c995 --- /dev/null +++ b/bin/live-md5check/md5.h @@ -0,0 +1,91 @@ +/* + Copyright (C) 1999, 2002 Aladdin Enterprises. All rights reserved. + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + L. Peter Deutsch + ghost@aladdin.com + + */ +/* $Id: md5.h,v 1.4 2002/04/13 19:20:28 lpd Exp $ */ +/* + Independent implementation of MD5 (RFC 1321). + + This code implements the MD5 Algorithm defined in RFC 1321, whose + text is available at + http://www.ietf.org/rfc/rfc1321.txt + The code is derived from the text of the RFC, including the test suite + (section A.5) but excluding the rest of Appendix A. It does not include + any code or documentation that is identified in the RFC as being + copyrighted. + + The original and principal author of md5.h is L. Peter Deutsch + . Other authors are noted in the change history + that follows (in reverse chronological order): + + 2002-04-13 lpd Removed support for non-ANSI compilers; removed + references to Ghostscript; clarified derivation from RFC 1321; + now handles byte order either statically or dynamically. + 1999-11-04 lpd Edited comments slightly for automatic TOC extraction. + 1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5); + added conditionalization for C++ compilation from Martin + Purschke . + 1999-05-03 lpd Original version. + */ + +#ifndef md5_INCLUDED +# define md5_INCLUDED + +/* + * This package supports both compile-time and run-time determination of CPU + * byte order. If ARCH_IS_BIG_ENDIAN is defined as 0, the code will be + * compiled to run only on little-endian CPUs; if ARCH_IS_BIG_ENDIAN is + * defined as non-zero, the code will be compiled to run only on big-endian + * CPUs; if ARCH_IS_BIG_ENDIAN is not defined, the code will be compiled to + * run on either big- or little-endian CPUs, but will run slightly less + * efficiently on either one than if ARCH_IS_BIG_ENDIAN is defined. + */ + +typedef unsigned char md5_byte_t; /* 8-bit byte */ +typedef unsigned int md5_word_t; /* 32-bit word */ + +/* Define the state of the MD5 Algorithm. */ +typedef struct md5_state_s { + md5_word_t count[2]; /* message length in bits, lsw first */ + md5_word_t abcd[4]; /* digest buffer */ + md5_byte_t buf[64]; /* accumulate block */ +} md5_state_t; + +#ifdef __cplusplus +extern "C" +{ +#endif + +/* Initialize the algorithm. */ +void md5_init(md5_state_t *pms); + +/* Append a string to the message. */ +void md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes); + +/* Finish the message and return the digest. */ +void md5_finish(md5_state_t *pms, md5_byte_t digest[16]); + +#ifdef __cplusplus +} /* end extern "C" */ +#endif + +#endif /* md5_INCLUDED */ diff --git a/bin/live-preseed b/bin/live-preseed new file mode 100755 index 0000000..c10315e --- /dev/null +++ b/bin/live-preseed @@ -0,0 +1,19 @@ +#! /bin/sh +set -e +PATH=/usr/sbin:/usr/bin:/sbin:/bin + +root="$1" +question="$2" +value="$3" +seen="$4" +[ "$seen" ] || seen=true + +if ! (echo "SET $question $value"; echo "FSET $question seen $seen") | chroot "$1" debconf-communicate -fnoninteractive live-initramfs >/dev/null; then + chroot "$1" debconf-communicate -fnoninteractive live-initramfs >/dev/null </dev/null) || version="" + +if [ -z "$version" ]; then + echo >&2 "$0: package '$package' is not installed" + exit 0 +fi + +runcommandinroot "$root" dpkg-reconfigure -fnoninteractive --no-reload "$package" + +exit 0 diff --git a/bin/live-snapshot b/bin/live-snapshot new file mode 100755 index 0000000..e3e05fe --- /dev/null +++ b/bin/live-snapshot @@ -0,0 +1,299 @@ +#! /bin/bash + +# casper-snapshot - utility to manage Debian Live systems snapshots +# +# This program mount a device (fallback to /tmpfs under /mnt/snapshot +# and save the /cow (or a different dir) filesystem in it for reusing +# in another casper session. Look at manpage for more info. +# +# Copyright (C) 2006 Marco Amadori +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# +# On Debian systems, the complete text of the GNU General Public License +# can be found in /usr/share/common-licenses/GPL file. + +PROGRAM="`basename $0`" +VERSION=0.0.1 + + +# Source live conf +if [ -e /etc/live.conf ]; then + . /etc/live.conf +else + USERNAME=$(cat /etc/passwd | grep "999" | cut -f1 -d ':') + HOSTNAME=$(hostname) + BUILD_SYSTEM="Debian" +fi + +export USERNAME USERFULLNAME HOSTNAME BUILD_SYSTEM + +# Source helper functions +helpers="/usr/share/initramfs-tools/scripts/live-helpers" +if [ -e "${helpers}" ]; then + . "${helpers}" +else + echo "Error: I cannot found helper functions \"${helpers}\"." + exit 1 +fi + +# Define LSB log_* functions. +# Depend on lsb-base (>= 3.0-6) to ensure that this file is present. +. /lib/lsb/init-functions + +MOUNTP="" +COW="" +DEV="" +DEST="" +TYPE="" +DESKTOP_LINK="" + +Header () +{ + echo "${PROGRAM} - utility to do Debian Live snapshots" + echo + echo "Usage: ${PROGRAM} [-c|--cow DIRECTORY] [-d|--device DEVICE] [-o|--output FILE] [-t|--type TYPE]" + echo "Usage: ${PROGRAM} [-r|--resync-string STRING]" + echo "Usage: ${PROGRAM} [-h|--help]" + echo "Usage: ${PROGRAM} [-u|--usage]" + echo "Usage: ${PROGRAM} [-v|--version]" +} + +Usage () +{ + MESSAGE=${1} + Header + echo + echo "Try \"${PROGRAM} --help\" for more information." + if [ ! -z "${MESSAGE}" ]; then + echo -e "${MESSAGE}" + exit 1 + else + exit 0 + fi +} + +Help () +{ + Header + echo + echo "Options:" + echo " -c, --cow: specifies the copy on write directory (default: /cow)." + echo " -d, --device: specifies the output snapshot device (default: none)." + echo " -o, --output: specifies the output image file (default: $type dependent)." + echo " -r, --resync-string: internally used to resync previous made snapshots." + echo " -t, --type: specifies the snapshot type between \"squashfs\", \"ext2\" or \"cpio\".gz archive (default: cpio)" + echo -e "\nLook at live-snapshot(1) man page for more information." + exit 0 +} + +Version () +{ + echo "${PROGRAM}, version ${VERSION}" + echo + echo "Copyright (C) 2006 Marco Amadori " + echo + echo "This program is free software; you can redistribute it and/or modify" + echo "it under the terms of the GNU General Public License as published by" + echo "the Free Software Foundation; either version 2 of the License, or" + echo "(at your option) any later version." + echo + echo "This program is distributed in the hope that it will be useful," + echo "but WITHOUT ANY WARRANTY; without even the implied warranty of" + echo "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the" + echo "GNU General Public License for more details." + echo + echo "You should have received a copy of the GNU General Public License" + echo "along with this program; if not, write to the Free Software" + echo "Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA" + echo + echo "On Debian systems, the complete text of the GNU General Public License" + echo "can be found in /usr/share/common-licenses/GPL file." + echo + echo "Homepage: " + exit 0 +} + +Do_snapshot () +{ + case "${TYPE}" in + squashfs) + echo "./tmp/exclude_list" > /tmp/exclude_list + ( cd "${COW}" && find . -name '*.wh.*' >> /tmp/exclude_list ) + mksquashfs "${COW}" "${DEST}" -ef /tmp/exclude_list || exit 1 + rm /tmp/exclude_list + ;; + cpio) + ( cd "${COW}" && find . -path '*.wh.*' -prune -o -print0 | cpio --quiet -o0 -H newc | gzip -9c > "${DEST}" ) || exit 1 + ;; + ext2) + DU_DIM="`du -ks ${COW} | cut -f1`" + REAL_DIM="`expr ${DU_DIM} + ${DU_DIM} / 20`" # Just 5% more to be sure, need something more sophistcated here... + genext2fs --size-in-blocks=${REAL_DIM} --reserved-blocks=0 --root="${COW}" "${DEST}" || exit 1 + ;; + *) + echo "Internal error." + exit 1 + ;; + esac +} + +Is_same_mount () +{ + dir1="`Base_path $1`" + dir2="`Base_path $2`" + if [ "${dir1}" == "${dir2}" ]; then + return 0 + else + return 1 + fi +} + +Parse_args () +{ + # Parse command line + ARGS="$1" + ARGUMENTS="`getopt --longoptions cow:,device:,output,resync-string:,type:,help,usage,version --name=${PROGRAM} --options c:d:o:t:r:,h,u,v --shell sh -- ${ARGS}`" + + if [ "$?" != "0" ]; then + echo "Terminating." >&2 + exit 1 + fi + + eval set -- "${ARGUMENTS}" + + while true; do + case "$1" in + -c|--cow) + SNAP_COW="$2"; shift 2 ;; + -d|--device) + SNAP_DEV="$2"; shift 2 ;; + -o|--output) + SNAP_OUTPUT="$2"; shift 2 ;; + -t|--type) + SNAP_TYPE="$2"; shift 2 ;; + -r|--resync-string) + SNAP_RSTRING="$2"; break ;; + -h|--help) + Help; shift ;; + -u|--usage) + Usage ; shift ;; + -v|--version) + Version; shift ;; + --) + shift; break ;; + *) + echo "Internal error."; exit 1 ;; + esac + done +} + +Mount_device () +{ + dev="$1" + + if [ ! -d "${MOUNTP}" ]; then + mkdir -p "${MOUNTP}" + fi + + if [ -z "${dev}" ]; then + # create a temp + mount -t tmpfs -o rw tmpfs "${MOUNTP}" + if [ ! -L /home/$USERNAME/Desktop/live-snapshot ]; then + ln -s "${MOUNTP}" /home/$USERNAME/Desktop/live-snapshot + fi + else + if [ -b "${dev}" ] ; then + try_mount "${dev}" "${MOUNTP}" rw + fi + fi +} + +Defaults () +{ + MOUNTP="/mnt/live-snapshot" + COW="/cow" + DEV="" + DEST="${MOUNTP}/live-sn.cpio.gz" + TYPE="cpio" + DESKTOP_LINK=/home/$USERNAME/Desktop/live-snapshot + + if [ -n "${SNAP_RSTRING}" ]; then + COW=$(echo "${SNAP_RSTRING}" | cut -f1 -d ':') + DEV=$(echo "${SNAP_RSTRING}" | cut -f2 -d ':') + DEST=$(echo "${SNAP_RSTRING}" | cut -f3 -d ':') + + case "${DEST}" in + *.cpio.gz) + TYPE="cpio" ;; + *.squashfs) + TYPE="squashfs" ;; + "") + TYPE="ext2" ;; + *.ext2) + TYPE="ext2" ;; + *) + Usage "Unregognized String" ;; + esac + else + DEF_COW="/cow" + # Bad options handling + if [ -z "${SNAP_COW}" ]; then + COW="${DEF_COW}" + else + COW="${SNAP_COW}" + fi + + case "${SNAP_TYPE}" in + "cpio"|"squashfs"|"ext2") + TYPE="${SNAP_TYPE}" + ;; + "") + TYPE="cpio" ;; + *) + Usage "Error: unrecognized snapshot type" + ;; + esac + #if [ -d + #if Is_same_mount + fi + + # check vars + if [ ! -d "${COW}" ]; then + Usage "Error: ${COW} is not a directory" + fi + + Mount_device $DEV + +} + +Clean () +{ + if [ -n "$DEV" ]; then + umount "${MOUNTP}" + rmdir "${MOUNTP}" + rm + fi +} + +Main () +{ + Parse_args "$@" + Defaults + Do_snapshot + Clean +} + +Main "$@" diff --git a/casper-md5check/Makefile b/casper-md5check/Makefile deleted file mode 100644 index 4e5408f..0000000 --- a/casper-md5check/Makefile +++ /dev/null @@ -1,9 +0,0 @@ - -CC=gcc -LDFLAGS=-lm -CFLAGS=$(getconf LFS_CFLAGS) -Wall -O2 - -casper-md5check: casper-md5check.c md5.c - -clean: - rm -f *.o casper-md5check diff --git a/casper-md5check/casper-md5check.c b/casper-md5check/casper-md5check.c deleted file mode 100644 index 8dfd577..0000000 --- a/casper-md5check/casper-md5check.c +++ /dev/null @@ -1,270 +0,0 @@ -/* casper-md5check - a tool to check md5sums and talk to usplash - (C) Canonical Ltd 2006 - Written by Tollef Fog Heen - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. */ - -#define _GNU_SOURCE -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define USPLASH_FIFO "/dev/.initramfs/usplash_fifo" -#define MAXTRIES 5 -#include "md5.h" -#define DEBUG - -int write_and_retry(int fd, char *s) { - int try = 0, ret = 0; - char *end; - -#ifdef DEBUG - fprintf(stderr, "-> %s\n", s); -#endif - - end = s + strlen(s)+1; - - ret = write(fd, s, end - s); - while (s + ret < end && try < MAXTRIES) { - sleep(1); - s += ret; - ret = write(fd, s, strlen(s)+1); - try++; - } - return (s+ret == end ? 0 : 1); -} - -void usplash_timeout(int fd, int timeout) { - char *s; - - asprintf(&s, "TIMEOUT %d", timeout); - - write_and_retry(fd, s); - - free(s); - -} - -void usplash_failure(int fd, char *format, ...) { - char *s, *s1; - va_list argp; - - va_start(argp, format); - vasprintf(&s, format, argp); - va_end(argp); - - asprintf(&s1, "FAILURE %s", s); - - write_and_retry(fd, s1); - - free(s); - free(s1); -} - -void usplash_text(int fd, char *format, ...) { - char *s, *s1; - va_list argp; - - va_start(argp, format); - vasprintf(&s, format, argp); - va_end(argp); - - asprintf(&s1, "TEXT %s", s); - - write_and_retry(fd, s1); - - free(s); - free(s1); -} - -void usplash_urgent(int fd, char *format, ...) { - char *s, *s1; - va_list argp; - - va_start(argp, format); - vasprintf(&s, format, argp); - va_end(argp); - - asprintf(&s1, "TEXT-URGENT %s", s); - - write_and_retry(fd, s1); - - free(s); - free(s1); -} - - -void usplash_success(int fd, char *format, ...) { - char *s, *s1; - va_list argp; - - va_start(argp, format); - vasprintf(&s, format, argp); - va_end(argp); - - asprintf(&s1, "SUCCESS %s", s); - - write_and_retry(fd, s1); - - free(s); - free(s1); -} - -void usplash_progress(int fd, int progress) { - static int prevprogress = -1; - char *s; - - if (progress == prevprogress) - return; - prevprogress = progress; - - asprintf(&s, "PROGRESS %d", progress); - - write_and_retry(fd, s); - - free(s); -} - -int set_nocanonical_tty(int fd) { - struct termios t; - - if (tcgetattr(fd, &t) == -1) { - perror("tcgetattr"); - } - t.c_lflag &= ~ICANON; - t.c_cc[VMIN] = 1; - t.c_cc[VTIME] = 0; - return tcsetattr(fd, TCSANOW, &t); -} - -int main(int argc, char **argv) { - - int pipe_fd, check_fd; - int failed = 0; - - FILE *md5_file; - md5_state_t state; - md5_byte_t digest[16]; - char hex_output[16*2 + 1]; - char *checksum, *checkfile; - ssize_t tsize, csize; - - tsize = 0; - csize = 0; - - if (argc != 3) { - fprintf(stderr,"Wrong number of arguments\n"); - fprintf(stderr,"%s \n", argv[0]); - exit(1); - } - - if (chdir(argv[1]) != 0) { - perror("chdir"); - exit(1); - } - - pipe_fd = open(USPLASH_FIFO, O_WRONLY|O_NONBLOCK); - - if (pipe_fd == -1) { - /* We can't really do anything useful here */ - perror("Opening pipe"); - exit(1); - } - - - usplash_progress(pipe_fd, 0); - usplash_urgent(pipe_fd, "Checking integrity, this may take some time"); - md5_file = fopen(argv[2], "r"); - if (!md5_file) { - perror("fopen md5_file"); - exit(1); - } - while (fscanf(md5_file, "%as %as", &checksum, &checkfile) == 2) { - struct stat statbuf; - - if (stat(checkfile, &statbuf) == 0) { - tsize += statbuf.st_size; - } - - free(checksum); - free(checkfile); - } - - rewind(md5_file); - while (fscanf(md5_file, "%as %as", &checksum, &checkfile) == 2) { - char buf[BUFSIZ]; - ssize_t rsize; - int i; - - md5_init(&state); - - usplash_text(pipe_fd, "Checking %s", checkfile); - - check_fd = open(checkfile, O_RDONLY); - if (check_fd < 0) { - usplash_timeout(pipe_fd, 300); - usplash_failure(pipe_fd, "%s", strerror(errno)); - sleep(10); - } - - rsize = read(check_fd, buf, sizeof(buf)); - - while (rsize > 0) { - csize += rsize; - usplash_progress(pipe_fd, floorl(100*((long double)csize)/tsize)); - - md5_append(&state, (const md5_byte_t *)buf, rsize); - rsize = read(check_fd, buf, sizeof(buf)); - } - - close(check_fd); - md5_finish(&state, digest); - - for (i = 0; i < 16; i++) - sprintf(hex_output + i * 2, "%02x", digest[i]); - - if (strncmp(hex_output, checksum, strlen(hex_output)) == 0) { - usplash_success(pipe_fd, "OK"); - } else { - usplash_failure(pipe_fd, "mismatch"); - failed++; - } - free(checksum); - free(checkfile); - } - if (failed) { - usplash_urgent(pipe_fd, "Check finished: errors found in %d files!", failed); - } else { - usplash_urgent(pipe_fd, "Check finished: no errors found"); - } - usplash_urgent(pipe_fd, "Press any key to reboot your system"); - usplash_timeout(pipe_fd, 86400); - set_nocanonical_tty(0); - getchar(); - reboot(LINUX_REBOOT_CMD_RESTART); - return 0; - -} diff --git a/casper-md5check/md5.c b/casper-md5check/md5.c deleted file mode 100644 index c35d96c..0000000 --- a/casper-md5check/md5.c +++ /dev/null @@ -1,381 +0,0 @@ -/* - Copyright (C) 1999, 2000, 2002 Aladdin Enterprises. All rights reserved. - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - L. Peter Deutsch - ghost@aladdin.com - - */ -/* $Id: md5.c,v 1.6 2002/04/13 19:20:28 lpd Exp $ */ -/* - Independent implementation of MD5 (RFC 1321). - - This code implements the MD5 Algorithm defined in RFC 1321, whose - text is available at - http://www.ietf.org/rfc/rfc1321.txt - The code is derived from the text of the RFC, including the test suite - (section A.5) but excluding the rest of Appendix A. It does not include - any code or documentation that is identified in the RFC as being - copyrighted. - - The original and principal author of md5.c is L. Peter Deutsch - . Other authors are noted in the change history - that follows (in reverse chronological order): - - 2002-04-13 lpd Clarified derivation from RFC 1321; now handles byte order - either statically or dynamically; added missing #include - in library. - 2002-03-11 lpd Corrected argument list for main(), and added int return - type, in test program and T value program. - 2002-02-21 lpd Added missing #include in test program. - 2000-07-03 lpd Patched to eliminate warnings about "constant is - unsigned in ANSI C, signed in traditional"; made test program - self-checking. - 1999-11-04 lpd Edited comments slightly for automatic TOC extraction. - 1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5). - 1999-05-03 lpd Original version. - */ - -#include "md5.h" -#include - -#undef BYTE_ORDER /* 1 = big-endian, -1 = little-endian, 0 = unknown */ -#ifdef ARCH_IS_BIG_ENDIAN -# define BYTE_ORDER (ARCH_IS_BIG_ENDIAN ? 1 : -1) -#else -# define BYTE_ORDER 0 -#endif - -#define T_MASK ((md5_word_t)~0) -#define T1 /* 0xd76aa478 */ (T_MASK ^ 0x28955b87) -#define T2 /* 0xe8c7b756 */ (T_MASK ^ 0x173848a9) -#define T3 0x242070db -#define T4 /* 0xc1bdceee */ (T_MASK ^ 0x3e423111) -#define T5 /* 0xf57c0faf */ (T_MASK ^ 0x0a83f050) -#define T6 0x4787c62a -#define T7 /* 0xa8304613 */ (T_MASK ^ 0x57cfb9ec) -#define T8 /* 0xfd469501 */ (T_MASK ^ 0x02b96afe) -#define T9 0x698098d8 -#define T10 /* 0x8b44f7af */ (T_MASK ^ 0x74bb0850) -#define T11 /* 0xffff5bb1 */ (T_MASK ^ 0x0000a44e) -#define T12 /* 0x895cd7be */ (T_MASK ^ 0x76a32841) -#define T13 0x6b901122 -#define T14 /* 0xfd987193 */ (T_MASK ^ 0x02678e6c) -#define T15 /* 0xa679438e */ (T_MASK ^ 0x5986bc71) -#define T16 0x49b40821 -#define T17 /* 0xf61e2562 */ (T_MASK ^ 0x09e1da9d) -#define T18 /* 0xc040b340 */ (T_MASK ^ 0x3fbf4cbf) -#define T19 0x265e5a51 -#define T20 /* 0xe9b6c7aa */ (T_MASK ^ 0x16493855) -#define T21 /* 0xd62f105d */ (T_MASK ^ 0x29d0efa2) -#define T22 0x02441453 -#define T23 /* 0xd8a1e681 */ (T_MASK ^ 0x275e197e) -#define T24 /* 0xe7d3fbc8 */ (T_MASK ^ 0x182c0437) -#define T25 0x21e1cde6 -#define T26 /* 0xc33707d6 */ (T_MASK ^ 0x3cc8f829) -#define T27 /* 0xf4d50d87 */ (T_MASK ^ 0x0b2af278) -#define T28 0x455a14ed -#define T29 /* 0xa9e3e905 */ (T_MASK ^ 0x561c16fa) -#define T30 /* 0xfcefa3f8 */ (T_MASK ^ 0x03105c07) -#define T31 0x676f02d9 -#define T32 /* 0x8d2a4c8a */ (T_MASK ^ 0x72d5b375) -#define T33 /* 0xfffa3942 */ (T_MASK ^ 0x0005c6bd) -#define T34 /* 0x8771f681 */ (T_MASK ^ 0x788e097e) -#define T35 0x6d9d6122 -#define T36 /* 0xfde5380c */ (T_MASK ^ 0x021ac7f3) -#define T37 /* 0xa4beea44 */ (T_MASK ^ 0x5b4115bb) -#define T38 0x4bdecfa9 -#define T39 /* 0xf6bb4b60 */ (T_MASK ^ 0x0944b49f) -#define T40 /* 0xbebfbc70 */ (T_MASK ^ 0x4140438f) -#define T41 0x289b7ec6 -#define T42 /* 0xeaa127fa */ (T_MASK ^ 0x155ed805) -#define T43 /* 0xd4ef3085 */ (T_MASK ^ 0x2b10cf7a) -#define T44 0x04881d05 -#define T45 /* 0xd9d4d039 */ (T_MASK ^ 0x262b2fc6) -#define T46 /* 0xe6db99e5 */ (T_MASK ^ 0x1924661a) -#define T47 0x1fa27cf8 -#define T48 /* 0xc4ac5665 */ (T_MASK ^ 0x3b53a99a) -#define T49 /* 0xf4292244 */ (T_MASK ^ 0x0bd6ddbb) -#define T50 0x432aff97 -#define T51 /* 0xab9423a7 */ (T_MASK ^ 0x546bdc58) -#define T52 /* 0xfc93a039 */ (T_MASK ^ 0x036c5fc6) -#define T53 0x655b59c3 -#define T54 /* 0x8f0ccc92 */ (T_MASK ^ 0x70f3336d) -#define T55 /* 0xffeff47d */ (T_MASK ^ 0x00100b82) -#define T56 /* 0x85845dd1 */ (T_MASK ^ 0x7a7ba22e) -#define T57 0x6fa87e4f -#define T58 /* 0xfe2ce6e0 */ (T_MASK ^ 0x01d3191f) -#define T59 /* 0xa3014314 */ (T_MASK ^ 0x5cfebceb) -#define T60 0x4e0811a1 -#define T61 /* 0xf7537e82 */ (T_MASK ^ 0x08ac817d) -#define T62 /* 0xbd3af235 */ (T_MASK ^ 0x42c50dca) -#define T63 0x2ad7d2bb -#define T64 /* 0xeb86d391 */ (T_MASK ^ 0x14792c6e) - - -static void -md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/) -{ - md5_word_t - a = pms->abcd[0], b = pms->abcd[1], - c = pms->abcd[2], d = pms->abcd[3]; - md5_word_t t; -#if BYTE_ORDER > 0 - /* Define storage only for big-endian CPUs. */ - md5_word_t X[16]; -#else - /* Define storage for little-endian or both types of CPUs. */ - md5_word_t xbuf[16]; - const md5_word_t *X; -#endif - - { -#if BYTE_ORDER == 0 - /* - * Determine dynamically whether this is a big-endian or - * little-endian machine, since we can use a more efficient - * algorithm on the latter. - */ - static const int w = 1; - - if (*((const md5_byte_t *)&w)) /* dynamic little-endian */ -#endif -#if BYTE_ORDER <= 0 /* little-endian */ - { - /* - * On little-endian machines, we can process properly aligned - * data without copying it. - */ - if (!((data - (const md5_byte_t *)0) & 3)) { - /* data are properly aligned */ - X = (const md5_word_t *)data; - } else { - /* not aligned */ - memcpy(xbuf, data, 64); - X = xbuf; - } - } -#endif -#if BYTE_ORDER == 0 - else /* dynamic big-endian */ -#endif -#if BYTE_ORDER >= 0 /* big-endian */ - { - /* - * On big-endian machines, we must arrange the bytes in the - * right order. - */ - const md5_byte_t *xp = data; - int i; - -# if BYTE_ORDER == 0 - X = xbuf; /* (dynamic only) */ -# else -# define xbuf X /* (static only) */ -# endif - for (i = 0; i < 16; ++i, xp += 4) - xbuf[i] = xp[0] + (xp[1] << 8) + (xp[2] << 16) + (xp[3] << 24); - } -#endif - } - -#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32 - (n)))) - - /* Round 1. */ - /* Let [abcd k s i] denote the operation - a = b + ((a + F(b,c,d) + X[k] + T[i]) <<< s). */ -#define F(x, y, z) (((x) & (y)) | (~(x) & (z))) -#define SET(a, b, c, d, k, s, Ti)\ - t = a + F(b,c,d) + X[k] + Ti;\ - a = ROTATE_LEFT(t, s) + b - /* Do the following 16 operations. */ - SET(a, b, c, d, 0, 7, T1); - SET(d, a, b, c, 1, 12, T2); - SET(c, d, a, b, 2, 17, T3); - SET(b, c, d, a, 3, 22, T4); - SET(a, b, c, d, 4, 7, T5); - SET(d, a, b, c, 5, 12, T6); - SET(c, d, a, b, 6, 17, T7); - SET(b, c, d, a, 7, 22, T8); - SET(a, b, c, d, 8, 7, T9); - SET(d, a, b, c, 9, 12, T10); - SET(c, d, a, b, 10, 17, T11); - SET(b, c, d, a, 11, 22, T12); - SET(a, b, c, d, 12, 7, T13); - SET(d, a, b, c, 13, 12, T14); - SET(c, d, a, b, 14, 17, T15); - SET(b, c, d, a, 15, 22, T16); -#undef SET - - /* Round 2. */ - /* Let [abcd k s i] denote the operation - a = b + ((a + G(b,c,d) + X[k] + T[i]) <<< s). */ -#define G(x, y, z) (((x) & (z)) | ((y) & ~(z))) -#define SET(a, b, c, d, k, s, Ti)\ - t = a + G(b,c,d) + X[k] + Ti;\ - a = ROTATE_LEFT(t, s) + b - /* Do the following 16 operations. */ - SET(a, b, c, d, 1, 5, T17); - SET(d, a, b, c, 6, 9, T18); - SET(c, d, a, b, 11, 14, T19); - SET(b, c, d, a, 0, 20, T20); - SET(a, b, c, d, 5, 5, T21); - SET(d, a, b, c, 10, 9, T22); - SET(c, d, a, b, 15, 14, T23); - SET(b, c, d, a, 4, 20, T24); - SET(a, b, c, d, 9, 5, T25); - SET(d, a, b, c, 14, 9, T26); - SET(c, d, a, b, 3, 14, T27); - SET(b, c, d, a, 8, 20, T28); - SET(a, b, c, d, 13, 5, T29); - SET(d, a, b, c, 2, 9, T30); - SET(c, d, a, b, 7, 14, T31); - SET(b, c, d, a, 12, 20, T32); -#undef SET - - /* Round 3. */ - /* Let [abcd k s t] denote the operation - a = b + ((a + H(b,c,d) + X[k] + T[i]) <<< s). */ -#define H(x, y, z) ((x) ^ (y) ^ (z)) -#define SET(a, b, c, d, k, s, Ti)\ - t = a + H(b,c,d) + X[k] + Ti;\ - a = ROTATE_LEFT(t, s) + b - /* Do the following 16 operations. */ - SET(a, b, c, d, 5, 4, T33); - SET(d, a, b, c, 8, 11, T34); - SET(c, d, a, b, 11, 16, T35); - SET(b, c, d, a, 14, 23, T36); - SET(a, b, c, d, 1, 4, T37); - SET(d, a, b, c, 4, 11, T38); - SET(c, d, a, b, 7, 16, T39); - SET(b, c, d, a, 10, 23, T40); - SET(a, b, c, d, 13, 4, T41); - SET(d, a, b, c, 0, 11, T42); - SET(c, d, a, b, 3, 16, T43); - SET(b, c, d, a, 6, 23, T44); - SET(a, b, c, d, 9, 4, T45); - SET(d, a, b, c, 12, 11, T46); - SET(c, d, a, b, 15, 16, T47); - SET(b, c, d, a, 2, 23, T48); -#undef SET - - /* Round 4. */ - /* Let [abcd k s t] denote the operation - a = b + ((a + I(b,c,d) + X[k] + T[i]) <<< s). */ -#define I(x, y, z) ((y) ^ ((x) | ~(z))) -#define SET(a, b, c, d, k, s, Ti)\ - t = a + I(b,c,d) + X[k] + Ti;\ - a = ROTATE_LEFT(t, s) + b - /* Do the following 16 operations. */ - SET(a, b, c, d, 0, 6, T49); - SET(d, a, b, c, 7, 10, T50); - SET(c, d, a, b, 14, 15, T51); - SET(b, c, d, a, 5, 21, T52); - SET(a, b, c, d, 12, 6, T53); - SET(d, a, b, c, 3, 10, T54); - SET(c, d, a, b, 10, 15, T55); - SET(b, c, d, a, 1, 21, T56); - SET(a, b, c, d, 8, 6, T57); - SET(d, a, b, c, 15, 10, T58); - SET(c, d, a, b, 6, 15, T59); - SET(b, c, d, a, 13, 21, T60); - SET(a, b, c, d, 4, 6, T61); - SET(d, a, b, c, 11, 10, T62); - SET(c, d, a, b, 2, 15, T63); - SET(b, c, d, a, 9, 21, T64); -#undef SET - - /* Then perform the following additions. (That is increment each - of the four registers by the value it had before this block - was started.) */ - pms->abcd[0] += a; - pms->abcd[1] += b; - pms->abcd[2] += c; - pms->abcd[3] += d; -} - -void -md5_init(md5_state_t *pms) -{ - pms->count[0] = pms->count[1] = 0; - pms->abcd[0] = 0x67452301; - pms->abcd[1] = /*0xefcdab89*/ T_MASK ^ 0x10325476; - pms->abcd[2] = /*0x98badcfe*/ T_MASK ^ 0x67452301; - pms->abcd[3] = 0x10325476; -} - -void -md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes) -{ - const md5_byte_t *p = data; - int left = nbytes; - int offset = (pms->count[0] >> 3) & 63; - md5_word_t nbits = (md5_word_t)(nbytes << 3); - - if (nbytes <= 0) - return; - - /* Update the message length. */ - pms->count[1] += nbytes >> 29; - pms->count[0] += nbits; - if (pms->count[0] < nbits) - pms->count[1]++; - - /* Process an initial partial block. */ - if (offset) { - int copy = (offset + nbytes > 64 ? 64 - offset : nbytes); - - memcpy(pms->buf + offset, p, copy); - if (offset + copy < 64) - return; - p += copy; - left -= copy; - md5_process(pms, pms->buf); - } - - /* Process full blocks. */ - for (; left >= 64; p += 64, left -= 64) - md5_process(pms, p); - - /* Process a final partial block. */ - if (left) - memcpy(pms->buf, p, left); -} - -void -md5_finish(md5_state_t *pms, md5_byte_t digest[16]) -{ - static const md5_byte_t pad[64] = { - 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - md5_byte_t data[8]; - int i; - - /* Save the length before padding. */ - for (i = 0; i < 8; ++i) - data[i] = (md5_byte_t)(pms->count[i >> 2] >> ((i & 3) << 3)); - /* Pad to 56 bytes mod 64. */ - md5_append(pms, pad, ((55 - (pms->count[0] >> 3)) & 63) + 1); - /* Append the length. */ - md5_append(pms, data, 8); - for (i = 0; i < 16; ++i) - digest[i] = (md5_byte_t)(pms->abcd[i >> 2] >> ((i & 3) << 3)); -} diff --git a/casper-md5check/md5.h b/casper-md5check/md5.h deleted file mode 100644 index 698c995..0000000 --- a/casper-md5check/md5.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - Copyright (C) 1999, 2002 Aladdin Enterprises. All rights reserved. - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - L. Peter Deutsch - ghost@aladdin.com - - */ -/* $Id: md5.h,v 1.4 2002/04/13 19:20:28 lpd Exp $ */ -/* - Independent implementation of MD5 (RFC 1321). - - This code implements the MD5 Algorithm defined in RFC 1321, whose - text is available at - http://www.ietf.org/rfc/rfc1321.txt - The code is derived from the text of the RFC, including the test suite - (section A.5) but excluding the rest of Appendix A. It does not include - any code or documentation that is identified in the RFC as being - copyrighted. - - The original and principal author of md5.h is L. Peter Deutsch - . Other authors are noted in the change history - that follows (in reverse chronological order): - - 2002-04-13 lpd Removed support for non-ANSI compilers; removed - references to Ghostscript; clarified derivation from RFC 1321; - now handles byte order either statically or dynamically. - 1999-11-04 lpd Edited comments slightly for automatic TOC extraction. - 1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5); - added conditionalization for C++ compilation from Martin - Purschke . - 1999-05-03 lpd Original version. - */ - -#ifndef md5_INCLUDED -# define md5_INCLUDED - -/* - * This package supports both compile-time and run-time determination of CPU - * byte order. If ARCH_IS_BIG_ENDIAN is defined as 0, the code will be - * compiled to run only on little-endian CPUs; if ARCH_IS_BIG_ENDIAN is - * defined as non-zero, the code will be compiled to run only on big-endian - * CPUs; if ARCH_IS_BIG_ENDIAN is not defined, the code will be compiled to - * run on either big- or little-endian CPUs, but will run slightly less - * efficiently on either one than if ARCH_IS_BIG_ENDIAN is defined. - */ - -typedef unsigned char md5_byte_t; /* 8-bit byte */ -typedef unsigned int md5_word_t; /* 32-bit word */ - -/* Define the state of the MD5 Algorithm. */ -typedef struct md5_state_s { - md5_word_t count[2]; /* message length in bits, lsw first */ - md5_word_t abcd[4]; /* digest buffer */ - md5_byte_t buf[64]; /* accumulate block */ -} md5_state_t; - -#ifdef __cplusplus -extern "C" -{ -#endif - -/* Initialize the algorithm. */ -void md5_init(md5_state_t *pms); - -/* Append a string to the message. */ -void md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes); - -/* Finish the message and return the digest. */ -void md5_finish(md5_state_t *pms, md5_byte_t digest[16]); - -#ifdef __cplusplus -} /* end extern "C" */ -#endif - -#endif /* md5_INCLUDED */ diff --git a/casper.conf b/casper.conf deleted file mode 100644 index e56ded3..0000000 --- a/casper.conf +++ /dev/null @@ -1,8 +0,0 @@ -# This file should go in /etc/casper.conf -# Supported variables are: -# USERNAME, USERFULLNAME, HOST, BUILD_SYSTEM - -export USERNAME="ubuntu" -export USERFULLNAME="Live session user" -export HOST="ubuntu" -export BUILD_SYSTEM="Ubuntu" diff --git a/caspermon/GNOME_PythonAppletCasper.server b/caspermon/GNOME_PythonAppletCasper.server deleted file mode 100644 index 34caa04..0000000 --- a/caspermon/GNOME_PythonAppletCasper.server +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/caspermon/caspermon-applet b/caspermon/caspermon-applet deleted file mode 100755 index 773e0a4..0000000 --- a/caspermon/caspermon-applet +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/python - -import pygtk -pygtk.require('2.0') - -import gtk -import gnome.applet -import subprocess -import os - -# A simple applet to display the utilization of the snapshot device -# during a casper session -# -# Matt Zimmerman - -# TODO: -# - tooltip with details -# - flash at threshold - -class CasperApplet: - def __init__(self, applet, iid): - self.timeout_interval = 1000 - self.device = 'casper-snapshot' - self.capacity = [0,0] - self.datafile = '/var/lib/casper/snapshot-status' - - # initializate the gnome internals - gnome.init("casper", "0.1") - - self.applet = applet - - self.tooltips = gtk.Tooltips() - self.hbox = gtk.HBox() - applet.add(self.hbox) - - # add the second button event for the popup menu and the enter mouse event to change the tooltip value - self.ev_box = gtk.EventBox() - #self.ev_box.connect("button-press-event",self.button_press) - self.ev_box.connect("enter-notify-event", self.update_info) - self.hbox.add(self.ev_box) - - self.prog = gtk.ProgressBar() - self.ev_box.add(self.prog) - - self.update_info() - - gtk.timeout_add(self.timeout_interval,self.update_info, self) - - applet.connect("destroy",self.cleanup) - applet.show_all() - - def update_info(self, event=None): - self.capacity = self.read_info() - self.prog.set_fraction(float(self.capacity[0]) / self.capacity[1]) - self.prog.update() - - def read_info(self): - fields = open(self.datafile).readline().split() - if fields[2] != 'snapshot': - return None - - return map(int,fields[3].split('/', 1)) - - def cleanup(self): - # what goes here? - pass - -def casper_factory(applet, iid): - CasperApplet(applet, iid) - - return gtk.TRUE - -gnome.applet.bonobo_factory("OAFIID:GNOME_PythonAppletCasper_Factory", - gnome.applet.Applet.__gtype__, - "casper", "0", casper_factory) diff --git a/caspermon/caspermond b/caspermon/caspermond deleted file mode 100644 index e126447..0000000 --- a/caspermon/caspermond +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -STATEFILE=/var/run/caspermond/status.casper-snapshot - -while true; do - dmsetup status /dev/mapper/casper-snapshot > $STATEFILE.new - mv $STATEFILE.new $STATEFILE - sleep 60 -done diff --git a/conf/live.conf b/conf/live.conf new file mode 100644 index 0000000..0b44894 --- /dev/null +++ b/conf/live.conf @@ -0,0 +1,9 @@ +# /etc/live.conf: configuration file for live-initramfs + +BUILD_SYSTEM="Debian" + +USERNAME="user" +USERFULLNAME="Live session user" +HOST="debian" + +export BUILD_SYSTEM USERNAME USERFULLNAME HOST diff --git a/debian/changelog b/debian/changelog index 2016c6f..1125793 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +live-initramfs (1.87.2-1) unstable; urgency=low + + * New upstream release. + + -- Daniel Baumann Mon, 7 May 2007 00:00:00 +0200 + live-initramfs (1.87.1-1) unstable; urgency=low * Initial release, forking casper. diff --git a/debian/copyright b/debian/copyright index d1c73c0..0174d36 100644 --- a/debian/copyright +++ b/debian/copyright @@ -36,7 +36,7 @@ License: On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL file. -License (casper-md5check/md5.c, casper-md5check/md5,h): +License (live-md5check/md5.c, live-md5check/md5,h): Copyright (C) 1999-2002 Aladdin Enterprises All rights reserved. diff --git a/debian/dirs b/debian/dirs index bb225f1..f929f0c 100644 --- a/debian/dirs +++ b/debian/dirs @@ -1,4 +1,4 @@ /etc -/usr/lib/casper +/usr/lib/live-initramfs /usr/share/initramfs-tools/hooks /usr/share/initramfs-tools/scripts diff --git a/debian/examples b/debian/examples index 195687c..63403a0 100644 --- a/debian/examples +++ b/debian/examples @@ -1 +1 @@ -casper.conf +conf/live.conf diff --git a/debian/init b/debian/init index 4e53eff..7c0dbe9 100644 --- a/debian/init +++ b/debian/init @@ -1,6 +1,6 @@ #! /bin/sh ### BEGIN INIT INFO -# Provides: casper +# Provides: live-initramfs # Required-Start: $syslog # Required-Stop: $syslog # Should-Start: $local_fs @@ -16,15 +16,15 @@ # Marco Amadori # PATH=/usr/sbin:/usr/bin:/sbin:/bin -NAME=casper +NAME=live-initramfs SCRIPTNAME=/etc/init.d/${NAME} -DO_SNAPSHOT=/sbin/${NAME}-snapshot +DO_SNAPSHOT=/sbin/live-snapshot -# Exit if system was not booted by casper -grep -qs boot=casper /proc/cmdline || exit 0 +# Exit if system was not booted by live-initramfs +grep -qs boot=live /proc/cmdline || exit 0 # Read configuration variable file if it is present -[ -r /etc/$NAME.conf ] && . /etc/$NAME.conf +[ -r /etc/live.conf ] && . /etc/live.conf # Load the VERBOSE setting and other rcS variables [ -f /etc/default/rcS ] && . /etc/default/rcS diff --git a/debian/install b/debian/install index 9e87fd8..fb597d4 100644 --- a/debian/install +++ b/debian/install @@ -1,7 +1,7 @@ -bin/casper-getty sbin -bin/casper-login sbin -bin/casper-preseed usr/share/casper -bin/casper-reconfigure usr/share/casper -bin/casper-snapshot sbin +bin/live-getty sbin +bin/live-login sbin +bin/live-preseed usr/share/live-initramfs +bin/live-reconfigure usr/share/live-initramfs +bin/live-snapshot sbin hooks usr/share/initramfs-tools scripts usr/share/initramfs-tools diff --git a/debian/links b/debian/links index 0d1d1df..fa3fb68 100644 --- a/debian/links +++ b/debian/links @@ -1,2 +1,2 @@ -/usr/share/man/man7/casper.7.gz /usr/share/man/man7/casper-getty.7.gz -/usr/share/man/man7/casper.7.gz /usr/share/man/man7/casper-login.7.gz +/usr/share/man/man7/casper.7.gz /usr/share/man/man7/live-getty.7.gz +/usr/share/man/man7/casper.7.gz /usr/share/man/man7/live-login.7.gz diff --git a/debian/manpage/casper-snapshot.1 b/debian/manpage/casper-snapshot.1 deleted file mode 100644 index 8f27412..0000000 --- a/debian/manpage/casper-snapshot.1 +++ /dev/null @@ -1,70 +0,0 @@ -.TH "CASPER-SNAPSHOT" 1 "Thu, 28 Sep 2006" "0.0.1" "User commands" - -.SH NAME -casper-snapshot \- a simple script to ease persistence usage. - -.SH SYNOPSIS -.B casper-snapshot -.RB [\| \-c \||\| \-\-cow -.IR DIRECTORY \|] -.RB [\| \-d \||\| \-\-device -.IR DEVICE \|] -.RB [\| \-e \||\| \-\-exclude\-list -.IR FILE \|] -.RB [\| \-o \||\| \-\-output -.IR FILE \|] -.RB [\| \-t \||\| \-\-type -.IR TYPE \|] -.PP -.B casper-snapshot -.RB \-r \||\| \-\-resync\-string -.IR STRING -.br -.B casper-snapshot -.RB \-h \||\| \-\-help -.br -.B casper-snapshot -.RB \-u \||\| \-\-usage -.br -.B casper-snapshot -.RB \-v \||\| \-\-version - -.SH DESCRIPTION -Casper-snapshot is a script which can be used to build the right types of persistent image files supported by casper. It is also used on exit by the casper init script to resync the boot-found snapshots devices. - -.SH OPTIONS -.TP -.BI "\-c, \-\-cow" DIRECTORY -specifies the input directory to be cloned in the image file. -Its default value "/cow" should be right for most uses. However it could be handy to specify "/home" and type ext2 for the type to prepare an image file suited to be directly mounted by casper as home. -.TP -.BI "\-d, \-\-device" DEVICE -sets the device where the media which the snapshot/persistence file/partition will be put. If it is not specified, a tmpfs will be used and linked to the user's desktop to move it where it is needed. If the device has no filesystem, an ext2 fs will be automatically created and labelled according to the values specified after the "--output" value or with a sane default. -.TP -.BI "\-e, \-\-exclude\-list" FILE -a file containing a list of filenames/paths that should not be saved. This exclude list will be remebered on the target snapshot media for reuse. -.TP -.BI "\-o, \-\-output" FILE -the filename/label used for the output file/partition. If left blank, casper-snapshot will search for a proper file on the device or use the whole partition. -.TP -.BI "\-r, \-\-resync\-string" STRING -internally used on resyncs. -.TP -.BI "\-t, \-\-type" TYPE -Type could be one of "cpio", "squashfs" or "ext2". - -.SH BUGS -.B casper-snapshot -Time (and BTS) will tell. - -.SH HOMEPAGE -Debian Live project - -.SH SEE ALSO -.BR casper(7) - -.SH AUTHOR -casper-snapshot was written Marco Amadori . -.TP -This manual page was written by Marco Amadori , -for the Debian project (but may be used by others). diff --git a/debian/manpage/casper.7 b/debian/manpage/casper.7 deleted file mode 100644 index 20805b9..0000000 --- a/debian/manpage/casper.7 +++ /dev/null @@ -1,84 +0,0 @@ -.TH CASPER 7 "Thu, 28 Sep 2006" "1.69" "Initramfs-tools hook" - -.SH NAME -casper \- a hook for initramfs-tools to boot live systems. - -.SH SYNOPSIS -.B BOOT=casper -As kernel parameter boot prompt. - -.SH DESCRIPTION -Casper is a hook for initramfs-tools used to generate an initramfs capable to boot live systems as those created by make-live. This includes the Debian-Live isos, netboot tarballs, and usb stick images and Ubuntu live cds. At boot time it will look for a (read-only) media containing a "/casper" directory where a root filesystems (often a compressed squashfs) is stored. If found, it will create a writable environment, using unionfs, for debian like systems to boot from. - -.SH RECOGNIZED BOOT OPTIONS -.TP -.B casper-getty -This enables a special "serial" login shell (experimental). -.TP -.B xdebconf -uses xdebconfigurator, if present on the rootfs, to configure X instead of the standard procedure (experimental). -.TP -.BI "hostname=" HOSTNAME " , userfullname=" USERFULLNAME " , username=" USERNAME -Those parameters lets you override values read from the config file. -.TP -.BI "{keyb|kbd-chooser/method}=" KEYBOARD " , {klayout|console-setup/layoutcode}=" LAYOUT " , {kvariant|console-setup/variantcode}=" VARIANT " , {kmodel|console-setup/modelcode}=" CODE " , koptions=" OPTIONS -Configure the running keyboard as specified, if this one misses casper behaves as if "keyb=us" was specified. It will be interfered from "locale=" if locale is only 2 lowecase letters as a special case. You could also specify console layout, variant, code, and options (no defaults). -.TP -.BI ip= IFACE,ADDRESS,NETMASK,GATEWAY [ :IFACE,ADDRESS,NETMASK,GATEWAY "]*" -Let you specify the name(s) and the options of the interface(s) that should be configured at boot time. Do not specify this if you want to use dhcp (default). -.TP -.BR ip[= frommedia ] -If this variable is set, dhcp and static configuration are just skipped and the system will use the (must be) media-preconfigured /etc/network/interfaces instead. -.TP -.BI "{live-media|bootfrom}=" DEVICE -If you specify one of this two equivalent forms, casper will first try to find this device for the "/casper" directory where the read-only root filesystem should reside. If it did not find something usable, the normal scan for block devices is performed. -.TP -.BI "live-media-offset=" BYTES -This way you could tell casper that your image starts at offset BYTES in the above specified or autodiscovered device, this could be useful to hide the debian-live iso or image inside another iso or image, to create "clean" images. -.TP -.BI "locale=" LOCALE " | debian-installer/locale=" LOCALE -Configure the running locale as specified, if not present the live-media rootfs configured locale will be used and if also this one misses casper behave as "locale=en_US.UTF-8" was specified. If only 2 lowercase letter are specified (like "it"), the "maybe wanted" locale is generated (like it:IT.UTF-8), in this case if also "keyb=" is unspecified is set with those 2 lowercase letters (keyb=it). -.TP -.BR "netboot[=" nfs "|" cifs ] -This tells casper to perform a network mount. The parameter "nfsroot=" (with optional "nfsopts="), should specify where is the location of the root filesystem. With no args, will try cifs first, and if it fails nfs. -.TP -.B persistent -Casper will look for persistent and snapshot partitions or files labeled "casper-rw", "home-rw", and files called "casper-sn*", "home-sn*" and will try to, in order: mount as /cow the first, mount the second in /home, and just copy the contents of the latter in appropriate locations (snapshots). Snapshots will be tried to be updated on reboot/shutdown. Look at casper-snapshot(1) for more informations. -.TP -.B nopersistent -disables the above mentioned "persistent" feature, useful if the bootloader (like syslinux) has been installed with persistent enabled. -.TP -.B "showmounts" -This parameter will make casper to show on "/" the ro filesystems (mostly compressed) on /casper. This is not enabled by default because could lead to problems by applications like "mono" which store binary paths on installation. -.TP -.BI "todisk=" DEVICE -Adding this parameter, casper will try to copy the entire read-only media to the specified device before mounting the root filesystem. It probably needs a lot of free space. Subsequent boots should then skip this step and just specify the "live-media=DEVICE" boot parameter with the same DEVICE used this time. -.TP -.B toram -Adding this parameter, casper will try to copy the whole read-only media to the computer's RAM before mounting the root filesystem. This could need a lot of ram, according to the space used by the read-only media. -.TP -.BI "{preseed/file|file}=" FILE -A path to a file present on the rootfs could be used to preseed debconf database. -.TP -.BI "package/question=" VALUE -All debian installed packages could be preseeded from command-line that way, beware of blanks spaces, they will interfere with parsing, use a preseed file in this case. - -.SH FILES -.B /etc/casper.conf -some variables can be configured via this config file. - -.SH BUGS -.B casper -works fully on amd64, i386 and ppc, it should also run on other archs. - -.SH HOMEPAGE -Debian Live project - -.SH SEE ALSO -.BR casper-snapshot(1), initramfs-tools(8), make-live(8), make-live.conf(5) - -.SH AUTHOR -casper was written by Tollen Fog Heen , Matt Zimmerman , and Marco Amadori . -.TP -This manual page was written by Marco Amadori , -for the Debian project (but may be used by others). diff --git a/debian/manpages b/debian/manpages index 31eb23e..96c4bf7 100644 --- a/debian/manpages +++ b/debian/manpages @@ -1 +1 @@ -debian/manpage/* +manpages/* diff --git a/debian/rules b/debian/rules index 34e0fae..79117a9 100755 --- a/debian/rules +++ b/debian/rules @@ -24,16 +24,16 @@ build-stamp: dh_testdir # Checking scripts - for SCRIPT in bin/* scripts/casper scripts/casper-bottom/*; \ + for SCRIPT in scripts/live scripts/live-bottom/*; \ do \ sh -n $$SCRIPT || exit 1; \ done # Setting BUILD_SYSTEM in the binary package - sed -i -e 's/\(BUILD_SYSTEM="\).*"/\1'$(BUILD_SYSTEM)'"/g' casper.conf + sed -e 's/\(BUILD_SYSTEM="\).*"/\1'$(BUILD_SYSTEM)'"/g' conf/live.conf > live.conf # Building package - CFLAGS="$(CFLAGS)" $(MAKE) -C casper-md5check + CFLAGS="$(CFLAGS)" $(MAKE) -C bin/live-md5check touch build-stamp @@ -43,7 +43,8 @@ clean: rm -f build-stamp # Cleaning package - $(MAKE) -C casper-md5check clean + $(MAKE) -C bin/live-md5check clean + rm -f live.conf dh_clean @@ -54,8 +55,8 @@ install: build dh_installdirs # Installing package - install -m 0755 casper-md5check/casper-md5check debian/live-initramfs/usr/lib/casper - install -m 0644 casper.conf debian/live-initramfs/etc/casper.conf + install -m 0755 bin/live-md5check/live-md5check debian/live-initramfs/usr/lib/live-initramfs + install -m 0644 live.conf debian/live-initramfs/etc/live.conf binary-indep: build install diff --git a/doc/ChangeLog b/doc/ChangeLog index af2cf53..087aa82 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,31 @@ +2007-05-06 Daniel Baumann + + * bin/casper-getty, casper-login, casper-preseed, casper-reconfigure, + casper-snapshot: + - Renamed to live-*. + * casper-md5check: + - Moved to bin. + - Renamed to live-md5check. + * casper.conf: + - Moved to conf/live.conf. + * caspermon: + - Removed. + * scripts/casper, casper-bottom, casper-functions, casper-helpers, + casper-premount: + - Renamed to live-*. + * bin/live-getty, live-login, conf/live.conf: + - Reformated. + * bin/live-snapshot, debian/dirs, debian/install, debian/rules, + hooks/live, scripts/live: + - Replaces casper path names with live. + * debian/manpage: + - Moved to manpages. + - Renamed casper.7 to live-initramfs.7. + * debian/init: + - Changed activation parameter from boot=casper to boot=live. + * scripts/casper-bottom/02_timezone: + - Fixed wrong script description. + 2007-04-30 Daniel Baumann * Forked casper 1.87. diff --git a/hooks/casper b/hooks/casper deleted file mode 100755 index 78a3cfb..0000000 --- a/hooks/casper +++ /dev/null @@ -1,75 +0,0 @@ -#!/bin/sh -e -# initramfs hook for casper - -PREREQS="" - -# Output pre-requisites -prereqs() -{ - echo "$PREREQ" -} - -case "$1" in - prereqs) - prereqs - exit 0 - ;; -esac - -. /usr/share/initramfs-tools/hook-functions - -manual_add_modules unionfs - -# We need losetup -copy_exec /sbin/losetup /sbin - -# Casper hooks -mkdir -p ${DESTDIR}/lib/casper -copy_exec /usr/share/casper/casper-reconfigure /bin -copy_exec /usr/share/casper/casper-preseed /bin - -mkdir -p ${DESTDIR}/lib/udev -copy_exec /lib/udev/cdrom_id /lib/udev -copy_exec /lib/udev/vol_id /lib/udev -copy_exec /lib/udev/path_id /lib/udev -copy_exec /usr/bin/udevinfo /bin -copy_exec /usr/bin/eject /bin - -# cifs boot -if [ -x /sbin/mount.cifs ]; then - copy_exec /sbin/mount.cifs /sbin - for x in cifs; do - manual_add_modules ${x} - done -fi - -# squashfs -manual_add_modules squashfs -manual_add_modules loop - -# random file system modules -manual_add_modules vfat -manual_add_modules ext3 -# needed for vfat. :-/ -manual_add_modules nls_cp437 -manual_add_modules nls_utf8 -manual_add_modules nls_iso8859-1 - -# cdrom modules -manual_add_modules sr_mod -manual_add_modules ide-cd -manual_add_modules sbp2 -manual_add_modules ohci1394 - -# integrity check -copy_exec /usr/lib/casper/casper-md5check /bin - -cp /usr/share/initramfs-tools/scripts/casper-functions $DESTDIR/scripts -cp /usr/share/initramfs-tools/scripts/casper-helpers $DESTDIR/scripts - -auto_add_modules net - -if [ -e /etc/casper.conf ]; then - mkdir -p ${DESTDIR}/etc - cp /etc/casper.conf ${DESTDIR}/etc -fi diff --git a/hooks/live b/hooks/live new file mode 100755 index 0000000..94383ca --- /dev/null +++ b/hooks/live @@ -0,0 +1,75 @@ +#!/bin/sh -e +# initramfs hook for casper + +PREREQS="" + +# Output pre-requisites +prereqs() +{ + echo "$PREREQ" +} + +case "$1" in + prereqs) + prereqs + exit 0 + ;; +esac + +. /usr/share/initramfs-tools/hook-functions + +manual_add_modules unionfs + +# We need losetup +copy_exec /sbin/losetup /sbin + +# Casper hooks +mkdir -p ${DESTDIR}/lib/live-initramfs +copy_exec /usr/share/live-initramfs/live-reconfigure /bin +copy_exec /usr/share/live-initramfs/live-preseed /bin + +mkdir -p ${DESTDIR}/lib/udev +copy_exec /lib/udev/cdrom_id /lib/udev +copy_exec /lib/udev/vol_id /lib/udev +copy_exec /lib/udev/path_id /lib/udev +copy_exec /usr/bin/udevinfo /bin +copy_exec /usr/bin/eject /bin + +# cifs boot +if [ -x /sbin/mount.cifs ]; then + copy_exec /sbin/mount.cifs /sbin + for x in cifs; do + manual_add_modules ${x} + done +fi + +# squashfs +manual_add_modules squashfs +manual_add_modules loop + +# random file system modules +manual_add_modules vfat +manual_add_modules ext3 +# needed for vfat. :-/ +manual_add_modules nls_cp437 +manual_add_modules nls_utf8 +manual_add_modules nls_iso8859-1 + +# cdrom modules +manual_add_modules sr_mod +manual_add_modules ide-cd +manual_add_modules sbp2 +manual_add_modules ohci1394 + +# integrity check +copy_exec /usr/lib/live-initramfs/live-md5check /bin + +cp /usr/share/initramfs-tools/scripts/live-functions $DESTDIR/scripts +cp /usr/share/initramfs-tools/scripts/live-helpers $DESTDIR/scripts + +auto_add_modules net + +if [ -e /etc/live.conf ]; then + mkdir -p ${DESTDIR}/etc + cp /etc/live.conf ${DESTDIR}/etc +fi diff --git a/manpages/live-initramfs.7 b/manpages/live-initramfs.7 new file mode 100644 index 0000000..d35e018 --- /dev/null +++ b/manpages/live-initramfs.7 @@ -0,0 +1,84 @@ +.TH CASPER 7 "Thu, 28 Sep 2006" "1.69" "Initramfs-tools hook" + +.SH NAME +casper \- a hook for initramfs-tools to boot live systems. + +.SH SYNOPSIS +.B BOOT=casper +As kernel parameter boot prompt. + +.SH DESCRIPTION +Casper is a hook for initramfs-tools used to generate an initramfs capable to boot live systems as those created by make-live. This includes the Debian-Live isos, netboot tarballs, and usb stick images and Ubuntu live cds. At boot time it will look for a (read-only) media containing a "/casper" directory where a root filesystems (often a compressed squashfs) is stored. If found, it will create a writable environment, using unionfs, for debian like systems to boot from. + +.SH RECOGNIZED BOOT OPTIONS +.TP +.B live-getty +This enables a special "serial" login shell (experimental). +.TP +.B xdebconf +uses xdebconfigurator, if present on the rootfs, to configure X instead of the standard procedure (experimental). +.TP +.BI "hostname=" HOSTNAME " , userfullname=" USERFULLNAME " , username=" USERNAME +Those parameters lets you override values read from the config file. +.TP +.BI "{keyb|kbd-chooser/method}=" KEYBOARD " , {klayout|console-setup/layoutcode}=" LAYOUT " , {kvariant|console-setup/variantcode}=" VARIANT " , {kmodel|console-setup/modelcode}=" CODE " , koptions=" OPTIONS +Configure the running keyboard as specified, if this one misses casper behaves as if "keyb=us" was specified. It will be interfered from "locale=" if locale is only 2 lowecase letters as a special case. You could also specify console layout, variant, code, and options (no defaults). +.TP +.BI ip= IFACE,ADDRESS,NETMASK,GATEWAY [ :IFACE,ADDRESS,NETMASK,GATEWAY "]*" +Let you specify the name(s) and the options of the interface(s) that should be configured at boot time. Do not specify this if you want to use dhcp (default). +.TP +.BR ip[= frommedia ] +If this variable is set, dhcp and static configuration are just skipped and the system will use the (must be) media-preconfigured /etc/network/interfaces instead. +.TP +.BI "{live-media|bootfrom}=" DEVICE +If you specify one of this two equivalent forms, casper will first try to find this device for the "/casper" directory where the read-only root filesystem should reside. If it did not find something usable, the normal scan for block devices is performed. +.TP +.BI "live-media-offset=" BYTES +This way you could tell casper that your image starts at offset BYTES in the above specified or autodiscovered device, this could be useful to hide the debian-live iso or image inside another iso or image, to create "clean" images. +.TP +.BI "locale=" LOCALE " | debian-installer/locale=" LOCALE +Configure the running locale as specified, if not present the live-media rootfs configured locale will be used and if also this one misses casper behave as "locale=en_US.UTF-8" was specified. If only 2 lowercase letter are specified (like "it"), the "maybe wanted" locale is generated (like it:IT.UTF-8), in this case if also "keyb=" is unspecified is set with those 2 lowercase letters (keyb=it). +.TP +.BR "netboot[=" nfs "|" cifs ] +This tells casper to perform a network mount. The parameter "nfsroot=" (with optional "nfsopts="), should specify where is the location of the root filesystem. With no args, will try cifs first, and if it fails nfs. +.TP +.B persistent +Casper will look for persistent and snapshot partitions or files labeled "casper-rw", "home-rw", and files called "casper-sn*", "home-sn*" and will try to, in order: mount as /cow the first, mount the second in /home, and just copy the contents of the latter in appropriate locations (snapshots). Snapshots will be tried to be updated on reboot/shutdown. Look at live-snapshot(1) for more informations. +.TP +.B nopersistent +disables the above mentioned "persistent" feature, useful if the bootloader (like syslinux) has been installed with persistent enabled. +.TP +.B "showmounts" +This parameter will make casper to show on "/" the ro filesystems (mostly compressed) on /casper. This is not enabled by default because could lead to problems by applications like "mono" which store binary paths on installation. +.TP +.BI "todisk=" DEVICE +Adding this parameter, casper will try to copy the entire read-only media to the specified device before mounting the root filesystem. It probably needs a lot of free space. Subsequent boots should then skip this step and just specify the "live-media=DEVICE" boot parameter with the same DEVICE used this time. +.TP +.B toram +Adding this parameter, casper will try to copy the whole read-only media to the computer's RAM before mounting the root filesystem. This could need a lot of ram, according to the space used by the read-only media. +.TP +.BI "{preseed/file|file}=" FILE +A path to a file present on the rootfs could be used to preseed debconf database. +.TP +.BI "package/question=" VALUE +All debian installed packages could be preseeded from command-line that way, beware of blanks spaces, they will interfere with parsing, use a preseed file in this case. + +.SH FILES +.B /etc/live.conf +some variables can be configured via this config file. + +.SH BUGS +.B casper +works fully on amd64, i386 and ppc, it should also run on other archs. + +.SH HOMEPAGE +Debian Live project + +.SH SEE ALSO +.BR live-snapshot(1), initramfs-tools(8), make-live(8), make-live.conf(5) + +.SH AUTHOR +casper was written by Tollen Fog Heen , Matt Zimmerman , and Marco Amadori . +.TP +This manual page was written by Marco Amadori , +for the Debian project (but may be used by others). diff --git a/manpages/live-snapshot.1 b/manpages/live-snapshot.1 new file mode 100644 index 0000000..8f27412 --- /dev/null +++ b/manpages/live-snapshot.1 @@ -0,0 +1,70 @@ +.TH "CASPER-SNAPSHOT" 1 "Thu, 28 Sep 2006" "0.0.1" "User commands" + +.SH NAME +casper-snapshot \- a simple script to ease persistence usage. + +.SH SYNOPSIS +.B casper-snapshot +.RB [\| \-c \||\| \-\-cow +.IR DIRECTORY \|] +.RB [\| \-d \||\| \-\-device +.IR DEVICE \|] +.RB [\| \-e \||\| \-\-exclude\-list +.IR FILE \|] +.RB [\| \-o \||\| \-\-output +.IR FILE \|] +.RB [\| \-t \||\| \-\-type +.IR TYPE \|] +.PP +.B casper-snapshot +.RB \-r \||\| \-\-resync\-string +.IR STRING +.br +.B casper-snapshot +.RB \-h \||\| \-\-help +.br +.B casper-snapshot +.RB \-u \||\| \-\-usage +.br +.B casper-snapshot +.RB \-v \||\| \-\-version + +.SH DESCRIPTION +Casper-snapshot is a script which can be used to build the right types of persistent image files supported by casper. It is also used on exit by the casper init script to resync the boot-found snapshots devices. + +.SH OPTIONS +.TP +.BI "\-c, \-\-cow" DIRECTORY +specifies the input directory to be cloned in the image file. +Its default value "/cow" should be right for most uses. However it could be handy to specify "/home" and type ext2 for the type to prepare an image file suited to be directly mounted by casper as home. +.TP +.BI "\-d, \-\-device" DEVICE +sets the device where the media which the snapshot/persistence file/partition will be put. If it is not specified, a tmpfs will be used and linked to the user's desktop to move it where it is needed. If the device has no filesystem, an ext2 fs will be automatically created and labelled according to the values specified after the "--output" value or with a sane default. +.TP +.BI "\-e, \-\-exclude\-list" FILE +a file containing a list of filenames/paths that should not be saved. This exclude list will be remebered on the target snapshot media for reuse. +.TP +.BI "\-o, \-\-output" FILE +the filename/label used for the output file/partition. If left blank, casper-snapshot will search for a proper file on the device or use the whole partition. +.TP +.BI "\-r, \-\-resync\-string" STRING +internally used on resyncs. +.TP +.BI "\-t, \-\-type" TYPE +Type could be one of "cpio", "squashfs" or "ext2". + +.SH BUGS +.B casper-snapshot +Time (and BTS) will tell. + +.SH HOMEPAGE +Debian Live project + +.SH SEE ALSO +.BR casper(7) + +.SH AUTHOR +casper-snapshot was written Marco Amadori . +.TP +This manual page was written by Marco Amadori , +for the Debian project (but may be used by others). diff --git a/scripts/casper b/scripts/casper deleted file mode 100755 index a4c78b3..0000000 --- a/scripts/casper +++ /dev/null @@ -1,549 +0,0 @@ -#!/bin/sh - -# set -e - -export PATH=/root/usr/bin:/root/usr/sbin:/root/bin:/root/sbin:/usr/bin:/usr/sbin:/bin:/sbin - -echo "/root/lib" >> /etc/ld.so.conf -echo "/root/usr/lib" >> /etc/ld.so.conf - -mountpoint=/cdrom - -USERNAME=casper -USERFULLNAME="Live session user" -HOST=live -BUILD_SYSTEM=Custom - -mkdir -p $mountpoint - -[ -f /etc/casper.conf ] && . /etc/casper.conf -export USERNAME USERFULLNAME HOST BUILD_SYSTEM - -. /scripts/casper-helpers - -if [ ! -f /casper.vars ]; then - touch /casper.vars -fi - -is_casper_path() { - path=$1 - if [ -d "$path/casper" ]; then - if [ "$(echo $path/casper/*.squashfs)" != "$path/casper/*.squashfs" ] || - [ "$(echo $path/casper/*.ext2)" != "$path/casper/*.ext2" ] || - [ "$(echo $path/casper/*.dir)" != "$path/casper/*.dir" ]; then - return 0 - fi - fi - return 1 -} - -get_backing_device() { - case "$1" in - *.squashfs|*.ext2) - echo $(setup_loop "$1" "loop" "/sys/block/loop*") - ;; - *.dir) - echo "directory" - ;; - *) - panic "Unrecognized casper filesystem: $1" - ;; - esac -} - -match_files_in_dir() { - # Does any files match pattern $1 ? - - local pattern="$1" - if [ "$(echo $pattern)" != "$pattern" ]; then - return 0 - fi - return 1 -} - -mount_images_in_directory() { - directory="$1" - rootmnt="$2" - if match_files_in_dir "$directory/casper/*.squashfs" || - match_files_in_dir "$directory/casper/*.ext2" || - match_files_in_dir "$directory/casper/*.dir"; then - setup_unionfs "$directory/casper" "$rootmnt" - else - : - fi -} - -is_nice_device() { - sysfs_path="${1#/sys}" - if /lib/udev/path_id "${sysfs_path}" | grep -E -q "ID_PATH=(usb|pci-[^-]*-[ide|scsi|usb])"; then - return 0 - fi - return 1 -} - -is_supported_fs () { - # FIXME: do something better like the scan of supported filesystems - fstype="${1}" - case ${fstype} in - vfat|iso9660|udf|ext2|ext3|ntfs) - return 0 - ;; - esac - return 1 -} - -copy_live_to() { - copyfrom="${1}" - copytodev="${2}" - copyto="${copyfrom}_swap" - - size=$(fs_size "" ${copyfrom} "used") - - if [ "${copytodev}" = "ram" ]; then - # copying to ram: - freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( cat /proc/meminfo | grep Cached | head -n 1 | awk '/Cached/{print $2}' - ) ) - mount_options="-o size=${size}k" - free_string="memory" - fstype="tmpfs" - dev="/dev/shm" - else - # it should be a writable block device - if [ -b "${copytodev}" ]; then - dev="${copytodev}" - free_string="space" - fstype=$(get_fstype "${dev}") - freespace=$(fs_size "${dev}") - else - [ "$quiet" != "y" ] && log_warning_msg "${copytodev} is not a block device." - return 1 - fi - fi - if [ "${freespace}" -lt "${size}" ] ; then - [ "$quiet" != "y" ] && log_warning_msg "Not enough free ${free_string} (${freespace}k > ${size}k) to copy live media in ${copytodev}." - return 1 - fi - - # begin copying.. - mkdir "${copyto}" - echo "mount -t ${fstype} ${mount_options} ${dev} ${copyto}" - mount -t "${fstype}" ${mount_options} "${dev}" "${copyto}" - cp -a ${copyfrom}/* ${copyto} # "cp -a" from busybox also copies hidden files - umount ${copyfrom} - mount -r -o move ${copyto} ${copyfrom} - rmdir ${copyto} - return 0 -} - -do_netmount() { - rc=1 - - modprobe "${MP_QUIET}" af_packet # For DHCP - - udevtrigger - udevsettle - - ipconfig ${DEVICE} /tmp/net-${DEVICE}.conf | tee /netboot.config - - if [ "${NFSROOT}" = "auto" ]; then - NFSROOT=${ROOTSERVER}:${ROOTPATH} - fi - - [ "$quiet" != "y" ] && log_begin_msg "Trying netboot from ${NFSROOT}" - - if [ "${NETBOOT}" != "nfs" ] && do_cifsmount ; then - rc=0 - elif do_nfsmount ; then - NETBOOT="nfs" - export NETBOOT - rc=0 - fi - - [ "$quiet" != "y" ] && log_end_msg - return ${rc} -} - -do_nfsmount() { - rc=1 - modprobe "${MP_QUIET}" nfs - if [ -z "${NFSOPTS}" ]; then - NFSOPTS="" - fi - - [ "$quiet" != "y" ] && log_begin_msg "Trying nfsmount -o nolock -o ro ${NFSOPTS} ${NFSROOT} ${mountpoint}" - # FIXME: This for loop is an ugly HACK round an nfs bug - for i in 0 1 2 3 4 5 6 7 8 9 a b c d e f 10 11 12 13; do - nfsmount -o nolock -o ro ${NFSOPTS} "${NFSROOT}" "${mountpoint}" && rc=0 && break - sleep 1 - done - return ${rc} -} - -do_cifsmount() { - rc=1 - if [ -x "/sbin/mount.cifs" ]; then - if [ -z "${NFSOPTS}" ]; then - CIFSOPTS="-ouser=root,password=" - else - CIFSOPTS="${NFSOPTS}" - fi - - [ "$quiet" != "y" ] && log_begin_msg "Trying mount.cifs ${NFSROOT} ${mountpoint} ${CIFSOPTS}" - modprobe "${MP_QUIET}" cifs - - if mount.cifs "${NFSROOT}" "${mountpoint}" "${CIFSOPTS}" ; then - rc=0 - fi - fi - return ${rc} -} - -do_snap_copy () -{ - fromdev="${1}" - todir="${2}" - snap_type="${3}" - - size=$(fs_size "${fromdev}" "" "used") - - if [ -b "${fromdev}" ]; then - # look for free mem - if [ -n "${HOMEMOUNTED}" -a "${snap_type}" = "HOME" ]; then - todev=$(cat /proc/mounts | grep -s " $(base_path ${todir}) " | awk '{print $1}' ) - freespace=$(df -k | grep -s ${todev} | awk '{print $4}') - else - freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( cat /proc/meminfo | grep Cached | head -n 1 | awk '/Cached/{print $2}' - )) - fi - - tomount="/mnt/tmpsnap" - if [ ! -d "${tomount}" ] ; then - mkdir -p "${tomount}" - fi - - fstype=$(get_fstype "${fromdev}") - if [ -n "${fstype}" ]; then - # Copying stuff... - mount -t "${fstype}" -o ro "${fromdev}" "${tomount}" - cp -a "${tomount}"/* ${todir} - umount "${tomount}" - else - log_warning_msg "Unrecognized fstype: ${fstype} on ${fromdev}:${snap_type}" - fi - - rmdir "${tomount}" - if echo ${fromdev} | grep -qs loop; then - losetup -d "${fromdev}" - fi - return 0 - else - return 1 - [ "$quiet" != "y" ] && log_warning_msg "Unable to find the snapshot ${snap_type} medium" - fi -} - -try_snap () -{ - # Look for $snap_label.* in block devices and copy the contents to $snap_mount - # and remember the device and filename for resync on exit in casper.init - - snap_label="${1}" - snap_mount="${2}" - snap_type="${3}" - - snapdata=$(find_files "${snap_label}.squashfs ${snap_label}.cpio.gz ${snap_label}.ext2") - if [ ! -z "${snapdata}" ]; then - snapdev="$(echo ${snapdata} | cut -f1 -d ' ')" - snapback="$(echo ${snapdata} | cut -f2 -d ' ')" - snapfile="$(echo ${snapdata} | cut -f3 -d ' ')" - if echo "${snapfile}" | grep -qs '\(squashfs\|ext2\)'; then - # squashfs or ext2 snapshot - dev=$(get_backing_device "${snapback}/${snapfile}") - if ! do_snap_copy "${dev}" "${snap_mount}" "${snap_type}"; then - log_warning_msg "Impossible to include the ${snapfile} Snapshot" - return 1 - fi - else - # cpio.gz snapshot - if ! (cd "${snap_mount}" && zcat "${snapback}/${snapfile}" | cpio -i -u -d 2>/dev/null) ; then - log_warning_msg "Impossible to include the ${snapfile} Snapshot" - return 1 - fi - fi - umount "${snapback}" - else - dev=$(find_cow_device "${snap_label}") - if [ -b ${dev} ]; then - if echo "${dev}" | grep -qs loop; then - # strange things happens, user confused? - snaploop=$( losetup ${dev} | awk '{print $3}' | tr -d '()' ) - snapfile=$(basename ${snaploop}) - snapdev=$(cat /proc/mounts | awk '{print $2,$1}' | grep -es "^$( dirname ${snaploop} )" | cut -f2 -d ' ') - else - snapdev="${dev}" - fi - if ! do_snap_copy "${dev}" "${snap_mount}" "${snap_type}" ; then - log_warning_msg "Impossible to include the ${snap_label} Snapshot" - return 1 - else - if [ -n "${snapfile}" ]; then - # it was a loop device, user confused - umount ${snapdev} - fi - fi - else - log_warning_msg "Impossible to include the ${snap_label} Snapshot" - return 1 - fi - fi - echo "export ${snap_type}SNAP="${snap_mount}":${snapdev}:${snapfile}" >> /etc/casper.conf # for resync on reboot/halt - return 0 -} - -setup_unionfs() { - image_directory="$1" - rootmnt="$2" - - modprobe "${MP_QUIET}" -b unionfs - - # run-init can't deal with images in a subdir, but we're going to - # move all of these away before it runs anyway. No, we're not, - # put them in / since move-mounting them into / breaks mono and - # some other apps. - - croot="/" - - # Let's just mount the read-only file systems first - rofsstring="" - rofslist="" - if [ "${NETBOOT}" = "nfs" ] ; then - roopt="nfsro" # go aroung a bug in nfs-unionfs locking - else - roopt="ro" - fi - - mkdir -p "${croot}" - for image_type in "ext2" "squashfs" "dir" ; do - for image in "${image_directory}"/*."${image_type}"; do - imagename=$(basename "${image}") - if [ -d "${image}" ]; then - # it is a plain directory: do nothing - rofsstring="${image}=${roopt}:${rofsstring}" - rofslist="${image} ${rofslist}" - elif [ -f "${image}" ]; then - backdev=$(get_backing_device "$image") - fstype=$(get_fstype "${backdev}") - if [ "${fstype}" = "unknown" ]; then - panic "Unknown file system type on ${backdev} (${image})" - fi - mkdir -p "${croot}/${imagename}" - mount -t "${fstype}" -o ro "${backdev}" "${croot}/${imagename}" || panic "Can not mount $backdev ($image) on ${croot}/${imagename}" && rofsstring="${croot}/${imagename}=${roopt}:${rofsstring}" && rofslist="${croot}/${imagename} ${rofslist}" - fi - done - done - rofsstring=${rofsstring%:} - - mkdir -p /cow - cowdevice="tmpfs" - cow_fstype="tmpfs" - - # Looking for "${root_persistence}" device or file - if [ -n "${PERSISTENT}" ]; then - cowprobe=$(find_cow_device "${root_persistence}") - if [ -b "${cowprobe}" ]; then - cowdevice=${cowprobe} - cow_fstype=$(get_fstype "${cowprobe}") - else - [ "$quiet" != "y" ] && log_warning_msg "Unable to find the persistent medium" - fi - fi - - mount ${cowdevice} -t ${cow_fstype} -o rw /cow || panic "Can not mount $cowdevice on /cow" - - mount -t unionfs -o dirs=/cow=rw:$rofsstring unionfs "$rootmnt" || panic "Unionfs mount failed" - - # Adding other custom mounts - if [ -n "${PERSISTENT}" ]; then - # directly mount /home - # FIXME: add a custom mounts configurable system - homecow=$(find_cow_device "${home_persistence}" ) - if [ -b "${homecow}" ]; then - mount -t $(get_fstype "${homecow}") -o rw "${homecow}" "${rootmnt}/home" - export HOMEMOUNTED=1 # used to proper calculate free space in do_snap_copy() - else - [ "$quiet" != "y" ] && log_warning_msg "Unable to find the persistent home medium" - fi - # Look for other snapshots to copy in - try_snap "${root_snapshot_label}" "${rootmnt}" "ROOT" - try_snap "${home_snapshot_label}" "${rootmnt}/home" "HOME" - fi - - if [ -n "${SHOWMOUNTS}" ]; then - for d in ${rofslist}; do - mkdir -p "${rootmnt}/casper/${d##*/}" - case d in - *.dir) # do nothing # mount -o bind "${d}" "${rootmnt}/casper/${d##*/}" - ;; - *) mount -o move "${d}" "${rootmnt}/casper/${d##*/}" - ;; - esac - done - # shows cow fs on /cow for use by casper-snapshot - mkdir -p "${rootmnt}/cow" - mount -o bind /cow "${rootmnt}/cow" - fi - - # move the first mount; no head in busybox-initramfs - for d in $(mount -t squashfs | cut -d\ -f 3); do - mkdir -p "${rootmnt}/rofs" - mount -o move "${d}" "${rootmnt}/rofs" - break - done -} - -check_dev () -{ - sysdev="${1}" - devname="${2}" - if [ -z "${devname}" ]; then - devname=$(sys2dev "${sysdev}") - fi - - if [ -n "${LIVEMEDIA_OFFSET}" ]; then - loopdevname=$(setup_loop "${devname}" "loop" "/sys/block/loop*" "${LIVEMEDIA_OFFSET}") - devname="${loopdevname}" - fi - - fstype=$(get_fstype "${devname}") - if is_supported_fs ${fstype}; then - mount -t ${fstype} -o ro "${devname}" $mountpoint || continue - if is_casper_path $mountpoint; then - echo $mountpoint - return 0 - else - umount $mountpoint - fi - fi - - if [ -n "${LIVEMEDIA_OFFSET}" ]; then - losetup -d "${loopdevname}" - fi - return 1 -} - -find_livefs() { - timeout="${1}" - # first look at the one specified in the command line - if [ ! -z "${LIVEMEDIA}" ]; then - if check_dev "null" "${LIVEMEDIA}"; then - return 0 - fi - fi - # don't start autodetection before timeout has expired - if [ -n "${LIVEMEDIA_TIMEOUT}" ]; then - if [ "${timeout}" -lt "${LIVEMEDIA_TIMEOUT}" ]; then - return 1 - fi - fi - # or do the scan of block devices - for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -v loop | grep -v ram); do - devname=$(sys2dev "${sysblock}") - fstype=$(get_fstype "${devname}") - if /lib/udev/cdrom_id ${devname} > /dev/null; then - if check_dev "null" "${devname}" ; then - return 0 - fi - elif is_nice_device "${sysblock}" ; then - for dev in $(subdevices "${sysblock}"); do - if check_dev "${dev}" ; then - return 0 - fi - done - elif [ "${fstype}" = "squashfs" -o \ - "${fstype}" = "ext3" -o \ - "${fstype}" = "ext2" ]; then - # This is an ugly hack situation, the block device has - # an image directly on it. It's hopefully - # casper, so take it and run with it. - ln -s "${devname}" "${devname}.${fstype}" - echo "${devname}.${fstype}" - return 0 - fi - done - return 1 -} - -pulsate() { - if [ -x /sbin/usplash_write ]; then - /sbin/usplash_write "PULSATE" - fi -} - -set_usplash_timeout() { - if [ -x /sbin/usplash_write ]; then - /sbin/usplash_write "TIMEOUT 120" - fi -} - -mountroot() { - exec 6>&1 - exec 7>&2 - exec > casper.log - exec 2>&1 - - set_usplash_timeout - [ "$quiet" != "y" ] && log_begin_msg "Running /scripts/casper-premount" - pulsate - run_scripts /scripts/casper-premount - [ "$quiet" != "y" ] && log_end_msg - - # Needed here too because some things (*cough* udev *cough*) - # changes the timeout - - set_usplash_timeout - - if [ ! -z "${NETBOOT}" ]; then - if do_netmount ; then - livefs_root="${mountpoint}" - else - panic "Unable to find a live file system on the network" - fi - else - # Scan local devices for the image - for i in 0 1 2 3 4 5 6 7 8 9 a b c d e f 10 11 12 13; do - livefs_root=$(find_livefs $i) - if [ "${livefs_root}" ]; then - break - fi - sleep 1 - done - fi - - if [ -z "${livefs_root}" ]; then - panic "Unable to find a medium containing a live file system" - fi - - if [ "${TORAM}" ]; then - live_dest="ram" - elif [ "${TODISK}" ]; then - live_dest="${TODISK}" - fi - if [ "${live_dest}" ]; then - log_begin_msg "Copying live_media to ${live_dest}" - copy_live_to "${livefs_root}" "${live_dest}" - log_end_msg - fi - - mount_images_in_directory "${livefs_root}" "${rootmnt}" - - log_end_msg - - maybe_break casper-bottom - [ "$quiet" != "y" ] && log_begin_msg "Running /scripts/casper-bottom" - - pulsate - run_scripts /scripts/casper-bottom - [ "$quiet" != "y" ] && log_end_msg - - exec 1>&6 6>&- - exec 2>&7 7>&- - cp casper.log "${rootmnt}/var/log/" -} diff --git a/scripts/casper-bottom/01integrity_check b/scripts/casper-bottom/01integrity_check deleted file mode 100755 index 637a1ff..0000000 --- a/scripts/casper-bottom/01integrity_check +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -PREREQ="" - -prereqs() -{ - echo "$PREREQ" -} - -case $1 in -# get pre-requisites -prereqs) - prereqs - exit 0 - ;; -esac - -grep integrity-check /proc/cmdline && casper-md5check /cdrom /cdrom/md5sum.txt < /dev/tty8 diff --git a/scripts/casper-bottom/02_timezone b/scripts/casper-bottom/02_timezone deleted file mode 100755 index 1cb6402..0000000 --- a/scripts/casper-bottom/02_timezone +++ /dev/null @@ -1,21 +0,0 @@ -#! /bin/sh - -PREREQ="" -DESCRIPTION="Adding APT-CDROM source..." - -. /scripts/casper-functions - -prereqs() -{ - echo "$PREREQ" -} - -case $1 in -# get pre-requisites -prereqs) - prereqs - exit 0 - ;; -esac - -cp -f /root/usr/share/zoneinfo/UTC /root/etc/localtime diff --git a/scripts/casper-bottom/05mountpoints b/scripts/casper-bottom/05mountpoints deleted file mode 100755 index 7c61de3..0000000 --- a/scripts/casper-bottom/05mountpoints +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh - -PREREQ="" -DESCRIPTION="Moving mount points..." - -. /scripts/casper-functions - -prereqs() -{ - echo "$PREREQ" -} - -case $1 in -# get pre-requisites -prereqs) - prereqs - exit 0 - ;; -esac - -log_begin_msg "$DESCRIPTION" - -# Move to the new root filesystem so that programs there can get at it. -mkdir -p /root/cdrom -mount -n -o move /cdrom /root/cdrom - -log_end_msg diff --git a/scripts/casper-bottom/10adduser b/scripts/casper-bottom/10adduser deleted file mode 100755 index 4fe9378..0000000 --- a/scripts/casper-bottom/10adduser +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/sh - -PREREQ="" -DESCRIPTION="Adding live session user..." - -. /scripts/casper-functions - -prereqs() -{ - echo "$PREREQ" -} - -case $1 in -# get pre-requisites -prereqs) - prereqs - exit 0 - ;; -esac - -log_begin_msg "$DESCRIPTION" - -# U6aMy0wojraho is just a blank password -chroot /root debconf-communicate -fnoninteractive casper > /dev/null < /dev/null - -# Clear out debconf database again to avoid confusing ubiquity later. -chroot /root debconf-communicate -fnoninteractive casper > /dev/null <> /root/etc/sudoers - elif [ "${BUILD_SYSTEM}" = "Debian" ]; then - echo "${USERNAME} ALL=(ALL) NOPASSWD: ALL" >> /root/etc/sudoers - fi -fi - -# XXX - awful hack to stop xscreensaver locking the screen (#7150) -echo 'RUNNING_UNDER_GDM="yes"' >> /root/etc/environment - -for file in /usr/share/applications/ubiquity-gtkui.desktop /usr/share/applications/kde/ubiquity-kdeui.desktop; do - if [ -f "/root/$file" ]; then - chroot /root install -D -o $USERNAME -g $USERNAME $file /home/$USERNAME/Desktop/$(basename "$file") - break - fi -done - -if [ -L /root/home/$USERNAME/Examples ]; then - chroot /root install -o $USERNAME -g $USERNAME -d /home/$USERNAME/Desktop/ - mv /root/home/$USERNAME/Examples /root/home/$USERNAME/Desktop/ -fi - -log_end_msg diff --git a/scripts/casper-bottom/12fstab b/scripts/casper-bottom/12fstab deleted file mode 100755 index 616216a..0000000 --- a/scripts/casper-bottom/12fstab +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh - -PREREQ="" -DESCRIPTION="Configuring fstab..." -FSTAB=/root/etc/fstab - -. /scripts/casper-functions - -prereqs() -{ - echo "$PREREQ" -} - -case $1 in -# get pre-requisites -prereqs) - prereqs - exit 0 - ;; -esac - -log_begin_msg "$DESCRIPTION" - -cat > $FSTAB </dev/null | /bin/dd bs=10 count=1 2>/dev/null) || continue - - if [ "$magic" = "SWAPSPACE2" -o "$magic" = "SWAP-SPACE" ]; then -# log "Found $device" - devices="$devices $device" - fi -done - -for device in $devices; do - cat >> $FSTAB <> "${grep_file}" - printf '%s UTF-8\n' "${LANG}" > /root/etc/locale.gen - chroot /root /usr/sbin/locale-gen "${LANG}" -fi - -log_end_msg diff --git a/scripts/casper-bottom/15autologin b/scripts/casper-bottom/15autologin deleted file mode 100755 index 81bd3a4..0000000 --- a/scripts/casper-bottom/15autologin +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/sh - -PREREQ="" -DESCRIPTION="Setting up automatic login..." - -. /scripts/casper-functions - -prereqs() -{ - echo "$PREREQ" -} - -case $1 in -# get pre-requisites -prereqs) - prereqs - exit 0 - ;; -esac - -log_begin_msg "$DESCRIPTION" - -if chroot /root [ -f /etc/gdm/gdm-cdd.conf ]; then - GDMCONF=/etc/gdm/gdm-cdd.conf -else - GDMCONF=/etc/gdm/gdm.conf -fi - -if chroot /root [ -f ${GDMCONF} ]; then - # Configure GDM autologin - chroot /root sed -i \ - -e "s/^AutomaticLoginEnable=.*\$/AutomaticLoginEnable=true/" \ - -e "s/^AutomaticLogin=.*\$/AutomaticLogin=$USERNAME/" \ - -e "s/^TimedLoginEnable=.*\$/TimedLoginEnable=true/" \ - -e "s/^TimedLogin=.*\$/TimedLogin=$USERNAME/" \ - -e "s/^TimedLoginDelay=.*\$/TimedLoginDelay=10/" \ - ${GDMCONF} -fi - -if [ -f /root/etc/kde3/kdm/kdmrc ]; then - # Configure KDM autologin - sed -i -r \ - -e "s/^#?AutoLoginEnable=.*\$/AutoLoginEnable=true/" \ - -e "s/^#?AutoLoginUser=.*\$/AutoLoginUser=$USERNAME/" \ - -e "s/^#?AutoReLogin=.*\$/AutoReLogin=true/" \ - /root/etc/kde3/kdm/kdmrc -fi - -if chroot /root /usr/bin/which kpersonalizer >/dev/null; then - # Disable first-login wizard for KDE - if [ ! -f /root/etc/kde3/kpersonalizerrc ]; then - cat > /root/etc/kde3/kpersonalizerrc <&2 - echo "Because kpersonalizerrc already exists" >&2 - fi -fi - -log_end_msg diff --git a/scripts/casper-bottom/18hostname b/scripts/casper-bottom/18hostname deleted file mode 100755 index 19ac61f..0000000 --- a/scripts/casper-bottom/18hostname +++ /dev/null @@ -1,38 +0,0 @@ -#! /bin/sh - -PREREQ="" -DESCRIPTION="Setting hostname..." - -. /scripts/casper-functions - -prereqs() -{ - echo "$PREREQ" -} - -case $1 in -# get pre-requisites -prereqs) - prereqs - exit 0 - ;; -esac - -log_begin_msg "$DESCRIPTION" - -echo "$HOST" > /root/etc/hostname -cat > /root/etc/hosts < /dev/null </dev/null) || panel_version="" -if [ -n "$panel_version" ]; then - chroot /root sudo -u "$USERNAME" gconftool-2 -s -t bool /apps/panel/global/disable_lock_screen true -fi - -log_end_msg diff --git a/scripts/casper-bottom/22screensaver b/scripts/casper-bottom/22screensaver deleted file mode 100755 index 39c0f22..0000000 --- a/scripts/casper-bottom/22screensaver +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/sh - -PREREQ="" -DESCRIPTION="Configuring screensaver..." - -. /scripts/casper-functions - -prereqs() -{ - echo "$PREREQ" -} - -case $1 in -# get pre-requisites -prereqs) - prereqs - exit 0 - ;; -esac - -log_begin_msg "$DESCRIPTION" - -gnome_screensaver_version=$(chroot /root dpkg-query -W --showformat='${Version}' gnome-screensaver 2>/dev/null) || gnome_screensaver_version="" -if [ -n "$gnome_screensaver_version" ]; then - # Support legacy gconf value - chroot /root sudo -u "$USERNAME" gconftool-2 -t bool -s /apps/gnome-screensaver/lock false - chroot /root sudo -u "$USERNAME" gconftool-2 -t bool -s /apps/gnome-screensaver/lock_enabled false -fi - -log_end_msg diff --git a/scripts/casper-bottom/23etc_modules b/scripts/casper-bottom/23etc_modules deleted file mode 100755 index 754a832..0000000 --- a/scripts/casper-bottom/23etc_modules +++ /dev/null @@ -1,30 +0,0 @@ -#! /bin/sh - -PREREQ="" -DESCRIPTION="Preconfiguring /etc/modules..." - -. /scripts/casper-functions - -prereqs() -{ - echo "$PREREQ" -} - -case $1 in -# get pre-requisites -prereqs) - prereqs - exit 0 - ;; -esac - -log_begin_msg "$DESCRIPTION" - -case "$DPKG_ARCH" in -# load the right modules -powerpc|ppc64) - echo snd_powermac >> /root/etc/modules - ;; -esac - -log_end_msg diff --git a/scripts/casper-bottom/23networking b/scripts/casper-bottom/23networking deleted file mode 100755 index 1b732d3..0000000 --- a/scripts/casper-bottom/23networking +++ /dev/null @@ -1,107 +0,0 @@ -#! /bin/sh - -PREREQ="" -DESCRIPTION="Preconfiguring networking..." -IFFILE="/root/etc/network/interfaces" - -. /scripts/casper-functions - -prereqs() -{ - echo "$PREREQ" -} - -case $1 in -# get pre-requisites -prereqs) - prereqs - exit 0 - ;; -esac - -log_begin_msg "$DESCRIPTION" - -if [ "${STATICIP}" = "frommedia" -a -e "$IFFILE" ] ; then - # will use existent /etc/network/interfaces - log_end_msg - exit 0 -fi - -cat > "$IFFILE" <> "$IFFILE" <> "$IFFILE" < /root/etc/resolv.conf <> /root/var/log/netboot.config - fi -fi - -for i in eth0 eth1 eth2 ath0 wlan0; do - grep -q "iface $i" $IFFILE && continue - cat >> "$IFFILE" </dev/\2 2>\&1|" /root/etc/inittab - fi - if [ "/root/etc/event.d/tty*" != "$(echo /root/etc/event.d/tty*)" ]; then - for f in /root/etc/event.d/tty*; do - sed -i -e "s|^exec.*|exec /bin/login -f $USERNAME /dev/$(basename $f) 2>\&1|" $f - done - fi -fi - -# This has the nice side effect of the cron.{daily,weekly,monthly} jobs in -# /etc/crontab remaining disabled, yet also not run by anacron -if [ -x /root/etc/init.d/anacron ]; then - for f in /root/etc/rc?.d/S??anacron; do - mv ${f} ${f%/*}/K00anacron - done -fi - -# No point, really -rm -f /root/etc/rc?.d/[SK]??postfix - -# Avoid clobbering the user's clock -rm -f /root/etc/rc?.d/K??hwclock.sh - -# Disable readahead since it doesn't play well with squashfs + unionfs -# use chmod instead of mv to not trigger unionfs bugs. -if [ -e /root/sbin/readahead-list ]; then - chmod -x /root/sbin/readahead-list -fi - -log_end_msg - -exit 0 diff --git a/scripts/casper-bottom/30accessibility b/scripts/casper-bottom/30accessibility deleted file mode 100755 index 01c2386..0000000 --- a/scripts/casper-bottom/30accessibility +++ /dev/null @@ -1,106 +0,0 @@ -#!/bin/sh - -PREREQ="" -DESCRIPTION="Configuring accessibility options..." - -. /scripts/casper-functions - -prereqs() -{ - echo "$PREREQ" -} - -case $1 in -# get pre-requisites -prereqs) - prereqs - exit 0 - ;; -esac - -log_begin_msg "$DESCRIPTION" - -gconf_version=$(chroot /root /usr/bin/dpkg-query -W --showformat='${Version}' gconf2 2>/dev/null) || gconf_version="" - -gct() { - if [ "$gconf_version" ]; then - chroot /root sudo -u "$USERNAME" gconftool-2 "$@" - fi -} - -kderc_addtoprefixes() { - if [ -e "/root/etc/kderc" ]; then - sed -i "s|\\(prefixes=/usr/share/kubuntu-default-settings/kde-profile/default/\\)|\\1,$1|" /root/etc/kderc - fi -} - -for x in $(cat /proc/cmdline); do - case $x in - # Lesser Visual Impairment - access=v1) - gct -s -t string /desktop/gnome/interface/gtk_theme HighContrastLargePrint - gct -s -t string /desktop/gnome/interface/icon_theme HighContrast - gct -s -t string /desktop/gnome/interface/monospace_font_name "monospace 18" - gct -s -t string /desktop/gnome/interface/font_name "sans 18" - gct -s -t string /apps/metacity/general/theme Atlanta - gct -s -t string /desktop/gnome/background/picture_filename "" - gct -s -t string /desktop/gnome/background/picture_options none - gct -s -t string /desktop/gnome/background/primary_color \#666666 - gct -s -t string /desktop/gnome/background/secondary_color \#7F7F7F - gct -s -t string /desktop/gnome/background/color_shading_type solid - gct -s -t int /desktop/gnome/peripherals/mouse/cursor_size 48 - gct -s -t string /desktop/gnome/peripherals/mouse/cursor_theme whiteglass - - kderc_addtoprefixes /usr/share/kubuntu-default-settings/kde-profile/lesser-visual-impairment/ - if [ -d /root/usr/share/xubuntu-default-settings/accessibility ]; then - cp -a /root/usr/share/xubuntu-default-settings/accessibility/* /root/etc/xdg/ - fi - ;; - # Moderate Visual Impairment - access=v2) - gct -s -t bool /desktop/gnome/interface/accessibility true - gct -s -t list --list-type=string /desktop/gnome/accessibility/startup/exec_ats [orca] - if [ -e /root/usr/share/pycentral/gnome-orca/site-packages/orca/settings.py ]; then - sed -i '/^enableSpeech\W/ s/True/False/;/^enableMagnifier/ s/False/True/' /root/usr/share/pycentral/gnome-orca/site-packages/orca/settings.py - fi - kderc_addtoprefixes /usr/share/kubuntu-default-settings/kde-profile/lesser-visual-impairment/,/usr/share/kubuntu-default-settings/kde-profile/moderate-visual-impairment/ - ;; - # Blindness - access=v3) - gct -s -t bool /desktop/gnome/sound/enable_esd false - gct -s -t bool /desktop/gnome/interface/accessibility true - gct -s -t list --list-type=string /desktop/gnome/accessibility/startup/exec_ats [orca] - ;; - # Minor Motor Difficulties - access=m1) - gct -s -t bool /desktop/gnome/accessibility/keyboard/enable true - gct -s -t bool /desktop/gnome/accessibility/keyboard/mousekeys_enable true - gct -s -t bool /desktop/gnome/accessibility/keyboard/stickykeys_enable true - gct -s -t bool /desktop/gnome/accessibility/keyboard/stickykeys_modifier_beep true - gct -s -t bool /desktop/accessibility/gnome/keyboard/stickykeys_two_key_off false - gct -s -t bool /desktop/gnome/peripherals/keyboard/repeat true - gct -s -t int /desktop/gnome/peripherals/keyboard/delay 700 - gct -s -t int /desktop/gnome/peripherals/keyboard/rate 10 - - kderc_addtoprefixes /usr/share/kubuntu-default-settings/kde-profile/minor-motor-difficulties/ - if [ -e /root/etc/xdg/xfce4/mcs_settings/keyboard.xml ]; then - sed -i 's/0/1/' /root/etc/xdg/xfce4/mcs_settings/keyboard.xml - fi - ;; - # Motor Difficulties - pointing devices - access=m2) - gct -s -t bool /desktop/gnome/accessibility/keyboard/enable true - gct -s -t bool /desktop/gnome/interface/accessibility true - gct -s -t bool /desktop/gnome/accessibility/keyboard/stickykeys_enable true - gct -s -t bool /desktop/gnome/accessibility/keyboard/stickykeys_modifier_beep false - gct -s -t bool /desktop/accessibility/gnome/keyboard/stickykeys_two_key_off false - gct -s -t list --list-type=string /desktop/gnome/accessibility/startup/exec_ats [onboard] - - kderc_addtoprefixes /usr/share/kubuntu-default-settings/kde-profile/minor-motor-difficulties/,/usr/share/kubuntu-default-settings/kde-profile/motor-difficulties-pointing-devices/ - if [ -e /root/etc/xdg/xfce4/mcs_settings/keyboard.xml ]; then - sed -i '/Sticky/ s/0/1/' /root/etc/xdg/xfce4/mcs_settings/keyboard.xml - fi - ;; - esac -done -log_end_msg diff --git a/scripts/casper-bottom/31disable_update_notifier b/scripts/casper-bottom/31disable_update_notifier deleted file mode 100755 index 2461c25..0000000 --- a/scripts/casper-bottom/31disable_update_notifier +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh - -PREREQ="" -DESCRIPTION="Disabling update-notifier..." - -. /scripts/casper-functions - -prereqs() -{ - echo "$PREREQ" -} - -case $1 in -# get pre-requisites -prereqs) - prereqs - exit 0 - ;; -esac - -log_begin_msg "$DESCRIPTION" - -# For GNOME, we divert away apt-check to avoid a regular 'apt-get update' -# equivalent in the live session. We want to run update-notifier for crash -# report handling. -chroot /root dpkg-divert --add --rename --quiet \ - /usr/lib/update-notifier/apt-check -ln -s /bin/true /root/usr/lib/update-notifier/apt-check - -# For KDE, adept_notifier's only useful function at the moment is an -# 'apt-get update' equivalent, so we disable it entirely. -rm -f /root/usr/share/autostart/adept_notifier_auto.desktop - -log_end_msg diff --git a/scripts/casper-bottom/32disable_hibernation b/scripts/casper-bottom/32disable_hibernation deleted file mode 100755 index ae4badd..0000000 --- a/scripts/casper-bottom/32disable_hibernation +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh - -PREREQ="" -DESCRIPTION="Configuring power management..." - -. /scripts/casper-functions - -prereqs() -{ - echo "$PREREQ" -} - -case $1 in -# get pre-requisites -prereqs) - prereqs - exit 0 - ;; -esac - -log_begin_msg "$DESCRIPTION" - - -gpm_version=$(chroot /root /usr/bin/dpkg-query -W --showformat='${Version}' gnome-power-manager 2>/dev/null) || panel_version="" -if [ -n "$gpm_version" ]; then -# casper-reconfigure /root gnome-power-manager - chroot /root sudo -u "$USERNAME" gconftool-2 -s -t bool /apps/gnome-power-manager/can_hibernate false - chroot /root sudo -u "$USERNAME" gconftool-2 -s -t bool /apps/gnome-power-manager/can_suspend false -fi - -if [ -d /root/usr/share/kubuntu-default-settings/kde-profile/default/share/config ]; then - echo "disableSuspend=1" >> /root/usr/share/kubuntu-default-settings/kde-profile/default/share/config/power-managerrc - echo "disableHibernate=1" >> /root/usr/share/kubuntu-default-settings/kde-profile/default/share/config/power-managerrc -fi - -log_end_msg diff --git a/scripts/casper-bottom/33enable_apport_crashes b/scripts/casper-bottom/33enable_apport_crashes deleted file mode 100755 index d1c8829..0000000 --- a/scripts/casper-bottom/33enable_apport_crashes +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh - -PREREQ="" -DESCRIPTION="Enabling notifications about program crashes..." - -. /scripts/casper-functions - -prereqs() -{ - echo "$PREREQ" -} - -case $1 in -# get pre-requisites -prereqs) - prereqs - exit 0 - ;; -esac - -log_begin_msg "$DESCRIPTION" - -update_notifier_version=$(chroot /root dpkg-query -W --showformat='${Version}' update-notifier 2>/dev/null) || update_notifier_version="" -if [ -n "$update_notifier_version" ]; then - chroot /root sudo -u "$USERNAME" gconftool-2 -t bool -s /apps/update-notifier/show_apport_crashes true -fi - -log_end_msg diff --git a/scripts/casper-bottom/34disable_kwallet b/scripts/casper-bottom/34disable_kwallet deleted file mode 100755 index add7cca..0000000 --- a/scripts/casper-bottom/34disable_kwallet +++ /dev/null @@ -1,25 +0,0 @@ -#! /bin/sh - -PREREQ="" -DESCRIPTION="Disabling kwallet..." - -. /scripts/casper-functions - -prereqs() -{ - echo "$PREREQ" -} - -case $1 in -# get pre-requisites -prereqs) - prereqs - exit 0 - ;; -esac - -log_begin_msg "$DESCRIPTION" - -rm -f /root/usr/share/services/kded/kwalletd.desktop - -log_end_msg \ No newline at end of file diff --git a/scripts/casper-bottom/35fix_language_selector b/scripts/casper-bottom/35fix_language_selector deleted file mode 100755 index 3a22602..0000000 --- a/scripts/casper-bottom/35fix_language_selector +++ /dev/null @@ -1,32 +0,0 @@ -#! /bin/sh - -PREREQ="" -DESCRIPTION="Fixing language selector..." - -. /scripts/casper-functions - -prereqs() -{ - echo "$PREREQ" -} - -case $1 in -# get pre-requisites -prereqs) - prereqs - exit 0 - ;; -esac - -log_begin_msg "$DESCRIPTION" - -if [ -e /root/usr/share/applications/language-selector.desktop ]; then - sed -i '/^Exec/ s|/usr/bin/gnome-language-selector|"& -n"|' /root/usr/share/applications/language-selector.desktop - -fi - -if [ -x /root/usr/bin/fontconfig-voodoo ]; then - chroot /root fontconfig-voodoo --auto --quiet || true -fi - -log_end_msg diff --git a/scripts/casper-bottom/40install_driver_updates b/scripts/casper-bottom/40install_driver_updates deleted file mode 100755 index 272a0ed..0000000 --- a/scripts/casper-bottom/40install_driver_updates +++ /dev/null @@ -1,40 +0,0 @@ -#! /bin/sh - -PREREQ="" -DESCRIPTION="Installing driver updates..." - -. /scripts/casper-functions - -prereqs() -{ - echo "$PREREQ" -} - -case $1 in -# get pre-requisites -prereqs) - prereqs - exit 0 - ;; -esac - -if [ ! -d /tmp/driver-updates ]; then - exit 0 -fi - -log_begin_msg "$DESCRIPTION" - -install_dir=/var/cache/driver-updates - -mkdir "/root$install_dir" -cp -a /tmp/driver-updates/*.deb "/root$install_dir/" - -# We cannot leave packages in a bad state. So if the install fails, remove -# it. This will get caught in casper.log. -for deb in "/root$install_dir"/*; do - if ! chroot /root dpkg -i "$install_dir/$deb"; then - chroot /root dpkg -P "${deb%%_*}" - fi -done - -log_end_msg diff --git a/scripts/casper-bottom/41apt_cdrom b/scripts/casper-bottom/41apt_cdrom deleted file mode 100755 index b4ab643..0000000 --- a/scripts/casper-bottom/41apt_cdrom +++ /dev/null @@ -1,24 +0,0 @@ -#! /bin/sh - -PREREQ="" -DESCRIPTION="Adding APT-CDROM source..." - -. /scripts/casper-functions - -prereqs() -{ - echo "$PREREQ" -} - -case $1 in -# get pre-requisites -prereqs) - prereqs - exit 0 - ;; -esac - -mkdir -p /root/cdrom -mount -n -o bind /cdrom /root/cdrom -chroot /root apt-cdrom -m add -umount /root/cdrom diff --git a/scripts/casper-functions b/scripts/casper-functions deleted file mode 100644 index 60721b4..0000000 --- a/scripts/casper-functions +++ /dev/null @@ -1,21 +0,0 @@ - -. /scripts/functions - -# Override this so we don't call PROGRESS -log_end_msg() -{ - if [ -x /sbin/usplash_write ]; then - /sbin/usplash_write "SUCCESS ok" - fi - _log_msg "Done." -} - -# Print a message and wait for enter -log_wait_msg() -{ - if [ -x /sbin/usplash_write ]; then - /sbin/usplash_write "INPUTENTER $@" - read nunya < /dev/.initramfs/usplash_outfifo - fi - _log_msg "Waiting: $@ ..." -} diff --git a/scripts/casper-helpers b/scripts/casper-helpers deleted file mode 100644 index 8402d93..0000000 --- a/scripts/casper-helpers +++ /dev/null @@ -1,197 +0,0 @@ -## Casper helper functions, used by casper on boot and by casper-snapshot - -if [ "${BUILD_SYSTEM}" = "Ubuntu" ]; then - MP_QUIET="-Q" -elif [ "${BUILD_SYSTEM}" = "Debian" ]; then - MP_QUIET="-q" -else - MP_QUIET="" -fi - -if [ ! -x "/bin/fstype" ]; then - # klibc not in path -> not in initramfs - export PATH="${PATH}:/usr/lib/klibc/bin" -fi - -sys2dev() { - sysdev=${1#/sys} - echo "/dev/$(udevinfo -q name -p ${sysdev} 2>/dev/null|| echo ${sysdev##*/})" -} - -subdevices() { - sysblock=$1 - r="" - for dev in "${sysblock}" "${sysblock}"/*; do - if [ -e "${dev}/dev" ]; then - r="${r} ${dev}" - fi - done - echo ${r} -} - -get_fstype() { - local FSTYPE - local FSSIZE - eval $(fstype < $1) - if [ "$FSTYPE" != "unknown" ]; then - echo $FSTYPE - return 0 - fi - /lib/udev/vol_id -t $1 2>/dev/null -} - -where_is_mounted() { - device=$1 - if grep -q "^$device " /proc/mounts; then - grep "^$device " /proc/mounts | read d mountpoint rest - echo $mountpoint - return 0 - fi - return 1 -} - -lastline() { - while read lines ; do - line=${lines} - done - echo "${line}" -} - -base_path () -{ - testpath="${1}" - mounts="$(awk '{print $2}' /proc/mounts)" - testpath="$(busybox realpath ${testpath})" - - while true ; do - if echo "${mounts}" | grep -qs "^${testpath}" ; then - set -- `echo "${mounts}" | grep "^${testpath}" | lastline` - echo ${1} - break - else - testpath=`dirname $testpath` - fi - done -} - -fs_size () -{ - # Returns used/free fs kbytes + 5% more - # You could pass a block device as $1 or the mount point as $2 - - dev="${1}" - mountp="${2}" - used="${3}" - - if [ -z "${mountp}" ]; then - mountp=$(where_is_mounted "${dev}") - if [ "$?" -gt 0 ]; then - mountp="/mnt/tmp_fs_size" - mkdir -p "${mountp}" - mount -t $(get_fstype "${dev}") -o ro "${dev}" "${mountp}" - doumount=1 - fi - fi - - if [ "${used}" = "used" ]; then - size=$(du -ks ${mountp} | cut -f1) - size=$(expr ${size} + ${size} / 20 ) # FIXME: 5% more to be sure - else - # free space - size="$(df -k | grep -s ${mountp} | awk '{print $4}')" - fi - - if [ -n "${doumount}" ]; then - umount "${mountp}" - rmdir "${mountp}" - fi - echo "${size}" -} - -setup_loop() { - local fspath=$1 - local module=$2 - local pattern=$3 - local offset=$4 - - modprobe ${MP_QUIET} -b "$module" - udevsettle - - for loopdev in $pattern; do - if [ "$(cat $loopdev/size)" -eq 0 ]; then - dev=$(sys2dev "${loopdev}") - if [ -n "$offset" ]; then - losetup -o "$offset" "$dev" "$fspath" - else - losetup "$dev" "$fspath" - fi - echo "$dev" - return 0 - fi - done - panic "No loop devices available" -} - -try_mount () -{ - dev="${1}" - mountp="${2}" - opts="${3}" - - if where_is_mounted ${dev} > /dev/null; then - mount -o remount,"${opts}" ${dev} $(where_is_mounted ${dev}) || panic "Remounting failed" - mount -o bind $(where_is_mounted ${dev}) ${mountp} || panic "Cannot bind-mount" - else - mount -t $(get_fstype "${dev}") -o "${opts}" "${dev}" "${mountp}" || panic "Cannot mount ${dev} on ${mountp}" - fi -} - -find_cow_device() { - pers_label="${1}" - cow_backing="/${pers_label}-backing" - for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -v loop); do - for dev in $(subdevices "${sysblock}"); do - devname=$(sys2dev "${dev}") - if [ "$(/lib/udev/vol_id -l $devname 2>/dev/null)" = "${pers_label}" ]; then - echo "$devname" - return - elif [ "$(get_fstype ${devname})" = "vfat" ]; then # FIXME: all supported block devices should be scanned - mkdir -p "${cow_backing}" - try_mount "${devname}" "${cow_backing}" "rw" - if [ -e "${cow_backing}/${pers_label}" ]; then - echo $(setup_loop "${cow_backing}/${pers_label}" "loop" "/sys/block/loop*") - return 0 - else - umount ${cow_backing} - fi - fi - done - done -} - -find_files() -# return the first of $filenames found on vfat and ext2 devices -# FIXME: merge with above function -{ - filenames="${1}" - snap_backing="/snap-backing" - for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -v loop); do - for dev in $(subdevices "${sysblock}"); do - devname=$(sys2dev "${dev}") - devfstype="$(get_fstype ${devname})" - if [ "${devfstype}" = "vfat" ] || [ "${devfstype}" = "ext2" ] ; then # FIXME: all supported block devices should be scanned - mkdir -p "${snap_backing}" - try_mount "${devname}" "${snap_backing}" "ro" - for filename in ${filenames}; do - if [ -e "${snap_backing}/${filename}" ]; then - echo "${devname} ${snap_backing} ${filename}" - return 0 - fi - done - umount ${snap_backing} - fi - done - done -} - - diff --git a/scripts/casper-premount/10driver_updates b/scripts/casper-premount/10driver_updates deleted file mode 100755 index 8009849..0000000 --- a/scripts/casper-premount/10driver_updates +++ /dev/null @@ -1,163 +0,0 @@ -#!/bin/sh - -PREREQ="" -. /scripts/casper-functions -. /scripts/casper-helpers - -prereqs() -{ - echo "$PREREQ" -} - -case $1 in -# get pre-requisites -prereqs) - prereqs - exit 0 - ;; -esac - -mountpoint=/cdrom - -is_updates_path() { - # Driver packages are stored in ubuntu-drivers// - # subdirectory. Each package contains a module for a specific - # kernel flavour. - path=$1 - kbase=$(uname -r | sed 's/^\([0-9]*\.[0-9]*\.[0-9]*\)-.*/\1/') - update_dir="$path/ubuntu-drivers/$kbase" - if [ -d "$update_dir" ]; then - if [ "$(echo $update_dir/*_$DPKG_ARCH.deb)" != \ - "$update_dir/*_$DPKG_ARCH.deb" ]; then - echo "$update_dir" - return 0; - fi - fi - return 1; -} - -is_nice_device() { - sysfs_path="${1#/sys}" - if /lib/udev/path_id "${sysfs_path}" | grep -E -q "ID_PATH=(usb|pci-[^-]*-[ide|scsi|usb])"; then - return 0 - fi - return 1 -} - -is_supported_fs () { - # FIXME: do something better like the scan of supported filesystems - fstype="${1}" - case ${fstype} in - vfat|iso9660|udf|ext2|ext3|ntfs) - return 0 - ;; - esac - return 1 -} - -check_dev_updates () -{ - sysdev="${1}" - devname="${2}" - if [ -z "${devname}" ]; then - devname=$(sys2dev "${sysdev}") - fi - - fstype=$(get_fstype "${devname}") - if is_supported_fs ${fstype}; then - mount -t ${fstype} -o ro "${devname}" $mountpoint || continue - if is_updates_path $mountpoint; then - return 0 - else - umount $mountpoint - fi - fi - - return 1 -} - -find_driver_updates() { - for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -v loop | grep -v ram); do - devname=$(sys2dev "${sysblock}") - fstype=$(get_fstype "${devname}") - if /lib/udev/cdrom_id ${devname} > /dev/null; then - if check_dev_updates "null" "${devname}" ; then - return 0 - fi - elif is_nice_device "${sysblock}" ; then - for dev in $(subdevices "${sysblock}"); do - if check_dev_updates "${dev}" ; then - return 0 - fi - done - fi - done - return 1 -} - -pulsate() { - if [ -x /sbin/usplash_write ]; then - /sbin/usplash_write "PULSATE" - fi -} - - -updates="false" - -for x in $(cat /proc/cmdline); do - case $x in - debian-installer/driver-update=*) - updates=${x#debian-installer/driver-update=} - ;; - esac -done - -if [ "$updates" != "true" ]; then - log_end_msg - exit 0 -fi - -# Not sure what to do for network installs. I assume there isn't even a CD -# for this anyway, so fail. -if [ -n "${NETBOOT}" ]; then - log_end_msg - exit 0; -fi - -#if chroot /root [ -f /etc/gdm/gdm-cdd.conf ]; then -# GDMCONF=/etc/gdm/gdm-cdd.conf -#else -# GDMCONF=/etc/gdm/gdm.conf -#fi - -eject -log_wait_msg "Insert a driver CD and press ENTER ($DPKG_ARCH)" - -log_begin_msg "Looking for driver update CD" - -for i in 0 1 2 3 4 5 6 7 8 9 a b c d e f 10 11 12 13; do - updates_root=$(find_driver_updates) - if [ "${updates_root}" ]; then - break; - fi - sleep 1 -done - -log_end_msg - -if [ -z "${updates_root}" ]; then - log_begin_msg "Could not find driver updates" - log_wait_msg "Re-insert install CD and press ENTER" - exit 0 -fi - -log_begin_msg "Copying driver updates to temporary location" - -mkdir -p /tmp/driver-updates -cp $updates_root/*_$DPKG_ARCH.deb /tmp/driver-updates/ -umount $mountpoint -eject - -log_end_msg - -log_wait_msg "Re-insert install CD and press ENTER." diff --git a/scripts/live b/scripts/live new file mode 100755 index 0000000..9ab1ac5 --- /dev/null +++ b/scripts/live @@ -0,0 +1,549 @@ +#!/bin/sh + +# set -e + +export PATH=/root/usr/bin:/root/usr/sbin:/root/bin:/root/sbin:/usr/bin:/usr/sbin:/bin:/sbin + +echo "/root/lib" >> /etc/ld.so.conf +echo "/root/usr/lib" >> /etc/ld.so.conf + +mountpoint=/cdrom + +USERNAME=user +USERFULLNAME="Live session user" +HOST=live +BUILD_SYSTEM=Custom + +mkdir -p $mountpoint + +[ -f /etc/live.conf ] && . /etc/live.conf +export USERNAME USERFULLNAME HOST BUILD_SYSTEM + +. /scripts/live-helpers + +if [ ! -f /live.vars ]; then + touch /live.vars +fi + +is_casper_path() { + path=$1 + if [ -d "$path/live" ]; then + if [ "$(echo $path/live/*.squashfs)" != "$path/live/*.squashfs" ] || + [ "$(echo $path/live/*.ext2)" != "$path/live/*.ext2" ] || + [ "$(echo $path/live/*.dir)" != "$path/live/*.dir" ]; then + return 0 + fi + fi + return 1 +} + +get_backing_device() { + case "$1" in + *.squashfs|*.ext2) + echo $(setup_loop "$1" "loop" "/sys/block/loop*") + ;; + *.dir) + echo "directory" + ;; + *) + panic "Unrecognized live filesystem: $1" + ;; + esac +} + +match_files_in_dir() { + # Does any files match pattern $1 ? + + local pattern="$1" + if [ "$(echo $pattern)" != "$pattern" ]; then + return 0 + fi + return 1 +} + +mount_images_in_directory() { + directory="$1" + rootmnt="$2" + if match_files_in_dir "$directory/live/*.squashfs" || + match_files_in_dir "$directory/live/*.ext2" || + match_files_in_dir "$directory/live/*.dir"; then + setup_unionfs "$directory/live" "$rootmnt" + else + : + fi +} + +is_nice_device() { + sysfs_path="${1#/sys}" + if /lib/udev/path_id "${sysfs_path}" | grep -E -q "ID_PATH=(usb|pci-[^-]*-[ide|scsi|usb])"; then + return 0 + fi + return 1 +} + +is_supported_fs () { + # FIXME: do something better like the scan of supported filesystems + fstype="${1}" + case ${fstype} in + vfat|iso9660|udf|ext2|ext3|ntfs) + return 0 + ;; + esac + return 1 +} + +copy_live_to() { + copyfrom="${1}" + copytodev="${2}" + copyto="${copyfrom}_swap" + + size=$(fs_size "" ${copyfrom} "used") + + if [ "${copytodev}" = "ram" ]; then + # copying to ram: + freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( cat /proc/meminfo | grep Cached | head -n 1 | awk '/Cached/{print $2}' - ) ) + mount_options="-o size=${size}k" + free_string="memory" + fstype="tmpfs" + dev="/dev/shm" + else + # it should be a writable block device + if [ -b "${copytodev}" ]; then + dev="${copytodev}" + free_string="space" + fstype=$(get_fstype "${dev}") + freespace=$(fs_size "${dev}") + else + [ "$quiet" != "y" ] && log_warning_msg "${copytodev} is not a block device." + return 1 + fi + fi + if [ "${freespace}" -lt "${size}" ] ; then + [ "$quiet" != "y" ] && log_warning_msg "Not enough free ${free_string} (${freespace}k > ${size}k) to copy live media in ${copytodev}." + return 1 + fi + + # begin copying.. + mkdir "${copyto}" + echo "mount -t ${fstype} ${mount_options} ${dev} ${copyto}" + mount -t "${fstype}" ${mount_options} "${dev}" "${copyto}" + cp -a ${copyfrom}/* ${copyto} # "cp -a" from busybox also copies hidden files + umount ${copyfrom} + mount -r -o move ${copyto} ${copyfrom} + rmdir ${copyto} + return 0 +} + +do_netmount() { + rc=1 + + modprobe "${MP_QUIET}" af_packet # For DHCP + + udevtrigger + udevsettle + + ipconfig ${DEVICE} /tmp/net-${DEVICE}.conf | tee /netboot.config + + if [ "${NFSROOT}" = "auto" ]; then + NFSROOT=${ROOTSERVER}:${ROOTPATH} + fi + + [ "$quiet" != "y" ] && log_begin_msg "Trying netboot from ${NFSROOT}" + + if [ "${NETBOOT}" != "nfs" ] && do_cifsmount ; then + rc=0 + elif do_nfsmount ; then + NETBOOT="nfs" + export NETBOOT + rc=0 + fi + + [ "$quiet" != "y" ] && log_end_msg + return ${rc} +} + +do_nfsmount() { + rc=1 + modprobe "${MP_QUIET}" nfs + if [ -z "${NFSOPTS}" ]; then + NFSOPTS="" + fi + + [ "$quiet" != "y" ] && log_begin_msg "Trying nfsmount -o nolock -o ro ${NFSOPTS} ${NFSROOT} ${mountpoint}" + # FIXME: This for loop is an ugly HACK round an nfs bug + for i in 0 1 2 3 4 5 6 7 8 9 a b c d e f 10 11 12 13; do + nfsmount -o nolock -o ro ${NFSOPTS} "${NFSROOT}" "${mountpoint}" && rc=0 && break + sleep 1 + done + return ${rc} +} + +do_cifsmount() { + rc=1 + if [ -x "/sbin/mount.cifs" ]; then + if [ -z "${NFSOPTS}" ]; then + CIFSOPTS="-ouser=root,password=" + else + CIFSOPTS="${NFSOPTS}" + fi + + [ "$quiet" != "y" ] && log_begin_msg "Trying mount.cifs ${NFSROOT} ${mountpoint} ${CIFSOPTS}" + modprobe "${MP_QUIET}" cifs + + if mount.cifs "${NFSROOT}" "${mountpoint}" "${CIFSOPTS}" ; then + rc=0 + fi + fi + return ${rc} +} + +do_snap_copy () +{ + fromdev="${1}" + todir="${2}" + snap_type="${3}" + + size=$(fs_size "${fromdev}" "" "used") + + if [ -b "${fromdev}" ]; then + # look for free mem + if [ -n "${HOMEMOUNTED}" -a "${snap_type}" = "HOME" ]; then + todev=$(cat /proc/mounts | grep -s " $(base_path ${todir}) " | awk '{print $1}' ) + freespace=$(df -k | grep -s ${todev} | awk '{print $4}') + else + freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( cat /proc/meminfo | grep Cached | head -n 1 | awk '/Cached/{print $2}' - )) + fi + + tomount="/mnt/tmpsnap" + if [ ! -d "${tomount}" ] ; then + mkdir -p "${tomount}" + fi + + fstype=$(get_fstype "${fromdev}") + if [ -n "${fstype}" ]; then + # Copying stuff... + mount -t "${fstype}" -o ro "${fromdev}" "${tomount}" + cp -a "${tomount}"/* ${todir} + umount "${tomount}" + else + log_warning_msg "Unrecognized fstype: ${fstype} on ${fromdev}:${snap_type}" + fi + + rmdir "${tomount}" + if echo ${fromdev} | grep -qs loop; then + losetup -d "${fromdev}" + fi + return 0 + else + return 1 + [ "$quiet" != "y" ] && log_warning_msg "Unable to find the snapshot ${snap_type} medium" + fi +} + +try_snap () +{ + # Look for $snap_label.* in block devices and copy the contents to $snap_mount + # and remember the device and filename for resync on exit in casper.init + + snap_label="${1}" + snap_mount="${2}" + snap_type="${3}" + + snapdata=$(find_files "${snap_label}.squashfs ${snap_label}.cpio.gz ${snap_label}.ext2") + if [ ! -z "${snapdata}" ]; then + snapdev="$(echo ${snapdata} | cut -f1 -d ' ')" + snapback="$(echo ${snapdata} | cut -f2 -d ' ')" + snapfile="$(echo ${snapdata} | cut -f3 -d ' ')" + if echo "${snapfile}" | grep -qs '\(squashfs\|ext2\)'; then + # squashfs or ext2 snapshot + dev=$(get_backing_device "${snapback}/${snapfile}") + if ! do_snap_copy "${dev}" "${snap_mount}" "${snap_type}"; then + log_warning_msg "Impossible to include the ${snapfile} Snapshot" + return 1 + fi + else + # cpio.gz snapshot + if ! (cd "${snap_mount}" && zcat "${snapback}/${snapfile}" | cpio -i -u -d 2>/dev/null) ; then + log_warning_msg "Impossible to include the ${snapfile} Snapshot" + return 1 + fi + fi + umount "${snapback}" + else + dev=$(find_cow_device "${snap_label}") + if [ -b ${dev} ]; then + if echo "${dev}" | grep -qs loop; then + # strange things happens, user confused? + snaploop=$( losetup ${dev} | awk '{print $3}' | tr -d '()' ) + snapfile=$(basename ${snaploop}) + snapdev=$(cat /proc/mounts | awk '{print $2,$1}' | grep -es "^$( dirname ${snaploop} )" | cut -f2 -d ' ') + else + snapdev="${dev}" + fi + if ! do_snap_copy "${dev}" "${snap_mount}" "${snap_type}" ; then + log_warning_msg "Impossible to include the ${snap_label} Snapshot" + return 1 + else + if [ -n "${snapfile}" ]; then + # it was a loop device, user confused + umount ${snapdev} + fi + fi + else + log_warning_msg "Impossible to include the ${snap_label} Snapshot" + return 1 + fi + fi + echo "export ${snap_type}SNAP="${snap_mount}":${snapdev}:${snapfile}" >> /etc/live.conf # for resync on reboot/halt + return 0 +} + +setup_unionfs() { + image_directory="$1" + rootmnt="$2" + + modprobe "${MP_QUIET}" -b unionfs + + # run-init can't deal with images in a subdir, but we're going to + # move all of these away before it runs anyway. No, we're not, + # put them in / since move-mounting them into / breaks mono and + # some other apps. + + croot="/" + + # Let's just mount the read-only file systems first + rofsstring="" + rofslist="" + if [ "${NETBOOT}" = "nfs" ] ; then + roopt="nfsro" # go aroung a bug in nfs-unionfs locking + else + roopt="ro" + fi + + mkdir -p "${croot}" + for image_type in "ext2" "squashfs" "dir" ; do + for image in "${image_directory}"/*."${image_type}"; do + imagename=$(basename "${image}") + if [ -d "${image}" ]; then + # it is a plain directory: do nothing + rofsstring="${image}=${roopt}:${rofsstring}" + rofslist="${image} ${rofslist}" + elif [ -f "${image}" ]; then + backdev=$(get_backing_device "$image") + fstype=$(get_fstype "${backdev}") + if [ "${fstype}" = "unknown" ]; then + panic "Unknown file system type on ${backdev} (${image})" + fi + mkdir -p "${croot}/${imagename}" + mount -t "${fstype}" -o ro "${backdev}" "${croot}/${imagename}" || panic "Can not mount $backdev ($image) on ${croot}/${imagename}" && rofsstring="${croot}/${imagename}=${roopt}:${rofsstring}" && rofslist="${croot}/${imagename} ${rofslist}" + fi + done + done + rofsstring=${rofsstring%:} + + mkdir -p /cow + cowdevice="tmpfs" + cow_fstype="tmpfs" + + # Looking for "${root_persistence}" device or file + if [ -n "${PERSISTENT}" ]; then + cowprobe=$(find_cow_device "${root_persistence}") + if [ -b "${cowprobe}" ]; then + cowdevice=${cowprobe} + cow_fstype=$(get_fstype "${cowprobe}") + else + [ "$quiet" != "y" ] && log_warning_msg "Unable to find the persistent medium" + fi + fi + + mount ${cowdevice} -t ${cow_fstype} -o rw /cow || panic "Can not mount $cowdevice on /cow" + + mount -t unionfs -o dirs=/cow=rw:$rofsstring unionfs "$rootmnt" || panic "Unionfs mount failed" + + # Adding other custom mounts + if [ -n "${PERSISTENT}" ]; then + # directly mount /home + # FIXME: add a custom mounts configurable system + homecow=$(find_cow_device "${home_persistence}" ) + if [ -b "${homecow}" ]; then + mount -t $(get_fstype "${homecow}") -o rw "${homecow}" "${rootmnt}/home" + export HOMEMOUNTED=1 # used to proper calculate free space in do_snap_copy() + else + [ "$quiet" != "y" ] && log_warning_msg "Unable to find the persistent home medium" + fi + # Look for other snapshots to copy in + try_snap "${root_snapshot_label}" "${rootmnt}" "ROOT" + try_snap "${home_snapshot_label}" "${rootmnt}/home" "HOME" + fi + + if [ -n "${SHOWMOUNTS}" ]; then + for d in ${rofslist}; do + mkdir -p "${rootmnt}/live/${d##*/}" + case d in + *.dir) # do nothing # mount -o bind "${d}" "${rootmnt}/live/${d##*/}" + ;; + *) mount -o move "${d}" "${rootmnt}/live/${d##*/}" + ;; + esac + done + # shows cow fs on /cow for use by live-snapshot + mkdir -p "${rootmnt}/cow" + mount -o bind /cow "${rootmnt}/cow" + fi + + # move the first mount; no head in busybox-initramfs + for d in $(mount -t squashfs | cut -d\ -f 3); do + mkdir -p "${rootmnt}/rofs" + mount -o move "${d}" "${rootmnt}/rofs" + break + done +} + +check_dev () +{ + sysdev="${1}" + devname="${2}" + if [ -z "${devname}" ]; then + devname=$(sys2dev "${sysdev}") + fi + + if [ -n "${LIVEMEDIA_OFFSET}" ]; then + loopdevname=$(setup_loop "${devname}" "loop" "/sys/block/loop*" "${LIVEMEDIA_OFFSET}") + devname="${loopdevname}" + fi + + fstype=$(get_fstype "${devname}") + if is_supported_fs ${fstype}; then + mount -t ${fstype} -o ro "${devname}" $mountpoint || continue + if is_casper_path $mountpoint; then + echo $mountpoint + return 0 + else + umount $mountpoint + fi + fi + + if [ -n "${LIVEMEDIA_OFFSET}" ]; then + losetup -d "${loopdevname}" + fi + return 1 +} + +find_livefs() { + timeout="${1}" + # first look at the one specified in the command line + if [ ! -z "${LIVEMEDIA}" ]; then + if check_dev "null" "${LIVEMEDIA}"; then + return 0 + fi + fi + # don't start autodetection before timeout has expired + if [ -n "${LIVEMEDIA_TIMEOUT}" ]; then + if [ "${timeout}" -lt "${LIVEMEDIA_TIMEOUT}" ]; then + return 1 + fi + fi + # or do the scan of block devices + for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -v loop | grep -v ram); do + devname=$(sys2dev "${sysblock}") + fstype=$(get_fstype "${devname}") + if /lib/udev/cdrom_id ${devname} > /dev/null; then + if check_dev "null" "${devname}" ; then + return 0 + fi + elif is_nice_device "${sysblock}" ; then + for dev in $(subdevices "${sysblock}"); do + if check_dev "${dev}" ; then + return 0 + fi + done + elif [ "${fstype}" = "squashfs" -o \ + "${fstype}" = "ext3" -o \ + "${fstype}" = "ext2" ]; then + # This is an ugly hack situation, the block device has + # an image directly on it. It's hopefully + # casper, so take it and run with it. + ln -s "${devname}" "${devname}.${fstype}" + echo "${devname}.${fstype}" + return 0 + fi + done + return 1 +} + +pulsate() { + if [ -x /sbin/usplash_write ]; then + /sbin/usplash_write "PULSATE" + fi +} + +set_usplash_timeout() { + if [ -x /sbin/usplash_write ]; then + /sbin/usplash_write "TIMEOUT 120" + fi +} + +mountroot() { + exec 6>&1 + exec 7>&2 + exec > live.log + exec 2>&1 + + set_usplash_timeout + [ "$quiet" != "y" ] && log_begin_msg "Running /scripts/live-premount" + pulsate + run_scripts /scripts/live-premount + [ "$quiet" != "y" ] && log_end_msg + + # Needed here too because some things (*cough* udev *cough*) + # changes the timeout + + set_usplash_timeout + + if [ ! -z "${NETBOOT}" ]; then + if do_netmount ; then + livefs_root="${mountpoint}" + else + panic "Unable to find a live file system on the network" + fi + else + # Scan local devices for the image + for i in 0 1 2 3 4 5 6 7 8 9 a b c d e f 10 11 12 13; do + livefs_root=$(find_livefs $i) + if [ "${livefs_root}" ]; then + break + fi + sleep 1 + done + fi + + if [ -z "${livefs_root}" ]; then + panic "Unable to find a medium containing a live file system" + fi + + if [ "${TORAM}" ]; then + live_dest="ram" + elif [ "${TODISK}" ]; then + live_dest="${TODISK}" + fi + if [ "${live_dest}" ]; then + log_begin_msg "Copying live_media to ${live_dest}" + copy_live_to "${livefs_root}" "${live_dest}" + log_end_msg + fi + + mount_images_in_directory "${livefs_root}" "${rootmnt}" + + log_end_msg + + maybe_break live-bottom + [ "$quiet" != "y" ] && log_begin_msg "Running /scripts/live-bottom" + + pulsate + run_scripts /scripts/live-bottom + [ "$quiet" != "y" ] && log_end_msg + + exec 1>&6 6>&- + exec 2>&7 7>&- + cp live.log "${rootmnt}/var/log/" +} diff --git a/scripts/live-bottom/01integrity_check b/scripts/live-bottom/01integrity_check new file mode 100755 index 0000000..d5bc5fe --- /dev/null +++ b/scripts/live-bottom/01integrity_check @@ -0,0 +1,18 @@ +#!/bin/sh + +PREREQ="" + +prereqs() +{ + echo "$PREREQ" +} + +case $1 in +# get pre-requisites +prereqs) + prereqs + exit 0 + ;; +esac + +grep integrity-check /proc/cmdline && live-md5check /cdrom /cdrom/md5sum.txt < /dev/tty8 diff --git a/scripts/live-bottom/02_timezone b/scripts/live-bottom/02_timezone new file mode 100755 index 0000000..873c1da --- /dev/null +++ b/scripts/live-bottom/02_timezone @@ -0,0 +1,21 @@ +#! /bin/sh + +PREREQ="" +DESCRIPTION="Setting timezone..." + +. /scripts/live-functions + +prereqs() +{ + echo "$PREREQ" +} + +case $1 in +# get pre-requisites +prereqs) + prereqs + exit 0 + ;; +esac + +cp -f /root/usr/share/zoneinfo/UTC /root/etc/localtime diff --git a/scripts/live-bottom/05mountpoints b/scripts/live-bottom/05mountpoints new file mode 100755 index 0000000..411660d --- /dev/null +++ b/scripts/live-bottom/05mountpoints @@ -0,0 +1,27 @@ +#!/bin/sh + +PREREQ="" +DESCRIPTION="Moving mount points..." + +. /scripts/live-functions + +prereqs() +{ + echo "$PREREQ" +} + +case $1 in +# get pre-requisites +prereqs) + prereqs + exit 0 + ;; +esac + +log_begin_msg "$DESCRIPTION" + +# Move to the new root filesystem so that programs there can get at it. +mkdir -p /root/cdrom +mount -n -o move /cdrom /root/cdrom + +log_end_msg diff --git a/scripts/live-bottom/10adduser b/scripts/live-bottom/10adduser new file mode 100755 index 0000000..9179f1b --- /dev/null +++ b/scripts/live-bottom/10adduser @@ -0,0 +1,66 @@ +#!/bin/sh + +PREREQ="" +DESCRIPTION="Adding live session user..." + +. /scripts/live-functions + +prereqs() +{ + echo "$PREREQ" +} + +case $1 in +# get pre-requisites +prereqs) + prereqs + exit 0 + ;; +esac + +log_begin_msg "$DESCRIPTION" + +# U6aMy0wojraho is just a blank password +chroot /root debconf-communicate -fnoninteractive live-initramfs > /dev/null < /dev/null + +# Clear out debconf database again to avoid confusing ubiquity later. +chroot /root debconf-communicate -fnoninteractive live-initramfs > /dev/null <> /root/etc/sudoers + elif [ "${BUILD_SYSTEM}" = "Debian" ]; then + echo "${USERNAME} ALL=(ALL) NOPASSWD: ALL" >> /root/etc/sudoers + fi +fi + +# XXX - awful hack to stop xscreensaver locking the screen (#7150) +echo 'RUNNING_UNDER_GDM="yes"' >> /root/etc/environment + +for file in /usr/share/applications/ubiquity-gtkui.desktop /usr/share/applications/kde/ubiquity-kdeui.desktop; do + if [ -f "/root/$file" ]; then + chroot /root install -D -o $USERNAME -g $USERNAME $file /home/$USERNAME/Desktop/$(basename "$file") + break + fi +done + +if [ -L /root/home/$USERNAME/Examples ]; then + chroot /root install -o $USERNAME -g $USERNAME -d /home/$USERNAME/Desktop/ + mv /root/home/$USERNAME/Examples /root/home/$USERNAME/Desktop/ +fi + +log_end_msg diff --git a/scripts/live-bottom/12fstab b/scripts/live-bottom/12fstab new file mode 100755 index 0000000..fa9c642 --- /dev/null +++ b/scripts/live-bottom/12fstab @@ -0,0 +1,31 @@ +#!/bin/sh + +PREREQ="" +DESCRIPTION="Configuring fstab..." +FSTAB=/root/etc/fstab + +. /scripts/live-functions + +prereqs() +{ + echo "$PREREQ" +} + +case $1 in +# get pre-requisites +prereqs) + prereqs + exit 0 + ;; +esac + +log_begin_msg "$DESCRIPTION" + +cat > $FSTAB </dev/null | /bin/dd bs=10 count=1 2>/dev/null) || continue + + if [ "$magic" = "SWAPSPACE2" -o "$magic" = "SWAP-SPACE" ]; then +# log "Found $device" + devices="$devices $device" + fi +done + +for device in $devices; do + cat >> $FSTAB <> "${grep_file}" + printf '%s UTF-8\n' "${LANG}" > /root/etc/locale.gen + chroot /root /usr/sbin/locale-gen "${LANG}" +fi + +log_end_msg diff --git a/scripts/live-bottom/15autologin b/scripts/live-bottom/15autologin new file mode 100755 index 0000000..4b64dc7 --- /dev/null +++ b/scripts/live-bottom/15autologin @@ -0,0 +1,62 @@ +#!/bin/sh + +PREREQ="" +DESCRIPTION="Setting up automatic login..." + +. /scripts/live-functions + +prereqs() +{ + echo "$PREREQ" +} + +case $1 in +# get pre-requisites +prereqs) + prereqs + exit 0 + ;; +esac + +log_begin_msg "$DESCRIPTION" + +if chroot /root [ -f /etc/gdm/gdm-cdd.conf ]; then + GDMCONF=/etc/gdm/gdm-cdd.conf +else + GDMCONF=/etc/gdm/gdm.conf +fi + +if chroot /root [ -f ${GDMCONF} ]; then + # Configure GDM autologin + chroot /root sed -i \ + -e "s/^AutomaticLoginEnable=.*\$/AutomaticLoginEnable=true/" \ + -e "s/^AutomaticLogin=.*\$/AutomaticLogin=$USERNAME/" \ + -e "s/^TimedLoginEnable=.*\$/TimedLoginEnable=true/" \ + -e "s/^TimedLogin=.*\$/TimedLogin=$USERNAME/" \ + -e "s/^TimedLoginDelay=.*\$/TimedLoginDelay=10/" \ + ${GDMCONF} +fi + +if [ -f /root/etc/kde3/kdm/kdmrc ]; then + # Configure KDM autologin + sed -i -r \ + -e "s/^#?AutoLoginEnable=.*\$/AutoLoginEnable=true/" \ + -e "s/^#?AutoLoginUser=.*\$/AutoLoginUser=$USERNAME/" \ + -e "s/^#?AutoReLogin=.*\$/AutoReLogin=true/" \ + /root/etc/kde3/kdm/kdmrc +fi + +if chroot /root /usr/bin/which kpersonalizer >/dev/null; then + # Disable first-login wizard for KDE + if [ ! -f /root/etc/kde3/kpersonalizerrc ]; then + cat > /root/etc/kde3/kpersonalizerrc <&2 + echo "Because kpersonalizerrc already exists" >&2 + fi +fi + +log_end_msg diff --git a/scripts/live-bottom/18hostname b/scripts/live-bottom/18hostname new file mode 100755 index 0000000..591e4ec --- /dev/null +++ b/scripts/live-bottom/18hostname @@ -0,0 +1,38 @@ +#! /bin/sh + +PREREQ="" +DESCRIPTION="Setting hostname..." + +. /scripts/live-functions + +prereqs() +{ + echo "$PREREQ" +} + +case $1 in +# get pre-requisites +prereqs) + prereqs + exit 0 + ;; +esac + +log_begin_msg "$DESCRIPTION" + +echo "$HOST" > /root/etc/hostname +cat > /root/etc/hosts < /dev/null </dev/null) || panel_version="" +if [ -n "$panel_version" ]; then + chroot /root sudo -u "$USERNAME" gconftool-2 -s -t bool /apps/panel/global/disable_lock_screen true +fi + +log_end_msg diff --git a/scripts/live-bottom/22screensaver b/scripts/live-bottom/22screensaver new file mode 100755 index 0000000..6193a41 --- /dev/null +++ b/scripts/live-bottom/22screensaver @@ -0,0 +1,30 @@ +#!/bin/sh + +PREREQ="" +DESCRIPTION="Configuring screensaver..." + +. /scripts/live-functions + +prereqs() +{ + echo "$PREREQ" +} + +case $1 in +# get pre-requisites +prereqs) + prereqs + exit 0 + ;; +esac + +log_begin_msg "$DESCRIPTION" + +gnome_screensaver_version=$(chroot /root dpkg-query -W --showformat='${Version}' gnome-screensaver 2>/dev/null) || gnome_screensaver_version="" +if [ -n "$gnome_screensaver_version" ]; then + # Support legacy gconf value + chroot /root sudo -u "$USERNAME" gconftool-2 -t bool -s /apps/gnome-screensaver/lock false + chroot /root sudo -u "$USERNAME" gconftool-2 -t bool -s /apps/gnome-screensaver/lock_enabled false +fi + +log_end_msg diff --git a/scripts/live-bottom/23etc_modules b/scripts/live-bottom/23etc_modules new file mode 100755 index 0000000..6eec342 --- /dev/null +++ b/scripts/live-bottom/23etc_modules @@ -0,0 +1,30 @@ +#! /bin/sh + +PREREQ="" +DESCRIPTION="Preconfiguring /etc/modules..." + +. /scripts/live-functions + +prereqs() +{ + echo "$PREREQ" +} + +case $1 in +# get pre-requisites +prereqs) + prereqs + exit 0 + ;; +esac + +log_begin_msg "$DESCRIPTION" + +case "$DPKG_ARCH" in +# load the right modules +powerpc|ppc64) + echo snd_powermac >> /root/etc/modules + ;; +esac + +log_end_msg diff --git a/scripts/live-bottom/23networking b/scripts/live-bottom/23networking new file mode 100755 index 0000000..988206e --- /dev/null +++ b/scripts/live-bottom/23networking @@ -0,0 +1,107 @@ +#! /bin/sh + +PREREQ="" +DESCRIPTION="Preconfiguring networking..." +IFFILE="/root/etc/network/interfaces" + +. /scripts/live-functions + +prereqs() +{ + echo "$PREREQ" +} + +case $1 in +# get pre-requisites +prereqs) + prereqs + exit 0 + ;; +esac + +log_begin_msg "$DESCRIPTION" + +if [ "${STATICIP}" = "frommedia" -a -e "$IFFILE" ] ; then + # will use existent /etc/network/interfaces + log_end_msg + exit 0 +fi + +cat > "$IFFILE" <> "$IFFILE" <> "$IFFILE" < /root/etc/resolv.conf <> /root/var/log/netboot.config + fi +fi + +for i in eth0 eth1 eth2 ath0 wlan0; do + grep -q "iface $i" $IFFILE && continue + cat >> "$IFFILE" </dev/\2 2>\&1|" /root/etc/inittab + fi + if [ "/root/etc/event.d/tty*" != "$(echo /root/etc/event.d/tty*)" ]; then + for f in /root/etc/event.d/tty*; do + sed -i -e "s|^exec.*|exec /bin/login -f $USERNAME /dev/$(basename $f) 2>\&1|" $f + done + fi +fi + +# This has the nice side effect of the cron.{daily,weekly,monthly} jobs in +# /etc/crontab remaining disabled, yet also not run by anacron +if [ -x /root/etc/init.d/anacron ]; then + for f in /root/etc/rc?.d/S??anacron; do + mv ${f} ${f%/*}/K00anacron + done +fi + +# No point, really +rm -f /root/etc/rc?.d/[SK]??postfix + +# Avoid clobbering the user's clock +rm -f /root/etc/rc?.d/K??hwclock.sh + +# Disable readahead since it doesn't play well with squashfs + unionfs +# use chmod instead of mv to not trigger unionfs bugs. +if [ -e /root/sbin/readahead-list ]; then + chmod -x /root/sbin/readahead-list +fi + +log_end_msg + +exit 0 diff --git a/scripts/live-bottom/30accessibility b/scripts/live-bottom/30accessibility new file mode 100755 index 0000000..127c48f --- /dev/null +++ b/scripts/live-bottom/30accessibility @@ -0,0 +1,106 @@ +#!/bin/sh + +PREREQ="" +DESCRIPTION="Configuring accessibility options..." + +. /scripts/live-functions + +prereqs() +{ + echo "$PREREQ" +} + +case $1 in +# get pre-requisites +prereqs) + prereqs + exit 0 + ;; +esac + +log_begin_msg "$DESCRIPTION" + +gconf_version=$(chroot /root /usr/bin/dpkg-query -W --showformat='${Version}' gconf2 2>/dev/null) || gconf_version="" + +gct() { + if [ "$gconf_version" ]; then + chroot /root sudo -u "$USERNAME" gconftool-2 "$@" + fi +} + +kderc_addtoprefixes() { + if [ -e "/root/etc/kderc" ]; then + sed -i "s|\\(prefixes=/usr/share/kubuntu-default-settings/kde-profile/default/\\)|\\1,$1|" /root/etc/kderc + fi +} + +for x in $(cat /proc/cmdline); do + case $x in + # Lesser Visual Impairment + access=v1) + gct -s -t string /desktop/gnome/interface/gtk_theme HighContrastLargePrint + gct -s -t string /desktop/gnome/interface/icon_theme HighContrast + gct -s -t string /desktop/gnome/interface/monospace_font_name "monospace 18" + gct -s -t string /desktop/gnome/interface/font_name "sans 18" + gct -s -t string /apps/metacity/general/theme Atlanta + gct -s -t string /desktop/gnome/background/picture_filename "" + gct -s -t string /desktop/gnome/background/picture_options none + gct -s -t string /desktop/gnome/background/primary_color \#666666 + gct -s -t string /desktop/gnome/background/secondary_color \#7F7F7F + gct -s -t string /desktop/gnome/background/color_shading_type solid + gct -s -t int /desktop/gnome/peripherals/mouse/cursor_size 48 + gct -s -t string /desktop/gnome/peripherals/mouse/cursor_theme whiteglass + + kderc_addtoprefixes /usr/share/kubuntu-default-settings/kde-profile/lesser-visual-impairment/ + if [ -d /root/usr/share/xubuntu-default-settings/accessibility ]; then + cp -a /root/usr/share/xubuntu-default-settings/accessibility/* /root/etc/xdg/ + fi + ;; + # Moderate Visual Impairment + access=v2) + gct -s -t bool /desktop/gnome/interface/accessibility true + gct -s -t list --list-type=string /desktop/gnome/accessibility/startup/exec_ats [orca] + if [ -e /root/usr/share/pycentral/gnome-orca/site-packages/orca/settings.py ]; then + sed -i '/^enableSpeech\W/ s/True/False/;/^enableMagnifier/ s/False/True/' /root/usr/share/pycentral/gnome-orca/site-packages/orca/settings.py + fi + kderc_addtoprefixes /usr/share/kubuntu-default-settings/kde-profile/lesser-visual-impairment/,/usr/share/kubuntu-default-settings/kde-profile/moderate-visual-impairment/ + ;; + # Blindness + access=v3) + gct -s -t bool /desktop/gnome/sound/enable_esd false + gct -s -t bool /desktop/gnome/interface/accessibility true + gct -s -t list --list-type=string /desktop/gnome/accessibility/startup/exec_ats [orca] + ;; + # Minor Motor Difficulties + access=m1) + gct -s -t bool /desktop/gnome/accessibility/keyboard/enable true + gct -s -t bool /desktop/gnome/accessibility/keyboard/mousekeys_enable true + gct -s -t bool /desktop/gnome/accessibility/keyboard/stickykeys_enable true + gct -s -t bool /desktop/gnome/accessibility/keyboard/stickykeys_modifier_beep true + gct -s -t bool /desktop/accessibility/gnome/keyboard/stickykeys_two_key_off false + gct -s -t bool /desktop/gnome/peripherals/keyboard/repeat true + gct -s -t int /desktop/gnome/peripherals/keyboard/delay 700 + gct -s -t int /desktop/gnome/peripherals/keyboard/rate 10 + + kderc_addtoprefixes /usr/share/kubuntu-default-settings/kde-profile/minor-motor-difficulties/ + if [ -e /root/etc/xdg/xfce4/mcs_settings/keyboard.xml ]; then + sed -i 's/0/1/' /root/etc/xdg/xfce4/mcs_settings/keyboard.xml + fi + ;; + # Motor Difficulties - pointing devices + access=m2) + gct -s -t bool /desktop/gnome/accessibility/keyboard/enable true + gct -s -t bool /desktop/gnome/interface/accessibility true + gct -s -t bool /desktop/gnome/accessibility/keyboard/stickykeys_enable true + gct -s -t bool /desktop/gnome/accessibility/keyboard/stickykeys_modifier_beep false + gct -s -t bool /desktop/accessibility/gnome/keyboard/stickykeys_two_key_off false + gct -s -t list --list-type=string /desktop/gnome/accessibility/startup/exec_ats [onboard] + + kderc_addtoprefixes /usr/share/kubuntu-default-settings/kde-profile/minor-motor-difficulties/,/usr/share/kubuntu-default-settings/kde-profile/motor-difficulties-pointing-devices/ + if [ -e /root/etc/xdg/xfce4/mcs_settings/keyboard.xml ]; then + sed -i '/Sticky/ s/0/1/' /root/etc/xdg/xfce4/mcs_settings/keyboard.xml + fi + ;; + esac +done +log_end_msg diff --git a/scripts/live-bottom/31disable_update_notifier b/scripts/live-bottom/31disable_update_notifier new file mode 100755 index 0000000..6c8b96f --- /dev/null +++ b/scripts/live-bottom/31disable_update_notifier @@ -0,0 +1,34 @@ +#!/bin/sh + +PREREQ="" +DESCRIPTION="Disabling update-notifier..." + +. /scripts/live-functions + +prereqs() +{ + echo "$PREREQ" +} + +case $1 in +# get pre-requisites +prereqs) + prereqs + exit 0 + ;; +esac + +log_begin_msg "$DESCRIPTION" + +# For GNOME, we divert away apt-check to avoid a regular 'apt-get update' +# equivalent in the live session. We want to run update-notifier for crash +# report handling. +chroot /root dpkg-divert --add --rename --quiet \ + /usr/lib/update-notifier/apt-check +ln -s /bin/true /root/usr/lib/update-notifier/apt-check + +# For KDE, adept_notifier's only useful function at the moment is an +# 'apt-get update' equivalent, so we disable it entirely. +rm -f /root/usr/share/autostart/adept_notifier_auto.desktop + +log_end_msg diff --git a/scripts/live-bottom/32disable_hibernation b/scripts/live-bottom/32disable_hibernation new file mode 100755 index 0000000..813abed --- /dev/null +++ b/scripts/live-bottom/32disable_hibernation @@ -0,0 +1,36 @@ +#!/bin/sh + +PREREQ="" +DESCRIPTION="Configuring power management..." + +. /scripts/live-functions + +prereqs() +{ + echo "$PREREQ" +} + +case $1 in +# get pre-requisites +prereqs) + prereqs + exit 0 + ;; +esac + +log_begin_msg "$DESCRIPTION" + + +gpm_version=$(chroot /root /usr/bin/dpkg-query -W --showformat='${Version}' gnome-power-manager 2>/dev/null) || panel_version="" +if [ -n "$gpm_version" ]; then +# live-reconfigure /root gnome-power-manager + chroot /root sudo -u "$USERNAME" gconftool-2 -s -t bool /apps/gnome-power-manager/can_hibernate false + chroot /root sudo -u "$USERNAME" gconftool-2 -s -t bool /apps/gnome-power-manager/can_suspend false +fi + +if [ -d /root/usr/share/kubuntu-default-settings/kde-profile/default/share/config ]; then + echo "disableSuspend=1" >> /root/usr/share/kubuntu-default-settings/kde-profile/default/share/config/power-managerrc + echo "disableHibernate=1" >> /root/usr/share/kubuntu-default-settings/kde-profile/default/share/config/power-managerrc +fi + +log_end_msg diff --git a/scripts/live-bottom/33enable_apport_crashes b/scripts/live-bottom/33enable_apport_crashes new file mode 100755 index 0000000..1fb1145 --- /dev/null +++ b/scripts/live-bottom/33enable_apport_crashes @@ -0,0 +1,28 @@ +#!/bin/sh + +PREREQ="" +DESCRIPTION="Enabling notifications about program crashes..." + +. /scripts/live-functions + +prereqs() +{ + echo "$PREREQ" +} + +case $1 in +# get pre-requisites +prereqs) + prereqs + exit 0 + ;; +esac + +log_begin_msg "$DESCRIPTION" + +update_notifier_version=$(chroot /root dpkg-query -W --showformat='${Version}' update-notifier 2>/dev/null) || update_notifier_version="" +if [ -n "$update_notifier_version" ]; then + chroot /root sudo -u "$USERNAME" gconftool-2 -t bool -s /apps/update-notifier/show_apport_crashes true +fi + +log_end_msg diff --git a/scripts/live-bottom/34disable_kwallet b/scripts/live-bottom/34disable_kwallet new file mode 100755 index 0000000..9fd0c26 --- /dev/null +++ b/scripts/live-bottom/34disable_kwallet @@ -0,0 +1,25 @@ +#! /bin/sh + +PREREQ="" +DESCRIPTION="Disabling kwallet..." + +. /scripts/live-functions + +prereqs() +{ + echo "$PREREQ" +} + +case $1 in +# get pre-requisites +prereqs) + prereqs + exit 0 + ;; +esac + +log_begin_msg "$DESCRIPTION" + +rm -f /root/usr/share/services/kded/kwalletd.desktop + +log_end_msg diff --git a/scripts/live-bottom/35fix_language_selector b/scripts/live-bottom/35fix_language_selector new file mode 100755 index 0000000..1fb78e5 --- /dev/null +++ b/scripts/live-bottom/35fix_language_selector @@ -0,0 +1,32 @@ +#! /bin/sh + +PREREQ="" +DESCRIPTION="Fixing language selector..." + +. /scripts/live-functions + +prereqs() +{ + echo "$PREREQ" +} + +case $1 in +# get pre-requisites +prereqs) + prereqs + exit 0 + ;; +esac + +log_begin_msg "$DESCRIPTION" + +if [ -e /root/usr/share/applications/language-selector.desktop ]; then + sed -i '/^Exec/ s|/usr/bin/gnome-language-selector|"& -n"|' /root/usr/share/applications/language-selector.desktop + +fi + +if [ -x /root/usr/bin/fontconfig-voodoo ]; then + chroot /root fontconfig-voodoo --auto --quiet || true +fi + +log_end_msg diff --git a/scripts/live-bottom/40install_driver_updates b/scripts/live-bottom/40install_driver_updates new file mode 100755 index 0000000..5822f8f --- /dev/null +++ b/scripts/live-bottom/40install_driver_updates @@ -0,0 +1,40 @@ +#! /bin/sh + +PREREQ="" +DESCRIPTION="Installing driver updates..." + +. /scripts/live-functions + +prereqs() +{ + echo "$PREREQ" +} + +case $1 in +# get pre-requisites +prereqs) + prereqs + exit 0 + ;; +esac + +if [ ! -d /tmp/driver-updates ]; then + exit 0 +fi + +log_begin_msg "$DESCRIPTION" + +install_dir=/var/cache/driver-updates + +mkdir "/root$install_dir" +cp -a /tmp/driver-updates/*.deb "/root$install_dir/" + +# We cannot leave packages in a bad state. So if the install fails, remove +# it. This will get caught in casper.log. +for deb in "/root$install_dir"/*; do + if ! chroot /root dpkg -i "$install_dir/$deb"; then + chroot /root dpkg -P "${deb%%_*}" + fi +done + +log_end_msg diff --git a/scripts/live-bottom/41apt_cdrom b/scripts/live-bottom/41apt_cdrom new file mode 100755 index 0000000..97b2cdc --- /dev/null +++ b/scripts/live-bottom/41apt_cdrom @@ -0,0 +1,24 @@ +#! /bin/sh + +PREREQ="" +DESCRIPTION="Adding APT-CDROM source..." + +. /scripts/live-functions + +prereqs() +{ + echo "$PREREQ" +} + +case $1 in +# get pre-requisites +prereqs) + prereqs + exit 0 + ;; +esac + +mkdir -p /root/cdrom +mount -n -o bind /cdrom /root/cdrom +chroot /root apt-cdrom -m add +umount /root/cdrom diff --git a/scripts/live-functions b/scripts/live-functions new file mode 100644 index 0000000..60721b4 --- /dev/null +++ b/scripts/live-functions @@ -0,0 +1,21 @@ + +. /scripts/functions + +# Override this so we don't call PROGRESS +log_end_msg() +{ + if [ -x /sbin/usplash_write ]; then + /sbin/usplash_write "SUCCESS ok" + fi + _log_msg "Done." +} + +# Print a message and wait for enter +log_wait_msg() +{ + if [ -x /sbin/usplash_write ]; then + /sbin/usplash_write "INPUTENTER $@" + read nunya < /dev/.initramfs/usplash_outfifo + fi + _log_msg "Waiting: $@ ..." +} diff --git a/scripts/live-helpers b/scripts/live-helpers new file mode 100644 index 0000000..8402d93 --- /dev/null +++ b/scripts/live-helpers @@ -0,0 +1,197 @@ +## Casper helper functions, used by casper on boot and by casper-snapshot + +if [ "${BUILD_SYSTEM}" = "Ubuntu" ]; then + MP_QUIET="-Q" +elif [ "${BUILD_SYSTEM}" = "Debian" ]; then + MP_QUIET="-q" +else + MP_QUIET="" +fi + +if [ ! -x "/bin/fstype" ]; then + # klibc not in path -> not in initramfs + export PATH="${PATH}:/usr/lib/klibc/bin" +fi + +sys2dev() { + sysdev=${1#/sys} + echo "/dev/$(udevinfo -q name -p ${sysdev} 2>/dev/null|| echo ${sysdev##*/})" +} + +subdevices() { + sysblock=$1 + r="" + for dev in "${sysblock}" "${sysblock}"/*; do + if [ -e "${dev}/dev" ]; then + r="${r} ${dev}" + fi + done + echo ${r} +} + +get_fstype() { + local FSTYPE + local FSSIZE + eval $(fstype < $1) + if [ "$FSTYPE" != "unknown" ]; then + echo $FSTYPE + return 0 + fi + /lib/udev/vol_id -t $1 2>/dev/null +} + +where_is_mounted() { + device=$1 + if grep -q "^$device " /proc/mounts; then + grep "^$device " /proc/mounts | read d mountpoint rest + echo $mountpoint + return 0 + fi + return 1 +} + +lastline() { + while read lines ; do + line=${lines} + done + echo "${line}" +} + +base_path () +{ + testpath="${1}" + mounts="$(awk '{print $2}' /proc/mounts)" + testpath="$(busybox realpath ${testpath})" + + while true ; do + if echo "${mounts}" | grep -qs "^${testpath}" ; then + set -- `echo "${mounts}" | grep "^${testpath}" | lastline` + echo ${1} + break + else + testpath=`dirname $testpath` + fi + done +} + +fs_size () +{ + # Returns used/free fs kbytes + 5% more + # You could pass a block device as $1 or the mount point as $2 + + dev="${1}" + mountp="${2}" + used="${3}" + + if [ -z "${mountp}" ]; then + mountp=$(where_is_mounted "${dev}") + if [ "$?" -gt 0 ]; then + mountp="/mnt/tmp_fs_size" + mkdir -p "${mountp}" + mount -t $(get_fstype "${dev}") -o ro "${dev}" "${mountp}" + doumount=1 + fi + fi + + if [ "${used}" = "used" ]; then + size=$(du -ks ${mountp} | cut -f1) + size=$(expr ${size} + ${size} / 20 ) # FIXME: 5% more to be sure + else + # free space + size="$(df -k | grep -s ${mountp} | awk '{print $4}')" + fi + + if [ -n "${doumount}" ]; then + umount "${mountp}" + rmdir "${mountp}" + fi + echo "${size}" +} + +setup_loop() { + local fspath=$1 + local module=$2 + local pattern=$3 + local offset=$4 + + modprobe ${MP_QUIET} -b "$module" + udevsettle + + for loopdev in $pattern; do + if [ "$(cat $loopdev/size)" -eq 0 ]; then + dev=$(sys2dev "${loopdev}") + if [ -n "$offset" ]; then + losetup -o "$offset" "$dev" "$fspath" + else + losetup "$dev" "$fspath" + fi + echo "$dev" + return 0 + fi + done + panic "No loop devices available" +} + +try_mount () +{ + dev="${1}" + mountp="${2}" + opts="${3}" + + if where_is_mounted ${dev} > /dev/null; then + mount -o remount,"${opts}" ${dev} $(where_is_mounted ${dev}) || panic "Remounting failed" + mount -o bind $(where_is_mounted ${dev}) ${mountp} || panic "Cannot bind-mount" + else + mount -t $(get_fstype "${dev}") -o "${opts}" "${dev}" "${mountp}" || panic "Cannot mount ${dev} on ${mountp}" + fi +} + +find_cow_device() { + pers_label="${1}" + cow_backing="/${pers_label}-backing" + for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -v loop); do + for dev in $(subdevices "${sysblock}"); do + devname=$(sys2dev "${dev}") + if [ "$(/lib/udev/vol_id -l $devname 2>/dev/null)" = "${pers_label}" ]; then + echo "$devname" + return + elif [ "$(get_fstype ${devname})" = "vfat" ]; then # FIXME: all supported block devices should be scanned + mkdir -p "${cow_backing}" + try_mount "${devname}" "${cow_backing}" "rw" + if [ -e "${cow_backing}/${pers_label}" ]; then + echo $(setup_loop "${cow_backing}/${pers_label}" "loop" "/sys/block/loop*") + return 0 + else + umount ${cow_backing} + fi + fi + done + done +} + +find_files() +# return the first of $filenames found on vfat and ext2 devices +# FIXME: merge with above function +{ + filenames="${1}" + snap_backing="/snap-backing" + for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -v loop); do + for dev in $(subdevices "${sysblock}"); do + devname=$(sys2dev "${dev}") + devfstype="$(get_fstype ${devname})" + if [ "${devfstype}" = "vfat" ] || [ "${devfstype}" = "ext2" ] ; then # FIXME: all supported block devices should be scanned + mkdir -p "${snap_backing}" + try_mount "${devname}" "${snap_backing}" "ro" + for filename in ${filenames}; do + if [ -e "${snap_backing}/${filename}" ]; then + echo "${devname} ${snap_backing} ${filename}" + return 0 + fi + done + umount ${snap_backing} + fi + done + done +} + + diff --git a/scripts/live-premount/10driver_updates b/scripts/live-premount/10driver_updates new file mode 100755 index 0000000..55aece5 --- /dev/null +++ b/scripts/live-premount/10driver_updates @@ -0,0 +1,163 @@ +#!/bin/sh + +PREREQ="" +. /scripts/live-functions +. /scripts/live-helpers + +prereqs() +{ + echo "$PREREQ" +} + +case $1 in +# get pre-requisites +prereqs) + prereqs + exit 0 + ;; +esac + +mountpoint=/cdrom + +is_updates_path() { + # Driver packages are stored in ubuntu-drivers// + # subdirectory. Each package contains a module for a specific + # kernel flavour. + path=$1 + kbase=$(uname -r | sed 's/^\([0-9]*\.[0-9]*\.[0-9]*\)-.*/\1/') + update_dir="$path/ubuntu-drivers/$kbase" + if [ -d "$update_dir" ]; then + if [ "$(echo $update_dir/*_$DPKG_ARCH.deb)" != \ + "$update_dir/*_$DPKG_ARCH.deb" ]; then + echo "$update_dir" + return 0; + fi + fi + return 1; +} + +is_nice_device() { + sysfs_path="${1#/sys}" + if /lib/udev/path_id "${sysfs_path}" | grep -E -q "ID_PATH=(usb|pci-[^-]*-[ide|scsi|usb])"; then + return 0 + fi + return 1 +} + +is_supported_fs () { + # FIXME: do something better like the scan of supported filesystems + fstype="${1}" + case ${fstype} in + vfat|iso9660|udf|ext2|ext3|ntfs) + return 0 + ;; + esac + return 1 +} + +check_dev_updates () +{ + sysdev="${1}" + devname="${2}" + if [ -z "${devname}" ]; then + devname=$(sys2dev "${sysdev}") + fi + + fstype=$(get_fstype "${devname}") + if is_supported_fs ${fstype}; then + mount -t ${fstype} -o ro "${devname}" $mountpoint || continue + if is_updates_path $mountpoint; then + return 0 + else + umount $mountpoint + fi + fi + + return 1 +} + +find_driver_updates() { + for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -v loop | grep -v ram); do + devname=$(sys2dev "${sysblock}") + fstype=$(get_fstype "${devname}") + if /lib/udev/cdrom_id ${devname} > /dev/null; then + if check_dev_updates "null" "${devname}" ; then + return 0 + fi + elif is_nice_device "${sysblock}" ; then + for dev in $(subdevices "${sysblock}"); do + if check_dev_updates "${dev}" ; then + return 0 + fi + done + fi + done + return 1 +} + +pulsate() { + if [ -x /sbin/usplash_write ]; then + /sbin/usplash_write "PULSATE" + fi +} + + +updates="false" + +for x in $(cat /proc/cmdline); do + case $x in + debian-installer/driver-update=*) + updates=${x#debian-installer/driver-update=} + ;; + esac +done + +if [ "$updates" != "true" ]; then + log_end_msg + exit 0 +fi + +# Not sure what to do for network installs. I assume there isn't even a CD +# for this anyway, so fail. +if [ -n "${NETBOOT}" ]; then + log_end_msg + exit 0; +fi + +#if chroot /root [ -f /etc/gdm/gdm-cdd.conf ]; then +# GDMCONF=/etc/gdm/gdm-cdd.conf +#else +# GDMCONF=/etc/gdm/gdm.conf +#fi + +eject +log_wait_msg "Insert a driver CD and press ENTER ($DPKG_ARCH)" + +log_begin_msg "Looking for driver update CD" + +for i in 0 1 2 3 4 5 6 7 8 9 a b c d e f 10 11 12 13; do + updates_root=$(find_driver_updates) + if [ "${updates_root}" ]; then + break; + fi + sleep 1 +done + +log_end_msg + +if [ -z "${updates_root}" ]; then + log_begin_msg "Could not find driver updates" + log_wait_msg "Re-insert install CD and press ENTER" + exit 0 +fi + +log_begin_msg "Copying driver updates to temporary location" + +mkdir -p /tmp/driver-updates +cp $updates_root/*_$DPKG_ARCH.deb /tmp/driver-updates/ +umount $mountpoint +eject + +log_end_msg + +log_wait_msg "Re-insert install CD and press ENTER." -- cgit v1.2.3