Last active
December 12, 2015 06:59
-
-
Save cryptorick/4733708 to your computer and use it in GitHub Desktop.
extract-file-from-sbcl-msi -- If you don't have admin privs on your Windoze machine but would like to install the SBCL msi (which contains pre-built Windoze binaries), you can use this script to extract the files and (original) directory structure. The true pathnames of the files are encoded by the msi by replacing the path separator '/' with '_…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# extract-file-from-sbcl-msi -- If you don't have admin privs on your | |
# Windoze machine but would like to install the SBCL msi (which contains | |
# pre-built Windoze binaries), you can use this script to extract the | |
# files and (original) directory structure. The true pathnames of the | |
# files are encoded by the msi by replacing the path separator '/' with | |
# '_'; hyphens, '-', in filenames are replaced with '.'; and every file | |
# that has a pathname (lives in the subdirectory) has its pathname | |
# additionally encoded by prepending the pathname with 'File_'. The | |
# script undoes all of that by performing the reverse transform of what | |
# was just described above. | |
# | |
# Additional requirements: cygwin (this script uses the 'cygpath' | |
# program) and 7-zip (7z.exe). | |
# | |
# Rick Hanson, 7 Feb 2013. | |
# | |
if (( $# < 1 )); then | |
echo "Usage: ${0##*/} msi-file-path [target-directory]" >&2 | |
exit 42 | |
fi | |
_msi_file=$1 | |
if (( $# > 1 )); then | |
_target_dir=$2 | |
else | |
_msi_base=${_msi_file##*/} # Get msi file's basename. | |
_target_dir=${_msi_base%.*} # Remove extension (.msi). | |
fi | |
mkdir -p ${_target_dir} && cd ${_target_dir} | |
# Convert pathname to Windoze format, so that 7z likes it. | |
_msi=$(cygpath -m ${_msi_file}) | |
7z x ${_msi} || exit 43 | |
for f in File_*; do | |
g=${f#File_} # Remove File_ prefix. | |
h=${g//_/\/} # Replace remaining '_' with '/' (path separator). | |
hd=${h%/*} # Extract working directory path. | |
hb=${h##*\/} # Extract working basename. | |
he=${hb##*.} # Extract working extension. | |
hbb=${hb%.*} # Extract working bare basename (basename w/o extension). | |
# Working bare basenames will equal working extensions for filenames | |
# that have no extensions, e.g. Makefile or README. In this case, set | |
# the working extension to the null string (signifying no extension). | |
[ "$hbb" == "$he" ] && he="" | |
d=${hd//./-} # Replace '.' with '-' to get directory path. | |
bb=${hbb//./-} # Replace '.' with '-' to get bare basename. | |
# An empty working extension translates to an empty extension. A | |
# non-empty working extension transforms to an extension by prepending | |
# a '.' to it. | |
if [ -z "$he" ]; then e=$he; else e=.$he; fi | |
# Now go forth and rename files, creating the directory structure as | |
# you go. Tell the user what you are doing. | |
tgt=$d/$bb$e | |
echo "Processing file $tgt." >&2 | |
[ -d $d ] || mkdir -p $d | |
mv $f $tgt | |
done | |
# Handle any exceptions to the encoding/decoding described above. | |
mv contrib/sb-posix/constants-lisp.temp contrib/sb-posix/constants.lisp-temp | |
mv contrib/sb-bsd-sockets/constants-lisp.temp contrib/sb-bsd-sockets/constants.lisp-temp | |
echo -n "Installing sbcl script (batch file) . . . " >&2 | |
cat <<'EOF' > sbcl.bat | |
@echo off | |
set SBCLLOC=%~dp0 | |
set SBCL_HOME=%SBCLLOC%contrib | |
%SBCLLOC%sbcl --core %SBCLLOC%sbcl.core | |
EOF | |
chmod +x sbcl.bat | |
echo "done." >&2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment