Portability fixes, tested on OpenBSD.

This commit is contained in:
Marco Cawthorne 2023-05-07 09:37:23 -07:00
parent dcfb8e28e8
commit 205f69fb27
Signed by: eukara
GPG key ID: CE2032F0A2882A22
6 changed files with 118 additions and 43 deletions

View file

@ -26,8 +26,17 @@ find_file ()
find "./_tmp" -type f -name "${SEARCHNAME}" | while read FOUND find "./_tmp" -type f -name "${SEARCHNAME}" | while read FOUND
do do
CHECK=$(sha256sum "${FOUND}" | cut -d ' ' -f 1) # GNU vs non GNU
#echo "$CHECK == $2" if [ -x "$(command -v sha512sum)" ]
then
CHECK=$(sha256sum "$FOUND" | awk '{ print $1 }')
elif [ -x "$(command -v sha512)" ]
then
CHECK=$(sha256 -q "$FOUND")
else
echo "No tool to validate sha256 sums with!"
exit 2
fi
if [ "${CHECK}" = "$2" ] if [ "${CHECK}" = "$2" ]
then then

View file

@ -18,20 +18,27 @@ then
fi fi
PAK0_OUTDIR="$(pwd)/_build/halflife/$1-pak0" PAK0_OUTDIR="$(pwd)/_build/halflife/$1-pak0"
FINAL_TEST=$(cat "sums/$1_pak0.sha512" | cut -d ' ' -f 1) FINAL_TEST=$(cat "sums/$1_pak0.sha512" | awk '{ print $1 }')
find_file () find_file ()
{ {
SEARCHNAME=$(basename "${1}") SEARCHNAME=$(basename "${1}")
#echo "Looking for $SEARCHNAME"
if [ ! -z "$HL_STEAM_INSTALL" ] if [ ! -z "$HL_STEAM_INSTALL" ]
then then
find "$HL_STEAM_INSTALL" -type f -name "${SEARCHNAME}" | while read FOUND find "$HL_STEAM_INSTALL" -type f -name "${SEARCHNAME}" | while read FOUND
do do
CHECK=$(sha256sum "${FOUND}" | cut -d ' ' -f 1) # GNU vs non GNU
#echo "$CHECK == $2" if [ -x "$(command -v sha512sum)" ]
then
CHECK=$(sha256sum "$FOUND" | awk '{ print $1 }')
elif [ -x "$(command -v sha512)" ]
then
CHECK=$(sha256 -q "$FOUND")
else
echo "No tool to validate sha256 sums with!"
exit 2
fi
if [ "${CHECK}" = "$2" ] if [ "${CHECK}" = "$2" ]
then then
@ -49,8 +56,17 @@ find_file ()
find "./_tmp" -type f -name "${SEARCHNAME}" | while read FOUND find "./_tmp" -type f -name "${SEARCHNAME}" | while read FOUND
do do
CHECK=$(sha256sum "${FOUND}" | cut -d ' ' -f 1) # GNU vs non GNU
#echo "$CHECK == $2" if [ -x "$(command -v sha512sum)" ]
then
CHECK=$(sha256sum "$FOUND" | awk '{ print $1 }')
elif [ -x "$(command -v sha512)" ]
then
CHECK=$(sha256 -q "$FOUND")
else
echo "No tool to validate sha256 sums with!"
exit 2
fi
if [ "${CHECK}" = "$2" ] if [ "${CHECK}" = "$2" ]
then then
@ -80,8 +96,8 @@ fi
while read LINE while read LINE
do do
FILE=$(echo ${LINE} | cut -d ' ' -f 2) FILE=$(echo ${LINE} | awk '{ print $2 }')
SUM=$(echo ${LINE} | cut -d ' ' -f 1) SUM=$(echo ${LINE} | awk '{ print $1 }')
find_file ${FILE} $SUM $1 find_file ${FILE} $SUM $1
done < "games/$1-pak0.sha256" done < "games/$1-pak0.sha256"
@ -92,7 +108,17 @@ cp -v "games/$1.dat" "$PAK0_OUTDIR/src/files.dat"
cd "$PAK0_OUTDIR/src/" cd "$PAK0_OUTDIR/src/"
qfiles -pak 0 qfiles -pak 0
FINAL_CHECK=$(sha512sum "$PAK0_OUTDIR/pak0.pak" | cut -d ' ' -f 1) # GNU vs non GNU
if [ -x "$(command -v sha512sum)" ]
then
FINAL_CHECK=$(sha512sum "$PAK0_OUTDIR/pak0.pak" | awk '{ print $1 }')
elif [ -x "$(command -v sha512)" ]
then
FINAL_CHECK=$(sha512 -q "$PAK0_OUTDIR/pak0.pak")
else
echo "No tool to validate sha512 sums with!"
exit 2
fi
echo "Desired SHA512: ${FINAL_TEST}" echo "Desired SHA512: ${FINAL_TEST}"
echo "Generated SHA512: ${FINAL_CHECK}" echo "Generated SHA512: ${FINAL_CHECK}"

View file

@ -2,6 +2,27 @@
set -e set -e
MAKEVER=$(make --version | awk '{ print $1 }' | head -n 1)
# is this GNU?
if [ "$MAKEVER" = "GNU" ]
then
MAKETOOL="make"
else
# guess not, do we have gmake?
if [ -x "$(command -v gmake)" ]
then
MAKEVER=$(gmake --version | awk '{ print $1 }' | head -n 1)
if [ "$MAKEVER" = "GNU" ]
then
MAKETOOL="gmake"
else
echo "Please install GNU Make."
exit 2
fi
fi
fi
DEPSDIR="$(pwd)/_deps" DEPSDIR="$(pwd)/_deps"
BINDIR="$(pwd)/_bin" BINDIR="$(pwd)/_bin"
INCTOOLDIR="$(pwd)/tools" INCTOOLDIR="$(pwd)/tools"
@ -20,23 +41,23 @@ mkdir "$DEPSDIR"
mkdir "$BINDIR" mkdir "$BINDIR"
cd "$DEPSDIR" cd "$DEPSDIR"
git clone https://notabug.org/CYBERDEViL/REWise git clone https://vcs.vera-visions.com/eukara/REWise
cd REWise cd REWise
make $MAKETOOL CC=cc
mv -v rewise "$BINDIR/rewise" mv -v rewise "$BINDIR/rewise"
cd "$DEPSDIR" cd "$DEPSDIR"
git clone https://github.com/RavuAlHemio/hllib git clone https://vcs.vera-visions.com/eukara/HLLib
cd hllib/HLLib cd HLLib/HLLib
make $MAKETOOL CC=cc CXX=c++
cd ../HLExtract cd ../HLExtract
make $MAKETOOL CC=cc CXX=c++
mv -v hlextract "$BINDIR/hlextract" mv -v hlextract "$BINDIR/hlextract"
cd "$DEPSDIR" cd "$DEPSDIR"
git clone https://github.com/yquake2/pakextract git clone https://github.com/yquake2/pakextract
cd pakextract cd pakextract
make CC=cc $MAKETOOL CC=cc
mv -v pakextract "$BINDIR/pakextract" mv -v pakextract "$BINDIR/pakextract"
cd "$INCTOOLDIR/bmpfix" cd "$INCTOOLDIR/bmpfix"

View file

@ -6,7 +6,7 @@ set -e
fetch_resource() fetch_resource()
{ {
BASENAME=$(basename "$1") BASENAME=$(basename "$1")
SHA512FILE=$(cat "./sums/$BASENAME.sha512") SHA512FILE=$(cat "./sums/$BASENAME.sha512" | awk '{ print $1 }')
if [ ! -f "$BASENAME" ] if [ ! -f "$BASENAME" ]
then then
@ -15,7 +15,17 @@ fetch_resource()
printf "\n" printf "\n"
fi fi
SHA512SUM=$(sha512sum "$BASENAME") # GNU vs non GNU
if [ -x "$(command -v sha512sum)" ]
then
SHA512SUM=$(sha512sum "$BASENAME" | awk '{ print $1 }')
elif [ -x "$(command -v sha512)" ]
then
SHA512SUM=$(sha512 -q "$BASENAME")
else
echo "No tool to validate sha512 sums with!"
exit 2
fi
if [ "$SHA512SUM" = "$SHA512FILE" ] if [ "$SHA512SUM" = "$SHA512FILE" ]
then then

View file

@ -13,12 +13,6 @@ x_rewise()
rewise -x "./_tmp/$1" "$1" rewise -x "./_tmp/$1" "$1"
} }
sz_extract()
{
7z x "$1"
}
# clean up # clean up
if [ -d "./_tmp" ] if [ -d "./_tmp" ]
then then
@ -31,8 +25,9 @@ x_rewise "hluplink.exe"
x_rewise "hl1110.exe" x_rewise "hl1110.exe"
x_rewise "opfordemofull.exe" x_rewise "opfordemofull.exe"
x_rewise "hl_sdk_v23.exe" x_rewise "hl_sdk_v23.exe"
x_rewise "of1108.exe"
x_rewise "steaminstall_halflife.exe" x_rewise "steaminstall_halflife.exe"
#x_rewise "steaminstall_opfor.exe" x_rewise "steaminstall_opfor.exe"
mkdir -p "./_tmp/hluplink-pak0" mkdir -p "./_tmp/hluplink-pak0"
pakextract -o "./_tmp/hluplink-pak0" "./_tmp/hluplink.exe/MAINDIR/valve/pak0.PAK" pakextract -o "./_tmp/hluplink-pak0" "./_tmp/hluplink.exe/MAINDIR/valve/pak0.PAK"
@ -40,19 +35,22 @@ pakextract -o "./_tmp/hluplink-pak0" "./_tmp/hluplink.exe/MAINDIR/valve/pak0.PAK
mkdir -p "./_tmp/opfordemofull-pak0" mkdir -p "./_tmp/opfordemofull-pak0"
pakextract -o "./_tmp/opfordemofull-pak0" "./_tmp/opfordemofull.exe/MAINDIR/valve/pak0.PAK" pakextract -o "./_tmp/opfordemofull-pak0" "./_tmp/opfordemofull.exe/MAINDIR/valve/pak0.PAK"
mkdir -p "./_tmp/opfordemofull-gbpak0"
pakextract -o "./_tmp/opfordemofull-gbpak0" "./_tmp/opfordemofull.exe/MAINDIR/gearbox/pak0.PAK"
mkdir -p "./_tmp/half-life.gcf" mkdir -p "./_tmp/half-life.gcf"
hlextract -p "./_tmp/steaminstall_halflife.exe/MAINDIR/SteamApps/half-life.gcf" -d "./_tmp/half-life.gcf" -e "root/valve/" hlextract -p "./_tmp/steaminstall_halflife.exe/MAINDIR/SteamApps/half-life.gcf" -d "./_tmp/half-life.gcf" -e "root/valve/"
#mkdir -p "./_tmp/opposing force.gcf" mkdir -p "./_tmp/opposing force.gcf"
#hlextract -p "./_tmp/steaminstall_opfor.exe/MAINDIR/SteamApps/opposing force.gcf" -d "./_tmp/opposing force.gcf" -e "root/gearbox/" hlextract -p "./_tmp/steaminstall_opfor.exe/MAINDIR/SteamApps/opposing force.gcf" -d "./_tmp/opposing force.gcf" -e "root/gearbox/"
./ccase.sh -r "./_tmp" ./ccase.sh -r "./_tmp"
# if anything goes wrong here, it's probably imagemagick messing with the image # if anything goes wrong here, it's probably imagemagick messing with the image
if [ ! -x "$(command -v magick)" ]; then convert "./_tmp/hluplink-pak0/gfx/shell/btns_main.bmp" -compress none -crop 156x4836+0+0 BMP3:"./_tmp/hluplink-pak0/btns_main.bmp"
convert "./_tmp/hluplink-pak0/gfx/shell/btns_main.bmp" -compress none -crop 156x4836+0+0 BMP3:"./_tmp/btns_main.bmp" convert "./_tmp/of1108.exe/maindir/gearbox/gfx/shell/btns_main.bmp" -compress none -crop 156x5382+0+0 BMP3:"./_tmp/of1108.exe/btns_main.bmp"
else
magick "./_tmp/hluplink-pak0/gfx/shell/btns_main.bmp" -compress none -crop 156x4836+0+0 BMP3:"./_tmp/btns_main.bmp"
fi
bmpfix "./_tmp/hl1110.exe/maindir/valve/models/player/hgrunt/hgrunt.bmp" bmpfix "./_tmp/hl1110.exe/maindir/valve/models/player/hgrunt/hgrunt.bmp"
sed -i '/slot6,/d' "./_tmp/opfordemofull-pak0/gfx/shell/kb_act.lst"
sed -i '/slot7,/d' "./_tmp/opfordemofull-pak0/gfx/shell/kb_act.lst"

View file

@ -2,25 +2,36 @@
set -e set -e
# some sanity checks before we continue # some sanity checks before we continue
if [ ! -x "$(command -v make)" ]; then if [ ! -x "$(command -v make)" ]
then
echo "make not found. Please install GNU make." echo "make not found. Please install GNU make."
exit 2 exit 2
fi fi
if [ ! -x "$(command -v cc)" ]; then if [ ! -x "$(command -v cc)" ]
then
echo "cc not found. Please install a C compiler." echo "cc not found. Please install a C compiler."
exit 2 exit 2
fi fi
if [ ! -x "$(command -v wget)" ]; then if [ ! -x "$(command -v wget)" ]
then
echo "wget not found. Please install wget." echo "wget not found. Please install wget."
exit 2 exit 2
fi fi
if [ ! -x "$(command -v magick)" ]; then if [ ! -x "$(command -v convert)" ]
if [ ! -x "$(command -v convert)" ]; then then
echo "magick/convert not found. Please install ImageMagick or higher." echo "magick/convert not found. Please install ImageMagick or higher."
exit 2 exit 2
fi
if [ ! -x "$(command -v sha512sum)" ]
then
if [ ! -x "$(command -v sha512)" ]
then
echo "sha512 or sha512sum not found."
exit 2
fi fi
fi fi