forked from synit/synit
Much work from recent days
This commit is contained in:
parent
49ef023dfd
commit
51a092a0e2
|
@ -0,0 +1,17 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Upload packages and scripts for converting a plain PostmarketOS system into a Synit system
|
||||
|
||||
set -eu
|
||||
|
||||
HOST=${1:-pm-qemu}
|
||||
SUDOPASS=${SUDOPASS:-user}
|
||||
|
||||
ssh ${HOST} "
|
||||
cp `which rsync` root-rsync;
|
||||
echo ${SUDOPASS} | sudo -S sh -c 'chown root:root root-rsync; chmod +s root-rsync';
|
||||
echo ${SUDOPASS} | sudo -S sh -c 'echo \"! <restart-service <daemon interface-monitor>>\" > /run/etc/syndicate/throck.pr';
|
||||
"
|
||||
rsync -avu --rsync-path="./root-rsync" \
|
||||
packaging/packages/synit-config/files/. \
|
||||
${HOST}:/
|
|
@ -1,3 +1,5 @@
|
|||
__ignored__ := $(shell ./copy-local-resources-into-package-folders.sh)
|
||||
|
||||
.PHONY: build-image build sign clean veryclean keyfile
|
||||
|
||||
# If you run:
|
||||
|
|
|
@ -8,11 +8,13 @@ ARCH_TARGET = $(TARGET)/packages/$(ARCH)
|
|||
SIGNING_KEY = $(HOME)/.abuild/$(KEYFILE)
|
||||
|
||||
PACKAGES = \
|
||||
preserves-schemas.apk \
|
||||
preserves-tools.apk \
|
||||
py3-preserves.apk \
|
||||
py3-syndicate.apk \
|
||||
squeak-cog-vm.apk \
|
||||
squeak-stack-vm.apk \
|
||||
syndicate-schemas.apk \
|
||||
syndicate-server.apk \
|
||||
syndicate-sh.apk \
|
||||
synit-pid1.apk \
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
#!/bin/sh
|
||||
rsync -a ../protocols packages/synit-config
|
|
@ -0,0 +1,24 @@
|
|||
# Maintainer: Tony Garnock-Jones <tonyg@leastfixedpoint.com>
|
||||
pkgname=preserves-schemas
|
||||
pkgver=0.6.0-r20220114
|
||||
pkgrel=0
|
||||
pkgdesc="Shared Preserves Schema definitions"
|
||||
url="https://preserves.gitlab.io/"
|
||||
arch="noarch"
|
||||
license="Apache-2.0"
|
||||
source="https://gitlab.com/preserves/preserves/-/archive/${pkgver}/preserves-${pkgver}.zip"
|
||||
builddir="$srcdir/preserves-${pkgver}"
|
||||
options="!check"
|
||||
|
||||
package() {
|
||||
cd "$builddir"
|
||||
mkdir -p "$pkgdir/usr/share/preserves/schemas"
|
||||
cp ./schema/schema.prs "$pkgdir/usr/share/preserves/schemas/."
|
||||
cp ./schema/schema.bin "$pkgdir/usr/share/preserves/schemas/schema.prb"
|
||||
cp ./path/path.prs "$pkgdir/usr/share/preserves/schemas/."
|
||||
cp ./path/path.bin "$pkgdir/usr/share/preserves/schemas/path.prb"
|
||||
}
|
||||
|
||||
sha512sums="
|
||||
62363962bc6849f026fe03faf1b41b4880f41cd2cacb26bb6e716f5c0d3b68f025aa306e0caa367bea32292694729f5e47069624b7395bb755b306a54532e288 preserves-0.6.0-r20220114.zip
|
||||
"
|
|
@ -0,0 +1,24 @@
|
|||
# Maintainer: Tony Garnock-Jones <tonyg@leastfixedpoint.com>
|
||||
pkgname=syndicate-schemas
|
||||
pkgver=0.0.1-r20220114
|
||||
pkgrel=0
|
||||
pkgdesc="Shared Syndicate Preserves Schema definitions"
|
||||
url="https://syndicate-lang.org/"
|
||||
arch="noarch"
|
||||
license="Apache-2.0"
|
||||
source="https://git.syndicate-lang.org/syndicate-lang/syndicate-protocols/archive/0.0.1-r20220114.zip"
|
||||
builddir="$srcdir/syndicate-protocols"
|
||||
makedepends="
|
||||
rsync
|
||||
"
|
||||
options="!check"
|
||||
|
||||
package() {
|
||||
cd "$builddir"
|
||||
mkdir -p "$pkgdir/usr/share/syndicate/schemas"
|
||||
rsync schema-bundle.bin schemas "$pkgdir/usr/share/syndicate/schemas/."
|
||||
}
|
||||
|
||||
sha512sums="
|
||||
f6b230db7315cbf32f3968d971ae807aa7344a5a97e42301beb069f4bda06034cd619c2c6afc5b4fc886ae956225393bed9e4e733977e2ec613a64bc72b243d7 0.0.1-r20220114.zip
|
||||
"
|
|
@ -1,19 +1,15 @@
|
|||
# Contributor: Tony Garnock-Jones <tonyg@leastfixedpoint.com>
|
||||
# Maintainer: Tony Garnock-Jones <tonyg@leastfixedpoint.com>
|
||||
pkgname=syndicate-server
|
||||
pkgver=0.18.0
|
||||
pkgrel=0
|
||||
pkgver=0.0.0
|
||||
pkgrel=$(date '+%Y%m%d%H%M%S')
|
||||
pkgdesc="Syndicate server"
|
||||
url="https://syndicate-lang.org/"
|
||||
arch="all"
|
||||
license="GPLv3"
|
||||
depends=""
|
||||
makedepends=""
|
||||
source="
|
||||
syndicate-server.aarch64
|
||||
syndicate-server.armv7
|
||||
syndicate-server.x86_64
|
||||
"
|
||||
makedepends="rsync"
|
||||
source=""
|
||||
builddir="$srcdir/"
|
||||
options="!check"
|
||||
|
||||
|
@ -23,11 +19,9 @@ build() {
|
|||
|
||||
package() {
|
||||
mkdir -p "$pkgdir/usr/bin"
|
||||
cp -p syndicate-server.${CARCH} "$pkgdir/usr/bin/syndicate-server"
|
||||
}
|
||||
cp -p ../syndicate-server.${CARCH} "$pkgdir/usr/bin/syndicate-server"
|
||||
|
||||
sha512sums="
|
||||
1778c033ef250de0a2a30767c962245eb1f247d71958833ed7a7fe7fbfdfe730ade6c6562b2e83f76dec4a6c061b0e2ed78ee25f5362aceea537b08df7634469 syndicate-server.aarch64
|
||||
80034a35ffb5e661e32bec63d81b22748ba5788546daa3472a0ba6cf5735cfae1812dcd24220aecd8088bbe9d94f35c01dd2cb514a4c9f1c812ab7f28154931d syndicate-server.armv7
|
||||
8d7f34a6ceb5ee23ae14fb8d82a8a75ec07887fb80ed83cfd4d9de4f7a41435f9eb213fe2607bd9784fe04f2dc8222c9daf17209360bbedd28112a0d0c406d96 syndicate-server.x86_64
|
||||
"
|
||||
mkdir -p "$pkgdir/usr/share/syndicate-server/schemas"
|
||||
rsync ../protocols/schema-bundle.bin ../protocols/schemas \
|
||||
"$pkgdir/usr/share/syndicate-server/schemas"
|
||||
}
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
all: schema-bundle.bin
|
||||
|
||||
clean:
|
||||
rm -f schema-bundle.bin
|
||||
|
||||
schema-bundle.bin: schemas/*.prs
|
||||
preserves-schemac schemas > $@.tmp
|
||||
mv $@.tmp $@
|
|
@ -0,0 +1,9 @@
|
|||
´³bundle·µ³externalServices„´³schema·³version‘³definitions·³Process´³orµµ±simple´³refµ„³CommandLine„„µ±full´³refµ„³FullProcess„„„„³Service´³refµ„³
DaemonService„³ClearEnv´³orµµ±present´³dict·³clearEnv´³named³clearEnv´³atom³Boolean„„„„„µ±invalid´³dict·³clearEnv´³named³clearEnv³any„„„„µ±absent´³dict·„„„„„³EnvValue´³orµµ±set´³atom³String„„µ±remove´³lit€„„µ±invalid³any„„„³Protocol´³orµµ±none´³lit³none„„µ±binarySyndicate´³lit³application/syndicate„„µ±
textSyndicate´³lit³text/syndicate„„„„³
|
||||
ProcessDir´³orµµ±present´³dict·³dir´³named³dir´³atom³String„„„„„µ±invalid´³dict·³dir´³named³dir³any„„„„µ±absent´³dict·„„„„„³
|
||||
ProcessEnv´³orµµ±present´³dict·³env´³named³env´³dictof´³refµ„³EnvVariable„´³refµ„³EnvValue„„„„„„µ±invalid´³dict·³env´³named³env³any„„„„µ±absent´³dict·„„„„„³CommandLine´³orµµ±shell´³atom³String„„µ±full´³refµ„³FullCommandLine„„„„³EnvVariable´³orµµ±string´³atom³String„„µ±symbol´³atom³Symbol„„µ±invalid³any„„„³FullProcess´³andµ´³dict·³argv´³named³argv´³refµ„³CommandLine„„„„´³named³env´³refµ„³
|
||||
ProcessEnv„„´³named³dir´³refµ„³
|
||||
ProcessDir„„´³named³clearEnv´³refµ„³ClearEnv„„„„³ReadyOnStart´³orµµ±present´³dict·³readyOnStart´³named³readyOnStart´³atom³Boolean„„„„„µ±invalid´³dict·³readyOnStart´³named³readyOnStart³any„„„„µ±absent´³dict·„„„„„³RestartField´³orµµ±present´³dict·³restart´³named³restart´³refµ„³
RestartPolicy„„„„„µ±invalid´³dict·³restart´³named³restart³any„„„„µ±absent´³dict·„„„„„³
DaemonProcess´³rec´³lit³daemon„´³tupleµ´³named³id³any„´³named³config´³refµ„³DaemonProcessSpec„„„„„³
DaemonService´³rec´³lit³daemon„´³tupleµ´³named³id³any„„„„³
ProtocolField´³orµµ±present´³dict·³protocol´³named³protocol´³refµ„³Protocol„„„„„µ±invalid´³dict·³protocol´³named³protocol³any„„„„µ±absent´³dict·„„„„„³
RestartPolicy´³orµµ±always´³lit³always„„µ±onError´³lit³on-error„„µ±all´³lit³all„„„„³FullCommandLine´³tuplePrefixµ´³named³program´³atom³String„„„´³named³args´³seqof´³atom³String„„„„³DaemonProcessSpec´³orµµ±simple´³refµ„³CommandLine„„µ±oneShot´³rec´³lit³one-shot„´³tupleµ´³named³setup´³refµ„³CommandLine„„„„„„µ±full´³refµ„³FullDaemonProcess„„„„³FullDaemonProcess´³andµ´³named³process´³refµ„³FullProcess„„´³named³readyOnStart´³refµ„³ReadyOnStart„„´³named³restart´³refµ„³RestartField„„´³named³protocol´³refµ„³
ProtocolField„„„„„³embeddedType´³refµ³ EntityRef„³Cap„„„µ³internalServices„´³schema·³version‘³definitions·³ ConfigEnv´³dictof´³atom³Symbol„³any„³ Milestone´³rec´³lit³ milestone„´³tupleµ´³named³name³any„„„„³DebtReporter´³rec´³lit³
debt-reporter„´³tupleµ´³named³intervalSeconds´³atom³Double„„„„„³
ConfigWatcher´³rec´³lit³config-watcher„´³tupleµ´³named³path´³atom³String„„´³named³env´³refµ„³ ConfigEnv„„„„„³TcpRelayListener´³rec´³lit³relay-listener„´³tupleµ´³named³addr´³refµ³TransportAddress„³Tcp„„´³named³
|
||||
gatekeeper´³embedded´³refµ³
|
||||
gatekeeper„³Resolve„„„„„„³UnixRelayListener´³rec´³lit³relay-listener„´³tupleµ´³named³addr´³refµ³TransportAddress„³Unix„„´³named³
|
||||
gatekeeper´³embedded´³refµ³
|
||||
gatekeeper„³Resolve„„„„„„„³embeddedType´³refµ³ EntityRef„³Cap„„„„„
|
|
@ -0,0 +1,52 @@
|
|||
version 1 .
|
||||
embeddedType EntityRef.Cap .
|
||||
|
||||
Service = DaemonService .
|
||||
|
||||
DaemonService = <daemon @id any> .
|
||||
DaemonProcess = <daemon @id any @config DaemonProcessSpec>.
|
||||
|
||||
DaemonProcessSpec = @simple CommandLine / @oneShot <one-shot @setup CommandLine> / @full FullDaemonProcess .
|
||||
FullDaemonProcess = @process FullProcess & @readyOnStart ReadyOnStart & @restart RestartField & @protocol ProtocolField .
|
||||
ReadyOnStart = @present { readyOnStart: bool } / @invalid { readyOnStart: any } / @absent {} .
|
||||
RestartField = @present { restart: RestartPolicy } / @invalid { restart: any } / @absent {} .
|
||||
ProtocolField = @present { protocol: Protocol } / @invalid { protocol: any } / @absent {} .
|
||||
|
||||
Process = @simple CommandLine / @full FullProcess .
|
||||
FullProcess =
|
||||
& { argv: CommandLine }
|
||||
& @env ProcessEnv
|
||||
& @dir ProcessDir
|
||||
& @clearEnv ClearEnv
|
||||
.
|
||||
ProcessEnv = @present { env: { EnvVariable: EnvValue ...:... } } / @invalid { env: any } / @absent {} .
|
||||
ProcessDir = @present { dir: string } / @invalid { dir: any } / @absent {} .
|
||||
ClearEnv = @present { clearEnv: bool } / @invalid { clearEnv: any } / @absent {} .
|
||||
|
||||
CommandLine = @shell string / @full FullCommandLine .
|
||||
FullCommandLine = [@program string, @args string ...] .
|
||||
|
||||
EnvVariable = @string string / @symbol symbol / @invalid any .
|
||||
EnvValue = @set string / @remove #f / @invalid any .
|
||||
|
||||
RestartPolicy =
|
||||
/ ; Whether the process terminates normally or abnormally, restart it
|
||||
; without affecting any peer processes within the service.
|
||||
=always
|
||||
/ ; If the process terminates normally, leave everything alone; if it
|
||||
; terminates abnormally, restart it without affecting peers.
|
||||
@onError =on-error
|
||||
/ ; If the process terminates normally, leave everything alone; if it
|
||||
; terminates abnormally, restart the whole daemon (all processes
|
||||
; within the daemon).
|
||||
=all
|
||||
.
|
||||
|
||||
Protocol =
|
||||
/ ; stdin is /dev/null, output and error are logged
|
||||
=none
|
||||
/ ; stdin and stdout are *binary* Syndicate-protocol channels
|
||||
@binarySyndicate =application/syndicate
|
||||
/ ; stdin and stdout are *text* Syndicate-protocol channels
|
||||
@textSyndicate =text/syndicate
|
||||
.
|
|
@ -0,0 +1,11 @@
|
|||
version 1 .
|
||||
embeddedType EntityRef.Cap .
|
||||
|
||||
DebtReporter = <debt-reporter @intervalSeconds double>.
|
||||
|
||||
TcpRelayListener = <relay-listener @addr TransportAddress.Tcp @gatekeeper #!gatekeeper.Resolve> .
|
||||
UnixRelayListener = <relay-listener @addr TransportAddress.Unix @gatekeeper #!gatekeeper.Resolve> .
|
||||
ConfigWatcher = <config-watcher @path string @env ConfigEnv>.
|
||||
Milestone = <milestone @name any>.
|
||||
|
||||
ConfigEnv = { symbol: any ...:... }.
|
|
@ -0,0 +1,15 @@
|
|||
#!/bin/sh
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
set -e
|
||||
|
||||
build() {
|
||||
make -C ~/src/syndicate-rs $1-binary-debug 2>&1 | tee buildlog.$1
|
||||
cp -p ~/src/syndicate-rs/target/$1-*/debug/syndicate-server syndicate-server.$1
|
||||
}
|
||||
|
||||
cp -r ~/src/syndicate-rs/syndicate-server/protocols .
|
||||
build x86_64 &
|
||||
#build armv7 &
|
||||
#build aarch64 &
|
||||
wait
|
|
@ -8,6 +8,7 @@ build() {
|
|||
cp -p ~/src/syndicate-rs/target/$1-*/release/syndicate-server syndicate-server.$1
|
||||
}
|
||||
|
||||
cp -r ~/src/syndicate-rs/syndicate-server/protocols .
|
||||
build x86_64 &
|
||||
build armv7 &
|
||||
build aarch64 &
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
protocols/
|
||||
__pycache__/
|
|
@ -1,8 +1,8 @@
|
|||
# Contributor: Tony Garnock-Jones <tonyg@leastfixedpoint.com>
|
||||
# Maintainer: Tony Garnock-Jones <tonyg@leastfixedpoint.com>
|
||||
pkgname=synit-config
|
||||
pkgver=0.0.2
|
||||
pkgrel=1
|
||||
pkgver=0.0.5
|
||||
pkgrel=0
|
||||
pkgdesc="synit system layer configuration"
|
||||
url="https://synit.org/"
|
||||
arch="noarch"
|
||||
|
@ -10,6 +10,11 @@ license="GPLv3"
|
|||
depends="
|
||||
synit-pid1
|
||||
syndicate-server
|
||||
syndicate-schemas
|
||||
preserves-schemas
|
||||
py3-syndicate
|
||||
|
||||
py3-pyroute2
|
||||
|
||||
eudev
|
||||
nftables
|
||||
|
@ -37,6 +42,13 @@ build() {
|
|||
package() {
|
||||
mkdir -p "$pkgdir"
|
||||
rsync -a "$startdir/files/." "$pkgdir/."
|
||||
|
||||
mkdir -p "$pkgdir/usr/share/synit/schemas"
|
||||
rsync -a \
|
||||
"$startdir/protocols/schema-bundle.bin" \
|
||||
"$startdir/protocols/schemas" \
|
||||
"$pkgdir/usr/share/synit/schemas"
|
||||
|
||||
ln -sf /sbin/synit-init.sh "$pkgdir/sbin/init"
|
||||
mkdir -p "$pkgdir/var/lock/synit"
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<depends-on <milestone system-layer> <service-state <daemon eudev-initial-scan> complete>>
|
||||
|
||||
<system-layer-service <daemon eudev>>
|
||||
<daemon eudev <one-shot ["/sbin/udevd", "--children-max=5"]>>
|
||||
<daemon eudev ["/sbin/udevd", "--children-max=5"]>
|
||||
|
||||
<system-layer-service <daemon eudev-initial-scan>>
|
||||
<depends-on <daemon eudev-initial-scan> <service-state <daemon eudev> ready>>
|
||||
|
|
|
@ -23,3 +23,7 @@
|
|||
? <run-service <daemon <udhcpc ?ifname>>> [
|
||||
<daemon <udhcpc $ifname> ["udhcpc" "-i" $ifname "-fR"]>
|
||||
]
|
||||
|
||||
;---------------------------------------------------------------------------
|
||||
|
||||
; TODO: put interface-monitor in here
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
#!/usr/bin/env python3
|
||||
import sys
|
||||
import os
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'python'))
|
||||
import synit.daemon.interface_monitor
|
|
@ -0,0 +1,159 @@
|
|||
import sys
|
||||
from syndicate import relay, turn, Symbol, Record, Formatter
|
||||
from syndicate.actor import find_loop
|
||||
from syndicate.during import During
|
||||
from socket import AF_INET, AF_INET6
|
||||
from dataclasses import dataclass
|
||||
from typing import Optional
|
||||
import logging
|
||||
import preserves.schema
|
||||
import threading
|
||||
|
||||
import pyroute2
|
||||
|
||||
schemas = preserves.schema.load_schema_file('/home/tonyg/src/syndicate-system/protocols/schema-bundle.bin')
|
||||
network = schemas.network
|
||||
|
||||
class LenientFormatter(Formatter):
|
||||
def cannot_format(self, v):
|
||||
if v is None:
|
||||
self.append(Record(Symbol('null'), []))
|
||||
else:
|
||||
super().cannot_format(v)
|
||||
|
||||
def lenient_stringify(v, indent=None):
|
||||
e = LenientFormatter(indent=indent)
|
||||
e.append(v)
|
||||
return e.contents()
|
||||
|
||||
@dataclass
|
||||
class Link:
|
||||
handle: Optional[int]
|
||||
record: Optional[network.Interface]
|
||||
def update(self, machine_ds, newRecord):
|
||||
if self.record != newRecord:
|
||||
self.handle = turn.replace(machine_ds, self.handle, newRecord)
|
||||
self.record = newRecord
|
||||
|
||||
def parse_route(linktable, m):
|
||||
af_number = m['family']
|
||||
if af_number == AF_INET6: af = network.AddressFamily.ipv6()
|
||||
elif af_number == AF_INET: af = network.AddressFamily.ipv4()
|
||||
else: af = network.AddressFamily.other(af_number)
|
||||
|
||||
dst = m.get_attr('RTA_DST')
|
||||
if dst is None:
|
||||
dst = network.RouteDestination.default()
|
||||
else:
|
||||
dst = network.RouteDestination.prefix(dst, m['dst_len'])
|
||||
|
||||
priority = m.get_attr('RTA_PRIORITY', 0)
|
||||
tos = m['tos']
|
||||
|
||||
link = linktable.get(m.get_attr('RTA_OIF'), None)
|
||||
if link is None:
|
||||
ifname = network.RouteInterface.none()
|
||||
else:
|
||||
ifname = network.RouteInterface.name(link.record.name)
|
||||
|
||||
gw = m.get_attr('RTA_GATEWAY')
|
||||
gw = network.Gateway.addr(gw) if gw is not None else network.Gateway.none()
|
||||
|
||||
return network.Route(af, dst, priority, tos, ifname, gw)
|
||||
|
||||
operational_state_map = {
|
||||
'UP': network.OperationalState.up(),
|
||||
'DORMANT': network.OperationalState.dormant(),
|
||||
'TESTING': network.OperationalState.testing(),
|
||||
'LOWERLAYERDOWN': network.OperationalState.lowerLayerDown(),
|
||||
'DOWN': network.OperationalState.down(),
|
||||
}
|
||||
|
||||
administrative_state_map = {
|
||||
'up': network.AdministrativeState.up(),
|
||||
'down': network.AdministrativeState.down(),
|
||||
}
|
||||
|
||||
def parse_interface(m):
|
||||
return network.Interface(m.get_attr('IFLA_IFNAME'),
|
||||
m['index'],
|
||||
administrative_state_map.get(m['state'],
|
||||
network.AdministrativeState.unknown()),
|
||||
operational_state_map.get(m.get_attr('IFLA_OPERSTATE', 'UNKNOWN'),
|
||||
network.OperationalState.unknown()),
|
||||
(network.CarrierState.carrier()
|
||||
if m.get_attr('IFLA_CARRIER', 0) else
|
||||
network.CarrierState.noCarrier()),
|
||||
m.get_attr('IFLA_ADDRESS', ''))
|
||||
|
||||
def gather_events_from_socket(facet, callback, ip, loop):
|
||||
facet.log.debug('Background netlink socket read thread started')
|
||||
try:
|
||||
while True:
|
||||
facet.log.debug('waiting for event...')
|
||||
events = ip.get()
|
||||
facet.log.debug(f'... got {len(events)} events')
|
||||
turn.external(facet, lambda: callback(events), loop=loop)
|
||||
except Exception as e:
|
||||
facet.log.debug(e)
|
||||
finally:
|
||||
facet.log.debug('Background netlink socket read thread terminated')
|
||||
|
||||
@relay.service(name='interface_monitor', debug=False)
|
||||
@During().add_handler
|
||||
def main(args):
|
||||
machine_ds = args[Symbol('machine')].embeddedValue
|
||||
|
||||
ip = pyroute2.IPRoute()
|
||||
ip.bind()
|
||||
|
||||
@turn.on_stop_or_crash
|
||||
def shutdown():
|
||||
ip.close()
|
||||
|
||||
linktable = {}
|
||||
routetable = {}
|
||||
|
||||
def handle_events(events):
|
||||
for m in events:
|
||||
event_type = m['event']
|
||||
if event_type == 'RTM_NEWLINK':
|
||||
i = parse_interface(m)
|
||||
if (wireless_extension := m.get_attr('IFLA_WIRELESS', None)) is not None \
|
||||
and wireless_extension.get_attr('SIOCGIWSCAN', None) is not None:
|
||||
turn.log.info(f'Interface {i.name} is performing a rescan')
|
||||
else:
|
||||
with open('/tmp/' + i.name + '.info', 'w') as f:
|
||||
f.write(lenient_stringify(m, indent=4))
|
||||
if i.index not in linktable:
|
||||
linktable[i.index] = Link(None, None)
|
||||
linktable[i.index].update(machine_ds, i)
|
||||
elif event_type == 'RTM_DELLINK':
|
||||
i = parse_interface(m)
|
||||
link = linktable.pop(i.index, None)
|
||||
if link is not None:
|
||||
link.update(machine_ds, None)
|
||||
elif event_type == 'RTM_NEWROUTE':
|
||||
if m.get_attr('RTA_TABLE') == 254: # RT_TABLE_MAIN
|
||||
r = parse_route(linktable, m)
|
||||
if r not in routetable:
|
||||
routetable[r] = turn.publish(machine_ds, r)
|
||||
elif event_type == 'RTM_DELROUTE':
|
||||
if m.get_attr('RTA_TABLE') == 254: # RT_TABLE_MAIN
|
||||
r = parse_route(linktable, m)
|
||||
turn.retract(routetable.pop(r, None))
|
||||
elif event_type in ['RTM_NEWNEIGH', 'RTM_DELNEIGH',
|
||||
'RTM_NEWADDR', 'RTM_DELADDR']:
|
||||
# Ignored
|
||||
pass
|
||||
else:
|
||||
turn.log.info(f'Unhandled netlink event: {lenient_stringify(m)}')
|
||||
|
||||
handle_events(ip.get_links())
|
||||
handle_events(ip.get_routes())
|
||||
|
||||
facet = turn.active_facet()
|
||||
loop = find_loop()
|
||||
threading.Thread(
|
||||
name='background-netlink-socket-read-thread',
|
||||
target=lambda: gather_events_from_socket(facet, handle_events, ip, loop)).start()
|
|
@ -2,7 +2,7 @@
|
|||
# Maintainer: Tony Garnock-Jones <tonyg@leastfixedpoint.com>
|
||||
pkgname=synit-pid1
|
||||
pkgver=0.0.1
|
||||
pkgrel=3
|
||||
pkgrel=4
|
||||
pkgdesc="synit pid 1 program"
|
||||
url="https://synit.org/"
|
||||
arch="all"
|
||||
|
@ -27,7 +27,7 @@ package() {
|
|||
}
|
||||
|
||||
sha512sums="
|
||||
e4aa3c352701f56cf0d877a565106f62fff555b529b7b6bf439a9d6b6b7e153b5a4f7749b27cc8278d78e48efa9373d4c71a22a95e26a1d59e8e4da9789f3b6d synit-pid1.aarch64
|
||||
f286e403b944a2364d4ed74dd2c02e2a26de2c68908969600c353f03b523faf7daa11ea5f482fa32d83a112487a4af383e10235c1acdc0e332bf1176a1113f4b synit-pid1.armv7
|
||||
791b9b65e72ff863308748d26bb77492b129769c611b1b70975ff67a7f24c5eda34b432ff34c4b576f7e26f51a6ce305f2bc20689eba1334f08499ba8fb28185 synit-pid1.x86_64
|
||||
0877d5b04e6b7621c86caa1ba583643a7f9b16a769f51fed8dfbb2e54b972e60b7593b7808b5e9612f2364b46a535e16e8698fe263ddff20212a1dbc47732b52 synit-pid1.aarch64
|
||||
adf55af01f2fef6006f9c3cfc3516fe2ef143d82d4781e5c77a25ef4f990755790680934ccab0397b142f430fcf453991d0a678bd28d12e33824ed4fe4180d3a synit-pid1.armv7
|
||||
326050787363663b44d1d64424a139aed8a887f133bdae64a1710ad22523a700afba1b594d6580ceaf3127f419188bd026b2fa962132e53923113eccb199f191 synit-pid1.x86_64
|
||||
"
|
||||
|
|
|
@ -3,7 +3,8 @@ WidgetType
|
|||
horizontal´³refµ„³Sizing„„´³named³vertical´³refµ„³Sizing„„„„„³SortKey´³orµµ±double´³atom³Double„„µ±string´³atom³String„„„„³LeafType´³orµµ±blank´³lit³blank„„µ±text´³lit³text„„µ±slider´³lit³slider„„µ±image´³lit³image„„µ±icon´³lit³icon„„„„³NodeType´³orµµ±column´³lit³column„„µ±row´³lit³row„„„„³WidgetId³any³ Attribute´³rec´³lit³ attribute„´³tupleµ´³named³id´³refµ„³WidgetId„„´³named³key´³atom³Symbol„„´³named³value³any„„„„³
|
||||
WidgetType´³orµµ±NodeType´³refµ„³NodeType„„µ±LeafType´³refµ„³LeafType„„„„³WindowTitle´³rec´³lit³window-title„´³tupleµ´³named³title´³atom³String„„„„„³WidgetInstance´³rec´³lit³widget-instance„´³tupleµ´³named³id´³refµ„³WidgetId„„´³named³instance´³embedded³any„„„„„³WindowCloseable´³rec´³lit³window-closeable„´³tupleµ„„„„³embeddedType€„„µ³mime„´³schema·³version‘³definitions·³Value´³rec´³lit³mime„´³tupleµ´³named³type´³atom³Symbol„„´³named³data´³atom³
|
||||
ByteString„„„„„„³embeddedType€„„µ³time„´³schema·³version‘³definitions·³Stamp´³rec´³lit³rfc3339„´³tupleµ´³named³value´³atom³String„„„„„„³embeddedType€„„µ³audio„´³schema·³version‘³definitions·³Sink´³orµµ±speaker´³lit³speaker„„µ±headset´³lit³headset„„µ±earpiece´³lit³earpiece„„„„³Source´³orµµ±speakerphone´³lit³speakerphone„„µ±headset´³lit³headset„„µ±handset´³lit³handset„„„„³SinkMapping´³rec´³lit³alsa-sink-mapping„´³tupleµ´³named³abstract´³refµ„³Sink„„´³named³concrete´³atom³String„„„„„³HeadsetSpeakerPresent´³rec´³lit³headset-speaker-present„´³tupleµ„„„³HeadsetMicrophonePresent´³rec´³lit³headset-microphone-present„´³tupleµ„„„„³embeddedType€„„µ³hayes„´³schema·³version‘³definitions·³Result´³rec´³lit³result„´³tupleµ´³named³text´³atom³String„„´³named³tag´³refµ„³MaybeString„„´³named³fields´³refµ„³MaybeStrings„„„„„³MaybeString´³orµµ±present´³atom³String„„µ±absent´³lit€„„„„³MaybeStrings´³orµµ±present´³seqof´³atom³String„„„µ±absent´³lit€„„„„³ModemPresent´³rec´³lit³modem„´³tupleµ´³lit³hayes„´³named³
|
||||
devicePath´³atom³String„„´³named³ dataspace´³embedded´³refµ„³InternalProtocol„„„„„„³
CommandResult´³rec´³lit³command-result„´³tupleµ´³named³commandText´³atom³String„„´³named³results´³seqof´³refµ„³Result„„„´³named³finalResult´³atom³String„„„„„³ExecuteCommand´³rec´³lit³execute-command„´³tupleµ´³named³commandText´³atom³String„„´³named³replyTo´³refµ„³CommandContinuation„„„„„³InternalProtocol³any³CommandContinuation´³orµµ±replyWanted´³embedded´³refµ„³
CommandResult„„„µ±
fireAndForget´³lit€„„„„³UnsolicitedResultCode´³rec´³lit³unsolicited„´³tupleµ´³named³result´³refµ„³Result„„„„„„³embeddedType€„„µ³ telephony„´³schema·³version‘³definitions·³CallId´³atom³
SignedInteger„³Address´³rec´³lit³address„´³tupleµ´³named³
|
||||
devicePath´³atom³String„„´³named³ dataspace´³embedded´³refµ„³InternalProtocol„„„„„„³
CommandResult´³rec´³lit³command-result„´³tupleµ´³named³commandText´³atom³String„„´³named³results´³seqof´³refµ„³Result„„„´³named³finalResult´³atom³String„„„„„³ExecuteCommand´³rec´³lit³execute-command„´³tupleµ´³named³commandText´³atom³String„„´³named³replyTo´³refµ„³CommandContinuation„„„„„³InternalProtocol³any³CommandContinuation´³orµµ±replyWanted´³embedded´³refµ„³
CommandResult„„„µ±
fireAndForget´³lit€„„„„³UnsolicitedResultCode´³rec´³lit³unsolicited„´³tupleµ´³named³result´³refµ„³Result„„„„„„³embeddedType€„„µ³network„´³schema·³version‘³definitions·³Route´³rec´³lit³route„´³tupleµ´³named³
addressFamily´³refµ„³
AddressFamily„„´³named³destination´³refµ„³RouteDestination„„´³named³priority´³atom³
SignedInteger„„´³named³
typeOfService´³atom³
SignedInteger„„´³named³
interfaceName´³refµ„³RouteInterface„„´³named³gateway´³refµ„³Gateway„„„„„³Gateway´³orµµ±addr´³atom³String„„µ±none´³lit€„„„„³ Interface´³rec´³lit³ interface„´³tupleµ´³named³name´³atom³String„„´³named³index´³atom³
SignedInteger„„´³named³administrativeState´³refµ„³AdministrativeState„„´³named³operationalState´³refµ„³OperationalState„„´³named³carrier´³refµ„³CarrierState„„´³named³linkAddr´³atom³String„„„„„³CarrierState´³orµµ± noCarrier´³lit³
|
||||
no-carrier„„µ±carrier´³lit³carrier„„„„³
AddressFamily´³orµµ±ipv4´³lit³ipv4„„µ±ipv6´³lit³ipv6„„µ±other´³atom³
SignedInteger„„„„³RouteInterface´³orµµ±name´³atom³String„„µ±none´³lit€„„„„³OperationalState´³orµµ±unknown´³lit³unknown„„µ±down´³lit³down„„µ±lowerLayerDown´³lit³lower-layer-down„„µ±testing´³lit³testing„„µ±dormant´³lit³dormant„„µ±up´³lit³up„„„„³RouteDestination´³orµµ±default´³lit³default„„µ±prefix´³rec´³lit³prefix„´³tupleµ´³named³net´³atom³String„„´³named³bits´³atom³
SignedInteger„„„„„„„„³AdministrativeState´³orµµ±unknown´³lit³unknown„„µ±down´³lit³down„„µ±up´³lit³up„„„„„³embeddedType€„„µ³ telephony„´³schema·³version‘³definitions·³CallId´³atom³
SignedInteger„³Address´³rec´³lit³address„´³tupleµ´³named³
|
||||
numberType´³refµ„³
|
||||
NumberType„„´³named³number´³atom³String„„„„„³CallType´³orµµ±voice´³lit³voice„„µ±data´³lit³data„„µ±fax´³lit³fax„„„„³ CallState´³orµµ±hold´³lit³hold„„µ±original´³lit³original„„µ±connect´³lit³connect„„µ±incoming´³lit³incoming„„µ±waiting´³lit³waiting„„µ±end´³lit³end„„µ±alerting´³lit³alerting„„„„³ PlaceCall´³rec´³lit³
|
||||
place-call„´³tupleµ´³named³
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
version 1 .
|
||||
|
||||
Interface = <interface
|
||||
@name string
|
||||
@index int
|
||||
@administrativeState AdministrativeState
|
||||
@operationalState OperationalState
|
||||
@carrier CarrierState
|
||||
@linkAddr string> .
|
||||
|
||||
AdministrativeState =
|
||||
/ =unknown
|
||||
/ =down
|
||||
/ =up
|
||||
.
|
||||
|
||||
OperationalState =
|
||||
/ =unknown
|
||||
/ =down
|
||||
/ @lowerLayerDown =lower-layer-down
|
||||
/ =testing
|
||||
/ =dormant
|
||||
/ =up
|
||||
.
|
||||
|
||||
CarrierState =
|
||||
/ @noCarrier =no-carrier
|
||||
/ =carrier
|
||||
.
|
||||
|
||||
Route = <route
|
||||
@addressFamily AddressFamily
|
||||
@destination RouteDestination
|
||||
@priority int
|
||||
@typeOfService int
|
||||
@interfaceName RouteInterface
|
||||
@gateway Gateway> .
|
||||
|
||||
AddressFamily =
|
||||
/ =ipv4
|
||||
/ =ipv6
|
||||
/ @other int
|
||||
.
|
||||
|
||||
RouteDestination =
|
||||
/ =default
|
||||
/ @prefix <prefix @net string @bits int>
|
||||
.
|
||||
|
||||
RouteInterface =
|
||||
/ @name string
|
||||
/ @none #f
|
||||
.
|
||||
|
||||
Gateway =
|
||||
/ @addr string
|
||||
/ @none #f
|
||||
.
|
|
@ -29,6 +29,13 @@ then
|
|||
qemu-img create -f qcow2 -F qcow2 -b ${BASEIMG} ${TMPIMG}
|
||||
fi
|
||||
|
||||
if [ -z "${DISPLAY:-}" ]
|
||||
then
|
||||
displayopts="-display none"
|
||||
else
|
||||
displayopts="-display gtk"
|
||||
fi
|
||||
|
||||
qemu-system-x86_64 \
|
||||
-nodefaults \
|
||||
-kernel ${ROOTDIR}/boot/vmlinuz-lts \
|
||||
|
@ -44,4 +51,4 @@ qemu-system-x86_64 \
|
|||
-vga virtio \
|
||||
-enable-kvm \
|
||||
-cpu host \
|
||||
-display gtk
|
||||
${displayopts}
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
<require-service <daemon squeak>>
|
||||
<depends-on <daemon squeak> <service-state <milestone network> ready>>
|
||||
<depends-on <daemon squeak> <service-state <daemon fbdev-setup> complete>>
|
||||
|
||||
<daemon fbdev-setup <one-shot "echo 1 > /sys/class/graphics/fb0/state">>
|
||||
|
||||
<daemon squeak {
|
||||
argv: "exec squeak -vm-display-fbdev -msdev /dev/null -kbdev /dev/input/event2"
|
||||
dir: "/home/user"
|
||||
protocol: application/syndicate
|
||||
}>
|
||||
|
||||
? <service-object <daemon squeak> ?cap> [
|
||||
$cap {
|
||||
config: $config
|
||||
}
|
||||
]
|
|
@ -0,0 +1,27 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Transmogrifies a running, plain PostmarketOS system into a Synit system
|
||||
|
||||
set -eu
|
||||
|
||||
SUDOPASS=${SUDOPASS:-user}
|
||||
|
||||
if [ $(id -u) -ne 0 ]
|
||||
then
|
||||
echo ${SUDOPASS} | sudo -S "$0" "$@"
|
||||
exit $?
|
||||
fi
|
||||
echo
|
||||
|
||||
cp synit-apk-key.pub /etc/apk/keys/.
|
||||
. /etc/deviceinfo
|
||||
ls packages/$deviceinfo_arch/
|
||||
|
||||
sudo apk add -X `pwd`/packages \
|
||||
preserves-tools \
|
||||
squeak-cog-vm \
|
||||
syndicate-sh \
|
||||
synit-config
|
||||
|
||||
rm -f /etc/syndicate/squeak.pr
|
||||
cp -p `pwd`/squeak.pr /etc/syndicate/squeak.pr
|
|
@ -0,0 +1,19 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Upload packages and scripts for converting a plain PostmarketOS system into a Synit system
|
||||
|
||||
set -eu
|
||||
|
||||
HOST=${1:-pm-qemu}
|
||||
SUDOPASS=${SUDOPASS:-user}
|
||||
|
||||
ssh ${HOST} "echo ${SUDOPASS} | sudo -S apk add rsync"
|
||||
rsync -avu --delete \
|
||||
transmogrify.sh \
|
||||
squeak.pr \
|
||||
packaging/synit-apk-key.pub \
|
||||
packaging/target/packages \
|
||||
../squeak-phone/images/current/squeak.changes \
|
||||
../squeak-phone/images/current/squeak.image \
|
||||
../squeak-phone/sounds \
|
||||
${HOST}:.
|
Loading…
Reference in New Issue