Compare commits

..

6 Commits

Author SHA1 Message Date
Daniel Barlow a9d1582b53 remove unused arg 2024-07-26 23:41:50 +01:00
Daniel Barlow eca8e37e7a anoia.svc use timeout for inotify
in case we miss a message, check the directory every 5s
anyway
2024-07-26 23:40:40 +01:00
Daniel Barlow d300373b96 anoia fs.dir use case not match
match was accidentally pinning the return from readdir against the
function parameter. Which didn't work.
2024-07-26 23:37:40 +01:00
Daniel Barlow 70ca7fac17 elfutils is reqd by iproute2 (for bpf?), build sans kitchen sink 2024-07-24 22:07:58 +01:00
Daniel Barlow 79a3a45061 build iproute2 without rb to avoid stdatomic 2024-07-24 21:13:55 +01:00
Daniel Barlow 612d6d7a51 build openssl without threads to avoid stdatomic 2024-07-24 21:12:52 +01:00
4 changed files with 58 additions and 21 deletions

View File

@ -3,7 +3,6 @@
, linotify , linotify
, anoia , anoia
, lualinux , lualinux
, lua
}: }:
writeFennel "acquire-wan-address" { writeFennel "acquire-wan-address" {
packages = [ linotify anoia lualinux ]; packages = [ linotify anoia lualinux ];

View File

@ -113,6 +113,21 @@ extraPkgs // {
''; '';
}); });
elfutils =
let native = (with final.stdenv; (buildPlatform == hostPlatform));
in if native
then prev.elfutils
else
let
e = prev.elfutils.overrideAttrs(o: {
configureFlags = o.configureFlags ++[
"ac_cv_has_stdatomic=no"
];
});
in e.override {
enableDebuginfod = false;
};
hostapd = hostapd =
let let
config = [ config = [
@ -141,6 +156,10 @@ extraPkgs // {
}); });
in h.override { openssl = null; sqlite = null; }; in h.override { openssl = null; sqlite = null; };
# berlekey db needs libatomic which we haven't figured out yet.
# disabling it means we don't have arpd
iproute2 = prev.iproute2.override { db = null; };
kexec-tools-static = prev.kexec-tools.overrideAttrs(o: { kexec-tools-static = prev.kexec-tools.overrideAttrs(o: {
# For kexecboot we copy kexec into a ramdisk on the system being # For kexecboot we copy kexec into a ramdisk on the system being
# upgraded from. This is more likely to work if kexec is # upgraded from. This is more likely to work if kexec is
@ -177,7 +196,11 @@ extraPkgs // {
]; ];
}); });
openssl = prev.openssl.overrideAttrs (o: { openssl = prev.openssl.overrideAttrs (o:
with final;
let cross = stdenv.buildPlatform != stdenv.hostPlatform;
in
{
# we want to apply # we want to apply
# https://patch-diff.githubusercontent.com/raw/openssl/openssl/pull/20273.patch"; # https://patch-diff.githubusercontent.com/raw/openssl/openssl/pull/20273.patch";
# which disables overriding the -march cflags to the wrong values, # which disables overriding the -march cflags to the wrong values,
@ -186,11 +209,19 @@ extraPkgs // {
postPatch = postPatch =
o.postPatch o.postPatch
+ ( + (
with final; lib.optionalString cross ''
lib.optionalString ( sed -i.bak 's/linux.*-mips/linux-mops/' Configure
stdenv.buildPlatform != stdenv.hostPlatform ''
) "\nsed -i.bak 's/linux.*-mips/linux-mops/' Configure\n"
); );
# openssl with threads requires stdatomic which drags in libgcc
# as a dependency
configureFlags = []
++ (lib.optional cross "no-threads")
++ o.configureFlags;
# don't need or want this bash script
postInstall = o.postInstall +
(lib.optionalString cross "rm $bin/bin/c_rehash\n");
}); });
pppBuild = prev.ppp; pppBuild = prev.ppp;

View File

@ -38,9 +38,10 @@
(fn dir [name] (fn dir [name]
(let [dp (assert (ll.opendir name) name)] (let [dp (assert (ll.opendir name) name)]
(fn [] (fn []
(match (ll.readdir dp) (case (ll.readdir dp)
(name type) (values name type) (name filetype) (values name filetype)
(nil err) (do (if err (print err)) (ll.closedir dp) nil))))) (nil err) (do (if (> err 0) (print "ERR" err)) (ll.closedir dp) nil)
))))
(fn rmtree [pathname] (fn rmtree [pathname]
(case (file-type pathname) (case (file-type pathname)

View File

@ -1,13 +1,14 @@
(local inotify (require :inotify)) (local inotify (require :inotify))
(local { : file-exists? } (require :anoia)) (local { : file-exists? } (require :anoia))
(local { : file-type : dir &as fs } (require :anoia.fs)) (local { : file-type : dir &as fs } (require :anoia.fs))
(local ll (require :lualinux))
(fn read-line [name] (fn read-line [name]
(with-open [f (assert (io.open name :r) (.. "can't open file " name))] (with-open [f (assert (io.open name :r) (.. "can't open file " name))]
(f:read "*l"))) (f:read "*l")))
(fn watch-fsevents [directory-name] (fn watch-fsevents [directory-name]
(let [handle (inotify.init)] (let [handle (inotify.init { :blocking false})]
(handle:addwatch directory-name (handle:addwatch directory-name
inotify.IN_CREATE inotify.IN_CREATE
inotify.IN_MOVE inotify.IN_MOVE
@ -39,11 +40,16 @@
(coroutine.yield self) (coroutine.yield self)
(self:wait)))) (self:wait))))
(fn read-with-timeout [watcher]
(let [fd (watcher:fileno)]
(ll.pollin fd 5000)
(watcher:read)))
(fn open [directory] (fn open [directory]
(let [watcher (watch-fsevents directory) (let [watcher (watch-fsevents directory)
has-file? (fn [filename] (file-exists? (.. directory "/" filename)))] has-file? (fn [filename] (file-exists? (.. directory "/" filename)))]
{ {
:wait #(watcher:read) :wait #(read-with-timeout watcher)
:ready? (fn [self] :ready? (fn [self]
(and (has-file? "state") (not (has-file? ".lock")))) (and (has-file? "state") (not (has-file? ".lock"))))
:output (fn [_ filename] :output (fn [_ filename]