diff --git a/debian/changelog b/debian/changelog index ffd3ca26..8d9d2cc8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +livecd-rootfs (2.306) wily; urgency=medium + + * Create hooks and image build config for the ubuntu-desktop-next + new based on snappy image. + + -- Didier Roche Fri, 29 May 2015 11:51:22 +0200 + livecd-rootfs (2.305) wily; urgency=medium * also add /lib/firmware to the dirs we pre-create on touch and core. diff --git a/live-build/auto/build b/live-build/auto/build index 0cf28a29..5a19d484 100755 --- a/live-build/auto/build +++ b/live-build/auto/build @@ -332,10 +332,11 @@ if [ -e "binary/$INITFS/filesystem.packages-remove" ]; then fi fi -# ubuntu-core splits kernel stuff into a "device" tarball so at this point -# we reset it to "none" as all the work to extract it was done already +# ubuntu-core and ubuntu-desktop-next splits kernel stuff into a "device" tarball so +# at this point we reset it to "none" as all the work to extract it was done already # in a binary hook -if [ "$PROJECT" = "ubuntu-core" ] && [ "$SUBPROJECT" = "system-image" ]; then +case $PROJECT:$SUBPROJECT in + ubuntu-core:system-image|ubuntu-desktop-next:system-image) LB_LINUX_FLAVOURS=none # rename to have the right prefix etc @@ -345,6 +346,15 @@ if [ "$PROJECT" = "ubuntu-core" ] && [ "$SUBPROJECT" = "system-image" ]; then if [ -e device-azure.tar.gz ]; then mv device-azure.tar.gz "$PREFIX.azure.device.tar.gz" fi + ;; +esac + +if [ "$PROJECT" = "ubuntu-desktop-next" ] && [ "$SUBPROJECT" = "system-image" ]; then + LB_LINUX_FLAVOURS=none + + # rename to have the right prefix etc + mv device.tar.gz "$PREFIX.device.tar.gz" + fi for FLAVOUR in $LB_LINUX_FLAVOURS; do diff --git a/live-build/auto/config b/live-build/auto/config index ee8dea1e..ceabd07c 100755 --- a/live-build/auto/config +++ b/live-build/auto/config @@ -162,7 +162,7 @@ if [ "$PREINSTALLED" = "true" ] && [ "$SUBPROJECT" != "wubi" ]; then ubuntu-server) add_package live oem-config-debconf ubiquity-frontend-debconf ;; - ubuntu-core|base|ubuntu-touch|ubuntu-cpc) + ubuntu-core|base|ubuntu-touch|ubuntu-cpc|ubuntu-desktop-next) ;; *) add_package live oem-config-gtk ubiquity-frontend-gtk @@ -210,6 +210,15 @@ case $PROJECT in case $ARCH in amd64) add_package live linux-signed-generic ;; esac + + # system image snappy desktop next image + # mvo: This is for cron.daily-preinstalled + # CDIMAGE_PREINSTALLED is not passed from build.py + # and PREINSTALLED means something different. So + # we use SUBPROJECT to pass on the information + if [ "$SUBPROJECT" = "system-image" ]; then + OPTS="${OPTS:+$OPTS }--linux-packages=linux-image" + fi ;; kubuntu|kubuntu-dvd) diff --git a/live-build/ubuntu-desktop-next/hooks/00-uid-gid-fix.chroot_early b/live-build/ubuntu-desktop-next/hooks/00-uid-gid-fix.chroot_early new file mode 100755 index 00000000..00ff4e3f --- /dev/null +++ b/live-build/ubuntu-desktop-next/hooks/00-uid-gid-fix.chroot_early @@ -0,0 +1,241 @@ +#!/bin/sh -eu + +ERRCNT="" + +# Known good post-debootstrap values +passwd_bootstrap="af34a24499223f08ab713138bec7ff54" +shadow_bootstrap="1fd73103260cbe5a13a4a38320de4129" +group_bootstrap="9edf30f181a6fd1d860cc7f4a71aa640" +gshadow_bootstrap="b9db51ef767ab98db963db69844635dd" + +# Current post-debootstrap values +passwd_hash=$(set -- $(md5sum /etc/passwd) && echo $1) +shadow_hash=$(set -- $(cat /etc/shadow | sed "s/:.*:0:99999:/:0:99999:/g" | md5sum) && echo $1) +group_hash=$(set -- $(md5sum /etc/group) && echo $1) +gshadow_hash=$(set -- $(md5sum /etc/gshadow) && echo $1) + +# /etc/passwd +if [ "$passwd_bootstrap" = "$passwd_hash" ]; then + cat > /etc/passwd <&2 + echo "The output below might help to resolve the issue" >&2 + cat /etc/passwd + echo "passwd md5sum: $passwd_hash" >&2 + ERRCNT=1 +fi + +# /etc/shadow +if [ "$shadow_bootstrap" = "$shadow_hash" ]; then + cat > /etc/shadow <&2 + echo "The output below might help to resolve the issue" >&2 + cat /etc/shadow + echo "shadow md5sum: $shadow_hash" >&2 + ERRCNT=1 +fi + +# /etc/group +if [ "$group_bootstrap" = "$group_hash" ]; then + cat > /etc/group <&2 + echo "The output below might help to resolve the issue" >&2 + cat /etc/group + echo "group md5sum: $group_hash" >&2 + ERRCNT=1 +fi + +# /etc/gshadow +if [ "$gshadow_bootstrap" = "$gshadow_hash" ]; then + cat > /etc/gshadow <&2 + echo "The output below might help to resolve the issue" >&2 + cat /etc/gshadow + echo "gshadow md5sum: $gshadow_hash" >&2 + ERRCNT=1 +fi + +if [ -n "$ERRCNT" ]; then + echo "There were changes to the password database," >&2 + echo "please adjust the values in the livecd-rootfs source in the file:" >&2 + echo "live-build/ubuntu-core/hooks/00-uid-gid-fix.chroot_early" >&2 + echo >&2 + echo "Please check also if a maintainer script of the package" >&2 + echo "that added these entries perhaps created a home directory and," >&2 + echo "if needed, add code for creation of it to the above hook" >&2 + exit 1 +fi + + +# Record the current state for later comparison +for file in /etc/passwd /etc/shadow /etc/group /etc/gshadow; do + rm -f ${file}- + cp ${file} ${file}.orig +done diff --git a/live-build/ubuntu-desktop-next/hooks/01-setup_user.chroot b/live-build/ubuntu-desktop-next/hooks/01-setup_user.chroot new file mode 100755 index 00000000..967c6a1b --- /dev/null +++ b/live-build/ubuntu-desktop-next/hooks/01-setup_user.chroot @@ -0,0 +1,37 @@ +#!/bin/sh -x + +set -e + +USER=ubuntu +UGID=1000 + +echo "I: creating default user $USER" +adduser --gecos $USER --disabled-login $USER --uid $UGID + +chown -R $UGID:$UGID /home/$USER + +# Enable libnss-extrusers +sed -i 's/^group:.*compat/\0 extrausers/' /etc/nsswitch.conf +sed -i 's/^passwd:.*compat/\0 extrausers/' /etc/nsswitch.conf +sed -i 's/^shadow:.*compat/\0 extrausers/' /etc/nsswitch.conf + +# Move user from /etc to extrausers location +grep "^$USER" /etc/group >> /var/lib/extrausers/group +grep "^$USER" /etc/passwd >> /var/lib/extrausers/passwd +grep "^$USER" /etc/shadow >> /var/lib/extrausers/shadow +grep "^$USER" /etc/gshadow >> /var/lib/extrausers/gshadow +chmod 0644 /var/lib/extrausers/group +chmod 0644 /var/lib/extrausers/passwd +chmod 0640 /var/lib/extrausers/shadow +chmod 0640 /var/lib/extrausers/gshadow +chown root:shadow /var/lib/extrausers/shadow +chown root:shadow /var/lib/extrausers/gshadow +sed -i "/^$USER/d" /etc/group +sed -i "/^$USER/d" /etc/passwd +sed -i "/^$USER/d" /etc/shadow +sed -i "/^$USER/d" /etc/gshadow + +# needs to run *after* the user was moved out to /var/lib/extrausers +echo "I: set user $USER password to $USER" +echo "$USER:$USER" | chpasswd + diff --git a/live-build/ubuntu-desktop-next/hooks/02-add_user_to_groups.chroot b/live-build/ubuntu-desktop-next/hooks/02-add_user_to_groups.chroot new file mode 100755 index 00000000..104cd44c --- /dev/null +++ b/live-build/ubuntu-desktop-next/hooks/02-add_user_to_groups.chroot @@ -0,0 +1,8 @@ +#!/bin/sh -x + +USER=ubuntu + +DEFGROUPS="docker,sudo" + +echo "I: add $USER to ($DEFGROUPS) group(s)" +usermod -a -G ${DEFGROUPS} ${USER} diff --git a/live-build/ubuntu-desktop-next/hooks/03-boot_with_systemd.chroot b/live-build/ubuntu-desktop-next/hooks/03-boot_with_systemd.chroot new file mode 100755 index 00000000..f19164f0 --- /dev/null +++ b/live-build/ubuntu-desktop-next/hooks/03-boot_with_systemd.chroot @@ -0,0 +1,11 @@ +#!/bin/sh -x + +# Boot using systemd and disable quiet boot +# to see what is happening. +systemd=/lib/systemd/systemd +if [ -f /etc/default/grub ]; then + sed -i \ + -e "s,^\\([ ]*GRUB_CMDLINE_LINUX\\)=\"\"$,\\1=\"init=$systemd\",g" \ + -e 's,^\([ ]*GRUB_CMDLINE_LINUX_DEFAULT\)="quiet splash",\1="",g' \ + /etc/default/grub +fi diff --git a/live-build/ubuntu-desktop-next/hooks/04-configure_network.chroot b/live-build/ubuntu-desktop-next/hooks/04-configure_network.chroot new file mode 100755 index 00000000..d96d9aa8 --- /dev/null +++ b/live-build/ubuntu-desktop-next/hooks/04-configure_network.chroot @@ -0,0 +1,9 @@ +#!/bin/sh -x + +if=eth0 + +# Manually configure the first ethernet device +cat >/etc/network/interfaces.d/"$if"<>/etc/fstab</etc/motd<$PREFIX/usr/local/bin/no-apt < $TMPDIR/hardware.yaml << EOF +kernel: assets/vmlinuz +initrd: assets/initrd.img +partiton-layout: system-AB +EOF + +# arch specific ones +if [ "$ARCH" = "armhf" ]; then + cat >> $TMPDIR/hardware.yaml << EOF +dtbs: assets/dtbs +bootloader: u-boot +EOF +else + cat >> $TMPDIR/hardware.yaml << EOF +bootloader: grub +EOF +fi +) + +# and tar it up +( + cd $TMPDIR + tar -c -z -f $HERE/device.tar.gz system assets hardware.yaml +) + +# now build the azure device tarball by adding walinuxagent +if [ -e binary/boot/filesystem.dir/var/lib/dpkg/info/walinuxagent.list ]; +then +( + cd binary/boot/filesystem.dir + while read line; do + line=$(echo $line |cut -d/ -f2-) + if [ -e "$line" ] && [ ! -d "$line" ]; then + cp -ar --parent $line $TMPDIR/system + fi + done < var/lib/dpkg/info/walinuxagent.list + # created by walinuxagent postinst/dh-systemd + cp -ar --parent var/lib/systemd/deb-systemd-helper-enabled/walinuxagent* $TMPDIR/system + cp -ar --parent etc/systemd/system/multi-user.target.wants/walinuxagent* $TMPDIR/system + mkdir -p $TMPDIR/system/var/lib/waagent +) +# and tar it up +( + cd $TMPDIR + tar -c -z -f $HERE/device-azure.tar.gz system assets hardware.yaml +) +fi +rm -rf $TMPDIR + +# remove files from the root filesystem +(cd binary/boot/filesystem.dir + rm -f boot/vmlinu?-* + rm -f boot/initrd.img-* + rm -f boot/abi-* + rm -f boot/System.map-* + rm -f initrd.img + rm -f vmlinu? + rm -rf lib/modules + rm -rf lib/firmware + # remove walinuxagent + if [ -e var/lib/dpkg/info/walinuxagent.list ]; then + chroot . dpkg --purge walinuxagent || true + fi +) diff --git a/live-build/ubuntu-desktop-next/hooks/99zz-check-uid-gid.chroot b/live-build/ubuntu-desktop-next/hooks/99zz-check-uid-gid.chroot new file mode 100755 index 00000000..4d7b807d --- /dev/null +++ b/live-build/ubuntu-desktop-next/hooks/99zz-check-uid-gid.chroot @@ -0,0 +1,52 @@ +#!/bin/sh -eu + +ERRCNT="" + +passwd_hash=$(set -- $(md5sum /etc/passwd) && echo $1) +shadow_hash=$(set -- $(cat /etc/shadow | sed "s/:.*:0:99999:/:0:99999:/g" | md5sum) && echo $1) +group_length=$(cat /etc/group | wc -l) +gshadow_length=$(cat /etc/gshadow | wc -l) + +passwd_orig_hash=$(set -- $(md5sum /etc/passwd.orig) && echo $1) +shadow_orig_hash=$(set -- $(cat /etc/shadow.orig | sed "s/:.*:0:99999:/:0:99999:/g" | md5sum) && echo $1) +group_orig_length=$(cat /etc/group.orig | wc -l) +gshadow_orig_length=$(cat /etc/gshadow.orig | wc -l) + +if [ "$passwd_hash" != "$passwd_orig_hash" ]; then + echo "/etc/passwd has changed during setup." >&2 + echo "The new /etc/passwd md5sum is: $passwd_hash" >&2 + diff -Nrup /etc/passwd.orig /etc/passwd >&2 || true + ERRCNT=1 +fi + +if [ "$shadow_hash" != "$shadow_orig_hash" ]; then + echo "/etc/shadow has changed during setup." >&2 + echo "The new /etc/shadow md5sum is: $shadow_hash" >&2 + diff -Nrup /etc/shadow.orig /etc/shadow >&2 || true + ERRCNT=1 +fi + +if [ "$group_length" != "$group_orig_length" ]; then + echo "/etc/group has changed during setup." >&2 + diff -Nrup /etc/group.orig /etc/group >&2 || true + ERRCNT=1 +fi + +if [ "$gshadow_length" != "$gshadow_orig_length" ]; then + echo "/etc/gshadow has changed during setup." >&2 + diff -Nrup /etc/gshadow.orig /etc/gshadow >&2 || true + ERRCNT=1 +fi + +if [ -n "$ERRCNT" ]; then + echo "There were changes to the password database," >&2 + echo "please adjust the values in the livecd-rootfs source in the file:" >&2 + echo "live-build/ubuntu-core/hooks/00-uid-gid-fix.chroot_early" >&2 + echo >&2 + echo "Please check also if a maintainer script of the package" >&2 + echo "that added these entries perhaps created a home directory and," >&2 + echo "if needed, add code for creation of it to the above hook" >&2 + exit 1 +fi + +rm /etc/passwd.orig /etc/shadow.orig /etc/group.orig /etc/gshadow.orig