====== Bauen eines Firefox-Android-Paketes (apk) ====== Nachfolgend soll das Bauen eines Firefox-Android-Paketes (apk) beschrieben werden. Es wird dabei die Anleitung der Seite [[https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Build_Instructions/Simple_Firefox_for_Android_build|Mozilla Central]] abgearbeitet. \\ ===== Voraussetzungen ===== Es wird ein DEBIAN-Linux-System vorausgesetzt, sowie eine Verbindung zum Internet. \\ Zum Herunterladen der Bauumgebung wird [[https://www.mercurial-scm.org/|Mercurial]] verwendet. Dafür muss das Paket "''mercurial''" installiert werden: ~# apt install mercurial \\ ===== Klonen ===== Jetzt kann die Bauumgebung heruntergeladen werden: ~$ mkdir -p /data/MozillaFirefoxAPK ~$ cd /data/MozillaFirefoxAPK ~$ hg clone https://hg.mozilla.org/mozilla-central destination directory: mozilla-central applying clone bundle from https://hg.cdn.mozilla.net/mozilla-central/0d806b3230fe4767fa70cdee57db87d1e9a5ba49.gzip-v2.hg adding changesets adding manifests adding file changes added 402376 changesets with 2498413 changes to 420988 files finished applying clone bundle searching for changes no changes found updating to branch default 232051 files updated, 0 files merged, 0 files removed, 0 files unresolved \\ ===== Bootstrap ===== Damit der nächste Schritt, das Erstellen des "''bootstrap''", funktioniert muss das Programm "''npm''" installiert sein. Dieses ist aber nicht im Repository von "''stretch''" vorhanden und wird daher aus dem "''sid''"-Repository neu gebaut. Zum Bauen wird eine [[software:schroot|CHROOT-Umgebung]] verwendet. \\ === npm === Bevor das Paket gebaut werden kann, müssen die Bauabhängigkeiten erfüllt werden: ~# apt install cdbs debhelper dh-buildinfo bash-completion nodejs node-glob ruby-ronn node-marked \\ Nachdem die Quellen für das "''sid-Repository''" hinzugefügt wurden, kann es installiert werden: ~# apt source npm \\ Jetzt kann das Paket gebaut werden: ~# cd npm-* ~# dpkg-buildpackage -us -uc \\ Jetzt kann die CHROOT-Umgebung wieder beendet werdne, falls sie zum Bauen genutzt wurde. Es sollte noch dafür gesorgt werden, dass ein Zugriff auf das soeben erstellte Paket außerhalb der CHROOT-Umgebung möglich ist. \\ Vor der Installation des Paketes müssen noch Abhängigkeiten Paket erfüllt werden: ~# apt install gyp libjs-inherits libjs-node-uuid libjs-underscore libssl1.0-dev libuv1 libuv1-dev node-abbrev \ node-ansi node-ansi-color-table node-archy node-async node-balanced-match node-block-stream node-brace-expansion \ node-builtin-modules node-combined-stream node-concat-map node-cookie-jar node-delayed-stream node-forever-agent \ node-form-data node-fs.realpath node-fstream node-fstream-ignore node-github-url-from-git node-glob node-graceful-fs \ node-gyp node-hosted-git-info node-inflight node-inherits node-ini node-is-builtin-module node-isexe \ node-json-stringify-safe node-lockfile node-lru-cache node-mime node-minimatch node-mkdirp node-mute-stream \ node-node-uuid node-nopt node-normalize-package-data node-npmlog node-once node-osenv node-path-is-absolute \ node-pseudomap node-qs node-read node-read-package-json node-request node-retry node-rimraf node-semver node-sha \ node-slide node-spdx-correct node-spdx-expression-parse node-spdx-license-ids node-tar node-tunnel-agent \ node-underscore node-validate-npm-package-license node-which node-wrappy node-yallist nodejs nodejs-dev \ rsync adb android-libadb android-libbase android-libcutils android-liblog android-sdk-platform-tools-common \\ Das neu erstellte Paket kann dann installiert werden (natürlich ausßerhalb der CHROOT-Umgebung): ~# dpkg -i npm_*.deb \\ === cargo === Der Pfad für "''cargo''" muss zum eigenen Pfad hinzugefügt werden (zum Beispiel in der Datei "''~/.bashrc''"): export PATH="$HOME/.cargo/bin:$PATH" \\ Damit der Eintrag wirksam wird, sollte die Datei eingelesen werden: ~$ source ~/.bashrc \\ === bootstrap === Jetzt kann der "''bootstrap''" erstellt werden: ~$ cd /data/MozillaFirefoxAPK/mozilla-central ~$ ./mach bootstrap Note on Artifact Mode: Firefox for Desktop and Android supports a fast build mode called artifact mode. Artifact mode downloads pre-built C++ components rather than building them locally, trading bandwidth for time. ... Please choose the version of Firefox you want to build: 1. Firefox for Desktop Artifact Mode 2. Firefox for Desktop 3. Firefox for Android Artifact Mode 4. Firefox for Android Your choice: 3 ... November 20, 2015 --------------------------------------- Accept? (y/N): y ... How would you like to continue? 1) Install a modern Mercurial via pip (recommended) 2) Install a legacy Mercurial via apt 3) Do not install Mercurial Choice:2 ... Would you like to run a configuration wizard to ensure Mercurial is optimally configured? 1. Yes 2. No Please enter your reply: 1 ... Would you like to continue using an old Mercurial version (Yn)? Y ... (Relevant config option: ui.username) What is your name? Unable to set username; You will be unable to author commits Mercurial is not configured to produce diffs in a more readable format. Would you like to change this (Yn)? Y Enable color output to your terminal (Yn) Y The "pager" extension transparently redirects command output to a pager program (like "less") so command output can be more easily consumed (e.g. output longer than the terminal can be scrolled). Please select one of the following for configuring pager: 1. Enable pager and configure with recommended settings (preferred) 2. Enable pager with default configuration 3. Don't enable pager Which option would you like? 1 Mercurial can provide richer terminal interactions for some operations by using the popular "curses" library. Would you like to enable "curses" interfaces (Yn)? Y Enable history rewriting commands (Yn)? Y ... Would you like to enable the evolve extension? (Yn) Y ... Enable logging of commands to help diagnose bugs and performance problems (Yn) Y ... The firefoxtree extension is *strongly* recommended if you: a) aggregate multiple Firefox repositories into a single local repo b) perform head/bookmark-based development (as opposed to mq) (Relevant config option: extensions.firefoxtree) Would you like to activate firefoxtree (Yn)? Y ... Would you like to install the `hg wip` alias (Yn)? Y Will you be submitting commits to Mozilla (Yn)? n ... Would you like to activate push-to-try (Yn)? n ... Would you like to see a diff of the changes first (Yn)? n Write changes to hgrc file (Yn)? Y Your hgrc file is currently readable by others. Sensitive information such as your Bugzilla credentials could be stolen if others have access to this file/machine. Would you like to fix the file permissions (Yn) Y ... Your system should be ready to build Firefox for Android Artifact Mode! \\ Folgende Pakete wurden auf dem beschriebenen System noch nachinstalliert: autoconf2.13 ccache dbus gir1.2-glib-2.0 libdbus-1-3 libdbus-glib-1-2 libexpat1-dev libgirepository-1.0-1 libossp-uuid16 libpython-all-dev libpython-dev libpython2.7 libpython2.7-dev libsigsegv2 m4 python-all python-all-dev python-cffi-backend python-crypto python-cryptography python-dbus python-dev python-enum34 python-gi python-idna python-ipaddress python-keyring python-keyrings.alt python-pip python-pip-whl python-pyasn1 python-secretstorage python-setuptools python-six python-wheel python-xdg python2.7-dev uuid zip adwaita-icon-theme at-spi2-core ca-certificates-java dconf-gsettings-backend dconf-service default-java-plugin default-jdk default-jdk-headless default-jre default-jre-headless fontconfig fontconfig-config fonts-dejavu-core fonts-dejavu-extra gcc-6-base:i386 glib-networking glib-networking-common glib-networking-services gnome-icon-theme gsettings-desktop-schemas gtk-update-icon-cache hicolor-icon-theme icedtea-8-plugin icedtea-netx icedtea-netx-common java-common libasound2 libasound2-data libasyncns0 libatk-bridge2.0-0 libatk-wrapper-java libatk-wrapper-java-jni libatk1.0-0 libatk1.0-data libatspi2.0-0 libavahi-client3 libavahi-common-data libavahi-common3 libc6:i386 libcairo-gobject2 libcairo2 libcolord2 libcroco3 libcups2 libdatrie1 libdconf1 libdrm-amdgpu1 libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libdrm2 libegl1-mesa libepoxy0 libflac8 libfontconfig1 libfontenc1 libfreetype6 libgail-common libgail18 libgbm1 libgcc1:i386 libgdk-pixbuf2.0-0 libgdk-pixbuf2.0-common libgif7 libgl1-mesa-dri libgl1-mesa-glx libglapi-mesa libgpm2:i386 libgraphite2-3 libgtk-3-0 libgtk-3-bin libgtk-3-common libgtk2.0-0 libgtk2.0-bin libgtk2.0-common libharfbuzz0b libice-dev libice6 libjbig0 libjpeg62-turbo libjson-glib-1.0-0 libjson-glib-1.0-common liblcms2-2 libllvm3.9 libncurses5:i386 libnspr4 libnss3 libogg0 libpango-1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0 libpciaccess0 libpcsclite1 libpixman-1-0 libpng16-16 libproxy1v5 libpthread-stubs0-dev libpulse0 librest-0.7-0 librsvg2-2 librsvg2-common libsensors4 libsm-dev libsm6 libsndfile1 libsoup-gnome2.4-1 libsoup2.4-1 libstdc++6:i386 libthai-data libthai0 libtiff5 libtinfo5:i386 libtxc-dxtn-s2tc libvorbis0a libvorbisenc2 libwayland-client0 libwayland-cursor0 libwayland-egl1-mesa libwayland-server0 libx11-dev libx11-doc libx11-xcb1 libxau-dev libxaw7 libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0 libxcb-present0 libxcb-render0 libxcb-shape0 libxcb-shm0 libxcb-sync1 libxcb-xfixes0 libxcb1-dev libxcomposite1 libxcursor1 libxdamage1 libxdmcp-dev libxfixes3 libxft2 libxi6 libxinerama1 libxkbcommon0 libxmu6 libxpm4 libxrandr2 libxrender1 libxshmfence1 libxt-dev libxt6 libxtst6 libxv1 libxxf86dga1 libxxf86vm1 openjdk-8-jdk openjdk-8-jdk-headless openjdk-8-jre openjdk-8-jre-headless x11-common x11-utils x11proto-core-dev x11proto-input-dev x11proto-kb-dev xkb-data xorg-sgml-doctools xtrans-dev \\ Auch hier erfolgt ein Verschieben mehrerer Konfigurationsverzeichnisse nach "''/data/''": ~$ cd ~$ mv .android /data/MozillaFirefoxAPK/ && ln -s /data/MozillaFirefoxAPK/.android ~$ mv .cargo /data/MozillaFirefoxAPK/ && ln -s /data/MozillaFirefoxAPK/.cargo ~$ mv .mozbuild /data/MozillaFirefoxAPK/ && ln -s /data/MozillaFirefoxAPK/.mozbuild ~$ mv .rustup /data/MozillaFirefoxAPK/ && ln -s /data/MozillaFirefoxAPK/.rustup \\ ===== Bauen ===== Die verschiedenen Umgebungsvariablen werden in der Datei "''mozilla-central/mozconfig''" definiert: # Enable debug versions of the pre-built binary artifacts: ac_add_options --enable-debug # Automatically download and use compiled C++ components: ac_add_options --enable-artifact-builds # Build Firefox for Android Artifact Mode: ac_add_options --enable-application=mobile/android ac_add_options --enable-artifact-builds # Erstellen von Paketen mit Architektur 'arm' ### ac_add_options --target=arm-linux-androideabi # Erstellen von Paketen mit Architektur 'x86' ac_add_options --target=i386-linux-android # With the following Android SDK: ac_add_options --with-android-sdk="/data/MozillaFirefoxAPK/.mozbuild/android-sdk-linux" # Enable artifact building: ac_add_options --enable-artifact-builds # Write build artifacts to: mk_add_options MOZ_OBJDIR=./objdir-frontend # Multi localisation ### mk_add_options MOZ_CHROME_MULTILOCALE="de" # Write build artifacts to: mk_add_options MOZ_OBJDIR=./objdir-frontend \\ Jetzt kann gebaut werden: ~$ ./mach build //Der Bauvorgang nimmt unter Umständen (je nach Rechnerkonfiguration) einige Zeit in Anspruch.// \\ Zum Bauen von Android-Paketen muss nach dem ersten Bauen dieser Befehl ausgeführt werden: ~$ ./mach build mobile/android \\ Nach erfolgreichem Bauen, kann das Paket erzeugt werden: ~$ ./mach package \\ Die fertige APK-Datei ist dann im Verzeichnis "''mozilla-central/objdir-frontend/dist/''" zu finden: "''fennec-.en-US.android-arm.apk''" \\ ===== Gradle ===== Für die Erstellung von Apps in Android Studio wird [[https://gradle.org/|Gradle]] verwendet. Damit die Bauumgebung importiert werden kann, bedarf es noch einer Vorbereitung. \\ Die Gradle-Umgebung muss erstellt werden: ~$ ./mach gradle clean app:assembleLocalPhotonDebug \\ Läuft das Erstellen der Gradle-Umgebung ohne Fehler durch, kann dies in Android Studio importiert werden. Während des Imports erfolgt die Anfrage, ob Gradle aktualisiert werden soll. Dies bitte **NICHT** durchführen, da ansonsten alles neu erstellt werden muss (Bootstrap, Bauen, Paketieren) \\ \\ --- //[[steffen.bornemann@gmx.de|Steffen Bornemann]] 08.11.2018// \\ {{tag>Mozilla Firefox DEBIAN APK Mercurial Gradle}}