Skip to content
Snippets Groups Projects
Commit aed034de authored by Ben Gamari's avatar Ben Gamari
Browse files

gitlab/upload: Rework recompression

The old `combine` approach was quite fragile due to use of filename
globbing. Moreover, it didn't parallelize well. This refactoring
makes the goal more obvious, parallelizes better, and is more robust.
parent 39c2a630
No related branches found
No related tags found
No related merge requests found
......@@ -27,6 +27,15 @@ let
buildCommand = ''
mkdir -p $out/bin
makeWrapper ${./recompress-all} $out/bin/recompress-all \
--prefix PATH : ${gnumake}/bin \
--prefix PATH : ${gnutar}/bin \
--prefix PATH : ${lzip}/bin \
--prefix PATH : ${bzip2}/bin \
--prefix PATH : ${gzip}/bin \
--prefix PATH : ${xz}/bin \
--prefix PATH : ${zip}/bin
makeWrapper ${./upload.sh} $out/bin/upload.sh \
--prefix PATH : ${moreutils}/bin \
--prefix PATH : ${lftp}/bin \
......@@ -35,8 +44,8 @@ let
--prefix PATH : ${s3cmd}/bin \
--prefix PATH : ${gnupg}/bin \
--prefix PATH : ${pinentry}/bin \
--prefix PATH : ${parallel}/bin \
--prefix PATH : ${python3}/bin \
--prefix PATH : $out/bin \
--set ENTER_FHS_ENV ${bindistPrepEnv}/bin/enter-fhs \
--set BASH ${bash}/bin/bash
......
#!/usr/bin/env -S make -f
MAKEFLAGS += --no-builtin-rules
MAKEFLAGS += --no-builtin-variables
usage :
echo "recompress [dest files]"
exit 1
%.gz : %.xz
echo "[xz->gz] $< to $@..."
xz -c $< | gzip -c > $@
%.bz2 : %.xz
echo "[xz->bz2] $< to $@..."
xz -c $< | bzip2 -c > $@
%.lz : %.xz
echo "[xz->lz] $< to $@..."
xz -c $< | lzip -c > $@
%.zip : %.tar.xz
echo "[tarxz->zip] $< to $@..."
tmp="$(mktemp tmp.XXX)" && \
tar -C "$$tmp" -xf $< && \
cd "$$tmp" && \
zip -9 -r $@ * && \
rm -R "$$tmp"
......@@ -193,29 +193,21 @@ function prepare_docs() {
function recompress() {
set -Eeuo pipefail
combine <(basename -s .xz *.xz) not <(basename -s .lz *.lz) | \
parallel 'echo "Recompressing {}.xz to {}.lz"; unxz -c {}.xz | lzip - -o {}.lz'
for darwin_bindist in $(ls ghc-*-darwin.tar.xz); do
local dest="$(basename $darwin_bindist .xz).bz2"
if [[ ! -f "$dest" ]]; then
echo "Recompressing Darwin bindist to bzip2..."
unxz -c "$darwin_bindist" | bzip2 > "$dest"
fi
needed=()
for i in ghc-*.tar.xz; do
needed+=( "$(basename $i .xz).gz" )
done
for windows_bindist in $(ls ghc-*-mingw32*.tar.xz); do
local tmp="$(mktemp -d tmp.XXX)"
local dest="$(realpath $(basename $windows_bindist .tar.xz).zip)"
echo $dest
if [[ ! -f "$dest" ]]; then
echo "Recompressing Windows bindist to zip..."
tar -C "$tmp" -xf "$windows_bindist"
ls $tmp
(cd "$tmp"; zip -9 -r "$dest" *)
fi
rm -R "$tmp"
for i in ghc-*-darwin.tar.xz; do
needed+=( "$(basename $i .xz).bz2" )
done
for i in ghc-*-mingw32.tar.xz; do
needed+=( "$(basename $i .tar.xz).zip" )
done
recompress-all -l ${needed[@]}
}
function upload_docs() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment