File: wolf3d

package info (click to toggle)
game-data-packager 37
  • links: PTS, VCS
  • area: contrib
  • in suites: jessie, jessie-kfreebsd
  • size: 512 kB
  • ctags: 97
  • sloc: sh: 235; makefile: 109
file content (130 lines) | stat: -rw-r--r-- 3,543 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
SHORTNAME=wolf3d
LONGNAME="Wolfenstein 3D"

ZIPSUM=a29432cd4a5184d552d8e5da8f80a531

wolf3d_usage() {
	echo "game-data-packager ${SHORTNAME} arguments:"
	printf "\tgame-data-packager ${SHORTNAME} [ -f path ] | [ -w ]
\t\t-f path\t\tpath to your existing copy of 1wolf14.zip\n\
\t\t-w\t\tfetch 1wolf14.zip from the World Wide Web\n"
}

verify_args() {
    case $# in
        0)
            wolf3d_usage
            exit 0
            ;;
        1)
            if [ "$1" != "-w" ]; then
                    usage >&2
                    wolf3d_usage >&2
                    exit 1
            fi
            downloadzip
            ;;
        2)
            if [ "$1" != "-f" ]; then
                usage >&2
                wolf3d_usage >&2
                exit 1
            fi
            downloaded=false
            wolf3dzip="$2"
            ;;
        *)
            usage >&2
            wolf3d_usage >&2
            exit 1
            ;;
    esac
}

wolf3dmirrors=$LIBDIR/wolf3d-mirrors

downloadzip() {
    dest="$WORKDIR/1wolf14.zip"
    mirror=$(grep -v ^# "$wolf3dmirrors" | sort -R | head -n1)
    for try in $mirror; do
        if wget --progress=dot --directory-prefix "$WORKDIR" -c "$try"
        then
            wolf3dzip="$dest"
            downloaded=true
            return
        fi
    done
    die "error: could not find 1wolf14.zip at our chosen mirror"
}

checksum() {
	CHECKSUM=`md5sum "$1" | cut -d' ' -f1`
	debug "checksum = $CHECKSUM"
}

SUFFIX=wl1
DEBBASE="wolf3d-data-${SUFFIX}_${GAME_PACKAGE_VERSION}_all.deb"
DEB="$DATADIR/$DEBBASE"

go() {
	require_program id-shr-extract dynamite
	verify_args "$@"
	ZIPFILE=`unravel "$wolf3dzip"`
    [ -e "$ZIPFILE" ] || die "ERROR: '$ZIPFILE' does not exist."
    [ -f "$ZIPFILE" ] || die "ERROR: '$ZIPFILE' is not a file."
    [ -r "$ZIPFILE" ] || die "ERROR: '$ZIPFILE' cannot be read."
	checksum "$ZIPFILE"
	if [ "$CHECKSUM" != "$ZIPSUM" ]; then
		echo "warning: checksum is not what we expected" >&2
	fi

    OUTFILE=`unravel "$OUTDIR"`"/$DEBBASE"
	cp -p "$DEB" "$OUTFILE"

	oldpwd=`pwd`
	cd "$WORKDIR"

    gdp_unzip "$ZIPFILE" W3DSW14.SHR
    id-shr-extract W3DSW14.SHR >/dev/null
    rm order.frm  w3dhelp.exe  W3DSW14.SHR  wolf3d.exe

	wlfiles="
		audiohed.wl1:58aa1b9892d5adfa725fab343d9446f8
		audiot.wl1:4b6109e957b584e4ad7f376961f3887e
		gamemaps.wl1:30fecd7cce6bc70402651ec922d2da3d
		maphead.wl1:7b6dd4e55c33c33a41d1600be5df3228
		vgadict.wl1:76a6128f3c0dd9b77939ce8313992746
		vgagraph.wl1:74decb641b1a4faed173e10ab744bff0
		vgahead.wl1:61bf1616e78367853c91f2c04e2c1cb7
		vswap.wl1:6efa079414b817c97db779cecfb081c9
		vendor.doc:eccc7fc421f3d1f00e6eabd6848637f6

	"

    # XXX: we have to re-implement most of slipstream() here, due
    # to the way we use it
    slipstream_permcheck "$OUTFILE"
    slipstream_unpack "$OUTFILE"
    for fc in $wlfiles; do
        # XXX: files are treated as being relative to $WORKDIR, hence
        # unpacking straight into it. Might be nicer to tidy away the
        # unpack into a subdir (no risk of stamping over another part
        # of g-d-p's operation) and specify full paths
		file=$(echo "$fc" | cut -d: -f1)
		checksum "$file"
		if [ "$CHECKSUM" != $(echo "$fc" | cut -d: -f2) ]; then
				echo "warning: checksum is not what we expected for $file" >&2
		fi
        slipstream_file "$file" "usr/share/games/wolf3d/$file"
		rm "$file"
    done
    slipstream_instsize
    slipstream_repack "$OUTFILE"
    slipstream_cleanup

    if [ "$downloaded" = "true" ]; then
        rm "$ZIPFILE"
    fi

	cd "$oldpwd"
}