Last active
June 13, 2018 00:29
-
-
Save darealshinji/67b7705d186a5e4bc8e0438aa339b7a1 to your computer and use it in GitHub Desktop.
This file contains 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 | |
set -e | |
export LANG=C | |
monopath="/usr/lib/mono/4.5" | |
file="$1" | |
need="/tmp/need.log" | |
out="bundle" | |
if [ ! -e "$file" ]; then | |
echo "error: cannot find file \`$file'" | |
exit 1 | |
fi | |
if [ "x$(printf "$file" | tail -c-4)" != "x.exe" ]; then | |
echo "error: not a .exe file extension" | |
exit 1 | |
fi | |
mkdir $out | |
monodis --assemblyref "$file" | sed -n 's@^\tName=@@p' > $need | |
cp -vf "$file" $out | |
while [ -f $need ]; do | |
for a in `cat $need` ; do | |
if [ -e "${a}.dll" ]; then | |
cp -vf "${a}.dll" $out | |
elif [ -e "$monopath/${a}.dll" ]; then | |
cp -vf "$monopath/${a}.dll" $out | |
fi | |
sed -i "/^${a}$/d" $need | |
if [ -e "$out/${a}.dll" ]; then | |
deps=$(monodis --assemblyref "$out/${a}.dll" | sed -n 's@^\tName=@@p') | |
for d in $deps ; do | |
if [ ! -e "$out/${d}.dll" ] && [ "x$(grep -Fx $d $need)" = "x" ]; then | |
echo "$d" >> $need | |
fi | |
done | |
else | |
echo "Missing: ${a}.dll" | |
exit 1 | |
fi | |
sort $need | uniq > ${need}_ | |
mv -f ${need}_ $need | |
if [ "x$(wc -l <$need)" = "x0" ]; then | |
rm -f $need | |
fi | |
done | |
done | |
cd $out | |
mkdir lib | |
sed -e 's@/usr/lib/@@g' /etc/mono/config > config | |
cp -vf /usr/bin/mono-sgen . | |
cp -vf /usr/lib/libMonoPosixHelper.so lib | |
cp -vf /usr/lib/libgdiplus.so.0 lib | |
wget -q "https://raw.githubusercontent.com/AppImage/AppImages/master/functions.sh" | |
. ./functions.sh | |
copy_deps | |
move_lib | |
delete_blacklisted | |
mkdir lib | |
mv -vf `find ./usr -type f` lib | |
ln -s libgdiplus.so.0 lib/libgdiplus.so | |
rm -rvf functions.sh usr | |
cat <<EOF> run.sh | |
#!/bin/sh | |
cd "\$(dirname "\$(readlink -f "\$0")")" | |
LD_LIBRARY_PATH="\$PWD/lib" MONO_PATH="\$PWD" ./mono-sgen --config config "$(basename "$file")" \$@ | |
EOF | |
chmod a+x run.sh | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment