[RESEND] UBUNTU: snapcraft.yaml: various improvements

Message ID 1501755972-22202-1-git-send-email-paolo.pisati@canonical.com
State New
Headers show

Commit Message

Paolo Pisati Aug. 3, 2017, 10:26 a.m.
BugLink: http://bugs.launchpad.net/bugs/1700577

Update the snapcraft.yaml we ship in Xenial to exploit some of the new feature
present in snapcraft's 3.21.

Among the improvements:

1) include the linux-firmware / raspberry-firmware-wireless package in the final
snap
2) rename it to pi2-kernel to match the snaps we have in the store
3) dynamic versioning
4) autogenerated config from debian.$DEBIAN/config/*
5) automatic download of raspberry-firmware-wireless from ppa:~snappy-dev

This brings the pi2 kernel in line with generic/pc-kernel and
snapdragon/snapdragon-kernel.

The resulting kernel is identical to the one we push to the store, but can be
fully built locally. Tested manually by comparing the two snaps (local generated
and the one we have in the store) and by building an edge image from scratch.

Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
---
 snapcraft.yaml | 53 +++++++++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 47 insertions(+), 6 deletions(-)

Comments

Kleber Souza Aug. 3, 2017, 10:33 a.m. | #1
On 08/03/17 12:26, Paolo Pisati wrote:
> BugLink: http://bugs.launchpad.net/bugs/1700577
> 
> Update the snapcraft.yaml we ship in Xenial to exploit some of the new feature
> present in snapcraft's 3.21.
> 
> Among the improvements:
> 
> 1) include the linux-firmware / raspberry-firmware-wireless package in the final
> snap
> 2) rename it to pi2-kernel to match the snaps we have in the store
> 3) dynamic versioning
> 4) autogenerated config from debian.$DEBIAN/config/*
> 5) automatic download of raspberry-firmware-wireless from ppa:~snappy-dev
> 
> This brings the pi2 kernel in line with generic/pc-kernel and
> snapdragon/snapdragon-kernel.
> 
> The resulting kernel is identical to the one we push to the store, but can be
> fully built locally. Tested manually by comparing the two snaps (local generated
> and the one we have in the store) and by building an edge image from scratch.
> 
> Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>

Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>

> ---
>  snapcraft.yaml | 53 +++++++++++++++++++++++++++++++++++++++++++++++------
>  1 file changed, 47 insertions(+), 6 deletions(-)
> 
> diff --git a/snapcraft.yaml b/snapcraft.yaml
> index e61207d..4581b9c 100644
> --- a/snapcraft.yaml
> +++ b/snapcraft.yaml
> @@ -1,7 +1,12 @@
> -name: ubuntu-raspi2-kernel
> -version: 4.4.0
> -summary: The Raspberry Pi 2/3 kernel for snappy
> -description: This is a snapped kernel, based off the xenial raspi2 branch and config
> +name: pi2-kernel
> +version: null
> +version-script: |
> +    . debian/debian.env
> +    dpkg-parsechangelog -l $DEBIAN/changelog -S version
> +summary: The Canonical raspi2 Linux kernel
> +description: The Canonical raspi2 Linux kernel
> +grade: stable
> +confinement: strict
>  type: kernel
>  
>  parts:
> @@ -9,8 +14,44 @@ parts:
>      plugin: kernel
>      source: .
>      source-type: git
> -    kdefconfig: ['--makefile=debian/snapcraft.mk', 'branch=raspi2','flavour=raspi2', 'config']
> +    kconfigflavour: raspi2
>      kconfigs:
> -      - CONFIG_LOCALVERSION="-xenial_raspi2"
>        - CONFIG_DEBUG_INFO=n
>      kernel-image-target: zImage
> +    install: |
> +      tar -C $SNAPCRAFT_PART_INSTALL/dtbs -f $SNAPCRAFT_PART_INSTALL/dtbs/overlays.tgz -czv overlays
> +      rm -rf $SNAPCRAFT_PART_INSTALL/dtbs/overlays
> +  firmware:
> +    plugin: nil
> +    stage-packages:
> +      - linux-firmware
> +    organize:
> +      lib/firmware: firmware
> +    prime:
> +      - -usr
> +      - -lib
> +    install: |
> +      rm $SNAPCRAFT_PART_INSTALL/lib/firmware/brcm/brcmfmac43430-sdio.bin
> +    build-packages:
> +      - cpio
> +      - libssl-dev
> +  raspiwififw:
> +    plugin: nil
> +    source: .
> +    after:
> +      - firmware
> +    prepare: |
> +      PKGS="http://ppa.launchpad.net/snappy-dev/image/ubuntu/dists/xenial/main/binary-armhf/Packages.gz"
> +      PKGPATH="$(wget -q -O- $PKGS|zcat|grep-dctrl raspberrypi-wireless-firmware |\
> +        grep Filename|tail -1| sed 's/^Filename: //')"
> +      wget http://ppa.launchpad.net/snappy-dev/image/ubuntu/$PKGPATH
> +      dpkg -x $(basename $PKGPATH) unpack/
> +    install: |
> +      mkdir -p $SNAPCRAFT_PART_INSTALL/firmware/brcm
> +      mv unpack/usr/share/doc/raspberrypi-wireless-firmware $SNAPCRAFT_PART_INSTALL/firmware/rpi-wlanfw-licenses
> +      mv unpack/lib/firmware/brcm80211/brcm/* $SNAPCRAFT_PART_INSTALL/firmware/brcm
> +    build-packages:
> +      - coreutils
> +      - dctrl-tools
> +      - sed
> +      - wget
>
Stefan Bader Aug. 3, 2017, 1:40 p.m. | #2
On 03.08.2017 12:26, Paolo Pisati wrote:
> BugLink: http://bugs.launchpad.net/bugs/1700577
> 
> Update the snapcraft.yaml we ship in Xenial to exploit some of the new feature
> present in snapcraft's 3.21.
> 
> Among the improvements:
> 
> 1) include the linux-firmware / raspberry-firmware-wireless package in the final
> snap
> 2) rename it to pi2-kernel to match the snaps we have in the store
> 3) dynamic versioning
> 4) autogenerated config from debian.$DEBIAN/config/*
> 5) automatic download of raspberry-firmware-wireless from ppa:~snappy-dev
> 
> This brings the pi2 kernel in line with generic/pc-kernel and
> snapdragon/snapdragon-kernel.
> 
> The resulting kernel is identical to the one we push to the store, but can be
> fully built locally. Tested manually by comparing the two snaps (local generated
> and the one we have in the store) and by building an edge image from scratch.
> 
> Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>

> ---

Provided it applies...

>  snapcraft.yaml | 53 +++++++++++++++++++++++++++++++++++++++++++++++------
>  1 file changed, 47 insertions(+), 6 deletions(-)
> 
> diff --git a/snapcraft.yaml b/snapcraft.yaml
> index e61207d..4581b9c 100644
> --- a/snapcraft.yaml
> +++ b/snapcraft.yaml
> @@ -1,7 +1,12 @@
> -name: ubuntu-raspi2-kernel
> -version: 4.4.0
> -summary: The Raspberry Pi 2/3 kernel for snappy
> -description: This is a snapped kernel, based off the xenial raspi2 branch and config
> +name: pi2-kernel
> +version: null
> +version-script: |
> +    . debian/debian.env
> +    dpkg-parsechangelog -l $DEBIAN/changelog -S version
> +summary: The Canonical raspi2 Linux kernel
> +description: The Canonical raspi2 Linux kernel
> +grade: stable
> +confinement: strict
>  type: kernel
>  
>  parts:
> @@ -9,8 +14,44 @@ parts:
>      plugin: kernel
>      source: .
>      source-type: git
> -    kdefconfig: ['--makefile=debian/snapcraft.mk', 'branch=raspi2','flavour=raspi2', 'config']
> +    kconfigflavour: raspi2
>      kconfigs:
> -      - CONFIG_LOCALVERSION="-xenial_raspi2"
>        - CONFIG_DEBUG_INFO=n
>      kernel-image-target: zImage
> +    install: |
> +      tar -C $SNAPCRAFT_PART_INSTALL/dtbs -f $SNAPCRAFT_PART_INSTALL/dtbs/overlays.tgz -czv overlays
> +      rm -rf $SNAPCRAFT_PART_INSTALL/dtbs/overlays
> +  firmware:
> +    plugin: nil
> +    stage-packages:
> +      - linux-firmware
> +    organize:
> +      lib/firmware: firmware
> +    prime:
> +      - -usr
> +      - -lib
> +    install: |
> +      rm $SNAPCRAFT_PART_INSTALL/lib/firmware/brcm/brcmfmac43430-sdio.bin
> +    build-packages:
> +      - cpio
> +      - libssl-dev
> +  raspiwififw:
> +    plugin: nil
> +    source: .
> +    after:
> +      - firmware
> +    prepare: |
> +      PKGS="http://ppa.launchpad.net/snappy-dev/image/ubuntu/dists/xenial/main/binary-armhf/Packages.gz"
> +      PKGPATH="$(wget -q -O- $PKGS|zcat|grep-dctrl raspberrypi-wireless-firmware |\
> +        grep Filename|tail -1| sed 's/^Filename: //')"
> +      wget http://ppa.launchpad.net/snappy-dev/image/ubuntu/$PKGPATH
> +      dpkg -x $(basename $PKGPATH) unpack/
> +    install: |
> +      mkdir -p $SNAPCRAFT_PART_INSTALL/firmware/brcm
> +      mv unpack/usr/share/doc/raspberrypi-wireless-firmware $SNAPCRAFT_PART_INSTALL/firmware/rpi-wlanfw-licenses
> +      mv unpack/lib/firmware/brcm80211/brcm/* $SNAPCRAFT_PART_INSTALL/firmware/brcm
> +    build-packages:
> +      - coreutils
> +      - dctrl-tools
> +      - sed
> +      - wget
>
Kleber Souza Aug. 8, 2017, 7:40 a.m. | #3
Applied on xenial/raspi2 branch. Thanks.

Patch

diff --git a/snapcraft.yaml b/snapcraft.yaml
index e61207d..4581b9c 100644
--- a/snapcraft.yaml
+++ b/snapcraft.yaml
@@ -1,7 +1,12 @@ 
-name: ubuntu-raspi2-kernel
-version: 4.4.0
-summary: The Raspberry Pi 2/3 kernel for snappy
-description: This is a snapped kernel, based off the xenial raspi2 branch and config
+name: pi2-kernel
+version: null
+version-script: |
+    . debian/debian.env
+    dpkg-parsechangelog -l $DEBIAN/changelog -S version
+summary: The Canonical raspi2 Linux kernel
+description: The Canonical raspi2 Linux kernel
+grade: stable
+confinement: strict
 type: kernel
 
 parts:
@@ -9,8 +14,44 @@  parts:
     plugin: kernel
     source: .
     source-type: git
-    kdefconfig: ['--makefile=debian/snapcraft.mk', 'branch=raspi2','flavour=raspi2', 'config']
+    kconfigflavour: raspi2
     kconfigs:
-      - CONFIG_LOCALVERSION="-xenial_raspi2"
       - CONFIG_DEBUG_INFO=n
     kernel-image-target: zImage
+    install: |
+      tar -C $SNAPCRAFT_PART_INSTALL/dtbs -f $SNAPCRAFT_PART_INSTALL/dtbs/overlays.tgz -czv overlays
+      rm -rf $SNAPCRAFT_PART_INSTALL/dtbs/overlays
+  firmware:
+    plugin: nil
+    stage-packages:
+      - linux-firmware
+    organize:
+      lib/firmware: firmware
+    prime:
+      - -usr
+      - -lib
+    install: |
+      rm $SNAPCRAFT_PART_INSTALL/lib/firmware/brcm/brcmfmac43430-sdio.bin
+    build-packages:
+      - cpio
+      - libssl-dev
+  raspiwififw:
+    plugin: nil
+    source: .
+    after:
+      - firmware
+    prepare: |
+      PKGS="http://ppa.launchpad.net/snappy-dev/image/ubuntu/dists/xenial/main/binary-armhf/Packages.gz"
+      PKGPATH="$(wget -q -O- $PKGS|zcat|grep-dctrl raspberrypi-wireless-firmware |\
+        grep Filename|tail -1| sed 's/^Filename: //')"
+      wget http://ppa.launchpad.net/snappy-dev/image/ubuntu/$PKGPATH
+      dpkg -x $(basename $PKGPATH) unpack/
+    install: |
+      mkdir -p $SNAPCRAFT_PART_INSTALL/firmware/brcm
+      mv unpack/usr/share/doc/raspberrypi-wireless-firmware $SNAPCRAFT_PART_INSTALL/firmware/rpi-wlanfw-licenses
+      mv unpack/lib/firmware/brcm80211/brcm/* $SNAPCRAFT_PART_INSTALL/firmware/brcm
+    build-packages:
+      - coreutils
+      - dctrl-tools
+      - sed
+      - wget