Skip to content

Commit

Permalink
Improve compatibility of consolidated build with older software
Browse files Browse the repository at this point in the history
  • Loading branch information
wholetthedogsout committed Sep 5, 2018
1 parent 02b0478 commit f236bd2
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 7 deletions.
17 changes: 10 additions & 7 deletions scripts/consolidated/Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
build/container.fmp: cleartmp build/consolidated.fmp
cd tmp; \
cp ../files/container.json ./manifest.json; \
cp ../files/server.js ../build/consolidated.fmp ../files/fabmo-temp-updater.service .; \
cp ../files/install ../files/do-consolidated-update.sh ../files/server.js ../build/consolidated.fmp ../files/fabmo-temp-updater.service .; \
tar -cvzf updater-stub.tar.gz server.js; \
tar -cvzf consolidated.tar.gz consolidated.fmp; \
tar -cvzf service.tar.gz fabmo-temp-updater.service; \
tar -cvzf ../build/container.fmp updater-stub.tar.gz manifest.json consolidated.tar.gz service.tar.gz
cp ../files/fabmo-temp-updater-old.service ./fabmo-temp-updater.service; \
tar -cvzf ../build/container.fmp updater-stub.tar.gz manifest.json consolidated.tar.gz service.tar.gz install do-consolidated-update.sh fabmo-temp-updater.service

dl/engine.fmp dl/updater.fmp:
mkdir -p dl
Expand All @@ -15,12 +16,14 @@ engine.tar.gz: cleartmp dl/engine.fmp
cd tmp; \
tar -xvzf ../dl/engine.fmp; \
mv files.tar.gz ../engine.tar.gz ;\
mv g2.bin ../
mv g2.bin ../; \
rm ../dl/engine.fmp;

updater.tar.gz: cleartmp dl/updater.fmp
cd tmp; \
tar -xvzf ../dl/updater.fmp; \
mv files.tar.gz ../updater.tar.gz
mv files.tar.gz ../updater.tar.gz; \
rm ../dl/updater.fmp;

token.tar.gz: cleartmp
cd tmp; \
Expand All @@ -31,9 +34,9 @@ token.tar.gz: cleartmp
build/consolidated.fmp: cleartmp token.tar.gz updater.tar.gz engine.tar.gz g2.bin files/consolidated.json
mkdir -p build
cd tmp; \
cp ../engine.tar.gz .; \
cp ../updater.tar.gz .; \
cp ../token.tar.gz .; \
mv ../engine.tar.gz .; \
mv ../updater.tar.gz .; \
mv ../token.tar.gz .; \
cp ../g2.bin .; \
cp ../files/consolidated.json ./manifest.json; \
tar -cvzf ../build/consolidated.fmp engine.tar.gz updater.tar.gz g2.bin manifest.json token.tar.gz
Expand Down
51 changes: 51 additions & 0 deletions scripts/consolidated/files/do-consolidated-update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/sh

# This is a consolidated update script (shim) targeted
# at pre-2.0 updaters with a more primitive update system
# It does most of the heavy lifting itself, with some of
# the scripts that come with the new updater picking up once
# that code is down.

# Write mount the disk
mount -w -o remount /

# Kill the running services
systemctl stop fabmo fabmo-updater

sleep 3

# Expand consolidated update package
mkdir /tmp/consolidated-update
cd /tmp/consolidated-update
tar -xvzf /tmp/consolidated.fmp

# Obliterate and recreate the engine/updater directories
rm -rf /fabmo/updater /fabmo/engine
mkdir /fabmo/updater /fabmo/engine

# Lay down the engine and updater
cd /fabmo/updater
tar -xvzf /tmp/consolidated-update/updater.tar.gz

cd /fabmo/engine
tar -xvzf /tmp/consolidated-update/engine.tar.gz

# Flush to disk
sync

# Update the G2 firmware
/fabmo/updater/hooks/linux/edison/update_firmware.sh /fabmo/engine/firmware/g2.bin

# Mark done
touch /fabmo/engine/install_token
touch /fabmo/updater/install_token

# Clear the app root
rm -rf /opt/fabmo/approot
sync

# Re-lock the disk
mount -r -o remount /

# Start everyhting back up
systemctl restart fabmo fabmo-updater
10 changes: 10 additions & 0 deletions scripts/consolidated/files/fabmo-temp-updater-old.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Unit]
Description=One time updater consolidated update

[Service]
Type=oneshot
ExecStart=/bin/sh /tmp/do-consolidated-update.sh
StandardOutput=journal

[Install]
WantedBy=multi-user.target
22 changes: 22 additions & 0 deletions scripts/consolidated/files/install
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh

mount -w -o remount /

FMUDIR=$(pwd)

rm -rf /opt/fabmo/updater/install_token

systemctl stop fabmo

# expandArchive src: updater-stub.tar.gz dest: /fabmo/engine
cd /fabmo/engine; tar -xvzf $FMUDIR/updater-stub.tar.gz

# expandArchive src: tmp dest: /tmp
cd /tmp; tar -xvzf $FMUDIR/consolidated.tar.gz

# expandArchive src: service.tar.gz dest: /etc/systemd/system
# cd /etc/systemd/system; tar -xvzf $FMUDIR/service.tar.gz
cp $FMUDIR/fabmo-temp-updater.service /etc/systemd/system
cp $FMUDIR/do-consolidated-update.sh /tmp

systemctl restart fabmo

0 comments on commit f236bd2

Please sign in to comment.