summarylogtreecommitdiffstats
path: root/copier.sh
blob: 247a8ef6255d4e68b07492e64914b9f718c1879d (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
#!/bin/bash

function _fail() {
  echo "ERROR: Failed to find or copy \"$1\""
  exit 1
}

if [ ! -r filelist ]; then
  echo "ERROR: Can't read filelist"
  exit 1
fi

read -p "Enter the path to the X-COM data files: " _xcompath
if [ ! -d "$_xcompath" ]; then
  echo "ERROR: No such directory"
  exit 1
fi

IFS="
"
for file in $(cat filelist); do
  # Handle files with identical names but different content
  case "$file" in
    DP_PREFS|INTICON.PCK|INTICON.TAB)
      if ! find "$_xcompath" -path "*UFOGRAPH/$file" -exec cp "{}" ./"ufo-$file" \; &>/dev/null; then
        _fail $file
      fi
      if ! find "$_xcompath" -path "*GEOGRAPH/$file" -exec cp "{}" ./"geo-$file" \; &>/dev/null; then
        _fail $file
      fi
      ;;
    GEODATA.DAT)
      if ! find "$_xcompath" -path "*MISSDAT/$file" -exec cp "{}" ./"missdat-$file" \; &>/dev/null; then
        _fail $file
      fi
      if ! find "$_xcompath" -path "*MAPS/$file" -exec cp "{}" ./"maps-$file" \; &>/dev/null; then
        _fail $file
      fi
      ;;
    SOUND.CFG)
      if ! find "$_xcompath" -path "*XCOM/$file" -exec cp "{}" ./"xcom-$file" \; &>/dev/null; then
        _fail $file
      fi
      if ! find "$_xcompath" -path "*SOUND/$file" -exec cp "{}" ./"sound-$file" \; &>/dev/null; then
        _fail $file
      fi
      ;;
    *)
      if ! find "$_xcompath" -name "$file" -exec cp "{}" . \; &>/dev/null; then
        _fail $file
      fi
      ;;
  esac
done

echo "All files successfully copied, now run makepkg"