Following in footsteps of other targets like 'deb-pkg, 'rpm-pkg' and 'tar-pkg',
this patch adds a 'snap-pkg' target for the creation of a Linux kernel snap
package using the kbuild infrastructure.
A snap, in its general form, is a self contained, sandboxed, universal package
and it is intended to work across multiple distributions and/or devices. A snap
package is distributed as a single compressed squashfs filesystem.
A kernel snap is a snap package carrying the Linux kernel, kernel modules,
accessory files (DTBs, System.map, etc) and a manifesto file. The purpose of a
kernel snap is to carry the Linux kernel during the creation of a system image,
eg. Ubuntu Core, and it's subsequent upgrades.
For more information on snap packages: https://snapcraft.io/docs/
Signed-off-by: Paolo Pisati <[email protected]>
---
.gitignore | 5 +++++
scripts/package/Makefile | 14 ++++++++++++++
scripts/package/snapcraft.template | 14 ++++++++++++++
3 files changed, 33 insertions(+)
create mode 100644 scripts/package/snapcraft.template
diff --git a/.gitignore b/.gitignore
index 0c39aa2..638c492 100644
--- a/.gitignore
+++ b/.gitignore
@@ -59,6 +59,11 @@ Module.symvers
/debian/
#
+# Snap directory (make snap-pkg)
+#
+/snap/
+
+#
# tar directory (make tar*-pkg)
#
/tar-install/
diff --git a/scripts/package/Makefile b/scripts/package/Makefile
index 71b4a8a..a7ea67c 100644
--- a/scripts/package/Makefile
+++ b/scripts/package/Makefile
@@ -99,6 +99,19 @@ bindeb-pkg: FORCE
clean-dirs += $(objtree)/debian/
+# snap-pkg
+# ---------------------------------------------------------------------------
+snap-pkg: FORCE
+ rm -rf $(objtree)/snap
+ mkdir $(objtree)/snap
+ sed "s@KERNELRELEASE@$(KERNELRELEASE)@; \
+ s@SRCTREE@$(shell realpath $(srctree))@" \
+ $(srctree)/scripts/package/snapcraft.template > \
+ $(objtree)/snap/snapcraft.yaml
+ cd $(objtree)/snap && \
+ snapcraft --target-arch=$(UTS_MACHINE)
+
+clean-dirs += $(objtree)/snap/
# tarball targets
# ---------------------------------------------------------------------------
@@ -143,6 +156,7 @@ help: FORCE
@echo ' binrpm-pkg - Build only the binary kernel RPM package'
@echo ' deb-pkg - Build both source and binary deb kernel packages'
@echo ' bindeb-pkg - Build only the binary kernel deb package'
+ @echo ' snap-pkg - Build only the binary kernel snap package'
@echo ' tar-pkg - Build the kernel as an uncompressed tarball'
@echo ' targz-pkg - Build the kernel as a gzip compressed tarball'
@echo ' tarbz2-pkg - Build the kernel as a bzip2 compressed tarball'
diff --git a/scripts/package/snapcraft.template b/scripts/package/snapcraft.template
new file mode 100644
index 0000000..2e7ffc8
--- /dev/null
+++ b/scripts/package/snapcraft.template
@@ -0,0 +1,14 @@
+name: kernel
+version: KERNELRELEASE
+summary: Linux kernel
+description: The upstream Linux kernel
+grade: stable
+confinement: strict
+type: kernel
+
+parts:
+ kernel:
+ plugin: kernel
+ source: SRCTREE
+ source-type: git
+ kconfigfile: SRCTREE/.config
--
2.7.4
On Mon, Jul 10, 2017 at 7:59 AM, Paolo Pisati
<[email protected]> wrote:
> eg. Ubuntu Core, and it's subsequent upgrades.
its
>
> For more information on snap packages: https://snapcraft.io/docs/
Is this something a user could do with the existing deb target, and
then running deb2snap?
--
Jim
On Mon, Jul 10, 2017 at 6:46 PM, Jim Davis <[email protected]> wrote:
>>
>> For more information on snap packages: https://snapcraft.io/docs/
>
> Is this something a user could do with the existing deb target, and
> then running deb2snap?
No, the kernel snap is a special case, it requires communication with
the store (e.g. to download the core snap) and some extra steps,
therefore you should use snapcraft and abstract from these details.
--
bye,
p.
On Mon, Jul 10, 2017 at 11:13 PM, Paolo Pisati
<[email protected]> wrote:
> On Mon, Jul 10, 2017 at 6:46 PM, Jim Davis <[email protected]> wrote:
>>>
>>> For more information on snap packages: https://snapcraft.io/docs/
>>
>> Is this something a user could do with the existing deb target, and
>> then running deb2snap?
>
> No, the kernel snap is a special case, it requires communication with
> the store (e.g. to download the core snap) and some extra steps,
> therefore you should use snapcraft and abstract from these details.
>From a quick check on top of 4.13-rc1 it does what it says, but...
building a snap like this, unless I'm missing something, is quite
different from building a kernel deb or rpm or tar package.
Once I fed the snap into ubuntu-image, after hunting down a plausible
model file, I did get an image file that booted under qemu. I guess
if you're in the know about snap (and I don't include myself in that
august company) you'd know that the snap-pkg target won't directly
give you something you can boot, but the "make help" output looks so
similar to the other conventional build targets that the some might
miss that point.
The snap-informed would also know that the snap-pkg target would
download stuff from the internet as part of the build process, but
that's unusual enough in kernel building that another recent build
target, linkcheckdocs, included "(will connect to external hosts)" as
part of its "make help" output. That probably would be a good idea
for the snap-pkg target too.
Running snap-pkg twice in a row seems to have rebuilt the entire
kernel source, unlike the other more conventional build targets.
--
Jim
On 10 July 2017 at 17:59, Paolo Pisati <[email protected]> wrote:
> Following in footsteps of other targets like 'deb-pkg, 'rpm-pkg' and 'tar-pkg',
> this patch adds a 'snap-pkg' target for the creation of a Linux kernel snap
> package using the kbuild infrastructure.
>
> A snap, in its general form, is a self contained, sandboxed, universal package
> and it is intended to work across multiple distributions and/or devices. A snap
> package is distributed as a single compressed squashfs filesystem.
>
> A kernel snap is a snap package carrying the Linux kernel, kernel modules,
> accessory files (DTBs, System.map, etc) and a manifesto file. The purpose of a
> kernel snap is to carry the Linux kernel during the creation of a system image,
> eg. Ubuntu Core, and it's subsequent upgrades.
>
> For more information on snap packages: https://snapcraft.io/docs/
>
> Signed-off-by: Paolo Pisati <[email protected]>
> ---
> .gitignore | 5 +++++
> scripts/package/Makefile | 14 ++++++++++++++
> scripts/package/snapcraft.template | 14 ++++++++++++++
> 3 files changed, 33 insertions(+)
> create mode 100644 scripts/package/snapcraft.template
>
> diff --git a/.gitignore b/.gitignore
> index 0c39aa2..638c492 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -59,6 +59,11 @@ Module.symvers
> /debian/
>
> #
> +# Snap directory (make snap-pkg)
> +#
> +/snap/
> +
> +#
> # tar directory (make tar*-pkg)
> #
> /tar-install/
> diff --git a/scripts/package/Makefile b/scripts/package/Makefile
> index 71b4a8a..a7ea67c 100644
> --- a/scripts/package/Makefile
> +++ b/scripts/package/Makefile
> @@ -99,6 +99,19 @@ bindeb-pkg: FORCE
>
> clean-dirs += $(objtree)/debian/
>
> +# snap-pkg
> +# ---------------------------------------------------------------------------
> +snap-pkg: FORCE
> + rm -rf $(objtree)/snap
> + mkdir $(objtree)/snap
> + sed "s@KERNELRELEASE@$(KERNELRELEASE)@; \
> + s@SRCTREE@$(shell realpath $(srctree))@" \
> + $(srctree)/scripts/package/snapcraft.template > \
> + $(objtree)/snap/snapcraft.yaml
> + cd $(objtree)/snap && \
> + snapcraft --target-arch=$(UTS_MACHINE)
> +
> +clean-dirs += $(objtree)/snap/
>
> # tarball targets
> # ---------------------------------------------------------------------------
> @@ -143,6 +156,7 @@ help: FORCE
> @echo ' binrpm-pkg - Build only the binary kernel RPM package'
> @echo ' deb-pkg - Build both source and binary deb kernel packages'
> @echo ' bindeb-pkg - Build only the binary kernel deb package'
> + @echo ' snap-pkg - Build only the binary kernel snap package'
> @echo ' tar-pkg - Build the kernel as an uncompressed tarball'
> @echo ' targz-pkg - Build the kernel as a gzip compressed tarball'
> @echo ' tarbz2-pkg - Build the kernel as a bzip2 compressed tarball'
> diff --git a/scripts/package/snapcraft.template b/scripts/package/snapcraft.template
> new file mode 100644
> index 0000000..2e7ffc8
> --- /dev/null
> +++ b/scripts/package/snapcraft.template
> @@ -0,0 +1,14 @@
> +name: kernel
> +version: KERNELRELEASE
> +summary: Linux kernel
> +description: The upstream Linux kernel
> +grade: stable
> +confinement: strict
> +type: kernel
> +
> +parts:
> + kernel:
> + plugin: kernel
> + source: SRCTREE
> + source-type: git
> + kconfigfile: SRCTREE/.config
As we see from the above lines, the snapcraft command already has lots
of special code for handling kernels. I think would make more sense to
add support building a kernel source tree into the snapcraft command
itself. Most importantly that would work with older kernel trees,
while this patch above will only work from v4.14+
Maybe add a parameter like "snapcraft --kernel" in current kernel
sourcetree. Or ship a "snapcraft-kernel" command in snapcraft package.
Riku
Apologise for the late reply.
On Wed, Jul 19, 2017 at 2:02 AM, Jim Davis <[email protected]> wrote:
>
> Once I fed the snap into ubuntu-image, after hunting down a plausible
> model file, I did get an image file that booted under qemu. I guess
> if you're in the know about snap (and I don't include myself in that
> august company) you'd know that the snap-pkg target won't directly
> give you something you can boot, but the "make help" output looks so
> similar to the other conventional build targets that the some might
> miss that point.
Well, snap-pkg gives you a kernel that you can use in an ubuntu-core
image (either when building an entire image from scratch, or you can
install it in a preinstalled system), much like deb-pkg or rpm-pkg
targets give you a kernel that you can use in a deb / rpm based
system, i don't see any semantics difference here.
> The snap-informed would also know that the snap-pkg target would
> download stuff from the internet as part of the build process, but
> that's unusual enough in kernel building that another recent build
> target, linkcheckdocs, included "(will connect to external hosts)" as
> part of its "make help" output. That probably would be a good idea
> for the snap-pkg target too.
Ack.
> Running snap-pkg twice in a row seems to have rebuilt the entire
> kernel source, unlike the other more conventional build targets.
The deb-pkg and rpm-pkg targets rebuild from scratch too if invoked in a row.
--
bye,
p.