Ubuntu Pastebin

Paste from ubuntu at Wed, 13 Jan 2016 16:07:31 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/bash
##
## Summary: is there a way to tell grub-pc on installation that it should
## not grub-probe and grub-install if I do not care about functional grub?
##
##  The goal is to install a kernel by package name (linux-generic)
##  into the "lxd tarball" (-root.tar.xz file) at 
##  http://cloud-images.ubuntu.com/daily/server/xenial/current/
##
##  The reason is to get the vmlinuz and a initramfs file.
##
##  On amd64, 
##    linux-generic -> linux-image-generic -> linux-image-4.3.0-5-generic
##    the 'linux-image-4.3.0-5-generic' package:
##      Recommends: grub-pc | grub-efi-amd64 | grub-efi-ia32 | grub | lilo (>= 19.1)
##
##  That installation of grub-pc causes me to fail like:
##     Setting up grub-pc (2.02~beta2-32ubuntu1) ...
##     Creating config file /etc/default/grub with new version
##     grub-probe: error: cannot find a device for / (is /dev mounted?).
##     grub-probe: error: cannot find a device for /boot (is /dev mounted?).
##     grub-probe: error: cannot find a device for /boot/grub (is /dev mounted?).
##     /usr/sbin/grub-probe: error: cannot find a device for / (is /dev mounted?).
##     dpkg: error processing package grub-pc (--configure):
##      subprocess installed post-installation script returned error exit status 1
##     Processing triggers for libc-bin (2.21-0ubuntu5) ...
##     /bin/df: no file systems processed
##     Processing triggers for ureadahead (0.100.0-19) ...
##     Processing triggers for systemd (228-3ubuntu1) ...
##     Processing triggers for dbus (1.10.6-1ubuntu1) ...
##     Errors were encountered while processing:
##      grub-pc
##     E: Sub-process /usr/bin/dpkg returned an error code (1)
##
##   I do not care specifically about grub-pc.  I'd like to keep 'recommends' to
##   to have whatever other goodness that would bring (assuming that therea are
##   valid reasons for the other packages that get installed:
##
##     crda grub-common grub-gfxpayload-lists grub-pc grub-pc-bin grub2-common
##     iw libnl-3-200 libnl-genl-3-200 linux-firmware linux-headers-4.3.0-5
##     linux-headers-4.3.0-5-generic linux-headers-generic linux-image-4.3.0-5-generic
##     linux-image-extra-4.3.0-5-generic linux-image-generic thermald wireless-regdb
##
XDIR="$PWD/x"

umount_r() {
    local p
    for p in "$@"; do
        [ -n "$p" ] || continue
        tac /proc/mounts | sh -c '
            p=$1
            while read s mp t opt a b ; do
                [ "${mp}" = "${p}" -o "${mp#${p}/}" != "${mp}" ] ||
                    continue
                umount "$mp" || exit 1
            done
            exit 0' umount_r "${p%/}"
        [ $? -eq 0 ] || return
    done
}

cleanup() {
   umount_r "$XDIR"
   
}
trap cleanup EXIT
fail() { echo "$@" 1>&2; exit 1; }
msg() { echo "$@" 1>&2; }
vrun() { msg "$@"; "$@"; }
set -e

url=http://cloud-images.ubuntu.com/daily/server/xenial/current/xenial-server-cloudimg-amd64-root.tar.xz
img=${url##*/}
if [ ! -f "${img}" ]; then
  wget "$url" -O "$img.tmp" && mv "$img.tmp" "$img" || fail "failed download $url"
fi
[ "$(id -u)"  = "0" ] || fail "must be root"

if [ -e "$XDIR" ]; then
   msg "removing existing $XDIR"
   rm -Rf "$XDIR"
fi
mkdir "$XDIR"

msg "extracting $img to $XDIR"
tar -C "$XDIR" -xpf "$img" 
mv "$XDIR/etc/resolv.conf" "$XDIR/etc/resolv.conf.dist"
cp "/etc/resolv.conf" "$XDIR/etc/resolv.conf"
mount -t proc /proc $XDIR/proc

vrun chroot "$XDIR" env DEBIAN_FRONTEND=noninteractive sh -ec \
   'apt-get update -q; apt-get install -qy linux-generic </dev/null'
Download as text