Skip to content

DLPX-93326 Add package containing rust source files #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,10 @@ Provides: cargo, rust-gdb, rustc (= ${binary:Version})
Conflicts: cargo, rust-gdb, rustc
Description: Rust - A programming language empowering everyone to build
reliable and efficient software.

Package: delphix-rust-src
Architecture: any
Provides: rust-src (= ${binary:Version})
Conflicts: rust-src
Description: Rust - A programming language empowering everyone to build
reliable and efficient software.
1 change: 1 addition & 0 deletions debian/delphix-rust-src.install
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
usr/src/*
5 changes: 5 additions & 0 deletions debian/delphix-rust.install
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
usr/bin/*
usr/etc/*
usr/lib/*
usr/libexec/*
usr/share/*
19 changes: 14 additions & 5 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,19 @@ RUSTC_VERSION := $(shell tr -d '\n' < RUSTC_VERSION)
%:
dh $@

override_dh_install:
./scripts/fetch-and-run-installer.sh ${RUSTC_VERSION} "/usr" "debian/tmp" $(DEB_HOST_GNU_CPU)

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

override_dh_strip:
# Skip this step; use artifacts from Rust tarball as-is.
# Skip this step; use artifacts from Rust tarballs as-is.

override_dh_strip_nondeterminism:
# Skip this step; use artifacts from Rust tarballs as-is.

override_dh_makeshlibs:
# Skip this step; use artifacts from Rust tarballs as-is.

override_dh_shlibdeps:
# Skip this step; use artifacts from Rust tarballs as-is.
76 changes: 76 additions & 0 deletions scripts/fetch-and-unpack-src.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/bin/bash
#
# Copyright 2021, 2025 Delphix
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

set -o xtrace

BASEURL="https://artifactory.delphix.com/artifactory/linux-pkg/rust"

function die() {
echo "$(basename "$0"): $*" >&2
exit 1
}

function usage() {
echo "$(basename "$0"): $*" >&2
echo "Usage: $(basename "$0") <version> <prefix> <destdir> <cpu>"
exit 2
}

function cleanup() {
[[ -n "$TEMP_DIR" ]] && [[ -d "$TEMP_DIR" ]] && rm -rf "$TEMP_DIR"
}

[[ $# -gt 3 ]] && usage "too many arguments specified"
[[ $# -lt 3 ]] && usage "too few arguments specified"

VERSION="$1"
PREFIX="$2"
DESTDIR="$3"

RUST="rustc-${VERSION}-src"

[[ -z "$VERSION" ]] && usage "version not specified."
[[ -z "$PREFIX" ]] && usage "prefix not specified."
[[ -z "$DESTDIR" ]] && usage "destdir not specified."

#
# The full path is required, so DESTDIR can be used after calling "pushd" below.
#
DESTDIR="$(readlink -f "$DESTDIR")"
mkdir -p "${DESTDIR}" || die "'mkdir -p \"${DESTDIR}\"' failed"

curl -v https://keybase.io/rust/pgp_keys.asc | gpg --import ||
die "failed to import GPG key"

trap cleanup EXIT

TEMP_DIR="$(mktemp -d -t delphix-rust.XXXXXXX)"
[[ -d "$TEMP_DIR" ]] || die "failed to create temporary directory '$TEMP_DIR'"
pushd "$TEMP_DIR" &>/dev/null || die "'pushd $TEMP_DIR' failed"

wget -nv "${BASEURL}/${RUST}.tar.xz" || die "failed to download tarfile"
wget -nv "${BASEURL}/${RUST}.tar.xz.asc" || die "failed to download signature"
gpg --verify "${RUST}.tar.xz.asc" "${RUST}.tar.xz" ||
die "failed to verify signature"

mkdir -p "${DESTDIR}${PREFIX}/rustc-${VERSION}" ||
die "failed to install; 'prefix=${PREFIX}' and 'destdir=${DESTDIR}'"
tar -xvf "${RUST}.tar.xz" \
-C "${DESTDIR}${PREFIX}/rustc-${VERSION}" --strip-components 1 ||
die "failed to extract tarfile"

popd &>/dev/null || die "'popd' failed"