Compile CyanogenMod13 using Ubuntu 16.04 in 2022. 0

Preface

Change your daily FreeBSD for a variety of reasons to Arch Linux's recent attempt to make a SalifishOS adapter for your idle mobile phone, before verifying the availability of Android Base. This mobile phone has CM13.0 is officially supported, but compilation on Arch Linux is often wrong, so this article

Find problems

Error Found

Half compiled on Arch Linux, my research found that errors focused on three areas:

  • Python file syntax error
  • Script and Function Errors
  • C Compilation Error with LC

Retrospective Origin

The Python problem is solved so well that programmers at Google are not foolish enough to send out grammatical errors. Almost all of these Python files are failing because Python 3 is incompatible with Python 2

The same is true for function errors. The problem is that Bash and zsh syntax are only partially compatible. So you must enter bash before compiling

Script errors are a bit difficult because we don't know which script or Makefile is causing the problem. Therefore, error correction requires traversing the entire source tree to find errors. Fortunately, I only encountered Jack's mistake.

C compilation errors are the most wonderful. The solution is to set LC_ The ALL environment variable is C. Source is here

Failed Attempts

After four hours of frustration, trying to replace all pythons in shebang with python2 and convert the Python script using 2to3 will still result in errors. It is also not possible to replace Python executables with python2. There is a lot of software on my system written in Python3.

Ultimately, because the python2-protobuf package in AUR could not be installed, all the schemes compiled on Arch were rejected by me...

Correct solution

The problem seems to be on Arch Linux. The latest packages do not appear to be compatible with the compilation tool chain of a few years ago. So I installed a Ubuntu 16.04.

There are many articles in the tutorial Getting Source Trees, which are not written out here.

Install compilation dependencies

Reference resources: AOSP official document "Build compilation environment"

sudo apt-get install openjdk-8-jdk git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip maven
# The repository for Ubuntu 16.04 contains Repo tools, but they seem to be no longer available and need to be installed manually

Demote repo

The repo tool is written in Python, which makes extensive use of Python 3. 6 Add the new feature `F-string', while the latest version of Python in the software repository of Ubuntu 16.04 is 3.5, so we need to update Python manually.

Never uninstall your own Python blindly! Many Python-dependent packages will be deleted at the same time (I was reinstalling misloaded packages from the cd at the time I wrote this sentence)

Compile the latest version of Python 3. 10 OpenSSL1 is also required. Over 1.1, and the latest version in the Ubuntu 16.04 repository is 1.0.5, so we also need to manually update OpenSSL.

Above is Failed Attempts

To solve the above problem, switch repo to the old version.

Method: After repo init, enter. repo/repo directory, use git to switch to old submissions. I recommend the last submission for 2018

git checkout a26c49ead4d4b1fdd71d91ebf997079f7acefc99
# This submission was created in 2018-12 08:34:28 UTC

Prepare before starting compilation

(Be sure to configure in bash!)

Set up environment

To ensure that Python scripts execute python2 and avoid some strange problems, we need to enter the Python virtual environment.

sudo apt install virtualenv
virtualenv ~/cm-13 #You can change it at will, but it's recommended to use something like cm-13
. ~/cm-13/bin/activate #To correspond to the previous step

Then go to the root directory of the source tree and use envsetup.sh to set environment variables, introduce compiler functions

. build/envsetup.sh
export LC_ALL=C #Important!

Download Device Source Tree

Only works on officially supported devices!

breakfast nx510j #Please replace nx510j with your own device

For Vendor, the officially supported method for Lineage (and CM) is to extract Vendor from an original ROM phone that already has root. My phone has already brushed another OS, so it can't.

There are other ways, of course. For example, use TheMuppets to extract Vendor s. In the project root directory/. repo/local_manifests/roomservice.xml add

<project path="vendor/zte" remote="github" name="TheMuppets/proprietary_vendor_zte" revision="cm-13.0" />
<!-- Modify according to your own situation, enter if necessary TheMuppets Of GitHub Home page to view warehouse name and branches -->

Fix errors in Jack compilation server script

(ashamed, I always thought this Jack was a JACK audio server when I made a mistake)

The Jack and jack-admin scripts use cURLs to communicate with the Jack server, but use the wrong curl parameters, and Google is too lazy to care about things that have been discarded. We users have to fix them.

Edit prebuilts/sdk/tools/jack and change--no-proxy to--no proxy

- HTTP_CODE=$(curl --fail --silent --data @- --output "$JACK_EXIT" --write-out %{http_code} --connect-timeout 10 --no-proxy 127.0.0.1:$SERVER_PORT_SERVICE http://127.0.0.1:$SERVER_PORT_SERVICE/jack <<< "+ $JACK_OUT $JACK_ERR $JACK_CLI")
+ HTTP_CODE=$(curl --fail --silent --data @- --output "$JACK_EXIT" --write-out %{http_code} --connect-timeout 10 --noproxy 127.0.0.1:$SERVER_PORT_SERVICE http://127.0.0.1:$SERVER_PORT_SERVICE/jack <<< "+ $JACK_OUT $JACK_ERR $JACK_CLI")

Edit prebuilts/sdk/tools/jack-admin and change--no-proxy to--no proxy

- HTTP_CODE=$(curl --fail --silent --output $JACK_EXIT --write-out %{http_code} --connect-timeout 5 --no-proxy 127.0.0.1:$SERVER_PORT_ADMIN http://127.0.0.1:$SERVER_PORT_ADMIN/$CMD)
+ HTTP_CODE=$(curl --fail --silent --output $JACK_EXIT --write-out %{http_code} --connect-timeout 5 --noproxy 127.0.0.1:$SERVER_PORT_ADMIN http://127.0.0.1:$SERVER_PORT_ADMIN/$CMD)

Start Compiling

Personally, it is recommended that -j's parameters be compiled with four times the number of physical cores (most cpu, four times the physical core is two times the logical core), although if you are unsure, you can also set -j's parameters automatically with MKA (mka sets the number of logical cores).

# Specify manually
croot
make -j16 bacon
# mka
mka bacon

It's a success to see text like this. Compiling is time consuming if a computer like me is not very good.

Brush in device

cout
#A function that quickly switches to the compile exit where the compile-time environment has been set with lunch (a reference to lunch included in the breakfast function)
sudo $(which fastboot) flashall -t nx510j
#Don't know why platform-tool can't connect to mobile without root

Postnote

This trial compilation has wasted me two days in total and is not over yet. Tornado time is mainly due to Python problems such as modifying erroneous Python files, compiling Python, and OpenSSL. However, switching to Ubuntu is always much easier than compiling under Arch. This compilation made me realize that the application should be running in the current environment.

Keywords: Linux Android virtualenv

Added by powerofphp on Sun, 30 Jan 2022 13:24:44 +0200