summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 5f13ad909f042450565a08b9cbd945a40f9a4371 (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
# Maintainer: Grey Christoforo <grey@christoforo.net>

_number_of_bits=16
pkgname=microchip-mplabxc${_number_of_bits}-bin
pkgver=1.24
pkgrel=4
pkgdesc="Microchip's MPLAB XC${_number_of_bits} C compiler toolchain for their dsPIC and PIC24 microcontroller families"
arch=(i686 x86_64)
url=http://www.microchip.com/xc${_number_of_bits}
license=(custom)
if [[ $CARCH = i686 ]]; then
  depends=(
    'expat'
    'gcc-libs'
  )
else
  depends=(
    'lib32-expat'
    'lib32-gcc-libs'
  )
fi
makedepends=(sdx tcl tcl-vfs) 
options=(!strip docs libtool emptydirs !zipman staticlibs !upx)
source=("installerBlobFromMicrochip::http://ww1.microchip.com/downloads/en/DeviceDoc/xc${_number_of_bits}-v$pkgver-full-install-linux-installer.run" liblzmadec0.2.so)
noextract=(installerBlobFromMicrochip liblzmadec0.2.so)
md5sums=('6c9c843c8233a450535bdb66f13644fe'
         'e43a1f543ba4f67a2d5b2e8d9656a6c7')
install=$pkgname.install

build() {
  # unwrap installer files
  sdx.kit unwrap installerBlobFromMicrochip
  
  # read unpack options
  _unpack_options=$(cat installerBlobFromMicrochip.vfs/cookfsinfo.txt)
  
  # write unpack tcl script to file
cat > unpack.tcl <<EOF
package require vfs::cookfs
package require Tcllzmadec
vfs::cookfs::Mount ${_unpack_options} installerBlobFromMicrochip virtual
file copy virtual unpacked.vfs
EOF

  # if this is a 64bit machine, we need to use the packaged zlma decoder so since the insaller only provides a 32bit one
  if [[ $CARCH = x86_64 ]]; then
    mv liblzmadec0.2.so installerBlobFromMicrochip.vfs/libraries/lzma*/.
  fi

  msg2 "Unpacking installer. This might take a while..."
  LD_LIBRARY_PATH=./usr/lib: TCL_LIBRARY=./installerBlobFromMicrochip.vfs/lib TCLLIBPATH=./installerBlobFromMicrochip.vfs/libraries tclsh unpack.tcl

  #now reassemble files larger than 5MB in the archive, which were split up for whatever reason
  msg2 "Reassembling files..."
  for f in `find ./unpacked.vfs -name '*___bitrockBigFile1'`
  do
    firstChunk="$f"
    baseName="${firstChunk//___bitrockBigFile1/}"
    allPieces="$(find -path "${baseName}*" | sort --version-sort)"
    cat $allPieces > "$baseName".reassembled
    rm $allPieces
    mv "$baseName".reassembled "$baseName"
  done
}

package() {
  mv unpacked.vfs/compiler/programfileslinux/* unpacked.vfs/compiler/programfiles/
  mv unpacked.vfs/compiler/programfiles/*License.txt unpacked.vfs/compiler/programfiles/docs/.

  mkdir -p "$pkgdir"/opt/$pkgname
  mv unpacked.vfs/compiler/programfiles/* "$pkgdir"/opt/$pkgname/.

  msg2 "Making executables executable"
  find "$pkgdir"/opt/$pkgname/bin -type f -exec /bin/sh -c "file {} | grep -q executable && chmod +x {}" \;

  mkdir -p "$pkgdir/etc/profile.d"
  echo "export PATH="'$PATH'":/opt/${pkgname}/bin" > "$pkgdir/etc/profile.d/${pkgname}.sh"
  echo "export XC${_number_of_bits}_TOOLCHAIN_ROOT=/opt/${pkgname}" >> "$pkgdir/etc/profile.d/${pkgname}.sh" 
 
  mkdir -p $pkgdir/usr/share/licenses/$pkgname
  ln -s "$pkgdir"/docs/*icense.txt $pkgdir/usr/share/licenses/$pkgname/LICENSE
}