Skip to content

Latest commit

 

History

History
88 lines (79 loc) · 2.35 KB

README.md

File metadata and controls

88 lines (79 loc) · 2.35 KB

Flatpak Go Get Generator

Tool to automatically create the source list for a Go module (legacy).

It runs the build in a legacy GOPATH mode. For a module-aware mode, see go-modules or flatpak-go-vendor-generator script.

The script does not require Go in the host system.

Usage

  1. In the manifest, give the Go module network access and set GOPATH to $PWD.

Example manifest module (json):

{
  "name": "writeas-cli",
  "buildsystem": "simple",
  "build-options": {
    "env": {
      "GOBIN": "/app/bin/"
    },
    "build-args": [
      "--share=network"
    ]
  },
  "build-commands": [
    ". /usr/lib/sdk/golang/enable.sh; export GOPATH=$PWD; go get github.com/writeas/writeas-cli/cmd/writeas"
  ]
}

Example manifest (yaml):

app-id: writeas-cli
runtime: org.freedesktop.Platform
runtime-version: '21.08'
sdk: org.freedesktop.Sdk
sdk-extensions:
  - org.freedesktop.Sdk.Extension.golang
command: echo "Done"
modules:
  - name: writeas
    buildsystem: simple
    build-options:
      append-path: /usr/lib/sdk/golang/bin
      env:
        GOBIN: /app/bin
        GO111MODULE: off
        GOPATH: /run/build/writeas
      build-args:
        - --share=network
    build-commands:
      - go get github.com/writeas/writeas-cli/cmd/writeas
  1. Run flatpak-builder with --keep-build-dirs.
  2. Run go-get/flatpak-go-get-generator.py <build-dir> with build-dir pointing the the build directory in .flatpak-builder/build.
  3. Convert the source list to YAML if necessary.
  4. Add the list to the sources field of the Go module in the manifest.
  5. Change build command from go get to go install.
  6. Remove network access.

The script assumes the networked built was run with GOPATH=$PWD.

Example final module

{
      "name": "writeas-cli",
      "buildsystem": "simple",
      "build-options": {
        "env": {
          "GOBIN": "/app/bin/"
        }
      },
      "build-commands": [
        ". /usr/lib/sdk/golang/enable.sh; export GOPATH=$PWD; go install github.com/writeas/writeas-cli/cmd/writeas"
      ],
      "sources": [
        {
          "type": "git",
          "url": "https://github.com/atotto/clipboard",
          "commit": "aa9549103943c05f3e8951009cdb6a0bec2c8949",
          "dest": "src/github.com/atotto/clipboard"
        },
        ...
      ]
    }