Skip to content

Commit 1439d78

Browse files
committed
DLPX-93326 Add package containing rust source files
PR URL: https://www.github.com/delphix/delphix-rust/pull/25
1 parent 336dc7a commit 1439d78

File tree

5 files changed

+103
-5
lines changed

5 files changed

+103
-5
lines changed

debian/control

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,10 @@ Provides: cargo, rust-gdb, rustc (= ${binary:Version})
2626
Conflicts: cargo, rust-gdb, rustc
2727
Description: Rust - A programming language empowering everyone to build
2828
reliable and efficient software.
29+
30+
Package: delphix-rust-src
31+
Architecture: any
32+
Provides: rustc-src (= ${binary:Version})
33+
Conflicts: rustc-src
34+
Description: Rust - A programming language empowering everyone to build
35+
reliable and efficient software.

debian/delphix-rust-src.install

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
usr/src/*

debian/delphix-rust.install

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
usr/bin/*
2+
usr/etc/*
3+
usr/lib/*
4+
usr/libexec/*
5+
usr/share/*

debian/rules

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,19 @@ RUSTC_VERSION := $(shell tr -d '\n' < RUSTC_VERSION)
2121
%:
2222
dh $@
2323

24-
override_dh_install:
25-
./scripts/fetch-and-run-installer.sh ${RUSTC_VERSION} "/usr" "debian/tmp" $(DEB_HOST_GNU_CPU)
26-
27-
dh_install --autodest "debian/tmp/*"
24+
override_dh_prep:
25+
dh_prep
26+
./scripts/fetch-and-run-installer.sh "${RUSTC_VERSION}" "/usr" "debian/tmp" $(DEB_HOST_GNU_CPU)
27+
./scripts/fetch-and-unpack-src.sh "${RUSTC_VERSION}" "/usr/src" "debian/tmp"
2828

2929
override_dh_strip:
30-
# Skip this step; use artifacts from Rust tarball as-is.
30+
# Skip this step; use artifacts from Rust tarballs as-is.
31+
32+
override_dh_strip_nondeterminism:
33+
# Skip this step; use artifacts from Rust tarballs as-is.
34+
35+
override_dh_makeshlibs:
36+
# Skip this step; use artifacts from Rust tarballs as-is.
37+
38+
override_dh_shlibdeps:
39+
# Skip this step; use artifacts from Rust tarballs as-is.

scripts/fetch-and-unpack-src.sh

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/bin/bash
2+
#
3+
# Copyright 2021, 2025 Delphix
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
set -o xtrace
19+
20+
BASEURL="https://artifactory.delphix.com/artifactory/linux-pkg/rust"
21+
22+
function die() {
23+
echo "$(basename "$0"): $*" >&2
24+
exit 1
25+
}
26+
27+
function usage() {
28+
echo "$(basename "$0"): $*" >&2
29+
echo "Usage: $(basename "$0") <version> <prefix> <destdir> <cpu>"
30+
exit 2
31+
}
32+
33+
function cleanup() {
34+
[[ -n "$TEMP_DIR" ]] && [[ -d "$TEMP_DIR" ]] && rm -rf "$TEMP_DIR"
35+
}
36+
37+
[[ $# -gt 3 ]] && usage "too many arguments specified"
38+
[[ $# -lt 3 ]] && usage "too few arguments specified"
39+
40+
VERSION="$1"
41+
PREFIX="$2"
42+
DESTDIR="$3"
43+
44+
RUST="rustc-${VERSION}-src"
45+
46+
[[ -z "$VERSION" ]] && usage "version not specified."
47+
[[ -z "$PREFIX" ]] && usage "prefix not specified."
48+
[[ -z "$DESTDIR" ]] && usage "destdir not specified."
49+
50+
#
51+
# The full path is required, so DESTDIR can be used after calling "pushd" below.
52+
#
53+
DESTDIR="$(readlink -f "$DESTDIR")"
54+
mkdir -p "${DESTDIR}" || die "'mkdir -p \"${DESTDIR}\"' failed"
55+
56+
curl -v https://keybase.io/rust/pgp_keys.asc | gpg --import ||
57+
die "failed to import GPG key"
58+
59+
trap cleanup EXIT
60+
61+
TEMP_DIR="$(mktemp -d -t delphix-rust.XXXXXXX)"
62+
[[ -d "$TEMP_DIR" ]] || die "failed to create temporary directory '$TEMP_DIR'"
63+
pushd "$TEMP_DIR" &>/dev/null || die "'pushd $TEMP_DIR' failed"
64+
65+
wget -nv "${BASEURL}/${RUST}.tar.xz" || die "failed to download tarfile"
66+
wget -nv "${BASEURL}/${RUST}.tar.xz.asc" || die "failed to download signature"
67+
gpg --verify "${RUST}.tar.xz.asc" "${RUST}.tar.xz" ||
68+
die "failed to verify signature"
69+
70+
mkdir -p "${DESTDIR}${PREFIX}/rustc-${VERSION}" ||
71+
die "failed to install; 'prefix=${PREFIX}' and 'destdir=${DESTDIR}'"
72+
tar -xvf "${RUST}.tar.xz" \
73+
-C "${DESTDIR}${PREFIX}/rustc-${VERSION}" --strip-components 1 ||
74+
die "failed to extract tarfile"
75+
76+
popd &>/dev/null || die "'popd' failed"

0 commit comments

Comments
 (0)