aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--.gitmodules3
-rw-r--r--COPYING14
-rw-r--r--Makefile43
-rw-r--r--README49
-rwxr-xr-xbin/build27
-rwxr-xr-xbin/check34
-rwxr-xr-xbin/package41
m---------git-annex0
-rwxr-xr-ximg-scripts/build28
10 files changed, 240 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..6896ef6
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+/config.mk
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..886aeca
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "git-annex"]
+ path = git-annex
+ url = git://git-annex.branchable.com/
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..374bfb7
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,14 @@
+BSD Zero Clause License
+
+Copyright (c) 2024 Kyle Meyer
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
+REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
+INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+PERFORMANCE OF THIS SOFTWARE.
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..e50bbe6
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,43 @@
+-include config.mk
+
+GHC_VERSION ?= 9.8.3
+img = quay.io/benz0li/ghc-musl:$(GHC_VERSION)
+
+annex_version := $(shell git -C git-annex describe)
+
+cabal_root = git-annex/dist-newstyle/build/x86_64-linux
+# NB: For a non-tagged commit, annex_version will be {tag}-N-g{hash}
+# while cabal will build under .../git-annex-{tag}/. That discrepancy
+# doesn't matter because bin/build aborts if git-annex repo is on a
+# non-tagged commit.
+binary = $(cabal_root)/ghc-$(GHC_VERSION)/git-annex-$(annex_version)/build/git-annex/git-annex
+
+build_dir = builds/git-annex-$(annex_version)
+meta_dir = meta/git-annex-$(annex_version)
+
+tgz = $(build_dir)-linux-amd64.tar.gz
+
+.PHONY: help
+help:
+ $(info build - build $(tgz))
+ $(info sign - sign $(tgz))
+ @:
+
+.PHONY: build
+build: $(tgz)
+
+.PHONY: sign
+sign: $(tgz).asc
+
+$(tgz): $(binary)
+ ./bin/package '$(GHC_VERSION)' '$(annex_version)'
+ mkdir -p '$(meta_dir)'
+ mv git-annex/cabal.project.freeze '$(meta_dir)'/cabal.project.freeze
+ ./bin/check '$(annex_version)'
+
+$(tgz).asc: $(tgz)
+ gpg --armor --detach-sign '$<'
+
+$(binary):
+ $(info Building git-annex $(annex_version))
+ ./bin/build '$(img)'
diff --git a/README b/README
new file mode 100644
index 0000000..5bcb84b
--- /dev/null
+++ b/README
@@ -0,0 +1,49 @@
+
+static-annex --- Scripts for creating a static git-annex build
+==============================================================
+
+This repository contains scripts for creating the statically linked
+linux/amd64 builds of git-annex [^1] that are hosted under
+
+ https://dl.kyleam.com/git-annex/
+
+To do so, it relies on the images defined at
+
+ https://gitlab.com/benz0li/ghc-musl
+
+[^1] https://git-annex.branchable.com/
+
+
+License
+-------
+
+This repository's build scripts are licensed under the BSD Zero Clause
+License. The licenses of the various git-annex components are
+specified in its COPYRIGHT file, which is bundled with each output
+tar.gz.
+
+
+Contributing
+------------
+
+Bug reports, patches, questions, and other feedback are welcome.
+Please send a plain-text email, with "[static-annex]" as the subject
+prefix, to
+
+ misc@inbox.kyleam.com
+
+To add this prefix to patches, you can generate the them with
+
+ git format-patch --subject-prefix="PATCH static-annex" ...
+
+To avoid passing --subject-prefix each time you call format-patch, you
+can configure the repository's default prefix:
+
+ git config format.subjectPrefix "PATCH static-annex"
+
+Messages that include the address above are public and available as
+public-inbox [^2] archives at
+
+ https://inbox.kyleam.com/misc/?q=s%3Astatic-annex
+
+[^2]: https://public-inbox.org/README
diff --git a/bin/build b/bin/build
new file mode 100755
index 0000000..63cfe97
--- /dev/null
+++ b/bin/build
@@ -0,0 +1,27 @@
+#!/bin/sh
+# SPDX-License-Identifier: 0BSD
+
+set -eu
+
+img=${1?"usage: $0 <image>"}
+
+test -f git-annex/git-annex.cabal || {
+ printf >&2 'initialize git-annex submodule first\n'
+ exit 1
+}
+test -z "$(git -C git-annex status --porcelain -unormal)" || {
+ printf >&2 'git-annex repository is dirty\n'
+ exit 1
+}
+test -n "$(git -C git-annex for-each-ref --points-at=HEAD refs/tags)" || {
+ printf >&2 'git-annex repository must be on a tagged commit\n'
+ exit 1
+}
+
+git -C git-annex clean -xfd
+podman run \
+ -v ./git-annex:/git-annex \
+ -v ./img-scripts:/mnt \
+ -w /git-annex \
+ --env RELEASE_BUILD=1 --rm \
+ "$img" /mnt/build
diff --git a/bin/check b/bin/check
new file mode 100755
index 0000000..fc1b75b
--- /dev/null
+++ b/bin/check
@@ -0,0 +1,34 @@
+#!/bin/sh
+# SPDX-License-Identifier: 0BSD
+
+set -eu
+
+version=${1?"usage: $0 <version>"}
+
+tgz=builds/git-annex-$version-linux-amd64.tar.gz
+test -f "$tgz" || {
+ printf >&2 'file does not exist: %s\n' "$tgz"
+ exit 2
+}
+
+tdir=$(mktemp -d "${TMPDIR:-/tmp}"/static-annex-XXXXXXX)
+tar xzf "$tgz" -C "$tdir"
+cd "$tdir/git-annex-$version"
+
+if ldd bin/git-annex 2>/dev/null
+then
+ printf >&2 'ldd unexpectedly had 0 exit status on bin/git-annex\n'
+ ldd bin/git-annex
+ exit 1
+fi
+
+PATH=$(pwd)/bin:$PATH
+export PATH
+
+base=${tdir##*/}
+command -v git-annex | grep -qF "$base"
+command -v git-annex-shell | grep -qF "$base"
+command -v git-remote-annex | grep -qF "$base"
+command -v git-remote-tor-annex | grep -qF "$base"
+
+git annex test
diff --git a/bin/package b/bin/package
new file mode 100755
index 0000000..837dfbf
--- /dev/null
+++ b/bin/package
@@ -0,0 +1,41 @@
+#!/bin/sh
+# SPDX-License-Identifier: 0BSD
+
+set -eu
+
+test $# = 2 || {
+ cat >&2 <<-EOF
+usage: $0 <ghc version> <annex version>
+
+Create 'builds/git-annex-<annex version>-linux-amd64.tar.gz' from
+files under ./git-annex/, most importantly the git-annex binary under
+cabal's build directory for <ghc version> and <annex version>.
+EOF
+ exit 2
+}
+
+version_ghc=$1
+version_annex=$2
+
+cabal_root=git-annex/dist-newstyle/build/x86_64-linux
+binary=$cabal_root/ghc-$version_ghc/git-annex-$version_annex/build/git-annex/git-annex
+
+pkg_root=builds/git-annex-$version_annex
+mkdir -p "$pkg_root"
+
+pkg_bin=$pkg_root/bin
+mkdir "$pkg_bin"
+cp "$binary" "$pkg_bin"/
+ln -s git-annex "$pkg_bin"/git-annex-shell
+ln -s git-annex "$pkg_bin"/git-remote-annex
+ln -s git-annex "$pkg_bin"/git-remote-tor-annex
+
+cp git-annex/COPYRIGHT "$pkg_root"/
+
+pkg_man=$pkg_root/share/man/man1
+mkdir -p "$pkg_man"
+cp git-annex/man/*.1 "$pkg_man"/
+gzip -9 "$pkg_man"/*.1
+
+tar czf "$pkg_root"-linux-amd64.tar.gz -C builds git-annex-"$version_annex"
+rm -r "$pkg_root"
diff --git a/git-annex b/git-annex
new file mode 160000
+Subproject b3dc65615318ffed194dfb85e631482d4515a18
diff --git a/img-scripts/build b/img-scripts/build
new file mode 100755
index 0000000..d2e0147
--- /dev/null
+++ b/img-scripts/build
@@ -0,0 +1,28 @@
+#!/bin/sh
+# SPDX-License-Identifier: 0BSD
+
+set -eu
+
+apk update --no-cache
+apk add --no-cache file-dev libmagic libmagic-static
+
+cabal update
+
+feats='-f-assistant -f-webapp'
+# shellcheck disable=SC2086
+cabal configure $feats
+# Generate a cabal.project.freeze file. Beyond recording what
+# dependencies were used for a build, this (hopefully) provides future
+# builds a way to get back to a known good state, if necessary.
+cabal v2-freeze
+
+make mans
+
+n=$(nproc --ignore=1)
+# Most of the cabal and GHC options from pandoc's Makefile (debpkg
+# target, 4c66bf279).
+#
+# shellcheck disable=SC2086
+cabal build -j"$n" \
+ --enable-executable-static $feats \
+ --ghc-options="-j$n +RTS -A256m -RTS -split-sections -optc-Os -optl=-pthread"