2021-01-28 22:03:33 +08:00
|
|
|
# Packager's Manual
|
|
|
|
|
2022-04-10 04:29:04 +08:00
|
|
|
The main package of Elvish is `cmd/elvish`, and you can build it like any other
|
|
|
|
Go application. None of the instructions below are strictly required.
|
|
|
|
|
2021-01-28 22:03:33 +08:00
|
|
|
**Note**: The guidance here applies to the current development version and
|
2022-04-03 01:11:23 +08:00
|
|
|
release versions starting from 0.19.0. The details for earlier versions are
|
2021-01-28 22:03:33 +08:00
|
|
|
different.
|
|
|
|
|
2022-04-10 04:29:04 +08:00
|
|
|
## Identifying the build variant
|
|
|
|
|
|
|
|
You are encouraged to identify your build by overriding
|
|
|
|
`src.elv.sh/pkg/buildinfo.BuildVariant` with something that identifies the
|
|
|
|
distribution you are building for, and any patch level you have applied for
|
|
|
|
Elvish. This will allow Elvish developers to easily identify any
|
|
|
|
distribution-specific issue:
|
|
|
|
|
2022-04-10 04:30:09 +08:00
|
|
|
```sh
|
2022-04-10 04:29:04 +08:00
|
|
|
go build -ldflags '-X src.elv.sh/pkg/buildinfo.BuildVariant=deb1' ./cmd/elvish
|
|
|
|
```
|
|
|
|
|
|
|
|
### Official builds
|
|
|
|
|
|
|
|
A special build variant is `official`. This variant has a special meaning: the
|
|
|
|
binary must be bit-by-bit identical to the official binaries, linked from
|
|
|
|
https://elv.sh/get.
|
|
|
|
|
|
|
|
The official binaries are built using the `tools/buildall.sh` script in the Git
|
|
|
|
repo, using the docker image defined in https://github.com/elves/up. If you can
|
|
|
|
fully mirror the environment **and** verify that the resulting binary is
|
|
|
|
bit-by-bit identical to the official one, you can identify your build as
|
|
|
|
`official`.
|
|
|
|
|
|
|
|
**Important**: Reproducing the official binaries is not a one-off investment,
|
|
|
|
but an ongoing commitment: whenever the configuration for the official builds
|
|
|
|
changes, you must update your build setup accordingly. You must always verify
|
|
|
|
that your binaries are identical to official ones. As an example of how this can
|
|
|
|
be done, the
|
|
|
|
[check website](https://github.com/elves/elvish/blob/master/.github/workflows/check_website.yml)
|
|
|
|
workflow builds binaries for commits on the `master` branch and compare them
|
|
|
|
with official ones. If your build setup is technically reproducible, but you are
|
|
|
|
ready to ensure it's always identical to official binaries, you can always use a
|
|
|
|
distribution-specific variant, such as `deb1-reproducible`.
|
2021-01-28 22:03:33 +08:00
|
|
|
|
2022-04-03 01:11:23 +08:00
|
|
|
## Supplying VCS information for development builds
|
2021-01-28 22:03:33 +08:00
|
|
|
|
2022-04-10 04:29:04 +08:00
|
|
|
**Note**: This section is only relevant when building **development commits**,
|
|
|
|
which most distributions do not provide. Release commits always have their
|
|
|
|
version hardcoded in the code.
|
|
|
|
|
2022-04-03 01:11:23 +08:00
|
|
|
When Elvish is built from a development branch, it will try to figure out its
|
|
|
|
version from the VCS information Go compiler encoded. When that works,
|
|
|
|
`elvish -version` will output something like this:
|
2021-01-28 22:03:33 +08:00
|
|
|
|
2022-04-03 01:11:23 +08:00
|
|
|
```
|
|
|
|
0.19.0-dev.0.20220320172241-5dc8c02a32cf
|
|
|
|
```
|
2021-01-28 22:03:33 +08:00
|
|
|
|
2022-04-03 01:11:23 +08:00
|
|
|
The version string follows the syntax of
|
|
|
|
[Go module pseudo-version](https://go.dev/ref/mod#pseudo-versions), and consists
|
|
|
|
of the following parts:
|
2021-01-28 22:03:33 +08:00
|
|
|
|
2022-04-03 01:11:23 +08:00
|
|
|
- `0.19.0-dev` identifies that this is a development build **before** the
|
|
|
|
0.19.0 release.
|
2021-01-28 22:03:33 +08:00
|
|
|
|
2022-04-03 01:11:23 +08:00
|
|
|
- `.0` indicates that this is a pseudo-version, instead of a real version.
|
2021-01-28 22:03:33 +08:00
|
|
|
|
2022-04-03 01:11:23 +08:00
|
|
|
- `20220320172241` identifies the commit's creation time, in UTC.
|
2021-01-28 22:03:33 +08:00
|
|
|
|
2022-04-03 01:11:23 +08:00
|
|
|
- `5dc8c02a32cf` is the 12-character prefix of the commit hash.
|
2021-08-21 23:34:33 +08:00
|
|
|
|
2022-04-03 01:11:23 +08:00
|
|
|
If that doesn't work for your build environment, the output of `elvish -version`
|
|
|
|
will instead be:
|
2021-01-28 22:03:33 +08:00
|
|
|
|
2022-04-10 04:30:09 +08:00
|
|
|
```
|
2022-04-03 01:11:23 +08:00
|
|
|
0.19.0-dev.unknown
|
2021-01-28 22:03:33 +08:00
|
|
|
```
|
|
|
|
|
2022-04-03 01:11:23 +08:00
|
|
|
If your build environment has the required information to build the
|
|
|
|
pseudo-version string, you can supply it by overriding
|
|
|
|
`src.elv.sh/pkg/buildinfo.VCSOverride` with the last two parts of the version
|
|
|
|
string, commit's creation time and the 12-character prefix of the commit hash:
|
2021-01-28 22:03:33 +08:00
|
|
|
|
|
|
|
```sh
|
2022-04-03 01:11:23 +08:00
|
|
|
go build -ldflags '-X src.elv.sh/pkg/buildinfo.VCSOverride=20220320172241-5dc8c02a32cf' ./cmd/elvish
|
2021-01-28 22:03:33 +08:00
|
|
|
```
|