summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorWesley Chan2015-09-18 14:54:51 +0800
committerWesley Chan2015-09-18 14:54:51 +0800
commit258136dc1814f2fd90dd4e20dad85ca9c91fc5f8 (patch)
tree170e25fad07e5f25de77d4d104a5dab86f1456a4
downloadaur-258136dc1814f2fd90dd4e20dad85ca9c91fc5f8.tar.gz
Initial import
-rw-r--r--.SRCINFO23
-rw-r--r--PKGBUILD34
-rwxr-xr-xbitrock-unpacker.tcl122
-rw-r--r--microchip-pic32-legacy-plib.install16
4 files changed, 195 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 000000000000..bac6137532fc
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,23 @@
+pkgbase = microchip-pic32-legacy-plib
+ pkgdesc = Microchip's PIC32 peripheral support libraries.
+ pkgver = 1.00
+ pkgrel = 1
+ url = http://www.microchip.com/pagehandler/en-us/devtools/mplabxc/home.html?tab=t2
+ arch = any
+ license = custom
+ makedepends = sdx
+ depends = microchip-mplabxc32-bin
+ options = !strip
+ options = docs
+ options = libtool
+ options = emptydirs
+ options = !zipman
+ options = staticlibs
+ options = !upx
+ source = http://ww1.microchip.com/downloads/en/DeviceDoc/PIC32 Legacy Peripheral Libraries Linux.tar
+ source = bitrock-unpacker.tcl
+ sha256sums = 644edc09b5164dbfe80c4f42c12fe506b58481bd71e4d0228b62ec7c305d027f
+ sha256sums = 1bcb58cdbb6e4a89415cf91cb6692aa0ada3abb41d22134510f8477ffd90b8a2
+
+pkgname = microchip-pic32-legacy-plib
+
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 000000000000..0ebec3d50856
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,34 @@
+# Maintainer: Wesley Chan <address at domain dot com>
+
+pkgname=microchip-pic32-legacy-plib
+pkgver=1.00
+pkgrel=1
+pkgdesc="Microchip's PIC32 peripheral support libraries."
+arch=('any')
+url=http://www.microchip.com/pagehandler/en-us/devtools/mplabxc/home.html?tab=t2
+license=(custom)
+depends=(microchip-mplabxc32-bin)
+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=("http://ww1.microchip.com/downloads/en/DeviceDoc/PIC32 Legacy Peripheral Libraries Linux.tar"
+ "bitrock-unpacker.tcl")
+
+sha256sums=('644edc09b5164dbfe80c4f42c12fe506b58481bd71e4d0228b62ec7c305d027f'
+ '1bcb58cdbb6e4a89415cf91cb6692aa0ada3abb41d22134510f8477ffd90b8a2')
+
+PKGEXT='.pkg.tar'
+
+build() {
+ msg2 "Unpacking files from installer"
+ ./bitrock-unpacker.tcl ./PIC32\ Legacy\ Peripheral\ Libraries.run ./unpacked.vfs
+}
+
+package() {
+ mkdir -p "${pkgdir}"`ls -rd /opt/microchip/xc32/*/ | { read first rest ; echo $first; }`
+ mv ${srcdir}/unpacked.vfs/default/programfileswindows/* "${pkgdir}"`ls -rd /opt/microchip/xc32/*/ | { read first rest ; echo $first; }`
+}
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/microchip-pic32-legacy-plib.install b/microchip-pic32-legacy-plib.install
new file mode 100644
index 000000000000..b6af665c4744
--- /dev/null
+++ b/microchip-pic32-legacy-plib.install
@@ -0,0 +1,16 @@
+message_to_user(){
+ echo '
+ This package will change a few lines in files of XC32 as the official installer does.
+ Thus, installing with `makepkg -i` will produce an error, stating files already exist.
+ Please use `pacman -U --force <file_name_of_the_package.tar>` to install instead.
+ It always installs to the latest version of XC32 available on your computer.
+'
+}
+
+post_install() {
+ message_to_user
+}
+
+post_upgrade() {
+ message_to_user
+}