Skip to content

Commit fb7ccd3

Browse files
authored
Merge pull request #6 from AkihiroSuda/dev
README.md: add environment variables
2 parents 10de920 + 7768c80 commit fb7ccd3

File tree

2 files changed

+38
-3
lines changed

2 files changed

+38
-3
lines changed

README.md

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
# repro-sources-list.sh
22

3-
[`repro-sources-list.sh`](./repro-sources-list.sh) configures `/etc/apt/sources.list` and similar files for installing packages from a snapshot.
3+
[`repro-sources-list.sh`](./repro-sources-list.sh) configures `/etc/apt/sources.list` and similar files
4+
for installing packages from a snapshot to help [Reproducible Builds](https://reproducible-builds.org/).
5+
6+
```dockerfile
7+
# SOURCE_DATE_EPOCH is set to 1691114774 (i.e., 20230804T020614Z, timestamp of /etc/apt/sources.list)
8+
FROM ubuntu:jammy-20230804
9+
ENV DEBIAN_FRONTEND=noninteractive
10+
RUN \
11+
--mount=type=cache,target=/var/cache/apt,sharing=locked \
12+
--mount=type=cache,target=/var/lib/apt,sharing=locked \
13+
--mount=type=bind,source=./repro-sources-list.sh,target=/usr/local/bin/repro-sources-list.sh \
14+
repro-sources-list.sh && \
15+
apt-get update && \
16+
apt-get install -y gcc
17+
```
418

519
Examples:
620
- [`Dockerfile.debian-11`](./Dockerfile.debian-11)
@@ -9,9 +23,27 @@ Examples:
923
- [`Dockerfile.ubuntu-2304`](./Dockerfile.ubuntu-2304)
1024
- [`Dockerfile.archlinux`](./Dockerfile.archlinux)
1125

12-
## Hint
26+
## Hints
1327
- To preserve the package cache on GHA, use <https://github.com/overmindtech/buildkit-cache-dance>.
1428
See [`.github/workflows/main.yaml`](./.github/workflows/main.yaml) for an example.
1529

1630
- For Debian >= 13 and Ubuntu >= 23.10, see also [`./alternative/`](./alternative/)
1731
to lock packages without using [`repro-sources-list.sh`](./repro-sources-list.sh).
32+
33+
### Environment variables
34+
35+
| Variable | Description | Default value |
36+
|---------------------------|-----------------------------------------------|--------------------------------------------------------------------|
37+
| `SOURCE_DATE_EPOCH` | Timestamp of the snapshot (int64) | Timestamp of `/etc/apt/sources.list`, etc. (See below) |
38+
| `WRITE_SOURCE_DATE_EPOCH` | Write the `SOURCE_DATE_EPOCH` value to a file | `/dev/null` |
39+
| `SNAPSHOT_ARCHIVE_BASE` | Base URL of the snapshot | `http://snapshot-cloudflare.debian.org/archive/`, etc. (See below) |
40+
| `BACKPORTS` | Enable Debian backports | `0` |
41+
42+
Distribution-specific default values:
43+
44+
| Distribution | `SOURCE_DATE_EPOCH` | `SNAPSHOT_ARCHIVE_BASE` |
45+
|----------------|------------------------------------------------------|--------------------------------------------------|
46+
| Debian (<= 11) | Timestamp of `/etc/apt/sources.list` | `http://snapshot-cloudflare.debian.org/archive/` |
47+
| Debian (>= 12) | Timestamp of `/etc/apt/sources.list.d/debian.source` | `http://snapshot-cloudflare.debian.org/archive/` |
48+
| Ubuntu | Timestamp of `/etc/apt/sources.list` | `http://snapshot.ubuntu.com/` |
49+
| ArchLinux | Timestamp of `/var/log/pacman.log` | `http://archive.archlinux.org/` |

repro-sources-list.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,18 @@ case "${ID}" in
8282
apt-get -o Acquire::https::Verify-Peer=false install -y ca-certificates >&2
8383
;;
8484
"arch")
85+
: "${SNAPSHOT_ARCHIVE_BASE:=http://archive.archlinux.org/}"
8586
: "${SOURCE_DATE_EPOCH:=$(stat --format=%Y /var/log/pacman.log)}"
8687
export SOURCE_DATE_EPOCH
8788
# shellcheck disable=SC2016
88-
date -d "@${SOURCE_DATE_EPOCH}" '+Server = https://archive.archlinux.org/repos/%Y/%m/%d/$repo/os/$arch' >/etc/pacman.d/mirrorlist
89+
date -d "@${SOURCE_DATE_EPOCH}" "+Server = ${SNAPSHOT_ARCHIVE_BASE}repos/%Y/%m/%d/\$repo/os/\$arch" >/etc/pacman.d/mirrorlist
8990
;;
9091
*)
9192
echo >&2 "Unsupported distribution: ${ID}"
9293
exit 1
9394
;;
9495
esac
9596

97+
: "${WRITE_SOURCE_DATE_EPOCH:=/dev/null}"
98+
echo "${SOURCE_DATE_EPOCH}" >"${WRITE_SOURCE_DATE_EPOCH}"
9699
echo "SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH}"

0 commit comments

Comments
 (0)