Windows11使用WSL2下载Android12系统源码

admin 2023年7月21日01:21:26评论24 views字数 6849阅读22分49秒阅读模式

操作性环境:
Windows 11 64bit 系统。

1.安装wsl命令

特别说明,后续windows终端操作命令都需要在在管理员模式下打开 PowerShell 或 Windows 命令提示符,方法是右键单击并选择“以管理员身份运行”。

1.1 前期准备

安装 WSL2之前,须启用虚拟机平台可选功能:

PS C:WINDOWSsystem32> dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

部署映像服务和管理工具
版本: 10.0.22000.653

映像版本: 10.0.22000.2057

启用一个或多个功能
[==========================100.0%==========================]
操作成功完成。
PS C:WINDOWSsystem32>

需要先启用“适用于Linux 的 Windows 子系统”可选功能,然后才能在 Windows上安装 Linux系统,比如ubuntu系统:

PS C:WINDOWSsystem32> dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

部署映像服务和管理工具
版本: 10.0.22000.653

映像版本: 10.0.22000.2057

启用一个或多个功能
[==========================100.0%==========================]
操作成功完成。
PS C:WINDOWSsystem32>

以上操作完成之后,并重启计算机。

1.2 安装wsl

可以使用单个命令安装运行 WSL。在管理员模式下打开 PowerShell 或 Windows 命令提示符,输入 wsl --install 命令完成安装然后重启计算机。

Windows PowerShell
版权所有(C) Microsoft Corporation。保留所有权利。

安装最新的 PowerShell,了解新功能和改进!https://aka.ms/PSWindows

PS C:WINDOWSsystem32> wsl --install
正在安装: 虚拟机平台
已安装 虚拟机平台。
正在安装: 适用于 Linux 的 Windows 子系统
已安装 适用于 Linux 的 Windows 子系统。
正在安装: Ubuntu
已安装 Ubuntu。
请求的操作成功。直到重新启动系统前更改将不会生效。

1.3 安装Windows子系统ubuntu 20.04

查看支持安装的系统版本:

PS C:WINDOWSsystem32> wsl -l -o
以下是可安装的有效分发的列表。
使用 'wsl.exe --install <Distro>' 安装。

NAME FRIENDLY NAME
Ubuntu Ubuntu
Debian Debian GNU/Linux
kali-linux Kali Linux Rolling
Ubuntu-18.04 Ubuntu 18.04 LTS
Ubuntu-20.04 Ubuntu 20.04 LTS
Ubuntu-22.04 Ubuntu 22.04 LTS
OracleLinux_7_9 Oracle Linux 7.9
OracleLinux_8_7 Oracle Linux 8.7
OracleLinux_9_1 Oracle Linux 9.1
openSUSE-Leap-15.5 openSUSE Leap 15.5
SUSE-Linux-Enterprise-Server-15-SP4 SUSE Linux Enterprise Server 15 SP4
SUSE-Linux-Enterprise-Server-15-SP5 SUSE Linux Enterprise Server 15 SP5
openSUSE-Tumbleweed openSUSE Tumbleweed

安装指定操作系统版本Ubuntu-20.04:

PS C:WINDOWSsystem32> wsl --install -d  Ubuntu-20.04
正在安装: Ubuntu 20.04 LTS
已安装 Ubuntu 20.04 LTS。
正在启动 Ubuntu 20.04 LTS...

1.4 迁移wsl2安装的子系统到其他磁盘

默认使用wsl安装的子系统存储在电脑C盘,由于安卓系统源码比较大,至少考虑预留200G的空闲磁盘。如果你的C盘空间充足,可以不用考虑迁移。否则需要将子系统放到一个相对比较大的磁盘。可以安装如下步骤迁移wsl安装的ubuntu子系统。以下以迁移到F盘为例说明:

PS C:WINDOWSsystem32> wsl -l --all -v
  NAME            STATE           VERSION
* Ubuntu-20.04    Running         2
PS C:WINDOWSsystem32> wsl --shutdown
PS C:WINDOWSsystem32>

PS C:WINDOWSsystem32> wsl --export Ubuntu-20.04 F:wslwsl-ubuntu20.04.tar
正在导出,这可能需要几分钟时间。
操作成功完成。
PS C:WINDOWSsystem32>
PS C:WINDOWSsystem32> wsl --unregister Ubuntu-20.04
正在注销。
操作成功完成。
PS C:WINDOWSsystem32> wsl --import Ubuntu-20.04 F:wslwsl-ubuntu20.04 F:wslwsl-ubuntu20.04.tar --version 2
正在导入,这可能需要几分钟时间。
操作成功完成。
PS C:WINDOWSsystem32>

1.5 启动进入wsl子系统

执行如下命令启动安装的Ubuntu子系统:

PS C:WINDOWSsystem32> wsl -d Ubuntu-20.04
操作成功完成。

如果需要以root用户进入,执行如下命令:

PS C:WINDOWSsystem32> wsl -u root

1.6 Windows端访问子系统ubuntu文件夹

Windows端查看wsl系统方法:
在Windows文件栏输入"\wsl$",回车就可以看到Ubuntu系统目录。

1.7 可能遇到的启动问题

启动过程中可能出现错误:

Installing, this may take a few minutes…
WslRegisterDistribution failed with error: 0x80370102
Please enable the Virtual Machine Platform Windows feature and ensure virtualization is enabled in the BIOS.
For information please visit https://aka.ms/enablevirtualization

解决方法:

执行如下命令然后重启电脑。

wsl --set-default-version 2
DISM /Online /Enable-Feature /All /FeatureName:Microsoft-Hyper-V
bcdedit /set hypervisorlaunchtype auto

2.源码下载

依次参考执行如下命令完成源码下载:

PS C:WINDOWSsystem32> wsl -d Ubuntu-20.04
qiang@LAPTOP-GACS65HF:/mnt/c/WINDOWS/system32$ cd /home
qiang@LAPTOP-GACS65HF:/home$ ls
qiang
qiang@LAPTOP-GACS65HF:/home$ cd qiang
qiang@LAPTOP-GACS65HF:~$ ls
AospCode
qiang@LAPTOP-GACS65HF:~$ cd AospCode/
qiang@LAPTOP-GACS65HF:~/AospCode$ ls
qiang@LAPTOP-GACS65HF:~/AospCode$ mkdir Aosp12
mkdir: cannot create directory ‘Aosp12’: Permission denied
qiang@LAPTOP-GACS65HF:~/AospCode$ ls -la
total 8
drwxr-xr-x 2 root  root  4096 Jul 10 18:49 .
drwxr-xr-x 6 qiang qiang 4096 Jul 10 17:20 ..
qiang@LAPTOP-GACS65HF:~/AospCode$ cd ..
qiang@LAPTOP-GACS65HF:~$ ls
AospCode
qiang@LAPTOP-GACS65HF:~$ ls -la
total 40
drwxr-xr-x 6 qiang qiang 4096 Jul 10 17:20 .
drwxr-xr-x 3 root  root  4096 Jul 10 14:43 ..
-rw------- 1 qiang qiang  780 Jul 10 19:00 .bash_history
-rw-r--r-- 1 qiang qiang  220 Jul 10 14:43 .bash_logout
-rw-r--r-- 1 qiang qiang 3771 Jul 10 14:43 .bashrc
drwx------ 2 qiang qiang 4096 Jul 10 14:47 .cache
drwx------ 3 qiang qiang 4096 Jul 10 17:20 .config
drwxr-xr-x 2 qiang qiang 4096 Jul 10 14:47 .landscape
-rw-r--r-- 1 qiang qiang    0 Jul 10 14:47 .motd_shown
-rw-r--r-- 1 qiang qiang  807 Jul 10 14:43 .profile
-rw-r--r-- 1 qiang qiang    0 Jul 10 15:54 .sudo_as_admin_successful
drwxr-xr-x 2 root  root  4096 Jul 10 18:49 AospCode
qiang@LAPTOP-GACS65HF:~$ chmod 777 AospCode/
chmod: changing permissions of 'AospCode/': Operation not permitted
qiang@LAPTOP-GACS65HF:~$ chmod 777 AospCode
chmod: changing permissions of 'AospCode': Operation not permitted
qiang@LAPTOP-GACS65HF:~$ sudo chmod 777 AospCode
[sudo] password for qiang:
qiang@LAPTOP-GACS65HF:~$ ls
AospCode
qiang@LAPTOP-GACS65HF:~$ cd AospCode/
qiang@LAPTOP-GACS65HF:~/AospCode$ mkdir ~/bin
qiang@LAPTOP-GACS65HF:~/AospCode$ PATH=~/bin:$PATH
qiang@LAPTOP-GACS65HF:~/AospCode$ curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o ~/bin/repo
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 45797  100 45797    0     0  63784      0 --:--:-- --:--:-- --:--:-- 63695
qiang@LAPTOP-GACS65HF:~/AospCode$ chmod +x ~/bin/repo
qiang@LAPTOP-GACS65HF:~/AospCode$ ls -la
total 8
drwxrwxrwx 2 root  root  4096 Jul 10 21:39 .
drwxr-xr-x 7 qiang qiang 4096 Jul 10 21:39 ..
qiang@LAPTOP-GACS65HF:~/AospCode$ mkdir Aosp12
qiang@LAPTOP-GACS65HF:~/AospCode$ ls
Aosp12
qiang@LAPTOP-GACS65HF:~/AospCode$ cd Aosp12/
qiang@LAPTOP-GACS65HF:~/AospCode/Aosp12$ ls
qiang@LAPTOP-GACS65HF:~/AospCode/Aosp12$ git config --global user.email "[email protected]"
qiang@LAPTOP-GACS65HF:~/AospCode/Aosp12$ git config --global user.name "testtest"
qiang@LAPTOP-GACS65HF:~/AospCode/Aosp12$ git config --global url.https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/.insteadof https://android.googlesource.com
qiang@LAPTOP-GACS65HF:~/AospCode/Aosp12$ export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo'

qiang@LAPTOP-GACS65HF:~/AospCode/Aosp12$ repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-12.0.0_r3
Downloading Repo source from https://mirrors.tuna.tsinghua.edu.cn/git/git-repo
remote: Enumerating objects: 4545, done.
remote: Counting objects: 100% (4545/4545), done.
remote: Compressing objects: 100% (2187/2187), done.
remote: Total 8138 (delta 4034), reused 2358 (delta 2358), pack-reused 3593
Receiving objects: 100% (8138/8138), 3.89 MiB | 1.76 MiB/s, done.
Resolving deltas: 100% (5223/5223), done.
repo: Updating release signing keys to keyset ver 2.3

qiang@LAPTOP-GACS65HF:~/AospCode/Aosp12$ repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-12.0.0_r3
repo: reusing existing repo client checkout in /home/qiang/AospCode/Aosp12

Testing colorized output (for 'repo diff', 'repo status'):
black red green yellow blue magenta cyan white
bold dim ul reverse
Enable color display in this user account (y/N)? y

repo has been initialized in /home/qiang/AospCode/Aosp12

qiang@LAPTOP-GACS65HF:~/AospCode/Aosp12$ repo sync
remote: Enumerating objects: 6509, done.
remote: Counting objects: 100% (6509/6509), done.
remote: Compressing objects: 100% (1982/1982), done.
remote: Total 80441 (delta 5492), reused 4154 (delta 4129), pack-reused 73932
Receiving objects: 100% (80441/80441), 17.02 MiB | 2.41 MiB/s, done.
Resolving deltas: 100% (32744/32744), completed with 375 local objects.
Fetching: 0% (4/1040) 4:35 | 4 jobs | 4:35 platform/art @ art

Windows11使用WSL2下载Android12系统源码
Windows11使用WSL2下载Android12系统源码

原文始发于微信公众号(哆啦安全):Windows11使用WSL2下载Android12系统源码

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2023年7月21日01:21:26
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   Windows11使用WSL2下载Android12系统源码https://cn-sec.com/archives/1895262.html

发表评论

匿名网友 填写信息