Skip to content

Commit 59514e3

Browse files
committed
.. commit more often
1 parent 44a5e29 commit 59514e3

8 files changed

+81
-52
lines changed

Dockerfile

+1-2
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,14 @@ ARG C_HOME="/home/${C_USER}"
3939
ARG C_UID=1000
4040
ARG C_GUID=1000
4141

42-
ARG ADDITIONAL_PACKAGES
43-
4442
ARG MPLABX_IDE=1
4543
ARG MPLABX_IDE_START=1
4644
ARG MPLABX_IPE=0
4745
ARG MPLABX_TELEMETRY=0
4846
ARG MPLABX_DARCULA=1
4947
ARG MPLABX_VERSION=0
5048
ARG DIRTY_CLEANUP=0
49+
ARG ADDITIONAL_PACKAGES
5150

5251
ARG ARDUINO=0
5352
ARG AVRGCC=0

docker-compose.yml

+1-7
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,7 @@ services:
1111
volumes:
1212
- /tmp/.X11-unix:/tmp/.X11-unix:ro
1313
- /dev/bus/usb:/dev/bus/usb
14-
- ./MPLABX_Folders/MPLABXProjects:/mplabx/MPLABXProjects
15-
- ./MPLABX_Folders/cache:/mplabx/.cache
16-
- ./MPLABX_Folders/java:/mplabx/.java
17-
- ./MPLABX_Folders/mchp_packs:/mplabx/.mchp_packs
18-
- ./MPLABX_Folders/mplab_ide:/mplabx/.mplab_ide
19-
- ./MPLABX_Folders/mplabcomm:/mplabx/.mplabcomm
20-
- ./MPLABX_Folders/oracle_jre_usage:/mplabx/.oracle_jre_usage
14+
- ./mplabx:/home/mplabx
2115
device_cgroup_rules:
2216
- 'c 189:* rmw'
2317
cap_drop:

scripts/mplabx/init.bash

+29-21
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,11 @@
22

33
mkdir -p /usr/share/man/man1 # long forgotten, but fixes some error
44

5-
dpkg --add-architecture i386
65
apt-get update
76
apt-get -qq install --yes --no-install-recommends \
87
bc \
98
ca-certificates \
109
curl \
11-
libc6:i386 \
12-
libx11-6:i386 \
13-
libxext6:i386 \
14-
libstdc++6:i386 \
15-
libexpat1:i386 \
1610
libgail18 \
1711
libgtk2.0-0 \
1812
libgtk2.0-bin \
@@ -33,23 +27,37 @@ apt-get -qq install --yes --no-install-recommends \
3327
xz-utils \
3428
x11-utils "$ADDITIONAL_PACKAGES"
3529

36-
wait
3730

38-
V535MINUS=0
39-
if [ "$MPLABX_VERSION" -gt 0 ]
40-
then
41-
V535MINUS=$(bc -l <<< "$MPLABX_VERSION < 5.35")
42-
fi
31+
V535MINUS=$(bc -l <<< "$MPLABX_VERSION <= 5.35")
4332

33+
# mplabx >= v5.40 will be 64bit
4434
if [ "$V535MINUS" -eq 1 ]
35+
then
36+
dpkg --add-architecture i386
37+
apt-get update
38+
apt-get -qq install --yes --no-install-recommends \
39+
libc6:i386 \
40+
libx11-6:i386 \
41+
libxext6:i386 \
42+
libstdc++6:i386 \
43+
libexpat1:i386
44+
fi
45+
46+
V530MINUS=0
47+
if [ "$MPLABX_VERSION" -gt 0 ]
4548
then
46-
apt-get install --yes --no-install-recommends default-jre
49+
V530MINUS=$(bc -l <<< "$MPLABX_VERSION <= 5.30")
50+
if [ "$V530MINUS" -eq 1 ]
51+
then
52+
# is this even needed after adding JAVA_HOME?
53+
apt-get install --yes --no-install-recommends default-jre
54+
fi
4755
fi
4856

4957
/create_user.bash \
50-
&& /mplabx_install.bash \
51-
&& /toolchain_install.bash \
52-
&& /startup_script.bash
58+
&& /mplabx_install.bash \
59+
&& /toolchain_install.bash \
60+
&& /startup_script.bash
5361

5462
if [ ! "$C_USER" = root ]
5563
then
@@ -60,8 +68,8 @@ fi
6068
/cleanup.bash
6169
apt-get purge --yes bc curl procps make xz-utils
6270
apt-get -qq clean autoclean \
63-
&& rm --recursive --force /usr/share/man/* \
64-
&& rm --recursive --force /tmp/* \
65-
&& rm --recursive --force /var/log/* \
66-
&& bash -c 'rm --recursive --force /var/lib/{apt,dpkg,cache,log}/*' \
67-
&& find / -maxdepth 1 -name "*.bash" -delete
71+
&& rm --recursive --force /usr/share/man/* \
72+
&& rm --recursive --force /tmp/* \
73+
&& rm --recursive --force /var/log/* \
74+
&& rm --recursive --force /var/lib/{apt,dpkg,cache,log}/* \
75+
&& find / -maxdepth 1 -name "*.bash" -delete

scripts/mplabx/mplabx_install.bash

+17-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,13 @@ fi
5151

5252
if [ "$CUSTOM_VERSION" -gt 0 ]
5353
then
54-
MPLABX_URL="https://ww1.microchip.com/downloads/en/DeviceDoc/MPLABX-v$MPLABX_VERSION-linux-installer.tar"
54+
if python -c "exit(0) if $MPLABX_VERSION * 100 % 5 == 0 else exit(1)" # confirm version ending in [.05, .10] etc
55+
then
56+
MPLABX_URL="https://ww1.microchip.com/downloads/en/DeviceDoc/MPLABX-v$MPLABX_VERSION-linux-installer.tar"
57+
else
58+
echo "Incorrect MPLABX version: $MPLABX_VERSION"
59+
exit 1
60+
fi
5561
fi
5662

5763
printf '\nMPLAB X\n'
@@ -68,4 +74,14 @@ if [ "$MPLABX_DARCULA" -eq 1 ]
6874
curl "$DARCULA_URL" > "$C_HOME/darcula_theme.nbm"
6975
fi
7076

77+
cd "$C_HOME" \
78+
&& mkdir MPLABXProjects \
79+
.cache \
80+
.java \
81+
.mchp_packs \
82+
.mplabcomm \
83+
.mplab_ide \
84+
.oracle_jre_usage
85+
86+
7187
rm --recursive --force /tmp/*

scripts/mplabx/startup_script.bash

+8-3
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,15 @@ if [ "$MPLABX_IDE_START" -eq 1 ]
1616
cat > /mplab_start.sh << EOF
1717
#!/bin/sh
1818
export JAVA_HOME="$JAVA_HOME"
19-
export PATH="$path$PATH"
20-
mplab_ide
19+
export PATH="$JAVA_HOMEbin:$path$PATH"
20+
/usr/bin/mplab_ide
2121
EOF
2222
else
23-
printf '#!/bin/bash\nbash --login' > /mplab_start.sh
23+
cat > /mplab_start.sh << EOF
24+
#!/bin/sh
25+
export JAVA_HOME="$JAVA_HOME"
26+
export PATH="$JAVA_HOME:$path$PATH"
27+
/bin/bash --login'
28+
EOF
2429
fi
2530
chmod 775 /mplab_start.sh

scripts/mplabx/toolchain_install.bash

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# download and install toolchains
44

55
# ARDUINO
6+
# TODO: this has never worked, problem with plugin/procedure
67
if [ "$ARDUINO" -eq 1 ]
78
then
89
printf '\nARDUINO\n'

scripts/tool_dl/init.bash

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
#!/bin/sh
22

3-
if [ "$MCP_USER" ]
3+
if [ "$MCP_USER" ] && [ "$MCP_PASS" ]
44
then
55
apt-get update \
66
&& apt-get install --yes firefox-esr \
7-
findutils \
8-
xvfb
7+
findutils \
8+
xvfb
99
pip3 install selenium \
10-
wget \
11-
&& latest_release="$(curl https://github.com/mozilla/geckodriver/releases | grep -io "/mozilla/geckodriver/releases/download/v0.[0-9]*.[0-9]*/geckodriver-v0.[0-9]*.[0-9]*-linux64.tar.gz" | head -1)" \
10+
&& latest_release="$(curl https://github.com/mozilla/geckodriver/releases 2> /dev/null \
11+
| grep -io \
12+
"/mozilla/geckodriver/releases/download/v0.[0-9]*.[0-9]*/geckodriver-v0.[0-9]*.[0-9]*-linux64.tar.gz" \
13+
| head -1)" \
1214
&& echo 'Downloading geckodriver' \
1315
&& wget --quiet "https://github.com$latest_release" \
1416
&& tar xf geckodriver*.tar.gz \
1517
&& mv geckodriver /bin \
1618
&& mkdir /toolchains
1719
/kill_firefox.bash &
20+
echo 'Starting downloader'
1821
xvfb-run /toolchains.py
1922
else
20-
/toolchains.py
23+
echo 'No user/password combo input for myMicrochip downloads'
24+
exit 0 # self provided url's or ide/ipe only
2125
fi

scripts/tool_dl/toolchains.py

+14-12
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
# needs a valid microchip user
44
import os
55
import sys
6-
import wget
76
import pickle
87
import multiprocessing as mp
98
from time import sleep
109
from selenium import webdriver
1110

11+
toolchains = ['AVRGCC', 'ARMGCC', 'MCPXC8', 'MCPXC16', 'MCPXC32', 'MPLAB_HARMONY', 'PIC32_LEGACY', 'OTHERMCU']
12+
1213
profile = webdriver.FirefoxProfile()
1314
# remove download dialog, set download directory etc
1415
profile.set_preference('browser.preferences.instantApply', True)
@@ -63,22 +64,23 @@ def check_downloads():
6364
sleep(1)
6465
check_downloads()
6566

66-
6767
try:
6868
mcp_login(os.environ['MCP_USER'], os.environ['MCP_PASS'])
69-
except TypeError:
70-
print('No Microchip user/pass input')
69+
except:
70+
print('myMicrochip login error')
71+
sys.exit(1)
7172

72-
toolchains = ['AVRGCC', 'ARMGCC', 'MCPXC8', 'MCPXC16', 'MCPXC32', 'MPLAB_HARMONY', 'PIC32_LEGACY', 'OTHERMCU']
7373
for tool in toolchains:
7474
if tool in os.environ:
75-
url = os.environ[tool + '_URL']
76-
if '.microchip.com' in url:
77-
print('Started download of {}'.format(tool))
78-
mcp_get(os.environ[tool + '_URL'])
79-
sleep(5)
80-
else:
81-
print('User defined URL of {}, will be downloaded later'.format(tool))
75+
if os.environ[tool] == '1':
76+
url = os.environ[tool + '_URL']
77+
if '.microchip.com' in url:
78+
print('Starting download of {}'.format(tool))
79+
mcp_get(os.environ[tool + '_URL'])
80+
sleep(5)
81+
else:
82+
print('User defined URL of {} will be downloaded later'.format(tool))
8283

8384
check_downloads()
8485
sys.exit(0)
86+

0 commit comments

Comments
 (0)