Skip to content

Commit

Permalink
vendor.c: new vendor.c subdir
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mvo5 committed Aug 18, 2021
1 parent ce84425 commit 3c1289e
Show file tree
Hide file tree
Showing 13 changed files with 33 additions and 47 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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' }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ cmd/VERSION
.vscode/
.idea/
vendor/*/
vendor.c/*/
.spread-reuse*.yaml
po/snappy.pot

Expand Down
2 changes: 2 additions & 0 deletions get-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion packaging/debian-sid/patches/series
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 0 additions & 3 deletions packaging/fedora/snapd.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions packaging/ubuntu-16.04/rules
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion packaging/ubuntu-16.04/snapd.install
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions systemd/systemd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 8 additions & 0 deletions tests/lib/prepare-restore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 2 additions & 0 deletions vendor.c/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This directory contains the vendored C code - with `go mod` it is
not possible to vendor non-go directories anymore.
14 changes: 14 additions & 0 deletions vendor.c/vendor.sh
Original file line number Diff line number Diff line change
@@ -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
7 changes: 0 additions & 7 deletions vendor/vendor.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 3c1289e

Please sign in to comment.