Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revisionBoth sides next revision
zh:docs:guide-user:additional-software:imagebuilder [2018/10/14 10:36] – [配置安装包库] lujimmyzh:docs:guide-user:additional-software:imagebuilder [2024/11/30 14:58] – [详细帮助] starsfall
Line 1: Line 1:
-====== 使用镜像生成工具 (Image Builder====== +====== 使用Image Builder ====== 
-Image Builder(以前称为Image Generator)是一个预编译环境,适用在不从源代码编译的情况创建自定义镜像文件。 +另请参阅: 
-它下载预编译的软件包并集成在一个可擦写的镜像中。+[[docs:guide-developer:imagebuilder_frontends|Image Builder frontends]], 
 +[[docs:guide-developer:start#using_the_toolchain|Using the toolchain]], 
 +[[docs:guide-developer:toolchain:beginners-build-guide|Quick image building guide]]
  
-适用于以下场景:  +Image Builder (以前称为 Image Generator) 是一个预编译环境, 适用于创建自定义映像, 而无需从源代码编译它们. 
-  * 您想在有限闪存中放入更多软件包。 +它下载预编译的软件包并将它们集成到单个可闪存映像中. 
-  * 跟进用于开发的“快照版”。 + 
-  * 您的设备有32MB或更内存,以至于opkg无法很好的工作 +以下情况下, 这样做很有用: 
-  * 想要固件刷入大量备。+  * 您想在较小的闪存中容纳更多的封装 
 +  * 关注开发快照 
 +  * 您的设备有 32MB 或更的 RAM 并且 opkg 无法正常工作 
 +  * 批量刷新几十个设备,你需一个特定的映像置 
 + 
 +<WRAP important> 
 +Image Builder 映像与官方映像不同, 因为它们获取预先生成的包.  
 +在进行 recent/important 的更改时, 这些包的传播可能会有一些延迟.最好检查包是否在 imagebuilder/change 日期之后上载. 
 +</WRAP>
  
-实现相同目标的替代指南有: 
-[[docs:guide-user:additional-software:imagebuilder|使用Image Builder]], 
-[[docs:guide-user:additional-software:beginners-build-guide|构建自己固件的入门指南]]。 
 ===== 先决条件 ===== ===== 先决条件 =====
-:!:  Image Builder仅可运行64位Linux环境下,您甚至可以32位Windows系统的虚拟机(如virtualbox)中运行64位的Linux。\\ +<WRAP important> 
-:!: Image Builder具有构建系统的一些相同先决条件[[docs:guide-developer:build-system:install-buildsystem|Build system – Installation]]。\\+  Image Builder 仅在 64 位 Linux 中运行. 但您以在 PC 或 VM(例如 VirtualBox)中运行 64 位 Linux甚至可以从 32 位 Windows 运行. 
 +  Image Builder 具有与 [[docs:guide-developer:toolchain:install-buildsystem|Build system]] 类似的先决条件. 
 +</WRAP>
  
-最常见发行版中的依赖关系示例: +最常见发行版中的示例依赖项:
-<WRAP>Debian/Ubuntu<code>apt-get install subversion build-essential libncurses5-dev zlib1g-dev gawk git ccache gettext libssl-dev xsltproc wget unzip python</code></WRAP>+
  
-<WRAP>CentOS/RHEL<code>yum install subversion git gawk gettext ncurses-devel zlib-devel openssl-devel libxslt wget +==== Arch ==== 
-yum group install "Development Tools"</code></WRAP>+<code bash> 
 +sudo pacman -S --needed base-devel ncurses zlib gawk git gettext \ 
 +openssl libxslt wget unzip python python-distutils-extra 
 +</code>
  
-<WRAP>Fedora 27+<code>dnf install @c-development @development-tools @development-libs zlib-static which</code></WRAP> +==== Fedora ==== 
-===== 获取镜像生成工具 ===== +<code bash> 
-您可以下载包含**Image Builder**的压缩文件,它通常在您找到设备固件映像文件的同一下载页面中。 +sudo dnf install git gawk gettext ncurses-devel zlib-devel \ 
-例如,您在以下页面可以下载**ar71xx/generic**设备的所有固件映像文件: +openssl-devel libxslt wget which @c-development @development-tools 
-https://downloads.lede-project.org/snapshots/targets/ar71xx/generic/。在此页面,您也可以看到包含Image Builder的名为**lede-imagebuilder-ar71xx-generic.Linux-x86_64.tar.xz**的压缩文件。+@development-libs zlib-static which python3 perl 
 +</code>
  
-当然,**Image Builder**也可以由构建系统生成,因为需要创建映像文件。如果启用了''构建OpenWrt Image Builder''选项,则**Image Builder**将在您找到固件映像的同一文件夹(''source/bin/targets/xxx'')中生成,您可以使用它从编译期间获得的软件包创建更多镜像文件。+==== Debian Ubuntu Mint ==== 
 +<code bash> 
 +sudo apt install build-essential libncurses-dev zlib1g-dev gawk git \ 
 +gettext libssl-dev xsltproc rsync wget unzip python3 python3-distutils 
 +</code>
  
-===== 配置软件包存储库 ===== +==== WSL ==== 
-您从OpenWrt页面下载的''Image Builder''已配置为不从官存储库下载任何非默认软件包。 +法未得到官方支持
-软件包源在解压目录中的''repositories.conf''文件中配置。源约定以//opkg//原生格式配置。这可以是官方软件包存储库,也可以是自定义生成的存储库+
  
-**openwrt-imagebuilder-18.06.0-rc2-ramips-mt7621.Linux-x86_64.tar.xz**中''repositories.conf''的内容示例:+但它有效。 [[docs:guide-developer:toolchain:wsl|Build system setup WSL]]
  
-<code>## Place your custom repositories here, they must match the architecture and version. +建议使用 VirtualBox 配合 Debian 或 DietPi(Debian) 使用,以减少资源和配置。
-# src/gz %n http://downloads.openwrt.org/releases/18.06.0-rc2 +
-# src custom file:///usr/src/openwrt/bin/ramips/packages+
  
-## Remote package repositories +===== 获取 Image Builder ===== 
-src/gz openwrt_core http://downloads.openwrt.org/releases/18.06.0-rc2/targets/ramips/mt7621/packages +您可以下载包含 **Image Builder** 的存档, 它通常位于您找到设备固件映像的同一下载页面中.
-src/gz openwrt_base http://downloads.openwrt.org/releases/18.06.0-rc2/packages/mipsel_24kc/base +
-src/gz openwrt_luci http://downloads.openwrt.org/releases/18.06.0-rc2/packages/mipsel_24kc/luci +
-src/gz openwrt_packages http://downloads.openwrt.org/releases/18.06.0-rc2/packages/mipsel_24kc/packages +
-src/gz openwrt_routing http://downloads.openwrt.org/releases/18.06.0-rc2/packages/mipsel_24kc/routing +
-src/gz openwrt_telephony http://downloads.openwrt.org/releases/18.06.0-rc2/packages/mipsel_24kc/telephony+
  
-## This is the local package repositorydo not remove! +例如这是您可以下载 **ath79/generic** 设备的所有固件映像的页面: 
-src imagebuilder file:packages+[[https://downloads.openwrt.org/snapshots/targets/ath79/generic/]] 
 +您会找到一个 **openwrt-imagebuilder-ath79-generic.Linux-x86_64.tar.xz** 包含映像生成器的存档. 
 +此外, 它始终由构建系统创建, 因为创建映像文件需要它. 
 +如果启用了 "**Build the OpenWrt Image Builder**" 选项, 则映像构建器将在您找到固件映像的文件夹中生成 (''source/bin/targets/xxx'') , 您可以使用它从编译期间获得的包中创建更多映像. 
 + 
 +===== 用法 ===== 
 +<WRAP important> 
 +所有操作都应使用非 root 用户帐户执行. 
 +</WRAP> 
 + 
 +解压存档并更改工作目录: 
 + 
 +<code bash> 
 +tar -J -x -f openwrt-imagebuilder-*.tar.xz 
 +cd openwrt-imagebuilder-*/
 </code> </code>
  
-您从源代码编译而来的''Image Builder''的''repositories.conf''缺少"Remote package repositories"链接.+可以使用以下变量自定义映像构建:
  
-如果您添加自定义本地存储库,请复制以下码: <code>src custom file:///usr/src/lede/bin/ramips/packages</code>  +^ 变量 ^ 描述 ^ 
-将其修改为指向您拥有软件包和软件包列表的本地文件夹。 +| ''PROFILE'' | 指定构建的目标映像 | 
-如果您有在线自定义存储库,请复制以下代码并修改:<code>src/gz reboot http://downloads.lede-project.org/snapshots</code> line instead.+| ''PACKAGES'' | 要嵌入映像的软件包列表 | 
 +| ''FILES'' | 包含自定义文件的目录 | 
 +| ''BIN_DIR'' | 映像的替输出目录 | 
 +| ''EXTRA_IMAGE_NAME''将其添加到输出映像文件名 (sanitized) | 
 +| ''DISABLED_SERVICES'' | 要禁用的 ''/etc/init.d'' 中服务的名称, 例如用于 dnsmasq 的 ''dhcp'' |
  
 +运行 ''make help'' 以获取 [[docs:guide-user:additional-software:imagebuilder#detailed_help|详细帮助]].
  
-===== Usage ===== +==== 选择配置文件 ==== 
-**make image** command will create a default image for a default device with default (essential) packages. In most cases it's not what you wanted.+该 ''PROFILE'变量指定要构建的目标映像.
  
-To change this not-so-useful default behavior you can use three variables passed as arguments:+<code bash> 
 +PROFILE="profile-name" 
 +</code>
  
-  * //''PROFILE''// specifies the target image to build +运行 ''make info'' 以获取 [[docs:guide-user:additional-software:imagebuilder#available_profiles|可用配置文件]]的列表.
-  * //''PACKAGES''// - a list of packages to embed into the image +
-  * //''FILES''// directory with custom files to include+
  
-Example syntax: +==== 选择插件 ==== 
-<code>$ make image PROFILE=XXX PACKAGES="pkg1 pkg2 pkg3 -pkg4 -pkg5 -pkg6" FILES=files/</code>+该 ''PACKAGES'' 变量允许在固件映像中含 和安装/或排除 插件. 
 +默认情况下( PACKAGES 变量值为空), Image Builder 将创建一个具有特定于设备的内核和驱动程序, uci, ssh, switch, 防火墙, ppp 及 ipv6 支持的最小映像.
  
-See the sections below for a more in-depth explanation. After the make command is finished, the generated images are stored in the bin///device-architecture/directory, just like if you were compiling them.+<code bash> 
 +PACKAGES="pkg1 pkg2 pkg3 -pkg4 -pkg5 -pkg6" 
 +</code>
  
-here the output of **make help**:\\ +上面的例子将安装 pkg1pkg2pkg3 插件, 并删除 pkg4, pkg5, pkg6 插件, 特别注意要删除插件前的 "-字符.
-  Available Commands: +
-        help:   This help text +
-        info:   Show a list of available target profiles +
-        clean:  Remove images and temporary build files +
-        image:  Build an image (see below for more information). +
-   +
-  Building images: +
-        By default 'make image' will create an image with the default +
-        target profile and package set. You can use the following parameters +
-        to change that: +
-   +
-        make image PROFILE="<profilename>" # override the default target profile +
-        make image PACKAGES="<pkg1> [<pkg2> [<pkg3> ...]]# include extra packages +
-        make image FILES="<path>" # include extra files from <path> +
-        make image BIN_DIR="<path>" # alternative output directory for the images +
-        make image EXTRA_IMAGE_NAME="<string>" # Add this to the output image filename (sanitized)+
  
-The built image will be found under the subdirectory ''./bin/targets/<target>/generic'' +您无需在此列表中列出您需要的插件的所有依赖项,Image Builder 使用 ''opkg'' 自动解析插件的依赖项并安装其他所需的软件包。
-==== PROFILE Variable ===== +
-Syntax:<code>$ make image PROFILE=NAME_OF_PROFILE</code>+
  
-=== Pre-defined Profiles === +可以使用以下命令获取设备上当前安装的插件列表: 
-Run ''make info'' to obtain a list of defined profiles+ 
-Example output from ''make info'' is listed below.+<code bash> 
 +echo $(opkg list-installed | sed -e "s/\s.*$//"
 +</code> 
 + 
 +<WRAP important> 
 +许多设备的存储容量有限,并且不能保证构建系统会检测到何时添加了过多的软件包以至于超出设备存储空间。如果安装过多软件包,可能会导致设备无法启动。如果有疑问,不要过度添加。以设备上安装成功的内容为指导,或者先创建一个最小的镜像,安装到设备上并首先测试要添加的内容。考虑删除不必要的软件包以 [[docs:guide-user:additional-software:saving_space|节省固件空间]]. 
 +</WRAP> 
 + 
 +此外,诸如 ''libubus20191227'' 或类似的 ABI 版本控制包可能会导致映像生成器出现问题. 
 +当这些作为插件提供时, 您可能会遇到编译错误. 
 +为避免出现问题, 您应该从映像生成器中省略它们, 并通过插件依赖项安装正确的版本 . 
 +该 ''%%--strip-abi%%'' 参数可用于导出规范化的插件列表. 
 + 
 +==== 添加额外插件 ==== 
 + 
 +如果有你喜欢使用的插件或 ''ipk'' 文件,创建一个 ''packages'' 目录(如果不存在,如果存在该目录则不需要创建),并将你的插件或 ''ipk'' 文件放在这个目录中。 
 + 
 +==== 自定义文件夹 ==== 
 +该 ''FILES'' 变量允许将自定义配置文件包含在使用 Image Builder 构建的映像中. 
 +如果您需要在刷机前更改默认网络配置, 或者如果您正在准备大量刷机许多设备的映像, 这将特别有用. 
 + 
 +<code bash> 
 +FILES="files" 
 +</code> 
 + 
 +该 ''files'' 目录应放置在发出 make 命令的 Image Builder 根目录中,否则指定绝对/完整路径. 
 + 
 +强烈建议使用 [[docs:guide-developer:uci-defaults|uci-defaults]] 仅增量集成所需的自定义. 
 +这有助于最大限度地减少与自动生成的设置的冲突,这些设置可以在版本之间更改. 
 + 
 +参考: [[:docs:guide-user:additional-software:imagebuilder#restricting_root_access|uci-default_example]] 
 + 
 +==== Building image ==== 
 +选择适当的配置文件, 插件和自定义文件夹, 将其传递给 ''make image'' 命令
 + 
 +<code bash> 
 +make image \ 
 +PROFILE="profile-name"
 +PACKAGES="pkg1 pkg2 pkg3 -pkg4 -pkg5 -pkg6" \ 
 +FILES="files"
 +DISABLED_SERVICES="svc1 svc2 svc3" 
 +</code> 
 + 
 +''make'' 命令完成后, 生成的镜像存放在 bin///设备架构名// 目录下, 就像编译一样. 
 + 
 +构建的固件将在子目录下找到 ''./bin/targets/<target>/generic'' 或查看里面 .''/build_dir/'' 对于文件 ''*-squashfs-sysupgrade.bin'' 和 ''*-squashfs-factory.bin'' (例如. ''/build_dir/target-mips_24kc_musl/linux-ar71xx_tiny/tmp/openwrt-18.06.2-ar71xx-tiny-tl-wr740n-v6-squashfs-factory.bin''
 + 
 +==== 清理编译 ==== 
 +要清理临时构建文件和生成的固件,请使用该 ''make clean'' 命令. 
 + 
 +==== 例子 ==== 
 +以下示例显示: 
 +  * 为配置文件创建目录. 
 +  * 使用 ''scp'' 发送 ''uci'' 配置文件到 WL500GP 路由器里的 ''files/etc/config'' 目录中. 
 +  * 使用自定义插件和 ''uci'' 配置文件为 WL500GP 生成固件映像 . 
 + 
 +<code bash> 
 +mkdir -p files/etc/config 
 +scp root@192.168.1.1:/etc/config/network files/etc/config/ 
 +scp root@192.168.1.1:/etc/config/wireless files/etc/config/ 
 +scp root@192.168.1.1:/etc/config/firewall files/etc/config/ 
 +make image PROFILE="wl500gp" PACKAGES="nano openvpn -ppp -ppp-mod-pppoe" FILES="files" 
 +</code> 
 + 
 +===== 故障排除 ===== 
 +  - 您是否以非 root 用户身份运行所有内容? 
 +  - 检查日志输出, 是否存在插件问题 (冲突, 导入名是否正确)? 
 +  - 检查日志输出, 是否超出了最大空间? 
 +  - 每天等待几个小时上游 packages 可能处于不一致状态, 尤其是在 master/snapshot 上 
 +  - 验证您拥有受支持的操作系统, 先决条件, 文件系统和路径命名 
 + 
 +===== 附加功能 ===== 
 +T以下主题不仅限于简单的使用,而且面向开发人员和高级用户. 
 + 
 +==== 详细帮助 ==== 
 +另请参阅 [[https://github.com/openwrt/openwrt/blob/master/target/imagebuilder/files/Makefile|ImageBuilder makefile]] 
 + 
 +获取详细帮助:
  
-== ar71xx-generic Profiles == 
 <code> <code>
 +# make help
 +
 +可用命令参数:
 + help: 此帮助文本
 + info: 显示可用目标配置文件的列表
 + clean: 删除映像和临时构建文件
 + image: 构建映像 (请参见下文有关更多信息).
 +
 +构建镜像:
 + 默认情况下 'make image' 将使用默认的目标配置文件和包集创建一个镜像. 
 + 您可以使用以下参数进行更改:
 +
 + make image PROFILE="<profilename>" # 覆盖默认目标配置文件
 + make image PACKAGES="<pkg1> [<pkg2> [<pkg3> ...]]" # 包括额外的插件
 + make image FILES="<path>" # 包含来自 <path> 的额外文件
 + make image BIN_DIR="<path>" # 固件生成的可选输出目录
 + make image EXTRA_IMAGE_NAME="<string>" # 将其添加到输出固件文件名 (sanitized)
 + make image DISABLED_SERVICES="<svc1> [<svc2> [<svc3> ..]]" # 应禁用 /etc/init.d/ 中的哪些服务
 + make image ADD_LOCAL_KEY=1 # 在构建的映像中存储本地生成的签名密钥
 + make image ROOTFS_PARTSIZE="<size>" # 以MB为单位更改默认的根文件系统分区大小。
 +
 +打印清单:
 + 列出安装到固件映像中的 "all" 所有插件.
 + 您可以使用以下参数:
 +
 + make manifest PROFILE="<profilename>" # 覆盖默认的目标配置文件
 + make manifest PACKAGES="<pkg1> [<pkg2> [<pkg3> ...]]" # 包含额外的插件
 + make manifest STRIP_ABI=1 # 从打印的插件名中删除 ABI 版本
 +</code>
 +
 +<color #ed1c24>注意:</color> make image ROOTFS_PARTSIZE="<size>" <color #ed1c24>该命令仅适用于受支持的Linux桌面版(或者服务器版)系统下使用,在 Image Builder 的目录内运行命令生成自定义大小的固件</color>
 +==== 可用配置文件 ====
 +列出可用的配置文件:
 +
 +<code>
 +# make info
 +
 Available Profiles: Available Profiles:
  
Line 111: Line 236:
 rp-n53: rp-n53:
     Asus RP-N53     Asus RP-N53
-    Packages: +    Packages:
 rt-n14u: rt-n14u:
     Asus RT-N14u     Asus RT-N14u
-    Packages: +    Packages:
 whr-1166d: whr-1166d:
     Buffalo WHR-1166D     Buffalo WHR-1166D
-    Packages: +    Packages:
 whr-300hp2: whr-300hp2:
     Buffalo WHR-300HP2     Buffalo WHR-300HP2
     Packages:     Packages:
--and many many more-+...
 </code> </code>
  
-After you find the appropriate profile pass it to the ''make image'' command:+==== 构建包含所有插件的 Image Builder ==== 
 +可以使用 buildroot 来创建您自己的 Image Builder 并将所有插件集成到其中, 这样它就可以在不下载包的情况下生成固件映像.
  
-For exampleif we wanted to generate a default image for for Asus RT-N14u (from above).+在图形配置中选择 "**Build the OpenWrt Image Builder**" 来编译镜像生成, 然后选择 **Global Build Settings -> Select all packages by default**, 保存(save)和退出(exit). 
 +如果遇到无法编译的未维护插件, 您可以[[docs:guide-developer:toolchain:use-buildsystem#ignore_build_errors|忽略构建错误]] , 假设这不会影响内核和核心依赖项.
  
-<code> +不要在路径中调用 ''make defconfig'' 或保留旧 ''.config'' 文件, 因为 ''Select all packages by default''只会将插件选择设置 ''[m]'' 为尚未配置的插件! ''make defconfig'' 将大多数包设置为 ''[n]'' 即//不编译//
-$ make image PROFILE=rt-n14u+ 
 +==== Adding package repositories ==== 
 +The Image Builder you download from the OpenWrt pages is already configured to download any non-default packages from official repositories. 
 +The package sources are configured in the ''repositories.conf'' file in the extracted directory. 
 +Sources are specified in //opkg// native config format. 
 +This can be either the official package repositories or custom generated repositories. 
 + 
 +An example of the contents of the ''repositories.conf'' from the **openwrt-imagebuilder-18.06.0-rc2-ramips-mt7621.Linux-x86_64.tar.xz**: 
 + 
 +<code bash
 +## Place your custom repositories here, they must match the architecture and version. 
 +# src/gz %n http://downloads.openwrt.org/releases/18.06.0-rc2 
 +# src custom file:///usr/src/openwrt/bin/ramips/packages 
 + 
 +## Remote package repositories 
 +src/gz openwrt_core http://downloads.openwrt.org/releases/18.06.0-rc2/targets/ramips/mt7621/packages 
 +src/gz openwrt_base http://downloads.openwrt.org/releases/18.06.0-rc2/packages/mipsel_24kc/base 
 +src/gz openwrt_luci http://downloads.openwrt.org/releases/18.06.0-rc2/packages/mipsel_24kc/luci 
 +src/gz openwrt_packages http://downloads.openwrt.org/releases/18.06.0-rc2/packages/mipsel_24kc/packages 
 +src/gz openwrt_routing http://downloads.openwrt.org/releases/18.06.0-rc2/packages/mipsel_24kc/routing 
 +src/gz openwrt_telephony http://downloads.openwrt.org/releases/18.06.0-rc2/packages/mipsel_24kc/telephony 
 + 
 +## This is the local package repository, do not remove! 
 +src imagebuilder file:packages
 </code> </code>
  
-==== PACKAGES Variable ==== +The ''repositories.conf'' in an imagebuilder you compile from source will lack the "Remote package repositories" links.
-The ''PACKAGES'' variable allows to include and/or exclude packages in the firmware image. By default (empty PACKAGES variable) the Image Generator will create a minimal image with device-specific kernel and drivers, uci, ssh, switch, firewall, ppp and ipv6 support.+
  
-Syntax:<code>$ make image PACKAGES="pkg1 pkg2 pkg3 -pkg4 -pkg5 -pkg6"</code> +If you want to add a custom local repository, copy the ''%%src custom file:///usr/src/openwrt/bin/ramips/packages%%'' line and modify it to point to the local folder you have your packages and package lists in. 
-The example above will include pkg1, pkg2, pkg3, and exclude pkg4, pkg5, pkg6, note the "-before each excluded package.+If you have problems with using you local repository because the "Signature check failedthen remove the line ''option check_signature'' from ''repositories.conf''
  
-You don't need to list all dependencies of the packages you need in this list, the Image Generator uses ''opkg'' to resolve automatically the package dependencies and install other required packages.+If you have custom repositories onlinecopy and modify the ''%%src/gz reboot http://downloads.openwrt.org/snapshots%%'' line instead.
  
-**Tip:** The list of currently installed packages on your device can be obtained with the command below: +NOTEif you want to override packages coming from an existing feed, you must write your custom feed ABOVE the line of the package feed containing the packages you want to override, as shown in the examples above.
-<code>echo $(opkg list_installed | awk '{ print $1 }')</code>+
  
-==== FILES Variable ==== +==== Restricting root access ==== 
-The ''FILES'' variable allows custom configuration files to be included in images built with Image GeneratorThis is especially useful if you need to change the network configuration from default before flashing, or if you are preparing an image for mass-flashing many devices.+Create a non-privileged admin user and lock root password. 
 +Configure privilege elevation with sudo. 
 +Set up key-based authentication and disable password authentication for Dropbear.
  
-Syntax: +<code bash> 
-<code>$ make image FILES=files/</code>+mkdir -p files/etc/uci-defaults 
 +cat << "EOF" > files/etc/uci-defaults/99-custom 
 +USER_NAME="admin" 
 +USER_GROUP="admin" 
 +USER_SSHPUB="SSH_PUBLIC_KEY" 
 +USER_SHELL="/bin/ash" 
 +SUDO_USER="root" 
 +SUDO_GROUP="sudo" 
 +SUDO_GID="27" 
 +uci set dropbear.@dropbear[0].PasswordAuth="0" 
 +uci set dropbear.@dropbear[0].RootPasswordAuth="0" 
 +uci commit dropbear 
 +/etc/init.d/dropbear restart 
 +passwd -l "${SUDO_USER}" 
 +groupadd -r -g "${SUDO_GID}" "${SUDO_GROUP}" 
 +touch /etc/environment 
 +cat << EOI > /etc/sudoers.d/00-custom 
 +%${SUDO_GROUP} ALL=(ALL) ALL 
 +EOI 
 +groupadd "${USER_GROUP}" 
 +useradd -m -g "${USER_GROUP}" -G "${SUDO_GROUP}"
 +-s "${USER_SHELL}" "${USER_NAME}" 
 +passwd -d "${USER_NAME}" 
 +USER_HOME="$(eval echo ~"${USER_NAME}")" 
 +mkdir -p "${USER_HOME}"/.ssh 
 +cat << EOI > "${USER_HOME}"/.ssh/authorized_keys 
 +${USER_SSHPUB} 
 +EOI 
 +chown -R "${USER_NAME}:${USER_GROUP}" "${USER_HOME}" 
 +chmod -R go= "${USER_HOME}" 
 +EOF 
 +make image FILES="files" PACKAGES="nano shadow sudo" 
 +</code>
  
-**Note:** The ''files/'' folder must be in the same folder where you issue the make command.+==== Adding/modifying profiles ====
  
 +<WRAP important>
 +Examples below may contain version dependent / legacy information and are for informational purposes. They are very low level so expect to have a good level of skill and familiarity with the ImageBuilder / OpenWrt in general. 
 +</WRAP>
  
-==== Examples ==== +The image building is tied to the profile names. 
-The following example shows:+If you add a new profile without also adding an appropriate macro to the image-generation Makefile, no suitable firmware file will get generated when using the custom profile. 
 +Remove the ''/tmp'' directory to properly apply the modified package selection from profiles.
  
-  -Creating the directory for the configuration files +The location of the profiles for the pre-compiled package for //brcm47xx-for-Linux-i686// was //target/linux/brcm47xx/profiles///
-  -Using ''scp'' to transfer ''uci'' configuration files from a WL500GP router to the ''files/etc/config'' directory +
-  -Generating an image for WL500GP with custom packages and ''uci'' configuration files+
  
-<code>mkdir -p files/etc/config +Remarkably, all that needs to be done to add a new profile, is to add a new file to the //profiles// directory. 
-scp root@192.168.1.1:/etc/config/network files/etc/config/ +//While this may have been the case in earlier releases, for 17.01, it appears that manual editing of ''.targetinfo'' is also required.// 
-scp root@192.168.1.1:/etc/config/wireless files/etc/config/ + 
-scp root@192.168.1.1:/etc/config/firewall files/etc/config+Here is what the //profiles/100-Broadcom-b43.mk// profile file looks like: 
-make image PROFILE=wl500gp PACKAGES="nano openvpn -ppp -ppp-mod-pppoe" FILES=files/+ 
 +<code bash> 
 +define Profile/Broadcom-b43 
 + NAME:=Broadcom BCM43xx WiFi (default) 
 + PACKAGES:=kmod-b43 kmod-b43legacy 
 +endef 
 + 
 +define Profile/Broadcom-b43/Description 
 + Package set compatible with hardware using Broadcom BCM43xx cards 
 +endef 
 +$(eval $(call Profile,Broadcom-b43))
 </code> </code>
  
-=====清除===== +Alternately edit the hidden .profile.mk file at the top level directory of the image builder and manually add the names of the desired packages to be added to the output image. 
-您可以使用**make clean**命令来清除临时构建文件和已生成的镜像文件。 +An "ls -a" will reveal the files hidden in the various directories. 
-=====移除固件中无用的文件===== + 
-<WRAP center round important 60%+==== Removing useless files from firmware ==== 
-This is not a standard feature of the Image Builder. +<WRAP important> 
 +This is not a standard feature of the Image Builder
 + 
 +It is highly recommended that you test file removal prior to incorporating such changes at the image builder level or that you have low level means to recover a device before attempting this type of mod, as bricking / non booting may result.
  
 Note that it requires patching of the ''Makefile'' Note that it requires patching of the ''Makefile''
 +
 +It is based on older Chaos Calmer era code... and not applicable to modern ImageBuilders but useful as a reference...
 </WRAP> </WRAP>
  
-1. 创建一个包含了文件完整径名为'files_remove',如: +Create file ''files_remove'' with full filenames: 
-<code>+ 
 +<code bash>
 /lib/modules/3.10.49/ts_bm.ko /lib/modules/3.10.49/ts_bm.ko
 /lib/modules/3.10.49/nf_nat_ftp.ko /lib/modules/3.10.49/nf_nat_ftp.ko
Line 183: Line 383:
 </code> </code>
  
-2. 给Makefile打补丁 +Patch Makefile
-<code bash>+ 
 +<code diff>
  ifneq ($(USER_FILES),)  ifneq ($(USER_FILES),)
   $(MAKE) copy_files   $(MAKE) copy_files
Line 193: Line 394:
 + @echo Remove useless files + @echo Remove useless files
 + +
-+ while read filename; do ++ while read filename; do \ 
-+     rm -rfv "$(TARGET_DIR)$$filename"; \++     rm -rfv "$(TARGET_DIR)$$filename"; \
 + done < $(FILES_REMOVE); + done < $(FILES_REMOVE);
 +endif +endif
Line 202: Line 403:
 </code> </code>
  
-3. 重构固件 +Rebuild firmware:
-<code> +
-# make image \ +
-    PROFILE=tlwr841 \ +
-    PACKAGES="igmpproxy ip iptraf kmod-ipt-nathelper-extra openvpn-polarssl tcpdump-mini -firewall -ip6tables -kmod-ip6tables -kmod-ipv6 -odhcp6c -ppp -ppp-mod-pppoe"+
-    FILES_REMOVE="files_remove" +
-</code>+
  
- +<code bash> 
-===== Building the Image Generator with all packages inside ===== +make image \ 
-It is possible to build the Image Generator and integrate in it all packages so it will be able to generate images without downloading packages: +PROFILE="tlwr841\ 
- +PACKAGES="igmpproxy ip iptraf kmod-ipt-nathelper-extra openvpn-polarssl tcpdump-mini -firewall -ip6tables -kmod-ip6tables -kmod-ipv6 -odhcp6c -ppp -ppp-mod-pppoe" \ 
-In the graphical configuration, select "**Build the LEDE Image Builder**to build the image builder, then  select **Global Build Settings** -> **Select all packages by default**, save and exit. +FILES_REMOVE="files_remove"
-Then build the image, including ''IGNORE_ERRORS=1'' as there might be unmaintained packages that fail to compile. +
- +
-Enabling ''IGNORE_ERRORS=1'' should only be done **once the kernel and required packages are known to compile successfully.** +
- +
-<code>make IGNORE_ERRORS=1+
 </code> </code>
- 
-**Note:** Don't call ''make defconfig'' or leave an old ''.config'' file in the path as ''Select all packages by default'' will only set the package selection to ''[m]'' for packages that are not already configured otherwise!(''make defconfig'' will set most packages to ''[n]'', i.e. //do not build//.) 
- 
- 
-===== Adding/Modifying Profiles ===== 
-The image generation is tied to the profile names. If you add a new profile without also adding an appropriate macro to the image-generation Makefile, no suitable firmware file will get generated when using the custom profile.  
-:!: Make sure to remove the /tmp directory to get modified package selection from profiles to work.  
- 
-The location of the profiles for the pre-compiled package for //brcm47xx-for-Linux-i686// was //target/linux/brcm47xx/profiles/// 
- 
-Remarkably, all that needs to be done to add a new profile, is to add a new file to the //profiles// directory. //While this may have been the case in earlier releases, for 17.01, it appears that manual editing of ''.targetinfo'' is also required.// 
- 
-Here is what the //profiles/100-Broadcom-b43.mk// profile file looks like:   
- 
-<WRAP> 
-<code> 
-define Profile/Broadcom-b43 
-  NAME:=Broadcom BCM43xx WiFi (default) 
-  PACKAGES:=kmod-b43 kmod-b43legacy 
-endef 
- 
-define Profile/Broadcom-b43/Description 
- Package set compatible with hardware using Broadcom BCM43xx cards 
-endef 
-$(eval $(call Profile,Broadcom-b43)) 
-</code> 
-</WRAP> 
  • Last modified: 2024/11/30 15:10
  • by starsfall