美文网首页
Windows11 使用 repo

Windows11 使用 repo

作者: 敲代码的本愿 | 来源:发表于2023-08-22 16:21 被阅读0次

工具

  • Git
  • Python 3,需要 add path

安装

repo下载方式:

//`C:\Users\账户名\bin`
mkdir ~/bin
//添加path
PATH=~/bin:$PATH

//下载方式二选一
//1.谷歌
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
//2.清华:下载到当前目录,文件手动复制到`C:\Users\账户名\bin`下
curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o repo

//设置权限
chmod a+x ~/bin/repo

//替换`repo`文件中`Url`
旧:REPO_URL = 'https://gerrit.googlesource.com/git-repo'
新:REPO_URL = 'https://mirrors.tuna.tsinghua.edu.cn/git/git-repo'

初始化

repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-4.0.1_r1
repo sync

问题

1. PermissionError: [Errno 1]

...
File "H:\Work\.repo\repo\platform_utils_win32.py", line 172, in _create_symlink
    raise OSError(errno.EPERM, error_desc, link_name)
PermissionError: [Errno 1] 客户端没有所需的特权。: 'H:\\Work\\.repo\\manifests\\.git'

错误代码:platform_utils_win32.py

def _create_symlink(source, link_name, dwFlags):
    if not CreateSymbolicLinkW(
        link_name,
        source,
        dwFlags | SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE,
    ):
        # See https://github.com/golang/go/pull/24307/files#diff-b87bc12e4da2497308f9ef746086e4f0  # noqa: E501
        # "the unprivileged create flag is unsupported below Windows 10 (1703,
        # v10.0.14972). retry without it."
        if not CreateSymbolicLinkW(link_name, source, dwFlags):
            code = get_last_error()
            error_desc = FormatError(code).strip()
            if code == ERROR_PRIVILEGE_NOT_HELD:
                raise OSError(errno.EPERM, error_desc, link_name)
            _raise_winerror(
                code, 'Error creating symbolic link "{}"'.format(link_name)
            )

原因
标志 SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE 必须先在计算机上启用开发人员模式才能正常工作。

相关文章

网友评论

      本文标题:Windows11 使用 repo

      本文链接:https://www.haomeiwen.com/subject/wrjumdtx.html