Skip to content

Instantly share code, notes, and snippets.

@mojotx
Last active October 26, 2017 15:26
Show Gist options
  • Save mojotx/68b3e077c118a4fc13986262b9173ff0 to your computer and use it in GitHub Desktop.
Save mojotx/68b3e077c118a4fc13986262b9173ff0 to your computer and use it in GitHub Desktop.
Workaround for godeb issue generating errors, "corrupted filesystem tarfile - corrupted package archive"
#!/bin/bash
#####################################################################
# Work-around for godeb issue
# assumes godeb is available using $GOPATH
# You can specify version on the command line,
# or else it will try and grab the latest
#####################################################################
set -e
if [ -z "${GOPATH}" ]; then
echo "error: \$GOPATH is not set" >&2
exit 1
fi
if [ ! -d "${GOPATH}" ]; then
echo "error: \$GOPATH is not a valid directory" >&2
exit 1
fi
if [ ! -x "${GOPATH}/bin/godeb" ]; then
echo "error: godeb not found in \"${GOPATH}/bin/godeb\"" >&2
echo "Please check your \$GOPATH environment variable" >&2
exit 1;
fi
test -n "$1" && VER="$1" || VER="$( ${GOPATH}/bin/godeb list | sort -n | tail -n 1 )"
do_work()
{
local WORKSPACE=$( mktemp -d )
local CYA=$( mktemp -d )
trap 'rm -rf $WORKSPACE $CYA' 0 1 2 15
cd $CYA
time ${GOPATH}/bin/godeb download ${VER}
ls -laF "$(pwd)/go_${VER}-godeb1_amd64.deb"
cd $WORKSPACE
ar x ${CYA}/go_${VER}-godeb1_amd64.deb
tar -zxf data.tar.gz
rm data.tar.gz
tar -czf data.tar.gz usr
ar r go_${VER}-godeb1_amd64.deb debian-binary control.tar.gz data.tar.gz
sudo dpkg -i ./go_${VER}-godeb1_amd64.deb
}
echo "About to download and install Go $VER using godeb, working around a known issue"
read -p "Continue? (Y/N)" REPLY
case "$REPLY" in
y*|Y*)
do_work
;;
*)
echo "Canceling!" >&2
exit 1
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment