fix: configure Cross release dependencies
Rust CI tiny-wb passed CI.
Gitea/tiny-wb/pipeline/head This commit looks good
Details
Rust CI tiny-wb passed CI.
Gitea/tiny-wb/pipeline/head This commit looks good
Details
This commit is contained in:
parent
2def6e61e0
commit
6fe4286e38
|
|
@ -71,12 +71,16 @@ For Cross installation and image setup, follow the
|
|||
`CROSS_CONTAINER_ENGINE=podman` or `docker` when necessary. Check `cross --version`,
|
||||
`cargo binstall -V`, and the selected engine's `info` command before building.
|
||||
|
||||
The target images must provide the Linux target's libudev development files and
|
||||
pkg-config configuration, the linker required by `.cargo/config.toml` (`lld`),
|
||||
and the Windows GNU resource compiler required by `build.rs` (`windres`). Native
|
||||
host compilation alone does not verify those container prerequisites. Configure
|
||||
suitable prebuilt Cross images before building; the publisher rejects repository
|
||||
`pre-build`, `dockerfile`, and `runner` hooks, so do not silently add install hooks.
|
||||
The Linux target needs libudev development files and pkg-config configuration;
|
||||
the Windows target needs the GNU resource compiler used by `build.rs`
|
||||
(`windres`). Native host compilation alone does not verify those container
|
||||
prerequisites. [`release/Cross.toml`](../release/Cross.toml) installs
|
||||
`libudev-dev` and `pkg-config` in the Linux image. `release.sh` exports its
|
||||
absolute path as `CROSS_CONFIG` for the publisher process. The file is kept away
|
||||
from the repository root because the publisher rejects root `pre-build`,
|
||||
`dockerfile`, and `runner` hooks. Package installation requires access to the
|
||||
image's Debian/Ubuntu repositories. A caller-supplied `CROSS_CONFIG` is
|
||||
intentionally replaced so releases use the reviewed, tracked configuration.
|
||||
|
||||
## Token handling and commands
|
||||
|
||||
|
|
@ -88,20 +92,26 @@ newline), rejects an empty first line, and exports it as `GITEA_TOKEN` only to
|
|||
the publisher. It never passes the token in arguments or prints it. The publisher
|
||||
is responsible for keeping it out of child builds and for download verification.
|
||||
|
||||
In these examples, set `TOKEN_FILE` in your shell to the existing token file's
|
||||
path; it is not a checked-in setting:
|
||||
Compile-only builds do not access Gitea and need no token:
|
||||
|
||||
```console
|
||||
./release.sh --compile-only
|
||||
```
|
||||
|
||||
`--compile-only` builds local artifacts in ignored `dist/release-*/`, without
|
||||
contacting Gitea. Inspect `SHA256SUMS`, archive members, executables and the
|
||||
binstall layout before publication.
|
||||
|
||||
For authenticated dry runs and publication, set `TOKEN_FILE` in your shell to
|
||||
the existing token file's path; it is not a checked-in setting:
|
||||
|
||||
```console
|
||||
./release.sh "$TOKEN_FILE" --dry-run
|
||||
./release.sh "$TOKEN_FILE" --compile-only
|
||||
```
|
||||
|
||||
A dry run must report the correct package, version, unprefixed tag, both targets,
|
||||
asset names and public HTTPS destination without changing files, refs or releases.
|
||||
A successful dry run is required but does not replace collision inspection.
|
||||
`--compile-only` builds local artifacts in ignored `dist/release-*/`, without
|
||||
contacting Gitea. Inspect `SHA256SUMS`, archive members, executables and the
|
||||
binstall layout before publication.
|
||||
|
||||
After all readiness checks and separate publication authorization:
|
||||
|
||||
|
|
|
|||
23
release.sh
23
release.sh
|
|
@ -7,17 +7,23 @@ unset GITEA_TOKEN
|
|||
|
||||
usage() {
|
||||
echo "usage: $0 <gitea-token-file> [rust_realease options...]" >&2
|
||||
echo " $0 --compile-only [rust_realease options...]" >&2
|
||||
exit 2
|
||||
}
|
||||
|
||||
[ "$#" -ge 1 ] || usage
|
||||
token_file=
|
||||
if [ "$1" = "--compile-only" ]; then
|
||||
shift
|
||||
set -- --compile-only "$@"
|
||||
else
|
||||
token_file=$1
|
||||
shift
|
||||
|
||||
if [ ! -f "$token_file" ] || [ ! -r "$token_file" ] || [ ! -s "$token_file" ]; then
|
||||
echo "token file must be readable, regular and nonempty" >&2
|
||||
exit 2
|
||||
fi
|
||||
fi
|
||||
if ! command -v rust_realease >/dev/null 2>&1; then
|
||||
echo "rust_realease is not installed or not available in PATH; see docs/releases.md" >&2
|
||||
exit 2
|
||||
|
|
@ -49,7 +55,9 @@ case "${manifest_version%%+*}" in
|
|||
*-*) set -- "$@" --prerelease ;;
|
||||
esac
|
||||
|
||||
# Read after subprocess-based discovery, and export only for the publisher.
|
||||
# Read after subprocess-based discovery, and export only when publishing or
|
||||
# performing an authenticated dry run. Compile-only mode needs no token.
|
||||
if [ -n "$token_file" ]; then
|
||||
GITEA_TOKEN=
|
||||
IFS= read -r GITEA_TOKEN <"$token_file" || :
|
||||
if [ -z "$GITEA_TOKEN" ]; then
|
||||
|
|
@ -57,4 +65,15 @@ if [ -z "$GITEA_TOKEN" ]; then
|
|||
exit 2
|
||||
fi
|
||||
export GITEA_TOKEN
|
||||
fi
|
||||
|
||||
# Cross builds in an isolated Debian/Ubuntu image, so native libraries from the
|
||||
# maintainer's host are unavailable. Keep this explicitly selected file away
|
||||
# from the root Cross.toml path validated by rust_realease.
|
||||
CROSS_CONFIG=$repository_dir/release/Cross.toml
|
||||
if [ ! -f "$CROSS_CONFIG" ] || [ ! -r "$CROSS_CONFIG" ]; then
|
||||
echo "release Cross configuration is missing or unreadable: $CROSS_CONFIG" >&2
|
||||
exit 2
|
||||
fi
|
||||
export CROSS_CONFIG
|
||||
exec rust_realease "$@"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
# Native dependencies required by the GNU/Linux release target. This file is
|
||||
# selected explicitly by release.sh because rust_realease reserves a root
|
||||
# Cross.toml for its validated repository configuration.
|
||||
[target.x86_64-unknown-linux-gnu]
|
||||
pre-build = [
|
||||
"apt-get update && apt-get install --assume-yes --no-install-recommends libudev-dev pkg-config",
|
||||
]
|
||||
|
|
@ -5,7 +5,8 @@ tag-prefix = ""
|
|||
|
||||
[build]
|
||||
# Desktop targets. Linux uses glibc because serialport links system libudev.
|
||||
# Cross images must provide target libudev/pkg-config, lld and Windows windres.
|
||||
# release/Cross.toml injects target libudev/pkg-config; the base images provide
|
||||
# the remaining target toolchains, including the Windows windres executable.
|
||||
targets = ["x86_64-unknown-linux-gnu", "x86_64-pc-windows-gnu"]
|
||||
profile = "release"
|
||||
locked = true
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ class ReleaseWrapperTests(unittest.TestCase):
|
|||
self.project.mkdir()
|
||||
for name in ('release.sh', 'Cargo.toml', 'rust-release.toml'):
|
||||
shutil.copy2(REPO / name, self.project / name)
|
||||
(self.project / 'release').mkdir()
|
||||
shutil.copy2(REPO / 'release' / 'Cross.toml', self.project / 'release' / 'Cross.toml')
|
||||
self.tools = self.root / 'tools'
|
||||
self.tools.mkdir()
|
||||
# An isolated PATH tests missing publishers without relying on the host.
|
||||
|
|
@ -31,8 +33,11 @@ class ReleaseWrapperTests(unittest.TestCase):
|
|||
self.fake = self.tools / 'rust_realease'
|
||||
self.fake.write_text('#!' + sys.executable + '\n' + '''import json, os, pathlib, sys
|
||||
repository = pathlib.Path(sys.argv[1])
|
||||
cross_config = pathlib.Path(os.environ["CROSS_CONFIG"])
|
||||
record = {"args": sys.argv[1:], "token": os.environ.get("GITEA_TOKEN"),
|
||||
"fallback": (repository / "rust-release.toml").read_text()}
|
||||
"fallback": (repository / "rust-release.toml").read_text(),
|
||||
"cross_config": str(cross_config),
|
||||
"cross_config_contents": cross_config.read_text()}
|
||||
pathlib.Path(os.environ["CAPTURE"]).write_text(json.dumps(record))
|
||||
sys.exit(int(os.environ.get("PUBLISHER_EXIT", "0")))
|
||||
''')
|
||||
|
|
@ -74,6 +79,13 @@ sys.exit(int(os.environ.get("PUBLISHER_EXIT", "0")))
|
|||
'--artifact-format', 'both', *extra, *prerelease])
|
||||
self.assertEqual(record['token'], 'inert-test-token-123')
|
||||
self.assertNotIn(record['token'], '\n'.join(record['args']))
|
||||
self.assertEqual(tomllib.loads(record['cross_config_contents']), {
|
||||
'target': {'x86_64-unknown-linux-gnu': {
|
||||
'pre-build': [
|
||||
'apt-get update && apt-get install --assume-yes '
|
||||
'--no-install-recommends libudev-dev pkg-config']}}})
|
||||
self.assertEqual(Path(record['cross_config']), self.project / 'release' / 'Cross.toml')
|
||||
self.assertTrue(Path(record['cross_config']).is_file())
|
||||
config = tomllib.loads(record['fallback'])
|
||||
self.assertEqual(config['repository']['fallbacks'], [{
|
||||
'origin': before.decode().strip(),
|
||||
|
|
@ -93,7 +105,24 @@ sys.exit(int(os.environ.get("PUBLISHER_EXIT", "0")))
|
|||
self.env['PUBLISHER_EXIT'] = '37'
|
||||
self.token.write_text('inert-test-token-123')
|
||||
self.run_wrapper([str(self.token), '--compile-only'], expected=37)
|
||||
self.assertEqual(json.loads(self.capture.read_text())['token'], 'inert-test-token-123')
|
||||
record = json.loads(self.capture.read_text())
|
||||
self.assertEqual(record['token'], 'inert-test-token-123')
|
||||
|
||||
def test_compile_only_needs_no_token(self):
|
||||
self.run_wrapper(['--compile-only', '--recompile'])
|
||||
record = json.loads(self.capture.read_text())
|
||||
version = tomllib.loads((self.project / 'Cargo.toml').read_text())['package']['version']
|
||||
prerelease = ['--prerelease'] if '-' in version.split('+', 1)[0] else []
|
||||
self.assertEqual(record['args'], [str(self.project), '--package', 'tiny-wb',
|
||||
'--artifact-format', 'both', '--compile-only',
|
||||
'--recompile', *prerelease])
|
||||
self.assertIsNone(record['token'])
|
||||
|
||||
def test_missing_release_cross_config_never_invokes_publisher(self):
|
||||
(self.project / 'release' / 'Cross.toml').unlink()
|
||||
result = self.run_wrapper(['--compile-only'], expected=2)
|
||||
self.assertIn('release Cross configuration is missing or unreadable', result.stderr)
|
||||
self.assertFalse(self.capture.exists())
|
||||
|
||||
def test_invalid_token_inputs_never_invoke_publisher(self):
|
||||
self.run_wrapper([], expected=2)
|
||||
|
|
|
|||
Loading…
Reference in New Issue