OpenWrt之feeds.conf.default详解


文件内容

src-git-full packages https://git.openwrt.org/feed/packages.git
src-git-full luci https://git.openwrt.org/project/luci.git
src-git-full routing https://git.openwrt.org/feed/routing.git
src-git-full telephony https://git.openwrt.org/feed/telephony.git
#src-git-full video https://github.com/openwrt/video.git
#src-git-full targets https://github.com/openwrt/targets.git
#src-git-full oldpackages http://git.openwrt.org/packages.git
#src-link custom /usr/src/openwrt/custom-feed

OpenWrt的feeds.conf.default, 是添加一些应用和包的文件, 看过之后下面解析命令用法


命令解释

  • 先说# , 这个是注释用, 不会有人不知道吧

  • 这个文件主要是由scripts/feeds这个perl脚本控制着, 贴一个命令的定义

    my %update_method = (
    'src-svn' => {
    'init' => "svn checkout '%s' '%s'",
    'update' => "svn update",
    'controldir' => ".svn",
    'revision' => "svn info | grep 'Revision' | cut -d ' ' -f 2 | tr -d '\n'"},
    'src-cpy' => {
    'init' => "cp -Rf '%s' '%s'",
    'update' => "",
    'revision' => "echo -n 'local'"},
    'src-link' => {
    'init' => "ln -s '%s' '%s'",
    'update' => "",
    'revision' => "echo -n 'local'"},
    'src-dummy' => {
    'init' => "true '%s' && mkdir '%s'",
    'update' => "",
    'revision' => "echo -n 'dummy'"},
    'src-git' => {
    'init' => "git clone --depth 1 '%s' '%s'",
    'init_branch' => "git clone --depth 1 --branch '%s' '%s' '%s'",
    'init_commit' => "git clone '%s' '%s' && cd '%s' && git checkout -b '%s' '%s' && cd -",
    'update' => "git pull --ff-only",
    'update_force' => "git pull --ff-only || (git reset --hard HEAD; git pull --ff-only; exit 1)",
    'post_update' => "git submodule update --init --recursive",
    'controldir' => ".git",
    'revision' => "git rev-parse --short HEAD | tr -d '\n'"},
    'src-git-full' => {
    'init' => "git clone '%s' '%s'",
    'init_branch' => "git clone --branch '%s' '%s' '%s'",
    'init_commit' => "git clone '%s' '%s' && cd '%s' && git checkout -b '%s' '%s' && cd -",
    'update' => "git pull --ff-only",
    'update_force' => "git pull --ff-only || (git reset --hard HEAD; git pull --ff-only; exit 1)",
    'post_update' => "git submodule update --init --recursive",
    'controldir' => ".git",
    'revision' => "git rev-parse --short HEAD | tr -d '\n'"},
    'src-gitsvn' => {
    'init' => "git svn clone -r HEAD '%s' '%s'",
    'update' => "git svn rebase",
    'controldir' => ".git",
    'revision' => "git rev-parse --short HEAD | tr -d '\n'"},
    'src-bzr' => {
    'init' => "bzr checkout --lightweight '%s' '%s'",
    'update' => "bzr update",
    'controldir' => ".bzr"},
    'src-hg' => {
    'init' => "hg clone '%s' '%s'",
    'update' => "hg pull --update",
    'controldir' => ".hg"},
    'src-darcs' => {
    'init' => "darcs get '%s' '%s'",
    'update' => "darcs pull -a",
    'controldir' => "_darcs"},
    ); # src-git: pull broken
    # src-cpy: broken if `basename $src` != $name

src-svn与src-gitsvn

'src-svn' => {
'init' => "svn checkout '%s' '%s'",
'update' => "svn update",
'controldir' => ".svn",
'revision' => "svn info | grep 'Revision' | cut -d ' ' -f 2 | tr -d '\n'"},
'src-gitsvn' => {
'init' => "git svn clone -r HEAD '%s' '%s'",
'update' => "git svn rebase",
'controldir' => ".git",
'revision' => "git rev-parse --short HEAD | tr -d '\n'"},
  • 用法:
src-svn NueXini_Packages https://github.com/NueXini/NueXini_Packages/trunk/
# 拉取默认分支
src-svn NueXini_Packages https://github.com/NueXini/NueXini_Packages/branches/v20220620
# 拉取指定分支
src-svn NueXini_Packages https://github.com/NueXini/NueXini_Packages/trunk/luci-app-disableipv6/
# 拉取指定文件夹
src-gitsvn NueXini_Packages https://github.com/NueXini/NueXini_Packages.git

src-git与src-git-full

'src-git' => {
'init' => "git clone --depth 1 '%s' '%s'",
'init_branch' => "git clone --depth 1 --branch '%s' '%s' '%s'",
'init_commit' => "git clone '%s' '%s' && cd '%s' && git checkout -b '%s' '%s' && cd -",
'update' => "git pull --ff-only",
'update_force' => "git pull --ff-only || (git reset --hard HEAD; git pull --ff-only; exit 1)",
'post_update' => "git submodule update --init --recursive",
'controldir' => ".git",
'revision' => "git rev-parse --short HEAD | tr -d '\n'"}, 'src-git-full' => {
'init' => "git clone '%s' '%s'",
'init_branch' => "git clone --branch '%s' '%s' '%s'",
'init_commit' => "git clone '%s' '%s' && cd '%s' && git checkout -b '%s' '%s' && cd -",
'update' => "git pull --ff-only",
'update_force' => "git pull --ff-only || (git reset --hard HEAD; git pull --ff-only; exit 1)",
'post_update' => "git submodule update --init --recursive",
'controldir' => ".git",
'revision' => "git rev-parse --short HEAD | tr -d '\n'"},
  • 这两者共同操作是git clone区别是clone的深度不一样, src-git-full是全clone, 而src-git的深度为--depth 1
  • 用法: src-git-full / src-git-full 保存的文件夹名 仓库地址
  • 注: 后面可指定 分支, tag, commit , 不填则是拉取默认分支
src-git NueXini_Packages https://github.com/NueXini/NueXini_Packages.git;main
# 指定branch
src-git NueXini_Packages https://github.com/NueXini/NueXini_Packages.git;v20220620
# 指定tag
src-git NueXini_Packages https://github.com/NueXini/NueXini_Packages.git^47e35dd380b88d5cffc267eabe7a125da86d194b
# 指定commit

src-cpy与src-link

'src-cpy' => {
'init' => "cp -Rf '%s' '%s'",
'update' => "",
'revision' => "echo -n 'local'"},
'src-link' => {
'init' => "ln -s '%s' '%s'",
'update' => "",
'revision' => "echo -n 'local'"},

这两个命令的唯一区别是src-cpy会复制一份源到feeds目录, src-link则是ln -s创建一个软链接, 我个人是比较倾向src-link的, 这样可以修改源码能及时响应.

  • 用法: src-cpy / src-link 保存的文件名 源目录
src-link NueXini_Packages package/NueXini_Packages
# 拉取package目录下的NueXini_Packages目录

其他的src命令

  • bzr, hg, darcs 一些其他的分布式版本控制系统, 基本很少用到, 可以自行参考命令解释了解使用方法

feeds命令用法

sub usage() {
print <<EOF;
Usage: $0 <command> [options]
Commands:
list [options]: List feeds, their content and revisions (if installed)
Options:
-n : List of feed names.
-s : List of feed names and their URL.
-r <feedname>: List packages of specified feed.
-d <delimiter>: Use specified delimiter to distinguish rows (default: spaces)
-f : List feeds in feeds.conf compatible format (when using -s).
install [options] <package>: Install a package
Options:
-a : Install all packages from all feeds or from the specified feed using the -p option.
-p <feedname>: Prefer this feed when installing packages.
-d <y|m|n>: Set default for newly installed packages.
-f : Install will be forced even if the package exists in core OpenWrt (override)
search [options] <substring>: Search for a package
Options:
-r <feedname>: Only search in this feed
uninstall -a|<package>: Uninstall a package
Options:
-a : Uninstalls all packages.
update -a|<feedname(s)>: Update packages and lists of feeds in feeds.conf .
Options:
-a : Update all feeds listed within feeds.conf. Otherwise the specified feeds will be updated.
-i : Recreate the index only. No feed update from repository is performed.
-f : Force updating feeds even if there are changed, uncommitted files.
clean: Remove downloaded/generated files.
EOF
exit(1);
} my %commands = (
'list' => \&list,
'update' => \&update,
'install' => \&install,
'search' => \&search,
'uninstall' => \&uninstall,
'feed_config' => \&feed_config,
'clean' => sub {
system("rm -rf ./feeds ./package/feeds ./target/linux/feeds");
}
);

branch与commit的分割符号

sub update_feed_via($$$$$) {
my $type = shift;
my $name = shift;
my $src = shift;
my $relocate = shift;
my $force = shift; my $m = $update_method{$type};
my $localpath = "./feeds/$name";
my $safepath = $localpath;
$safepath =~ s/'/'\\''/;
my ($base_branch, $branch) = split(/;/, $src, 2);
my ($base_commit, $commit) = split(/\^/, $src, 2); if( $relocate || !$m->{'update'} || !-d "$localpath/$m->{'controldir'}" ) {
system("rm -rf '$safepath'");
if ($m->{'init_branch'} and $branch) {
system(sprintf($m->{'init_branch'}, $branch, $base_branch, $safepath)) == 0 or return 1;
} elsif ($m->{'init_commit'} and $commit) {
system(sprintf($m->{'init_commit'}, $base_commit, $safepath, $safepath, $commit, $commit)) == 0 or return 1;
} else {
system(sprintf($m->{'init'}, $src, $safepath)) == 0 or return 1;
}
} elsif ($m->{'init_commit'} and $commit) {
# in case git hash has been provided don't update the feed
} else {
my $update_cmd = $m->{'update'};
if ($force && exists $m->{'update_force'}) {
$update_cmd = $m->{'update_force'};
}
system("cd '$safepath'; $update_cmd") == 0 or return 1;
}
if ($m->{'post_update'}) {
my $cmd = $m->{'post_update'};
system("cd '$safepath'; $cmd") == 0 or return 1;
} return 0;
}
  • 透过以上代码, 主要能看见branchcommit的分割是不一样的
  • branch用的分割符号是;
  • commit用的分割符号是^
my ($base_branch, $branch) = split(/;/, $src, 2);
my ($base_commit, $commit) = split(/\^/, $src, 2);

branch与tag的区别

  • tag就是给commit的hash校验和取的一个名字,比较直观,方便记忆和使用

  • tag就像是一个里程碑一个标志一个点,branch是一个新的征程一条线;tag是静态的,branch要向前走;

  • tag 对应某次 commit, 是一个点,是不可移动的。

    branch 对应一系列 commit,是很多点连成的一根线,有一个HEAD 指针,是可以依靠 HEAD 指针移动的。

    所以,两者的区别决定了使用方式,改动代码用 branch ,不改动只查看用 tag。

  • 参考https://git-scm.com/book/zh/v2/Git-%E5%9F%BA%E7%A1%80-%E6%89%93%E6%A0%87%E7%AD%BE


Enjoy it ~

OpenWrt之feeds.conf.default详解的更多相关文章

  1. Redis 配置文件 redis.conf 项目详解

    Redis.conf 配置文件详解 # [Redis](http://yijiebuyi.com/category/redis.html) 配置文件 # 当配置中需要配置内存大小时,可以使用 1k, ...

  2. webpack.dev.conf.js详解

    转载自:https://www.cnblogs.com/ye-hcj/p/7087205.html webpack.dev.conf.js详解 //引入当前目录下的utils.js文件模块var ut ...

  3. redis.windows.conf配置详解

    redis.windows.conf配置详解 转自:https://www.cnblogs.com/kreo/p/4423362.html # redis 配置文件示例 # 当你需要为某个配置项指定内 ...

  4. Linux-apache httd.conf文件详解

    Linux-apache httd.conf文件详解 # This is the main Apache server configuration file. It contains the # co ...

  5. Nginx配置文件nginx.conf中文详解(转)

    ######Nginx配置文件nginx.conf中文详解##### #定义Nginx运行的用户和用户组 user www www; #nginx进程数,建议设置为等于CPU总核心数. worker_ ...

  6. apache 虚拟主机详细配置:http.conf配置详解

    apache 虚拟主机详细配置:http.conf配置详解 Apache的配置文件http.conf参数含义详解 Apache的配置由httpd.conf文件配置,因此下面的配置指令都是在httpd. ...

  7. VSFTPD全攻略(/etc/vsftpd/vsftpd.conf文件详解)

    /etc/vsftpd/vsftpd.conf文件详解,分好类,方便大家查找与学习 #################匿名权限控制############### anonymous_enable=YE ...

  8. Nginx配置文件nginx.conf中文详解【转】

    PS:Nginx使用有两三年了,现在经常碰到有新用户问一些很基本的问题,我也没时间一一回答,今天下午花了点时间,结合自己的使用经验,把Nginx的主要配置参数说明分享一下,也参考了一些网络的内容,这篇 ...

  9. nginx.conf配置详解

    ######Nginx配置文件nginx.conf中文详解##### #定义Nginx运行的用户和用户组 user www www; #nginx进程数,建议设置为等于CPU总核心数. worker_ ...

随机推荐

  1. MyCat 使用中问题记录

    MyCat问题记录: Unknown charsetIndex:255 异常消息: jvm 1 | 2022-04-27 14:09:13,337 [WARN ][$_NIOREACTOR-13-RW ...

  2. NLP教程(6) - 神经机器翻译、seq2seq与注意力机制

    作者:韩信子@ShowMeAI 教程地址:http://www.showmeai.tech/tutorials/36 本文地址:http://www.showmeai.tech/article-det ...

  3. MySQL字段约束条件、字段类型、存储引擎、配置文件

    字符编码与配置文件 # 查看MySQL默认字符编码 \s ''' 如果是5.X系列 显示的编码有很多种 Latin1 gbk 如果是8.X系列 显示的统一是utf8mb4 utf8mb4是utf8优化 ...

  4. 探索ABP基础架构

    为了了解应用程序是如何配置和初始化,本文将探讨ASP.NET Core和ABP框架最基本的构建模块.我们将从 ASP.NET Core 的 Startup类开始了解为什么我们需要模块化系统,以及 AB ...

  5. 虚拟机:ESX

    VMware ESXi 与ESX 产品之比较   VMware vSphere 5.0 以后版本,所有底层虚拟化产品都改为ESXi产品,本文主要比较了ESXi与ESX的各自特点,以便对大家是否要把现有 ...

  6. 好客租房29-从jsx中抽离事件处理程序

    从jsx中抽离过多js逻辑代码 会显得非常混乱 推荐:将逻辑抽离到单独的方法中 保证jsx结构清晰 //导入react     import React from 'react'           ...

  7. 使用虚拟机在3台centos7系统安装docker和k8s集群

    一.安装docker 环境:准备3台centos7系统,都安装上docker环境,具体安装步骤和流程如下 参考: https://docs.docker.com/install/linux/docke ...

  8. IDEA windows版本快捷键

    使用本快捷键前,可以在idea使用下面方法确认版本! Ctrl 快捷键 介绍 Ctrl + F 在当前文件进行文本查找 (必备)Ctrl + R 在当前文件进行文本替换 (必备) Ctrl + Z 撤 ...

  9. CSP-J游记

    祝大家 CSP-J/CSP-S 稳过第一轮 ~(- ∨ -)~ ~~ 建议扩大110%食用 ~~ 中秋快乐鸭(希望大家不会收到损友送的砖头月饼 : − ) :-) :−)) 咳咳,昨天是我们可爱初赛来 ...

  10. pycharm相关介绍

    一.settings设置   1.搜font 设置字体 2.Keymap------快捷键 二.常用快捷键 1.Ctrl + Enter:在下方新建行但不移动光标: 2.Shift + Enter:在 ...