Ubuntu Pastebin

Paste from ogra at Mon, 23 May 2016 10:42:52 +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
case $PROJECT:$SUBPROJECT in
        ubuntu-core:system-image|ubuntu-desktop-next:system-image)

    # create device tarball (for snappy only atm)
    if [ "$PROJECT:$SUBPROJECT" = "ubuntu-core:system-image" ]; then
      case $ARCH in
          armhf)
            subarches="generic raspi2"
            ;;
          arm64)
            subarches="generic dragonboard"
            ;;
          i386|amd64|powerpc|ppc64el|s390x)
            subarches="generic"
            ;;
      esac

      # create a clean chroot
      debootstrap --variant=minbase $LB_DISTRIBUTION chroot-device $LB_PARENT_MIRROR_BOOTSTRAP

      # ... but keep the PPA setup
      cp -a chroot/etc/apt/* chroot-device/etc/apt/

      # ... and move it in place
      rm -rf chroot
      mv chroot-device chroot

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

        linux_package="linux-image-$devarch"
        case $ARCH in
            amd64)
              linux_package="linux-signed-image-generic"
              ;;
            arm64)
              if [ "$devarch" = "dragonboard" ]; then
                  linux_package="linux-image-snapdragon linux-firmware-snapdragon"
              fi
              ;;
            armhf)
              if [ "$devarch" = "raspi2" ]; then
                  linux_package="linux-image-raspi2"
              fi
              ;;
            ppc64el|s390x)
              echo "I: skipping kernel and device tarball for $ARCH"
              return
              ;;
        esac

...
        # 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"

        Chroot chroot "dpkg -l" > chroot/dpkg.list
...
        kvers="$(ls vmlinuz-*|sed 's/^.*vmlinuz-//;s/-[a-z.]*$//')"

        VERSION=$kvers+$(date +20%y%m%d.%H-%M)

        cat > meta/kernel.yaml <<EOF
version: $kvers
EOF
        
        cat > meta/snap.yaml <<EOF
name: $metaname
version: $VERSION
architectures: [$ARCH]
summary: The canonical $devarch $ARCH kernel
type: kernel

kernel: $(ls vmlinuz-*)
initrd: $(ls initrd.img-*)
modules: $(ls -d lib/modules/*)
firmware: lib/firmware
EOF
        if [ -d dtbs ]; then
            printf "dtbs: dtbs/ \n" >> meta/snap.yaml
        fi
        cd $HERE

        apt-get -y install snapcraft
        snapcraft snap snap
...
Download as text