Ubuntu Pastebin

Paste from ogra at Mon, 16 Nov 2015 15:01:59 +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
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
      # create a clean chroot
      debootstrap --variant=minbase $LB_DISTRIBUTION chroot $LB_PARENT_MIRROR_BOOTSTRAP

      for devarch in $subarches; do
        (echo "I: creating $devarch device tarball for $ARCH"
        HERE="$(pwd)"
        set -x

        linux_package="linux-$devarch"
        case $ARCH in
            amd64)
              linux_package="linux-signed-generic"
              ;;
        esac

        # make sure all virtual filesystems are available
        lb chroot_proc install "$@"
        lb chroot_sysfs install "$@"
        lb chroot_devpts install "$@"

        # prepare the env
        Chroot chroot "apt-get -y update"
        Chroot chroot "apt-get -y purge linux-image-*"
        Chroot chroot "apt-get -y autoremove"
        rm -rf chroot/boot/initrd.img* chroot/boot/vmlinu?-* chroot/lib/modules/* \
            chroot/boot/abi-* chroot/boot/System.map-* chroot/boot/config-*
        mkdir -p chroot/etc/initramfs-tools/conf.d
        echo "COMPRESS=lzma" >chroot/etc/initramfs-tools/conf.d/snappy-device-tarball.conf

        # install needed packages and the kernel itself
        Chroot chroot "apt-get -y install initramfs-tools-ubuntu-core linux-firmware xz-utils"
        Chroot chroot "apt-get -y install $linux_package"

        # clean up
        lb chroot_devpts remove "$@"
        lb chroot_sysfs remove "$@"
        lb chroot_proc remove "$@"

        # now build the actual device tarball
        TMPDIR="$(mktemp -d)"
        mkdir -p $TMPDIR/system/
        mkdir -p $TMPDIR/assets/

        cd chroot
        cp -ar --parent lib/modules/ $TMPDIR/system/
        cp -ar --parent lib/firmware/ $TMPDIR/system/

        # new assets handling
        if [ -f boot/vmlinu?-*.signed ]; then
            kernel=boot/vmlinu?-*.signed
        else
            kernel=boot/vmlinu?-*
        fi

        initrd=boot/initrd.img-*

        cp -ar $initrd $TMPDIR/assets/
        cp -ar $kernel $TMPDIR/assets/
        cp -ar boot/abi-* boot/System.map-* boot/config-* $TMPDIR/assets/

        dtbs=$(find lib/firmware -type d -name 'device-tree' -print0)
        if [ -n "$dtbs" ]; then
           mv "$dtbs" $TMPDIR/assets/dtbs
           case $devarch in
               raspi2)
                   # ubuntu-device-flash does not like subdirs here, we need to tar it up
                   if [ -e $TMPDIR/assets/dtbs/overlays ]; then
                       tar -C $TMPDIR/assets/dtbs -f $TMPDIR/assets/dtbs/overlays.tgz -czv overlays
                       rm -rf $TMPDIR/assets/dtbs/overlays
                   fi
                   ;;
           esac
        fi

        # create hardware.yaml
        # this assumes armhf == u-boot
        # and all others grub
        # common bits
        cat > $TMPDIR/hardware.yaml << EOF
kernel: assets/$(basename $kernel)
initrd: assets/$(basename $initrd)
partition-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

        # compress everything
        cd $TMPDIR
        tarname="device.tar.gz"
        if [ "$devarch" = "raspi2" ];then
            tarname="raspi2.$tarname"
        fi
        tar -c -z -f $HERE/$PREFIX.$tarname system assets hardware.yaml

        # show size of initrd and kernel in the log
        ls -lh assets/

        # dump the content list into the log
        echo "I: device tarball contents for $PREFIX.$tarname:"
        find . -type f

        # azure wants its own device tarball
        if [ "$ARCH" = "amd64" ]; then
            cp $HERE/$PREFIX.$tarname $HERE/$PREFIX.azure.$tarname
        fi
        cd $HERE)
      done
Download as text