From 5c8af029c7cc27c42f89291f7e62ec81f1f1c1c9 Mon Sep 17 00:00:00 2001 From: Simon Eisenmann Date: Mon, 9 Jan 2017 14:08:09 +0100 Subject: [PATCH] Build gadget snap with snapcraft This requires most recent snapcraft with support for hooks. https://github.com/snapcore/snapcraft/pull/1026 --- .gitignore | 6 ++--- snappy/README.md | 2 +- snappy/gadget.mk | 27 +++++++++---------- snappy/gadget/{meta/readme.md => README.md} | 0 snappy/gadget/{meta => }/gadget.yaml | 0 snappy/gadget/{ => prebuilt}/uboot.env.in | 0 snappy/gadget/{meta => setup/gui}/icon.png | 0 .../{meta => snap}/hooks/prepare-device | 0 .../gadget/{meta/snap.yaml => snapcraft.yaml} | 6 +++++ 9 files changed, 23 insertions(+), 18 deletions(-) rename snappy/gadget/{meta/readme.md => README.md} (100%) rename snappy/gadget/{meta => }/gadget.yaml (100%) rename snappy/gadget/{ => prebuilt}/uboot.env.in (100%) rename snappy/gadget/{meta => setup/gui}/icon.png (100%) rename snappy/gadget/{meta => snap}/hooks/prepare-device (100%) rename snappy/gadget/{meta/snap.yaml => snapcraft.yaml} (59%) diff --git a/.gitignore b/.gitignore index 28ca64fa..5dbad0d6 100644 --- a/.gitignore +++ b/.gitignore @@ -22,6 +22,6 @@ /snappy/*/stage /snappy/*/prime /snappy/*/parts -/snappy/gadget/uboot.env -/snappy/gadget/uboot.conf -/snappy/gadget/boot-assets +/snappy/gadget/prebuilt/uboot.env +/snappy/gadget/prebuilt/uboot.conf +/snappy/gadget/prebuilt/boot-assets diff --git a/snappy/README.md b/snappy/README.md index 8fa5606d..33911d4b 100644 --- a/snappy/README.md +++ b/snappy/README.md @@ -2,5 +2,5 @@ ## Build image ``` -UBUNTU_IMAGE_SKIP_COPY_UNVERIFIED_MODEL=1 ubuntu-image -c stable --image-size 2G --extra-snaps pine64_16.04-2_arm64.snap --extra-snaps kernel/pine64-kernel_3.10.104-2_arm64.snap -o test2.img pine64.model --debug +UBUNTU_IMAGE_SKIP_COPY_UNVERIFIED_MODEL=1 ubuntu-image -c stable --image-size 2G --extra-snaps gadget/pine64_16.04-3_arm64.snap --extra-snaps kernel/pine64-kernel_3.10.104-2_arm64.snap -o test4.img pine64.model --debug ``` diff --git a/snappy/gadget.mk b/snappy/gadget.mk index 430a93fe..59245485 100644 --- a/snappy/gadget.mk +++ b/snappy/gadget.mk @@ -3,31 +3,30 @@ include common.mk all: build clean: - rm -rf $(GADGET_DIR)/boot-assets - rm -f $(GADGET_DIR)/uboot.conf - rm -f $(GADGET_DIR)/uboot.env - rm -f $(GADGET_SNAP) + rm -rf $(GADGET_DIR)/prebuilt/boot-assets + rm -f $(GADGET_DIR)/prebuilt/uboot.conf + rm -f $(GADGET_DIR)/prebuilt/uboot.env + cd gadget; snapcraft clean distclean: clean u-boot: - @if [ ! -d $(GADGET_DIR)/boot-assets ] ; then mkdir -p $(GADGET_DIR)/boot-assets; fi + @if [ ! -d $(GADGET_DIR)/prebuilt/boot-assets ] ; then mkdir -p $(GADGET_DIR)/prebuilt/boot-assets; fi @if [ ! -f $(UBOOT_BIN) ]; then echo "Build u-boot first."; exit 1; fi - cp -fa $(UBOOT_BIN) $(GADGET_DIR)/boot-assets/u-boot-with-dtb.bin + cp -fa $(UBOOT_BIN) $(GADGET_DIR)/prebuilt/boot-assets/u-boot-with-dtb.bin dtbs: - @if [ ! -d $(GADGET_DIR)/boot-assets/dtbs ] ; then mkdir -p $(GADGET_DIR)/boot-assets/dtbs; fi - dtc -Odtb -o $(GADGET_DIR)/boot-assets/dtbs/sun50i-a64-pine64-plus.dtb $(BLOBS_DIR)/pine64.dts - dtc -Odtb -o $(GADGET_DIR)/boot-assets/dtbs/sun50i-a64-pine64.dtb $(BLOBS_DIR)/pine64noplus.dts - dtc -Odtb -o $(GADGET_DIR)/boot-assets/dtbs/sun50i-a64-pine64so.dtb $(BLOBS_DIR)/pine64so.dts + @if [ ! -d $(GADGET_DIR)/prebuilt/boot-assets/dtbs ] ; then mkdir -p $(GADGET_DIR)/prebuilt/boot-assets/dtbs; fi + dtc -Odtb -o $(GADGET_DIR)/prebuilt/boot-assets/dtbs/sun50i-a64-pine64-plus.dtb $(BLOBS_DIR)/pine64.dts + dtc -Odtb -o $(GADGET_DIR)/prebuilt/boot-assets/dtbs/sun50i-a64-pine64.dtb $(BLOBS_DIR)/pine64noplus.dts + dtc -Odtb -o $(GADGET_DIR)/prebuilt/boot-assets/dtbs/sun50i-a64-pine64so.dtb $(BLOBS_DIR)/pine64so.dts preload: u-boot dtbs - cp -fa $(BLOBS_DIR)/boot0.bin $(GADGET_DIR)/boot-assets/boot0.bin - mkenvimage -r -s 131072 -o $(GADGET_DIR)/uboot.env $(GADGET_DIR)/uboot.env.in - @if [ ! -f $(GADGET_DIR)/uboot.conf ]; then ln -s uboot.env $(GADGET_DIR)/uboot.conf; fi + cp -fa $(BLOBS_DIR)/boot0.bin $(GADGET_DIR)/prebuilt/boot-assets/boot0.bin + mkenvimage -r -s 131072 -o $(GADGET_DIR)/prebuilt/uboot.env $(GADGET_DIR)/prebuilt/uboot.env.in snappy: preload - snapcraft snap gadget + cd gadget; snapcraft --target-arch amd64 snap build: dtbs preload snappy diff --git a/snappy/gadget/meta/readme.md b/snappy/gadget/README.md similarity index 100% rename from snappy/gadget/meta/readme.md rename to snappy/gadget/README.md diff --git a/snappy/gadget/meta/gadget.yaml b/snappy/gadget/gadget.yaml similarity index 100% rename from snappy/gadget/meta/gadget.yaml rename to snappy/gadget/gadget.yaml diff --git a/snappy/gadget/uboot.env.in b/snappy/gadget/prebuilt/uboot.env.in similarity index 100% rename from snappy/gadget/uboot.env.in rename to snappy/gadget/prebuilt/uboot.env.in diff --git a/snappy/gadget/meta/icon.png b/snappy/gadget/setup/gui/icon.png similarity index 100% rename from snappy/gadget/meta/icon.png rename to snappy/gadget/setup/gui/icon.png diff --git a/snappy/gadget/meta/hooks/prepare-device b/snappy/gadget/snap/hooks/prepare-device similarity index 100% rename from snappy/gadget/meta/hooks/prepare-device rename to snappy/gadget/snap/hooks/prepare-device diff --git a/snappy/gadget/meta/snap.yaml b/snappy/gadget/snapcraft.yaml similarity index 59% rename from snappy/gadget/meta/snap.yaml rename to snappy/gadget/snapcraft.yaml index fc400ea4..163842f8 100644 --- a/snappy/gadget/meta/snap.yaml +++ b/snappy/gadget/snapcraft.yaml @@ -6,3 +6,9 @@ description: | type: gadget architectures: - arm64 +confinement: strict +grade: stable +parts: + prebuilt: + plugin: dump + source: prebuilt