"""Build the full PsionLX tree: Psion's genuine soho image, plus our additions. Until 4 October 2026 the full image was the community GPE root filesystem with Psion's configuration and our rebuilds of Psion's applications applied on top, because Psion's own image was lost. It has since been found (Pulster's archive), so the relationship is inverted: the base is now Psion's genuine soho image, byte for byte, and everything that is ours is layered on top and declared below. Nothing reaches the full image by accident. python3 merge-soho.py # card-soho + card-reconstruction + bootimg -> card/ The categories, in the order they are applied: BASE card-soho/root -- the genuine image, verified byte-faithful to Psion's tarball. Every genuine file is kept, including the launcher, dock, wallpaper, theme, icons, overrides, help, tutorial, applications and libraries. EXTRAS applications Psion did not ship, taken whole from the previous reconstruction by their package lists. Each one was checked to link against Psion's own libraries (scripts/linkcheck.py). CUSTOM deliberate departures that are ours: the Agfa fonts Psion's recipe installs but whose shipped r6 package was empty, the EPOC names for extras Psion never named, and the PsionLX picture in the media player. NEW psionlx-software, "Find new software" with its PsionNet helpers, written for PsionLX in 2026. Built from source in this workspace, link-checked against Psion's own libraries. The Spotify app, also written in 2026, is NOT in the image: it is one Install away in Find new software (Joshua, 4 Oct 2026). PACKAGES every addition above, registered with the image's ipkg as the package PsionLX-Software offers (scripts/mkfeed.py defines both), so "Find new software" shows them installed and can remove them. SAFETY the same changes as the safe image: no NAND /home mount, no flash-writing tools, and a card ejector that will not stop the disk the system is running from. FIXES bugs present in Psion's own image, and the TASKS entry "Find new software" Psion left without a command. The kernel and initial ramdisk are not part of this tree; the card's boot partition carries the hardened boot image (see docs/09-THE-SOHO-IMAGE.md). """ import hashlib, importlib.util, os, shutil, struct, sys, re W = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..') SOHO = os.path.join(W, 'card-soho', 'root') OLD = os.path.join(W, 'card-reconstruction', 'root') # the pre-soho reconstruction CARD = os.path.join(W, 'card') NEW = os.path.join(CARD, 'root') # ----------------------------------------------------------------- EXTRAS # Applications from the previous reconstruction that Psion's image lacks. # Taken by package list, so each brings exactly its own files. # # NOT CARRIED -- every program the previous card had and this one lacks: # bcscan needs GLib 2.6; no barcode hardware # desktop-suspend (pm) never worked here; Psion's power button runs apm -s # gpe-today Psion's Today screen replaces it # gpe-calculator Psion's Calculator is galculator # gpe-aerial, prismstumbler, ifrename # Wi-Fi scanning; gpe-wlancfg is carried # rosetta, xkbd handwriting and an on-screen keyboard; the # netBook Pro has a keyboard # xmonobut, keylaunch, teleport, matchbox-desktop, matchbox-panel-manager, # matchbox-panel-hacks, mb-applet-volume, mbcontrol # panel plumbing Psion left out; minimix is the # volume control # Xfbdev Psion's Xepson drives the display (the previous # card also ran an Xepson on the hardware) # xauth, xdpyinfo, ipkg-link, sysvinit, depmod.24/.26, busybox applet links # Psion's own init, depmod and busybox are kept # no package record (came with the community root filesystem): # hcid, hciattach, hciconfig, sdpd, sdptool, l2ping, hidd, ciptool, # bluepin Psion's bluez-utils 2.10 has them in /sbin and /bin # gs-esp Psion's CUPS has its own gs and pstoraster # gpe-keylock Psion's 50autolock does this # ncpd, plpbackup, plp_upgrade, sync_serv (plptools), rxvt-xpm, # rxvt-xterm, rclock, gaby helper scripts, asn1 tools, word-list-compress, # prezip-bin, bl, plog, ssconvert, unix_chkpwd, scap.sh, pppoe-discovery, # bt_connect.sh, ir_connect.sh, and psion-tasks.sh (our stand-in for the # TASKS screen, which Psion's gpe-appmgr provides) # MTD tools flash writers; see SAFETY # every backup copy of a superseded binary (*.gpe-orig, *.pre-psionise) EXTRA_PACKAGES = [ 'figment', # Jotter (EPOC name) 'xdemineur', # Bombs (EPOC name) -- "want minesweeper :P", meta-psion.oe 'gpe-tetris', 'gpe-othello', 'gpe-go', 'gpe-lights', 'gsoko', 'gpe-plucker', # e-book reader 'gpe-soundbite', # Record / Play (EPOC names) 'gpe-watch', 'gpe-timesheet', 'gpe-taskmanager', 'gpe-mixer', # Psion's overrides already name it "Audio mixer" 'telnet-session', # gtelnet / xtelnet -- Teklogix terminal emulation ] EXTRA_FILES = [ # Psion patched gpe-wlancfg, but soho does not ship it 'usr/bin/gpe-wlancfg', 'usr/share/pixmaps/gpe-wlancfg.png', 'usr/share/applications/gpe-wlancfg.desktop', ] # ----------------------------------------------------------------- CUSTOM AGFA = ['ALBW.TTF', 'ALBWB.TTF', 'ALBWBI.TTF', 'ALBWI.TTF', 'ARIALN.TTF', 'ARIALNB.TTF', 'ARIALNBI.TTF', 'ARIALNI.TTF', 'CumberlandAMT-Bold.otf', 'CumberlandAMT-BoldItalic.otf', 'CumberlandAMT-Italic.otf', 'CumberlandAMT-Regular.otf', 'THOWBI__.TTF', 'THOWB___.TTF', 'THOWI___.TTF', 'THOWR___.TTF'] CUSTOM_FILES = ( [f'usr/share/fonts/ttf/{f}' for f in AGFA] + ['usr/share/gpe/overrides/figment.desktop', 'usr/share/gpe/overrides/xdemineur.desktop', 'usr/share/gpe/overrides/gpe-soundbite-play.desktop', 'usr/share/gpe/overrides/gpe-soundbite-record.desktop', 'usr/share/totem/totem_logo.png'] ) # ----------------------------------------------------------------- NEW # Our programs, and every package registered with ipkg, come from mkfeed.py, # which builds the PsionLX-Software archive folder from the same definitions. def _feed(): spec = importlib.util.spec_from_file_location('mkfeed', os.path.join(W, 'scripts', 'mkfeed.py')) mod = importlib.util.module_from_spec(spec) spec.loader.exec_module(mod) return mod NEW_PACKAGES = ('psionlx-software',) NOT_IN_IMAGE = ('psionnet-spotify',) # in the catalogue, installed on request FLASH_TOOLS = ['flash_eraseall', 'flash_lock', 'flash_unlock', 'flashcp', 'nandwrite', 'nanddump'] def cp(rel, src_root=OLD): s, d = os.path.join(src_root, rel), os.path.join(NEW, rel) if not os.path.lexists(s): raise SystemExit(f'missing source: {rel}') os.makedirs(os.path.dirname(d), exist_ok=True) if os.path.lexists(d): os.remove(d) if os.path.islink(s): os.symlink(os.readlink(s), d) else: shutil.copy2(s, d) def patch(rel, old, new, why): p = os.path.join(NEW, rel) s = open(p).read() if s.count(old) != 1: raise SystemExit(f'{rel}: anchor for "{why}" not found exactly once') open(p, 'w').write(s.replace(old, new)) print(f' {rel:44} {why}') def main(): if os.path.exists(CARD): shutil.rmtree(CARD) print('BASE') shutil.copytree(SOHO, NEW, symlinks=True) print(f' Psion\'s genuine image, {sum(len(f) for _, _, f in os.walk(NEW))} files') print('EXTRAS') info = os.path.join(OLD, 'usr/lib/ipkg/info') added = 0 for pkg in EXTRA_PACKAGES: files = [l.strip().lstrip('/') for l in open(os.path.join(info, pkg + '.list')) if l.strip()] for f in files: if os.path.lexists(os.path.join(NEW, f)): raise SystemExit(f'{pkg}: {f} would overwrite a genuine file') if os.path.lexists(os.path.join(OLD, f)) and not os.path.isdir(os.path.join(OLD, f)): cp(f); added += 1 print(f' {pkg:18} {len(files)} files') for f in EXTRA_FILES: cp(f); added += 1 print(f' gpe-wlancfg {len(EXTRA_FILES)} files') print(f' {added} files added') feed = _feed() pkgs = feed.packages() feed.check_built() # no binary older than its source feed.resolve(pkgs) # Depends, and checks against Psion's image pkgs = [pk for pk in pkgs if pk.name not in NOT_IN_IMAGE] print('CUSTOM') for f in CUSTOM_FILES: cp(f) print(f' {len(AGFA)} Agfa fonts, 4 EPOC-name overrides, the PsionLX picture in Totem') # Make "Sans" resolve one way regardless of directory scan order. The Agfa # fonts are what made it ambiguous (docs/05, the desktop overflow bug); # Psion's shipped image had only Bitstream Vera, so its gtkrc's generic # "Sans" was safe there. This keeps Psion's gtkrc untouched. # The same marked block the agfa-fonts package's postinst adds on a stock card. patch('etc/fonts/local.conf', '', feed.FONT_PIN + '', 'Sans pinned to Bitstream Vera') print('NEW') byname = {p.name: p for p in pkgs} for name in NEW_PACKAGES: feed.install_files(byname[name], NEW) print(f' {name:18} {len(byname[name].files)} files') print('SAFETY') patch('etc/fstab', '/dev/mtdblock1 /home jffs2 defaults 0 2\n', '# PsionLX (2026): Psion mounted /home from NAND partition 1 as JFFS2, because\n' '# this image was built for LX-partitioned internal flash. On a netBook Pro whose\n' '# NAND holds Windows CE that must never happen, so it is disabled and /home\n' '# stays on the card, in the "emergency" home directory soho-image.oe provides.\n' '#/dev/mtdblock1 /home jffs2 defaults 0 2\n', 'NAND /home mount disabled') for t in FLASH_TOOLS: p = os.path.join(NEW, 'usr/bin', t) if os.path.lexists(p): os.remove(p) print(f' usr/bin/{{{",".join(FLASH_TOOLS)}}} removed') patch('usr/bin/eject.sh', '/etc/pcmcia/ide stop hda > /dev/null\n', '# PsionLX (2026): on Psion\'s NAND-booted machine hda was only ever the CF slot.\n' '# Booted from a card, hda IS the root disk, and stopping it pulls the filesystem\n' '# out from under the running system. Only stop it when it is not root.\n' 'if ! grep -q \'^/dev/hda[0-9]* / \' /proc/mounts; then\n' ' /etc/pcmcia/ide stop hda > /dev/null\n' 'fi\n', 'card ejector will not stop the root disk') print('FIXES') patch('etc/init.d/populate-var', 'mkdir -p /var/run\nchmod 755 /var/run\n', 'mkdir -p /var/run\nchmod 755 /var/run\n' '# PsionLX (2026): ipaq-sleep is started by the session as the lx user\n' '# (Xsession.d/69ipaq-sleep), and its init script then tries to mkdir this\n' '# directory inside root-owned /var/run, which fails -- a bug in Psion\'s own\n' '# image. Minor: ipaq-sleep still runs and still suspends, but nothing can hold\n' '# it off (it skips sleeping while a file exists here). Create it at boot.\n' 'mkdir -p /var/run/no-sleep\nchmod 1777 /var/run/no-sleep\n', 'ipaq-sleep can create its /var/run/no-sleep') # Psion's TASKS screen "Back up your information" runs backup.sh, which copies # nothing: the globs are inside quotes ("${HOME}/*"), so the shell never # expands them -- and it then reports "Backup Complete". "Config and # Contacts" also means the hidden ~/.gpe databases, which "*" could never # have matched. Copy what each option actually names. patch('usr/bin/backup.sh', 'if echo $DIRS | grep "Config and Contacts" ; then\n' '\tcp -a "${HOME}/*" "${MNTPT}/${DIRNAMEBASE}-${COUNT}/"\n' 'fi', '# PsionLX (2026): Psion\'s line was cp -a "${HOME}/*" ... -- quoted, so the glob\n' '# never expanded and nothing was copied. Config and contacts live in hidden\n' '# files (~/.gpe), so copy everything in $HOME except My Documents.\n' 'if echo $DIRS | grep "Config and Contacts" ; then\n' '\t( cd "${HOME}" && for f in .[!.]* *; do\n' '\t\t[ "$f" = "My Documents" ] && continue\n' '\t\t[ -e "$f" ] && cp -a "$f" "${MNTPT}/${DIRNAMEBASE}-${COUNT}/"\n' '\tdone )\n' 'fi', 'backup copies config, contacts and documents') patch('usr/bin/backup.sh', '\tcp -a "${HOME}/My Documents/*" "${MNTPT}/${DIRNAMEBASE}-${COUNT}/My Documents/"', '\tcp -a "${HOME}/My Documents/." "${MNTPT}/${DIRNAMEBASE}-${COUNT}/My Documents/"', 'backup copies My Documents') # "Synchronise with a PC" runs lx_sync.sh, which is not in Psion's image. stub = os.path.join(NEW, 'usr/bin/lx_sync.sh') open(stub, 'w').write( '#!/bin/sh\n' '# PsionLX (2026): Psion\'s TASKS screen offers "Synchronise with a PC" and runs\n' '# this script, but no lx_sync.sh exists in their image, so the task did nothing.\n' '# PC synchronisation was never finished; say so rather than fail silently.\n' 'zenity --info --title="Synchronise with a PC" --text="PC synchronisation was not finished ' 'in PsionLX. To move files to a PC, use a CF, MMC or USB card, or Back up your information."\n') os.chmod(stub, 0o755) print(f' {"usr/bin/lx_sync.sh":44} added: explains instead of failing silently') # TASKS > "Find new software": Psion listed it and never gave it a command. # The same patch, from mkfeed.py, that the psionlx-software package applies # on a stock card -- with Psion's launcher kept beside it, as there. p = os.path.join(NEW, 'usr/bin/gpe-appmgr') original = open(p, 'rb').read() shutil.copy2(p, os.path.join(NEW, 'usr/lib/psionlx-software/gpe-appmgr.psion')) open(p, 'wb').write(feed.patch_appmgr(original)) print(f' {"usr/bin/gpe-appmgr":44} TASKS > Find new software runs psionlx-software') print('PACKAGES') for pk in pkgs: missing = [rel for _, rel, _ in pk.files if not os.path.lexists(os.path.join(NEW, rel))] if missing: raise SystemExit(f'{pk.name}: not in the image: {missing[:3]}') feed.register(pkgs, NEW) print(f' {len(pkgs)} packages registered with ipkg: {", ".join(pk.name for pk in pkgs)}') print('CARD') # the hardened boot partition shared with the safe image shutil.copy2(os.path.join(W, 'bootimg', 'boot-safe.fat'), os.path.join(CARD, 'boot.fat')) # Psion's own device nodes and exact file modes; the flash tools are gone shutil.copy2(os.path.join(W, 'card-soho', 'mknods.debugfs'), os.path.join(CARD, 'mknods.debugfs')) meta = [l for l in open(os.path.join(W, 'card-soho', 'metadata.debugfs')) if not any(f'"/usr/bin/{t}"' in l for t in FLASH_TOOLS)] open(os.path.join(CARD, 'metadata.debugfs'), 'w').writelines(meta) print(f' boot.fat (hardened), mknods.debugfs, metadata.debugfs ({len(meta)} lines)') print('done:', CARD) if __name__ == '__main__': main()