[lxc-devel] [lxd-pkg-snap/latest-edge] Avoid implicit "." `source` dir in legacy Snapcraft

Lin-Buo-Ren on Github lxc-bot at linuxcontainers.org
Fri Dec 21 16:28:16 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 922 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20181221/7ab90c61/attachment.bin>
-------------- next part --------------
From 2f1b222fc6442e7e68493775a7d8d8e2fd31a320 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9E=97=E5=8D=9A=E4=BB=81=28Buo-ren=2C=20Lin=29?=
 <Buo.Ren.Lin at gmail.com>
Date: Fri, 21 Dec 2018 23:20:59 +0800
Subject: [PATCH] Avoid implicit "." `source` dir in legacy Snapcraft
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

There is a default behavior of legacy 2.x Snapcraft which sets an
implicit "." `source` directory for parts without the `source` key.
This prevents parts that uses the `nil` plugin be considered "changed"
whenever a file under "." directory is modified.

This patch sets a fake source directory to all parts without the
`source` key to workaround the issue.

Refer the following snapcraft forum topic for more info:

    Snapcraft implicit source - snapcraft - snapcraft.io
    https://forum.snapcraft.io/t/snapcraft-implicit-source/7060

Signed-off-by: ๆž—ๅšไป(Buo-ren, Lin) <Buo.Ren.Lin at gmail.com>
---
 snapcraft.yaml         | 8 ++++++++
 snapcraft/empty/README | 6 ++++++
 2 files changed, 14 insertions(+)
 create mode 100644 snapcraft/empty/README

diff --git a/snapcraft.yaml b/snapcraft.yaml
index a4c827b..d171d8f 100644
--- a/snapcraft.yaml
+++ b/snapcraft.yaml
@@ -91,6 +91,7 @@ hooks:
 parts:
   # Dependencies
   btrfs:
+    source: snapcraft/empty
     plugin: nil
     stage-packages:
       - btrfs-tools
@@ -100,6 +101,7 @@ parts:
       - bin/mkfs.btrfs
 
   ceph:
+    source: snapcraft/empty
     plugin: nil
     stage-packages:
       - ceph-common
@@ -139,6 +141,7 @@ parts:
     source-tag: go1.11.2
 
   lvm:
+    source: snapcraft/empty
     plugin: nil
     stage-packages:
       - dmeventd
@@ -170,6 +173,7 @@ parts:
       - lib/*/libreadline.so*
 
   nano:
+    source: snapcraft/empty
     plugin: nil
     stage-packages:
       - nano
@@ -210,6 +214,7 @@ parts:
       - lib/libnvidia-container.so*
 
   openvswitch:
+    source: snapcraft/empty
     plugin: nil
     stage-packages:
       - openvswitch-switch
@@ -267,6 +272,7 @@ parts:
       - lib/*/libuv*
 
   vim:
+    source: snapcraft/empty
     plugin: nil
     stage-packages:
       - vim-tiny
@@ -278,6 +284,7 @@ parts:
       - etc/vimrc
 
   xfs:
+    source: snapcraft/empty
     plugin: nil
     stage-packages:
       - xfsprogs
@@ -628,6 +635,7 @@ parts:
       - bin/snap-query
 
   strip:
+    source: snapcraft/empty
     after:
       - btrfs
       - ceph
diff --git a/snapcraft/empty/README b/snapcraft/empty/README
new file mode 100644
index 0000000..11d6413
--- /dev/null
+++ b/snapcraft/empty/README
@@ -0,0 +1,6 @@
+This is a fake source directory to avoid the default behavior of legacy 2.x Snapcraft which sets an implicit "." `source` directory for parts without the `source` key.  This prevents parts that uses the `nil` plugin be considered "changed" whenever a file under "." directory is modified.
+
+Refer the following snapcraft forum topic for more info about this issue:
+
+    Snapcraft implicit source - snapcraft - snapcraft.io
+    https://forum.snapcraft.io/t/snapcraft-implicit-source/7060


More information about the lxc-devel mailing list