Skip to content

Commit

Permalink
feat: diffutils build
Browse files Browse the repository at this point in the history
  • Loading branch information
alecthomas committed Jan 15, 2023
1 parent d559204 commit c875123
Show file tree
Hide file tree
Showing 11 changed files with 115 additions and 2 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/diffutils.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Build diffutils
on:
workflow_dispatch:
inputs:
version:
description: "Version of diffutils"
required: true
default: 3.8
type: string
jobs:
gpg:
name: Build
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Init Hermit
run: ./bin/hermit env --raw >> $GITHUB_ENV
- name: Build
run: make VERSION=${{ inputs.version }} -C diffutils
- name: Upload Release
uses: ncipollo/release-action@v1
with:
tag: diffutils
allowUpdates: true
artifacts: "diffutils/diffutils-*.tar.xz"
token: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .github/workflows/go-tools.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
name: Build Go tools
on:
workflow_dispatch:
push:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/gotip.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
name: Build Go tip
on:
workflow_dispatch:
push:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/gpg.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
name: Build gpg
on:
workflow_dispatch:
jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/mysql-client.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: mysql client binaries lightweight packages
name: MySQL client binaries lightweight packages
on:
workflow_dispatch:
push:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/protoc-gen-swift.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: protoc-gen-swift
name: Build protoc-gen-swift
on:
workflow_dispatch:
inputs:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/gotip/goroot
/gotip/go-*
/go-tools/*.bz2
*/build/*
*/dist/*
3 changes: 3 additions & 0 deletions bin/hermit.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
env = {
"PATH": "${HERMIT_ENV}/scripts:${PATH}",
}
22 changes: 22 additions & 0 deletions diffutils/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
VERSION ?= 3.8
DESTDIR ?= $(CURDIR)/dist
OS = $(shell go env GOOS)
ARCH = $(shell go env GOARCH)

.PHONY: all
all: diffutils.tar.xz
rm -rf build
mkdir build
tar -C build --strip-components 1 -xvf diffutils.tar.xz
sandbox $(MAKE) -C build -f ../Makefile build
mv build/dist diffutils-$(VERSION)
tar cfJv diffutils-$(VERSION)-$(OS)-$(ARCH).tar.xz diffutils-$(VERSION)

.PHONY: build
build:
./configure --prefix=/ --disable-rpath
$(MAKE) -j8
$(MAKE) DESTDIR=$(DESTDIR) install

diffutils.tar.xz:
curl -L https://ftpmirror.gnu.org/diffutils/diffutils-$(VERSION).tar.xz -o diffutils.tar.xz
36 changes: 36 additions & 0 deletions sandbox.sb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
(version 1)
(deny default)
(import "/System/Library/Sandbox/Profiles/bsd.sb")

;(allow network* (local ip "localhost:*"))
;(allow network* (remote ip "localhost:*"))
(allow network* (remote unix-socket))

(system-network)

(allow mach-lookup
(global-name "com.apple.diagnosticd")
(global-name "com.apple.system.logger"))

(allow file-read*)
(deny file-read*
(subpath "/opt/")
(subpath "/usr/local/")
)

(deny file-write*)
(allow file-write*
(subpath "/dev/")
(subpath "/tmp/")
(subpath (param "HERMIT_STATE_DIR"))
(subpath (param "TMPDIR"))
(subpath (param "BUILD_DIR"))
)

(allow process-exec*)
(deny process-exec*
(subpath "/opt/")
(subpath "/usr/local/")
)

(allow process-fork)
17 changes: 17 additions & 0 deletions scripts/sandbox
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

root="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/.. && pwd )"

case "$(uname -s)" in
Darwin)
# This is to prevent builds using dependencies from /opt and /usr/local.
sandbox-exec -D TMPDIR="/private$TMPDIR" -D BUILD_DIR="${root}" -D HERMIT_STATE_DIR="${HOME}/Library/Caches/hermit" -f "${root}/sandbox.sb" "$@"
;;
*)
# Not ideal, in that we still might end up with extra dependencies, but at least they will be static.
export CFLAGS="-static"
export CXXFLAGS="-static"
export LDFLAGS="-static"
exec "$@"
;;
esac

0 comments on commit c875123

Please sign in to comment.