Skip to content

Instantly share code, notes, and snippets.

@mikeytown2
Created December 13, 2021 17:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikeytown2/1e79d758206a663b2b277585dc4e51a2 to your computer and use it in GitHub Desktop.
Save mikeytown2/1e79d758206a663b2b277585dc4e51a2 to your computer and use it in GitHub Desktop.
#!/bin/bash
# This will get the latest ghostscript linux 64bit release.
# Requires jq and wget
# Get a new copy of the github latest release if the mtime is older than 1 day.
if [[ ! -f ghostpdl-downloads.js || $(find "ghostpdl-downloads.js" -mtime +1 -print) ]]
then
echo "Getting the latest ghostscript release from github."
rm -f ghostpdl-downloads.js
wget -O ghostpdl-downloads.js https://api.github.com/repos/ArtifexSoftware/ghostpdl-downloads/releases/latest -q
# Set mtime to now.
touch ghostpdl-downloads.js
fi
# Get the ghostscript url.
NEW_NAME=$( cat ghostpdl-downloads.js | jq '.assets[].name' | grep 'ghostscript' | grep 'linux-x86_64.tgz' | tr -d '"' )
URL=$( cat ghostpdl-downloads.js | jq ".assets[] | select(.name == \"${NEW_NAME}\") | .browser_download_url" | tr -d '"' )
FILENAME=$( basename "${URL}" )
if [[ ! -f "${FILENAME}" ]]
then
echo "downloading ${URL}"
wget "${URL}" -q
fi
echo "extracting ${FILENAME}."
EXEC_FILE=$( tar -ztvf "${FILENAME}" | grep "^\-..x" | awk '{print $6}' )
FILENAME=$( tar zxvf "${FILENAME}" "${EXEC_FILE}" )
CURRENT_DIR=$( pwd )
mv "${FILENAME}" "${CURRENT_DIR}/gs"
echo "cleaning up unneeded files."
FOLDER=$( dirname "${FILENAME}" )
rm -rf "${FOLDER}"
echo "running ldd ${CURRENT_DIR}/gs."
ldd "${CURRENT_DIR}/gs"
echo "running ${CURRENT_DIR}/gs."
${CURRENT_DIR}/gs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment