-
-
Save khromalabs/f35c0b491fc24d1776d6bd6b8a71296c to your computer and use it in GitHub Desktop.
DPM Dosbox Package Manager v.0.1
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 -eu | |
ME="${0##*/}" | |
PWDROM="/home/ruben/Juegos/dosbox/rom" | |
EXTROM=".tar.zst" | |
INFO="Dosbox Package Manager\nUse: $ME <action> [<rom_package>|<directory>]\nAvailable actions:\n launch <romfile>: Launch a rom package in dosbox\n list: List roms\n pack <directory>: Compress a game into a rom package\n unpack <romfile>: Decompresses a rom package into a directory\nLibrary location: \"$PWDROM\"\n" | |
if [ "$#" -lt 1 ]; then | |
echo -e "$INFO" | |
exit | |
fi | |
launch() { | |
# Clean any path in ROM name | |
ROMPACK=$(basename -- "$1") | |
if [ ! -f "$PWDROM/$ROMPACK" ]; then | |
echo "$ME: Game rom pack '$PWDROM/$ROMPACK' doesn't exist" | |
return | |
fi | |
TMPDIR="/dev/shm/dosbox/${ROMPACK%%.*}" | |
mkdir -p "$TMPDIR" | |
cd "$TMPDIR" | |
bsdtar xf "$PWDROM/$ROMPACK" | |
dosbox -conf "${ROMPACK%%.*}.dosboxconf" | |
rm -r /dev/shm/dosbox | |
} | |
pack() { | |
PACKDIR="$PWDROM/$1" | |
if [ ! -d "$PACKDIR" ]; then | |
echo "$ME: Game directory doesn't exist" | |
return | |
fi | |
cd "$PWDROM/$1" | |
bsdtar --zstd --options zstd:compression-level=19,zstd:threads=0 -cf "../${1%/}$EXTROM" -- * | |
cd .. | |
rm -r "$1" | |
} | |
unpack() { | |
if [ ! -f "$PWDROM/$1" ]; then | |
echo "$ME: Game rom pack doesn't exist" | |
return | |
fi | |
UNPACKDIR="$PWDROM/${1%%.*}" | |
mkdir "$UNPACKDIR" | |
cd "$UNPACKDIR" | |
bsdtar xf "$PWDROM/$1" | |
} | |
list() { | |
ls -1 "$PWDROM" | |
} | |
case "$1" in | |
list) $1;; | |
pack|unpack|launch) [ "$#" -gt 1 ] && $1 "$2" || echo -e "$INFO";; | |
*) echo "$INFO";; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is an attempt to emulate thought a script the game packing functionality implemented in Dosbox-Pure , games are packed in tar.zst files which are quickly unpacked in /dev/shm (RAM) and the program expects a .dosboxconf file in the root of the packed file which will use to launch the game. Works pretty well for me, still lacks saving any change occurred during the game I plan to do that in the future as there are some tools available for that in the command line stack.