OpenWrt之feeds.conf.default详解


文件内容

  1. src-git-full packages https://git.openwrt.org/feed/packages.git
  2. src-git-full luci https://git.openwrt.org/project/luci.git
  3. src-git-full routing https://git.openwrt.org/feed/routing.git
  4. src-git-full telephony https://git.openwrt.org/feed/telephony.git
  5. #src-git-full video https://github.com/openwrt/video.git
  6. #src-git-full targets https://github.com/openwrt/targets.git
  7. #src-git-full oldpackages http://git.openwrt.org/packages.git
  8. #src-link custom /usr/src/openwrt/custom-feed

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


命令解释

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

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

    1. my %update_method = (
    2. 'src-svn' => {
    3. 'init' => "svn checkout '%s' '%s'",
    4. 'update' => "svn update",
    5. 'controldir' => ".svn",
    6. 'revision' => "svn info | grep 'Revision' | cut -d ' ' -f 2 | tr -d '\n'"},
    7. 'src-cpy' => {
    8. 'init' => "cp -Rf '%s' '%s'",
    9. 'update' => "",
    10. 'revision' => "echo -n 'local'"},
    11. 'src-link' => {
    12. 'init' => "ln -s '%s' '%s'",
    13. 'update' => "",
    14. 'revision' => "echo -n 'local'"},
    15. 'src-dummy' => {
    16. 'init' => "true '%s' && mkdir '%s'",
    17. 'update' => "",
    18. 'revision' => "echo -n 'dummy'"},
    19. 'src-git' => {
    20. 'init' => "git clone --depth 1 '%s' '%s'",
    21. 'init_branch' => "git clone --depth 1 --branch '%s' '%s' '%s'",
    22. 'init_commit' => "git clone '%s' '%s' && cd '%s' && git checkout -b '%s' '%s' && cd -",
    23. 'update' => "git pull --ff-only",
    24. 'update_force' => "git pull --ff-only || (git reset --hard HEAD; git pull --ff-only; exit 1)",
    25. 'post_update' => "git submodule update --init --recursive",
    26. 'controldir' => ".git",
    27. 'revision' => "git rev-parse --short HEAD | tr -d '\n'"},
    28. 'src-git-full' => {
    29. 'init' => "git clone '%s' '%s'",
    30. 'init_branch' => "git clone --branch '%s' '%s' '%s'",
    31. 'init_commit' => "git clone '%s' '%s' && cd '%s' && git checkout -b '%s' '%s' && cd -",
    32. 'update' => "git pull --ff-only",
    33. 'update_force' => "git pull --ff-only || (git reset --hard HEAD; git pull --ff-only; exit 1)",
    34. 'post_update' => "git submodule update --init --recursive",
    35. 'controldir' => ".git",
    36. 'revision' => "git rev-parse --short HEAD | tr -d '\n'"},
    37. 'src-gitsvn' => {
    38. 'init' => "git svn clone -r HEAD '%s' '%s'",
    39. 'update' => "git svn rebase",
    40. 'controldir' => ".git",
    41. 'revision' => "git rev-parse --short HEAD | tr -d '\n'"},
    42. 'src-bzr' => {
    43. 'init' => "bzr checkout --lightweight '%s' '%s'",
    44. 'update' => "bzr update",
    45. 'controldir' => ".bzr"},
    46. 'src-hg' => {
    47. 'init' => "hg clone '%s' '%s'",
    48. 'update' => "hg pull --update",
    49. 'controldir' => ".hg"},
    50. 'src-darcs' => {
    51. 'init' => "darcs get '%s' '%s'",
    52. 'update' => "darcs pull -a",
    53. 'controldir' => "_darcs"},
    54. );
    55. # src-git: pull broken
    56. # src-cpy: broken if `basename $src` != $name

src-svn与src-gitsvn

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

src-git与src-git-full

  1. 'src-git' => {
  2. 'init' => "git clone --depth 1 '%s' '%s'",
  3. 'init_branch' => "git clone --depth 1 --branch '%s' '%s' '%s'",
  4. 'init_commit' => "git clone '%s' '%s' && cd '%s' && git checkout -b '%s' '%s' && cd -",
  5. 'update' => "git pull --ff-only",
  6. 'update_force' => "git pull --ff-only || (git reset --hard HEAD; git pull --ff-only; exit 1)",
  7. 'post_update' => "git submodule update --init --recursive",
  8. 'controldir' => ".git",
  9. 'revision' => "git rev-parse --short HEAD | tr -d '\n'"},
  10. 'src-git-full' => {
  11. 'init' => "git clone '%s' '%s'",
  12. 'init_branch' => "git clone --branch '%s' '%s' '%s'",
  13. 'init_commit' => "git clone '%s' '%s' && cd '%s' && git checkout -b '%s' '%s' && cd -",
  14. 'update' => "git pull --ff-only",
  15. 'update_force' => "git pull --ff-only || (git reset --hard HEAD; git pull --ff-only; exit 1)",
  16. 'post_update' => "git submodule update --init --recursive",
  17. 'controldir' => ".git",
  18. '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 , 不填则是拉取默认分支
  1. src-git NueXini_Packages https://github.com/NueXini/NueXini_Packages.git;main
  2. # 指定branch
  3. src-git NueXini_Packages https://github.com/NueXini/NueXini_Packages.git;v20220620
  4. # 指定tag
  5. src-git NueXini_Packages https://github.com/NueXini/NueXini_Packages.git^47e35dd380b88d5cffc267eabe7a125da86d194b
  6. # 指定commit

src-cpy与src-link

  1. 'src-cpy' => {
  2. 'init' => "cp -Rf '%s' '%s'",
  3. 'update' => "",
  4. 'revision' => "echo -n 'local'"},
  5. 'src-link' => {
  6. 'init' => "ln -s '%s' '%s'",
  7. 'update' => "",
  8. 'revision' => "echo -n 'local'"},

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

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

其他的src命令

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

feeds命令用法

  1. sub usage() {
  2. print <<EOF;
  3. Usage: $0 <command> [options]
  4. Commands:
  5. list [options]: List feeds, their content and revisions (if installed)
  6. Options:
  7. -n : List of feed names.
  8. -s : List of feed names and their URL.
  9. -r <feedname>: List packages of specified feed.
  10. -d <delimiter>: Use specified delimiter to distinguish rows (default: spaces)
  11. -f : List feeds in feeds.conf compatible format (when using -s).
  12. install [options] <package>: Install a package
  13. Options:
  14. -a : Install all packages from all feeds or from the specified feed using the -p option.
  15. -p <feedname>: Prefer this feed when installing packages.
  16. -d <y|m|n>: Set default for newly installed packages.
  17. -f : Install will be forced even if the package exists in core OpenWrt (override)
  18. search [options] <substring>: Search for a package
  19. Options:
  20. -r <feedname>: Only search in this feed
  21. uninstall -a|<package>: Uninstall a package
  22. Options:
  23. -a : Uninstalls all packages.
  24. update -a|<feedname(s)>: Update packages and lists of feeds in feeds.conf .
  25. Options:
  26. -a : Update all feeds listed within feeds.conf. Otherwise the specified feeds will be updated.
  27. -i : Recreate the index only. No feed update from repository is performed.
  28. -f : Force updating feeds even if there are changed, uncommitted files.
  29. clean: Remove downloaded/generated files.
  30. EOF
  31. exit(1);
  32. }
  33. my %commands = (
  34. 'list' => \&list,
  35. 'update' => \&update,
  36. 'install' => \&install,
  37. 'search' => \&search,
  38. 'uninstall' => \&uninstall,
  39. 'feed_config' => \&feed_config,
  40. 'clean' => sub {
  41. system("rm -rf ./feeds ./package/feeds ./target/linux/feeds");
  42. }
  43. );

branch与commit的分割符号

  1. sub update_feed_via($$$$$) {
  2. my $type = shift;
  3. my $name = shift;
  4. my $src = shift;
  5. my $relocate = shift;
  6. my $force = shift;
  7. my $m = $update_method{$type};
  8. my $localpath = "./feeds/$name";
  9. my $safepath = $localpath;
  10. $safepath =~ s/'/'\\''/;
  11. my ($base_branch, $branch) = split(/;/, $src, 2);
  12. my ($base_commit, $commit) = split(/\^/, $src, 2);
  13. if( $relocate || !$m->{'update'} || !-d "$localpath/$m->{'controldir'}" ) {
  14. system("rm -rf '$safepath'");
  15. if ($m->{'init_branch'} and $branch) {
  16. system(sprintf($m->{'init_branch'}, $branch, $base_branch, $safepath)) == 0 or return 1;
  17. } elsif ($m->{'init_commit'} and $commit) {
  18. system(sprintf($m->{'init_commit'}, $base_commit, $safepath, $safepath, $commit, $commit)) == 0 or return 1;
  19. } else {
  20. system(sprintf($m->{'init'}, $src, $safepath)) == 0 or return 1;
  21. }
  22. } elsif ($m->{'init_commit'} and $commit) {
  23. # in case git hash has been provided don't update the feed
  24. } else {
  25. my $update_cmd = $m->{'update'};
  26. if ($force && exists $m->{'update_force'}) {
  27. $update_cmd = $m->{'update_force'};
  28. }
  29. system("cd '$safepath'; $update_cmd") == 0 or return 1;
  30. }
  31. if ($m->{'post_update'}) {
  32. my $cmd = $m->{'post_update'};
  33. system("cd '$safepath'; $cmd") == 0 or return 1;
  34. }
  35. return 0;
  36. }
  • 透过以上代码, 主要能看见branchcommit的分割是不一样的
  • branch用的分割符号是;
  • commit用的分割符号是^
  1. my ($base_branch, $branch) = split(/;/, $src, 2);
  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. 使用 HDFS 协议访问对象存储服务

    背景介绍 原生对象存储服务的索引是扁平化的组织形式,在传统文件语义下的 List 和 Rename 操作性能表现上存在短板.腾讯云对象存储服务 COS 通过元数据加速功能,为上层计算业务提供了等效于 ...

  2. vue - Vue脚手架/TodoList案例

    今天做了一个案例,可以好好做做能够将之前的内容结合起来,最主要的是能对组件化编码流程有一个大概的清晰认知,这一套做下来,明天自己再做一遍复习一下,其实组件化流程倒是基本上没什么问题了,主要是很多vue ...

  3. 好客租房18-jsx阶段总结

    JSX 1jsx是react的核心内容 2jsx是在js代码中写HTML结构,是react中声明式的提现 3使用jsx配合嵌入的js表达式,条件渲染,列表渲染,可以描述任意ui结构 4推荐使用cals ...

  4. 安装Zabbix到CentOS(YUM)

    运行环境 系统版本:CentOS 7 软件版本:Zabbix-4.2.1 硬件要求:无 安装过程 1.安装YUM-Zabbix存储库 [root@localhost ~]# rpm -Uvh http ...

  5. 一文带你看懂Java中的Lock锁底层AQS到底是如何实现的

    前言 相信大家对Java中的Lock锁应该不会陌生,比如ReentrantLock,锁主要是用来解决解决多线程运行访问共享资源时的线程安全问题.那你是不是很好奇,这些Lock锁api是如何实现的呢?本 ...

  6. 【原创】渗透神器CoblatStrike实践(1)

    渗透神器CoblatStrike实践(1) 前言 正常的渗透测试: ​ 寻找漏洞,利用漏洞,拿到一定的权限 后渗透(CS为代表的): ​ 提升权限,内网渗透,权限维持 工具地址(非官方取到后门多,建议 ...

  7. 【摸鱼神器】UI库秒变LowCode工具——列表篇(一)设计与实现

    内容摘要: 需求分析 定义 interface 定义 json 文件 定义列表控件的 props 基于 el-table 封装,实现依赖 json 渲染 实现内置功能:选择行(单选.多选),格式化.锁 ...

  8. JavaScript中用画布canvans做贪吃蛇

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  9. React与Koa一起打造一个功能丰富的全栈个人博客(业务篇)

    前言 豆哥的个人博客又改版了,本版主要技术栈是前台用的React,后台用的Koa.博客改版的初衷是自己可以练练React(公司的项目部分要用React,我也没法啊,再说早晚得学).本文主要介绍博客的业 ...

  10. Java 将HTML转为Word

    本文以Java代码为例介绍如何实现将HTML文件转为Word文档(.docx..doc).在实际开发场景中可参考此方法来转换.下面详细方法及步骤. 在编辑代码前,请先在程序中导入Spire.Doc.j ...