Skip to content

Instantly share code, notes, and snippets.

@mauritiusdadd
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mauritiusdadd/2085b330176a7753963e to your computer and use it in GitHub Desktop.
Save mauritiusdadd/2085b330176a7753963e to your computer and use it in GitHub Desktop.
Fixed PKGBUILD for microchip-mplabxc8-bin 1.34-5
# Maintainer: Grey Christoforo <grey@christoforo.net>
_number_of_bits=8
pkgname=microchip-mplabxc${_number_of_bits}-bin
pkgver=1.34
pkgrel=5
pkgdesc="Microchip's MPLAB XC8 C compiler toolchain for their PIC10/12/16/18 microcontroller families and their PIC14000 device"
arch=(i686 x86_64)
url=http://www.microchip.com/xc${_number_of_bits}
license=(custom)
depends_i686=('expat' 'gcc-libs')
depends_x86_64=('lib32-expat' 'lib32-gcc-libs')
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")
noextract=(installerBlobFromMicrochip)
sha256sums=('ab0e36db27919fee2f41f95f345920e50fa3f32ba64f0accd2e041715ebdb231')
install=${pkgname}.install
build() {
mkdir "${srcdir}/build"
cd "${srcdir}/build"
cp "${srcdir}/installerBlobFromMicrochip" "${srcdir}/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
msg2 "Unpacking installer. This might take a while..."
LD_LIBRARY_PATH="${srcdir}/build/installerBlobFromMicrochip.vfs/usr/lib" \
TCL_LIBRARY="${srcdir}/build/installerBlobFromMicrochip.vfs/lib" \
TCLLIBPATH="${srcdir}/build/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 "${srcdir}/build/unpacked.vfs" -name '*___bitrockBigFile1')
do
firstChunk="$f"
baseName="${firstChunk//___bitrockBigFile1/}"
allPieces=$(find "${srcdir}/build/unpacked.vfs" -path "${baseName}*___bitrockBigFile*" | sort --version-sort)
echo " - ressembling ${baseName}"
cat ${allPieces} > "${baseName}"
done
}
package() {
mkdir -p "${pkgdir}/opt/${pkgname}"
mv "${srcdir}/build/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}"
cp "${pkgdir}/opt/microchip-mplabxc8-bin/docs/license.txt" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment