Thursday 24 May 2018

Introducing '' templates

Sometimes when respinning an ISO using '' you find yourself using the same combination of options. Typically each combination is to include a specific type of functionality. An example might be for someone with a Broadcom wifi device always having to load and move the NVRAM file to its required location.

I've now added functionality that can simply this through the introduction of 'templates'. Similar to how the processor options of 'atom' and 'apollo' work, a template is a list of options to be included when respinning.

Looking at the​ wifi example ​in more detail, ​the ​required ​options ​​might be​:​

-f nvram.txt \
-c "mv /usr/local/bin/nvram.txt /lib/firmwaee/brcm/brcm4330-stdio.txt"

​which can be save​d​ in a text file, say 'wifi.tpl',​ with the extension '.tpl' being used just to serve as a descriptive reminder of the file's contents. This file can then be used with the new '-t' o​r​ '--template' option when respinning, fo​r​ example: -i ubuntu-18.04-desktop-amd64.iso​ --atom -t wifi.tpl
Templates can ​also ​be combined. Another example might be when a spec​i​f​i​c set of packages is required such as for 'ssh' so if the template fi​l​e 'ssh.t​​p​l​' contained '-p "ssh openssh.server"' ​then respinning with both ​'​wifi​'​ and 'ssh' is as s​imp​le as: -i ubuntu18.04.desktop.iso --atom -t wifi.tpl -t ssh.tpl
There actually is no reason why the '--atom' option cannot be included within a template however it ​would ​make sense to call the template​ ​something ​​meaningful e.g. 'atom-wifi.tpl'.

Templates are also extremely useful for complex respins. To respin an ​ISO for the ​GPD Pocket device the ​current command is​:​ -i ​<​ISO​>​ \
​​-k v4.17-rc2 \
-e bcmwl-kernel-source \
-p "xfonts-terminus thermald tlp va-driver-all vainfo libva2 i965-va-driver gstreamer1.0-libav gstreamer1.0-vaapi vlc python-gi git python gir1.2-appindicator3-0.1" \
-f display/20-intel.conf \
-f display/30-monitor.conf \
-f display/35-screen.conf \
-f display/40-touch.conf \
-f display/40-trackpoint.conf \
-f display/console-setup \
-f display/monitors.xml \
-f display/adduser.local \
-f display/90-scale \
-f display/90-interface \
-f display/ \
-f audio/chtrt5645.conf \
-f audio/HiFi.conf \
-f audio/headphone-jack \
-f audio/ \
-f audio/ \
-f fan/gpdfand \
-f fan/gpdfand.conf \
-f fan/ \
-f fan/gpdfand.service \
-f fan/ \
-f network/99-local-bluetooth.rules \
-f network/brcmfmac4356-pcie.txt \
-f network/ \
-f power/ \
-c \
-c \
-c \
-c \
-c \
-g "" \
-g "i915.fastboot=1 i915.semaphores=1 fbcon=rotate:1 gpd-pocket-fan.speed_on_ac=0"

Whilst this can be stored as a template ​to simplify things further template​s​ can in turn contain templates so a com​p​lex respin ca​n​ both be easier t​o build and understand.
For​ example we ​could build ​a ​template​ ​f​o​r​ 'display' as '​gpd-display.tpl' containing:

--file gpd-pocket-ubuntu-respin/display/20-intel.conf
--file gpd-pocket-ubuntu-respin/display/30-monitor.conf
--file gpd-pocket-ubuntu-respin/display/35-screen.conf
--file gpd-pocket-ubuntu-respin/display/40-touch.conf
--file gpd-pocket-ubuntu-respin/display/40-trackpoint.conf
--file gpd-pocket-ubuntu-respin/display/console-setup
--file gpd-pocket-ubuntu-respin/display/monitors.xml
--file gpd-pocket-ubuntu-respin/display/adduser.local
--file gpd-pocket-ubuntu-respin/display/90-scale
--file gpd-pocket-ubuntu-respin/display/90-interface
--file gpd-pocket-ubuntu-respin/display/

​and then similar templates for 'gpd-audio.tpl', 'gpd-fan.tpl' etc. together with a 'gpd.tpl' template containing:

​--template gpd-kernel.tpl
--template gpd-packages.tpl
--template gpd-display.tpl
--template gpd-audio.tpl
--template gpd-fan.tpl
--template gpd-network.tpl
--template gpd-power.tpl
--template gpd-grub.tpl​

So respinning ​U​b​u​ntu ​B​ionic for ​the GPD Pocket becomes​:​ -i ubuntu-18.04-desktop-amd64.iso​ -t gpd​.tpl​
Taken to an even further ​level the ISO can be specified as a template e.g. 'bionic​.tpl​' containing '-i ​ubuntu-18.04-desktop-amd64.iso'

So the ​final ​respin becomes​:
​ -t bionic.tpl -t gpd.tpl

To assist in building templates each time ​'​​'​ is ​successfully run a template file 'isorespin.tpl' ​is ​created containing the options used in respinning excluding the ISO option.

Fot the ​GPD Pocket example above the 'isorespin.tpl' file after respinning contains​:​

--kernel v4.17-rc2
--erase bcmwl-kernel-source
--package "xfonts-terminus thermald tlp va-driver-all vainfo libva2 i965-va-driver gstreamer1.0-libav gstreamer1.0-vaapi vlc python-gi git python gir1.2-appindicator3-0.1"
--file /<path>/gpd-pocket-ubuntu-respin/display/20-intel.conf
--file /<path>/gpd-pocket-ubuntu-respin/display/30-monitor.conf
--file /<path>/gpd-pocket-ubuntu-respin/display/35-screen.conf
--file /<path>/gpd-pocket-ubuntu-respin/display/40-touch.conf
--file /<path>/gpd-pocket-ubuntu-respin/display/40-trackpoint.conf
--file /<path>/gpd-pocket-ubuntu-respin/display/console-setup
--file /<path>/gpd-pocket-ubuntu-respin/display/monitors.xml
--file /<path>/gpd-pocket-ubuntu-respin/display/adduser.local
--file /<path>/gpd-pocket-ubuntu-respin/display/90-scale
--file /<path>/gpd-pocket-ubuntu-respin/display/90-interface
--file /<path>/gpd-pocket-ubuntu-respin/display/
--file /<path>/gpd-pocket-ubuntu-respin/audio/chtrt5645.conf
--file /<path>/gpd-pocket-ubuntu-respin/audio/HiFi.conf
--file /<path>/gpd-pocket-ubuntu-respin/audio/headphone-jack
--file /<path>/gpd-pocket-ubuntu-respin/audio/
--file /<path>/gpd-pocket-ubuntu-respin/audio/
--file /<path>/gpd-pocket-ubuntu-respin/fan/gpdfand
--file /<path>/gpd-pocket-ubuntu-respin/fan/gpdfand.conf
--file /<path>/gpd-pocket-ubuntu-respin/fan/
--file /<path>/gpd-pocket-ubuntu-respin/fan/gpdfand.service
--file /<path>/gpd-pocket-ubuntu-respin/fan/
--file /<path>/gpd-pocket-ubuntu-respin/network/99-local-bluetooth.rules
--file /<path>/gpd-pocket-ubuntu-respin/network/brcmfmac4356-pcie.txt
--file /<path>/gpd-pocket-ubuntu-respin/network/
--file /<path>/gpd-pocket-ubuntu-respin/power/
--grub ""
--grub "i915.fastboot=1 i915.semaphores=1 fbcon=rotate:1 gpd-pocket-fan.speed_on_ac=0"

where '/<path>/' is the full path to the specified file.

Besides using t​h​e template file as a base for ​further ​individual templates yo​u​ can also simply recreate the last respun ​ISO​ by rerunning with the last generated template: -i <ISO> -t isorespin.tpl

Please​ donate if yo​u​ find this functionality and/or the script useful​ using the following link