summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 7d6ca0d5c76dbf446d69e6b95f0968da4b51bdcb (plain)
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# Contributor: quantax -- contact via Arch Linux forum or AUR
#              M0Rf30
# Mantainer: XenGi
pkgname=unrealtournament
pkgver=451
pkgrel=11
pkgdesc="The classic Unreal Tournament from 1999 (Retail CD or DVD required)"
arch=('i686' 'x86_64')
url="http://www.unrealtournament.com/"
license=('custom')
groups=(ut1999-goty)
[ "$CARCH" = "i686" ] && depends=(ossp libnotify sdl libgl)
[ "$CARCH" = "x86_64" ] &&  depends=(ossp libnotify lib32-sdl lib32-libgl)
makedepends=(makepkg-unreal unshield lib32-fakeroot)
provides=(ut1999)
conflicts=(ut1999 ut ut-server)
source=(ut436.run::'https://gitlab.com/XenGi/oldgames/raw/master/ut/unreal.tournament_436-multilanguage.run'
        ut436goty.run::'https://gitlab.com/XenGi/oldgames/raw/master/ut/unreal.tournament_436-multilanguage.goty.run'
        https://gitlab.com/XenGi/oldgames/raw/master/ut/ALAudio-86eade1c.zip
	    https://gitlab.com/XenGi/oldgames/raw/master/ut/OpenGLDrv-3.6-86eade1c.zip
        https://gitlab.com/XenGi/oldgames/raw/master/ut/UTPGPatch451.tar.bz2
        ut.desktop
        disk.list
        utpg.list
        utcustom.sh
        https://gitlab.com/XenGi/oldgames/raw/master/ut/ut.svgz)
noextract=(UTPGPatch451.tar.bz2)
sha512sums=('e3ab99af410eaa486a62cc21a40c5047996d0667ace963ccf2db666e5af9365ec49b707310fabf0bb1ed4d31ca78d9eb1e26a02ed6f258a4c1154bcc7184f518'
            '6ba8dbf3a05b293eccc500e9edcf5417f38d0b60ff31f8df728e8791ec902e95d2d21feb025655ad5e464b9f0f025c79054baf43bd70bfd6e4644b693f6a4a49'
            '5b2cb8a5c5690d785c9972a85b2608fdfe37c19eddc7b28c8b9599bd468306d7f340352b72113914a9d85ce1f5f95d9edc15aff87fe6d5e88326c01657ded822'
            'fe10ff2f916df08c2904aa4311d668f7460415f8c6b07b17c2797e8a3c19333ac8484d53da3cb426a616b5ca4b6464e3f6d55b6f93502b854500ba172dc0fb07'
            'd11ecb3e60e8bba0288be0a4860acb563c277e75ce30a749de04673219d484b7a8c7e6207bc582872df33db684658dc1a15235b9d79ceb98fcd2ad1410982423'
            '204fe409d2b10416301cb72f57abb6b547c88909339fbb9f27cb42a08072f0e935b2bdfd7cc2cc4db1432db54f3d64d4c616f58e51de20722d05214069ff8c2f'
            '4d0bbbef707eceac5e3ecf8711d92c3df6d1467cf6ef949d5c773c70858750e5bf4f820d67fbfb26708d6d145de143a14e390c891a9a49bd68301bb1452ffd5c'
            '623f429e07ddf004d8288a355f4da7e7ac3b249cdf2bb61d206a806fadb294c315182d3d22facf01c55c87938055bb122bb21a2a21610c9beeac9df09deaae4b'
            'b9da24af0845128990e6eb2fc71c146b12a5902dbf5326161ad10858bdf1fcc1aec6d78d0bc812e399a990d07fb4d2e010eec9232b0232138b73bca860b16936'
            'cc662cac9b0dee11e65f20cb7bd2d241690b22054527b2eb2ba36eb309844ea671529f4b7da4e9bab839cb254d572eb5807c15687979594e88429132cf332daf')

# You can uncomment and set these two variables in order to override the auto
# detection done in build() by _detect_cdpath() and _detect_cdversion().
#_cdpath="/mnt"    # path to your mounted UT CD or DVD
#_cdversion="" # "default" or "anthology"

# Detect the mount point of the install medium.
_detect_cdpath() {
    echo "Searching for mount point of install medium..."

    for mountpoint in $(egrep "(iso9660|udf)" /etc/mtab | awk '{print $2}'); do
        if [ -f "${mountpoint}/SYSTEM/UnrealTournament.exe" ] || [ -f "${mountpoint}/Disk1/data1.hdr" ]; then
            _cdpath="${mountpoint}"
            break
        fi
    done

    if [ -z "${_cdpath}" ]; then
	    cat << EOF >&2
No mounted valid Unreal Tournament CD or Unreal Anthology
DVD has been detected while scanning all "iso9660"
and all "udf" filesystems in "/etc/mtab" for the file
"SYSTEM/UnrealTournament.exe" or the file "Disk1/data1.hdr".
Make sure you mounted the right disk correctly.  If it still
doesn't work you can try setting the "_cdpath" and/or the
"_cdversion" variable in this PKGBUILD to your mount point and
your version of UT manually.
EOF
        return 1
    else
        echo "${_cdpath} looks promising."
    fi
}

# Determine which method should be used for extracting the files from the
# install medium.
_detect_cdversion() {
    echo "Determining install method... "

    if [ -f "${_cdpath}/SYSTEM/UnrealTournament.exe" ]; then
        _cdversion="default"
    elif [ -f "${_cdpath}/Disk1/data1.hdr" ]; then
        _cdversion="anthology"
    elif [ -f "${_cdpath}/System/UnrealTournament.exe" ]; then
        _cdversion="default"
    else
        echo "Could not determine _cdversion." >&2
        return 1
    fi
    echo "    Using \"${_cdversion}\" method."
}

# Install files from most UT99 CDs.
_build_default() {
    echo "Extracting files from ${_cdpath}..."
    cd "${srcdir}"

    _unreal_install_files "${_cdpath}" "${pkgdir}/opt/ut" "*./System400/.*" < disk.list || return 1

    _install_patches || return 1

    echo "Decompressing maps from ${_cdpath}..."
    grep "Maps/" disk.list | sed -e "s/$/\.uz/" | _unreal_decompress_files "${_cdpath}" "${pkgdir}/opt/ut" || return 1
    grep "Maps/" disk.list | _unreal_move_files "${pkgdir}/opt/ut/System" "${pkgdir}/opt/ut" || return 1
    rm -f -- "${pkgdir}/opt/ut/System/ucc.log"
}

# Install files from the Unreal Anthology DVD.
_build_anthology() {
    echo "Extracting files from ${_cdpath}..."
    cd "${srcdir}"

    ln -fs -- ${_cdpath}/Disk*/data* -t . || return 1
    unshield -g 3_UnrealTournament_Help -d dvd x data1.hdr || return 1
    unshield -g 3_UnrealTournament_Maps -d dvd x data1.hdr || return 1
    unshield -g 3_UnrealTournament_Music -d dvd x data1.hdr || return 1
    unshield -g 3_UnrealTournament_Sounds_All -d dvd x data1.hdr || return 1
    unshield -g 3_UnrealTournament_Sounds_English -d dvd x data1.hdr || return 1
    unshield -g 3_UnrealTournament_System_All -d dvd x data1.hdr || return 1
    unshield -g 3_UnrealTournament_System_English -d dvd x data1.hdr || return 1
    unshield -g 3_UnrealTournament_Textures -d dvd x data1.hdr || return 1
    _unreal_move_files dvd "${pkgdir}/opt/ut" < disk.list || return 1
    _install_patches || return 1
}

# Add files for running UT on Linux, apply the patches shipped by Loki and add
# some third party fixes.
_install_patches() {
    echo "Adding Loki's Linux runtime files..."
    cd "${srcdir}"

    sh ./ut436.run --tar xfC 436 || return 1
    sh ./ut436goty.run --tar xfC 436goty || return 1

    cd 436goty
    zcat ../ut.svgz > ../ut.svg
    install --mode=755 -D ../ut.svg "${pkgdir}/usr/share/pixmaps/ut.svg"
    install --mode=644 -- README "${pkgdir}/opt/ut/Help/README"
    install --mode=644 -- README.Loki "${pkgdir}/opt/ut/Help/README.Loki"
    install --mode=755 -- bin/Linux/x86/ucc "${pkgdir}/opt/ut/ucc"
    install --mode=755 -- ../utcustom.sh "${pkgdir}/usr/bin/ut"
    chmod +x $pkgdir/usr/bin/ut
    ln -fs -- /opt/ut/ut "${pkgdir}ut"

    tar xfC data.tar.gz "${pkgdir}/opt/ut" --exclude=System/UnrealTournament.ini.PATCH || return 1
    chmod 644 -- "${pkgdir}/opt/ut/System/OpenGLDrv.int"
    install --mode=644 -D -- "${pkgdir}/opt/ut/System/License.int" \
                             "${pkgdir}/usr/share/licenses/${pkgname}/License.int"

    tar xfC UT436-OpenGLDrv-Linux-090602.tar.gz "${pkgdir}/opt/ut" || return 1
    tar xfC OpenGL.ini.tar.gz "${pkgdir}/opt/ut" || return 1
    tar xfC Credits.tar.gz "${pkgdir}/opt/ut" || return 1
    tar xfC NetGamesUSA.com.tar.gz "${pkgdir}/opt/ut" || return 1

    # As there is no distinction between GOTY and non-GOTY CDs yet, we just try
    # to patch everything that applies.  Also Loki's patcher is too unreliable.
    cd "${srcdir}"
    echo "Trying to apply Loki's 436 Xdelta patches..."
    _unreal_fail_safe_patcher 436/setup.data/data "${pkgdir}/opt/ut"
    _unreal_fail_safe_patcher 436goty/setup.data/data "${pkgdir}/opt/ut"

    echo "Applying 451 UTPG patch..."
    tar xfC UTPGPatch451.tar.bz2 451utpg || return 1
    _unreal_move_files 451utpg "${pkgdir}/opt/ut" < utpg.list || return 1

    # Fix a small bug until next UTPG release.  Thanks for the hint, elsixdiab.
    sed -i '/^LoadClassMismatch/s/\.%s$//' "${pkgdir}/opt/ut/System/Core.int"
}

package() {
    source /usr/lib/makepkg/unreal.sh || return 1

    if [ -z "${_cdpath}" ]; then
        _detect_cdpath || return 1
    else
        echo "Using ${_cdpath} as install medium."
    fi
    if [ -z "${_cdversion}" ]; then
        _detect_cdversion || return 1
    else
        echo "Using \"${_cdversion}\" install method."
    fi

    install --directory -- ${srcdir}/{436,436goty,451utpg} \
                           ${pkgdir}/usr/bin \
                           ${pkgdir}/opt/ut/{Help,Logs,Maps,Music,Sounds,System,Textures} \
                           ${pkgdir}/opt/ut/Web/{images,inc,plaintext/inc} || return 1
    install --mode=644 -D -- "${srcdir}/ut.desktop" \
                             "${pkgdir}/usr/share/applications/ut.desktop"
    # Update OpenGL driver to 3.6 and ALaudio
    cp $srcdir/*.so* $pkgdir/opt/ut/System

    case "${_cdversion}" in
        ("default")
            _build_default || return 1
            ;;
        ("anthology")
            _build_anthology || return 1
            ;;
        (*)
            echo "Unknown _cdversion: ${_cdversion}" >&2
            return 1
            ;;
    esac
}