Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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/
% 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
-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 -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