<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>WSL on ousfifty's blog</title><link>https://blog.ous50.moe/en/categories/wsl/</link><description>Recent content in WSL on ousfifty's blog</description><generator>Hugo -- gohugo.io</generator><language>en-US</language><copyright>ousfifty 2020-</copyright><lastBuildDate>Thu, 25 Jan 2024 03:46:22 +0000</lastBuildDate><atom:link href="https://blog.ous50.moe/en/categories/wsl/index.xml" rel="self" type="application/rss+xml"/><item><title>Compiling Lineage OS on WSL2</title><link>https://blog.ous50.moe/en/p/compiling-lineage-os-on-wsl2/</link><pubDate>Thu, 25 Jan 2024 03:46:22 +0000</pubDate><guid>https://blog.ous50.moe/en/p/compiling-lineage-os-on-wsl2/</guid><description>&lt;h1 id="install-wsl-linux-and-compiling-dependency"&gt;&lt;a href="#install-wsl-linux-and-compiling-dependency" class="header-anchor"&gt;&lt;/a&gt;Install WSL Linux and Compiling Dependency
&lt;/h1&gt;&lt;p&gt;By default Ubuntu is installed:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-powershell" data-lang="powershell"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c"&gt;# Make downloads faster by not displaying progress bar:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;$ProgressPreference&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;SilentlyContinue&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c"&gt;# Using the URL you found above, download the appx package:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;Invoke-WebRequest&lt;/span&gt; &lt;span class="n"&gt;-Uri&lt;/span&gt; &lt;span class="n"&gt;https&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt;&lt;span class="p"&gt;//&lt;/span&gt;&lt;span class="n"&gt;aka&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ms&lt;/span&gt;&lt;span class="p"&gt;/&lt;/span&gt;&lt;span class="n"&gt;wslubuntu&lt;/span&gt; &lt;span class="n"&gt;-OutFile&lt;/span&gt; &lt;span class="n"&gt;Linux&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="py"&gt;appx&lt;/span&gt; &lt;span class="n"&gt;-UseBasicParsing&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c"&gt;# Make a backup and unpack:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;Copy-Item&lt;/span&gt; &lt;span class="p"&gt;.\&lt;/span&gt;&lt;span class="n"&gt;Linux&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="py"&gt;appx&lt;/span&gt; &lt;span class="p"&gt;.\&lt;/span&gt;&lt;span class="n"&gt;Linux&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="py"&gt;zip&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;Expand-Archive&lt;/span&gt; &lt;span class="p"&gt;.\&lt;/span&gt;&lt;span class="n"&gt;Linux&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="py"&gt;zip&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c"&gt;# Search for the installer:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;Get-Childitem&lt;/span&gt; &lt;span class="n"&gt;-Filter&lt;/span&gt; &lt;span class="p"&gt;*.&lt;/span&gt;&lt;span class="n"&gt;exe&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-shell" data-lang="shell"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Install compiling dependency for Ubuntu&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo apt install bc bison build-essential ccache curl flex g++-multilib gcc-multilib git gnupg gperf imagemagick lib32ncurses5-dev lib32readline-dev lib32z1-dev libelf-dev liblz4-tool libncurses5 libncurses5-dev libsdl1.2-dev libssl-dev libxml2 libxml2-utils lzop pngcrush rsync schedtool squashfs-tools xsltproc zip zlib1g-dev git
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="for-debian-bookworm"&gt;&lt;a href="#for-debian-bookworm" class="header-anchor"&gt;&lt;/a&gt;For Debian Bookworm:
&lt;/h2&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-shell" data-lang="shell"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo apt install bc bison build-essential ccache curl flex g++-multilib gcc-multilib git git-lfs gnupg gperf imagemagick lib32readline-dev lib32z1-dev libelf-dev liblz4-tool libsdl1.2-dev libssl-dev libxml2 libxml2-utils lzop pngcrush rsync schedtool squashfs-tools xsltproc zip zlib1g-dev libncurses5 
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h1 id="install-build-packages"&gt;&lt;a href="#install-build-packages" class="header-anchor"&gt;&lt;/a&gt;Install build packages:
&lt;/h1&gt;&lt;h2 id="repo"&gt;&lt;a href="#repo" class="header-anchor"&gt;&lt;/a&gt;Repo
&lt;/h2&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-shell" data-lang="shell"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;curl https://storage.googleapis.com/git-repo-downloads/repo &lt;span class="p"&gt;|&lt;/span&gt;sudo tee /usr/bin/repo
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo chmod a+x /usr/bin/repo
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="platform-tools"&gt;&lt;a href="#platform-tools" class="header-anchor"&gt;&lt;/a&gt;Platform tools
&lt;/h2&gt;&lt;p&gt;If you haven’t previously installed &lt;code&gt;adb&lt;/code&gt; and &lt;code&gt;fastboot&lt;/code&gt;, you can &lt;a class="link" href="https://dl.google.com/android/repository/platform-tools-latest-linux.zip" target="_blank" rel="noopener"
 &gt;download the original version from Google&lt;/a&gt; and extract it:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-shell" data-lang="shell"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;wget https://dl.google.com/android/repository/platform-tools-latest-linux.zip
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;wget https://dl.google.cn/android/repository/platform-tools-latest-linux.zip &lt;span class="c1"&gt;# For readers located in China&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;unzip platform-tools-latest-linux.zip -d ~/.local/bin
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now you have to add &lt;code&gt;adb&lt;/code&gt; and &lt;code&gt;fastboot&lt;/code&gt; to your PATH. Open &lt;code&gt;~/.profile&lt;/code&gt; and add the following:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-txt" data-lang="txt"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# add Android SDK platform tools to path
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;if [ -d &amp;#34;$HOME/.local/bin/platform-tools&amp;#34; ] ; then
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; PATH=&amp;#34;$HOME/.local/bin/platform-tools:$PATH&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;fi
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Run &lt;code&gt;source ~/.profile&lt;/code&gt; to update your environment, or simply restart the shell.&lt;/p&gt;
&lt;h2 id="python"&gt;&lt;a href="#python" class="header-anchor"&gt;&lt;/a&gt;Python
&lt;/h2&gt;&lt;p&gt;For Lineage OS 18+, &lt;code&gt;python3&lt;/code&gt; is required to build a package.&lt;/p&gt;
&lt;h1 id="configure-git"&gt;&lt;a href="#configure-git" class="header-anchor"&gt;&lt;/a&gt;Configure Git
&lt;/h1&gt;&lt;p&gt;You would have to set your name to sync android source code.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-shell" data-lang="shell"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;git config --global user.email &lt;span class="s2"&gt;&amp;#34;you@example.com&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;git config --global user.name &lt;span class="s2"&gt;&amp;#34;Your Name&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Some large files may be required to download when syncing source code, hence install &lt;code&gt;git-lfs&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-shell" data-lang="shell"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;git lfs intall
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h1 id="make-new-directory-to-pull-source-code"&gt;&lt;a href="#make-new-directory-to-pull-source-code" class="header-anchor"&gt;&lt;/a&gt;Make new directory to pull source code
&lt;/h1&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-shell" data-lang="shell"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mkdir lineage-21.0 &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;cd&lt;/span&gt; lineage-21.0
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h1 id="initialize-repo"&gt;&lt;a href="#initialize-repo" class="header-anchor"&gt;&lt;/a&gt;Initialize repo
&lt;/h1&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-shell" data-lang="shell"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;repo init -u https://github.com/LineageOS/android.git -b lineage-21.0 &lt;span class="c1"&gt;# Sync the whole repo with all commit log, takes a lot of spaces.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;repo init -u https://github.com/LineageOS/android.git -b lineage-21.0 --depth&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt; &lt;span class="c1"&gt;# Only pull the latest commit without commit logs, takes not much spaces&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h1 id="start-syncing-repo"&gt;&lt;a href="#start-syncing-repo" class="header-anchor"&gt;&lt;/a&gt;Start syncing repo
&lt;/h1&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-shell" data-lang="shell"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;repo sync -c -j&lt;span class="k"&gt;$(&lt;/span&gt;nproc --all&lt;span class="k"&gt;)&lt;/span&gt; --force-sync --no-clone-bundle --no-tags
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then follow &lt;a class="link" href="https://wiki.lineageos.org/devices/rtwo/build/variant2/#download-the-source-code" target="_blank" rel="noopener"
 &gt;Lineage OS building guide&lt;/a&gt;&amp;hellip;&lt;/p&gt;</description></item></channel></rss>