pgt-gopath

command
v0.0.0-...-be83729 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 3, 2021 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Program pgt-gopath constructs a Go workspace src directory from the Debian unstable archive. See https://golang.org/doc/code.html#Workspaces

This is useful, for example, for quick continuous integration: gone is the computationally intensive step of identifying reverse dependencies of Debian packages, and gone is the overhead of installing .deb packages (orders of magnitude slower than pgt-gopath). One can directly use the go tool, which builds/tests quickly and with caching. See https://pkg-go.alioth.debian.org/ci.html for more details on how Debian uses this.

Even users outside of Debian can use such a Go workspace to obtain a reasonably large body of software with real-world usage, perhaps to run regression tests when doing changes to the Go standard library.

pgt-gopath leverages apt-cacher-ng(8) for caching: each run of pgt-gopath constructs an entirely new GOPATH/src directory, consuming many .orig tarballs from the Debian archive. This typically takes less than 10 seconds on a modern computer.

The resulting src directory is suffixed with the UNIX timestamp of the release metadata’s last modified timestamp. In case the last modified timestamp matches the current on-disk timestamp, pgt-gopath immediately exits successfully. Hence, it can be run in a minutely cronjob.

This last modified timestamp is printed to stdout (whereas log messages are printed to stderr). This allows for post-processing (e.g. chmod) and atomically updating the Go workspace via:

#!/bin/bash
# Not safe for concurrent execution: wrap in flock(1) or a systemd service.
set -e

# Update pgt-gopath to pick up fixes:
go get -u github.com/Debian/pkg-go-team/cmd/pgt-gopath

mkdir -p /srv/gopath
cd /srv/gopath

# Create a new src-<timestamp> directory:
latest=$(pgt-gopath)

# Atomically update the src symlink:
ln -snf src-${latest} new_src
mv -T new_src src

# Clean up all old src-<timestamp> directories:
rm -rf -- $(ls -d src-* | grep -v "^src-$latest\$")

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL