From 481b44872f39053669ca9a517b52ad521afe610b Mon Sep 17 00:00:00 2001
From: Yuval Adam <_@yuv.al>
Date: Mon, 7 Aug 2017 09:42:33 +0300
Subject: Sample blog post
---
app.py | 2 +-
content/blog/2017-05-26-intro.md | 165 +++++++++++++++++++++++++++++++++++++++
2 files changed, 166 insertions(+), 1 deletion(-)
create mode 100644 content/blog/2017-05-26-intro.md
diff --git a/app.py b/app.py
index e0b4d13..97fe702 100644
--- a/app.py
+++ b/app.py
@@ -33,7 +33,7 @@ def blog_post(y, m, d, title):
if h.startswith('title'):
title = h.split('title:')[0].strip()
html = markdown.markdown(body, extensions=['markdown.extensions.extra', 'markdown.extensions.codehilite'])
- return render_template('post.html', title=title, html=html)
+ return render_template('blog-post.html', title=title, html=html)
def parse_page(page):
slug = page[:-3]
diff --git a/content/blog/2017-05-26-intro.md b/content/blog/2017-05-26-intro.md
new file mode 100644
index 0000000..cca8a99
--- /dev/null
+++ b/content/blog/2017-05-26-intro.md
@@ -0,0 +1,165 @@
+---
+title: postmarketOS: Aiming for a 10 year life-cycle for smartphones
+---
+
+
+_Introduction post to [postmarketOS](https://github.com/postmarketOS/), a touch-optimized, pre-configured [Alpine Linux](https://alpinelinux.org/) with own packages, that can be installed on smartphones. (Not usable for most people yet!)_
+
+
+
+_Update: Alpine Linux developers do not see their distribution as "GNU/Linux", so I won't be using this term for Alpine or pmOS anymore. One of these developers, ^7heo, [helped me](https://github.com/ollieparanoid/ollieparanoid.github.io/pull/1) to reword this article and other pages on this blog accordingly, thank you!_
+
+[Index](#index)
+
+* [Minimalistic Linux distributions run fine on ten year old PCs.](#10-year-old-pcs)
+* [Why are Android/Linux phones different?](#why-is-android-different)
+* [We can fix this as a community.](#we-can-fix-this)
+* [postmarketOS architecture](#architecture)
+* [Prototype](#prototype)
+* [pmbootstrap](#pmbootstrap)
+* [Future goals and where you could help](#future)
+* [There is so much more...](#more)
+
+[Minimalistic Linux distributions run fine on ten year old PCs.](#10-year-old-pcs)
+
+It is 2017\. Pick an average PC from 2007 and install a minimal Linux based operating system. You will be able to do basic computing tasks (eg. surfing the web, reading E-Mails, listening to music, chatting) just like on an _expensive_ modern PC. You will even get security updates, so your old computer is protected, just like as a new one.
+
+[Why are Android/Linux phones different?](#why-is-android-different)
+
+Androids architecture is based on **forking** (one might as well say _copy-pasting_) **the entire code-base for each and every device _and_ Android version.** And then working on that independent, basically instantly incompatible version. Especially adding device-specific drivers plays an important role.
+
+This workflow makes it next to impossible to patch all Android devices with security updates in time or at all (_Stagefright_ vulnerabilities for example rendered [one billion devices](https://threatpost.com/stagefright-2-0-vulnerabilities-affect-1-billion-android-devices/114863/) vulnerable). And even if the vendor provides updates, it will only be for a limited time and then you must buy a new device to get security updates or the latest Android version. How convenient!
+
+Alright, so there is the [LineageOS](https://lineageos.org/) community, which provides weekly updates for an impressive number of smartphones. They provide a practical solution today, and I am very grateful for that. However, such Android based projects will always run behind Google and the phone industry, fixing only symptoms but never the root-cause.
+
+_This is just the tip of the iceberg. Android has way more problems, read Cascardo's [GNU on Smartphones (part II)](https://cascardo.eti.br/blog/GNU_on_Smartphones_part_II/) for more nightmares._
+
+[We can fix this as a community.](#we-can-fix-this)
+
+Here is the solution: Bend an existing Linux distribution to run on smartphones. Apply all necessary changes as small patches and upstream them, where it makes sense.
+
+Of course I am not the only one, that came to this conclusion - especially in the last few weeks with the [Halium](https://halium.org/) project rising _(greetings!)_. I am all-in for working together — sharing udev rules, merging Android kernels together, whatever makes sense!
+
+[](https://ollieparanoid.github.io/img/2017-05-26/i9100/telnet.jpg)
+
+[postmarketOS architecture](#architecture)
+
+I'm working on an Alpine Linux based distribution called postmarketOS where each phone will have **only one [unique](https://github.com/postmarketOS/pmbootstrap/tree/master/aports/device-samsung-i9100/) [package](https://github.com/postmarketOS/pmbootstrap/tree/master/aports/device-lg-mako)** — all other packages are shared among all devices.
+
+These `device-$vendor-$name` packages contain a so-called `/etc/deviceinfo` file, which [describes](https://github.com/postmarketOS/pmbootstrap/blob/master/aports/device-samsung-i9100/deviceinfo) [what](https://github.com/postmarketOS/pmbootstrap/blob/master/aports/device-lg-mako/deviceinfo) makes the device special: SD card availability, which flash software to use and other information. The file format is not stable yet, and once we have common kernels for multiple devices, I'd like to include the required modules and `dtb` name.
+
+And just to make it clear, postmarketOS does not fit the Halium model, as it avoids the Android build system entirely and does _not_ run any part of the Android userspace next to its more or less typical Linux userspace. _(At least not in the regular install, but it could come at some point in the future as optional compatibility layer for Android applications if someone wants to work on it. Personally, I'd rather have native Linux applications (in the case of Alpine: linked against [musl](https://www.musl-libc.org/), dynamically or statically) than Android apps on my phone.)_
+
+[Prototype](#prototype)
+
+So much for the theory. Practically I can show you a sophisticated chroot/build/flash tool called **pmbootstrap** which should allow **fast and clean development progress**, both in porting to new phones and in implementing hardware support for the existing ports _(more on pmbootstrap below)_. That is also where most of the time went during development so far, so don't expect too much of postmarketOS. Most drivers don't work so you can't make phone calls or use the WiFi. Nevertheless, here is the current state of postmarketOS.
+
+Devices:
+
+* Samsung Galaxy SII (samsung-i9100)
+* Google Nexus 4 (lg-mako)
+
+Features:
+
+* Encrypted root file system (password needs to be typed in via USB telnet right now)
+* Installation on SD card or internal memory
+* Weston with working touchscreen
+* Weston demos work performantly (_without_ proprietary 3D acceleration!)
+* SSH access via USB
+* Kernels compiled from LineageOS source
+* Clean package manager based installation
+
+[ ](https://ollieparanoid.github.io/img/2017-05-26/i9100/demos.jpg) [  ](https://ollieparanoid.github.io/img/2017-05-26/i9100/firefox.jpg) [  ](https://ollieparanoid.github.io/img/2017-05-26/i9100/htop.jpg) [  ](https://ollieparanoid.github.io/img/2017-05-26/i9100/smoke.jpg) [](https://ollieparanoid.github.io/img/2017-05-26/mako/editor.jpg)
+
+Generally speaking, the samsung-i9100 port works better than the lg-mako port. The latter has some strange driver bugs. The boot splash images only appear for a second, XWayland does not work there and the colors in Weston are all red. I even [had to patch Weston](https://patchwork.freedesktop.org/patch/150943/) before it worked at all. Without the patch it assumes it should draw with 0 Hz — in other words: Never ;)
+
+It should be noted, that the [Replicant](https://www.replicant.us/), the free software clone of Android, also targets the [samsung-i9100](https://redmine.replicant.us/projects/replicant/wiki/GalaxyS2I9100) and has [open source user-space drivers for the modem](https://redmine.replicant.us/projects/replicant/wiki/Samsung-RIL), which I plan to package for postmarketOS/Alpine Linux.
+
+[pmbootstrap](#pmbootstrap)
+
+_Technical details incoming! If you're not into that, skip this section._
+
+Alpine Linux is _really small_. A base installation is only about 6 MB in size and takes not more than a few seconds to extract! Thanks to this characteristic, I was able to write a bootstrap program that abstracts everything in [chroots](https://en.wikipedia.org/wiki/chroot) and therefore basically runs on top of any Linux distribution (GNU-based or not), which has Python 3 and the `openssl` command line program available.
+
+Consequently, the host system does not get touched when installing the required programs ([`fastboot`](https://en.wikipedia.org/wiki/Android_software_development#Fastboot) etc.) and your distribution doesn't even need to have them packaged.
+
+Quick feature rundown:
+
+* Chroot setup (with distro-independent [QEMU user emulation](https://wiki.debian.org/QemuUserEmulation)):
+ * `x86_64`* (building, flashing, ...)
+ * `armhf`* (building)
+ * `armhf`* (target rootfs)
+* Clean chroot shutdown (`umount`) and zapping
+* Build software as packages:
+ * Wraps `abuild`, the ["light version of `makepkg`"](https://github.com/alpinelinux/abuild/blob/master/abuild.in#L3)
+ * Alpine Linux' [`APKBUILD`s](https://wiki.alpinelinux.org/wiki/APKBUILD_Reference) are very similar to Arch Linux' `PKGBUILD`s
+* [Cross-compile](https://en.wikipedia.org/wiki/Cross_compiler) **all** `armhf`-packages:
+ * Linux Kernel: build with cross-compiler in `x86_64` chroot
+ * Other: build in `armhf` chroot, use cross-compiler with [`distcc`](https://en.wikipedia.org/wiki/distcc) from `x86_64` chroot ([alarm-style](https://archlinuxarm.org/wiki/Distcc_Cross-Compiling))
+ * Use Alpine Linux' shipped modern `gcc`, no pre-built Android toolchain
+* Effective caching out of the box (survives chroot zaps):
+ * [`ccache`](https://ccache.samba.org/) (also works with `distcc`/cross-compiler)
+ * Alpine Linux package cache
+* Installation targets:
+ * Raw image file (flash as "system" partition)
+ * SD card
+* Flasher abstraction:
+ * [`fastboot`](https://en.wikipedia.org/wiki/Android_software_development#Fastboot)
+ * [`heimdall`](http://glassechidna.com.au/heimdall/)
+ * ... really easy to add more!
+* Logging:
+ * all shell commands executed are logged in an extra file
+ * readable overview is displayed on the screen
+* Security:
+ * Initial package manager download
+ * Signature verification with `openssl` against keys shipped with pmbootstrap
+ * Minimum installed version check (for downloaded package and version reported by the extracted binary)
+ * All executed shell commands get properly escaped with Python's built-in [shlex](https://docs.python.org/3/library/shlex.html)
+ * Working testcases for the above two points
+ * Only using root rights where necessary (through sudo)
+ * No default passwords in the installation: The `install` action asks for the _user's_ and for the _root partition_ password.
+
+* `x86_64`/`armhf`: Example architectures for host/target. The code is generic, so it should work with any architectures supported by Alpine Linux.
+
+[Future goals and where _you_ could help](#future)
+
+Rough direction of where I'd like postmarketOS to head to. In case you're a hacker who wants to help, feel free to do so. But please write into the [tracker](https://github.com/postmarketOS/pmbootstrap/issues) before starting serious work. This way we can make sure, that we do not have redundant work.
+
+### Devices
+
+Pick an old Android device, that you don't need anymore and start porting postmarketOS for it. It should be pretty straight forward. One `device-*` package, one for the kernel, calibrate the touchscreen, and the demos should more or less work already!
+
+If you're feeling adventurous, try a non-Android device. [How about iPhones](https://en.wikipedia.org/wiki/OpeniBoot)? I'll probably be working on a port for at least one non-Android device myself for demonstration purposes.
+
+### Drivers
+
+Fix the lg-mako screen colors and/or make the following peripherals work:
+
+* WiFi
+* Audio
+* Modem (Phone calls, mobile internet)
+* Hardware buttons (Volume keys, home button)
+* Camera
+* ...
+
+In most cases, the drivers are already provided by the Android/LineageOS kernels, that we currently use and only need to be configured in the userspace (for example with [udev rules](https://en.wikipedia.org/wiki/Udev)).
+
+The long time goal is using the [mainline kernel](https://lwn.net/Articles/680109/).
+
+### Phone interface
+
+Package a Linux-based phone interface. [Plasma mobile](https://plasma-mobile.org/) _seems_ to be the most complete one right now (although still not stable). But I'd also be interested in [ubports](https://ubports.com/) (fork of the discontinued [Ubuntu Touch](https://en.wikipedia.org/wiki/Ubuntu_Touch)) once it matures. Or maybe writing a minimal Android-like interface based on [libweston](https://github.com/wayland-project/weston).
+
+From what I understand, the [SailfishOS interface is closed source](https://together.jolla.com/question/20488/which-parts-of-sailfish-are-closed-source-why-and-will-that-change/), so that will not be an option.
+
+_postmarketOS is developed in the spirit of regular Linux distributions, so there's no problem in having multiple phone interfaces (just like KDE/Gnome/XFCE/...) and let the user choose._
+
+### Security
+
+Great care has been taken to make pmbootstrap safe, as it will run on productive systems of postmarketOS developers. This is not the case for postmarketOS in its current proof-of-concept state (Weston runs as root, ...) so we must work on that before it can be used in real life. Even better would be [privilege separation](https://en.wikipedia.org/wiki/Privilege_separation) throughout the entire OS.
+
+[There is so much more...](#more)
+
+...but the blog post is long enough as it is, so I'll wrap it up. Thanks for reading, thanks to my friends who reviewed earlier versions of this blog post. Thanks to Replicant, LineageOS, Halium. Together, we can make the vision of long-lasting, open source smartphone operating systems a reality!
+
+**Tell your friends!**
--
cgit v1.3.1