Subversion Repositories duke3d_hrp

Rev

Rev 415 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 415 Rev 431
Line 1... Line 1...
1
#!/bin/sh
1
#!/bin/sh
2
 
2
 
3
# Duke Nukem 3D High Resolution Pack Extractor  v0.5  2012-12-23
3
# Duke Nukem 3D High Resolution Pack Extractor  v0.5.1  2013-01-22
4
#
4
#
5
# Author: LeoD
5
# Author: LeoD
6
# License: ISC license : http://opensource.org/licenses/isc-license.txt
6
# License: ISC license : http://opensource.org/licenses/isc-license.txt
7
#
7
#
8
# This script extracts a working copy of your local Duke Nukem 3D High
8
# This script extracts a working copy of your local Duke Nukem 3D High
Line 17... Line 17...
17
# Or maybe MSYS' bash gets finally updated to 4.* and I'll use its regex engine.
17
# Or maybe MSYS' bash gets finally updated to 4.* and I'll use its regex engine.
18
 
18
 
19
DEF_TOP=UNDEFINED
19
DEF_TOP=UNDEFINED
20
SET_VERSION=YES            # [YES|NO]
20
SET_VERSION=YES            # [YES|NO]
21
EXTRACT_COMMENTED_FILES=NO # [YES|NO]
21
EXTRACT_COMMENTED_FILES=NO # [YES|NO]
22
DUKEPLUS_POLYMOST_COMPATIBILTY_APPROACH=polymost # [none|polymost|polymer|mixed]
22
DUKEPLUS_POLYMOST_COMPATIBILTY_APPROACH=polymost  #[none|polymost|polymer|mixed]
23
ATTRITION_POLYMOST_COMPATIBILTY_APPROACH=polymost # [none|polymost|polymer|mixed]
23
ATTRITION_POLYMOST_COMPATIBILTY_APPROACH=polymost #[none|polymost|polymer|mixed]
24
 
24
 
25
ask()
25
ask()
26
{
26
{
27
  echo -n "$@" '[y/N] ' ; read ans
27
  echo -n "$@" '[y/N] ' ; read ans
28
  case "$ans" in
28
  case "$ans" in
Line 80... Line 80...
80
        cat "${VER_FILE}" | sed -r --posix \
80
        cat "${VER_FILE}" | sed -r --posix \
81
          s/\(Version\ *\)\([0-9\.]*\)\(.*\)/\\1${VERSION}\\3/ \
81
          s/\(Version\ *\)\([0-9\.]*\)\(.*\)/\\1${VERSION}\\3/ \
82
          >> "${TARGET_FILE}"
82
          >> "${TARGET_FILE}"
83
      fi
83
      fi
84
      ;;
84
      ;;
85
    duke3d_hrp_polymost.def)
85
    duke3d_hrp_polymost.def | \
86
      if [ "${HRPTYPE}" = "polymost_override" ] ; then
86
    installer/polymost_override/duke3d_hrp_polymost_override.def )
87
        cat "${VER_FILE}" | sed -r --posix \
-
 
88
          s/\(Version\ *\)\([0-9\.]*\)\(\ Polymost\)/\\1${VERSION}\ Polymost\ Override/ \
-
 
89
          >> "${TARGET_FILE}"
-
 
90
      else
-
 
91
        cat "${VER_FILE}" | sed -r --posix \
87
      cat "${VER_FILE}" | sed -r --posix \
92
          s/\(Version\ *\)\([0-9\.]*\)\(.*\)/\\1${VERSION}\\3/ \
88
        s/\(Version\ *\)\([0-9\.]*\)\(.*\)/\\1${VERSION}\\3/ \
93
          >> "${TARGET_FILE}"
89
        >> "${TARGET_FILE}"
94
      fi
-
 
95
      ;;
90
      ;;
96
    *)
91
    *)
97
      echo "###ERROR: copy_set_version() - BAD FILE: ${VER_FILE}"
92
      echo "###ERROR: copy_set_version() - BAD FILE: ${VER_FILE}"
98
      exit 1
93
      exit 1
99
      ;;
94
      ;;
Line 111... Line 106...
111
    copy_set_version hrp_readme.txt "${EXTRACTDIR}/hrp_readme.txt"
106
    copy_set_version hrp_readme.txt "${EXTRACTDIR}/hrp_readme.txt"
112
  else
107
  else
113
    cp -pv hrp_readme.txt           "${EXTRACTDIR}"
108
    cp -pv hrp_readme.txt           "${EXTRACTDIR}"
114
  fi
109
  fi
115
 
110
 
116
  if [ "${HRPTYPE}" = "polymost" ] || [ "${HRPTYPE}" = "polymost_override" ] || \
111
  if [ "${HRPTYPE}" = "polymost" ] || [ "${HRPTYPE}" = "polymost_override" ] ||\
117
     [ "${HRPTYPE}" = "polymer"  ] || [ "${HRPTYPE}" = "full" ] ; then
112
     [ "${HRPTYPE}" = "polymer"  ] || [ "${HRPTYPE}" = "full" ] ; then
118
    cp -pv hrp_art_license.txt      "${EXTRACTDIR}"
113
    cp -pv hrp_art_license.txt      "${EXTRACTDIR}"
119
  fi
114
  fi
120
 
115
 
121
  if [ "${HRPTYPE}" = "polymost" ] || [ "${HRPTYPE}" = "polymost_override" ] ; then
116
  if [ "${HRPTYPE}" = "polymost" ] ; then
122
    if [ "${SET_VERSION}" = "YES" ] ; then
117
    if [ "${SET_VERSION}" = "YES" ] ; then
123
      copy_set_version duke3d_hrp_polymost.def "${EXTRACTDIR}/duke3d_hrp.def"
118
      copy_set_version duke3d_hrp_polymost.def "${EXTRACTDIR}/duke3d_hrp.def"
124
    else
119
    else
125
      cp -pv           duke3d_hrp_polymost.def "${EXTRACTDIR}/duke3d_hrp.def"
120
      cp -pv           duke3d_hrp_polymost.def "${EXTRACTDIR}/duke3d_hrp.def"
126
    fi
121
    fi
127
  fi
122
  fi
128
 
123
 
-
 
124
  if [ "${HRPTYPE}" = "polymost_override" ] ; then
-
 
125
    if [ "${SET_VERSION}" = "YES" ] ; then
-
 
126
      copy_set_version \
-
 
127
        installer/polymost_override/duke3d_hrp_polymost_override.def \
-
 
128
        "${EXTRACTDIR}/duke3d_hrp.def"
-
 
129
    else
-
 
130
      cp -pv installer/polymost_override/duke3d_hrp_polymost_override.def \
-
 
131
        "${EXTRACTDIR}/duke3d_hrp.def"
-
 
132
    fi
-
 
133
  fi
-
 
134
 
129
  if [ "${HRPTYPE}" = "polymost" ] ; then
135
  if [ "${HRPTYPE}" = "polymost" ] ; then
130
    cp -pv duke3d.def "${EXTRACTDIR}"
136
    cp -pv duke3d.def "${EXTRACTDIR}"
131
    #cp -pv duke3d_hrp_polymost.def               "${EXTRACTDIR}"
137
    #cp -pv duke3d_hrp_polymost.def               "${EXTRACTDIR}"
132
    #cp -pv highres/screen/menu/2492_polymost.png "${EXTRACTDIR}/highres/screen/menu"
138
    #cp -pv highres/screen/menu/2492_polymost.png "${EXTRACTDIR}/highres/screen/menu"
133
  fi
139
  fi
134
 
140
 
135
  if [ "${HRPTYPE}" = "full" ] ; then
141
  if [ "${HRPTYPE}" = "full" ] ; then
136
    if [ "${SET_VERSION}" = "YES" ] ; then
142
    if [ "${SET_VERSION}" = "YES" ] ; then
137
      copy_set_version duke3d_hrp_polymost.def "${EXTRACTDIR}/duke3d_hrp_polymost.def"
143
      copy_set_version duke3d_hrp_polymost.def \
-
 
144
        "${EXTRACTDIR}/duke3d_hrp_polymost.def"
138
    else
145
    else
139
      cp -pv           duke3d_hrp_polymost.def "${EXTRACTDIR}"
146
      cp -pv           duke3d_hrp_polymost.def "${EXTRACTDIR}"
140
    fi
147
    fi
141
  fi
148
  fi
142
 
149
 
-
 
150
  if [ "${HRPTYPE}" = "full" ] ; then
-
 
151
    cp -pv highres/screen/menu/2492_ver_polymost.png \
-
 
152
      "${EXTRACTDIR}/highres/screen/menu"
-
 
153
  fi
-
 
154
 
143
  if [ "${HRPTYPE}" = "polymost_override" ] || [ "${HRPTYPE}" = "full" ] ; then
155
  if [ "${HRPTYPE}" = "polymost_override" ] ; then
-
 
156
    cp -pv installer/polymost_override/hrp_polymost_override.txt \
-
 
157
      "${EXTRACTDIR}"
-
 
158
    cp -pv installer/polymost_override/2492_ver_polymost_override.png \
144
    cp -pv highres/screen/menu/2492_ver_polymost.png "${EXTRACTDIR}/highres/screen/menu"
159
      "${EXTRACTDIR}/highres/screen/menu/2492_ver_polymost.png"
145
  fi
160
  fi
146
 
161
 
147
  if [ "${HRPTYPE}" = "polymer" ] || [ "${HRPTYPE}" = "full" ] ; then
162
  if [ "${HRPTYPE}" = "polymer" ] || [ "${HRPTYPE}" = "full" ] ; then
148
    cp -pv duke3d.def                   "${EXTRACTDIR}"
163
    cp -pv duke3d.def                   "${EXTRACTDIR}"
149
    if [ "${SET_VERSION}" = "YES" ] ; then
164
    if [ "${SET_VERSION}" = "YES" ] ; then
Line 289... Line 304...
289
          MHKSTOP="1"
304
          MHKSTOP="1"
290
        fi
305
        fi
291
      fi
306
      fi
292
    done
307
    done
293
  done
308
  done
294
  # Some people prefer unusual setups ...
309
  # Some people prefer unusual setups ... polymost_mhk_patch not applied automatically
295
  zip -rq9 ${EXTRACTDIR}/polymost_hrp_update_polymer_maphacks.zip *.mhk
310
  zip -rq9 ${EXTRACTDIR}/polymost_hrp_polymer_maphacks.zip *.mhk
296
} # create_polymost_mhk()
311
} # create_polymost_mhk()
297
 
312
 
298
 
313
 
299
# I really don't know yet if this will become necessary, or if it does make
314
# I really don't know yet if this will become necessary, or if it does make
300
# sense at all, but at least the files involved are listed.
315
# sense at all, but at least the files involved are listed.
Line 527... Line 542...
527
 
542
 
528
delete_empty_folders()
543
delete_empty_folders()
529
{
544
{
530
    if [ -d "${EXTRACTDIR}" ] ; then
545
    if [ -d "${EXTRACTDIR}" ] ; then
531
      rm -rf ${EXTRACTDIR}/.svn
546
      rm -rf ${EXTRACTDIR}/.svn
532
      rm -rf ${EXTRACTDIR}/installer
-
 
533
      DIRLIST=./EXTRACT_DIRECTORIES.lst
547
      DIRLIST=./EXTRACT_DIRECTORIES.lst
534
      du "${EXTRACTDIR}" > ${DIRLIST}
548
      du "${EXTRACTDIR}" > ${DIRLIST}
535
      cat ${DIRLIST} | while read DIR ; do
549
      cat ${DIRLIST} | while read DIR ; do
536
        if [ "0" = "`echo \"${DIR}\" | grep -owE \"0\"`" ] ; then
550
        if [ "0" = "`echo \"${DIR}\" | grep -owE \"0\"`" ] ; then
537
          EMPTYDIR="`echo \"${DIR}\" | sed -r --posix s/0//`"
551
          EMPTYDIR="`echo \"${DIR}\" | sed -r --posix s/0//`"
538
          if [ -d ${EMPTYDIR} ] ; then
552
          if [ -d ${EMPTYDIR} ] ; then
539
            rmdir ${EMPTYDIR}
553
            rmdir --parents --ignore-fail-on-non-empty ${EMPTYDIR}
540
          fi
554
          fi
541
        fi
555
        fi
542
      done
556
      done
543
      rm ${DIRLIST}
557
      rm ${DIRLIST}
544
    else
558
    else