From 3c1289e00c60293324eb8811ddf94c186828b076 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 18 Aug 2021 21:15:48 +0200 Subject: [PATCH] vendor.c: new vendor.c subdir The `go.mod` system has no support to checkout non-go code anymore. So in order to vendor the squashfuse code we need to come up with a simple vendoring system ourself it seems. This will unblock the move to `go.mod` further. --- .github/workflows/test.yaml | 3 ++ .gitignore | 1 + get-deps.sh | 2 ++ ...0006-systemd-disable-snapfuse-system.patch | 31 ------------------- packaging/debian-sid/patches/series | 1 - packaging/fedora/snapd.spec | 3 -- packaging/ubuntu-16.04/rules | 4 +-- packaging/ubuntu-16.04/snapd.install | 2 +- systemd/systemd.go | 2 -- tests/lib/prepare-restore.sh | 8 +++++ vendor.c/README | 2 ++ vendor.c/vendor.sh | 14 +++++++++ vendor/vendor.json | 7 ----- 13 files changed, 33 insertions(+), 47 deletions(-) delete mode 100644 packaging/debian-sid/patches/0006-systemd-disable-snapfuse-system.patch create mode 100644 vendor.c/README create mode 100755 vendor.c/vendor.sh diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index d7bf72e7252..c0c7a04f585 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -145,6 +145,9 @@ jobs: - name: Get Go dependencies run: cd ${{ github.workspace }}/src/github.com/snapcore/snapd && ${{ github.workspace }}/bin/govendor sync + - name: Get C vnedoring + run: cd ${{ github.workspace }}/src/github.com/snapcore/snapd/vendor.c && ./vendor.sh + - name: golangci-lint uses: golangci/golangci-lint-action@v2 if: ${{ matrix.gochannel == 'latest/stable' }} diff --git a/.gitignore b/.gitignore index 29007f65d05..964528f41ee 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ cmd/VERSION .vscode/ .idea/ vendor/*/ +vendor.c/*/ .spread-reuse*.yaml po/snappy.pot diff --git a/get-deps.sh b/get-deps.sh index d9f1ad58081..aa0efaa93b0 100755 --- a/get-deps.sh +++ b/get-deps.sh @@ -25,6 +25,8 @@ fi echo Obtaining dependencies govendor sync +echo Obtaining c-dependencies +(cd vendor.c && ./vendor.sh) if [ "$1" != "--skip-unused-check" ]; then unused="$(govendor list +unused)" diff --git a/packaging/debian-sid/patches/0006-systemd-disable-snapfuse-system.patch b/packaging/debian-sid/patches/0006-systemd-disable-snapfuse-system.patch deleted file mode 100644 index c778f1a4ecc..00000000000 --- a/packaging/debian-sid/patches/0006-systemd-disable-snapfuse-system.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 49cfcd5201beb6ffb454abd68b7d31d8b2b243da Mon Sep 17 00:00:00 2001 -From: Zygmunt Krynicki -Date: Thu, 17 Jan 2019 15:51:14 +0200 -Subject: [PATCH 6/9] systemd: disable snapfuse system - -Upstream snapd uses an elaborate hack to bundle squashfuse under the -name snapfuse, and built as a fake go package. This component is not -available in Debian where bundling elements is not allowed. - -Signed-off-by: Zygmunt Krynicki -Signed-off-by: Maciej Borzecki ---- - systemd/systemd.go | 2 -- - 1 file changed, 2 deletions(-) - -diff --git a/systemd/systemd.go b/systemd/systemd.go -index b433bdda4d2a07ded262fd645a4ef41a1444102c..29365b046e24c5042c48b68b8468fc5d4c93978f 100644 ---- a/systemd/systemd.go -+++ b/systemd/systemd.go -@@ -36,8 +36,6 @@ import ( - "sync/atomic" - "time" - -- _ "github.com/snapcore/squashfuse" -- - "github.com/snapcore/snapd/dirs" - "github.com/snapcore/snapd/gadget/quantity" - "github.com/snapcore/snapd/osutil" --- -2.31.1 - diff --git a/packaging/debian-sid/patches/series b/packaging/debian-sid/patches/series index 25176ed893a..2f3c5da3b0e 100644 --- a/packaging/debian-sid/patches/series +++ b/packaging/debian-sid/patches/series @@ -3,6 +3,5 @@ 0003-cmd-snap-seccomp-skip-tests-that-use-m32.patch 0004-cmd-snap-skip-tests-depending-on-text-wrapping.patch 0005-advisor-errtracker-use-upstream-bolt-package.patch -0006-systemd-disable-snapfuse-system.patch 0007-i18n-use-dummy-localizations-to-avoid-dependencies.patch 0010-man-page-sections.patch diff --git a/packaging/fedora/snapd.spec b/packaging/fedora/snapd.spec index 5ad91dd0ca4..728893a497e 100644 --- a/packaging/fedora/snapd.spec +++ b/packaging/fedora/snapd.spec @@ -509,9 +509,6 @@ rm -rf vendor/* # Generate version files ./mkversion.sh "%{version}-%{release}" -# We don't want/need squashfuse in the rpm, as it's available in Fedora and EPEL -sed -e 's:_ "github.com/snapcore/squashfuse"::g' -i systemd/systemd.go - # Build snapd mkdir -p src/github.com/snapcore ln -s ../../../ src/github.com/snapcore/snapd diff --git a/packaging/ubuntu-16.04/rules b/packaging/ubuntu-16.04/rules index 173d5f2172f..af36530c9d2 100755 --- a/packaging/ubuntu-16.04/rules +++ b/packaging/ubuntu-16.04/rules @@ -163,7 +163,7 @@ endif # XXX: hacky $(MAKE) -C cmd distclean || true # XXX: hacky^2 - (cd vendor/github.com/snapcore/squashfuse/src && rm -f snapfuse && make distclean || true ) + (cd vendor.c/squashfuse/src && rm -f snapfuse && make distclean || true ) override_dh_auto_build: # usually done via `go generate` but that is not supported on powerpc @@ -211,7 +211,7 @@ endif $(MAKE) -C data all # build squashfuse and rename to snapfuse - (cd vendor/github.com/snapcore/squashfuse/src && mkdir -p autom4te.cache && ./autogen.sh --disable-demo && ./configure --disable-demo && make && mv squashfuse_ll snapfuse) + (cd vendor.c/squashfuse/src && mkdir -p autom4te.cache && ./autogen.sh --disable-demo && ./configure --disable-demo && make && mv squashfuse_ll snapfuse) override_dh_auto_test: dh_auto_test -- $(BUILDFLAGS) $(TAGS) $(GCCGOFLAGS) diff --git a/packaging/ubuntu-16.04/snapd.install b/packaging/ubuntu-16.04/snapd.install index edf58ceeafa..8f4e7905a8f 100644 --- a/packaging/ubuntu-16.04/snapd.install +++ b/packaging/ubuntu-16.04/snapd.install @@ -42,7 +42,7 @@ usr/lib/snapd/snap-gdb-shim usr/lib/snapd/snap-gdbserver-shim # install squashfuse as snapfuse to ensure it is available in e.g. lxd -vendor/github.com/snapcore/squashfuse/src/snapfuse usr/bin +vendor.c/squashfuse/src/snapfuse usr/bin # use "usr/lib" here because apparently systemd looks only there usr/lib/systemd/system-environment-generators diff --git a/systemd/systemd.go b/systemd/systemd.go index a5dbb3f6970..568e1481ca6 100644 --- a/systemd/systemd.go +++ b/systemd/systemd.go @@ -36,8 +36,6 @@ import ( "sync/atomic" "time" - _ "github.com/snapcore/squashfuse" - "github.com/snapcore/snapd/dirs" "github.com/snapcore/snapd/gadget/quantity" "github.com/snapcore/snapd/osutil" diff --git a/tests/lib/prepare-restore.sh b/tests/lib/prepare-restore.sh index da95b247f7f..66078aca69f 100755 --- a/tests/lib/prepare-restore.sh +++ b/tests/lib/prepare-restore.sh @@ -531,6 +531,14 @@ prepare_project() { fi sleep 1 done + # Update C dependencies + for _ in $(seq 10); do + if (cd vendor.c && ./vendor.sh); then + break + fi + sleep 1 + done + # govendor runs as root and will leave strange permissions chown test.test -R "$SPREAD_PATH" diff --git a/vendor.c/README b/vendor.c/README new file mode 100644 index 00000000000..bb7cab7c7c5 --- /dev/null +++ b/vendor.c/README @@ -0,0 +1,2 @@ +This directory contains the vendored C code - with `go mod` it is +not possible to vendor non-go directories anymore. \ No newline at end of file diff --git a/vendor.c/vendor.sh b/vendor.c/vendor.sh new file mode 100755 index 00000000000..fd771ec5d9c --- /dev/null +++ b/vendor.c/vendor.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +set -e + +# XXX: provide a nice declarative format +# XXX2: reuse vendor.json and write some python3 code? +if [ ! -d ./squashfuse ]; then + git clone https://github.com/snapcore/squashfuse +fi +(cd squashfuse && git checkout 319f6d41a0419465a55d9dcb848d2408b97764f9) + + +# XXX: also checkout squashfuse3 and build with that depending on +# host env diff --git a/vendor/vendor.json b/vendor/vendor.json index 0bd52451b81..643c53add43 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -171,13 +171,6 @@ "revision": "785f3aec664fcad504befe8b59b55949b6e68dc6", "revisionTime": "2021-04-20T15:53:42Z" }, - { - "checksumSHA1": "3AmEm18mKj8XxBuru/ix4OOpRkE=", - "path": "github.com/snapcore/squashfuse", - "revision": "319f6d41a0419465a55d9dcb848d2408b97764f9", - "revisionTime": "2017-12-20T16:53:23Z", - "tree": true - }, { "checksumSHA1": "/mphxOFx5uIoQCnt6YtFmmPDBao=", "path": "go.mozilla.org/pkcs7",