Skip to content

Instantly share code, notes, and snippets.

@jordansissel
Last active November 10, 2021 14:28
Show Gist options
  • Save jordansissel/0e0fc22344a17eadd1a3b9a1bbb7ed60 to your computer and use it in GitHub Desktop.
Save jordansissel/0e0fc22344a17eadd1a3b9a1bbb7ed60 to your computer and use it in GitHub Desktop.
Convert curl|bash to an rpm with Docker and FPM
% docker build -t rust .
...
# Export the image to tarball, which itself contains tarballs and a manifest.json
% docker save -o rust.tar rust
# Extract the last layer
# tar's -O flag extracts a single entry from the tarball.
# The file we want is the last "Layer" in the manifest.json
% tar -xf rust.tar -O $(tar -xf rust.tar -O manifest.json | jq -r '.[].Layers[-1]') > curlbash.tar
# Use fpm to convert it to an rpm
% fpm -s tar -t rpm -n rustup -C /home/builder/.rustup --prefix /usr/local/share curlbash.tar
Created package {:path=>"rustup-1.0-1.x86_64.rpm"}
# Check the rpm for joyful files.
% rpm -qp rustup-1.0-1.x86_64.rpm -l | less | grep bin/
/usr/local/share/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo
/usr/local/share/toolchains/stable-x86_64-unknown-linux-gnu/bin/rust-gdb
/usr/local/share/toolchains/stable-x86_64-unknown-linux-gnu/bin/rust-lldb
/usr/local/share/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc
/usr/local/share/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustdoc
% sudo rpm -i rustup-1.0-1.x86_64.rpm
% /usr/local/share/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc -h
Usage: rustc [OPTIONS] INPUT
Options:
-h, --help Display this message
...
% sudo rpm -e rustup
👍
👍
👍
from centos:7
RUN useradd builder
USER builder
# curl | sh, but also delete rust docs to make this demo shorter.
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y; \
rm -r ~/.rustup/toolchains/*/share/doc/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment