[game-data-packager] 02/02: Use Python/YAML for all quake modes except music
Simon McVittie
smcv at debian.org
Sun Jan 4 18:39:07 UTC 2015
This is an automated email from the git hooks/post-receive script.
smcv pushed a commit to branch wip/quake
in repository game-data-packager.
commit f40dfd686dad1058dedc44d67c004b4caa1b3d6f
Author: Simon McVittie <smcv at debian.org>
Date: Sat Jan 3 20:34:48 2015 +0000
Use Python/YAML for all quake modes except music
---
Makefile | 4 +
data/quake.yaml | 4 +-
lib/game_data_packager/__init__.py | 42 +++---
supported/quake | 262 ++-----------------------------------
4 files changed, 42 insertions(+), 270 deletions(-)
diff --git a/Makefile b/Makefile
index 623a98b..4d91abf 100644
--- a/Makefile
+++ b/Makefile
@@ -6,6 +6,10 @@ default: $(DIRS)
gzip -nc9 debian/changelog > ./out/changelog.gz
chmod 0644 ./out/changelog.gz
install -m644 data/*.yaml out/
+ ln -sf quake.yaml out/quake-registered.yaml
+ ln -sf quake.yaml out/quake-shareware.yaml
+ ln -sf quake.yaml out/quake-armagon.yaml
+ ln -sf quake.yaml out/quake-dissolution.yaml
install -m644 data/*.copyright out/
install -m755 data/*.preinst out/
install -m755 data/*.postinst out/
diff --git a/data/quake.yaml b/data/quake.yaml
index e6ce670..bf553e2 100644
--- a/data/quake.yaml
+++ b/data/quake.yaml
@@ -47,7 +47,6 @@ files:
hipnotic/pak0.pak_cd:
look_for:
- hipnotic/pak0.pak
- distinctive_name: false
size: 35527205
# http://speeddemosarchive.com/quake/qdq/movies/sds.html
@@ -55,6 +54,9 @@ files:
look_for:
- hipnotic/pak0.pak
distinctive_name: false
+ # don't whine about files that don't match this: we don't know its
+ # correct size and the non-matching file is probably the genuine pak0.pak
+ skip_mismatch_warning: true
id1/pak0.pak_106:
install_as: id1/pak0.pak
diff --git a/lib/game_data_packager/__init__.py b/lib/game_data_packager/__init__.py
index f8098b9..7fc9197 100644
--- a/lib/game_data_packager/__init__.py
+++ b/lib/game_data_packager/__init__.py
@@ -158,6 +158,7 @@ class WantedFile(HashedFile):
self.optional = False
self._provides = set()
self._size = None
+ self.skip_mismatch_warning = False
self.unpack = None
@property
@@ -199,6 +200,7 @@ class WantedFile(HashedFile):
'provides': list(self.provides),
'size': self.size,
'skip_hash_matching': self.skip_hash_matching,
+ 'skip_mismatch_warning': self.skip_mismatch_warning,
'unpack': self.unpack,
}
@@ -483,6 +485,7 @@ class GameData(object):
'sha256',
'size',
'skip_hash_matching',
+ 'skip_mismatch_warning',
'unpack',
):
if k in data:
@@ -517,25 +520,26 @@ class GameData(object):
progress=(size > QUITE_LARGE))
if not wanted.skip_hash_matching and not hashes.matches(wanted):
- logger.warning('found possible %s\n' +
- 'but its checksums do not match:\n' +
- ' file: %s\n' +
- ' expected:\n' +
- ' md5: %s\n' +
- ' sha1: %s\n' +
- ' sha256: %s\n' +
- ' got:\n' +
- ' md5: %s\n' +
- ' sha1: %s\n' +
- ' sha256: %s',
- wanted.name,
- path,
- wanted.md5,
- wanted.sha1,
- wanted.sha256,
- hashes.md5,
- hashes.sha1,
- hashes.sha256)
+ if not wanted.skip_mismatch_warning:
+ logger.warning('found possible %s\n' +
+ 'but its checksums do not match:\n' +
+ ' file: %s\n' +
+ ' expected:\n' +
+ ' md5: %s\n' +
+ ' sha1: %s\n' +
+ ' sha256: %s\n' +
+ ' got:\n' +
+ ' md5: %s\n' +
+ ' sha1: %s\n' +
+ ' sha256: %s',
+ wanted.name,
+ path,
+ wanted.md5,
+ wanted.sha1,
+ wanted.sha256,
+ hashes.md5,
+ hashes.sha1,
+ hashes.sha256)
return False
logger.debug('... yes, looks good')
diff --git a/supported/quake b/supported/quake
index 2fbffd5..4dd4b51 100644
--- a/supported/quake
+++ b/supported/quake
@@ -3,16 +3,6 @@
SHORTNAME=quake
LONGNAME="Quake (including mission packs)"
-IDMIRRORFILE=/etc/game-data-packager/idstuff-mirrors
-
-if [ "$0" = "./game-data-packager" ]; then
- IDMIRRORFILE="./etc/idstuff-mirrors"
-fi
-
-quake106_zip_sha256=ec6c9d34b1ae0252ac0066045b6611a7919c2a0d78a3a66d9387a8f597553239
-quake_pak0sum_106=5906e5998fc3d896ddaf5e6a62e03abb
-quake_pak0sum_101=85fc9cee2035b66290da1e33be2ac86b
-
quake_usage() {
printf "game-data-packager ${SHORTNAME} [-m|-d|-mp1|-mp2] <path>\n\
game-data-packager ${SHORTNAME} -s [<path>]\n\
@@ -34,12 +24,6 @@ game-data-packager ${SHORTNAME} -c [<device>]\n\
"
}
-get_mirror () {
- (
- grep -v '^#' "${IDMIRRORFILE}" | sed 's#$#/quake#'
- ) | sort -R | head -n1
-}
-
copyin () {
install -d `dirname "$2"`
install -m644 "$1" "$2"
@@ -105,12 +89,6 @@ verify_args() {
}
go() {
- # Not the default because it doesn't yet support music
- if [ -n "$GDP_PREFER_YAML" ]; then
- . $LIBDIR/via-python
- gdp_data_driven quake "$@"
- return $?
- fi
verify_args "$@"
case "$method" in
@@ -118,19 +96,20 @@ go() {
guess_method
;;
"cdrom")
- cdrom_method
+ python_method quake-registered "$mountpoint"
;;
"dir")
- dir_method
+ python_method quake-registered "$mountpoint"
;;
"swzip")
- swzip_method
+ # mountpoint is optional here
+ python_method quake-shareware ${mountpoint:+"${mountpoint}"}
;;
"mp1")
- mp1_method
+ python_method quake-armagon "$mountpoint"
;;
"mp2")
- mp2_method
+ python_method quake-dissolution "$mountpoint"
;;
"music"|"mp1-music"|"mp2-music")
music_method "$method" "$mountpoint"
@@ -142,27 +121,7 @@ go() {
}
guess_method() {
- if [ -f "$mountpoint" ]; then
- debug "treating $mountpoint like a shareware ZIP"
- method="swzip"
- swzip_method
- elif [ -f "$(ifind "$mountpoint" "id1/pak0.pak")" ]; then
- debug "treating $mountpoint like an installed directory"
- method="dir"
- dir_method
- elif [ -f "$mountpoint/q101_int.1" ]; then
- debug "treating $mountpoint like a CD-ROM"
- method="cdrom"
- cdrom_method
- elif [ -f "$mountpoint/hipnotic/pak0.pak" ]; then
- debug "treating $mountpoint like a Scourge of Armagon directory or CD"
- method="mp1"
- mp1_method
- elif [ -f "$mountpoint/rogue/pak0.pak" ]; then
- debug "treating $mountpoint like a Dissolution of Eternity directory or CD"
- method="mp2"
- mp2_method
- elif [ -b "$mountpoint" ]; then
+ if [ -b "$mountpoint" ]; then
printf "Unable to determine which CD-ROM is at $mountpoint.\n\
For Quake 1 please use:\n\
\t$0 $SHORTNAME --music $mountpoint\n\
@@ -173,211 +132,14 @@ For Mission Pack 2, Dissolution of Eternity please use:\n\
" >&2
die "Please specify --music, --mp1-music or --mp2-music."
else
- die "couldn't figure out what method to use for mountpoint $mountpoint"
- fi
-}
-
-unpack_quake106_pak0 () {
- require_program lha lhasa
- mirror=
-
- set +u
- zipfile="$1"
- set -u
-
- if [ -n "$zipfile" ]; then
- :
- elif [ -f "$WORKDIR/quake106.zip" ]; then
- zipfile="$WORKDIR/quake106.zip"
- else
- zipfile="$WORKDIR/quake106.zip"
- echo "downloading quake106.zip..." >&2
- mirror=`get_mirror`
- wget -O "$zipfile" "$mirror/quake106.zip" >&2
- fi
-
- exp=$quake106_zip_sha256
- real=`sha256sum -b "$zipfile" | cut -d ' ' -f1`
-
- if [ "x$real" != "x$exp" ]; then
- warn "$zipfile sha256sum does not match expected value"
- [ -z "$mirror" ] || warn "downloaded: $mirror/quake106.zip"
- warn "expected: $exp"
- warn " got: $real"
- die "please obtain a correct copy of quake106.zip" 1
- fi
-
- (
- cd "$WORKDIR"
- gdp_unzip_paths "$zipfile" . resource.1
- mv resource.1 resource.exe
- lha xq resource.exe id1/pak0.pak
- rm resource.exe
- )
-
- pak0="$WORKDIR/id1/pak0.pak"
-}
-
-# check that the pak0/pak1 for original Quake are recognised.
-# detect older versions and automatically replace with 1.06
-verify_quake() {
- pak1sum=d76b3e5678f0b64ac74ce5e340e6a685 # 1.06
- pak1sum=$pak1sum,d76b3e5678f0b64ac74ce5e340e6a685 # 1.01
-
- verify_file "$pak0"
- [ "$pak1" = "" ] || verify_file "$pak1"
-
- # pak0 for shareware or registered Quake 1.06 is identical, and the
- # 1.01 to 1.06 patch only upgrades pak0 anyway, so if we find
- # that we have a 1.01 pak0, we can quietly upgrade it to 1.06
- # by downloading the shareware version.
-
- sum=`md5sum "$pak0" | cut -d' ' -f1`
-
- case "$sum" in
- ($quake_pak0sum_106)
- # OK
- ;;
- (*)
- # Not 1.06. Upgrade it using the shareware version.
- echo "Your copy of Quake is not 1.06. Upgrading it by" \
- "downloading quake106.zip" >&2
- require_program lha lhasa
- unpack_quake106_pak0
- ;;
- esac
-
- [ "$pak1" = "" ] || verify_md5sum_alternatives "$pak1" "$pak1sum"
-}
-
-cdrom_method() {
- bit1="$mountpoint/q101_int.1"
- bit2="$mountpoint/q101_int.2"
- bit1sum=752f49131bb3ba832346e873c1bcfdc6
- bit2sum=9ed67b39020575771e29645d977c9216
-
- require_program lha lhasa
- verify_file "$bit1"
- verify_file "$bit2"
- verify_md5sum "$bit1" "$bit1sum"
- verify_md5sum "$bit2" "$bit2sum"
-
- cat "$bit1" "$bit2" > "$WORKDIR/unpackme.exe"
- (
- cd "$WORKDIR"
- lha xq unpackme.exe
- rm unpackme.exe
- )
-
- pak0="$WORKDIR/id1/pak0.pak"
- if ! test -f "$pak0"; then
- pak0="$WORKDIR/ID1/PAK0.PAK"
- fi
- pak1="$WORKDIR/id1/pak1.pak"
- if ! test -f "$pak1"; then
- pak1="$WORKDIR/ID1/PAK1.PAK"
- fi
- suffix=registered
- folder=id1
- verify_quake
- common_method
-}
-
-dir_method() {
- pak0=$(ifind "$mountpoint" "id1/pak0.pak" | head -1)
- pak1=$(ifind "$mountpoint" "id1/pak1.pak" | head -1)
- suffix=registered
- folder=id1
-
- if [ -z "$pak0" ]; then
- die "id1/pak0.pak not found in $mountpoint" 1
- fi
-
- if [ -z "$pak1" ]; then
- die "id1/pak1.pak not found in $mountpoint" 1
- fi
-
- verify_quake
- common_method
-}
-
-swzip_method() {
- if [ -n "$mountpoint" ]; then
- zipfile=$(unravel "$mountpoint")
- else
- zipfile=""
+ python_method quake "$mountpoint"
fi
-
- unpack_quake106_pak0 "$zipfile"
- pak1=""
-
- suffix=shareware
- folder=id1
-
- verify_file "$pak0"
- verify_md5sum_alternatives "$pak0" "$quake_pak0sum_106"
- common_method
-}
-
-mp1_method() {
- pak0="$mountpoint/hipnotic/pak0.pak"
- # MD5 sum for original CD version
- pak0sum=0ab83681aaf841c4320269e02941a14a
- # MD5 sum for glQuake-compatible version (see
- # http://speeddemosarchive.com/quake/qdq/movies/sds.html for more
- # info)
- pak0sum=$pak0sum,f05b7452ae725e060fb3d14f7731fb00
- pak1=""
- suffix=armagon
- folder=hipnotic
-
- verify_file "$pak0"
- verify_md5sum_alternatives "$pak0" "$pak0sum"
- common_method
}
-mp2_method() {
- pak0="$mountpoint/rogue/pak0.pak"
- # MP2 CD
- pak0sum=f8898a483b131de21581656c94f3c1a4
- # MD5 sum for Steam-supplied version
- pak0sum=$pak0sum,f71428763229bdb373f00a547296efe3
- # MP2 as supplied with MP1 on a single CD
- pak0sum=$pak0sum,c38a4e04219c317cd1b02f386bdfe11f
- pak1=""
- suffix=dissolution
- folder=rogue
-
- verify_file "$pak0"
- verify_md5sum_alternatives "$pak0" "$pak0sum"
- common_method
-}
-
-# Requires the following variables on entry:
-# pak0 - full path of the pak0.pak file to include
-# pak1 - full path of the pak1.pak file to include (optional)
-# suffix - package suffix to use
-# folder - base folder for the PAK files
-common_method() {
- DEBBASE="quake-${suffix}_${GAME_PACKAGE_VERSION}_all.deb"
- OUTFILE=`unravel "$OUTDIR"`"/$DEBBASE"
- cp -p "$DATADIR/$DEBBASE" "$OUTFILE"
-
- # force lower case for our copy of the files
- ln -s `unravel "$pak0"` "$WORKDIR/pak0.pak"
- [ "$pak1" = "" ] || ln -s `unravel "$pak1"` "$WORKDIR/pak1.pak"
-
- if [ "$pak1" = "" ]; then
- slipstream "$OUTFILE" "usr/share/games/quake/${folder}" \
- "$WORKDIR/pak0.pak"
- else
- slipstream "$OUTFILE" "usr/share/games/quake/${folder}" \
- "$WORKDIR/pak0.pak" "$WORKDIR/pak1.pak"
- fi
- [ -d "$WORKDIR/${folder}" ] && rm -rf "$WORKDIR/${folder}"
- [ ! -f "$WORKDIR/pak1.pak" ] || rm "$WORKDIR/pak1.pak"
- rm "$WORKDIR/pak0.pak"
- rm -f "$WORKDIR/quake106.zip"
+python_method() {
+ . $LIBDIR/via-python
+ gdp_data_driven "$@"
+ return $?
}
music_method () {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/game-data-packager.git
More information about the Pkg-games-commits
mailing list