Skip to content

Commit

Permalink
Add Internet Connectivity
Browse files Browse the repository at this point in the history
  • Loading branch information
nyxkrage committed Dec 21, 2022
1 parent 892fdef commit 14abfdf
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .emacs.d/init.el
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@

;; Add some standard directories to exec-path to use in eshell
(setenv "PATH" "/bin:/sbin")
(add-to-list 'load-path "/.emacs.d/")

;; Mount various needed virtual/tmp filesystem
(call-process "/sbin/mount" nil "*log*" nil "-t" "proc" "proc" "/proc")
Expand All @@ -59,6 +60,11 @@
(call-process "/sbin/mount" nil "*log*" nil "-t" "tmpfs" "run" "/run")
(call-process "/sbin/mount" nil "*log*" nil "-t" "devtmpfs" "dev" "/dev")

(call-process "/bin/hostname" nil nil nil "emacs")

(require 'ip)
(assign-ip '(172 16 57 10) "ens33")

(custom-set-variables
'(inhibit-startup-screen t)
'(initial-buffer-choice nil))
Expand Down
34 changes: 34 additions & 0 deletions .emacs.d/ip.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
(defun ip-to-string (ip)
(mapconcat 'int-to-string ip "."))

(defun modify-ip (ip idx newval)
(let ((i (copy-tree ip)))
(setcar (nthcdr idx i) newval)
i))

(defun assign-ip (ip interface)
(call-process "/sbin/ip" nil "*log*" nil
"addr"
"add"
(concat (ip-to-string ip) "/24")
"broadcast"
(ip-to-string (modify-ip ip 3 255))
"dev"
interface)
(call-process "/sbin/ip" nil "*log*" nil
"link"
"set"
"dev"
interface
"up")
(call-process "/sbin/ip" nil "*log*" nil
"route"
"add"
"default"
"via"
(ip-to-string (modify-ip ip 3 2))
"dev"
interface))

(provide 'ip)

3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@
[submodule "busybox"]
path = busybox
url = https://github.com/mirror/busybox
[submodule "libxml2"]
path = libxml2
url = https://github.com/GNOME/libxml2.git
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,23 @@ $ make DESTDIR=$PWD/build install
$ popd
```

## Statically compiled libxml2
The Emacs web browser requires libxml2 to work

``` shellsession
$ pushd libxml2
$ cmake -DBUILD_SHARED_LIBS=OFF -DLIBXML2_WITH_LZMA=OFF -DLIBXML2_WITH_ZLIB=OFF -DLIBXML_HTTP_ENABLED=OFF -DCMAKE_INSTALL_PREFIX:PATH=$PWD/build .
$ sudo cmake --build . --target install
$ popd libmxl2
```

## Statically compiled Emacs
We need a statically compiled version of emacs if we want to keep the rootfs minimal

``` shellsession
$ pushd emacs
$ ./autogen.sh
$ ./configure --with-json=no --without-x --without-libsystemd --without-gnutls --with-sound=no --without-lcms2 --without-dbus CFLAGS="-static -O3 -I$PWD/../ncurses/build/include" LDFLAGS="-static -L$PWD/../ncurses/build/lib" CC=musl-gcc CXX=musl-gcc --prefix=""
$ ./configure --with-json=no --without-x --without-libsystemd --without-gnutls --with-sound=no --without-lcms2 --without-dbus CFLAGS="-static -O3 -I$PWD/../ncurses/build/include -I$PWD/../libxml2/build/include/libxml2 -I$PWD/../zlib/build/include -I$PWD/../lzma/liblzma" LDFLAGS="-static -L$PWD/../ncurses/build/lib -L$PWD/../libxml2/build/lib -L$PWD/../zlib/build/lib -lpthread -lm -ldl" CC=musl-gcc CXX=musl-gcc --prefix=""
$ make -j$(nproc)
$ sudo make DESTDIR=$ROOTFS_MNT install
$ popd
Expand Down
1 change: 1 addition & 0 deletions libxml2
Submodule libxml2 added at f67dc6

0 comments on commit 14abfdf

Please sign in to comment.