This package is vendoring all the Go dependencies for reasons explained in LP: #1896246

To update the debian/extra/vendor/ dir run:

rm -r debian/extra/vendor
go mod download
go mod vendor
mv vendor debian/extra/

Update debian/copyright, for example using decopy.

 -- Balint Reczey <rbalint@ubuntu.com>, Fri, 18 Sep 2020 17:19:27 +0200

### 2026
------------------------------------

This source package now builds from two repos:

  1. guest-agent (https://github.com/GoogleCloudPlatform/guest-agent) built from these golang packages:
     - github.com/GoogleCloudPlatform/guest-agent/google_guest_agent
     - github.com/GoogleCloudPlatform/guest-agent/google_metadata_script_runner
     - github.com/GoogleCloudPlatform/guest-agent/gce_workload_cert_refresh

  2) google-guest-agent (NEW add on/plugin manager, https://github.com/GoogleCloudPlatform/google-guest-agent)
     This repo provides additional binaries and plugins:
       - google_guest_agent_manager
       - google_guest_compat_manager
       - gce_metadata_script_runner
       - gce_compat_metadata_script_runner
       - ggactl_plugin_cleanup (from /cmd/ggactl)
       - core_plugin (under /usr/lib/google/guest_agent/core_plugin)

Why are we bundling the second repo?
------------------------------------
The guest-agent repository references the google-guest-agent repository
for its `plugin manager` functionality, so we need to vendor the second repo
into the source package (rather than allowing it to be fetched during pkg build)

Bundled upstream source using multiple tarballs
------------------------------------------------
We ship the new `google-guest-agent` repository as an extra tarball:

  google-guest-agent_${UPSTREAM_TAG}.orig-google-guest-agent.tar.xz

and when unpacked from the `.dsc`, `dpkg-source` extracts this to `./google-guest-agent`, which
keeps the full add on source outside of `debian/` (i.e. it's treated as an upstream
source and not a patch).

Pinned revision
---------------
The vendored `google-guest-agent` repository is currently pinned to a specific `git commit`
hash for reproducibility. This hash will likely need to change every time there is a package
update to `guest-agent` for Ubuntu. That entails regenerating the secondary orig tarball and
vendored dependencies (please see below).

Two vendored Golang dependency trees
-------------------------------------------
Both repos are built using vendored Go dependencies:

  - Main/original repo vendor tree:
      debian/extra/vendor/
    (copied into ./vendor/ during override_dh_auto_configure)

  - Add on/new repo vendor tree:
      debian/extra/vendor-google-guest-agent/vendor/
    (copied into ./google-guest-agent/vendor/ during override_dh_auto_configure)

N.B. The add on vendor tree *must* be copied as a vendor directory and not nested. If you end
up with .../vendor/vendor/modules.txt, golang will complain about “inconsistent vendoring”.

Binary blobs in vendor trees
----------------------------
Golang’s `protobuf` edition defaults include this binary file:
  `.../vendor/google.golang.org/protobuf/internal/editiondefaults/editions_defaults.binpb`

but `dpkg-source` rejects binary files in debian.tar.* unless *explicitly* allowed. The allowed-list
is `debian/source/include-binaries`.

Toolchain selection && avoiding downloads
----------------------------------------------------
google-guest-agent’s go.mod (currently) specifies both:
  - go 1.24.0
  - toolchain go1.24.4

Newer golang versions will try to select and download a toolchain automatically, but we cannot do that
during build, so in `debian/rules` we set:

  GOTOOLCHAIN=local

which forces use of the local toolchain provided by the environment.

How to update the vendored google-guest-agent snapshot
------------------------------------------------------

1. Check out the desired hash or tag:
     git clone https://github.com/GoogleCloudPlatform/google-guest-agent
     cd google-guest-agent
     git checkout ${GIT_HASH_OR_TAG}

2) Run `make cmd/core_plugin/core_plugin` to generate the protobufs

3) Regenerate the vendored deps using:
     export GOTOOLCHAIN=local
     /usr/lib/go-${GOLANG_VERSION}/bin/go mod download
     /usr/lib/go-${GOLANG_VERSION}/bin/go mod vendor

4) Copy the vendored tree into the "actual" packaging repo here:
     cp -r vendor/ ${HERE}/debian/extra/vendor-google-guest-agent/vendor/

5) Create the new additional orig tarball

   The tarball should contain the generated *.pb.go outputs. It should *not*
   contain the vendor dir (as the vendor dir is shipped separately here in debian/extra/)
   or .git, proto_deps/ etc.

```
UPSTREAM_TAG=xyz # (upstream tag Google wants us to pull `guest-agent` from)
# Clean out things we don't want in the tarball
rm -rfv .git proto_deps vendor

# Create the new orig tarball
tar -cJf "../google-guest-agent_${UPSTREAM_TAG}.orig-google-guest-agent.tar.xz" .
```
