diff options
-rw-r--r-- | .SRCINFO | 15 | ||||
-rw-r--r-- | PKGBUILD | 88 | ||||
-rwxr-xr-x | bitrock-unpacker.tcl | 122 | ||||
-rw-r--r-- | liblzmadec0.2.so | bin | 29008 -> 0 bytes |
4 files changed, 155 insertions, 70 deletions
@@ -1,19 +1,13 @@ pkgbase = microchip-mplabxc8-bin pkgdesc = Microchip's MPLAB XC8 C compiler toolchain for their PIC10/12/16/18 microcontroller families and their PIC14000 device pkgver = 1.34 - pkgrel = 5 + pkgrel = 6 url = http://www.microchip.com/xc8 install = microchip-mplabxc8-bin.install arch = i686 arch = x86_64 license = custom makedepends = sdx - makedepends = tcl - makedepends = tcl-vfs - depends = lib32-expat - depends = lib32-gcc-libs - noextract = installerBlobFromMicrochip - noextract = liblzmadec0.2.so options = !strip options = docs options = libtool @@ -22,9 +16,12 @@ pkgbase = microchip-mplabxc8-bin options = staticlibs options = !upx source = installerBlobFromMicrochip::http://ww1.microchip.com/downloads/en/DeviceDoc/xc8-v1.34-full-install-linux-installer.run - source = liblzmadec0.2.so + source = bitrock-unpacker.tcl md5sums = 443c0b7045bf414aaccb64b91036aac8 - md5sums = e43a1f543ba4f67a2d5b2e8d9656a6c7 + md5sums = 70dedba4c417f8c0bb07c32d19e9d197 + makedepends_i686 = tclkit + depends_x86_64 = lib32-gcc-libs + makedepends_x86_64 = lib32-tclkit pkgname = microchip-mplabxc8-bin @@ -1,79 +1,45 @@ -# Maintainer: Grey Christoforo <grey@christoforo.net> +# Maintainer: Grey Christoforo <first name at last name dot net> +# Contributer: mickael9 <mickael9 at gmail dot com> _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" +pkgrel=6 +pkgdesc="Microchip's MPLAB XC${_number_of_bits} 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) -if [[ $CARCH = i686 ]]; then - depends=( - 'expat' - 'gcc-libs' - ) -else - depends=( - 'lib32-expat' - 'lib32-gcc-libs' - ) -fi -makedepends=(sdx tcl tcl-vfs) +depends_i688=(gcc-libs) +depends_x86_64=(lib32-gcc-libs) +makedepends=(sdx) +makedepends_x86_64=(lib32-tclkit) +makedepends_i686=(tclkit) + 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) +source=("installerBlobFromMicrochip::http://ww1.microchip.com/downloads/en/DeviceDoc/xc${_number_of_bits}-v$pkgver-full-install-linux-installer.run" + "bitrock-unpacker.tcl") + md5sums=('443c0b7045bf414aaccb64b91036aac8' - 'e43a1f543ba4f67a2d5b2e8d9656a6c7') + '70dedba4c417f8c0bb07c32d19e9d197') 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 +instdir="/opt/microchip/xc${_number_of_bits}/v${pkgver}" - 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 +build() { + msg2 "Unpacking files from installer" + ./bitrock-unpacker.tcl ./installerBlobFromMicrochip ./unpacked.vfs } package() { - 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}${instdir}" + mv unpacked.vfs/compiler/programfiles*/* "${pkgdir}${instdir}" + mv unpacked.vfs/licensecomponent "${pkgdir}${instdir}" + mv "${pkgdir}${instdir}"/*License.txt "${pkgdir}${instdir}/docs" 2>/dev/null || true 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 /opt/microchip-mplabxc8-bin/docs/*icense.txt $pkgdir/usr/share/licenses/$pkgname/LICENSE + echo "export PATH=\"\$PATH\":'${instdir}/bin'" > "${pkgdir}/etc/profile.d/${pkgname}.sh" + echo "export XC${_number_of_bits}_TOOLCHAIN_ROOT='${instdir}'" >> "$pkgdir/etc/profile.d/${pkgname}.sh" + + mkdir -p "$pkgdir/usr/share/licenses/$pkgname" + ln -s "${instdir}/docs/$(basename "${pkgdir}${instdir}/docs"/*[Ll]icense.txt)" "${pkgdir}/usr/share/licenses/$pkgname/LICENSE" } diff --git a/bitrock-unpacker.tcl b/bitrock-unpacker.tcl new file mode 100755 index 000000000000..43d99e0538ab --- /dev/null +++ b/bitrock-unpacker.tcl @@ -0,0 +1,122 @@ +#!/usr/bin/env tclkit +# +# Bitrock unpacking script +# This script should be executed using 32-bit tclkit because +# it uses Tcllzmadec provided by the installer blob which likely only +# contains the 32 bit tcl lzma decompression shared opject, liblzmadec0.2.so +# Author : mickael9 <mickael9 at gmail dot com> + +source /usr/bin/sdx.kit + +if {$argc < 2} { + puts "Usage: $argv0 installerFile outputDirectory" + exit 1 +} + +set installerFile [lindex $argv 0] +set destDir [lindex $argv 1] + +set installerMount /installer +set dataMount /installerData + +vfs::mk4::Mount $installerFile $installerMount -readonly + +lappend auto_path $installerMount/libraries/ +package require vfs::cookfs +package require Tcllzmadec + +# progress from http://wiki.tcl.tk/16939 (sligtly modified) +# thanks to the author +proc progress {cur tot} { + # set to total width of progress bar + set total 76 + + if {$cur == $tot} { + # cleanup + set str "\r[string repeat " " [expr $total + 4]]\r" + } else { + set half [expr {$total/2}] + set percent [expr {100.*$cur/$tot}] + set val (\ [format "%6.2f%%" $percent]\ ) + set str "\r|[string repeat = [ + expr {round($percent*$total/100)}]][ + string repeat { } [expr {$total-round($percent*$total/100)}]]|" + set str "[string range $str 0 $half]$val[string range $str [expr {$half+[string length $val]-1}] end]" + } + puts -nonewline stderr $str +} + +# Read cookfs options +set optionsFile [open $installerMount/cookfsinfo.txt] +set options [read $optionsFile] +close $optionsFile + +# Read the manifest +set manifestFile [open $installerMount/manifest.txt] +set manifest [read $manifestFile] +close $manifestFile + +# Mount the files to $dataMount +vfs::cookfs::Mount {*}$options $installerFile $dataMount + +puts "Creating directories..." +foreach {fileName props} $manifest { + set type [lindex $props 0] + + if {$type == "directory"} { + set mode [lindex $props 1] + file mkdir $destDir/$fileName + } +} + +puts "Unpacking files, please wait..." + +set entryCount [expr [llength $manifest] / 2] +set entryIndex 0 + +foreach {fileName props} $manifest { + set type [lindex $props 0] + + if {$type == "file"} { + set mode [lindex $props 1] + set sizes [lindex $props 4] + set nparts [llength $sizes] + set index 1 + + file mkdir [file dirname $destDir/$fileName] + file copy -force $dataMount/$fileName $destDir/$fileName + + if {$nparts > 0} { + set fp [open $destDir/$fileName a] + fconfigure $fp -translation binary + + while {$index < $nparts} { + set chunkName $dataMount/${fileName}___bitrockBigFile$index + set fp2 [open $chunkName r] + fconfigure $fp2 -translation binary + puts -nonewline $fp [read $fp2] + close $fp2 + incr index + } + close $fp + } + + file attributes $destDir/$fileName -permissions $mode + } + + incr entryIndex + progress $entryIndex $entryCount +} + +puts "Creating links..." + +foreach {fileName props} $manifest { + set type [lindex $props 0] + + if {$type == "link"} { + set linkTarget [lindex $props 1] + file delete $destDir/$fileName + file link -symbolic $destDir/$fileName $linkTarget + } +} +puts "Done" diff --git a/liblzmadec0.2.so b/liblzmadec0.2.so Binary files differdeleted file mode 100644 index cdfdce1d5c3c..000000000000 --- a/liblzmadec0.2.so +++ /dev/null |