Created
September 3, 2015 07:31
-
-
Save mickael9/e107ad9f687690865c7f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
post_install() { | |
update-desktop-database -q | |
udevadm control --reload-rules &> /dev/null | |
echo "--------------------------------------------------------- | |
Before using MPLAB X you have to agree with LICENSE: | |
/usr/share/licenses/microchip-mplabx-bin/LICENSE | |
To run MPLAB X, type 'mplab_ide' in console or just use the 'microchip-mplabx.desktop' desktop file. | |
To run (IPE) Integrated Programmer Environment, type 'mplab_ipe' in console or just use the 'microchip-mplab_ipe.desktop' desktop file. | |
---------------------------------------------------------" | |
} | |
post_upgrade() { | |
post_install | |
} | |
post_remove() { | |
update-desktop-database -q | |
udevadm control --reload-rules &> /dev/null | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Maintainer: Peter Ivanov <[email protected]> | |
# Contributor: mickael9 <mickael9 at gmail dot com> | |
# Contributor: joat | |
# Submitter: BxS <bxsbxs at gmail dot com> | |
pkgname=microchip-mplabx-bin | |
pkgver=3.10 | |
pkgrel=1 | |
pkgdesc="IDE for Microchip PIC and dsPIC development" | |
arch=(i686 x86_64) | |
url='http://www.microchip.com/mplabx' | |
license=(custom) | |
depends=(gtk2 alsa-lib libxslt libxtst desktop-file-utils "java-runtime>=7") | |
depends_x86_64=(lib32-glibc lib32-fakeroot) | |
makedepends=(fakechroot) | |
optdepends=('microchip-mplabxc8-bin: C compiler for PIC10 PIC12 PIC16 PIC18 MCUs' | |
'microchip-mplabxc16-bin: C compiler for PIC24 MCUs and dsPIC DSCs' | |
'microchip-mplabxc32-bin: C Compiler for PIC32 MCUs' | |
'microchip-mplabc18_bin: C compiler for PIC18 MCUs' | |
'sdcc: C compiler for PIC16/18 MCUs' | |
'jdk: required JavaFX is included in Oracle JDK' | |
'openjfx: required JavaFX package for OpenJDK users' | |
) | |
provides=(mplab) | |
conflicts=(mplab) | |
options=(!strip docs libtool emptydirs !zipman !upx) | |
install="${pkgname}.install" | |
_mplabx_dir="/opt/microchip/mplabx/v${pkgver}" | |
_mplabcomm_dir="/opt/microchip/mplabcomm/v${pkgver}" | |
_mplabx_installer="MPLABX-v${pkgver}-linux-installer" | |
_mplabcomm_installer="MPLABCOMM-v${pkgver}-linux-installer" | |
source=("http://ww1.microchip.com/downloads/en/DeviceDoc/${_mplabx_installer}.tar" | |
"LICENSE") | |
source_x86_64=("fakechroot-i686.pkg.tar.xz::http://www.archlinux.org/packages/extra/i686/fakechroot/download/") | |
md5sums=('7746910503fd9a01152d43b649cca211' | |
'a34a85b2600a26f1c558bcd14c2444bd') | |
md5sums_x86_64=('92b9a1dc8fa0534048790731a7bf2fc5') | |
backup=("${_mplabx_dir:1}/mplab_ide/etc/mplab_ide.conf") | |
PKGEXT='.pkg.tar' | |
package() { | |
mkdir -p "${pkgdir}"/{etc,usr/{bin,lib},tmp} | |
# Create a fake chroot in $pkgdir to run installers into | |
ln -s /usr/bin "${pkgdir}/" | |
echo "root:x:0:0:root:/root:/bin/bash" > "${pkgdir}/etc/passwd" | |
echo "root:x:0:root" > "${pkgdir}/etc/group" | |
echo "Extracting installers..." | |
sh ${_mplabx_installer}.sh --tar xf | |
mv ${_mplabx_installer}.run ${_mplabcomm_installer}.run "${pkgdir}/tmp" | |
chmod 0755 "${pkgdir}/tmp/${_mplabx_installer}.run" | |
chmod 0755 "${pkgdir}/tmp/${_mplabcomm_installer}.run" | |
# Create install script | |
cat << EOF > "${pkgdir}/tmp/install.sh" | |
#!/bin/sh | |
LD_LIBRARY_PATH="${srcdir}/usr/lib/libfakeroot/fakechroot:\$LD_LIBRARY_PATH" | |
PATH=/bin | |
echo Running MPLABX installer... | |
tmp/${_mplabx_installer}.run --mode unattended >/dev/null | |
echo Running MPLABCOMM installer... | |
tmp/${_mplabcomm_installer}.run --mode unattended >/dev/null | |
EOF | |
chmod 0755 "${pkgdir}/tmp/install.sh" | |
# Run installers in the fake chroot | |
fakechroot chroot "${pkgdir}" tmp/install.sh | |
# Remove uninstaller | |
rm -f "${pkgdir}${_mplabx_dir}"/Uninstall_* | |
# Fix ugly fonts | |
sed -i 's/^default_options="/default_options="-J-Dawt.useSystemAAFontSettings=on /' "${pkgdir}${_mplabx_dir}/mplab_ide/etc/mplab_ide.conf" | |
# Patch jdkhome to use system JRE | |
local conf | |
for conf in mplab_ipe/mplab_ipe mplab_ipe/ipecmd.sh mplab_ide/etc/mplab_ide.conf; do | |
sed -i '/^jdkhome=/c \jdkhome=/usr/lib/jvm/default-runtime/' "${pkgdir}${_mplabx_dir}/${conf}" | |
done | |
sed -i '/^"$jdkhome"bin\/java/c\ java -jar '${_mplabx_dir}'/mplab_ipe/ipe.jar' "${pkgdir}${_mplabx_dir}/mplab_ipe/mplab_ipe" | |
# Remove bundled JRE | |
rm -rf "${pkgdir}${_mplabx_dir}/sys" | |
# Move libs away from /usr/local/lib | |
mv "${pkgdir}"/usr/local/lib/*.so{,.*} "${pkgdir}"/usr/lib/ | |
rm -rf "${pkgdir}/usr/local/" | |
# Symlink executables | |
ln -sf "${_mplabx_dir}"/mplab_ide/bin/mplab_ide "${pkgdir}/usr/bin/" | |
ln -sf "${_mplabx_dir}"/mplab_ipe/mplab_ipe "${pkgdir}/usr/bin/" | |
ln -sf "${_mplabcomm_dir}/lib/mchplinusbdevice" "${pkgdir}/etc/.mplab_ide/" | |
# Symlink libs from MPLABCOMM | |
local lib | |
for lib in "${pkgdir}${_mplabcomm_dir}"/lib/*.so{,.*}; do | |
local bname=$(basename "$lib") | |
ln -sf "${_mplabcomm_dir}/lib/${bname}" "${pkgdir}/usr/lib/" | |
done | |
# Correctly link .so.* -> .so for all libs | |
for lib in "${pkgdir}"/usr/lib/*.so.*; do | |
local bname=$(basename "$lib") | |
local soname=${bname%.so.*} | |
ln -sf ${bname} "${pkgdir}/usr/lib/${soname}.so" | |
done | |
# Tweak .desktop files for better desktop integration | |
echo "StartupWMClass=MPLAB X IDE v${pkgver}" >> "${pkgdir}/usr/share/applications/mplab.desktop" | |
echo "StartupWMClass=com-microchip-ipe-ui-ProdProgrammerApp" >> "${pkgdir}/usr/share/applications/mplab_ipe.desktop" | |
# Install license files | |
install -Dm 644 "${srcdir}"/LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE" | |
install -Dm 644 "${pkgdir}${_mplabcomm_dir}/MPLABCOMMLicense.txt" "${pkgdir}/usr/share/licenses/${pkgname}/MPLABCOMMLicense.txt" | |
# Cleanup | |
rm "${pkgdir}"/{bin,etc/{group,passwd}} | |
rm -r "${pkgdir}/tmp" | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment