commit d35682f2b79381fdaad70b3b0c5e5a9814c00295 Author: Chen Wang Date: Mon Nov 24 16:22:33 2025 +0800 Step1: build with busybox. Signed-off-by: Chen Wang diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..25bd7c1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +dl/ +output/ \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..17cb286 --- /dev/null +++ b/LICENSE @@ -0,0 +1,117 @@ +GNU GENERAL PUBLIC LICENSE +Version 2, June 1991 + +Copyright (C) 1989, 1991 Free Software Foundation, Inc. +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + +Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. + +Preamble + +The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. + +When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. + +To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. + +For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. + +We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. + +Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. + +Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. + +The precise terms and conditions for copying, distribution and modification follow. + +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. + +1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. + +You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. + + c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. + +3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. + +If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. + +4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. + +5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. + +6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. + +7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. + +This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. + +8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. + +9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. + +10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. + +NO WARRANTY + +11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +END OF TERMS AND CONDITIONS + +How to Apply These Terms to Your New Programs + +If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. + +To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. + + one line to give the program's name and an idea of what it does. Copyright (C) yyyy name of author + + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. + +signature of Ty Coon, 1 April 1989 Ty Coon, President of Vice diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..a110640 --- /dev/null +++ b/Makefile @@ -0,0 +1,73 @@ +.PHONY: all +all: + @./build.sh + +.PHONY: source +source: + @./package/prepare-env/make.sh || exit 1 + @./source.sh || exit 1 + +.PHONY: prepare-env +prepare-env: + @./package/prepare-env/make.sh || exit 1 + @./package/skeleton/make.sh || exit 1 + +.PHONY: host-tools +host-tools: + @./package/pkgconf/make-host.sh || exit 1 + @./package/libzlib/make-host.sh || exit 1 + @./package/m4/make-host.sh || exit 1 + @./package/libtool/make-host.sh || exit 1 + @./package/autoconf/make-host.sh || exit 1 + @./package/automake/make-host.sh || exit 1 + +.PHONY: toolchain +toolchain: + @./package/bison/make-host.sh || exit 1 + @./package/gawk/make-host.sh || exit 1 + @./package/gmp/make-host.sh || exit 1 + @./package/mpfr/make-host.sh || exit 1 + @./package/mpc/make-host.sh || exit 1 + @./package/binutils/make-host.sh || exit 1 + @./package/gcc/make-host-initial.sh || exit 1 + @./package/linux-headers/make.sh || exit 1 + @./package/glibc/make.sh || exit 1 + @./package/gcc/make-host-final.sh || exit 1 + @./package/gcc/make-final.sh || exit 1 + @./package/toolchain/make.sh || exit 1 + +.PHONY: opensbi +opensbi: + @./package/opensbi/make.sh || exit 1 + +.PHONY: linux +linux: + @./package/kmod/make-host.sh || exit 1 + @./package/gettext-tiny/make-host.sh || exit 1 + @./package/flex/make-host.sh || exit 1 + @./package/linux/make.sh || exit 1 + +.PHONY: busybox +busybox: + @./package/busybox/make.sh || exit 1 + +.PHONY: before-target-image +before-target-image: + @./package/util-linux/make-host.sh || exit 1 + @./package/e2fsprogs/make-host.sh || exit 1 + @./package/attr/make-host.sh || exit 1 + @./package/acl/make-host.sh || exit 1 + @./package/fakeroot/make-host.sh || exit 1 + @./package/makedevs/make-host.sh || exit 1 + @./package/patchelf/make-host.sh || exit 1 + +.PHONY: rebuild-target-image +rebuild-target-image: + @echo "----> Building $@ ..." + @./package/host-finalize/make.sh || exit 1 + @./package/target-finalize/make.sh || exit 1 + @./package/rootfs-ext2/make.sh || exit 1 + @echo "<---- $@ build complete." + +clean: + rm -rf output/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..a5e7290 --- /dev/null +++ b/README.md @@ -0,0 +1,135 @@ +**从零开始为 RISC-V 构建一个 Linux 系统** + + + +- [1. 课程简介](#1-课程简介) +- [2. 本仓库介绍](#2-本仓库介绍) +- [3. 运行环境](#3-运行环境) +- [4. 下载本仓库](#4-下载本仓库) +- [5. 构建和使用说明](#5-构建和使用说明) + - [5.1. 批量下载软件包源码压缩包](#51-批量下载软件包源码压缩包) + - [5.2. 构建](#52-构建) + - [5.3. 运行](#53-运行) +- [6. 致谢](#6-致谢) + + + +# 1. 课程简介 + +随着 RISC-V 生态的不断发展,越来越多的开发者开始在实际项目中接触 RISC-V 架构下的 Linux 系统。然而在学习与实践过程中,开发者往往会遇到以下困惑: + +- 使用现成镜像可以快速启动,但对系统的构成与启动流程缺乏整体认知。 +- 能够编译内核或应用程序,却不清楚各组件之间的依赖关系。 +- 对工具链、OpenSBI、内核、文件系统等概念有所了解,但理解碎片化,尚未形成完整体系。 + +针对这些常见困惑,中国科学院软件研究所智能软件研究中心特此推出由汪辰老师主讲的在线慕课课程:《从零开始为 RISC-V 构建一个 Linux 系统》。本课程内容涵盖交叉编译工具链的制作、SBI 固件的构建、Linux 内核的编译与加载、根文件系统的组织与实现,并最终在 QEMU 模拟器中运行自制的 Linux 系统。通过本课程的学习,希望能够帮助大家更加系统地了解和掌握构建一个完整的 Linux 操作系统所需的关键知识与方法。 + +本课程也是 openRuyi 课程系列的重要组成部分。 + +在线慕课 B 站地址: + +欢迎加入本课程的 QQ 学习群 (群号:1090841283),边学习边讨论: + +![](./qq-group.png) + +# 2. 本仓库介绍 + +本仓库包含课程《从零开始为 RISC-V 构建一个 Linux 系统》的配套课件和构建脚本代码。该课程用于教学演示如何从零开始为 RISC-V 平台构建一个 Linux 系统。采用 GPL v2 许可证发布(具体请阅读本仓库根目录下的 [LICENSE 文件](./LICENSE))。 + +本仓库目录文件介绍: + +- `package`: 目录,用于存放每个软件包的构建素材(譬如补丁文件)和构建脚本。 +- `slides`: 目录,用于存放本课程对应的课件(pdf)。 +- `support`:目录,用于存放构建中会用到的一些辅助脚本和素材文件。 +- `.gitignore`: Git 配置文件,用于指定哪些文件或目录应该被 Git 忽略,不纳入版本控制。 +- `build.sh`: 执行 `make` 时会执行的脚本文件。 +- `LICENSE`: 本仓库的发布许可证文件。 +- `Makefile`: make 文件。 +- `README.md`: 本文件。 +- `source.sh`: 执行 `make source` 时会执行的脚本文件。 + +执行构建过程中还会创建以下目录,但不作为本仓库的一部分。 + +- `dl`: 目录,用于存放网络下载的软件包源码压缩包。 +- `output`: 目录,用于存放构建的输出,即本课程定义的 `${OUTPUT_DIR}`。 + +# 3. 运行环境 + +本仓库提供了对应课程内容的参考构建脚本,构建脚本在 Ubuntu 22.04 LTS 和 Ubuntu 24.04 LTS 上验证通过。有关运行环境的具体要求可以参考课件 “第 3 章 构建 Linux 系统之前的准备工作” 的 02 部分:“构建环境准备” 的介绍。 + +也欢迎大家在其他 Linux 发行版上尝试,原理上本仓库的参考构建脚本并不局限于 Ubuntu 系统。 + +# 4. 下载本仓库 + +```shell +$ git clone https://git.openruyi.cn/openRuyi-tutorials/build-linux-system-from-scratch.git +``` + +下载后进入课程仓库目录: + +```shell +$ cd build-linux-system-from-scratch +``` + +下文假设下载后的课程仓库目录为 `${PROJECT_DIR}`,不再赘述。 + +**注意:由于本仓库代码出于演示 Step by Step 的修改过程的目的,main 分支的 commit 仅用于演示步骤而不反应实际 git 提交历史,所以在同步本地仓库时不支持简单的 pull。建议每次同步本地时直接采用完整的 clone 方式**。 + +# 5. 构建和使用说明 + +本节运行命令时假设都在 `${PROJECT_DIR}`,即本仓库所在路径下运行,不再赘述。 + +本仓库的构建命令无需 root 权限。 + +## 5.1. 批量下载软件包源码压缩包 + +强烈建议在开始构建之前先完整下载所需的软件包源码压缩包。 + +批量下载软件包源码压缩包的命令如下。注意:中途可能失败,多半是因为网络超时所致,可以多试几次以下命令,直到全部成功。 + +```shell +$ make source +``` + +如果仍然无法完整下载软件包,也可以去 openRuyi 仓库克隆一份。确保在 `${PROJECT_DIR}` 下执行如下命令: + +```shell +$ git clone --depth 1 --branch main https://git.openruyi.cn/openRuyi-tutorials/packages-for-build-linux-system-from-scratch.git dl +``` + +## 5.2. 构建 + +本仓库的主分支 main 上有 6 个 commit,从下到上分别对应以下步骤: + +``` +Step6: add python and snake. +Step5: add vim. +Step4: enhanced shell with bash. +Step3: enhanced with coreutiles. +Step2: enhanced with sysvinit +Step1: build with busybox. +``` + +学习者可以 checkout 到任意一个 commit 并运行以下命令进行构建。注意:本仓库的构建脚本不支持增量构建,只支持从零开始一次性构建(实际上执行 `make` 内部也会默认先执行 `make clean`)。 + +```shell +$ make clean +$ make +``` + +## 5.3. 运行 + +构建成功后可以进入 `${IMAGES_DIR}` 执行脚本,运行 QEMU 模拟器并加载我们制作的 Linux 系统。 + +```shell +$ cd output/images/ +$ ./start-qemu.sh +``` + +登录系统的用户名是 root,无密码。 + +关机可以在登录系统后在控制台中输入 poweroff 命令,或者直接 "Ctrl+A X" 强制退出 QEMU(所谓 "Ctrl+A X" 是指同时按下 Ctrl 和 A,同时松开后再按 X)。 + +# 6. 致谢 + +本仓库的构建脚本参考了 [Buildroot (2025.08.1)](https://buildroot.org/)。在此表示衷心感谢! diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..e906b19 --- /dev/null +++ b/build.sh @@ -0,0 +1,12 @@ +#!/usr/bin/bash + +make clean + +make prepare-env || exit 1 +make host-tools || exit 1 +make toolchain || exit 1 +make opensbi || exit 1 +make linux || exit 1 +make busybox || exit 1 +make before-target-image || exit 1 +make rebuild-target-image || exit 1 \ No newline at end of file diff --git a/package/acl/0001-Build-with-old-GCC-versions.patch b/package/acl/0001-Build-with-old-GCC-versions.patch new file mode 100644 index 0000000..a05ff5d --- /dev/null +++ b/package/acl/0001-Build-with-old-GCC-versions.patch @@ -0,0 +1,32 @@ +From a42519dceef0493ece45538375ae1791313f16d3 Mon Sep 17 00:00:00 2001 +From: Hollis Blanchard +Date: Mon, 30 Jul 2018 14:29:46 -0700 +Subject: [PATCH] Remove pragmas inside functions + +GCC 4.4.7, as found in RHEL6, reports: + libacl/acl_from_text.c:307: error: #pragma GCC diagnostic not allowed inside functions + +Signed-off-by: Hollis Blanchard +--- + libacl/acl_from_text.c | 3 --- + 1 file changed, 3 deletions(-) + +diff --git a/libacl/acl_from_text.c b/libacl/acl_from_text.c +index 09790c9..fb6bc07 100644 +--- a/libacl/acl_from_text.c ++++ b/libacl/acl_from_text.c +@@ -304,11 +304,8 @@ parse_acl_entry(const char **text_p, acl_t *acl_p) + create_entry: + if (acl_create_entry(acl_p, &entry_d) != 0) + return -1; +-#pragma GCC diagnostic push +-#pragma GCC diagnostic ignored "-Waddress" + if (acl_copy_entry(entry_d, int2ext(&entry_obj)) != 0) + return -1; +-#pragma GCC diagnostic pop + return 0; + + fail: +-- +2.13.0 + diff --git a/package/acl/make-host.sh b/package/acl/make-host.sh new file mode 100755 index 0000000..2ac9211 --- /dev/null +++ b/package/acl/make-host.sh @@ -0,0 +1,41 @@ +#!/usr/bin/bash +source $(dirname "$0")/../common.sh + +PKGNAME=acl +PKGVERSION=2.3.2 +PKGSOURCE_DIR=acl +PKGSOURCE=acl-2.3.2.tar.xz +PKGURL=https://download.savannah.nongnu.org/releases/acl/acl-2.3.2.tar.xz + +PKGBUILDNAME=host-${PKGNAME} +PKGBUILD_DIR=${BUILD_DIR}/${PKGBUILDNAME}-${PKGVERSION} + +echo "----> Building ${PKGBUILDNAME} ..." + +stamp_downloaded + +step_start extract +mkdir -p ${PKGBUILD_DIR} +xzcat ${DL_DIR}/${PKGSOURCE_DIR}/${PKGSOURCE} | tar --strip-components=1 -C ${PKGBUILD_DIR} -xf - +chmod -R +rw ${PKGBUILD_DIR} +step_end extract + +step_start patch +TAR="tar" PATH=${HOST_DIR}/bin:$PATH ${PROJECT_DIR}/support/scripts/apply-patches.sh ${PKGBUILD_DIR} ${PROJECT_DIR}/package/${PKGNAME} \*.patch +step_end patch autotools + +step_start configure +(cd ${PKGBUILD_DIR} && rm -rf config.cache; eval "${HOST_CONFIGURE_OPTS} CONFIG_SITE=/dev/null ./configure --prefix=\"${HOST_DIR}\" --sysconfdir=\"${HOST_DIR}/etc\" --localstatedir=\"${HOST_DIR}/var\" --enable-shared --disable-static --disable-gtk-doc --disable-gtk-doc-html --disable-doc --disable-docs --disable-documentation --disable-debug --with-xmlto=no --with-fop=no --disable-nls --disable-dependency-tracking") +step_end configure + +step_start build +eval "${HOST_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} -C ${PKGBUILD_DIR}" +step_end build + +step_start install-host +eval "${HOST_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} install -C ${PKGBUILD_DIR}" +step_end install-host + +stamp_installed + +echo "<---- ${PKGBUILDNAME} build complete." diff --git a/package/attr/0001-build-with-older-GCCs.patch b/package/attr/0001-build-with-older-GCCs.patch new file mode 100644 index 0000000..22cfac2 --- /dev/null +++ b/package/attr/0001-build-with-older-GCCs.patch @@ -0,0 +1,87 @@ +From 3ac428794ea0f95c854166c9c0cffb0267c5e98b Mon Sep 17 00:00:00 2001 +From: Hollis Blanchard +Date: Mon, 30 Jul 2018 14:17:21 -0700 +Subject: [PATCH] Remove messages in "deprecated" gcc attributes + +GCC versions up through 4.4.7 (which is used in RHEL 6) do not accept +any argument for the deprecated attribute. GCC 4.5 and later say the +"msg" argument is optional. We don't need the messages during +Buildroot builds anyways. + +Signed-off-by: Hollis Blanchard +--- + include/attributes.h | 20 ++++++++++---------- + 1 file changed, 10 insertions(+), 10 deletions(-) + +diff --git a/include/attributes.h b/include/attributes.h +index 14beb8f..23c39c8 100644 +--- a/include/attributes.h ++++ b/include/attributes.h +@@ -127,10 +127,10 @@ typedef struct attr_multiop { + */ + EXPORT int attr_get (const char *__path, const char *__attrname, + char *__attrvalue, int *__valuelength, int __flags) +- __attribute__ ((deprecated ("Use getxattr or lgetxattr instead"))); ++ __attribute__ ((deprecated)); + EXPORT int attr_getf (int __fd, const char *__attrname, char *__attrvalue, + int *__valuelength, int __flags) +- __attribute__ ((deprecated ("Use fgetxattr instead"))); ++ __attribute__ ((deprecated)); + + /* + * Set the value of an attribute, creating the attribute if necessary. +@@ -139,11 +139,11 @@ EXPORT int attr_getf (int __fd, const char *__attrname, char *__attrvalue, + EXPORT int attr_set (const char *__path, const char *__attrname, + const char *__attrvalue, const int __valuelength, + int __flags) +- __attribute__ ((deprecated ("Use setxattr or lsetxattr instead"))); ++ __attribute__ ((deprecated)); + EXPORT int attr_setf (int __fd, const char *__attrname, + const char *__attrvalue, const int __valuelength, + int __flags) +- __attribute__ ((deprecated ("Use fsetxattr instead"))); ++ __attribute__ ((deprecated)); + + /* + * Remove an attribute. +@@ -151,9 +151,9 @@ EXPORT int attr_setf (int __fd, const char *__attrname, + */ + EXPORT int attr_remove (const char *__path, const char *__attrname, + int __flags) +- __attribute__ ((deprecated ("Use removexattr or lremovexattr instead"))); ++ __attribute__ ((deprecated)); + EXPORT int attr_removef (int __fd, const char *__attrname, int __flags) +- __attribute__ ((deprecated ("Use fremovexattr instead"))); ++ __attribute__ ((deprecated)); + + /* + * List the names and sizes of the values of all the attributes of an object. +@@ -164,10 +164,10 @@ EXPORT int attr_removef (int __fd, const char *__attrname, int __flags) + */ + EXPORT int attr_list(const char *__path, char *__buffer, const int __buffersize, + int __flags, attrlist_cursor_t *__cursor) +- __attribute__ ((deprecated ("Use listxattr or llistxattr instead"))); ++ __attribute__ ((deprecated)); + EXPORT int attr_listf(int __fd, char *__buffer, const int __buffersize, + int __flags, attrlist_cursor_t *__cursor) +- __attribute__ ((deprecated ("Use flistxattr instead"))); ++ __attribute__ ((deprecated)); + + /* + * Operate on multiple attributes of the same object simultaneously. +@@ -188,10 +188,10 @@ EXPORT int attr_listf(int __fd, char *__buffer, const int __buffersize, + */ + EXPORT int attr_multi (const char *__path, attr_multiop_t *__oplist, + int __count, int __flags) +- __attribute__ ((deprecated ("Use getxattr, setxattr, listxattr, removexattr instead"))); ++ __attribute__ ((deprecated)); + EXPORT int attr_multif (int __fd, attr_multiop_t *__oplist, + int __count, int __flags) +- __attribute__ ((deprecated ("Use getxattr, setxattr, listxattr, removexattr instead"))); ++ __attribute__ ((deprecated)); + + #ifdef __cplusplus + } +-- +2.13.0 + diff --git a/package/attr/0002-configure.ac-add-detection-of-symver-gcc-attribute.patch b/package/attr/0002-configure.ac-add-detection-of-symver-gcc-attribute.patch new file mode 100644 index 0000000..ee029e9 --- /dev/null +++ b/package/attr/0002-configure.ac-add-detection-of-symver-gcc-attribute.patch @@ -0,0 +1,75 @@ +From 365426c28f8bf73d34d77cc06b7d5ffeae17f13a Mon Sep 17 00:00:00 2001 +From: Thomas Petazzoni +Date: Tue, 6 Feb 2024 15:33:15 +0100 +Subject: [PATCH] configure.ac: add detection of symver gcc attribute + +On non-ELF platforms, such as microblaze, builds will fail when trying +to add symver information because __attribute__((symver ..)) is not +supported even though __has_attribute(__symver__) returns true. + +Support for symver needs to be detected via a compile test since +__has_attribute can report false positives [0]. + +Add a configure compile check for __attribute__((symver ..)) to ensure +it is supported and define a variable to advertise support. + +[0] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101766#c1 + +Upstream: https://git.savannah.nongnu.org/cgit/attr.git/commit/?id=943c776089dbb24ebbfb7432ba9841f1845bf95a + +Signed-off-by: Thomas Petazzoni +[Giulio: rework local patch for #if nesting] +Signed-off-by: Giulio Benetti +--- + configure.ac | 15 +++++++++++++++ + libattr/syscalls.c | 8 ++++---- + 2 files changed, 19 insertions(+), 4 deletions(-) + +diff --git a/configure.ac b/configure.ac +index 7e362e9..98477b5 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -57,6 +57,21 @@ AS_CASE([$host_os], + [linux*], [os_linux=yes]) + AM_CONDITIONAL([OS_LINUX], [test "x$os_linux" = "xyes"]) + ++AC_CACHE_CHECK(whether __attribute__((__symver__())) is supported, ++ gcc_cv_symver_attribute, ++ [cat > conftest.c </dev/null 2>&1; then \ ++ gcc_cv_symver_attribute=yes ++ fi ++ rm -f conftest.[cs] ++]) ++AS_IF([test $gcc_cv_symver_attribute = yes], ++ [AC_DEFINE(HAVE_SYMVER_ATTRIBUTE, [], [GCC supports symver attribute])]) ++ + AC_CONFIG_COMMANDS([include/attr], + [dnl + rm -rf include/attr +diff --git a/libattr/syscalls.c b/libattr/syscalls.c +index 907560a..7ee6d39 100644 +--- a/libattr/syscalls.c ++++ b/libattr/syscalls.c +@@ -31,10 +31,10 @@ + * prefer symver attribute if available (since gcc 10), + * fall back to traditional .symver asm directive otherwise. + */ +-#ifdef __has_attribute +-# if __has_attribute(__symver__) +-# define SYMVER(cn, vn) __typeof(cn) cn __attribute__((__symver__(vn))) +-# elif __has_attribute(__no_reorder__) ++#if defined(HAVE_SYMVER_ATTRIBUTE) ++# define SYMVER(cn, vn) __typeof(cn) cn __attribute__((__symver__(vn))) ++#elif defined(__has_attribute) ++# if __has_attribute(__no_reorder__) + /* + * Avoid wrong partitioning with older gcc and LTO. May not work reliably + * with all versions; use -flto-partition=none if you encounter problems. +-- +2.34.1 + diff --git a/package/attr/0003-tools-attr.c-Add-missing-libgen.h-include-for-basena.patch b/package/attr/0003-tools-attr.c-Add-missing-libgen.h-include-for-basena.patch new file mode 100644 index 0000000..3041772 --- /dev/null +++ b/package/attr/0003-tools-attr.c-Add-missing-libgen.h-include-for-basena.patch @@ -0,0 +1,32 @@ +From 8a80d895dfd779373363c3a4b62ecce5a549efb2 Mon Sep 17 00:00:00 2001 +From: "Haelwenn (lanodan) Monnier" +Date: Sat, 30 Mar 2024 10:17:10 +0100 +Subject: [PATCH] tools/attr.c: Add missing libgen.h include for basename(3) + +Fixes compilation issue with musl and modern C99 compilers. + +See: https://bugs.gentoo.org/926294 + +Upstream: https://git.savannah.nongnu.org/cgit/attr.git/commit/?id=8a80d895dfd779373363c3a4b62ecce5a549efb2 + +Signed-off-by: Yegor Yefremov +Signed-off-by: Romain Naour +--- + tools/attr.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/tools/attr.c b/tools/attr.c +index f12e4af..6a3c1e9 100644 +--- a/tools/attr.c ++++ b/tools/attr.c +@@ -28,6 +28,7 @@ + #include + #include + #include ++#include + + #include + +-- +2.45.0 + diff --git a/package/attr/make-host.sh b/package/attr/make-host.sh new file mode 100755 index 0000000..4c20512 --- /dev/null +++ b/package/attr/make-host.sh @@ -0,0 +1,44 @@ +#!/usr/bin/bash +source $(dirname "$0")/../common.sh + +PKGNAME=attr +PKGVERSION=2.5.2 +PKGSOURCE_DIR=attr +PKGSOURCE=attr-2.5.2.tar.xz +PKGURL=http://download.savannah.gnu.org/releases/attr/attr-2.5.2.tar.xz + +PKGBUILDNAME=host-${PKGNAME} +PKGBUILD_DIR=${BUILD_DIR}/${PKGBUILDNAME}-${PKGVERSION} + +echo "----> Building ${PKGBUILDNAME} ..." + +stamp_downloaded + +step_start extract +mkdir -p ${PKGBUILD_DIR} +xzcat ${DL_DIR}/${PKGSOURCE_DIR}/${PKGSOURCE} | tar --strip-components=1 -C ${PKGBUILD_DIR} -xf - +chmod -R +rw ${PKGBUILD_DIR} +step_end extract + +step_start patch +TAR="tar" PATH=${HOST_DIR}/bin:$PATH ${PROJECT_DIR}/support/scripts/apply-patches.sh ${PKGBUILD_DIR} ${PROJECT_DIR}/package/${PKGNAME} \*.patch +step_end patch autotools ignore_libtool_patch + +step_start configure +echo ">>> ${PKGBUILDNAME} ${PKGVERSION} Autoreconfiguring" +cd ${PKGBUILD_DIR} && eval "AUTOPOINT=/bin/true ${AUTORECONF_OPTS} ${HOST_DIR}/bin/autoreconf -f -i" +patch_libtool ${PKGBUILD_DIR} +(cd ${PKGBUILD_DIR} && rm -rf config.cache; eval "${HOST_CONFIGURE_OPTS} CONFIG_SITE=/dev/null ./configure --prefix=\"${HOST_DIR}\" --sysconfdir=\"${HOST_DIR}/etc\" --localstatedir=\"${HOST_DIR}/var\" --enable-shared --disable-static --disable-gtk-doc --disable-gtk-doc-html --disable-doc --disable-docs --disable-documentation --disable-debug --with-xmlto=no --with-fop=no --disable-nls --disable-dependency-tracking") +step_end configure + +step_start build +eval "${HOST_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} -C ${PKGBUILD_DIR}" +step_end build + +step_start install-host +eval "${HOST_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} install -C ${PKGBUILD_DIR}" +step_end install-host + +stamp_installed + +echo "<---- ${PKGBUILDNAME} build complete." diff --git a/package/autoconf/0001-dont-add-dirty-to-version.patch b/package/autoconf/0001-dont-add-dirty-to-version.patch new file mode 100644 index 0000000..a1a50d2 --- /dev/null +++ b/package/autoconf/0001-dont-add-dirty-to-version.patch @@ -0,0 +1,28 @@ +autoconf: don't append -dirty to version + +Don't append -dirty to autoconf version number if the buildroot git tree +has uncommitted changes. + +This script is meant for the autoconf developers, but it also activates +if you build autoconf in a subdirectory of a git tree (E.G. like how it's +commonly done in buildroot). + +The affect is that autoconf gets built as being version 2.65-dirty, which +breaks programs (like Python) which explicitly checks for autoconf-2.65. + +[Gustavo: update for autoconf 2.69] +Signed-off-by: Peter Korsgaard +Signed-off-by: Gustavo Zacarias + +diff -Nura autoconf-2.69.orig/build-aux/git-version-gen autoconf-2.69/build-aux/git-version-gen +--- autoconf-2.69.orig/build-aux/git-version-gen 2013-06-27 11:31:02.340200154 -0300 ++++ autoconf-2.69/build-aux/git-version-gen 2013-06-27 11:31:13.734577033 -0300 +@@ -210,7 +210,7 @@ + *) # Append the suffix only if there isn't one already. + case $v in + *-dirty) ;; +- *) v="$v-dirty" ;; ++ #*) v="$v-dirty" ;; + esac ;; + esac + fi diff --git a/package/autoconf/make-host.sh b/package/autoconf/make-host.sh new file mode 100755 index 0000000..d9d7dc0 --- /dev/null +++ b/package/autoconf/make-host.sh @@ -0,0 +1,41 @@ +#!/usr/bin/bash +source $(dirname "$0")/../common.sh + +PKGNAME=autoconf +PKGVERSION=2.72 +PKGSOURCE_DIR=autoconf +PKGSOURCE=autoconf-2.72.tar.xz +PKGURL=http://mirrors.ustc.edu.cn/gnu/autoconf/autoconf-2.72.tar.xz + +PKGBUILDNAME=host-${PKGNAME} +PKGBUILD_DIR=${BUILD_DIR}/${PKGBUILDNAME}-${PKGVERSION} + +echo "----> Building ${PKGBUILDNAME} ..." + +stamp_downloaded + +step_start extract +mkdir -p ${PKGBUILD_DIR} +xzcat ${DL_DIR}/${PKGSOURCE_DIR}/${PKGSOURCE} | tar --strip-components=1 -C ${PKGBUILD_DIR} -xf - +chmod -R +rw ${PKGBUILD_DIR} +step_end extract + +step_start patch +TAR="tar" PATH=${HOST_DIR}/bin:$PATH ${PROJECT_DIR}/support/scripts/apply-patches.sh ${PKGBUILD_DIR} ${PROJECT_DIR}/package/${PKGNAME} \*.patch +step_end patch autotools + +step_start configure +(cd ${PKGBUILD_DIR} && rm -rf config.cache; eval "${HOST_CONFIGURE_OPTS} EMACS=\"no\" ac_cv_path_M4=${HOST_DIR}/bin/m4 ac_cv_prog_gnu_m4_gnu=no CONFIG_SITE=/dev/null ./configure --prefix=\"${HOST_DIR}\" --sysconfdir=\"${HOST_DIR}/etc\" --localstatedir=\"${HOST_DIR}/var\" --enable-shared --disable-static --disable-gtk-doc --disable-gtk-doc-html --disable-doc --disable-docs --disable-documentation --disable-debug --with-xmlto=no --with-fop=no --disable-nls --disable-dependency-tracking") +step_end configure + +step_start build +eval "${HOST_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} -C ${PKGBUILD_DIR}" +step_end build + +step_start install-host +eval "${HOST_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} install -C ${PKGBUILD_DIR}" +step_end install-host + +echo "<---- ${PKGBUILDNAME} build complete." + +stamp_installed diff --git a/package/automake/0001-noman.patch b/package/automake/0001-noman.patch new file mode 100644 index 0000000..a4ad16d --- /dev/null +++ b/package/automake/0001-noman.patch @@ -0,0 +1,27 @@ +Disable manpages build and installation, seems the bundled version of +help2man is somewhat old and breaks on modern distributions such as +Fedora 20, as reported by Kanibal on IRC. + +Signed-off-by: Gustavo Zacarias + +diff -Nura automake-1.14.1.orig/Makefile.in automake-1.14.1/Makefile.in +--- automake-1.14.1.orig/Makefile.in 2014-09-10 18:40:57.554164448 -0300 ++++ automake-1.14.1/Makefile.in 2014-09-10 18:42:01.050348068 -0300 +@@ -3387,7 +3387,7 @@ + check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) check-TESTS check-local + check: check-am +-all-am: Makefile $(INFO_DEPS) $(SCRIPTS) $(MANS) $(DATA) ++all-am: Makefile $(INFO_DEPS) $(SCRIPTS) $(DATA) + installdirs: + for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(infodir)" "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(amdir)" "$(DESTDIR)$(automake_acdir)" "$(DESTDIR)$(automake_internal_acdir)" "$(DESTDIR)$(docdir)" "$(DESTDIR)$(perllibdir)" "$(DESTDIR)$(pkgvdatadir)" "$(DESTDIR)$(scriptdir)" "$(DESTDIR)$(system_acdir)" "$(DESTDIR)$(perllibdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ +@@ -3454,7 +3454,7 @@ + install-dist_automake_internal_acDATA install-dist_docDATA \ + install-dist_perllibDATA install-dist_pkgvdataDATA \ + install-dist_scriptDATA install-dist_system_acDATA \ +- install-info-am install-man install-nodist_perllibDATA ++ install-info-am install-nodist_perllibDATA + @$(NORMAL_INSTALL) + $(MAKE) $(AM_MAKEFLAGS) install-data-hook + install-dvi: install-dvi-am diff --git a/package/automake/gtk-doc.m4 b/package/automake/gtk-doc.m4 new file mode 100644 index 0000000..3675543 --- /dev/null +++ b/package/automake/gtk-doc.m4 @@ -0,0 +1,88 @@ +dnl -*- mode: autoconf -*- + +# serial 2 + +dnl Usage: +dnl GTK_DOC_CHECK([minimum-gtk-doc-version]) +AC_DEFUN([GTK_DOC_CHECK], +[ + AC_REQUIRE([PKG_PROG_PKG_CONFIG]) + AC_BEFORE([AC_PROG_LIBTOOL],[$0])dnl setup libtool first + AC_BEFORE([AM_PROG_LIBTOOL],[$0])dnl setup libtool first + + ifelse([$1],[],[gtk_doc_requires="gtk-doc"],[gtk_doc_requires="gtk-doc >= $1"]) + AC_MSG_CHECKING([for gtk-doc]) + PKG_CHECK_EXISTS([$gtk_doc_requires],[have_gtk_doc=yes],[have_gtk_doc=no]) + AC_MSG_RESULT($have_gtk_doc) + + if test "$have_gtk_doc" = "no"; then + AC_MSG_WARN([ + You will not be able to create source packages with 'make dist' + because $gtk_doc_requires is not found.]) + fi + + dnl check for tools we added during development + dnl Use AC_CHECK_PROG to avoid the check target using an absolute path that + dnl may not be writable by the user. Currently, automake requires that the + dnl test name must end in '.test'. + dnl https://bugzilla.gnome.org/show_bug.cgi?id=701638 + AC_CHECK_PROG([GTKDOC_CHECK],[gtkdoc-check],[gtkdoc-check.test]) + AC_PATH_PROG([GTKDOC_CHECK_PATH],[gtkdoc-check]) + AC_PATH_PROGS([GTKDOC_REBASE],[gtkdoc-rebase],[true]) + AC_PATH_PROG([GTKDOC_MKPDF],[gtkdoc-mkpdf]) + + dnl for overriding the documentation installation directory + AC_ARG_WITH([html-dir], + AS_HELP_STRING([--with-html-dir=PATH], [path to installed docs]),, + [with_html_dir='${datadir}/gtk-doc/html']) + HTML_DIR="$with_html_dir" + AC_SUBST([HTML_DIR]) + + dnl enable/disable documentation building + AC_ARG_ENABLE([gtk-doc], + AS_HELP_STRING([--enable-gtk-doc], + [use gtk-doc to build documentation [[default=no]]]),, + [enable_gtk_doc=no]) + + AC_MSG_CHECKING([whether to build gtk-doc documentation]) + AC_MSG_RESULT($enable_gtk_doc) + + if test "x$enable_gtk_doc" = "xyes" && test "$have_gtk_doc" = "no"; then + AC_MSG_ERROR([ + You must have $gtk_doc_requires installed to build documentation for + $PACKAGE_NAME. Please install gtk-doc or disable building the + documentation by adding '--disable-gtk-doc' to '[$]0'.]) + fi + + dnl don't check for glib if we build glib + if test "x$PACKAGE_NAME" != "xglib"; then + dnl don't fail if someone does not have glib + PKG_CHECK_MODULES(GTKDOC_DEPS, glib-2.0 >= 2.10.0 gobject-2.0 >= 2.10.0,,[:]) + fi + + dnl enable/disable output formats + AC_ARG_ENABLE([gtk-doc-html], + AS_HELP_STRING([--enable-gtk-doc-html], + [build documentation in html format [[default=yes]]]),, + [enable_gtk_doc_html=yes]) + AC_ARG_ENABLE([gtk-doc-pdf], + AS_HELP_STRING([--enable-gtk-doc-pdf], + [build documentation in pdf format [[default=no]]]),, + [enable_gtk_doc_pdf=no]) + + if test -z "$GTKDOC_MKPDF"; then + enable_gtk_doc_pdf=no + fi + + if test -z "$AM_DEFAULT_VERBOSITY"; then + AM_DEFAULT_VERBOSITY=1 + fi + AC_SUBST([AM_DEFAULT_VERBOSITY]) + + AM_CONDITIONAL([HAVE_GTK_DOC], [test x$have_gtk_doc = xyes]) + AM_CONDITIONAL([ENABLE_GTK_DOC], [test x$enable_gtk_doc = xyes]) + AM_CONDITIONAL([GTK_DOC_BUILD_HTML], [test x$enable_gtk_doc_html = xyes]) + AM_CONDITIONAL([GTK_DOC_BUILD_PDF], [test x$enable_gtk_doc_pdf = xyes]) + AM_CONDITIONAL([GTK_DOC_USE_LIBTOOL], [test -n "$LIBTOOL"]) + AM_CONDITIONAL([GTK_DOC_USE_REBASE], [test -n "$GTKDOC_REBASE"]) +]) diff --git a/package/automake/make-host.sh b/package/automake/make-host.sh new file mode 100755 index 0000000..24f1906 --- /dev/null +++ b/package/automake/make-host.sh @@ -0,0 +1,43 @@ +#!/usr/bin/bash +source $(dirname "$0")/../common.sh + +PKGNAME=automake +PKGVERSION=1.16.5 +PKGSOURCE_DIR=automake +PKGSOURCE=automake-1.16.5.tar.xz +PKGURL=http://mirrors.ustc.edu.cn/gnu/automake/automake-1.16.5.tar.xz + +PKGBUILDNAME=host-${PKGNAME} +PKGBUILD_DIR=${BUILD_DIR}/${PKGBUILDNAME}-${PKGVERSION} + +echo "----> Building ${PKGBUILDNAME} ..." + +stamp_downloaded + +step_start extract +mkdir -p ${PKGBUILD_DIR} +xzcat ${DL_DIR}/${PKGSOURCE_DIR}/${PKGSOURCE} | tar --strip-components=1 -C ${PKGBUILD_DIR} -xf - +chmod -R +rw ${PKGBUILD_DIR} +step_end extract + +step_start patch +TAR="tar" PATH=${HOST_DIR}/bin:$PATH ${PROJECT_DIR}/support/scripts/apply-patches.sh ${PKGBUILD_DIR} ${PROJECT_DIR}/package/${PKGNAME} \*.patch +step_end patch autotools + +step_start configure +(cd ${PKGBUILD_DIR} && rm -rf config.cache; eval "${HOST_CONFIGURE_OPTS} CONFIG_SITE=/dev/null ./configure --prefix=\"${HOST_DIR}\" --sysconfdir=\"${HOST_DIR}/etc\" --localstatedir=\"${HOST_DIR}/var\" --enable-shared --disable-static --disable-gtk-doc --disable-gtk-doc-html --disable-doc --disable-docs --disable-documentation --disable-debug --with-xmlto=no --with-fop=no --disable-nls --disable-dependency-tracking") +step_end configure + +step_start build +eval "${HOST_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} -C ${PKGBUILD_DIR}" +step_end build + +step_start install-host +eval "${HOST_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} install -C ${PKGBUILD_DIR}" +/usr/bin/install -D -m 0644 ${PROJECT_DIR}/package/automake/gtk-doc.m4 ${HOST_DIR}/share/aclocal/gtk-doc.m4 +mkdir -p ${STAGING_DIR}/usr/share/aclocal +step_end install-host + +stamp_installed + +echo "<---- ${PKGBUILDNAME} build complete." diff --git a/package/binutils/2.43.1/0001-sh-conf.patch b/package/binutils/2.43.1/0001-sh-conf.patch new file mode 100644 index 0000000..c381017 --- /dev/null +++ b/package/binutils/2.43.1/0001-sh-conf.patch @@ -0,0 +1,50 @@ +From d71fb5a9999ee7c8963342caa0d5cbb16872ab07 Mon Sep 17 00:00:00 2001 +From: Romain Naour +Date: Fri, 25 Dec 2015 11:38:13 +0100 +Subject: [PATCH] sh-conf + +Likewise, binutils has no idea about any of these new targets either, so we +fix that up too.. now we're able to actually build a real toolchain for +sh2a_nofpu- and other more ineptly named toolchains (and yes, there are more +inept targets than that one, really. Go look, I promise). + +Upstream: N/A [Buildroot specific] + +[Romain: rebase on top of 2.32] +Signed-off-by: Romain Naour +[Thomas: rebase on top of 2.29, in which sh64 support was removed.] +Signed-off-by: Thomas Petazzoni +--- + configure | 2 +- + configure.ac | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/configure b/configure +index 670684d83d1..967c6708a0c 100755 +--- a/configure ++++ b/configure +@@ -4042,7 +4042,7 @@ case "${target}" in + nvptx*-*-*) + noconfigdirs="$noconfigdirs target-libssp target-libstdc++-v3 target-libobjc" + ;; +- sh-*-*) ++ sh*-*-*) + case "${target}" in + sh*-*-elf) + ;; +diff --git a/configure.ac b/configure.ac +index 88b4800e298..2c8d08ff6ec 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -1269,7 +1269,7 @@ case "${target}" in + nvptx*-*-*) + noconfigdirs="$noconfigdirs target-libssp target-libstdc++-v3 target-libobjc" + ;; +- sh-*-*) ++ sh*-*-*) + case "${target}" in + sh*-*-elf) + ;; +-- +2.43.0 + diff --git a/package/binutils/2.43.1/0002-poison-system-directories.patch b/package/binutils/2.43.1/0002-poison-system-directories.patch new file mode 100644 index 0000000..8da0ec3 --- /dev/null +++ b/package/binutils/2.43.1/0002-poison-system-directories.patch @@ -0,0 +1,307 @@ +From 00f6b0a7d31085831429834b2bc8f511b8fab6ce Mon Sep 17 00:00:00 2001 +From: Romain Naour +Date: Fri, 25 Dec 2015 11:45:38 +0100 +Subject: [PATCH] poison-system-directories + +Patch adapted to binutils 2.23.2 and extended to use +BR_COMPILER_PARANOID_UNSAFE_PATH by Thomas Petazzoni. + +[Waldemar: rebase on top of 2.43] +Signed-off-by: Waldemar Brodkorb +[Waldemar: rebase on top of 2.39] +Signed-off-by: Waldemar Brodkorb +[Romain: rebase on top of 2.33.1] +Signed-off-by: Romain Naour +[Gustavo: adapt to binutils 2.25] +Signed-off-by: Thomas Petazzoni +Signed-off-by: Gustavo Zacarias + +Upstream-Status: Inappropriate [distribution: codesourcery] +Upstream: N/A [Buildroot specific] + +Patch originally created by Mark Hatle, forward-ported to +binutils 2.21 by Scott Garman. + +purpose: warn for uses of system directories when cross linking + +Code Merged from Sourcery G++ binutils 2.19 - 4.4-277 + +2008-07-02 Joseph Myers + + ld/ + * ld.h (args_type): Add error_poison_system_directories. + * ld.texinfo (--error-poison-system-directories): Document. + * ldfile.c (ldfile_add_library_path): Check + command_line.error_poison_system_directories. + * ldmain.c (main): Initialize + command_line.error_poison_system_directories. + * lexsup.c (enum option_values): Add + OPTION_ERROR_POISON_SYSTEM_DIRECTORIES. + (ld_options): Add --error-poison-system-directories. + (parse_args): Handle new option. + +2007-06-13 Joseph Myers + + ld/ + * config.in: Regenerate. + * ld.h (args_type): Add poison_system_directories. + * ld.texinfo (--no-poison-system-directories): Document. + * ldfile.c (ldfile_add_library_path): Check + command_line.poison_system_directories. + * ldmain.c (main): Initialize + command_line.poison_system_directories. + * lexsup.c (enum option_values): Add + OPTION_NO_POISON_SYSTEM_DIRECTORIES. + (ld_options): Add --no-poison-system-directories. + (parse_args): Handle new option. + +2007-04-20 Joseph Myers + + Merge from Sourcery G++ binutils 2.17: + + 2007-03-20 Joseph Myers + Based on patch by Mark Hatle . + ld/ + * configure.ac (--enable-poison-system-directories): New option. + * configure, config.in: Regenerate. + * ldfile.c (ldfile_add_library_path): If + ENABLE_POISON_SYSTEM_DIRECTORIES defined, warn for use of /lib, + /usr/lib, /usr/local/lib or /usr/X11R6/lib. + +Signed-off-by: Mark Hatle +Signed-off-by: Scott Garman +--- + ld/config.in | 3 +++ + ld/configure | 14 ++++++++++++++ + ld/configure.ac | 10 ++++++++++ + ld/ld.h | 8 ++++++++ + ld/ld.texi | 12 ++++++++++++ + ld/ldfile.c | 17 +++++++++++++++++ + ld/ldlex.h | 2 ++ + ld/ldmain.c | 2 ++ + ld/lexsup.c | 21 +++++++++++++++++++++ + 9 files changed, 89 insertions(+) + +diff --git a/ld/config.in b/ld/config.in +index f7c9da3d02a..e4fdbf6db5b 100644 +--- a/ld/config.in ++++ b/ld/config.in +@@ -74,6 +74,9 @@ + language is requested. */ + #undef ENABLE_NLS + ++/* Define to warn for use of native system library directories */ ++#undef ENABLE_POISON_SYSTEM_DIRECTORIES ++ + /* Additional extension a shared object might have. */ + #undef EXTRA_SHLIB_EXTENSION + +diff --git a/ld/configure b/ld/configure +index 44d79c2445d..e28cea11977 100755 +--- a/ld/configure ++++ b/ld/configure +@@ -844,6 +844,7 @@ with_lib_path + enable_targets + enable_64_bit_bfd + with_sysroot ++enable_poison_system_directories + enable_gold + enable_got + enable_compressed_debug_sections +@@ -1535,6 +1536,8 @@ Optional Features: + --enable-checking enable run-time checks + --enable-targets alternative target configurations + --enable-64-bit-bfd 64-bit support (on hosts with narrower word sizes) ++ --enable-poison-system-directories ++ warn for use of native system library directories + --enable-gold[=ARG] build gold [ARG={default,yes,no}] + --enable-got= GOT handling scheme (target, single, negative, + multigot) +@@ -15587,7 +15590,18 @@ else + fi + + ++# Check whether --enable-poison-system-directories was given. ++if test "${enable_poison_system_directories+set}" = set; then : ++ enableval=$enable_poison_system_directories; ++else ++ enable_poison_system_directories=no ++fi ++ ++if test "x${enable_poison_system_directories}" = "xyes"; then + ++$as_echo "#define ENABLE_POISON_SYSTEM_DIRECTORIES 1" >>confdefs.h ++ ++fi + + # Check whether --enable-got was given. + if test "${enable_got+set}" = set; then : +diff --git a/ld/configure.ac b/ld/configure.ac +index bdf51a062fa..3d370ff92ce 100644 +--- a/ld/configure.ac ++++ b/ld/configure.ac +@@ -102,6 +102,16 @@ AC_SUBST(use_sysroot) + AC_SUBST(TARGET_SYSTEM_ROOT) + AC_SUBST(TARGET_SYSTEM_ROOT_DEFINE) + ++AC_ARG_ENABLE([poison-system-directories], ++ AS_HELP_STRING([--enable-poison-system-directories], ++ [warn for use of native system library directories]),, ++ [enable_poison_system_directories=no]) ++if test "x${enable_poison_system_directories}" = "xyes"; then ++ AC_DEFINE([ENABLE_POISON_SYSTEM_DIRECTORIES], ++ [1], ++ [Define to warn for use of native system library directories]) ++fi ++ + dnl Use --enable-gold to decide if this linker should be the default. + dnl "install_as_default" is set to false if gold is the default linker. + dnl "installed_linker" is the installed BFD linker name. +diff --git a/ld/ld.h b/ld/ld.h +index 0dee944cf2a..83bd82d2a2e 100644 +--- a/ld/ld.h ++++ b/ld/ld.h +@@ -166,6 +166,14 @@ typedef struct + in the linker script. */ + bool force_group_allocation; + ++ /* If TRUE (the default) warn for uses of system directories when ++ cross linking. */ ++ bool poison_system_directories; ++ ++ /* If TRUE (default FALSE) give an error for uses of system ++ directories when cross linking instead of a warning. */ ++ bool error_poison_system_directories; ++ + /* Big or little endian as set on command line. */ + enum endian_enum endian; + +diff --git a/ld/ld.texi b/ld/ld.texi +index 89e3913317a..b80cf05617f 100644 +--- a/ld/ld.texi ++++ b/ld/ld.texi +@@ -3234,6 +3234,18 @@ string identifying the original linked file does not change. + Passing @code{none} for @var{style} disables the setting from any + @code{--build-id} options earlier on the command line. + ++@kindex --no-poison-system-directories ++@item --no-poison-system-directories ++Do not warn for @option{-L} options using system directories such as ++@file{/usr/lib} when cross linking. This option is intended for use ++in chroot environments when such directories contain the correct ++libraries for the target system rather than the host. ++ ++@kindex --error-poison-system-directories ++@item --error-poison-system-directories ++Give an error instead of a warning for @option{-L} options using ++system directories when cross linking. ++ + @kindex --package-metadata=@var{JSON} + @item --package-metadata=@var{JSON} + Request the creation of a @code{.note.package} ELF note section. The +diff --git a/ld/ldfile.c b/ld/ldfile.c +index 87be885d31a..9bc7adca4bc 100644 +--- a/ld/ldfile.c ++++ b/ld/ldfile.c +@@ -327,6 +327,22 @@ ldfile_add_library_path (const char *name, enum search_dir_source source) + else + new_dirs->name = xstrdup (name); + ++#ifdef ENABLE_POISON_SYSTEM_DIRECTORIES ++ if (command_line.poison_system_directories ++ && ((!strncmp (name, "/lib", 4)) ++ || (!strncmp (name, "/usr/lib", 8)) ++ || (!strncmp (name, "/usr/local/lib", 14)) ++ || (!strncmp (name, "/usr/X11R6/lib", 14)))) ++ { ++ if (command_line.error_poison_system_directories) ++ einfo (_("%X%P: error: library search path \"%s\" is unsafe for " ++ "cross-compilation\n"), name); ++ else ++ einfo (_("%P: warning: library search path \"%s\" is unsafe for " ++ "cross-compilation\n"), name); ++ } ++#endif ++ + /* Accumulate script and command line sourced + search paths at the end of the current list. */ + #if BFD_SUPPORTS_PLUGINS +diff --git a/ld/ldlex.h b/ld/ldlex.h +index defe3fcbbb9..0ff12614926 100644 +--- a/ld/ldlex.h ++++ b/ld/ldlex.h +@@ -170,6 +170,8 @@ enum option_values + OPTION_CTF_VARIABLES, + OPTION_NO_CTF_VARIABLES, + OPTION_CTF_SHARE_TYPES, ++ OPTION_NO_POISON_SYSTEM_DIRECTORIES, ++ OPTION_ERROR_POISON_SYSTEM_DIRECTORIES, + OPTION_ERROR_EXECSTACK, + OPTION_NO_ERROR_EXECSTACK, + OPTION_WARN_EXECSTACK_OBJECTS, +diff --git a/ld/ldmain.c b/ld/ldmain.c +index 037099b9d37..204feedc6e3 100644 +--- a/ld/ldmain.c ++++ b/ld/ldmain.c +@@ -347,6 +347,8 @@ main (int argc, char **argv) + command_line.warn_mismatch = true; + command_line.warn_search_mismatch = true; + command_line.check_section_addresses = -1; ++ command_line.poison_system_directories = true; ++ command_line.error_poison_system_directories = false; + + /* We initialize DEMANGLING based on the environment variable + COLLECT_NO_DEMANGLE. The gcc collect2 program will demangle the +diff --git a/ld/lexsup.c b/ld/lexsup.c +index 4aa0124ce2f..c4d76943821 100644 +--- a/ld/lexsup.c ++++ b/ld/lexsup.c +@@ -648,6 +648,14 @@ static const struct ld_option ld_options[] = + " is: share-unconflicted (default),\n" + " share-duplicated"), + TWO_DASHES }, ++ { {"no-poison-system-directories", no_argument, NULL, ++ OPTION_NO_POISON_SYSTEM_DIRECTORIES}, ++ '\0', NULL, N_("Do not warn for -L options using system directories"), ++ TWO_DASHES }, ++ { {"error-poison-system-directories", no_argument, NULL, ++ OPTION_ERROR_POISON_SYSTEM_DIRECTORIES}, ++ '\0', NULL, N_("Give an error for -L options using system directories"), ++ TWO_DASHES }, + }; + + #define OPTION_COUNT ARRAY_SIZE (ld_options) +@@ -660,6 +668,7 @@ parse_args (unsigned argc, char **argv) + int ingroup = 0; + char *default_dirlist = NULL; + char *shortopts; ++ char *BR_paranoid_env; + struct option *longopts; + struct option *really_longopts; + int last_optind; +@@ -1785,6 +1794,14 @@ parse_args (unsigned argc, char **argv) + } + break; + ++ case OPTION_NO_POISON_SYSTEM_DIRECTORIES: ++ command_line.poison_system_directories = false; ++ break; ++ ++ case OPTION_ERROR_POISON_SYSTEM_DIRECTORIES: ++ command_line.error_poison_system_directories = true; ++ break; ++ + case OPTION_PUSH_STATE: + input_flags.pushed = xmemdup (&input_flags, + sizeof (input_flags), +@@ -1938,6 +1955,10 @@ parse_args (unsigned argc, char **argv) + command_line.soname = NULL; + } + ++ BR_paranoid_env = getenv("BR_COMPILER_PARANOID_UNSAFE_PATH"); ++ if (BR_paranoid_env && strlen(BR_paranoid_env) > 0) ++ command_line.error_poison_system_directories = true; ++ + while (ingroup) + { + einfo (_("%P: missing --end-group; added as last command line option\n")); diff --git a/package/binutils/2.43.1/0003-objdump-memleak.patch b/package/binutils/2.43.1/0003-objdump-memleak.patch new file mode 100644 index 0000000..1b16320 --- /dev/null +++ b/package/binutils/2.43.1/0003-objdump-memleak.patch @@ -0,0 +1,31 @@ +From ba6ad3a18cb26b79e0e3b84c39f707535bbc344d Mon Sep 17 00:00:00 2001 +From: Alan Modra +Date: Wed, 19 Feb 2025 07:58:54 +1030 +Subject: [PATCH] PR32716, objdump -i memory leak + +PR binutils/32716 +* bucomm.c (display_info): Free arg.info. + +Upstream: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ba6ad3a18cb26b79e0e3b84c39f707535bbc344d + +CVE: CVE-2025-3198 +Signed-off-by: Titouan Christophe +--- + binutils/bucomm.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/binutils/bucomm.c b/binutils/bucomm.c +index ccf54099154..d4554737db1 100644 +--- a/binutils/bucomm.c ++++ b/binutils/bucomm.c +@@ -435,6 +435,7 @@ display_info (void) + if (!arg.error) + display_target_tables (&arg); + ++ free (arg.info); + return arg.error; + } + +-- +2.43.5 + diff --git a/package/binutils/2.43.1/0004-opcodes-fix-std-gnu23-compatibility-wrt-static_asser.patch b/package/binutils/2.43.1/0004-opcodes-fix-std-gnu23-compatibility-wrt-static_asser.patch new file mode 100644 index 0000000..f9b870a --- /dev/null +++ b/package/binutils/2.43.1/0004-opcodes-fix-std-gnu23-compatibility-wrt-static_asser.patch @@ -0,0 +1,90 @@ +From 8ebe62f3f0d27806b1bf69f301f5e188b4acd2b4 Mon Sep 17 00:00:00 2001 +From: Sam James +Date: Sat, 16 Nov 2024 05:03:52 +0000 +Subject: [PATCH] opcodes: fix -std=gnu23 compatibility wrt static_assert + +static_assert is declared in C23 so we can't reuse that identifier: +* Define our own static_assert conditionally; + +* Rename "static assert" hacks to _N as we do already in some places + to avoid a conflict. + +ChangeLog: + PR ld/32372 + + * i386-gen.c (static_assert): Define conditionally. + * mips-formats.h (MAPPED_INT): Rename identifier. + (MAPPED_REG): Rename identifier. + (OPTIONAL_MAPPED_REG): Rename identifier. + * s390-opc.c (static_assert): Define conditionally. + +Upstream: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=8ebe62f3f0d27806b1bf69f301f5e188b4acd2b4 +Signed-off-by: Raphaël Mélotte +--- + opcodes/i386-gen.c | 2 ++ + opcodes/mips-formats.h | 6 +++--- + opcodes/s390-opc.c | 2 ++ + 3 files changed, 7 insertions(+), 3 deletions(-) + +diff --git a/opcodes/i386-gen.c b/opcodes/i386-gen.c +index 053b66675c5..7ee8a30310c 100644 +--- a/opcodes/i386-gen.c ++++ b/opcodes/i386-gen.c +@@ -30,7 +30,9 @@ + + /* Build-time checks are preferrable over runtime ones. Use this construct + in preference where possible. */ ++#ifndef static_assert + #define static_assert(e) ((void)sizeof (struct { int _:1 - 2 * !(e); })) ++#endif + + static const char *program_name = NULL; + static int debug = 0; +diff --git a/opcodes/mips-formats.h b/opcodes/mips-formats.h +index 90df7100803..c4dec6352bf 100644 +--- a/opcodes/mips-formats.h ++++ b/opcodes/mips-formats.h +@@ -49,7 +49,7 @@ + #define MAPPED_INT(SIZE, LSB, MAP, PRINT_HEX) \ + { \ + typedef char ATTRIBUTE_UNUSED \ +- static_assert[(1 << (SIZE)) == ARRAY_SIZE (MAP)]; \ ++ static_assert_3[(1 << (SIZE)) == ARRAY_SIZE (MAP)]; \ + static const struct mips_mapped_int_operand op = { \ + { OP_MAPPED_INT, SIZE, LSB }, MAP, PRINT_HEX \ + }; \ +@@ -83,7 +83,7 @@ + #define MAPPED_REG(SIZE, LSB, BANK, MAP) \ + { \ + typedef char ATTRIBUTE_UNUSED \ +- static_assert[(1 << (SIZE)) == ARRAY_SIZE (MAP)]; \ ++ static_assert_4[(1 << (SIZE)) == ARRAY_SIZE (MAP)]; \ + static const struct mips_reg_operand op = { \ + { OP_REG, SIZE, LSB }, OP_REG_##BANK, MAP \ + }; \ +@@ -93,7 +93,7 @@ + #define OPTIONAL_MAPPED_REG(SIZE, LSB, BANK, MAP) \ + { \ + typedef char ATTRIBUTE_UNUSED \ +- static_assert[(1 << (SIZE)) == ARRAY_SIZE (MAP)]; \ ++ static_assert_5[(1 << (SIZE)) == ARRAY_SIZE (MAP)]; \ + static const struct mips_reg_operand op = { \ + { OP_OPTIONAL_REG, SIZE, LSB }, OP_REG_##BANK, MAP \ + }; \ +diff --git a/opcodes/s390-opc.c b/opcodes/s390-opc.c +index 9d9f0973e55..49efd714157 100644 +--- a/opcodes/s390-opc.c ++++ b/opcodes/s390-opc.c +@@ -36,7 +36,9 @@ + + /* Build-time checks are preferrable over runtime ones. Use this construct + in preference where possible. */ ++#ifndef static_assert + #define static_assert(e) ((void)sizeof (struct { int _:1 - 2 * !(e); })) ++#endif + + #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) + +-- +2.34.1 + diff --git a/package/binutils/2.43.1/0005-Fix-32097-Warnings-when-building-gprofng-with-Clang.patch b/package/binutils/2.43.1/0005-Fix-32097-Warnings-when-building-gprofng-with-Clang.patch new file mode 100644 index 0000000..1f28137 --- /dev/null +++ b/package/binutils/2.43.1/0005-Fix-32097-Warnings-when-building-gprofng-with-Clang.patch @@ -0,0 +1,801 @@ +From 3e8c6e03675963d65a2f98eb006336c5cd375ec3 Mon Sep 17 00:00:00 2001 +From: Vladimir Mezentsev +Date: Tue, 3 Sep 2024 21:30:31 -0700 +Subject: [PATCH] Fix 32097 Warnings when building gprofng with Clang + +gprofng/ChangeLog +2024-09-03 Vladimir Mezentsev . + + PR gprofng/32097 + * common/hwcdrv.c: Fix -Wempty-body warnings. + * common/hwcentry.h: Fix -Wdeprecated-non-prototype warnings. + * common/hwctable.c: Fix -Wdeprecated-non-prototype warnings. + * libcollector/collector.c: Likewise. + * libcollector/collector.h: Likewise. + * libcollector/collectorAPI.c: Likewise. + * libcollector/dispatcher.c: Likewise. + * libcollector/iotrace.c: Likewise. + * libcollector/libcol_util.c: Fix -Wunused-but-set-variable warnings. + * libcollector/libcol_util.h: Remove unused declarations. + * libcollector/linetrace.c: Fix -Wdeprecated-non-prototype warnings. + * src/BaseMetricTreeNode.h: Fix -Wunused-private-field warnings. + * src/Dbe.cc: Fix -Wself-assign warnings. + * src/DbeSession.cc: Fix -Wunused-but-set-variable warnings. + * src/Disasm.cc: Fix -Wunused-const-variable warnings. + * src/Experiment.cc: Fix -Wunused-private-field warnings. + * src/HashMap.h: Fix -Wself-assign warnings. + * src/IOActivity.h: Fix -Wunused-private-field warnings. + * src/collctrl.cc: Fix -Wself-assign, -Wparentheses-equality warnings. + * src/collctrl.h: Fix -Wunused-private-field warnings. + * src/collector_module.h: Fix -Wdeprecated-non-prototype warnings. + * src/gp-display-src.cc: Fix -Wunused-private-field warnings. + * src/gp-print.h: Fix -Wheader-guard warnings. + * src/hwc_intel_icelake.h: Fix -Winitializer-overrides warnings. + * src/util.cc: Fix -Wunused-but-set-variable warnings. + +Upstream: b79c457ca01df82dbe1facb708e45def4584c903 +Signed-off-by: Thomas Petazzoni +--- + gprofng/common/hwcdrv.c | 3 ++- + gprofng/common/hwcentry.h | 7 +---- + gprofng/common/hwctable.c | 13 +--------- + gprofng/libcollector/collector.c | 15 ++++------- + gprofng/libcollector/collector.h | 2 +- + gprofng/libcollector/collectorAPI.c | 15 ++++++----- + gprofng/libcollector/dispatcher.c | 19 ++++++++------ + gprofng/libcollector/iotrace.c | 12 ++++----- + gprofng/libcollector/libcol_util.c | 2 -- + gprofng/libcollector/libcol_util.h | 6 ----- + gprofng/libcollector/linetrace.c | 40 +++++++++++++++++------------ + gprofng/src/BaseMetricTreeNode.h | 1 - + gprofng/src/Dbe.cc | 12 ++++----- + gprofng/src/DbeSession.cc | 3 --- + gprofng/src/Disasm.cc | 1 - + gprofng/src/Experiment.cc | 2 -- + gprofng/src/HashMap.h | 3 +-- + gprofng/src/IOActivity.h | 1 - + gprofng/src/collctrl.cc | 14 +++++----- + gprofng/src/collctrl.h | 1 - + gprofng/src/collector_module.h | 20 +++++++-------- + gprofng/src/gp-display-src.cc | 8 ------ + gprofng/src/gp-print.h | 2 +- + gprofng/src/hwc_intel_icelake.h | 6 +++-- + gprofng/src/util.cc | 10 +++----- + 25 files changed, 88 insertions(+), 130 deletions(-) + +diff --git a/gprofng/common/hwcdrv.c b/gprofng/common/hwcdrv.c +index aaf3acdf9cd..51492a8d35c 100644 +--- a/gprofng/common/hwcdrv.c ++++ b/gprofng/common/hwcdrv.c +@@ -574,6 +574,7 @@ read_sample (counter_state_t *ctr_state, int msgsz, uint64_t *rvalue, + static void + dump_perf_event_attr (struct perf_event_attr *at) + { ++#if defined(DEBUG) + TprintfT (DBG_LT2, "dump_perf_event_attr: size=%d type=%d sample_period=%lld\n" + " config=0x%llx config1=0x%llx config2=0x%llx wakeup_events=%lld __reserved_1=%lld\n", + (int) at->size, (int) at->type, (unsigned long long) at->sample_period, +@@ -589,13 +590,13 @@ dump_perf_event_attr (struct perf_event_attr *at) + DUMP_F (exclude_kernel); + DUMP_F (exclude_hv); + DUMP_F (exclude_idle); +- // DUMP_F(xmmap); + DUMP_F (comm); + DUMP_F (freq); + DUMP_F (inherit_stat); + DUMP_F (enable_on_exec); + DUMP_F (task); + DUMP_F (watermark); ++#endif + } + + static void +diff --git a/gprofng/common/hwcentry.h b/gprofng/common/hwcentry.h +index b2ab8b9b22c..0b923fc3576 100644 +--- a/gprofng/common/hwcentry.h ++++ b/gprofng/common/hwcentry.h +@@ -200,17 +200,12 @@ extern "C" + extern char *hwc_get_docref (char *buf, size_t buflen); + /* Return a CPU HWC document reference, or NULL. */ + +- // TBR +- extern char *hwc_get_default_cntrs (); +- /* Return a default HW counter string; may be NULL, or zero-length */ +- /* NULL means none is defined in the table; or zero-length means string defined could not be loaded */ +- + extern char *hwc_get_default_cntrs2 (int forKernel, int style); + /* like hwc_get_default_cntrs() for style==1 */ + /* but allows other styles of formatting as well */ + /* deprecate and eventually remove hwc_get_default_cntrs() */ + +- extern char *hwc_get_orig_default_cntrs (); ++ extern char *hwc_get_orig_default_cntrs (int forKernel); + /* Get the default HW counter string as set in the table */ + /* NULL means none is defined in the table */ + +diff --git a/gprofng/common/hwctable.c b/gprofng/common/hwctable.c +index 0baf63b1805..338a1ea86f4 100644 +--- a/gprofng/common/hwctable.c ++++ b/gprofng/common/hwctable.c +@@ -1783,7 +1783,7 @@ check_tables () + } + #endif + +-static int try_a_counter (); ++static int try_a_counter (int forKernel); + static void hwc_process_raw_ctrs (int forKernel, Hwcentry ***pstd_out, + Hwcentry ***praw_out, Hwcentry ***phidden_out, + Hwcentry**static_tables, +@@ -2824,17 +2824,6 @@ hwc_get_docref (char *buf, size_t buflen) + return buf; + } + +-//TBR: +- +-extern char* +-hwc_get_default_cntrs () +-{ +- setup_cpcx (); +- if (cpcx_default_hwcs[0] != NULL) +- return strdup (cpcx_default_hwcs[0]); // TBR deprecate this +- return NULL; +-} +- + extern char* + hwc_get_default_cntrs2 (int forKernel, int style) + { +diff --git a/gprofng/libcollector/collector.c b/gprofng/libcollector/collector.c +index 3a8f27a719d..2ff95e58fde 100644 +--- a/gprofng/libcollector/collector.c ++++ b/gprofng/libcollector/collector.c +@@ -210,15 +210,10 @@ get_collector_interface () + static void + collector_module_init (CollectorInterface *col_intf) + { +- int nmodules = 0; +- + ModuleInitFunc next_init = (ModuleInitFunc) dlsym (RTLD_DEFAULT, "__collector_module_init"); + if (next_init != NULL) +- { +- nmodules++; +- next_init (col_intf); +- } +- TprintfT (DBG_LT1, "collector_module_init: %d modules\n", nmodules); ++ next_init (col_intf); ++ TprintfT (DBG_LT1, "collector_module_init: %d modules\n", next_init ? 1 : 0); + } + + /* Routines concerned with general experiment start and stop */ +@@ -1783,7 +1778,7 @@ __collector_pause () + } + + void +-__collector_pause_m (char *reason) ++__collector_pause_m (const char *reason) + { + hrtime_t now; + char xreason[MAXPATHLEN]; +@@ -2449,8 +2444,8 @@ __collector_dlog (int tflag, int level, char *format, ...) + + static void (*__real__exit) (int status) = NULL; /* libc only: _exit */ + static void (*__real__Exit) (int status) = NULL; /* libc only: _Exit */ +-void _exit () __attribute__ ((weak, alias ("__collector_exit"))); +-void _Exit () __attribute__ ((weak, alias ("__collector_Exit"))); ++void _exit (int status) __attribute__ ((weak, alias ("__collector_exit"))); ++void _Exit (int status) __attribute__ ((weak, alias ("__collector_Exit"))); + + void + __collector_exit (int status) +diff --git a/gprofng/libcollector/collector.h b/gprofng/libcollector/collector.h +index 07a03bdd17a..eda68a0e4f5 100644 +--- a/gprofng/libcollector/collector.h ++++ b/gprofng/libcollector/collector.h +@@ -123,7 +123,7 @@ extern void __collector_terminate_expt (); + extern void __collector_terminate_hook (); + extern void __collector_sample (char *name); + extern void __collector_pause (); +-extern void __collector_pause_m (); ++extern void __collector_pause_m (const char *reason); + extern void __collector_resume (); + extern int collector_sigemt_sigaction (const struct sigaction*, + struct sigaction*); +diff --git a/gprofng/libcollector/collectorAPI.c b/gprofng/libcollector/collectorAPI.c +index 5fa6403ad49..449bbbaab65 100644 +--- a/gprofng/libcollector/collectorAPI.c ++++ b/gprofng/libcollector/collectorAPI.c +@@ -26,16 +26,17 @@ + #include "collectorAPI.h" + #include "gp-experiment.h" + +-static void *__real_collector_sample = NULL; +-static void *__real_collector_pause = NULL; +-static void *__real_collector_resume = NULL; +-static void *__real_collector_terminate_expt = NULL; +-static void *__real_collector_func_load = NULL; +-static void *__real_collector_func_unload = NULL; ++static void (*__real_collector_sample)(const char *) = NULL; ++static void (*__real_collector_pause)() = NULL; ++static void (*__real_collector_resume)() = NULL; ++static void (*__real_collector_terminate_expt)() = NULL; ++static void (*__real_collector_func_load)(const char *, const char *, ++ const char *, void *, int, int, Lineno *) = NULL; ++static void (*__real_collector_func_unload)(void *) = NULL; + + #define INIT_API if (init_API == 0) collectorAPI_initAPI() + #define NULL_PTR(x) (__real_##x == NULL) +-#define CALL_REAL(x) (*(void(*)())__real_##x) ++#define CALL_REAL(x) (__real_##x) + #define CALL_IF_REAL(x) INIT_API; if (!NULL_PTR(x)) CALL_REAL(x) + + static int init_API = 0; +diff --git a/gprofng/libcollector/dispatcher.c b/gprofng/libcollector/dispatcher.c +index 8b8ad77b5ee..f7cd46e7e6b 100644 +--- a/gprofng/libcollector/dispatcher.c ++++ b/gprofng/libcollector/dispatcher.c +@@ -908,8 +908,9 @@ sigset (int sig, sighandler_t handler) + + // map interposed symbol versions + static int +-gprofng_timer_create (int (real_func) (), clockid_t clockid, +- struct sigevent *sevp, timer_t *timerid) ++gprofng_timer_create (int (real_func) (clockid_t, struct sigevent *, timer_t *), ++ clockid_t clockid, ++ struct sigevent *sevp, timer_t *timerid) + { + // collector reserves SIGPROF + if (sevp == NULL || sevp->sigev_notify != SIGEV_SIGNAL || +@@ -1044,7 +1045,7 @@ __collector_thr_sigsetmask (int how, const sigset_t* iset, sigset_t* oset) + // map interposed symbol versions + + static int +-gprofng_pthread_sigmask (int (real_func) (), ++gprofng_pthread_sigmask (int (real_func) (int, const sigset_t *, sigset_t*), + int how, const sigset_t *iset, sigset_t* oset) + { + sigset_t lsigset; +@@ -1139,9 +1140,10 @@ collector_root (void *cargs) + // map interposed symbol versions + + static int +-gprofng_pthread_create (int (real_func) (), pthread_t *thread, +- const pthread_attr_t *attr, +- void *(*func)(void*), void *arg) ++gprofng_pthread_create (int (real_func) (pthread_t *, const pthread_attr_t *, ++ void *(*)(void *), void *), ++ pthread_t *thread, const pthread_attr_t *attr, ++ void *(*func)(void*), void *arg) + { + TprintfT (DBG_LTT, "gprofng_pthread_create @%p\n", real_func); + if (dispatch_mode != DISPATCH_ON) +@@ -1276,6 +1278,7 @@ __collector_ext_clone_pthread (int (*fn)(void *), void *child_stack, int flags, + } + + // weak symbols: +-int sigprocmask () __attribute__ ((weak, alias ("__collector_sigprocmask"))); +-int thr_sigsetmask () __attribute__ ((weak, alias ("__collector_thr_sigsetmask"))); ++int sigprocmask (int, const sigset_t*, sigset_t*) __attribute__ ((weak, alias ("__collector_sigprocmask"))); ++int thr_sigsetmask (int, const sigset_t*, sigset_t*) __attribute__ ((weak, alias ("__collector_thr_sigsetmask"))); + int setitimer () __attribute__ ((weak, alias ("_setitimer"))); ++ +diff --git a/gprofng/libcollector/iotrace.c b/gprofng/libcollector/iotrace.c +index 18060864796..3deb441d9c7 100644 +--- a/gprofng/libcollector/iotrace.c ++++ b/gprofng/libcollector/iotrace.c +@@ -1350,7 +1350,7 @@ mkstemp (char *template) + unsigned pktSize; + if (NULL_PTR (mkstemp)) + init_io_intf (); +- if (CHCK_REENTRANCE (guard) || template == NULL) ++ if (CHCK_REENTRANCE (guard)) + return CALL_REAL (mkstemp)(template); + PUSH_REENTRANCE (guard); + hrtime_t reqt = gethrtime (); +@@ -1405,7 +1405,7 @@ mkstemps (char *template, int slen) + unsigned pktSize; + if (NULL_PTR (mkstemps)) + init_io_intf (); +- if (CHCK_REENTRANCE (guard) || template == NULL) ++ if (CHCK_REENTRANCE (guard)) + return CALL_REAL (mkstemps)(template, slen); + PUSH_REENTRANCE (guard); + hrtime_t reqt = gethrtime (); +@@ -1485,7 +1485,7 @@ close (int fildes) + + /*------------------------------------------------------------- fopen */ + static FILE* +-gprofng_fopen (FILE*(real_fopen) (), const char *filename, const char *mode) ++gprofng_fopen (FILE*(real_fopen) (const char *, const char *), const char *filename, const char *mode) + { + int *guard; + FILE *fp = NULL; +@@ -1559,7 +1559,7 @@ DCL_FOPEN (fopen) + + /*------------------------------------------------------------- fclose */ + static int +-gprofng_fclose (int(real_fclose) (), FILE *stream) ++gprofng_fclose (int(real_fclose) (FILE *), FILE *stream) + { + int *guard; + int stat; +@@ -1645,7 +1645,7 @@ fflush (FILE *stream) + + /*------------------------------------------------------------- fdopen */ + static FILE* +-gprofng_fdopen (FILE*(real_fdopen) (), int fildes, const char *mode) ++gprofng_fdopen (FILE*(real_fdopen) (int, const char *), int fildes, const char *mode) + { + int *guard; + FILE *fp = NULL; +@@ -2957,7 +2957,7 @@ DCL_FGETPOS (fgetpos) + + /*------------------------------------------------------------- fgetpos64 */ + static int +-gprofng_fgetpos64 (int(real_fgetpos64) (), FILE *stream, fpos64_t *pos) ++gprofng_fgetpos64 (int(real_fgetpos64) (FILE *, fpos64_t *), FILE *stream, fpos64_t *pos) + { + int *guard; + int ret; +diff --git a/gprofng/libcollector/libcol_util.c b/gprofng/libcollector/libcol_util.c +index 1e58cf491a1..baac15db5c4 100644 +--- a/gprofng/libcollector/libcol_util.c ++++ b/gprofng/libcollector/libcol_util.c +@@ -1013,7 +1013,6 @@ __collector_open (const char *path, int oflag, ...) + mode_t mode = 0; + + hrtime_t t_timeout = __collector_gethrtime () + 5 * ((hrtime_t) NANOSEC); +- int nretries = 0; + long long delay = 100; /* start at some small, arbitrary value */ + + /* get optional mode argument if it's expected/required */ +@@ -1058,7 +1057,6 @@ __collector_open (const char *path, int oflag, ...) + delay *= 2; + if (delay > 100000000) + delay = 100000000; /* cap at some large, arbitrary value */ +- nretries++; + } + return fd; + } +diff --git a/gprofng/libcollector/libcol_util.h b/gprofng/libcollector/libcol_util.h +index c8ec83ff0d9..aa30db72bcc 100644 +--- a/gprofng/libcollector/libcol_util.h ++++ b/gprofng/libcollector/libcol_util.h +@@ -81,12 +81,6 @@ extern int __collector_mutex_trylock (collector_mutex_t *mp); + #define __collector_mutex_init(xx) \ + do { collector_mutex_t tmp=COLLECTOR_MUTEX_INITIALIZER; *(xx)=tmp; } while(0) + +-void __collector_sample (char *name); +-void __collector_terminate_expt (); +-void __collector_pause (); +-void __collector_pause_m (); +-void __collector_resume (); +- + struct DT_lineno; + + typedef enum +diff --git a/gprofng/libcollector/linetrace.c b/gprofng/libcollector/linetrace.c +index 67b2d7e9030..66844bc1337 100644 +--- a/gprofng/libcollector/linetrace.c ++++ b/gprofng/libcollector/linetrace.c +@@ -1207,7 +1207,7 @@ __collector_vfork (void) + } + + /*------------------------------------------------------------- execve */ +-int execve () __attribute__ ((weak, alias ("__collector_execve"))); ++int execve (const char *, char *const [], char *const []) __attribute__ ((weak, alias ("__collector_execve"))); + + int + __collector_execve (const char* path, char *const argv[], char *const envp[]) +@@ -1237,7 +1237,7 @@ __collector_execve (const char* path, char *const argv[], char *const envp[]) + return ret; + } + +-int execvp () __attribute__ ((weak, alias ("__collector_execvp"))); ++int execvp (const char *, char *const []) __attribute__ ((weak, alias ("__collector_execvp"))); + + int + __collector_execvp (const char* file, char *const argv[]) +@@ -1269,7 +1269,7 @@ __collector_execvp (const char* file, char *const argv[]) + return ret; + } + +-int execv () __attribute__ ((weak, alias ("__collector_execv"))); ++int execv (const char *, char *const []) __attribute__ ((weak, alias ("__collector_execv"))); + + int + __collector_execv (const char* path, char *const argv[]) +@@ -1408,7 +1408,10 @@ __collector_execl (const char* path, const char *arg0, ...) + /*-------------------------------------------------------- posix_spawn */ + // map interposed symbol versions + static int +-gprofng_posix_spawn (int(real_posix_spawn) (), ++gprofng_posix_spawn (int(real_posix_spawn) (pid_t *, const char *, ++ const posix_spawn_file_actions_t *, ++ const posix_spawnattr_t *, ++ char *const [], char *const []), + pid_t *pidp, const char *path, + const posix_spawn_file_actions_t *file_actions, + const posix_spawnattr_t *attrp, +@@ -1466,7 +1469,10 @@ DCL_POSIX_SPAWN (posix_spawn) + + /*-------------------------------------------------------- posix_spawnp */ + static int +-gprofng_posix_spawnp (int (real_posix_spawnp) (), ++gprofng_posix_spawnp (int (real_posix_spawnp) (pid_t *, const char *, ++ const posix_spawn_file_actions_t *, ++ const posix_spawnattr_t *, ++ char *const [], char *const []), + pid_t *pidp, const char *path, + const posix_spawn_file_actions_t *file_actions, + const posix_spawnattr_t *attrp, +@@ -1754,8 +1760,8 @@ __collector_clone (int (*fn)(void *), void *child_stack, int flags, void *arg, + } + + /*-------------------------------------------------------------------- setuid */ +-int setuid () __attribute__ ((weak, alias ("__collector_setuid"))); +-int _setuid () __attribute__ ((weak, alias ("__collector_setuid"))); ++int setuid (uid_t) __attribute__ ((weak, alias ("__collector_setuid"))); ++int _setuid (uid_t) __attribute__ ((weak, alias ("__collector_setuid"))); + + int + __collector_setuid (uid_t ruid) +@@ -1770,8 +1776,8 @@ __collector_setuid (uid_t ruid) + } + + /*------------------------------------------------------------------- seteuid */ +-int seteuid () __attribute__ ((weak, alias ("__collector_seteuid"))); +-int _seteuid () __attribute__ ((weak, alias ("__collector_seteuid"))); ++int seteuid (uid_t) __attribute__ ((weak, alias ("__collector_seteuid"))); ++int _seteuid (uid_t) __attribute__ ((weak, alias ("__collector_seteuid"))); + + int + __collector_seteuid (uid_t euid) +@@ -1786,8 +1792,8 @@ __collector_seteuid (uid_t euid) + } + + /*------------------------------------------------------------------ setreuid */ +-int setreuid () __attribute__ ((weak, alias ("__collector_setreuid"))); +-int _setreuid () __attribute__ ((weak, alias ("__collector_setreuid"))); ++int setreuid (uid_t, uid_t) __attribute__ ((weak, alias ("__collector_setreuid"))); ++int _setreuid (uid_t, uid_t) __attribute__ ((weak, alias ("__collector_setreuid"))); + + int + __collector_setreuid (uid_t ruid, uid_t euid) +@@ -1802,8 +1808,8 @@ __collector_setreuid (uid_t ruid, uid_t euid) + } + + /*-------------------------------------------------------------------- setgid */ +-int setgid () __attribute__ ((weak, alias ("__collector_setgid"))); +-int _setgid () __attribute__ ((weak, alias ("__collector_setgid"))); ++int setgid (gid_t) __attribute__ ((weak, alias ("__collector_setgid"))); ++int _setgid (gid_t) __attribute__ ((weak, alias ("__collector_setgid"))); + + int + __collector_setgid (gid_t rgid) +@@ -1818,8 +1824,8 @@ __collector_setgid (gid_t rgid) + } + + /*------------------------------------------------------------------- setegid */ +-int setegid () __attribute__ ((weak, alias ("__collector_setegid"))); +-int _setegid () __attribute__ ((weak, alias ("__collector_setegid"))); ++int setegid (gid_t) __attribute__ ((weak, alias ("__collector_setegid"))); ++int _setegid (gid_t) __attribute__ ((weak, alias ("__collector_setegid"))); + + int + __collector_setegid (gid_t egid) +@@ -1834,8 +1840,8 @@ __collector_setegid (gid_t egid) + } + + /*------------------------------------------------------------------ setregid */ +-int setregid () __attribute__ ((weak, alias ("__collector_setregid"))); +-int _setregid () __attribute__ ((weak, alias ("__collector_setregid"))); ++int setregid (gid_t, gid_t) __attribute__ ((weak, alias ("__collector_setregid"))); ++int _setregid (gid_t, gid_t) __attribute__ ((weak, alias ("__collector_setregid"))); + + int + __collector_setregid (gid_t rgid, gid_t egid) +diff --git a/gprofng/src/BaseMetricTreeNode.h b/gprofng/src/BaseMetricTreeNode.h +index d73d244e27e..7698f9c6eaf 100644 +--- a/gprofng/src/BaseMetricTreeNode.h ++++ b/gprofng/src/BaseMetricTreeNode.h +@@ -85,7 +85,6 @@ private: + + BaseMetricTreeNode *root; // root of tree + BaseMetricTreeNode *parent; // my parent +- bool aggregation; // value is based on children's values + char *name; // bm->get_cmd() for metrics, unique string otherwise + char *uname; // user-visible text + char *unit; // see UNIT_* defines +diff --git a/gprofng/src/Dbe.cc b/gprofng/src/Dbe.cc +index 95daa727186..09b7f94eaa8 100644 +--- a/gprofng/src/Dbe.cc ++++ b/gprofng/src/Dbe.cc +@@ -9591,14 +9591,12 @@ dbeGetTLDataRepVals (VMode view_mode, hrtime_t start_ts, hrtime_t delta, + } + if (sampleVals != NULL) + { +- Sample* sample = (Sample*) packets->getObjValue (PROP_SMPLOBJ, packetIdx); +- if (!sample || !sample->get_usage ()) +- sample = sample; +- else ++ Sample *sample = (Sample*) packets->getObjValue (PROP_SMPLOBJ, packetIdx); ++ if (sample != NULL) + { +- PrUsage* prusage = sample->get_usage (); +- Vector *mstateVals = prusage->getMstateValues (); +- sampleVals->store (eventIdx, mstateVals); ++ PrUsage *prusage = sample->get_usage (); ++ if (prusage != NULL) ++ sampleVals->store (eventIdx, prusage->getMstateValues ()); + } + } + } +diff --git a/gprofng/src/DbeSession.cc b/gprofng/src/DbeSession.cc +index a6808d8d8f6..3649357bc79 100644 +--- a/gprofng/src/DbeSession.cc ++++ b/gprofng/src/DbeSession.cc +@@ -1164,8 +1164,6 @@ DbeSession::open_experiment (Experiment *exp, char *path) + closedir (exp_dir); + exp_names->sort (dir_name_cmp); + Experiment **t_exp_list = new Experiment *[exp_names->size ()]; +- int nsubexps = 0; +- + for (int j = 0, jsz = exp_names->size (); j < jsz; j++) + { + t_exp_list[j] = NULL; +@@ -1222,7 +1220,6 @@ DbeSession::open_experiment (Experiment *exp, char *path) + dexp->open (dpath); + append (dexp); + t_exp_list[j] = dexp; +- nsubexps++; + dexp->set_clock (exp->clock); + + // DbeView add_experiment() is split into two parts +diff --git a/gprofng/src/Disasm.cc b/gprofng/src/Disasm.cc +index e41bf679292..19f2174d536 100644 +--- a/gprofng/src/Disasm.cc ++++ b/gprofng/src/Disasm.cc +@@ -49,7 +49,6 @@ struct DisContext + }; + + static const int MAX_DISASM_STR = 2048; +-static const int MAX_INSTR_SIZE = 8; + + Disasm::Disasm (char *fname) + { +diff --git a/gprofng/src/Experiment.cc b/gprofng/src/Experiment.cc +index a1f78fc0cde..627a755c88c 100644 +--- a/gprofng/src/Experiment.cc ++++ b/gprofng/src/Experiment.cc +@@ -1937,8 +1937,6 @@ private: + } + + Experiment *exp; +- char *hostname; +- hrtime_t time, tstamp; + }; + + void +diff --git a/gprofng/src/HashMap.h b/gprofng/src/HashMap.h +index 918c0dc95f9..c5fdd345ba8 100644 +--- a/gprofng/src/HashMap.h ++++ b/gprofng/src/HashMap.h +@@ -78,9 +78,8 @@ copy_key (uint64_t a) + } + + template<> inline void +-delete_key (uint64_t a) ++delete_key (uint64_t) + { +- a = a; + } + + template<> inline int +diff --git a/gprofng/src/IOActivity.h b/gprofng/src/IOActivity.h +index cf462cf8d55..f3a22ada6b1 100644 +--- a/gprofng/src/IOActivity.h ++++ b/gprofng/src/IOActivity.h +@@ -78,7 +78,6 @@ private: + Hist_data *hist_data_file_all; + Hist_data *hist_data_vfd_all; + Hist_data *hist_data_callstack_all; +- Hist_data *hist_data_callstack; + + DbeView *dbev; + }; +diff --git a/gprofng/src/collctrl.cc b/gprofng/src/collctrl.cc +index 029c0387f19..c0234130f00 100644 +--- a/gprofng/src/collctrl.cc ++++ b/gprofng/src/collctrl.cc +@@ -880,9 +880,7 @@ Coll_Ctrl::set_clkprof (const char *string, char** warn) + double dval = strtod (string, &endchar); + if (*endchar == 'm' || *endchar == 0) /* user specified milliseconds */ + dval = dval * 1000.; +- else if (*endchar == 'u') /* user specified microseconds */ +- dval = dval; +- else ++ else if (*endchar != 'u') + return dbe_sprintf (GTXT ("Unrecognized clock-profiling interval `%s'\n"), string); + nclkprof_timer = (int) (dval + 0.5); + } +@@ -2791,7 +2789,7 @@ Coll_Ctrl::get (char * control) + } + if (!strncmp (control, ipc_str_javaprof, len)) + { +- if ((java_mode == 0)) ++ if (java_mode == 0) + return strdup (ipc_str_off); + return strdup (ipc_str_on); + } +@@ -2807,7 +2805,7 @@ Coll_Ctrl::get (char * control) + } + if (!strncmp (control, ipc_str_sample_sig, len)) + { +- if ((sample_sig == 0)) ++ if (sample_sig == 0) + return strdup (ipc_str_off); + char *str_signal = find_signal_name (sample_sig); + if (str_signal != NULL) +@@ -2841,15 +2839,15 @@ Coll_Ctrl::get (char * control) + } + if (!strncmp (control, ipc_str_iotrace, len)) + { +- if ((iotrace_enabled == 0)) ++ if (iotrace_enabled == 0) + return strdup (ipc_str_off); + return strdup (ipc_str_on); + } + if (!strncmp (control, ipc_str_count, len)) + { +- if ((count_enabled == 0)) ++ if (count_enabled == 0) + return strdup (ipc_str_off); +- if ((count_enabled < 0)) ++ if (count_enabled < 0) + return strdup ("on\nstatic"); + return strdup (ipc_str_on); + } +diff --git a/gprofng/src/collctrl.h b/gprofng/src/collctrl.h +index a41647440ac..e2a8e450890 100644 +--- a/gprofng/src/collctrl.h ++++ b/gprofng/src/collctrl.h +@@ -272,7 +272,6 @@ private: + char *node_name; /* name of machine on which experiment is run */ + long ncpus; /* number of online CPUs */ + int cpu_clk_freq; /* chip clock (MHz.), as reported from processor_info */ +- int cpc_cpuver; /* chip version, as reported from libcpc */ + long sys_resolution; /* system clock resolution */ + int sample_period; /* period for sampling, seconds */ + int sample_default; /* if period for sampling set by default */ +diff --git a/gprofng/src/collector_module.h b/gprofng/src/collector_module.h +index bb48eadb9f8..ebcdbca561f 100644 +--- a/gprofng/src/collector_module.h ++++ b/gprofng/src/collector_module.h +@@ -40,12 +40,12 @@ struct tm; + * If you add any, please put it in the right place */ + typedef struct CollectorUtilFuncs + { +- int (*access)(); ++ int (*access)(const char *, int); + int (*atoi)(const char *nptr); + void *(*calloc)(size_t nelem, size_t elsize); + int (*clearenv)(void); + int (*close)(int); +- int (*closedir)(); ++ int (*closedir)(DIR *); + int (*execv)(const char *path, char *const argv[]); + void (*exit)(int status); + int (*fclose)(FILE *stream); +@@ -66,20 +66,20 @@ typedef struct CollectorUtilFuncs + off_t (*lseek)(int fd, off_t offset, int whence); + void *(*malloc)(size_t size); + void *(*memset)(void *s1, int c, size_t n); +- int (*mkdir)(); ++ int (*mkdir)(const char *, mode_t); + time_t (*mktime)(struct tm *timeptr); + void *(*mmap)(void *, size_t, int, int, int, off_t); +- void *(*mmap64_)(); +- int (*munmap)(); ++ void *(*mmap64_)(void *, size_t, int, int, int, off_t); ++ int (*munmap)(void *, size_t); + int (*open)(const char *, int, ...); + int (*open_bare)(const char *, int, ...); +- DIR *(*opendir)(); ++ DIR *(*opendir)(const char *); + int (*pclose)(FILE *stream); + FILE *(*popen)(const char *command, const char *mode); + int (*putenv)(char *string); +- ssize_t (*pwrite)(); +- ssize_t (*pwrite64_)(); +- ssize_t (*read)(); ++ ssize_t (*pwrite)(int, const void *, size_t, off_t); ++ ssize_t (*pwrite64_)(int, const void *, size_t, off_t); ++ ssize_t (*read)(int, void *, size_t); + int (*setenv)(const char *name, const char *value, int overwrite); + int (*sigfillset)(sigset_t *set); + int (*sigprocmask)(int how, const sigset_t *set, sigset_t *oldset); +@@ -112,7 +112,7 @@ typedef struct CollectorUtilFuncs + int (*unsetenv)(const char *name); + int (*vsnprintf)(char *str, size_t size, const char *format, va_list ap); + pid_t (*waitpid)(pid_t pid, int *stat_loc, int options); +- ssize_t (*write)(); ++ ssize_t (*write)(int, void *, size_t); + double (*atof)(); + void *n_a; + } CollectorUtilFuncs; +diff --git a/gprofng/src/gp-display-src.cc b/gprofng/src/gp-display-src.cc +index 200e6080d2e..24af375edf1 100644 +--- a/gprofng/src/gp-display-src.cc ++++ b/gprofng/src/gp-display-src.cc +@@ -75,14 +75,6 @@ private: + bool v_opt; + int multiple; + char *str_compcom; +- bool hex_visible; +- int src_visible; +- int vis_src; +- int vis_dis; +- int threshold_src; +- int threshold_dis; +- int threshold; +- int vis_bits; + }; + + static int +diff --git a/gprofng/src/gp-print.h b/gprofng/src/gp-print.h +index 1b748ea60a3..1a8ad3b6c13 100644 +--- a/gprofng/src/gp-print.h ++++ b/gprofng/src/gp-print.h +@@ -19,7 +19,7 @@ + MA 02110-1301, USA. */ + + #ifndef _GP_PRINT_H +-#define _ER_PRINT_H ++#define _GP_PRINT_H + + #include "Command.h" + #include "DbeApplication.h" +diff --git a/gprofng/src/hwc_intel_icelake.h b/gprofng/src/hwc_intel_icelake.h +index 46f4ac5005f..4fe2e26f63b 100644 +--- a/gprofng/src/hwc_intel_icelake.h ++++ b/gprofng/src/hwc_intel_icelake.h +@@ -24,8 +24,10 @@ + #define SH(val, n) (((unsigned long long) (val)) << n) + #define I(nm, event, umask, edge, cmask, inv, \ + offcore_rsp, ldlat, frontend, period, mtr) \ +- INIT_HWC(nm, mtr, SH(event, 0) | SH(umask, 8) | SH(edge, 18) \ +- | SH(cmask, 24) | SH(inv, 23), PERF_TYPE_RAW), \ ++ .use_perf_event_type = 1, .type = PERF_TYPE_RAW, \ ++ .name = (nm), .metric = (mtr), .reg_num = REGNO_ANY, \ ++ .config = SH(event, 0) | SH(umask, 8) | SH(edge, 18) | SH(cmask, 24) \ ++ | SH(inv, 23), \ + .config1 = SH(offcore_rsp, 0) | SH(ldlat, 0) | SH(frontend, 0), \ + .val = period + +diff --git a/gprofng/src/util.cc b/gprofng/src/util.cc +index 201f7088b66..228140b61ae 100644 +--- a/gprofng/src/util.cc ++++ b/gprofng/src/util.cc +@@ -741,17 +741,13 @@ get_relative_link (const char *path_from, const char *path_to) + s2 = canonical_path (s2); + long l = dbe_sstrlen (s1); + // try to find common directories +- int common_slashes = 0; + int last_common_slash = -1; + for (int i = 0; i < l; i++) + { +- if (s1[i] != s2[i]) break; +- if (s1[i] == 0) break; ++ if (s1[i] != s2[i] || s1[i] == 0) ++ break; + if (s1[i] == '/') +- { +- common_slashes++; +- last_common_slash = i; +- } ++ last_common_slash = i; + } + // find slashes in remaining path_to + int slashes = 0; +-- +2.50.1 + diff --git a/package/binutils/2.43.1/0006-gprofng-fix-std-gnu23-compatibility-wrt-unprototyped.patch b/package/binutils/2.43.1/0006-gprofng-fix-std-gnu23-compatibility-wrt-unprototyped.patch new file mode 100644 index 0000000..7c6ed29 --- /dev/null +++ b/package/binutils/2.43.1/0006-gprofng-fix-std-gnu23-compatibility-wrt-unprototyped.patch @@ -0,0 +1,619 @@ +From a5be89126b9bee78224be842e3086ce99dc045e6 Mon Sep 17 00:00:00 2001 +From: Sam James +Date: Sat, 16 Nov 2024 05:13:48 +0000 +Subject: [PATCH] gprofng: fix -std=gnu23 compatibility wrt unprototyped + functions + +C23 removes support for unprototyped functions. Fix function pointer types +accordingly. + +This does not fix all instances, there's a few left as I commented on in +PR32374 (e.g. setitimer which I have a local workaround for but it involves +a glibc implementation detail; the Linaro precommit CI tester pointed that +out too, so dropped that). + +ChangeLog: + PR gprofng/32374 + + * libcollector/collector.c (collector_sample): Fix prototype. + * libcollector/envmgmt.c (putenv): Ditto. + (_putenv): Ditto. + (__collector_putenv): Ditto. + (setenv): Ditto. + (_setenv): Ditto. + (__collector_setenv): Ditto. + (unsetenv): Ditto. + (_unsetenv): Ditto. + (__collector_unsetenv): Ditto. + * libcollector/jprofile.c (open_experiment): Ditto. + (__collector_jprofile_enable_synctrace): Ditto. + (jprof_find_asyncgetcalltrace): Ditto. + * libcollector/libcol_util.c (__collector_util_init): Ditto. + (ARCH): Ditto. + * libcollector/mmaptrace.c (collector_func_load): Ditto. + (collector_func_unload): Ditto. + * libcollector/unwind.c (__collector_ext_unwind_init): Ditto. + * src/collector_module.h: Ditto. + +Upstream: a2f774427e078f3da2c06bdea25f77a61979a695 +Signed-off-by: Thomas Petazzoni +--- + gprofng/libcollector/collector.c | 2 +- + gprofng/libcollector/dispatcher.c | 1 - + gprofng/libcollector/envmgmt.c | 24 ++++----- + gprofng/libcollector/jprofile.c | 10 ++-- + gprofng/libcollector/libcol_util.c | 84 +++++++++++++++--------------- + gprofng/libcollector/mmaptrace.c | 4 +- + gprofng/libcollector/unwind.c | 2 +- + gprofng/src/collector_module.h | 2 +- + 8 files changed, 64 insertions(+), 65 deletions(-) + +diff --git a/gprofng/libcollector/collector.c b/gprofng/libcollector/collector.c +index 2ff95e58fde..3cab346e7dc 100644 +--- a/gprofng/libcollector/collector.c ++++ b/gprofng/libcollector/collector.c +@@ -1578,7 +1578,7 @@ __collector_resume_experiment () + } + + /* Code to support Samples and Pause/Resume */ +-void collector_sample () __attribute__ ((weak, alias ("__collector_sample"))); ++void collector_sample (char *name) __attribute__ ((weak, alias ("__collector_sample"))); + void + __collector_sample (char *name) + { +diff --git a/gprofng/libcollector/dispatcher.c b/gprofng/libcollector/dispatcher.c +index f7cd46e7e6b..4eda18ec324 100644 +--- a/gprofng/libcollector/dispatcher.c ++++ b/gprofng/libcollector/dispatcher.c +@@ -1281,4 +1281,3 @@ __collector_ext_clone_pthread (int (*fn)(void *), void *child_stack, int flags, + int sigprocmask (int, const sigset_t*, sigset_t*) __attribute__ ((weak, alias ("__collector_sigprocmask"))); + int thr_sigsetmask (int, const sigset_t*, sigset_t*) __attribute__ ((weak, alias ("__collector_thr_sigsetmask"))); + int setitimer () __attribute__ ((weak, alias ("_setitimer"))); +- +diff --git a/gprofng/libcollector/envmgmt.c b/gprofng/libcollector/envmgmt.c +index a399c0d0cb4..f2bf2c41bfb 100644 +--- a/gprofng/libcollector/envmgmt.c ++++ b/gprofng/libcollector/envmgmt.c +@@ -685,8 +685,8 @@ __collector_env_update (char *envp[]) + + + /*------------------------------------------------------------- putenv */ +-int putenv () __attribute__ ((weak, alias ("__collector_putenv"))); +-int _putenv () __attribute__ ((weak, alias ("__collector_putenv"))); ++int putenv (char*) __attribute__ ((weak, alias ("__collector_putenv"))); ++int _putenv (char*) __attribute__ ((weak, alias ("__collector_putenv"))); + + int + __collector_putenv (char * string) +@@ -694,9 +694,9 @@ __collector_putenv (char * string) + if (CALL_UTIL (putenv) == __collector_putenv || + CALL_UTIL (putenv) == NULL) + { // __collector_libc_funcs_init failed +- CALL_UTIL (putenv) = (int(*)())dlsym (RTLD_NEXT, "putenv"); ++ CALL_UTIL (putenv) = (int(*)(char*))dlsym (RTLD_NEXT, "putenv"); + if (CALL_UTIL (putenv) == NULL || CALL_UTIL (putenv) == __collector_putenv) +- CALL_UTIL (putenv) = (int(*)())dlsym (RTLD_DEFAULT, "putenv"); ++ CALL_UTIL (putenv) = (int(*)(char*))dlsym (RTLD_DEFAULT, "putenv"); + if (CALL_UTIL (putenv) == NULL || CALL_UTIL (putenv) == __collector_putenv) + { + TprintfT (DBG_LT2, "__collector_putenv(): ERROR: no pointer found.\n"); +@@ -712,8 +712,8 @@ __collector_putenv (char * string) + } + + /*------------------------------------------------------------- setenv */ +-int setenv () __attribute__ ((weak, alias ("__collector_setenv"))); +-int _setenv () __attribute__ ((weak, alias ("__collector_setenv"))); ++int setenv (const char*, const char*, int) __attribute__ ((weak, alias ("__collector_setenv"))); ++int _setenv (const char*, const char*, int) __attribute__ ((weak, alias ("__collector_setenv"))); + + int + __collector_setenv (const char *name, const char *value, int overwrite) +@@ -721,9 +721,9 @@ __collector_setenv (const char *name, const char *value, int overwrite) + if (CALL_UTIL (setenv) == __collector_setenv || + CALL_UTIL (setenv) == NULL) + { // __collector_libc_funcs_init failed +- CALL_UTIL (setenv) = (int(*)())dlsym (RTLD_NEXT, "setenv"); ++ CALL_UTIL (setenv) = (int(*)(const char*, const char*, int))dlsym (RTLD_NEXT, "setenv"); + if (CALL_UTIL (setenv) == NULL || CALL_UTIL (setenv) == __collector_setenv) +- CALL_UTIL (setenv) = (int(*)())dlsym (RTLD_DEFAULT, "setenv"); ++ CALL_UTIL (setenv) = (int(*)(const char*, const char*, int))dlsym (RTLD_DEFAULT, "setenv"); + if (CALL_UTIL (setenv) == NULL || CALL_UTIL (setenv) == __collector_setenv) + { + TprintfT (DBG_LT2, "__collector_setenv(): ERROR: no pointer found.\n"); +@@ -758,8 +758,8 @@ __collector_setenv (const char *name, const char *value, int overwrite) + } + + /*------------------------------------------------------------- unsetenv */ +-int unsetenv () __attribute__ ((weak, alias ("__collector_unsetenv"))); +-int _unsetenv () __attribute__ ((weak, alias ("__collector_unsetenv"))); ++int unsetenv (const char*) __attribute__ ((weak, alias ("__collector_unsetenv"))); ++int _unsetenv (const char*) __attribute__ ((weak, alias ("__collector_unsetenv"))); + + int + __collector_unsetenv (const char *name) +@@ -767,9 +767,9 @@ __collector_unsetenv (const char *name) + if (CALL_UTIL (unsetenv) == __collector_unsetenv || + CALL_UTIL (unsetenv) == NULL) + { // __collector_libc_funcs_init failed +- CALL_UTIL (unsetenv) = (int(*)())dlsym (RTLD_NEXT, "unsetenv"); ++ CALL_UTIL (unsetenv) = (int(*)(const char*))dlsym (RTLD_NEXT, "unsetenv"); + if (CALL_UTIL (unsetenv) == NULL || CALL_UTIL (unsetenv) == __collector_unsetenv) +- CALL_UTIL (unsetenv) = (int(*)())dlsym (RTLD_DEFAULT, "unsetenv"); ++ CALL_UTIL (unsetenv) = (int(*)(const char*))dlsym (RTLD_DEFAULT, "unsetenv"); + if (CALL_UTIL (unsetenv) == NULL || CALL_UTIL (unsetenv) == __collector_unsetenv) + { + TprintfT (DBG_LT2, "__collector_unsetenv(): ERROR: no pointer found.\n"); +diff --git a/gprofng/libcollector/jprofile.c b/gprofng/libcollector/jprofile.c +index cd498bed0a3..d8f2d049a84 100644 +--- a/gprofng/libcollector/jprofile.c ++++ b/gprofng/libcollector/jprofile.c +@@ -99,8 +99,8 @@ static void rwrite (int fd, const void *buf, size_t nbyte); + static void addToDynamicArchive (const char* name, const unsigned char* class_data, int class_data_len); + static void (*AsyncGetCallTrace)(JVMPI_CallTrace*, jint, ucontext_t*) = NULL; + static void (*collector_heap_record)(int, int, void*) = NULL; +-static void (*collector_jsync_begin)() = NULL; +-static void (*collector_jsync_end)(hrtime_t, void *) = NULL; ++static void (*collector_jsync_begin)(void) = NULL; ++static void (*collector_jsync_end)(hrtime_t, void*) = NULL; + + #define gethrtime collector_interface->getHiResTime + +@@ -224,7 +224,7 @@ open_experiment (const char *exp) + else if (__collector_strStartWith (args, "s:") == 0) + { + java_sync_mode = 1; +- collector_jsync_begin = (void(*)(hrtime_t, void *))dlsym (RTLD_DEFAULT, "__collector_jsync_begin"); ++ collector_jsync_begin = (void(*)(void))dlsym (RTLD_DEFAULT, "__collector_jsync_begin"); + collector_jsync_end = (void(*)(hrtime_t, void *))dlsym (RTLD_DEFAULT, "__collector_jsync_end"); + } + #endif +@@ -249,7 +249,7 @@ __collector_jprofile_enable_synctrace () + return; + } + java_sync_mode = 1; +- collector_jsync_begin = (void(*)(hrtime_t, void *))dlsym (RTLD_DEFAULT, "__collector_jsync_begin"); ++ collector_jsync_begin = (void(*)(void))dlsym (RTLD_DEFAULT, "__collector_jsync_begin"); + collector_jsync_end = (void(*)(hrtime_t, void *))dlsym (RTLD_DEFAULT, "__collector_jsync_end"); + TprintfT (DBG_LT1, "jprofile: turning on Java synctrace, and requesting events\n"); + } +@@ -1123,7 +1123,7 @@ jprof_find_asyncgetcalltrace () + { + void *jvmhandle; + if (__collector_VM_ReadByteInstruction == NULL) +- __collector_VM_ReadByteInstruction = (int(*)()) dlsym (RTLD_DEFAULT, "Async_VM_ReadByteInstruction"); ++ __collector_VM_ReadByteInstruction = (int(*)(unsigned char*)) dlsym (RTLD_DEFAULT, "Async_VM_ReadByteInstruction"); + + /* look for stack unwind function using default path */ + AsyncGetCallTrace = (void (*)(JVMPI_CallTrace*, jint, ucontext_t*)) +diff --git a/gprofng/libcollector/libcol_util.c b/gprofng/libcollector/libcol_util.c +index baac15db5c4..a73488e3f60 100644 +--- a/gprofng/libcollector/libcol_util.c ++++ b/gprofng/libcollector/libcol_util.c +@@ -1114,7 +1114,7 @@ __collector_util_init () + + ptr = dlsym (libc, "munmap"); + if (ptr) +- __collector_util_funcs.munmap = (int(*)())ptr; ++ __collector_util_funcs.munmap = (int(*)(void *, size_t))ptr; + else + { + CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT munmap: %s\n", dlerror ()); +@@ -1123,7 +1123,7 @@ __collector_util_init () + + ptr = dlsym (libc, "close"); + if (ptr) +- __collector_util_funcs.close = (int(*)())ptr; ++ __collector_util_funcs.close = (int(*)(int))ptr; + else + { + CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT close: %s\n", dlerror ()); +@@ -1158,7 +1158,7 @@ __collector_util_init () + + ptr = dlsym (libc, "close"); + if (ptr) +- __collector_util_funcs.close = (int(*)())ptr; ++ __collector_util_funcs.close = (int(*)(int))ptr; + else + { + CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT close: %s\n", dlerror ()); +@@ -1167,7 +1167,7 @@ __collector_util_init () + + ptr = dlsym (libc, "read"); + if (ptr) +- __collector_util_funcs.read = (ssize_t (*)())ptr; ++ __collector_util_funcs.read = (ssize_t (*)(int, void*, size_t))ptr; + else + { + CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT read: %s\n", dlerror ()); +@@ -1176,7 +1176,7 @@ __collector_util_init () + + ptr = dlsym (libc, "write"); + if (ptr) +- __collector_util_funcs.write = (ssize_t (*)())ptr; ++ __collector_util_funcs.write = (ssize_t (*)(int, void*, size_t))ptr; + else + { + CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT write: %s\n", dlerror ()); +@@ -1186,14 +1186,14 @@ __collector_util_init () + #if ARCH(Intel) && WSIZE(32) + ptr = dlvsym (libc, "pwrite", "GLIBC_2.2"); // it is in /lib/libpthread.so.0 + if (ptr) +- __collector_util_funcs.pwrite = (ssize_t (*)())ptr; ++ __collector_util_funcs.pwrite = (ssize_t (*)(int, void*, size_t, off_t))ptr; + else + { + Tprintf (DBG_LT0, "libcol_util: WARNING: dlvsym for %s@%s failed. Using dlsym() instead.", "pwrite", "GLIBC_2.2"); + #endif /* ARCH(Intel) && WSIZE(32) */ + ptr = dlsym (libc, "pwrite"); + if (ptr) +- __collector_util_funcs.pwrite = (ssize_t (*)())ptr; ++ __collector_util_funcs.pwrite = (ssize_t (*)(int, const void*, size_t, off_t))ptr; + else + { + CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT pwrite: %s\n", dlerror ()); +@@ -1213,7 +1213,7 @@ __collector_util_init () + #endif /* ARCH(Intel) && WSIZE(32) */ + ptr = dlsym (libc, "pwrite64"); + if (ptr) +- __collector_util_funcs.pwrite64_ = (ssize_t (*)())ptr; ++ __collector_util_funcs.pwrite64_ = (ssize_t (*)(int, const void*, size_t, off_t))ptr; + else + __collector_util_funcs.pwrite64_ = __collector_util_funcs.pwrite; + #if ARCH(Intel) && WSIZE(32) +@@ -1222,7 +1222,7 @@ __collector_util_init () + + ptr = dlsym (libc, "lseek"); + if (ptr) +- __collector_util_funcs.lseek = (off_t (*)())ptr; ++ __collector_util_funcs.lseek = (off_t (*)(int, off_t, int))ptr; + else + { + CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT lseek: %s\n", dlerror ()); +@@ -1231,7 +1231,7 @@ __collector_util_init () + + ptr = dlsym (libc, "access"); + if (ptr) +- __collector_util_funcs.access = (int(*)())ptr; ++ __collector_util_funcs.access = (int(*)(const char*, int))ptr; + else + { + CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT access: %s\n", dlerror ()); +@@ -1240,7 +1240,7 @@ __collector_util_init () + + ptr = dlsym (libc, "mkdir"); + if (ptr) +- __collector_util_funcs.mkdir = (int(*)())ptr; ++ __collector_util_funcs.mkdir = (int(*)(const char*, mode_t))ptr; + else + { + CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT mkdir: %s\n", dlerror ()); +@@ -1249,7 +1249,7 @@ __collector_util_init () + + ptr = dlsym (libc, "opendir"); + if (ptr) +- __collector_util_funcs.opendir = (DIR * (*)())ptr; ++ __collector_util_funcs.opendir = (DIR * (*)(const char*))ptr; + else + { + CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT opendir: %s\n", dlerror ()); +@@ -1258,7 +1258,7 @@ __collector_util_init () + + ptr = dlsym (libc, "closedir"); + if (ptr) +- __collector_util_funcs.closedir = (int(*)())ptr; ++ __collector_util_funcs.closedir = (int(*)(DIR*))ptr; + else + { + CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT closedir: %s\n", dlerror ()); +@@ -1267,7 +1267,7 @@ __collector_util_init () + + ptr = dlsym (libc, "execv"); + if (ptr) +- __collector_util_funcs.execv = (int(*)())ptr; ++ __collector_util_funcs.execv = (int(*)(const char*, char* const*))ptr; + else + { + CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT execv: %s\n", dlerror ()); +@@ -1276,7 +1276,7 @@ __collector_util_init () + + ptr = dlsym (libc, "exit"); + if (ptr) +- __collector_util_funcs.exit = (void(*)())ptr; ++ __collector_util_funcs.exit = (void(*)(int))ptr; + else + { + CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT exit: %s\n", dlerror ()); +@@ -1285,7 +1285,7 @@ __collector_util_init () + + ptr = dlsym (libc, "vfork"); + if (ptr) +- __collector_util_funcs.vfork = (pid_t (*)())ptr; ++ __collector_util_funcs.vfork = (pid_t (*)(void))ptr; + else + { + CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT vfork: %s\n", dlerror ()); +@@ -1294,7 +1294,7 @@ __collector_util_init () + + ptr = dlsym (libc, "waitpid"); + if (ptr) +- __collector_util_funcs.waitpid = (pid_t (*)())ptr; ++ __collector_util_funcs.waitpid = (pid_t (*)(pid_t, int*, int))ptr; + else + { + CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT waitpid: %s\n", dlerror ()); +@@ -1313,7 +1313,7 @@ __collector_util_init () + + ptr = dlsym (libc, "getcontext"); + if (ptr) +- __collector_util_funcs.getcontext = (int(*)())ptr; ++ __collector_util_funcs.getcontext = (int(*)(ucontext_t*))ptr; + else + { + CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT getcontext: %s\n", dlerror ()); +@@ -1331,7 +1331,7 @@ __collector_util_init () + + ptr = dlsym (libc, "putenv"); + if (ptr) +- __collector_util_funcs.putenv = (int(*)())ptr; ++ __collector_util_funcs.putenv = (int(*)(char*))ptr; + else + { + CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT putenv: %s\n", dlerror ()); +@@ -1340,7 +1340,7 @@ __collector_util_init () + + ptr = dlsym (libc, "getenv"); + if (ptr) +- __collector_util_funcs.getenv = (char*(*)())ptr; ++ __collector_util_funcs.getenv = (char*(*)(const char*))ptr; + else + { + CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT getenv: %s\n", dlerror ()); +@@ -1349,7 +1349,7 @@ __collector_util_init () + + ptr = dlsym (libc, "time"); + if (ptr) +- __collector_util_funcs.time = (time_t (*)())ptr; ++ __collector_util_funcs.time = (time_t (*)(time_t*))ptr; + else + { + CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT time: %s\n", dlerror ()); +@@ -1358,7 +1358,7 @@ __collector_util_init () + + ptr = dlsym (libc, "mktime"); + if (ptr) +- __collector_util_funcs.mktime = (time_t (*)())ptr; ++ __collector_util_funcs.mktime = (time_t (*)(struct tm*))ptr; + else + { + CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT mktime: %s\n", dlerror ()); +@@ -1372,7 +1372,7 @@ __collector_util_init () + + ptr = dlsym (libc, "gmtime_r"); + if (ptr) +- __collector_util_funcs.gmtime_r = (struct tm * (*)())ptr; ++ __collector_util_funcs.gmtime_r = (struct tm * (*)(const time_t*, struct tm*))ptr; + else + { + CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT gmtime_r: %s\n", dlerror ()); +@@ -1381,7 +1381,7 @@ __collector_util_init () + + ptr = dlsym (libc, "strtol"); + if (ptr) +- __collector_util_funcs.strtol = (long (*)())ptr; ++ __collector_util_funcs.strtol = (long (*)(const char*, char**, int))ptr; + else + { + CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT strtol: %s\n", dlerror ()); +@@ -1390,7 +1390,7 @@ __collector_util_init () + + ptr = dlsym (libc, "strtoll"); + if (ptr) +- __collector_util_funcs.strtoll = (long long (*)())ptr; ++ __collector_util_funcs.strtoll = (long long (*)(const char*, char**, int))ptr; + else + { + CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT strtoll: %s\n", dlerror ()); +@@ -1402,7 +1402,7 @@ __collector_util_init () + + ptr = dlsym (libc, "setenv"); + if (ptr) +- __collector_util_funcs.setenv = (int(*)())ptr; ++ __collector_util_funcs.setenv = (int(*)(const char*, const char*, int))ptr; + else + { + CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT setenv: %s\n", dlerror ()); +@@ -1411,7 +1411,7 @@ __collector_util_init () + + ptr = dlsym (libc, "unsetenv"); + if (ptr) +- __collector_util_funcs.unsetenv = (int(*)())ptr; ++ __collector_util_funcs.unsetenv = (int(*)(const char*))ptr; + else + { + CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT unsetenv: %s\n", dlerror ()); +@@ -1507,7 +1507,7 @@ __collector_util_init () + + ptr = dlsym (libc, "pclose"); + if (ptr) +- __collector_util_funcs.pclose = (int(*)())ptr; ++ __collector_util_funcs.pclose = (int(*)(FILE*))ptr; + else + { + CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT pclose: %s\n", dlerror ()); +@@ -1516,7 +1516,7 @@ __collector_util_init () + + ptr = dlsym (libc, "fgets"); + if (ptr) +- __collector_util_funcs.fgets = (char*(*)())ptr; ++ __collector_util_funcs.fgets = (char*(*)(char*, int, FILE*))ptr; + else + { + CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT fgets: %s\n", dlerror ()); +@@ -1543,7 +1543,7 @@ __collector_util_init () + + ptr = dlsym (libc, "vsnprintf"); + if (ptr) +- __collector_util_funcs.vsnprintf = (int(*)())ptr; ++ __collector_util_funcs.vsnprintf = (int(*)(char*, size_t, const char*, ...))ptr; + else + { + CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT vsnprintf: %s\n", dlerror ()); +@@ -1552,7 +1552,7 @@ __collector_util_init () + + ptr = dlsym (libc, "atoi"); + if (ptr) +- __collector_util_funcs.atoi = (int(*)())ptr; ++ __collector_util_funcs.atoi = (int(*)(const char*))ptr; + else + { + CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT atoi: %s\n", dlerror ()); +@@ -1561,7 +1561,7 @@ __collector_util_init () + + ptr = dlsym (libc, "calloc"); + if (ptr) +- __collector_util_funcs.calloc = (void*(*)())ptr; ++ __collector_util_funcs.calloc = (void*(*)(size_t, size_t))ptr; + else + { + CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT calloc: %s\n", dlerror ()); +@@ -1571,7 +1571,7 @@ __collector_util_init () + ptr = dlsym (libc, "free"); + if (ptr) + { +- __collector_util_funcs.free = (void(*)())ptr; ++ __collector_util_funcs.free = (void(*)(void*))ptr; + } + else + { +@@ -1581,7 +1581,7 @@ __collector_util_init () + + ptr = dlsym (libc, "strdup"); + if (ptr) +- __collector_util_funcs.libc_strdup = (char*(*)())ptr; ++ __collector_util_funcs.libc_strdup = (char*(*)(const char*))ptr; + else + { + CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT strdup: %s\n", dlerror ()); +@@ -1594,7 +1594,7 @@ __collector_util_init () + + ptr = dlsym (libc, "strerror"); + if (ptr) +- __collector_util_funcs.strerror = (char*(*)())ptr; ++ __collector_util_funcs.strerror = (char*(*)(int))ptr; + else + { + CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT strerror: %s\n", dlerror ()); +@@ -1602,7 +1602,7 @@ __collector_util_init () + } + ptr = dlsym (libc, "strerror_r"); + if (ptr) +- __collector_util_funcs.strerror_r = (int(*)())ptr; ++ __collector_util_funcs.strerror_r = (int(*)(int, char*, size_t))ptr; + else + { + CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT strerror_r: %s\n", dlerror ()); +@@ -1610,7 +1610,7 @@ __collector_util_init () + } + ptr = dlsym (libc, "strspn"); + if (ptr) +- __collector_util_funcs.strspn = (size_t (*)())ptr; ++ __collector_util_funcs.strspn = (size_t (*)(const char*, const char*))ptr; + else + { + CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT strspn: %s\n", dlerror ()); +@@ -1619,7 +1619,7 @@ __collector_util_init () + + ptr = dlsym (libc, "strtoul"); + if (ptr) +- __collector_util_funcs.strtoul = (unsigned long int(*)())ptr; ++ __collector_util_funcs.strtoul = (unsigned long int(*)(const char*, char**, int))ptr; + else + { + CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT strtoul: %s\n", dlerror ()); +@@ -1628,7 +1628,7 @@ __collector_util_init () + + ptr = dlsym (libc, "strtoull"); + if (ptr) +- __collector_util_funcs.strtoull = (unsigned long long int(*)())ptr; ++ __collector_util_funcs.strtoull = (unsigned long long int(*)(const char*, char**, int))ptr; + else + { + CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT strtoull: %s\n", dlerror ()); +@@ -1673,7 +1673,7 @@ __collector_util_init () + + ptr = dlsym (libc, "sysconf"); + if (ptr) +- __collector_util_funcs.sysconf = (long(*)())ptr; ++ __collector_util_funcs.sysconf = (long(*)(int))ptr; + else + { + CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT sysconf: %s\n", dlerror ()); +@@ -1682,7 +1682,7 @@ __collector_util_init () + + ptr = dlsym (libc, "sigfillset"); + if (ptr) +- __collector_util_funcs.sigfillset = (int(*)())ptr; ++ __collector_util_funcs.sigfillset = (int(*)(sigset_t*))ptr; + else + { + CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT sigfillset: %s\n", dlerror ()); +@@ -1691,7 +1691,7 @@ __collector_util_init () + + ptr = dlsym (libc, "sigprocmask"); + if (ptr) +- __collector_util_funcs.sigprocmask = (int(*)())ptr; ++ __collector_util_funcs.sigprocmask = (int(*)(int, const sigset_t*, sigset_t*))ptr; + else + { + CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT sigprocmask: %s\n", dlerror ()); +diff --git a/gprofng/libcollector/mmaptrace.c b/gprofng/libcollector/mmaptrace.c +index f07f4d76513..2a6857ab58e 100644 +--- a/gprofng/libcollector/mmaptrace.c ++++ b/gprofng/libcollector/mmaptrace.c +@@ -1209,7 +1209,7 @@ process_vsyscall_page () + /* + * collector API for dynamic functions + */ +-void collector_func_load () __attribute__ ((weak, alias ("__collector_func_load"))); ++void collector_func_load (char*, char*, char*, void*, int, int, DT_lineno *) __attribute__ ((weak, alias ("__collector_func_load"))); + void + __collector_func_load (char *name, char *alias, char *sourcename, + void *vaddr, int size, int lntsize, DT_lineno *lntable) +@@ -1218,7 +1218,7 @@ __collector_func_load (char *name, char *alias, char *sourcename, + vaddr, size, lntsize, lntable); + } + +-void collector_func_unload () __attribute__ ((weak, alias ("__collector_func_unload"))); ++void collector_func_unload (void *vaddr) __attribute__ ((weak, alias ("__collector_func_unload"))); + void + __collector_func_unload (void *vaddr) + { +diff --git a/gprofng/libcollector/unwind.c b/gprofng/libcollector/unwind.c +index 55fa2e9e9e7..e08afa165d1 100644 +--- a/gprofng/libcollector/unwind.c ++++ b/gprofng/libcollector/unwind.c +@@ -421,7 +421,7 @@ __collector_ext_unwind_init (int record) + omp_no_walk = 1; + + if (__collector_VM_ReadByteInstruction == NULL) +- __collector_VM_ReadByteInstruction = (int(*)()) dlsym (RTLD_DEFAULT, "Async_VM_ReadByteInstruction"); ++ __collector_VM_ReadByteInstruction = (int(*)(unsigned char*)) dlsym (RTLD_DEFAULT, "Async_VM_ReadByteInstruction"); + + #if ARCH(SPARC) + #if WSIZE(64) +diff --git a/gprofng/src/collector_module.h b/gprofng/src/collector_module.h +index ebcdbca561f..fd888cd58dd 100644 +--- a/gprofng/src/collector_module.h ++++ b/gprofng/src/collector_module.h +@@ -110,7 +110,7 @@ typedef struct CollectorUtilFuncs + long (*sysinfo)(int command, char *buf, long count); + time_t (*time)(time_t *tloc); + int (*unsetenv)(const char *name); +- int (*vsnprintf)(char *str, size_t size, const char *format, va_list ap); ++ int (*vsnprintf)(char *str, size_t size, const char *format, ...); + pid_t (*waitpid)(pid_t pid, int *stat_loc, int options); + ssize_t (*write)(int, void *, size_t); + double (*atof)(); +-- +2.50.1 + diff --git a/package/binutils/2.43.1/0007-gprofng-fix-build-with-std-gnu23.patch b/package/binutils/2.43.1/0007-gprofng-fix-build-with-std-gnu23.patch new file mode 100644 index 0000000..fe03b4b --- /dev/null +++ b/package/binutils/2.43.1/0007-gprofng-fix-build-with-std-gnu23.patch @@ -0,0 +1,199 @@ +From 9ca25799ea0e92855d19adc46634e6dd0675a0b7 Mon Sep 17 00:00:00 2001 +From: Vladimir Mezentsev +Date: Thu, 21 Nov 2024 14:48:20 -0800 +Subject: [PATCH] gprofng: fix build with -std=gnu23 + +Fix function pointer types accordingly. +Remove unused function pointers. + +gprofng/ChangeLog +2024-11-21 Vladimir Mezentsev + + PR gprofng/32374 + PR gprofng/32373 + * common/cpuid.c: Define ATTRIBUTE_UNUSED if necessary. + * libcollector/libcol_util.c (sysinfo): Remove unused pointer. + * src/collector_module.h: Likewise. + * libcollector/dispatcher.c (setitimer): Fix prototype. + * libcollector/linetrace.c (system, grantpt, ptsname): Likewise. + * testsuite/gprofng.display/mttest/mttest.c (dump_arrays): Likewise. + * testsuite/gprofng.display/synprog/endcases.c (xinline_code, + s_inline_code): Likewise. + * testsuite/gprofng.display/synprog/inc_inline.h (ext_inline_code): + Likewise. + * testsuite/gprofng.display/synprog/synprog.c (doabort): Rename nullptr. + +Upstream: 4e943705e3e8a5a9448d087502bcb390a694ad02 +Signed-off-by: Thomas Petazzoni +--- + gprofng/common/cpuid.c | 2 ++ + gprofng/libcollector/dispatcher.c | 2 +- + gprofng/libcollector/libcol_util.c | 9 --------- + gprofng/libcollector/linetrace.c | 10 +++++----- + gprofng/src/collector_module.h | 1 - + gprofng/testsuite/gprofng.display/mttest/mttest.c | 2 +- + gprofng/testsuite/gprofng.display/synprog/endcases.c | 4 ++-- + gprofng/testsuite/gprofng.display/synprog/inc_inline.h | 2 +- + gprofng/testsuite/gprofng.display/synprog/synprog.c | 4 ++-- + 9 files changed, 14 insertions(+), 22 deletions(-) + +diff --git a/gprofng/common/cpuid.c b/gprofng/common/cpuid.c +index 891d5471335..b4caef54f57 100644 +--- a/gprofng/common/cpuid.c ++++ b/gprofng/common/cpuid.c +@@ -21,7 +21,9 @@ + #if defined(__i386__) || defined(__x86_64) + #include /* GCC-provided */ + #elif defined(__aarch64__) ++#if !defined(ATTRIBUTE_UNUSED) + #define ATTRIBUTE_UNUSED __attribute__((unused)) ++#endif + + static inline uint_t __attribute_const__ + __get_cpuid (unsigned int op ATTRIBUTE_UNUSED, unsigned int *eax, +diff --git a/gprofng/libcollector/dispatcher.c b/gprofng/libcollector/dispatcher.c +index 4eda18ec324..6f0364cc52c 100644 +--- a/gprofng/libcollector/dispatcher.c ++++ b/gprofng/libcollector/dispatcher.c +@@ -1280,4 +1280,4 @@ __collector_ext_clone_pthread (int (*fn)(void *), void *child_stack, int flags, + // weak symbols: + int sigprocmask (int, const sigset_t*, sigset_t*) __attribute__ ((weak, alias ("__collector_sigprocmask"))); + int thr_sigsetmask (int, const sigset_t*, sigset_t*) __attribute__ ((weak, alias ("__collector_thr_sigsetmask"))); +-int setitimer () __attribute__ ((weak, alias ("_setitimer"))); ++__typeof(setitimer) setitimer __attribute__ ((weak, alias ("_setitimer"))); +diff --git a/gprofng/libcollector/libcol_util.c b/gprofng/libcollector/libcol_util.c +index a73488e3f60..77dc886be22 100644 +--- a/gprofng/libcollector/libcol_util.c ++++ b/gprofng/libcollector/libcol_util.c +@@ -1427,15 +1427,6 @@ __collector_util_init () + err = COL_ERROR_UTIL_INIT; + } + +- ptr = dlsym (libc, "sysinfo"); +- if (ptr) +- __collector_util_funcs.sysinfo = (long (*)())ptr; +- else +- { +- CALL_UTIL (fprintf)(stderr, "collector_util_init COL_ERROR_UTIL_INIT sysinfo: %s\n", dlerror ()); +- err = COL_ERROR_UTIL_INIT; +- } +- + ptr = dlsym (libc, "clearenv"); + if (ptr) + __collector_util_funcs.clearenv = (int(*)())ptr; +diff --git a/gprofng/libcollector/linetrace.c b/gprofng/libcollector/linetrace.c +index 66844bc1337..c81ae1a2272 100644 +--- a/gprofng/libcollector/linetrace.c ++++ b/gprofng/libcollector/linetrace.c +@@ -1527,7 +1527,7 @@ DCL_FUNC_VER (DCL_POSIX_SPAWNP, posix_spawnp_2_2, posix_spawnp@GLIBC_2.2) + DCL_POSIX_SPAWNP (posix_spawnp) + + /*------------------------------------------------------------- system */ +-int system () __attribute__ ((weak, alias ("__collector_system"))); ++int system (const char *cmd) __attribute__ ((weak, alias ("__collector_system"))); + + int + __collector_system (const char *cmd) +@@ -1582,10 +1582,10 @@ DCL_FUNC_VER (DCL_POPEN, popen_2_0, popen@GLIBC_2.0) + DCL_POPEN (popen) + + /*------------------------------------------------------------- grantpt */ +-int grantpt () __attribute__ ((weak, alias ("__collector_grantpt"))); ++int grantpt (int fildes) __attribute__ ((weak, alias ("__collector_grantpt"))); + + int +-__collector_grantpt (const int fildes) ++__collector_grantpt (int fildes) + { + if (NULL_PTR (grantpt)) + init_lineage_intf (); +@@ -1607,10 +1607,10 @@ __collector_grantpt (const int fildes) + } + + /*------------------------------------------------------------- ptsname */ +-char *ptsname () __attribute__ ((weak, alias ("__collector_ptsname"))); ++char *ptsname (int fildes) __attribute__ ((weak, alias ("__collector_ptsname"))); + + char * +-__collector_ptsname (const int fildes) ++__collector_ptsname (int fildes) + { + if (NULL_PTR (ptsname)) + init_lineage_intf (); +diff --git a/gprofng/src/collector_module.h b/gprofng/src/collector_module.h +index fd888cd58dd..6640f12fa3c 100644 +--- a/gprofng/src/collector_module.h ++++ b/gprofng/src/collector_module.h +@@ -107,7 +107,6 @@ typedef struct CollectorUtilFuncs + int (*symlink)(const char *s1, const char *s2); + int (*syscall)(int number, ...); + long (*sysconf)(int name); +- long (*sysinfo)(int command, char *buf, long count); + time_t (*time)(time_t *tloc); + int (*unsetenv)(const char *name); + int (*vsnprintf)(char *str, size_t size, const char *format, ...); +diff --git a/gprofng/testsuite/gprofng.display/mttest/mttest.c b/gprofng/testsuite/gprofng.display/mttest/mttest.c +index e0835c833e5..3db5b8d8e86 100644 +--- a/gprofng/testsuite/gprofng.display/mttest/mttest.c ++++ b/gprofng/testsuite/gprofng.display/mttest/mttest.c +@@ -171,7 +171,7 @@ void computeJ (workStruct_t *x); + void computeK (workStruct_t *x); + void addone (workCtr_t *x); + void init_arrays (int strat); +-void dump_arrays (); ++void dump_arrays (hrtime_t real, hrtime_t cpu, int case_index); + void *do_work (void *v); + void thread_work (); + void nothreads (Workblk *array, struct scripttab *k); +diff --git a/gprofng/testsuite/gprofng.display/synprog/endcases.c b/gprofng/testsuite/gprofng.display/synprog/endcases.c +index a6a1389658a..6f1c83b6859 100644 +--- a/gprofng/testsuite/gprofng.display/synprog/endcases.c ++++ b/gprofng/testsuite/gprofng.display/synprog/endcases.c +@@ -40,8 +40,8 @@ static void s_inline_code (int); + void ext_inline_code (int); + + #ifndef NO_INLINE +-void xinline_code () __attribute__ ((always_inline)); +-void s_inline_code () __attribute__ ((always_inline)); ++void xinline_code (int) __attribute__ ((always_inline)); ++void s_inline_code (int) __attribute__ ((always_inline)); + #endif + + #include "inc_inline.h" +diff --git a/gprofng/testsuite/gprofng.display/synprog/inc_inline.h b/gprofng/testsuite/gprofng.display/synprog/inc_inline.h +index da42563c828..6600eacb66d 100644 +--- a/gprofng/testsuite/gprofng.display/synprog/inc_inline.h ++++ b/gprofng/testsuite/gprofng.display/synprog/inc_inline.h +@@ -19,7 +19,7 @@ + MA 02110-1301, USA. */ + + #ifndef NO_INLINE +-void ext_inline_code() __attribute__ ((always_inline)); ++void ext_inline_code(int) __attribute__ ((always_inline)); + #endif + + void +diff --git a/gprofng/testsuite/gprofng.display/synprog/synprog.c b/gprofng/testsuite/gprofng.display/synprog/synprog.c +index cf1bc5b0909..05920dc7419 100644 +--- a/gprofng/testsuite/gprofng.display/synprog/synprog.c ++++ b/gprofng/testsuite/gprofng.display/synprog/synprog.c +@@ -528,14 +528,14 @@ reapchildren () + int + doabort (int k) + { +- char *nullptr = NULL; ++ char *p = NULL; + char c; + + /* Log the event */ + wlog ("start of doabort", NULL); + + /* and dereference a NULL */ +- c = *nullptr; ++ c = *p; + + /* this should never be reached */ + return (int) c; +-- +2.50.1 + diff --git a/package/binutils/make-host.sh b/package/binutils/make-host.sh new file mode 100755 index 0000000..2fe6715 --- /dev/null +++ b/package/binutils/make-host.sh @@ -0,0 +1,49 @@ +#!/usr/bin/bash +source $(dirname "$0")/../common.sh + +PKGNAME=binutils +PKGVERSION=2.43.1 +PKGSOURCE_DIR=binutils +PKGSOURCE=binutils-2.43.1.tar.xz +PKGURL=http://mirrors.ustc.edu.cn/gnu/binutils/binutils-2.43.1.tar.xz + +PKGBUILDNAME=host-${PKGNAME} +PKGBUILD_DIR=${BUILD_DIR}/${PKGBUILDNAME}-${PKGVERSION} + +echo "----> Building ${PKGBUILDNAME} ..." + +stamp_downloaded + +step_start extract +mkdir -p ${PKGBUILD_DIR} +xzcat ${DL_DIR}/${PKGSOURCE_DIR}/${PKGSOURCE} | tar --strip-components=1 -C ${PKGBUILD_DIR} -xf - +chmod -R +rw ${PKGBUILD_DIR} +step_end extract + +step_start patch +TAR="tar" PATH=${HOST_DIR}/bin:$PATH ${PROJECT_DIR}/support/scripts/apply-patches.sh ${PKGBUILD_DIR} ${PROJECT_DIR}/package/${PKGNAME}/${PKGVERSION} \*.patch +step_end patch autotools + +step_start configure +(cd ${PKGBUILD_DIR} && rm -rf config.cache; eval "${HOST_CONFIGURE_OPTS} MAKEINFO=true CONFIG_SITE=/dev/null ./configure --prefix=\"${HOST_DIR}\" --sysconfdir=\"${HOST_DIR}/etc\" --localstatedir=\"${HOST_DIR}/var\" --enable-shared --disable-static --disable-gtk-doc --disable-gtk-doc-html --disable-doc --disable-docs --disable-documentation --disable-debug --with-xmlto=no --with-fop=no --disable-nls --disable-dependency-tracking --disable-multilib --disable-werror --target=${GNU_TARGET_NAME} --disable-shared --enable-static --with-sysroot=${STAGING_DIR} --enable-poison-system-directories --without-debuginfod --enable-plugins --enable-lto --disable-sim --disable-gdb --without-zstd --with-system-readline --disable-gprofng") +step_end configure + +step_start build +eval "${HOST_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} MAKEINFO=true -C ${PKGBUILD_DIR}" +step_end build + +step_start install-host +eval "${HOST_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} MAKEINFO=true install -C ${PKGBUILD_DIR}" +# Hardlinks between binaries in different directories cause a problem +# with rpath fixup, so we de-hardlink those binaries, and replace them +# with copies instead. +BINUTILS_TOOLS="ar as ld ld.bfd nm objcopy objdump ranlib readelf strip" +for tool in ${BINUTILS_TOOLS}; do + rm -f ${HOST_DIR}/${GNU_TARGET_NAME}/bin/${tool} && \ + cp -a ${HOST_DIR}/bin/${GNU_TARGET_NAME}-${tool} ${HOST_DIR}/${GNU_TARGET_NAME}/bin/${tool} +done +step_end install-host + +stamp_installed + +echo "<---- ${PKGBUILDNAME} build complete." diff --git a/package/bison/make-host.sh b/package/bison/make-host.sh new file mode 100755 index 0000000..9f08c34 --- /dev/null +++ b/package/bison/make-host.sh @@ -0,0 +1,40 @@ +#!/usr/bin/bash +source $(dirname "$0")/../common.sh + +PKGNAME=bison +PKGVERSION=3.8.2 +PKGSOURCE_DIR=bison +PKGSOURCE=bison-3.8.2.tar.xz +PKGURL=http://mirrors.ustc.edu.cn/gnu/bison/bison-3.8.2.tar.xz + +PKGBUILDNAME=host-${PKGNAME} +PKGBUILD_DIR=${BUILD_DIR}/${PKGBUILDNAME}-${PKGVERSION} + +echo "----> Building ${PKGBUILDNAME} ..." + +stamp_downloaded + +step_start extract +mkdir -p ${PKGBUILD_DIR} +xzcat ${DL_DIR}/${PKGSOURCE_DIR}/${PKGSOURCE} | tar --strip-components=1 -C ${PKGBUILD_DIR} -xf - +chmod -R +rw ${PKGBUILD_DIR} +step_end extract + +stamp_patched autotools + +step_start configure +(cd ${PKGBUILD_DIR} && rm -rf config.cache; eval "${HOST_CONFIGURE_OPTS} ac_cv_libtextstyle=no CONFIG_SITE=/dev/null ./configure --prefix=\"${HOST_DIR}\" --sysconfdir=\"${HOST_DIR}/etc\" --localstatedir=\"${HOST_DIR}/var\" --enable-shared --disable-static --disable-gtk-doc --disable-gtk-doc-html --disable-doc --disable-docs --disable-documentation --disable-debug --with-xmlto=no --with-fop=no --disable-nls --disable-dependency-tracking --enable-relocatable") +step_end configure + +step_start build +# parallel build issue in examples/c/reccalc/, so use -j1 +eval "${HOST_MAKE_ENV} /usr/bin/make -j1 -C ${PKGBUILD_DIR}" +step_end build + +step_start install-host +eval "${HOST_MAKE_ENV} /usr/bin/make -j1 install -C ${PKGBUILD_DIR}" +step_end install-host + +stamp_installed + +echo "<---- ${PKGBUILDNAME} build complete." diff --git a/package/busybox/0001-networking-libiproute-use-linux-if_packet.h-instead-.patch b/package/busybox/0001-networking-libiproute-use-linux-if_packet.h-instead-.patch new file mode 100644 index 0000000..76d9a37 --- /dev/null +++ b/package/busybox/0001-networking-libiproute-use-linux-if_packet.h-instead-.patch @@ -0,0 +1,37 @@ +From e1690453cd84c798ca88cc4370710f65da86d986 Mon Sep 17 00:00:00 2001 +From: Thomas Petazzoni +Date: Sat, 5 Oct 2013 15:55:06 +0200 +Subject: [PATCH] networking/libiproute: use instead of + + +The musl C library doesn't provide the since the +corresponding kernel headers already provides the +necessary definitions. Replacing by + also removes the need to include + + +This commit fixes the build of iplink with the musl C library. + +Signed-off-by: Thomas Petazzoni +[Gustavo: update for busybox 1.22.0] +Signed-off-by: Petr Vorel +--- + networking/libiproute/iplink.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/networking/libiproute/iplink.c b/networking/libiproute/iplink.c +index 37ed114bc..bc526d89c 100644 +--- a/networking/libiproute/iplink.c ++++ b/networking/libiproute/iplink.c +@@ -7,7 +7,7 @@ + */ + #include + /*#include - not needed? */ +-#include ++#include + #include + + #include +-- +2.48.1 + diff --git a/package/busybox/0002-Makefile.flags-strip-non-l-arguments-returned-by-pkg.patch b/package/busybox/0002-Makefile.flags-strip-non-l-arguments-returned-by-pkg.patch new file mode 100644 index 0000000..040b0b2 --- /dev/null +++ b/package/busybox/0002-Makefile.flags-strip-non-l-arguments-returned-by-pkg.patch @@ -0,0 +1,32 @@ +From df20ae1280a2601a4c233ec12372d1e17db21e96 Mon Sep 17 00:00:00 2001 +From: Thomas Petazzoni +Date: Mon, 25 Nov 2013 22:51:53 +0100 +Subject: [PATCH] Makefile.flags: strip non -l arguments returned by pkg-config + +Signed-off-by: Thomas Petazzoni +[yann.morin.1998@free.fr: refresh for 1.29.0] +[petr.vorel@gmail.com: refresh for 1.32.0] +Signed-off-by: "Yann E. MORIN" +Signed-off-by: Petr Vorel +--- + Makefile.flags | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/Makefile.flags b/Makefile.flags +index 97cb4dca2..92a9063d9 100644 +--- a/Makefile.flags ++++ b/Makefile.flags +@@ -181,7 +181,9 @@ ifeq ($(CONFIG_SELINUX),y) + SELINUX_PC_MODULES = libselinux libsepol + $(eval $(call pkg_check_modules,SELINUX,$(SELINUX_PC_MODULES))) + CPPFLAGS += $(SELINUX_CFLAGS) +-LDLIBS += $(if $(SELINUX_LIBS),$(SELINUX_LIBS:-l%=%),$(SELINUX_PC_MODULES:lib%=%)) ++LDLIBS += $(if $(SELINUX_LIBS),\ ++ $(patsubst -l%,%,$(filter -l%,$(SELINUX_LIBS))),\ ++ $(SELINUX_PC_MODULES:lib%=%)) + endif + + ifeq ($(CONFIG_FEATURE_NSLOOKUP_BIG),y) +-- +2.48.1 + diff --git a/package/busybox/0003-libbb-sockaddr2str-ensure-only-printable-characters-.patch b/package/busybox/0003-libbb-sockaddr2str-ensure-only-printable-characters-.patch new file mode 100644 index 0000000..c7800b5 --- /dev/null +++ b/package/busybox/0003-libbb-sockaddr2str-ensure-only-printable-characters-.patch @@ -0,0 +1,42 @@ +From 68eaf20d86d4fe0f16a914817217f386155157cc Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Mon, 19 Sep 2022 14:15:12 +0200 +Subject: [PATCH] libbb: sockaddr2str: ensure only printable characters are + returned for the hostname part + +CVE: CVE-2022-28391 +Signed-off-by: Ariadne Conill +Tested-by: Radoslav Kolev +Backport from ML: http://lists.busybox.net/pipermail/busybox/2022-July/089796.html +Signed-off-by: Quentin Schulz +--- + libbb/xconnect.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/libbb/xconnect.c b/libbb/xconnect.c +index 0e0b247b8..02c061e67 100644 +--- a/libbb/xconnect.c ++++ b/libbb/xconnect.c +@@ -497,8 +497,9 @@ static char* FAST_FUNC sockaddr2str(const struct sockaddr *sa, int flags) + ); + if (rc) + return NULL; ++ /* ensure host contains only printable characters */ + if (flags & IGNORE_PORT) +- return xstrdup(host); ++ return xstrdup(printable_string(host)); + #if ENABLE_FEATURE_IPV6 + if (sa->sa_family == AF_INET6) { + if (strchr(host, ':')) /* heh, it's not a resolved hostname */ +@@ -509,7 +510,7 @@ static char* FAST_FUNC sockaddr2str(const struct sockaddr *sa, int flags) + #endif + /* For now we don't support anything else, so it has to be INET */ + /*if (sa->sa_family == AF_INET)*/ +- return xasprintf("%s:%s", host, serv); ++ return xasprintf("%s:%s", printable_string(host), serv); + /*return xstrdup(host);*/ + } + +-- +2.48.1 + diff --git a/package/busybox/0004-nslookup-sanitize-all-printed-strings-with-printable.patch b/package/busybox/0004-nslookup-sanitize-all-printed-strings-with-printable.patch new file mode 100644 index 0000000..3396441 --- /dev/null +++ b/package/busybox/0004-nslookup-sanitize-all-printed-strings-with-printable.patch @@ -0,0 +1,69 @@ +From 56b84c6efb9a06ae294eb92cf9634f70af443b0a Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Mon, 19 Sep 2022 14:15:12 +0200 +Subject: [PATCH] nslookup: sanitize all printed strings with printable_string + +Otherwise, terminal sequences can be injected, which enables various terminal injection +attacks from DNS results. + +CVE: CVE-2022-28391 +Signed-off-by: Ariadne Conill +Tested-by: Radoslav Kolev +Backport from ML: http://lists.busybox.net/pipermail/busybox/2022-July/089795.html +Signed-off-by: Quentin Schulz +--- + networking/nslookup.c | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +diff --git a/networking/nslookup.c b/networking/nslookup.c +index b67d354f7..79412477c 100644 +--- a/networking/nslookup.c ++++ b/networking/nslookup.c +@@ -784,7 +784,7 @@ static NOINLINE int parse_reply(const unsigned char *msg, size_t len) + //printf("Unable to uncompress domain: %s\n", strerror(errno)); + return -1; + } +- printf(format, ns_rr_name(rr), dname); ++ printf(format, ns_rr_name(rr), printable_string(dname)); + break; + + case ns_t_mx: +@@ -799,7 +799,7 @@ static NOINLINE int parse_reply(const unsigned char *msg, size_t len) + //printf("Cannot uncompress MX domain: %s\n", strerror(errno)); + return -1; + } +- printf("%s\tmail exchanger = %d %s\n", ns_rr_name(rr), n, dname); ++ printf("%s\tmail exchanger = %d %s\n", ns_rr_name(rr), n, printable_string(dname)); + break; + + case ns_t_txt: +@@ -811,7 +811,7 @@ static NOINLINE int parse_reply(const unsigned char *msg, size_t len) + if (n > 0) { + memset(dname, 0, sizeof(dname)); + memcpy(dname, ns_rr_rdata(rr) + 1, n); +- printf("%s\ttext = \"%s\"\n", ns_rr_name(rr), dname); ++ printf("%s\ttext = \"%s\"\n", ns_rr_name(rr), printable_string(dname)); + } + break; + +@@ -831,7 +831,7 @@ static NOINLINE int parse_reply(const unsigned char *msg, size_t len) + } + + printf("%s\tservice = %u %u %u %s\n", ns_rr_name(rr), +- ns_get16(cp), ns_get16(cp + 2), ns_get16(cp + 4), dname); ++ ns_get16(cp), ns_get16(cp + 2), ns_get16(cp + 4), printable_string(dname)); + break; + + case ns_t_soa: +@@ -860,7 +860,7 @@ static NOINLINE int parse_reply(const unsigned char *msg, size_t len) + return -1; + } + +- printf("\tmail addr = %s\n", dname); ++ printf("\tmail addr = %s\n", printable_string(dname)); + cp += n; + + printf("\tserial = %lu\n", ns_get32(cp)); +-- +2.48.1 + diff --git a/package/busybox/0005-seedrng-fix-getrandom-detection-for-non-glibc-libc.patch b/package/busybox/0005-seedrng-fix-getrandom-detection-for-non-glibc-libc.patch new file mode 100644 index 0000000..84d7df1 --- /dev/null +++ b/package/busybox/0005-seedrng-fix-getrandom-detection-for-non-glibc-libc.patch @@ -0,0 +1,106 @@ +From 9fed109be1f811069cb2f727e04c6996cd44b017 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Rapha=C3=ABl=20M=C3=A9lotte?= +Date: Tue, 18 Apr 2023 15:54:43 +0200 +Subject: [PATCH] seedrng: fix getrandom() detection for non-glibc libc +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +glibc <= 2.24 does not provide getrandom(). A check for it has been +added in 200a9669fbf6f06894e4243cccc9fc11a1a6073a and fixed in +cb57abb46f06f4ede8d9ccbdaac67377fdf416cf. + +However, building with a libc other than glibc can lead to the same +problem as not every other libc has getrandom() either: + +- uClibc provides it from v1.0.2 onwards, but requires to define +_GNU_SOURCE (all versions - we already define it by default), and +stddef to be included first (when using uClibc < 1.0.35 - we already +include it through libbb.h). + +- musl libc has getrandom(), but only from version 1.1.20 onwards. As +musl does not provide __MUSL__ or version information, it's not +possible to check for it like we did for glibc. + +All of this makes it difficult (or impossible in case of musl) to +check what we need to do to have getrandom() based on each libc +versions. + +On top of that, getrandom() is also not available on older kernels. As +an example, when using a 3.10 kernel with uClibc 1.0.26, getrandom() +is declared so compiling works, but it fails at link time because +getrandom() is not defined. + +To make it easier, take a similar approach to what was done for the +crypt library: try to build a sample program to see if we have +getrandom(). To keep it compatible with different versions of +make (for reference see [1]), a variable for '#' is also introduced. + +Based on the new Makefile variable, we now either use the +libc-provided getrandom() when it's available, or use our own +implementation when it's not (like it was the case already for glibc < +2.25). + +This should fix compiling with many libc/kernel combinations. + +[1]: https://git.savannah.gnu.org/cgit/make.git/commit/?id=c6966b323811c37acedff05b576b907b06aea5f4 + +Signed-off-by: Raphaël Mélotte +Upstream: http://lists.busybox.net/pipermail/busybox/2023-May/090317.html +--- + Makefile.flags | 12 ++++++++++++ + miscutils/seedrng.c | 8 ++++---- + 2 files changed, 16 insertions(+), 4 deletions(-) + +diff --git a/Makefile.flags b/Makefile.flags +index 92a9063d9..c8f601308 100644 +--- a/Makefile.flags ++++ b/Makefile.flags +@@ -162,6 +162,18 @@ ifeq ($(RT_AVAILABLE),y) + LDLIBS += rt + endif + ++# GNU Make version 4.2.1 and earlier require number signs ('#') ++# inside function invocations to be escaped, while versions 4.3+ ++# require them to be unescaped. Use a variable for it so that it works ++# for both versions: ++C := \# ++# Not all libc versions have getrandom, so check for it: ++HAVE_GETRANDOM := $(shell printf '$Cdefine _GNU_SOURCE\n$Cinclude \n$Cinclude \nint main(void){char buf[256];\ngetrandom(buf,sizeof(buf),0);}' >bb_libtest.c; $(CC) $(CFLAGS) $(CFLAGS_busybox) -o /dev/null bb_libtest.c >/dev/null 2>&1 && echo "y"; rm bb_libtest.c) ++ ++ifeq ($(HAVE_GETRANDOM),y) ++CFLAGS += -DHAVE_GETRANDOM ++endif ++ + # libpam may use libpthread, libdl and/or libaudit. + # On some platforms that requires an explicit -lpthread, -ldl, -laudit. + # However, on *other platforms* it fails when some of those flags +diff --git a/miscutils/seedrng.c b/miscutils/seedrng.c +index 7a2331cb1..ba98f4d19 100644 +--- a/miscutils/seedrng.c ++++ b/miscutils/seedrng.c +@@ -44,8 +44,10 @@ + #include + #include + +-/* Fix up glibc <= 2.24 not having getrandom() */ +-#if defined(__GLIBC__) && __GLIBC__ == 2 && __GLIBC_MINOR__ <= 24 ++/* Fix up some libc (e.g. glibc <= 2.24) not having getrandom() */ ++#if defined HAVE_GETRANDOM ++#include ++#else /* No getrandom */ + #include + static ssize_t getrandom(void *buffer, size_t length, unsigned flags) + { +@@ -56,8 +58,6 @@ static ssize_t getrandom(void *buffer, size_t length, unsigned flags) + return -1; + # endif + } +-#else +-#include + #endif + + /* Apparently some headers don't ship with this yet. */ +-- +2.48.1 + diff --git a/package/busybox/0006-menuconfig-GCC-failing-saying-ncurses-is-not-found.patch b/package/busybox/0006-menuconfig-GCC-failing-saying-ncurses-is-not-found.patch new file mode 100644 index 0000000..5948744 --- /dev/null +++ b/package/busybox/0006-menuconfig-GCC-failing-saying-ncurses-is-not-found.patch @@ -0,0 +1,38 @@ +From 7f0bb7f69f38298971aa8153d3fbe9b1fdda8ae7 Mon Sep 17 00:00:00 2001 +From: ctxnop +Date: Sun, 26 Jan 2025 20:59:20 +0100 +Subject: [PATCH] menuconfig: GCC failing saying ncurses is not found + +Newer GCC increased diagnostics levels resulting in considering the +test code to be invalid. The resulting message was misleading, saying +that ncurses was not found, while the check failed for an unrelated +reason which was hidden because GCC stderr was redirected to +/dev/null. + +Signed-off-by: ctxnop +Upstream: http://lists.busybox.net/pipermail/busybox/2024-July/090840.html +[Fiona: rephrased commit message for clarity] +Signed-off-by: Fiona Klute (WIWA) +--- + scripts/kconfig/lxdialog/check-lxdialog.sh | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/scripts/kconfig/lxdialog/check-lxdialog.sh b/scripts/kconfig/lxdialog/check-lxdialog.sh +index 5075ebf2d..08e4da3de 100755 +--- a/scripts/kconfig/lxdialog/check-lxdialog.sh ++++ b/scripts/kconfig/lxdialog/check-lxdialog.sh +@@ -45,9 +45,9 @@ trap "rm -f $tmp" 0 1 2 3 15 + + # Check if we can link to ncurses + check() { +- $cc -x c - -o $tmp 2>/dev/null <<'EOF' ++ $cc -x c - -o $tmp <<'EOF' + #include CURSES_LOC +-main() {} ++int main() { return 0; } + EOF + if [ $? != 0 ]; then + echo " *** Unable to find the ncurses libraries or the" 1>&2 +-- +2.48.1 + diff --git a/package/busybox/0007-tc-Fix-compilation-with-Linux-v6.8-rc1.patch b/package/busybox/0007-tc-Fix-compilation-with-Linux-v6.8-rc1.patch new file mode 100644 index 0000000..c7968de --- /dev/null +++ b/package/busybox/0007-tc-Fix-compilation-with-Linux-v6.8-rc1.patch @@ -0,0 +1,70 @@ +From 1dbb3073a3a8856b9446b882f797be1bb2e21a26 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= +Date: Mon, 23 Sep 2024 18:56:00 +0200 +Subject: [PATCH] tc: Fix compilation with Linux v6.8-rc1 + +Linux v6.8-rc1 removed the definitions related to CBQ: +https://github.com/torvalds/linux/commit/33241dca486264193ed68167c8eeae1fb197f3df +making tc fail to build. +Add some #ifdefs to handle this missing support. + +Upstream: http://lists.busybox.net/pipermail/busybox/2024-March/090678.html +Bug report: https://bugs.busybox.net/show_bug.cgi?id=15931 + +Signed-off-by: Bernd Kuhls +--- + networking/tc.c | 12 ++++++++++++ + 1 file changed, 12 insertions(+) + +diff --git a/networking/tc.c b/networking/tc.c +index 3a79fd2d9..d08fd1359 100644 +--- a/networking/tc.c ++++ b/networking/tc.c +@@ -231,6 +231,13 @@ static int cbq_parse_opt(int argc, char **argv, struct nlmsghdr *n) + return 0; + } + #endif ++ ++#ifndef TCA_CBQ_MAX ++/* ++ * Linux v6.8-rc1~131^2~60^2^2 removed the uapi definitions for CBQ. ++ * See https://git.kernel.org/linus/33241dca48626 ++ */ ++#else + static int cbq_print_opt(struct rtattr *opt) + { + struct rtattr *tb[TCA_CBQ_MAX+1]; +@@ -322,6 +329,7 @@ static int cbq_print_opt(struct rtattr *opt) + done: + return 0; + } ++#endif + + static FAST_FUNC int print_qdisc( + const struct sockaddr_nl *who UNUSED_PARAM, +@@ -372,8 +380,10 @@ static FAST_FUNC int print_qdisc( + int qqq = index_in_strings(_q_, name); + if (qqq == 0) { /* pfifo_fast aka prio */ + prio_print_opt(tb[TCA_OPTIONS]); ++#ifdef TCA_CBQ_MAX + } else if (qqq == 1) { /* class based queuing */ + cbq_print_opt(tb[TCA_OPTIONS]); ++#endif + } else { + /* don't know how to print options for this qdisc */ + printf("(options for %s)", name); +@@ -442,9 +452,11 @@ static FAST_FUNC int print_class( + int qqq = index_in_strings(_q_, name); + if (qqq == 0) { /* pfifo_fast aka prio */ + /* nothing. */ /*prio_print_opt(tb[TCA_OPTIONS]);*/ ++#ifdef TCA_CBQ_MAX + } else if (qqq == 1) { /* class based queuing */ + /* cbq_print_copt() is identical to cbq_print_opt(). */ + cbq_print_opt(tb[TCA_OPTIONS]); ++#endif + } else { + /* don't know how to print options for this class */ + printf("(options for %s)", name); +-- +2.48.1 + diff --git a/package/busybox/0008-awk.c-fix-CVE-2023-42366-bug-15874.patch b/package/busybox/0008-awk.c-fix-CVE-2023-42366-bug-15874.patch new file mode 100644 index 0000000..f973223 --- /dev/null +++ b/package/busybox/0008-awk.c-fix-CVE-2023-42366-bug-15874.patch @@ -0,0 +1,43 @@ +From 88f8a046f27cb81ccc30d038465e963b8300cf1b Mon Sep 17 00:00:00 2001 +From: Valery Ushakov +Date: Wed, 24 Jan 2024 22:24:41 +0300 +Subject: [PATCH] awk.c: fix CVE-2023-42366 (bug #15874) + +Make sure we don't read past the end of the string in next_token() +when backslash is the last character in an (invalid) regexp. +a fix and issue reported in bugzilla + +https://bugs.busybox.net/show_bug.cgi?id=15874 + +Upstream-Status: Submitted [http://lists.busybox.net/pipermail/busybox/2024-May/090766.html] + +CVE: CVE-2023-42366 +Signed-off-by: Khem Raj +[Thomas: https://git.openembedded.org/openembedded-core/tree/meta/recipes-core/busybox/busybox/0001-awk.c-fix-CVE-2023-42366-bug-15874.patch?id=e0ff4813b1cf4df0d851c857d57fb88d7db51bdd] +Upstream: http://lists.busybox.net/pipermail/busybox/2024-May/090766.html +Signed-off-by: Thomas Petazzoni +--- + editors/awk.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/editors/awk.c b/editors/awk.c +index 64e752f4b..222e6298d 100644 +--- a/editors/awk.c ++++ b/editors/awk.c +@@ -1234,9 +1234,11 @@ static uint32_t next_token(uint32_t expected) + s[-1] = bb_process_escape_sequence((const char **)&pp); + if (*p == '\\') + *s++ = '\\'; +- if (pp == p) ++ if (pp == p) { ++ if (*p == '\0') ++ syntax_error(EMSG_UNEXP_EOS); + *s++ = *p++; +- else ++ } else + p = pp; + } + } +-- +2.48.1 + diff --git a/package/busybox/0009-hwclock-Check-for-SYS_settimeofday-before-calling-sy.patch b/package/busybox/0009-hwclock-Check-for-SYS_settimeofday-before-calling-sy.patch new file mode 100644 index 0000000..1e95fae --- /dev/null +++ b/package/busybox/0009-hwclock-Check-for-SYS_settimeofday-before-calling-sy.patch @@ -0,0 +1,54 @@ +From 0583f8eda94f97e15e371e12458877b738439e8c Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Sun, 7 Mar 2021 17:30:24 -0800 +Subject: [PATCH] hwclock: Check for SYS_settimeofday before calling syscall + +Some newer architectures e.g. RISCV32 have 64bit time_t from get go and +thusly do not have gettimeofday_time64/settimeofday_time64 implemented +therefore check for SYS_settimeofday definition before making the +syscall. Fixes build for riscv32 and it will bail out at runtime. + +Upstream-Status: Submitted [http://lists.busybox.net/pipermail/busybox/2021-March/088583.html] +Signed-off-by: Khem Raj +Upstream: http://lists.busybox.net/pipermail/busybox/2021-March/088583.html +[Thomas: this issue has been discussed on the musl mailing list, and +the musl developers' opinion is that Busybox is wrong: +https://www.openwall.com/lists/musl/2024/03/03/2 +https://www.openwall.com/lists/musl/2024/04/07/2. The correct fix +isn't clear, and in the mean time, the patch from Khem turns the build +issue into a runtime error only on the problematic architecture, which +seems like a reasonable trade-off] +Signed-off-by: Thomas Petazzoni +--- + util-linux/hwclock.c | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +diff --git a/util-linux/hwclock.c b/util-linux/hwclock.c +index c3fd0eb57..dea9c9a55 100644 +--- a/util-linux/hwclock.c ++++ b/util-linux/hwclock.c +@@ -132,6 +132,7 @@ static void show_clock(const char **pp_rtcname, int utc) + + static void set_kernel_tz(const struct timezone *tz) + { ++ int ret = 1; + #if LIBC_IS_MUSL + /* musl libc does not pass tz argument to syscall + * because "it's deprecated by POSIX, therefore it's fine +@@ -140,9 +141,11 @@ static void set_kernel_tz(const struct timezone *tz) + #if !defined(SYS_settimeofday) && defined(SYS_settimeofday_time32) + # define SYS_settimeofday SYS_settimeofday_time32 + #endif +- int ret = syscall(SYS_settimeofday, NULL, tz); ++#if defined(SYS_settimeofday) ++ ret = syscall(SYS_settimeofday, NULL, tz); ++#endif + #else +- int ret = settimeofday(NULL, tz); ++ ret = settimeofday(NULL, tz); + #endif + if (ret) + bb_simple_perror_msg_and_die("settimeofday"); +-- +2.48.1 + diff --git a/package/busybox/0010-libbb-sha-add-missing-sha-NI-guard.patch b/package/busybox/0010-libbb-sha-add-missing-sha-NI-guard.patch new file mode 100644 index 0000000..0fd7014 --- /dev/null +++ b/package/busybox/0010-libbb-sha-add-missing-sha-NI-guard.patch @@ -0,0 +1,54 @@ +From bba9e99026a3dafe75f608459533e0b6d8cf3874 Mon Sep 17 00:00:00 2001 +From: Andre Przywara +Date: Tue, 10 Sep 2024 14:32:46 +0100 +Subject: [PATCH] libbb/sha: add missing sha-NI guard +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The ENABLE_SHA1_HWACCEL Kconfig symbol is meant to be archicture +agnostic, so can be enabled regardless of whether your build +architecture provides hardware acceleration or not. At the moment only +x86 implements this, so every piece of optimised code should be guarded +by both ENABLE_SHA1_HWACCEL and (__x86_64__ || __i386__). This is missing +at one place, so compiling for arm64 breaks when ENABLE_SHA1_HWACCEL is +enabled: +================================ +libbb/hash_md5_sha.c: In function ‘sha1_end’: +libbb/hash_md5_sha.c:1316:28: error: ‘sha1_process_block64_shaNI’ undeclared (first use in this function); did you mean ‘sha1_process_block64’? + 1316 | || ctx->process_block == sha1_process_block64_shaNI + | ^~~~~~~~~~~~~~~~~~~~~~~~~~ + | sha1_process_block64 +libbb/hash_md5_sha.c:1316:28: note: each undeclared identifier is reported only once for each function it appears in +make[1]: *** [scripts/Makefile.build:197: libbb/hash_md5_sha.o] Error 1 +make: *** [Makefile:744: libbb] Error 2 +================================ + +Add the missing guards around the call to sha1_process_block64_shaNI to +fix the build on other architectures with ENABLE_SHA1_HWACCEL enabled. + +Change-Id: I40bba388422625f4230abf15a5de23e1fdc654fc +Signed-off-by: Andre Przywara +Upstream: https://lists.busybox.net/pipermail/busybox/2024-September/090899.html +Signed-off-by: Thomas Petazzoni +--- + libbb/hash_md5_sha.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/libbb/hash_md5_sha.c b/libbb/hash_md5_sha.c +index 57a801459..75a61c32c 100644 +--- a/libbb/hash_md5_sha.c ++++ b/libbb/hash_md5_sha.c +@@ -1313,7 +1313,9 @@ unsigned FAST_FUNC sha1_end(sha1_ctx_t *ctx, void *resbuf) + hash_size = 8; + if (ctx->process_block == sha1_process_block64 + #if ENABLE_SHA1_HWACCEL ++# if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) + || ctx->process_block == sha1_process_block64_shaNI ++# endif + #endif + ) { + hash_size = 5; +-- +2.48.1 + diff --git a/package/busybox/0011-syslogd-fix-wrong-OPT_locallog-flag-detection.patch b/package/busybox/0011-syslogd-fix-wrong-OPT_locallog-flag-detection.patch new file mode 100644 index 0000000..1dfd6f3 --- /dev/null +++ b/package/busybox/0011-syslogd-fix-wrong-OPT_locallog-flag-detection.patch @@ -0,0 +1,37 @@ +From 34d331d642c3312e1c04e4650f547f1a67abee24 Mon Sep 17 00:00:00 2001 +From: Andrej Valek +Date: Wed, 16 Oct 2024 10:15:08 +0200 +Subject: [PATCH] syslogd: fix wrong OPT_locallog flag detection + +The OPT_locallog was set on "option_mask32" but checked on local +"opts" variable. While this flag it's used on multiple places can't be +has to be used with "option_mask32". Without this change syslogd +is more-less unusable while no messages are logged locally. + +Signed-off-by: Andrej Valek +Upstream: https://lists.busybox.net/pipermail/busybox/2024-October/090969.html +[Thomas: this was reported as beeing needed by Bernd Kuhls at +https://lore.kernel.org/buildroot/pan$de0bb$35c5a64$ca9b6f21$2408ff40@ID-313208.user.individual.net/, +but also on the Busybox mailing list at +https://lists.busybox.net/pipermail/busybox/2023-September/090499.html] +Signed-off-by: Thomas Petazzoni +--- + sysklogd/syslogd.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c +index 7558051f0..fa03aa280 100644 +--- a/sysklogd/syslogd.c ++++ b/sysklogd/syslogd.c +@@ -1179,7 +1179,7 @@ int syslogd_main(int argc UNUSED_PARAM, char **argv) + } + } + #endif +- if (!ENABLE_FEATURE_REMOTE_LOG || (opts & OPT_locallog)) { ++ if (!ENABLE_FEATURE_REMOTE_LOG || (option_mask32 & OPT_locallog)) { + recvbuf[sz] = '\0'; /* ensure it *is* NUL terminated */ + split_escape_and_log(recvbuf, sz); + } +-- +2.48.1 + diff --git a/package/busybox/S01syslogd b/package/busybox/S01syslogd new file mode 100644 index 0000000..a1f4bbf --- /dev/null +++ b/package/busybox/S01syslogd @@ -0,0 +1,60 @@ +#!/bin/sh + +DAEMON="syslogd" +PIDFILE="/var/run/$DAEMON.pid" + +SYSLOGD_ARGS="" + +# shellcheck source=/dev/null +[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON" + +# BusyBox' syslogd does not create a pidfile, so pass "-n" in the command line +# and use "--make-pidfile" to instruct start-stop-daemon to create one. +start() { + printf 'Starting %s: ' "$DAEMON" + # shellcheck disable=SC2086 # we need the word splitting + start-stop-daemon --start --background --make-pidfile \ + --pidfile "$PIDFILE" --exec "/sbin/$DAEMON" \ + -- -n $SYSLOGD_ARGS + status=$? + if [ "$status" -eq 0 ]; then + echo "OK" + else + echo "FAIL" + fi + return "$status" +} + +stop() { + printf 'Stopping %s: ' "$DAEMON" + start-stop-daemon --stop --pidfile "$PIDFILE" --exec "/sbin/$DAEMON" + status=$? + if [ "$status" -eq 0 ]; then + echo "OK" + else + echo "FAIL" + return "$status" + fi + while start-stop-daemon --stop --test --quiet --pidfile "$PIDFILE" \ + --exec "/sbin/$DAEMON"; do + sleep 0.1 + done + rm -f "$PIDFILE" + return "$status" +} + +restart() { + stop + start +} + +case "$1" in + start|stop|restart) + "$1";; + reload) + # Restart, since there is no true "reload" feature. + restart;; + *) + echo "Usage: $0 {start|stop|restart|reload}" + exit 1 +esac diff --git a/package/busybox/S02klogd b/package/busybox/S02klogd new file mode 100644 index 0000000..0677e1e --- /dev/null +++ b/package/busybox/S02klogd @@ -0,0 +1,55 @@ +#!/bin/sh + +DAEMON="klogd" +PIDFILE="/var/run/$DAEMON.pid" + +KLOGD_ARGS="" + +# shellcheck source=/dev/null +[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON" + +# BusyBox' klogd does not create a pidfile, so pass "-n" in the command line +# and use "-m" to instruct start-stop-daemon to create one. +start() { + printf 'Starting %s: ' "$DAEMON" + # shellcheck disable=SC2086 # we need the word splitting + start-stop-daemon -b -m -S -q -p "$PIDFILE" -x "/sbin/$DAEMON" \ + -- -n $KLOGD_ARGS + status=$? + if [ "$status" -eq 0 ]; then + echo "OK" + else + echo "FAIL" + fi + return "$status" +} + +stop() { + printf 'Stopping %s: ' "$DAEMON" + start-stop-daemon -K -q -p "$PIDFILE" + status=$? + if [ "$status" -eq 0 ]; then + rm -f "$PIDFILE" + echo "OK" + else + echo "FAIL" + fi + return "$status" +} + +restart() { + stop + sleep 1 + start +} + +case "$1" in + start|stop|restart) + "$1";; + reload) + # Restart, since there is no true "reload" feature. + restart;; + *) + echo "Usage: $0 {start|stop|restart|reload}" + exit 1 +esac diff --git a/package/busybox/S02sysctl b/package/busybox/S02sysctl new file mode 100644 index 0000000..c202833 --- /dev/null +++ b/package/busybox/S02sysctl @@ -0,0 +1,94 @@ +#!/bin/sh +# +# This script is used by busybox and procps-ng. +# +# With procps-ng, the "--system" option of sysctl also enables "--ignore", so +# errors are not reported via syslog. Use the run_logger function to mimic the +# --system behavior, still reporting errors via syslog. Users not interested +# on error reports can add "-e" to SYSCTL_ARGS. +# +# busybox does not have a "--system" option neither reports errors via syslog, +# so the scripting provides a consistent behavior between the implementations. +# Testing the busybox sysctl exit code is fruitless, as at the moment, since +# its exit status is zero even if errors happen. Hopefully this will be fixed +# in a future busybox version. + +PROGRAM="sysctl" + +SYSCTL_ARGS="" + +# shellcheck source=/dev/null +[ -r "/etc/default/$PROGRAM" ] && . "/etc/default/$PROGRAM" + +# Files are read from directories in the SYSCTL_SOURCES list, in the given +# order. A file may be used more than once, since there can be multiple +# symlinks to it. No attempt is made to prevent this. +SYSCTL_SOURCES="/etc/sysctl.d/ /usr/local/lib/sysctl.d/ /usr/lib/sysctl.d/ /lib/sysctl.d/ /etc/sysctl.conf" + +# If the logger utility is available all messages are sent to syslog, except +# for the final status. The file redirections do the following: +# +# - stdout is redirected to syslog with facility.level "kern.info" +# - stderr is redirected to syslog with facility.level "kern.err" +# - file dscriptor 4 is used to pass the result to the "start" function. +# +run_logger() { + # shellcheck disable=SC2086 # we need the word splitting + find $SYSCTL_SOURCES -maxdepth 1 -name '*.conf' -print0 2> /dev/null | \ + xargs -0 -r -n 1 readlink -f | { + prog_status="OK" + while :; do + read -r file || { + echo "$prog_status" >&4 + break + } + echo "* Applying $file ..." + /sbin/sysctl $SYSCTL_ARGS -p "$file" || prog_status="FAIL" + done 2>&1 >&3 | /usr/bin/logger -t sysctl -p kern.err + } 3>&1 | /usr/bin/logger -t sysctl -p kern.info +} + +# If logger is not available all messages are sent to stdout/stderr. +run_std() { + # shellcheck disable=SC2086 # we need the word splitting + find $SYSCTL_SOURCES -maxdepth 1 -name '*.conf' -print0 2> /dev/null | \ + xargs -0 -r -n 1 readlink -f | { + prog_status="OK" + while :; do + read -r file || { + echo "$prog_status" >&4 + break + } + echo "* Applying $file ..." + /sbin/sysctl $SYSCTL_ARGS -p "$file" || prog_status="FAIL" + done + } +} + +if [ -x /usr/bin/logger ]; then + run_program="run_logger" +else + run_program="run_std" +fi + +start() { + printf '%s %s: ' "$1" "$PROGRAM" + status=$("$run_program" 4>&1) + echo "$status" + if [ "$status" = "OK" ]; then + return 0 + fi + return 1 +} + +case "$1" in + start) + start "Running";; + restart|reload) + start "Rerunning";; + stop) + :;; + *) + echo "Usage: $0 {start|stop|restart|reload}" + exit 1 +esac diff --git a/package/busybox/S41ifplugd b/package/busybox/S41ifplugd new file mode 100644 index 0000000..8c2c1a5 --- /dev/null +++ b/package/busybox/S41ifplugd @@ -0,0 +1,85 @@ +#!/bin/sh + +DAEMON="ifplugd" + +# Each ifplugd instance handles only one interface, so this script is +# designed to be symlinked per interface. For each interface create a +# symlink with .IFACE appended to the name. E.g. to launch ifplugd for +# eth1 create a symlink from /etc/init.d/S41ifplugd.eth1 to this +# script. DEFAULT_IFACE sets the interface the non-symlink script will +# use, set it to empty in /etc/default/ifplugd to disable the default +# instance and use symlinked instances only. +DEFAULT_IFACE="eth0" +# If your action script is not in the default location +# /etc/ifplugd/ifplugd.action, use the "-r" option to set the +# location. +IFPLUGD_ARGS="-M" + +# shellcheck source=/dev/null +[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON" + +NAME_IFACE="$(basename "$0" | cut -s -d. -f2)" +if [ -n "$NAME_IFACE" ]; then + IFACE="${NAME_IFACE}" +elif [ -n "$DEFAULT_IFACE" ]; then + IFACE="${DEFAULT_IFACE}" +else + # no interface configured + exit 0 +fi + +# check-package disable Variables +PIDFILE="/var/run/${DAEMON}.${IFACE}.pid" +IFPLUGD_ARGS="${IFPLUGD_ARGS} -i ${IFACE}" + +# BusyBox' ifplugd does not create a pidfile, so pass "-n" in the +# command line and use "--make-pidfile" to instruct start-stop-daemon +# to create one. +start() { + printf 'Starting %s for %s: ' "$DAEMON" "$IFACE" + # shellcheck disable=SC2086 # we need the word splitting + start-stop-daemon --start --background --make-pidfile \ + --pidfile "$PIDFILE" --exec "/usr/sbin/$DAEMON" \ + -- -n $IFPLUGD_ARGS + status=$? + if [ "$status" -eq 0 ]; then + echo "OK" + else + echo "FAIL" + fi + return "$status" +} + +stop() { + printf 'Stopping %s for %s: ' "$DAEMON" "$IFACE" + start-stop-daemon --stop --pidfile "$PIDFILE" --exec "/usr/sbin/$DAEMON" + status=$? + if [ "$status" -eq 0 ]; then + echo "OK" + else + echo "FAIL" + return "$status" + fi + while start-stop-daemon --stop --test --quiet --pidfile "$PIDFILE" \ + --exec "/sbin/$DAEMON"; do + sleep 0.1 + done + rm -f "$PIDFILE" + return "$status" +} + +restart() { + stop + start +} + +case "$1" in + start|stop|restart) + "$1";; + reload) + # Restart, since there is no true "reload" feature. + restart;; + *) + echo "Usage: $0 {start|stop|restart|reload}" + exit 1 +esac diff --git a/package/busybox/S50crond b/package/busybox/S50crond new file mode 100644 index 0000000..7083a36 --- /dev/null +++ b/package/busybox/S50crond @@ -0,0 +1,60 @@ +#!/bin/sh + +DAEMON="crond" +PIDFILE="/var/run/$DAEMON.pid" + +CROND_ARGS="" + +# shellcheck source=/dev/null +[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON" + +# BusyBox' crond does not create a pidfile, so pass "-f" on the crond +# command line and use "--make-pidfile" to instruct start-stop-daemon +# to create one. +start() { + printf 'Starting %s: ' "$DAEMON" + # shellcheck disable=SC2086 # we need the word splitting + start-stop-daemon --start --background --make-pidfile \ + --pidfile "$PIDFILE" --exec "/usr/sbin/$DAEMON" \ + -- -f $CROND_ARGS + status=$? + if [ "$status" -eq 0 ]; then + echo "OK" + else + echo "FAIL" + fi + return "$status" +} + +stop() { + printf 'Stopping %s: ' "$DAEMON" + start-stop-daemon --stop --pidfile "$PIDFILE" --exec "/usr/sbin/$DAEMON" + status=$? + if [ "$status" -eq 0 ]; then + echo "OK" + else + echo "FAIL" + fi + while start-stop-daemon --stop --test --quiet --pidfile "$PIDFILE" \ + --exec "/usr/sbin/$DAEMON"; do + sleep 0.1 + done + rm -f "$PIDFILE" + return "$status" +} + +restart() { + stop + start +} + +case "$1" in + start|stop|restart) + "$1";; + reload) + # Restart, since there is no true "reload" feature. + restart;; + *) + echo "Usage: $0 {start|stop|restart|reload}" + exit 1 +esac diff --git a/package/busybox/S50telnet b/package/busybox/S50telnet new file mode 100644 index 0000000..82952b8 --- /dev/null +++ b/package/busybox/S50telnet @@ -0,0 +1,39 @@ +#!/bin/sh +# +# Start telnet.... +# + +TELNETD_ARGS=-F +[ -r /etc/default/telnet ] && . /etc/default/telnet + +start() { + printf "Starting telnetd: " + start-stop-daemon -S -q -m -b -p /var/run/telnetd.pid \ + -x /usr/sbin/telnetd -- $TELNETD_ARGS + [ $? = 0 ] && echo "OK" || echo "FAIL" +} + +stop() { + printf "Stopping telnetd: " + start-stop-daemon -K -q -p /var/run/telnetd.pid \ + -x /usr/sbin/telnetd + [ $? = 0 ] && echo "OK" || echo "FAIL" +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart|reload) + stop + start + ;; + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 +esac + +exit $? diff --git a/package/busybox/busybox.config b/package/busybox/busybox.config new file mode 100644 index 0000000..823fcd2 --- /dev/null +++ b/package/busybox/busybox.config @@ -0,0 +1,1227 @@ +# +# Automatically generated make config: don't edit +# Busybox version: 1.36.1 +# Wed May 8 17:25:31 2024 +# +CONFIG_HAVE_DOT_CONFIG=y + +# +# Settings +# +CONFIG_DESKTOP=y +# CONFIG_EXTRA_COMPAT is not set +# CONFIG_FEDORA_COMPAT is not set +CONFIG_INCLUDE_SUSv2=y +CONFIG_LONG_OPTS=y +CONFIG_SHOW_USAGE=y +CONFIG_FEATURE_VERBOSE_USAGE=y +# CONFIG_FEATURE_COMPRESS_USAGE is not set +CONFIG_LFS=y +# CONFIG_PAM is not set +CONFIG_FEATURE_DEVPTS=y +CONFIG_FEATURE_UTMP=y +CONFIG_FEATURE_WTMP=y +# CONFIG_FEATURE_PIDFILE is not set +CONFIG_PID_FILE_PATH="" +CONFIG_BUSYBOX=y +CONFIG_FEATURE_SHOW_SCRIPT=y +CONFIG_FEATURE_INSTALLER=y +# CONFIG_INSTALL_NO_USR is not set +CONFIG_FEATURE_SUID=y +# CONFIG_FEATURE_SUID_CONFIG is not set +# CONFIG_FEATURE_SUID_CONFIG_QUIET is not set +# CONFIG_FEATURE_PREFER_APPLETS is not set +CONFIG_BUSYBOX_EXEC_PATH="/proc/self/exe" +# CONFIG_SELINUX is not set +# CONFIG_FEATURE_CLEAN_UP is not set +CONFIG_FEATURE_SYSLOG_INFO=y +CONFIG_FEATURE_SYSLOG=y + +# +# Build Options +# +# CONFIG_STATIC is not set +# CONFIG_PIE is not set +# CONFIG_NOMMU is not set +# CONFIG_BUILD_LIBBUSYBOX is not set +# CONFIG_FEATURE_LIBBUSYBOX_STATIC is not set +# CONFIG_FEATURE_INDIVIDUAL is not set +# CONFIG_FEATURE_SHARED_BUSYBOX is not set +CONFIG_CROSS_COMPILER_PREFIX="" +CONFIG_SYSROOT="" +CONFIG_EXTRA_CFLAGS="" +CONFIG_EXTRA_LDFLAGS="" +CONFIG_EXTRA_LDLIBS="" +# CONFIG_USE_PORTABLE_CODE is not set +# CONFIG_STACK_OPTIMIZATION_386 is not set +CONFIG_STATIC_LIBGCC=y + +# +# Installation Options ("make install" behavior) +# +CONFIG_INSTALL_APPLET_SYMLINKS=y +# CONFIG_INSTALL_APPLET_HARDLINKS is not set +# CONFIG_INSTALL_APPLET_SCRIPT_WRAPPERS is not set +# CONFIG_INSTALL_APPLET_DONT is not set +# CONFIG_INSTALL_SH_APPLET_SYMLINK is not set +# CONFIG_INSTALL_SH_APPLET_HARDLINK is not set +# CONFIG_INSTALL_SH_APPLET_SCRIPT_WRAPPER is not set +CONFIG_PREFIX="./_install" + +# +# Debugging Options +# +# CONFIG_DEBUG is not set +# CONFIG_DEBUG_PESSIMIZE is not set +# CONFIG_DEBUG_SANITIZE is not set +# CONFIG_UNIT_TEST is not set +# CONFIG_WERROR is not set +# CONFIG_WARN_SIMPLE_MSG is not set +CONFIG_NO_DEBUG_LIB=y +# CONFIG_DMALLOC is not set +# CONFIG_EFENCE is not set + +# +# Library Tuning +# +# CONFIG_FEATURE_USE_BSS_TAIL is not set +CONFIG_FLOAT_DURATION=y +CONFIG_FEATURE_RTMINMAX=y +CONFIG_FEATURE_RTMINMAX_USE_LIBC_DEFINITIONS=y +CONFIG_FEATURE_BUFFERS_USE_MALLOC=y +# CONFIG_FEATURE_BUFFERS_GO_ON_STACK is not set +# CONFIG_FEATURE_BUFFERS_GO_IN_BSS is not set +CONFIG_PASSWORD_MINLEN=6 +CONFIG_MD5_SMALL=1 +CONFIG_SHA1_SMALL=3 +CONFIG_SHA1_HWACCEL=y +CONFIG_SHA256_HWACCEL=y +CONFIG_SHA3_SMALL=1 +CONFIG_FEATURE_NON_POSIX_CP=y +# CONFIG_FEATURE_VERBOSE_CP_MESSAGE is not set +CONFIG_FEATURE_USE_SENDFILE=y +CONFIG_FEATURE_COPYBUF_KB=4 +CONFIG_MONOTONIC_SYSCALL=y +CONFIG_IOCTL_HEX2STR_ERROR=y +CONFIG_FEATURE_EDITING=y +CONFIG_FEATURE_EDITING_MAX_LEN=1024 +CONFIG_FEATURE_EDITING_VI=y +CONFIG_FEATURE_EDITING_HISTORY=999 +CONFIG_FEATURE_EDITING_SAVEHISTORY=y +CONFIG_FEATURE_EDITING_SAVE_ON_EXIT=y +CONFIG_FEATURE_REVERSE_SEARCH=y +CONFIG_FEATURE_TAB_COMPLETION=y +# CONFIG_FEATURE_USERNAME_COMPLETION is not set +CONFIG_FEATURE_EDITING_FANCY_PROMPT=y +CONFIG_FEATURE_EDITING_WINCH=y +# CONFIG_FEATURE_EDITING_ASK_TERMINAL is not set +# CONFIG_LOCALE_SUPPORT is not set +# CONFIG_UNICODE_SUPPORT is not set +# CONFIG_UNICODE_USING_LOCALE is not set +# CONFIG_FEATURE_CHECK_UNICODE_IN_ENV is not set +CONFIG_SUBST_WCHAR=0 +CONFIG_LAST_SUPPORTED_WCHAR=0 +# CONFIG_UNICODE_COMBINING_WCHARS is not set +# CONFIG_UNICODE_WIDE_WCHARS is not set +# CONFIG_UNICODE_BIDI_SUPPORT is not set +# CONFIG_UNICODE_NEUTRAL_TABLE is not set +# CONFIG_UNICODE_PRESERVE_BROKEN is not set +# CONFIG_LOOP_CONFIGURE is not set +# CONFIG_NO_LOOP_CONFIGURE is not set +CONFIG_TRY_LOOP_CONFIGURE=y + +# +# Applets +# + +# +# Archival Utilities +# +# CONFIG_FEATURE_SEAMLESS_XZ is not set +# CONFIG_FEATURE_SEAMLESS_LZMA is not set +# CONFIG_FEATURE_SEAMLESS_BZ2 is not set +# CONFIG_FEATURE_SEAMLESS_GZ is not set +# CONFIG_FEATURE_SEAMLESS_Z is not set +CONFIG_AR=y +# CONFIG_FEATURE_AR_LONG_FILENAMES is not set +CONFIG_FEATURE_AR_CREATE=y +# CONFIG_UNCOMPRESS is not set +CONFIG_GUNZIP=y +CONFIG_ZCAT=y +CONFIG_FEATURE_GUNZIP_LONG_OPTIONS=y +CONFIG_BUNZIP2=y +CONFIG_BZCAT=y +CONFIG_UNLZMA=y +CONFIG_LZCAT=y +CONFIG_LZMA=y +CONFIG_UNXZ=y +CONFIG_XZCAT=y +CONFIG_XZ=y +# CONFIG_BZIP2 is not set +CONFIG_BZIP2_SMALL=0 +CONFIG_FEATURE_BZIP2_DECOMPRESS=y +CONFIG_CPIO=y +# CONFIG_FEATURE_CPIO_O is not set +# CONFIG_FEATURE_CPIO_P is not set +# CONFIG_FEATURE_CPIO_IGNORE_DEVNO is not set +# CONFIG_FEATURE_CPIO_RENUMBER_INODES is not set +# CONFIG_DPKG is not set +# CONFIG_DPKG_DEB is not set +CONFIG_GZIP=y +# CONFIG_FEATURE_GZIP_LONG_OPTIONS is not set +CONFIG_GZIP_FAST=0 +# CONFIG_FEATURE_GZIP_LEVELS is not set +CONFIG_FEATURE_GZIP_DECOMPRESS=y +# CONFIG_LZOP is not set +CONFIG_UNLZOP=y +CONFIG_LZOPCAT=y +# CONFIG_LZOP_COMPR_HIGH is not set +# CONFIG_RPM is not set +# CONFIG_RPM2CPIO is not set +CONFIG_TAR=y +CONFIG_FEATURE_TAR_LONG_OPTIONS=y +CONFIG_FEATURE_TAR_CREATE=y +# CONFIG_FEATURE_TAR_AUTODETECT is not set +CONFIG_FEATURE_TAR_FROM=y +# CONFIG_FEATURE_TAR_OLDGNU_COMPATIBILITY is not set +# CONFIG_FEATURE_TAR_OLDSUN_COMPATIBILITY is not set +CONFIG_FEATURE_TAR_GNU_EXTENSIONS=y +CONFIG_FEATURE_TAR_TO_COMMAND=y +# CONFIG_FEATURE_TAR_UNAME_GNAME is not set +# CONFIG_FEATURE_TAR_NOPRESERVE_TIME is not set +# CONFIG_FEATURE_TAR_SELINUX is not set +CONFIG_UNZIP=y +CONFIG_FEATURE_UNZIP_CDF=y +CONFIG_FEATURE_UNZIP_BZIP2=y +CONFIG_FEATURE_UNZIP_LZMA=y +CONFIG_FEATURE_UNZIP_XZ=y +# CONFIG_FEATURE_LZMA_FAST is not set + +# +# Coreutils +# +CONFIG_FEATURE_VERBOSE=y + +# +# Common options for date and touch +# +CONFIG_FEATURE_TIMEZONE=y + +# +# Common options for cp and mv +# +CONFIG_FEATURE_PRESERVE_HARDLINKS=y + +# +# Common options for df, du, ls +# +CONFIG_FEATURE_HUMAN_READABLE=y +CONFIG_BASENAME=y +CONFIG_CAT=y +CONFIG_FEATURE_CATN=y +CONFIG_FEATURE_CATV=y +CONFIG_CHGRP=y +CONFIG_CHMOD=y +CONFIG_CHOWN=y +# CONFIG_FEATURE_CHOWN_LONG_OPTIONS is not set +CONFIG_CHROOT=y +CONFIG_CKSUM=y +CONFIG_CRC32=y +# CONFIG_COMM is not set +CONFIG_CP=y +# CONFIG_FEATURE_CP_LONG_OPTIONS is not set +# CONFIG_FEATURE_CP_REFLINK is not set +CONFIG_CUT=y +CONFIG_FEATURE_CUT_REGEX=y +CONFIG_DATE=y +CONFIG_FEATURE_DATE_ISOFMT=y +# CONFIG_FEATURE_DATE_NANO is not set +CONFIG_FEATURE_DATE_COMPAT=y +CONFIG_DD=y +CONFIG_FEATURE_DD_SIGNAL_HANDLING=y +# CONFIG_FEATURE_DD_THIRD_STATUS_LINE is not set +CONFIG_FEATURE_DD_IBS_OBS=y +CONFIG_FEATURE_DD_STATUS=y +CONFIG_DF=y +# CONFIG_FEATURE_DF_FANCY is not set +CONFIG_FEATURE_SKIP_ROOTFS=y +CONFIG_DIRNAME=y +CONFIG_DOS2UNIX=y +CONFIG_UNIX2DOS=y +CONFIG_DU=y +CONFIG_FEATURE_DU_DEFAULT_BLOCKSIZE_1K=y +CONFIG_ECHO=y +CONFIG_FEATURE_FANCY_ECHO=y +CONFIG_ENV=y +# CONFIG_EXPAND is not set +# CONFIG_UNEXPAND is not set +CONFIG_EXPR=y +CONFIG_EXPR_MATH_SUPPORT_64=y +CONFIG_FACTOR=y +CONFIG_FALSE=y +CONFIG_FOLD=y +CONFIG_HEAD=y +CONFIG_FEATURE_FANCY_HEAD=y +CONFIG_HOSTID=y +CONFIG_ID=y +# CONFIG_GROUPS is not set +CONFIG_INSTALL=y +CONFIG_FEATURE_INSTALL_LONG_OPTIONS=y +CONFIG_LINK=y +CONFIG_LN=y +CONFIG_LOGNAME=y +CONFIG_LS=y +CONFIG_FEATURE_LS_FILETYPES=y +CONFIG_FEATURE_LS_FOLLOWLINKS=y +CONFIG_FEATURE_LS_RECURSIVE=y +CONFIG_FEATURE_LS_WIDTH=y +CONFIG_FEATURE_LS_SORTFILES=y +CONFIG_FEATURE_LS_TIMESTAMPS=y +CONFIG_FEATURE_LS_USERNAME=y +CONFIG_FEATURE_LS_COLOR=y +CONFIG_FEATURE_LS_COLOR_IS_DEFAULT=y +CONFIG_MD5SUM=y +CONFIG_SHA1SUM=y +CONFIG_SHA256SUM=y +CONFIG_SHA512SUM=y +CONFIG_SHA3SUM=y + +# +# Common options for md5sum, sha1sum, sha256sum, sha512sum, sha3sum +# +CONFIG_FEATURE_MD5_SHA1_SUM_CHECK=y +CONFIG_MKDIR=y +CONFIG_MKFIFO=y +CONFIG_MKNOD=y +CONFIG_MKTEMP=y +CONFIG_MV=y +CONFIG_NICE=y +CONFIG_NL=y +CONFIG_NOHUP=y +CONFIG_NPROC=y +CONFIG_OD=y +CONFIG_PASTE=y +CONFIG_PRINTENV=y +CONFIG_PRINTF=y +CONFIG_PWD=y +CONFIG_READLINK=y +CONFIG_FEATURE_READLINK_FOLLOW=y +CONFIG_REALPATH=y +CONFIG_RM=y +CONFIG_RMDIR=y +CONFIG_SEQ=y +CONFIG_SHRED=y +# CONFIG_SHUF is not set +CONFIG_SLEEP=y +CONFIG_FEATURE_FANCY_SLEEP=y +CONFIG_SORT=y +CONFIG_FEATURE_SORT_BIG=y +# CONFIG_FEATURE_SORT_OPTIMIZE_MEMORY is not set +# CONFIG_SPLIT is not set +# CONFIG_FEATURE_SPLIT_FANCY is not set +# CONFIG_STAT is not set +# CONFIG_FEATURE_STAT_FORMAT is not set +# CONFIG_FEATURE_STAT_FILESYSTEM is not set +CONFIG_STTY=y +# CONFIG_SUM is not set +CONFIG_SYNC=y +# CONFIG_FEATURE_SYNC_FANCY is not set +# CONFIG_FSYNC is not set +# CONFIG_TAC is not set +CONFIG_TAIL=y +CONFIG_FEATURE_FANCY_TAIL=y +CONFIG_TEE=y +CONFIG_FEATURE_TEE_USE_BLOCK_IO=y +CONFIG_TEST=y +CONFIG_TEST1=y +CONFIG_TEST2=y +CONFIG_FEATURE_TEST_64=y +# CONFIG_TIMEOUT is not set +CONFIG_TOUCH=y +CONFIG_FEATURE_TOUCH_SUSV3=y +CONFIG_TR=y +CONFIG_FEATURE_TR_CLASSES=y +CONFIG_FEATURE_TR_EQUIV=y +CONFIG_TRUE=y +CONFIG_TRUNCATE=y +CONFIG_TSORT=y +CONFIG_TTY=y +CONFIG_UNAME=y +CONFIG_UNAME_OSNAME="GNU/Linux" +CONFIG_BB_ARCH=y +CONFIG_UNIQ=y +CONFIG_UNLINK=y +CONFIG_USLEEP=y +CONFIG_UUDECODE=y +CONFIG_BASE32=y +CONFIG_BASE64=y +CONFIG_UUENCODE=y +CONFIG_WC=y +# CONFIG_FEATURE_WC_LARGE is not set +CONFIG_WHO=y +CONFIG_W=y +# CONFIG_USERS is not set +CONFIG_WHOAMI=y +CONFIG_YES=y + +# +# Console Utilities +# +CONFIG_CHVT=y +CONFIG_CLEAR=y +CONFIG_DEALLOCVT=y +CONFIG_DUMPKMAP=y +# CONFIG_FGCONSOLE is not set +# CONFIG_KBD_MODE is not set +CONFIG_LOADFONT=y +# CONFIG_SETFONT is not set +# CONFIG_FEATURE_SETFONT_TEXTUAL_MAP is not set +CONFIG_DEFAULT_SETFONT_DIR="" + +# +# Common options for loadfont and setfont +# +CONFIG_FEATURE_LOADFONT_PSF2=y +CONFIG_FEATURE_LOADFONT_RAW=y +CONFIG_LOADKMAP=y +CONFIG_OPENVT=y +CONFIG_RESET=y +CONFIG_RESIZE=y +CONFIG_FEATURE_RESIZE_PRINT=y +CONFIG_SETCONSOLE=y +# CONFIG_FEATURE_SETCONSOLE_LONG_OPTIONS is not set +CONFIG_SETKEYCODES=y +CONFIG_SETLOGCONS=y +# CONFIG_SHOWKEY is not set + +# +# Debian Utilities +# +CONFIG_PIPE_PROGRESS=y +CONFIG_RUN_PARTS=y +CONFIG_FEATURE_RUN_PARTS_LONG_OPTIONS=y +# CONFIG_FEATURE_RUN_PARTS_FANCY is not set +CONFIG_START_STOP_DAEMON=y +CONFIG_FEATURE_START_STOP_DAEMON_LONG_OPTIONS=y +CONFIG_FEATURE_START_STOP_DAEMON_FANCY=y +CONFIG_WHICH=y + +# +# klibc-utils +# +# CONFIG_MINIPS is not set +CONFIG_NUKE=y +CONFIG_RESUME=y +CONFIG_RUN_INIT=y + +# +# Editors +# +CONFIG_AWK=y +# CONFIG_FEATURE_AWK_LIBM is not set +CONFIG_FEATURE_AWK_GNU_EXTENSIONS=y +CONFIG_CMP=y +CONFIG_DIFF=y +# CONFIG_FEATURE_DIFF_LONG_OPTIONS is not set +CONFIG_FEATURE_DIFF_DIR=y +# CONFIG_ED is not set +CONFIG_PATCH=y +CONFIG_SED=y +CONFIG_VI=y +CONFIG_FEATURE_VI_MAX_LEN=4096 +CONFIG_FEATURE_VI_8BIT=y +CONFIG_FEATURE_VI_COLON=y +CONFIG_FEATURE_VI_COLON_EXPAND=y +CONFIG_FEATURE_VI_YANKMARK=y +CONFIG_FEATURE_VI_SEARCH=y +# CONFIG_FEATURE_VI_REGEX_SEARCH is not set +CONFIG_FEATURE_VI_USE_SIGNALS=y +CONFIG_FEATURE_VI_DOT_CMD=y +CONFIG_FEATURE_VI_READONLY=y +CONFIG_FEATURE_VI_SETOPTS=y +CONFIG_FEATURE_VI_SET=y +CONFIG_FEATURE_VI_WIN_RESIZE=y +CONFIG_FEATURE_VI_ASK_TERMINAL=y +CONFIG_FEATURE_VI_UNDO=y +CONFIG_FEATURE_VI_UNDO_QUEUE=y +CONFIG_FEATURE_VI_UNDO_QUEUE_MAX=256 +CONFIG_FEATURE_VI_VERBOSE_STATUS=y +CONFIG_FEATURE_ALLOW_EXEC=y + +# +# Finding Utilities +# +CONFIG_FIND=y +CONFIG_FEATURE_FIND_PRINT0=y +CONFIG_FEATURE_FIND_MTIME=y +CONFIG_FEATURE_FIND_ATIME=y +CONFIG_FEATURE_FIND_CTIME=y +CONFIG_FEATURE_FIND_MMIN=y +CONFIG_FEATURE_FIND_AMIN=y +CONFIG_FEATURE_FIND_CMIN=y +CONFIG_FEATURE_FIND_PERM=y +CONFIG_FEATURE_FIND_TYPE=y +CONFIG_FEATURE_FIND_EXECUTABLE=y +CONFIG_FEATURE_FIND_XDEV=y +CONFIG_FEATURE_FIND_MAXDEPTH=y +CONFIG_FEATURE_FIND_NEWER=y +# CONFIG_FEATURE_FIND_INUM is not set +CONFIG_FEATURE_FIND_SAMEFILE=y +CONFIG_FEATURE_FIND_EXEC=y +CONFIG_FEATURE_FIND_EXEC_PLUS=y +CONFIG_FEATURE_FIND_USER=y +CONFIG_FEATURE_FIND_GROUP=y +CONFIG_FEATURE_FIND_NOT=y +CONFIG_FEATURE_FIND_DEPTH=y +CONFIG_FEATURE_FIND_PAREN=y +CONFIG_FEATURE_FIND_SIZE=y +CONFIG_FEATURE_FIND_PRUNE=y +CONFIG_FEATURE_FIND_QUIT=y +# CONFIG_FEATURE_FIND_DELETE is not set +CONFIG_FEATURE_FIND_EMPTY=y +CONFIG_FEATURE_FIND_PATH=y +CONFIG_FEATURE_FIND_REGEX=y +# CONFIG_FEATURE_FIND_CONTEXT is not set +# CONFIG_FEATURE_FIND_LINKS is not set +CONFIG_GREP=y +CONFIG_EGREP=y +CONFIG_FGREP=y +CONFIG_FEATURE_GREP_CONTEXT=y +CONFIG_XARGS=y +# CONFIG_FEATURE_XARGS_SUPPORT_CONFIRMATION is not set +CONFIG_FEATURE_XARGS_SUPPORT_QUOTES=y +CONFIG_FEATURE_XARGS_SUPPORT_TERMOPT=y +CONFIG_FEATURE_XARGS_SUPPORT_ZERO_TERM=y +CONFIG_FEATURE_XARGS_SUPPORT_REPL_STR=y +CONFIG_FEATURE_XARGS_SUPPORT_PARALLEL=y +CONFIG_FEATURE_XARGS_SUPPORT_ARGS_FILE=y + +# +# Init Utilities +# +# CONFIG_BOOTCHARTD is not set +# CONFIG_FEATURE_BOOTCHARTD_BLOATED_HEADER is not set +# CONFIG_FEATURE_BOOTCHARTD_CONFIG_FILE is not set +CONFIG_HALT=y +CONFIG_POWEROFF=y +CONFIG_REBOOT=y +CONFIG_FEATURE_WAIT_FOR_INIT=y +# CONFIG_FEATURE_CALL_TELINIT is not set +CONFIG_TELINIT_PATH="" +CONFIG_INIT=y +CONFIG_LINUXRC=y +CONFIG_FEATURE_USE_INITTAB=y +CONFIG_FEATURE_KILL_REMOVED=y +CONFIG_FEATURE_KILL_DELAY=0 +CONFIG_FEATURE_INIT_SCTTY=y +CONFIG_FEATURE_INIT_SYSLOG=y +CONFIG_FEATURE_INIT_QUIET=y +# CONFIG_FEATURE_INIT_COREDUMPS is not set +CONFIG_INIT_TERMINAL_TYPE="linux" +CONFIG_FEATURE_INIT_MODIFY_CMDLINE=y + +# +# Login/Password Management Utilities +# +CONFIG_FEATURE_SHADOWPASSWDS=y +# CONFIG_USE_BB_PWD_GRP is not set +# CONFIG_USE_BB_SHADOW is not set +CONFIG_USE_BB_CRYPT=y +CONFIG_USE_BB_CRYPT_SHA=y +# CONFIG_ADD_SHELL is not set +# CONFIG_REMOVE_SHELL is not set +CONFIG_ADDGROUP=y +# CONFIG_FEATURE_ADDUSER_TO_GROUP is not set +CONFIG_ADDUSER=y +# CONFIG_FEATURE_CHECK_NAMES is not set +CONFIG_LAST_ID=60000 +CONFIG_FIRST_SYSTEM_ID=100 +CONFIG_LAST_SYSTEM_ID=999 +# CONFIG_CHPASSWD is not set +CONFIG_FEATURE_DEFAULT_PASSWD_ALGO="md5" +# CONFIG_CRYPTPW is not set +CONFIG_MKPASSWD=y +CONFIG_DELUSER=y +CONFIG_DELGROUP=y +# CONFIG_FEATURE_DEL_USER_FROM_GROUP is not set +CONFIG_GETTY=y +CONFIG_LOGIN=y +# CONFIG_LOGIN_SESSION_AS_CHILD is not set +# CONFIG_LOGIN_SCRIPTS is not set +CONFIG_FEATURE_NOLOGIN=y +CONFIG_FEATURE_SECURETTY=y +CONFIG_PASSWD=y +CONFIG_FEATURE_PASSWD_WEAK_CHECK=y +CONFIG_SU=y +CONFIG_FEATURE_SU_SYSLOG=y +CONFIG_FEATURE_SU_CHECKS_SHELLS=y +# CONFIG_FEATURE_SU_BLANK_PW_NEEDS_SECURE_TTY is not set +CONFIG_SULOGIN=y +CONFIG_VLOCK=y + +# +# Linux Ext2 FS Progs +# +CONFIG_CHATTR=y +CONFIG_FSCK=y +CONFIG_LSATTR=y +# CONFIG_TUNE2FS is not set + +# +# Linux Module Utilities +# +# CONFIG_MODPROBE_SMALL is not set +# CONFIG_DEPMOD is not set +CONFIG_INSMOD=y +CONFIG_LSMOD=y +CONFIG_FEATURE_LSMOD_PRETTY_2_6_OUTPUT=y +# CONFIG_MODINFO is not set +CONFIG_MODPROBE=y +# CONFIG_FEATURE_MODPROBE_BLACKLIST is not set +CONFIG_RMMOD=y + +# +# Options common to multiple modutils +# +CONFIG_FEATURE_CMDLINE_MODULE_OPTIONS=y +# CONFIG_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED is not set +# CONFIG_FEATURE_2_4_MODULES is not set +# CONFIG_FEATURE_INSMOD_VERSION_CHECKING is not set +# CONFIG_FEATURE_INSMOD_KSYMOOPS_SYMBOLS is not set +# CONFIG_FEATURE_INSMOD_LOADINKMEM is not set +# CONFIG_FEATURE_INSMOD_LOAD_MAP is not set +# CONFIG_FEATURE_INSMOD_LOAD_MAP_FULL is not set +CONFIG_FEATURE_CHECK_TAINTED_MODULE=y +# CONFIG_FEATURE_INSMOD_TRY_MMAP is not set +CONFIG_FEATURE_MODUTILS_ALIAS=y +CONFIG_FEATURE_MODUTILS_SYMBOLS=y +CONFIG_DEFAULT_MODULES_DIR="/lib/modules" +CONFIG_DEFAULT_DEPMOD_FILE="modules.dep" + +# +# Linux System Utilities +# +# CONFIG_ACPID is not set +# CONFIG_FEATURE_ACPID_COMPAT is not set +# CONFIG_BLKDISCARD is not set +CONFIG_BLKID=y +# CONFIG_FEATURE_BLKID_TYPE is not set +# CONFIG_BLOCKDEV is not set +# CONFIG_CAL is not set +CONFIG_CHRT=y +CONFIG_DMESG=y +CONFIG_FEATURE_DMESG_PRETTY=y +CONFIG_EJECT=y +# CONFIG_FEATURE_EJECT_SCSI is not set +CONFIG_FALLOCATE=y +# CONFIG_FATATTR is not set +CONFIG_FBSET=y +CONFIG_FEATURE_FBSET_FANCY=y +CONFIG_FEATURE_FBSET_READMODE=y +CONFIG_FDFORMAT=y +CONFIG_FDISK=y +# CONFIG_FDISK_SUPPORT_LARGE_DISKS is not set +CONFIG_FEATURE_FDISK_WRITABLE=y +# CONFIG_FEATURE_AIX_LABEL is not set +# CONFIG_FEATURE_SGI_LABEL is not set +# CONFIG_FEATURE_SUN_LABEL is not set +# CONFIG_FEATURE_OSF_LABEL is not set +CONFIG_FEATURE_GPT_LABEL=y +CONFIG_FEATURE_FDISK_ADVANCED=y +# CONFIG_FINDFS is not set +CONFIG_FLOCK=y +CONFIG_FDFLUSH=y +CONFIG_FREERAMDISK=y +# CONFIG_FSCK_MINIX is not set +CONFIG_FSFREEZE=y +CONFIG_FSTRIM=y +CONFIG_GETOPT=y +CONFIG_FEATURE_GETOPT_LONG=y +CONFIG_HEXDUMP=y +# CONFIG_HD is not set +CONFIG_XXD=y +CONFIG_HWCLOCK=y +CONFIG_FEATURE_HWCLOCK_ADJTIME_FHS=y +# CONFIG_IONICE is not set +CONFIG_IPCRM=y +CONFIG_IPCS=y +CONFIG_LAST=y +# CONFIG_FEATURE_LAST_FANCY is not set +CONFIG_LOSETUP=y +CONFIG_LSPCI=y +CONFIG_LSUSB=y +CONFIG_MDEV=y +CONFIG_FEATURE_MDEV_CONF=y +CONFIG_FEATURE_MDEV_RENAME=y +# CONFIG_FEATURE_MDEV_RENAME_REGEXP is not set +CONFIG_FEATURE_MDEV_EXEC=y +# CONFIG_FEATURE_MDEV_LOAD_FIRMWARE is not set +CONFIG_FEATURE_MDEV_DAEMON=y +CONFIG_MESG=y +CONFIG_FEATURE_MESG_ENABLE_ONLY_GROUP=y +CONFIG_MKE2FS=y +# CONFIG_MKFS_EXT2 is not set +# CONFIG_MKFS_MINIX is not set +# CONFIG_FEATURE_MINIX2 is not set +# CONFIG_MKFS_REISER is not set +CONFIG_MKDOSFS=y +# CONFIG_MKFS_VFAT is not set +CONFIG_MKSWAP=y +# CONFIG_FEATURE_MKSWAP_UUID is not set +CONFIG_MORE=y +CONFIG_MOUNT=y +# CONFIG_FEATURE_MOUNT_FAKE is not set +# CONFIG_FEATURE_MOUNT_VERBOSE is not set +# CONFIG_FEATURE_MOUNT_HELPERS is not set +# CONFIG_FEATURE_MOUNT_LABEL is not set +# CONFIG_FEATURE_MOUNT_NFS is not set +CONFIG_FEATURE_MOUNT_CIFS=y +CONFIG_FEATURE_MOUNT_FLAGS=y +CONFIG_FEATURE_MOUNT_FSTAB=y +CONFIG_FEATURE_MOUNT_OTHERTAB=y +CONFIG_MOUNTPOINT=y +CONFIG_NOLOGIN=y +# CONFIG_NOLOGIN_DEPENDENCIES is not set +# CONFIG_NSENTER is not set +CONFIG_PIVOT_ROOT=y +CONFIG_RDATE=y +# CONFIG_RDEV is not set +CONFIG_READPROFILE=y +CONFIG_RENICE=y +# CONFIG_REV is not set +# CONFIG_RTCWAKE is not set +# CONFIG_SCRIPT is not set +# CONFIG_SCRIPTREPLAY is not set +CONFIG_SETARCH=y +CONFIG_LINUX32=y +CONFIG_LINUX64=y +CONFIG_SETPRIV=y +CONFIG_FEATURE_SETPRIV_DUMP=y +CONFIG_FEATURE_SETPRIV_CAPABILITIES=y +CONFIG_FEATURE_SETPRIV_CAPABILITY_NAMES=y +CONFIG_SETSID=y +CONFIG_SWAPON=y +# CONFIG_FEATURE_SWAPON_DISCARD is not set +# CONFIG_FEATURE_SWAPON_PRI is not set +CONFIG_SWAPOFF=y +CONFIG_FEATURE_SWAPONOFF_LABEL=y +CONFIG_SWITCH_ROOT=y +# CONFIG_TASKSET is not set +# CONFIG_FEATURE_TASKSET_FANCY is not set +# CONFIG_FEATURE_TASKSET_CPULIST is not set +CONFIG_UEVENT=y +CONFIG_UMOUNT=y +CONFIG_FEATURE_UMOUNT_ALL=y +# CONFIG_UNSHARE is not set +# CONFIG_WALL is not set + +# +# Common options for mount/umount +# +CONFIG_FEATURE_MOUNT_LOOP=y +CONFIG_FEATURE_MOUNT_LOOP_CREATE=y +# CONFIG_FEATURE_MTAB_SUPPORT is not set +CONFIG_VOLUMEID=y + +# +# Filesystem/Volume identification +# +# CONFIG_FEATURE_VOLUMEID_BCACHE is not set +# CONFIG_FEATURE_VOLUMEID_BTRFS is not set +# CONFIG_FEATURE_VOLUMEID_CRAMFS is not set +CONFIG_FEATURE_VOLUMEID_EROFS=y +CONFIG_FEATURE_VOLUMEID_EXFAT=y +CONFIG_FEATURE_VOLUMEID_EXT=y +CONFIG_FEATURE_VOLUMEID_F2FS=y +CONFIG_FEATURE_VOLUMEID_FAT=y +# CONFIG_FEATURE_VOLUMEID_HFS is not set +# CONFIG_FEATURE_VOLUMEID_ISO9660 is not set +# CONFIG_FEATURE_VOLUMEID_JFS is not set +# CONFIG_FEATURE_VOLUMEID_LFS is not set +# CONFIG_FEATURE_VOLUMEID_LINUXRAID is not set +# CONFIG_FEATURE_VOLUMEID_LINUXSWAP is not set +# CONFIG_FEATURE_VOLUMEID_LUKS is not set +CONFIG_FEATURE_VOLUMEID_MINIX=y +# CONFIG_FEATURE_VOLUMEID_NILFS is not set +# CONFIG_FEATURE_VOLUMEID_NTFS is not set +# CONFIG_FEATURE_VOLUMEID_OCFS2 is not set +# CONFIG_FEATURE_VOLUMEID_REISERFS is not set +# CONFIG_FEATURE_VOLUMEID_ROMFS is not set +# CONFIG_FEATURE_VOLUMEID_SQUASHFS is not set +# CONFIG_FEATURE_VOLUMEID_SYSV is not set +CONFIG_FEATURE_VOLUMEID_UBIFS=y +# CONFIG_FEATURE_VOLUMEID_UDF is not set +# CONFIG_FEATURE_VOLUMEID_XFS is not set + +# +# Miscellaneous Utilities +# +# CONFIG_ADJTIMEX is not set +CONFIG_ASCII=y +# CONFIG_BBCONFIG is not set +# CONFIG_FEATURE_COMPRESS_BBCONFIG is not set +CONFIG_BC=y +CONFIG_DC=y +CONFIG_FEATURE_DC_BIG=y +# CONFIG_FEATURE_DC_LIBM is not set +CONFIG_FEATURE_BC_INTERACTIVE=y +CONFIG_FEATURE_BC_LONG_OPTIONS=y +# CONFIG_BEEP is not set +CONFIG_FEATURE_BEEP_FREQ=0 +CONFIG_FEATURE_BEEP_LENGTH_MS=0 +# CONFIG_CHAT is not set +# CONFIG_FEATURE_CHAT_NOFAIL is not set +# CONFIG_FEATURE_CHAT_TTY_HIFI is not set +# CONFIG_FEATURE_CHAT_IMPLICIT_CR is not set +# CONFIG_FEATURE_CHAT_SWALLOW_OPTS is not set +# CONFIG_FEATURE_CHAT_SEND_ESCAPES is not set +# CONFIG_FEATURE_CHAT_VAR_ABORT_LEN is not set +# CONFIG_FEATURE_CHAT_CLR_ABORT is not set +# CONFIG_CONSPY is not set +CONFIG_CROND=y +# CONFIG_FEATURE_CROND_D is not set +# CONFIG_FEATURE_CROND_CALL_SENDMAIL is not set +CONFIG_FEATURE_CROND_SPECIAL_TIMES=y +CONFIG_FEATURE_CROND_DIR="/etc/cron" +CONFIG_CRONTAB=y +# CONFIG_DEVFSD is not set +# CONFIG_DEVFSD_MODLOAD is not set +# CONFIG_DEVFSD_FG_NP is not set +# CONFIG_DEVFSD_VERBOSE is not set +# CONFIG_FEATURE_DEVFS is not set +CONFIG_DEVMEM=y +# CONFIG_FBSPLASH is not set +# CONFIG_FLASH_ERASEALL is not set +# CONFIG_FLASH_LOCK is not set +# CONFIG_FLASH_UNLOCK is not set +# CONFIG_FLASHCP is not set +CONFIG_HDPARM=y +CONFIG_FEATURE_HDPARM_GET_IDENTITY=y +# CONFIG_FEATURE_HDPARM_HDIO_SCAN_HWIF is not set +# CONFIG_FEATURE_HDPARM_HDIO_UNREGISTER_HWIF is not set +# CONFIG_FEATURE_HDPARM_HDIO_DRIVE_RESET is not set +# CONFIG_FEATURE_HDPARM_HDIO_TRISTATE_HWIF is not set +# CONFIG_FEATURE_HDPARM_HDIO_GETSET_DMA is not set +CONFIG_HEXEDIT=y +CONFIG_I2CGET=y +CONFIG_I2CSET=y +CONFIG_I2CDUMP=y +CONFIG_I2CDETECT=y +CONFIG_I2CTRANSFER=y +# CONFIG_INOTIFYD is not set +CONFIG_LESS=y +CONFIG_FEATURE_LESS_MAXLINES=9999999 +CONFIG_FEATURE_LESS_BRACKETS=y +CONFIG_FEATURE_LESS_FLAGS=y +CONFIG_FEATURE_LESS_TRUNCATE=y +# CONFIG_FEATURE_LESS_MARKS is not set +CONFIG_FEATURE_LESS_REGEXP=y +# CONFIG_FEATURE_LESS_WINCH is not set +# CONFIG_FEATURE_LESS_ASK_TERMINAL is not set +CONFIG_FEATURE_LESS_DASHCMD=y +# CONFIG_FEATURE_LESS_LINENUMS is not set +CONFIG_FEATURE_LESS_RAW=y +CONFIG_FEATURE_LESS_ENV=y +CONFIG_LSSCSI=y +CONFIG_MAKEDEVS=y +# CONFIG_FEATURE_MAKEDEVS_LEAF is not set +CONFIG_FEATURE_MAKEDEVS_TABLE=y +# CONFIG_MAN is not set +CONFIG_MICROCOM=y +CONFIG_MIM=y +CONFIG_MT=y +# CONFIG_NANDWRITE is not set +# CONFIG_NANDDUMP is not set +CONFIG_PARTPROBE=y +# CONFIG_RAIDAUTORUN is not set +# CONFIG_READAHEAD is not set +# CONFIG_RFKILL is not set +CONFIG_RUNLEVEL=y +# CONFIG_RX is not set +CONFIG_SEEDRNG=y +CONFIG_SETFATTR=y +CONFIG_SETSERIAL=y +CONFIG_STRINGS=y +CONFIG_TIME=y +CONFIG_TREE=y +CONFIG_TS=y +# CONFIG_TTYSIZE is not set +# CONFIG_UBIATTACH is not set +# CONFIG_UBIDETACH is not set +# CONFIG_UBIMKVOL is not set +# CONFIG_UBIRMVOL is not set +# CONFIG_UBIRSVOL is not set +# CONFIG_UBIUPDATEVOL is not set +CONFIG_UBIRENAME=y +# CONFIG_VOLNAME is not set +CONFIG_WATCHDOG=y +# CONFIG_FEATURE_WATCHDOG_OPEN_TWICE is not set + +# +# Networking Utilities +# +CONFIG_FEATURE_IPV6=y +# CONFIG_FEATURE_UNIX_LOCAL is not set +CONFIG_FEATURE_PREFER_IPV4_ADDRESS=y +# CONFIG_VERBOSE_RESOLUTION_ERRORS is not set +# CONFIG_FEATURE_ETC_NETWORKS is not set +# CONFIG_FEATURE_ETC_SERVICES is not set +CONFIG_FEATURE_HWIB=y +# CONFIG_FEATURE_TLS_SHA1 is not set +CONFIG_ARP=y +CONFIG_ARPING=y +# CONFIG_BRCTL is not set +# CONFIG_FEATURE_BRCTL_FANCY is not set +# CONFIG_FEATURE_BRCTL_SHOW is not set +CONFIG_DNSD=y +CONFIG_ETHER_WAKE=y +# CONFIG_FTPD is not set +# CONFIG_FEATURE_FTPD_WRITE is not set +# CONFIG_FEATURE_FTPD_ACCEPT_BROKEN_LIST is not set +# CONFIG_FEATURE_FTPD_AUTHENTICATION is not set +# CONFIG_FTPGET is not set +# CONFIG_FTPPUT is not set +# CONFIG_FEATURE_FTPGETPUT_LONG_OPTIONS is not set +CONFIG_HOSTNAME=y +CONFIG_DNSDOMAINNAME=y +# CONFIG_HTTPD is not set +CONFIG_FEATURE_HTTPD_PORT_DEFAULT=0 +# CONFIG_FEATURE_HTTPD_RANGES is not set +# CONFIG_FEATURE_HTTPD_SETUID is not set +# CONFIG_FEATURE_HTTPD_BASIC_AUTH is not set +# CONFIG_FEATURE_HTTPD_AUTH_MD5 is not set +# CONFIG_FEATURE_HTTPD_CGI is not set +# CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR is not set +# CONFIG_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV is not set +# CONFIG_FEATURE_HTTPD_ENCODE_URL_STR is not set +# CONFIG_FEATURE_HTTPD_ERROR_PAGES is not set +# CONFIG_FEATURE_HTTPD_PROXY is not set +# CONFIG_FEATURE_HTTPD_GZIP is not set +# CONFIG_FEATURE_HTTPD_ETAG is not set +# CONFIG_FEATURE_HTTPD_LAST_MODIFIED is not set +# CONFIG_FEATURE_HTTPD_DATE is not set +# CONFIG_FEATURE_HTTPD_ACL_IP is not set +CONFIG_IFCONFIG=y +CONFIG_FEATURE_IFCONFIG_STATUS=y +CONFIG_FEATURE_IFCONFIG_SLIP=y +CONFIG_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ=y +CONFIG_FEATURE_IFCONFIG_HW=y +# CONFIG_FEATURE_IFCONFIG_BROADCAST_PLUS is not set +# CONFIG_IFENSLAVE is not set +# CONFIG_IFPLUGD is not set +CONFIG_IFUP=y +CONFIG_IFDOWN=y +CONFIG_IFUPDOWN_IFSTATE_PATH="/var/run/ifstate" +CONFIG_FEATURE_IFUPDOWN_IP=y +CONFIG_FEATURE_IFUPDOWN_IPV4=y +CONFIG_FEATURE_IFUPDOWN_IPV6=y +CONFIG_FEATURE_IFUPDOWN_MAPPING=y +# CONFIG_FEATURE_IFUPDOWN_EXTERNAL_DHCP is not set +CONFIG_INETD=y +CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_ECHO=y +CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DISCARD=y +CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_TIME=y +CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME=y +CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN=y +# CONFIG_FEATURE_INETD_RPC is not set +CONFIG_IP=y +CONFIG_IPADDR=y +CONFIG_IPLINK=y +CONFIG_IPROUTE=y +CONFIG_IPTUNNEL=y +CONFIG_IPRULE=y +CONFIG_IPNEIGH=y +CONFIG_FEATURE_IP_ADDRESS=y +CONFIG_FEATURE_IP_LINK=y +CONFIG_FEATURE_IP_ROUTE=y +CONFIG_FEATURE_IP_ROUTE_DIR="/etc/iproute2" +CONFIG_FEATURE_IP_TUNNEL=y +CONFIG_FEATURE_IP_RULE=y +CONFIG_FEATURE_IP_NEIGH=y +# CONFIG_FEATURE_IP_RARE_PROTOCOLS is not set +# CONFIG_IPCALC is not set +# CONFIG_FEATURE_IPCALC_LONG_OPTIONS is not set +# CONFIG_FEATURE_IPCALC_FANCY is not set +# CONFIG_FAKEIDENTD is not set +CONFIG_NAMEIF=y +# CONFIG_FEATURE_NAMEIF_EXTENDED is not set +# CONFIG_NBDCLIENT is not set +# CONFIG_NC is not set +# CONFIG_NETCAT is not set +# CONFIG_NC_SERVER is not set +# CONFIG_NC_EXTRA is not set +# CONFIG_NC_110_COMPAT is not set +CONFIG_NETSTAT=y +# CONFIG_FEATURE_NETSTAT_WIDE is not set +# CONFIG_FEATURE_NETSTAT_PRG is not set +CONFIG_NSLOOKUP=y +CONFIG_FEATURE_NSLOOKUP_BIG=y +CONFIG_FEATURE_NSLOOKUP_LONG_OPTIONS=y +# CONFIG_NTPD is not set +# CONFIG_FEATURE_NTPD_SERVER is not set +# CONFIG_FEATURE_NTPD_CONF is not set +# CONFIG_FEATURE_NTP_AUTH is not set +CONFIG_PING=y +# CONFIG_PING6 is not set +CONFIG_FEATURE_FANCY_PING=y +# CONFIG_PSCAN is not set +CONFIG_ROUTE=y +# CONFIG_SLATTACH is not set +# CONFIG_SSL_CLIENT is not set +# CONFIG_TC is not set +# CONFIG_FEATURE_TC_INGRESS is not set +# CONFIG_TCPSVD is not set +# CONFIG_UDPSVD is not set +CONFIG_TELNET=y +CONFIG_FEATURE_TELNET_TTYPE=y +CONFIG_FEATURE_TELNET_AUTOLOGIN=y +CONFIG_FEATURE_TELNET_WIDTH=y +# CONFIG_TELNETD is not set +# CONFIG_FEATURE_TELNETD_STANDALONE is not set +CONFIG_FEATURE_TELNETD_PORT_DEFAULT=0 +# CONFIG_FEATURE_TELNETD_INETD_WAIT is not set +CONFIG_TFTP=y +# CONFIG_FEATURE_TFTP_PROGRESS_BAR is not set +CONFIG_FEATURE_TFTP_HPA_COMPAT=y +# CONFIG_TFTPD is not set +CONFIG_FEATURE_TFTP_GET=y +CONFIG_FEATURE_TFTP_PUT=y +CONFIG_FEATURE_TFTP_BLOCKSIZE=y +# CONFIG_TFTP_DEBUG is not set +# CONFIG_TLS is not set +CONFIG_TRACEROUTE=y +# CONFIG_TRACEROUTE6 is not set +# CONFIG_FEATURE_TRACEROUTE_VERBOSE is not set +# CONFIG_FEATURE_TRACEROUTE_USE_ICMP is not set +# CONFIG_TUNCTL is not set +# CONFIG_FEATURE_TUNCTL_UG is not set +CONFIG_VCONFIG=y +CONFIG_WGET=y +CONFIG_FEATURE_WGET_LONG_OPTIONS=y +CONFIG_FEATURE_WGET_STATUSBAR=y +CONFIG_FEATURE_WGET_FTP=y +CONFIG_FEATURE_WGET_AUTHENTICATION=y +CONFIG_FEATURE_WGET_TIMEOUT=y +# CONFIG_FEATURE_WGET_HTTPS is not set +# CONFIG_FEATURE_WGET_OPENSSL is not set +# CONFIG_WHOIS is not set +# CONFIG_ZCIP is not set +# CONFIG_UDHCPD is not set +# CONFIG_FEATURE_UDHCPD_BASE_IP_ON_MAC is not set +# CONFIG_FEATURE_UDHCPD_WRITE_LEASES_EARLY is not set +CONFIG_DHCPD_LEASES_FILE="" +# CONFIG_DUMPLEASES is not set +# CONFIG_DHCPRELAY is not set +CONFIG_UDHCPC=y +CONFIG_FEATURE_UDHCPC_ARPING=y +CONFIG_FEATURE_UDHCPC_SANITIZEOPT=y +CONFIG_UDHCPC_DEFAULT_SCRIPT="/usr/share/udhcpc/default.script" +CONFIG_UDHCPC6_DEFAULT_SCRIPT="/usr/share/udhcpc/default.script" +# CONFIG_UDHCPC6 is not set +# CONFIG_FEATURE_UDHCPC6_RFC3646 is not set +# CONFIG_FEATURE_UDHCPC6_RFC4704 is not set +# CONFIG_FEATURE_UDHCPC6_RFC4833 is not set +# CONFIG_FEATURE_UDHCPC6_RFC5970 is not set + +# +# Common options for DHCP applets +# +CONFIG_UDHCPC_DEFAULT_INTERFACE="eth0" +# CONFIG_FEATURE_UDHCP_PORT is not set +CONFIG_UDHCP_DEBUG=0 +CONFIG_UDHCPC_SLACK_FOR_BUGGY_SERVERS=80 +CONFIG_FEATURE_UDHCP_RFC3397=y +CONFIG_FEATURE_UDHCP_8021Q=y +CONFIG_IFUPDOWN_UDHCPC_CMD_OPTIONS="-t1 -A3 -b -R -O search -O staticroutes" + +# +# Print Utilities +# +# CONFIG_LPD is not set +# CONFIG_LPR is not set +# CONFIG_LPQ is not set + +# +# Mail Utilities +# +CONFIG_FEATURE_MIME_CHARSET="" +# CONFIG_MAKEMIME is not set +# CONFIG_POPMAILDIR is not set +# CONFIG_FEATURE_POPMAILDIR_DELIVERY is not set +# CONFIG_REFORMIME is not set +# CONFIG_FEATURE_REFORMIME_COMPAT is not set +# CONFIG_SENDMAIL is not set + +# +# Process Utilities +# +# CONFIG_FEATURE_FAST_TOP is not set +# CONFIG_FEATURE_SHOW_THREADS is not set +CONFIG_FREE=y +CONFIG_FUSER=y +# CONFIG_IOSTAT is not set +CONFIG_KILL=y +CONFIG_KILLALL=y +CONFIG_KILLALL5=y +CONFIG_LSOF=y +# CONFIG_MPSTAT is not set +# CONFIG_NMETER is not set +# CONFIG_PGREP is not set +# CONFIG_PKILL is not set +CONFIG_PIDOF=y +CONFIG_FEATURE_PIDOF_SINGLE=y +CONFIG_FEATURE_PIDOF_OMIT=y +# CONFIG_PMAP is not set +# CONFIG_POWERTOP is not set +# CONFIG_FEATURE_POWERTOP_INTERACTIVE is not set +CONFIG_PS=y +# CONFIG_FEATURE_PS_WIDE is not set +# CONFIG_FEATURE_PS_LONG is not set +# CONFIG_FEATURE_PS_TIME is not set +# CONFIG_FEATURE_PS_UNUSUAL_SYSTEMS is not set +# CONFIG_FEATURE_PS_ADDITIONAL_COLUMNS is not set +# CONFIG_PSTREE is not set +# CONFIG_PWDX is not set +# CONFIG_SMEMCAP is not set +CONFIG_BB_SYSCTL=y +CONFIG_TOP=y +CONFIG_FEATURE_TOP_INTERACTIVE=y +CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE=y +CONFIG_FEATURE_TOP_CPU_GLOBAL_PERCENTS=y +# CONFIG_FEATURE_TOP_SMP_CPU is not set +# CONFIG_FEATURE_TOP_DECIMALS is not set +# CONFIG_FEATURE_TOP_SMP_PROCESS is not set +# CONFIG_FEATURE_TOPMEM is not set +CONFIG_UPTIME=y +# CONFIG_FEATURE_UPTIME_UTMP_SUPPORT is not set +CONFIG_WATCH=y + +# +# Runit Utilities +# +# CONFIG_CHPST is not set +# CONFIG_SETUIDGID is not set +# CONFIG_ENVUIDGID is not set +# CONFIG_ENVDIR is not set +# CONFIG_SOFTLIMIT is not set +# CONFIG_RUNSV is not set +# CONFIG_RUNSVDIR is not set +# CONFIG_FEATURE_RUNSVDIR_LOG is not set +# CONFIG_SV is not set +CONFIG_SV_DEFAULT_SERVICE_DIR="" +CONFIG_SVC=y +CONFIG_SVOK=y +# CONFIG_SVLOGD is not set +# CONFIG_CHCON is not set +# CONFIG_GETENFORCE is not set +# CONFIG_GETSEBOOL is not set +# CONFIG_LOAD_POLICY is not set +# CONFIG_MATCHPATHCON is not set +# CONFIG_RUNCON is not set +# CONFIG_SELINUXENABLED is not set +# CONFIG_SESTATUS is not set +# CONFIG_SETENFORCE is not set +# CONFIG_SETFILES is not set +# CONFIG_FEATURE_SETFILES_CHECK_OPTION is not set +# CONFIG_RESTORECON is not set +# CONFIG_SETSEBOOL is not set + +# +# Shells +# +CONFIG_SH_IS_ASH=y +# CONFIG_SH_IS_HUSH is not set +# CONFIG_SH_IS_NONE is not set +# CONFIG_BASH_IS_ASH is not set +# CONFIG_BASH_IS_HUSH is not set +CONFIG_BASH_IS_NONE=y +CONFIG_SHELL_ASH=y +CONFIG_ASH=y +CONFIG_ASH_OPTIMIZE_FOR_SIZE=y +CONFIG_ASH_INTERNAL_GLOB=y +CONFIG_ASH_BASH_COMPAT=y +# CONFIG_ASH_BASH_SOURCE_CURDIR is not set +CONFIG_ASH_BASH_NOT_FOUND_HOOK=y +CONFIG_ASH_JOB_CONTROL=y +CONFIG_ASH_ALIAS=y +CONFIG_ASH_RANDOM_SUPPORT=y +CONFIG_ASH_EXPAND_PRMT=y +CONFIG_ASH_IDLE_TIMEOUT=y +# CONFIG_ASH_MAIL is not set +CONFIG_ASH_ECHO=y +CONFIG_ASH_PRINTF=y +CONFIG_ASH_TEST=y +CONFIG_ASH_SLEEP=y +CONFIG_ASH_HELP=y +CONFIG_ASH_GETOPTS=y +CONFIG_ASH_CMDCMD=y +# CONFIG_CTTYHACK is not set +# CONFIG_HUSH is not set +# CONFIG_SHELL_HUSH is not set +# CONFIG_HUSH_BASH_COMPAT is not set +# CONFIG_HUSH_BRACE_EXPANSION is not set +# CONFIG_HUSH_BASH_SOURCE_CURDIR is not set +# CONFIG_HUSH_LINENO_VAR is not set +# CONFIG_HUSH_INTERACTIVE is not set +# CONFIG_HUSH_SAVEHISTORY is not set +# CONFIG_HUSH_JOB is not set +# CONFIG_HUSH_TICK is not set +# CONFIG_HUSH_IF is not set +# CONFIG_HUSH_LOOPS is not set +# CONFIG_HUSH_CASE is not set +# CONFIG_HUSH_FUNCTIONS is not set +# CONFIG_HUSH_LOCAL is not set +# CONFIG_HUSH_RANDOM_SUPPORT is not set +# CONFIG_HUSH_MODE_X is not set +# CONFIG_HUSH_ECHO is not set +# CONFIG_HUSH_PRINTF is not set +# CONFIG_HUSH_TEST is not set +# CONFIG_HUSH_HELP is not set +# CONFIG_HUSH_EXPORT is not set +# CONFIG_HUSH_EXPORT_N is not set +# CONFIG_HUSH_READONLY is not set +# CONFIG_HUSH_KILL is not set +# CONFIG_HUSH_WAIT is not set +# CONFIG_HUSH_COMMAND is not set +# CONFIG_HUSH_TRAP is not set +# CONFIG_HUSH_TYPE is not set +# CONFIG_HUSH_TIMES is not set +# CONFIG_HUSH_READ is not set +# CONFIG_HUSH_SET is not set +# CONFIG_HUSH_UNSET is not set +# CONFIG_HUSH_ULIMIT is not set +# CONFIG_HUSH_UMASK is not set +# CONFIG_HUSH_GETOPTS is not set +# CONFIG_HUSH_MEMLEAK is not set + +# +# Options common to all shells +# +CONFIG_FEATURE_SH_MATH=y +CONFIG_FEATURE_SH_MATH_64=y +CONFIG_FEATURE_SH_MATH_BASE=y +CONFIG_FEATURE_SH_EXTRA_QUIET=y +# CONFIG_FEATURE_SH_STANDALONE is not set +# CONFIG_FEATURE_SH_NOFORK is not set +CONFIG_FEATURE_SH_READ_FRAC=y +# CONFIG_FEATURE_SH_HISTFILESIZE is not set +CONFIG_FEATURE_SH_EMBEDDED_SCRIPTS=y + +# +# System Logging Utilities +# +CONFIG_KLOGD=y +CONFIG_FEATURE_KLOGD_KLOGCTL=y +CONFIG_LOGGER=y +# CONFIG_LOGREAD is not set +# CONFIG_FEATURE_LOGREAD_REDUCED_LOCKING is not set +CONFIG_SYSLOGD=y +CONFIG_FEATURE_ROTATE_LOGFILE=y +CONFIG_FEATURE_REMOTE_LOG=y +# CONFIG_FEATURE_SYSLOGD_DUP is not set +# CONFIG_FEATURE_SYSLOGD_CFG is not set +# CONFIG_FEATURE_SYSLOGD_PRECISE_TIMESTAMPS is not set +CONFIG_FEATURE_SYSLOGD_READ_BUFFER_SIZE=256 +# CONFIG_FEATURE_IPC_SYSLOG is not set +CONFIG_FEATURE_IPC_SYSLOG_BUFFER_SIZE=0 +# CONFIG_FEATURE_KMSG_SYSLOG is not set diff --git a/package/busybox/inittab b/package/busybox/inittab new file mode 100644 index 0000000..f2b4df8 --- /dev/null +++ b/package/busybox/inittab @@ -0,0 +1,40 @@ +# /etc/inittab +# +# Copyright (C) 2001 Erik Andersen +# +# Note: BusyBox init doesn't support runlevels. The runlevels field is +# completely ignored by BusyBox init. If you want runlevels, use +# sysvinit. +# +# Format for each entry: ::: +# +# id == tty to run on, or empty for /dev/console +# runlevels == ignored +# action == one of sysinit, respawn, askfirst, wait, and once +# process == program to run + +# Startup the system +::sysinit:/bin/mount -t proc proc /proc +::sysinit:/bin/mount -o remount,rw / +::sysinit:/bin/mkdir -p /dev/pts /dev/shm +::sysinit:/bin/mount -a +::sysinit:/bin/mkdir -p /run/lock/subsys +::sysinit:/sbin/swapon -a +null::sysinit:/bin/ln -sf /proc/self/fd /dev/fd +null::sysinit:/bin/ln -sf /proc/self/fd/0 /dev/stdin +null::sysinit:/bin/ln -sf /proc/self/fd/1 /dev/stdout +null::sysinit:/bin/ln -sf /proc/self/fd/2 /dev/stderr +::sysinit:/bin/hostname -F /etc/hostname +# now run any rc scripts +::sysinit:/etc/init.d/rcS + +# Put a getty on the serial port +#ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt100 # GENERIC_SERIAL + +# Stuff to do for the 3-finger salute +#::ctrlaltdel:/sbin/reboot + +# Stuff to do before rebooting +::shutdown:/etc/init.d/rcK +::shutdown:/sbin/swapoff -a +::shutdown:/bin/umount -a -r diff --git a/package/busybox/make.sh b/package/busybox/make.sh new file mode 100755 index 0000000..6dcbc70 --- /dev/null +++ b/package/busybox/make.sh @@ -0,0 +1,86 @@ +#!/usr/bin/bash +source $(dirname "$0")/../common.sh + +PKGNAME=busybox +PKGVERSION=1.37.0 +PKGSOURCE_DIR=busybox +PKGSOURCE=busybox-1.37.0.tar.bz2 +PKGURL=https://www.busybox.net/downloads/busybox-1.37.0.tar.bz2 + +PKGBUILDNAME=${PKGNAME} +PKGBUILD_DIR=${BUILD_DIR}/${PKGBUILDNAME}-${PKGVERSION} + +echo "----> Building ${PKGBUILDNAME} ..." + +stamp_downloaded + +step_start extract +mkdir -p ${PKGBUILD_DIR} +bzcat ${DL_DIR}/${PKGSOURCE_DIR}/${PKGSOURCE} | tar --strip-components=1 -C ${PKGBUILD_DIR} -xf - +chmod -R +rw ${PKGBUILD_DIR} +step_end extract + +step_start patch +TAR="tar" PATH=${HOST_DIR}/bin:$PATH ${PROJECT_DIR}/support/scripts/apply-patches.sh ${PKGBUILD_DIR} ${PROJECT_DIR}/package/${PKGNAME} \*.patch +step_end patch + +# Before running configure, the configuration file should be present and fixed +# busybox 这里的动作分以下几步: +# 先用 busybox.config 替换 .config 文件,busybox.config 基于 1.36.1,这里直接参考了 buildroot (2025.08.1) 维护的一套针对 busybox 的默认配置 +# 然后执行 yes = "" | make oldconfig,目的是基于我们当前的 busybox 版本(1.37.0)升级 .config 文件 +# 然后执行 fix,即手动调整一些配置 +# 最后再执行一遍 yes = "" | make oldconfig,确保配置正确 +/usr/bin/install -m 0644 -D ${PROJECT_DIR}/package/busybox/busybox.config ${PKGBUILD_DIR}/.config +yes "" | eval "${TARGET_MAKE_ENV} CFLAGS=\"-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g0 -D_FORTIFY_SOURCE=1\" CFLAGS_busybox=\"\" /usr/bin/make -j${MAXNUM_CPUS} -C ${PKGBUILD_DIR} HOSTCC=\"/usr/bin/gcc\" AR=\"${CROSS_COMPILE}gcc-ar\" NM=\"${CROSS_COMPILE}gcc-nm\" RANLIB=\"${CROSS_COMPILE}gcc-ranlib\" CC=\"${CROSS_COMPILE}gcc\" ARCH=riscv PREFIX=\"${TARGET_DIR}\" EXTRA_LDFLAGS=\"\" CROSS_COMPILE=\"${CROSS_COMPILE}\" CONFIG_PREFIX=\"${TARGET_DIR}\" SKIP_STRIP=y oldconfig" +touch ${PKGBUILD_DIR}/.stamp_dotconfig +# fixup +kconfig_disable_option CONFIG_NOMMU +kconfig_enable_option CONFIG_USE_BB_CRYPT_SHA +kconfig_disable_option CONFIG_PAM +kconfig_enable_option CONFIG_INIT +yes "" | eval "${TARGET_MAKE_ENV} CFLAGS=\"-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g0 -D_FORTIFY_SOURCE=1\" CFLAGS_busybox=\"\" /usr/bin/make -j${MAXNUM_CPUS} -C ${PKGBUILD_DIR} HOSTCC=\"/usr/bin/gcc\" AR=\"${CROSS_COMPILE}gcc-ar\" NM=\"${CROSS_COMPILE}gcc-nm\" RANLIB=\"${CROSS_COMPILE}gcc-ranlib\" CC=\"${CROSS_COMPILE}gcc\" ARCH=riscv PREFIX=\"${TARGET_DIR}\" EXTRA_LDFLAGS=\"\" CROSS_COMPILE=\"${CROSS_COMPILE}\" CONFIG_PREFIX=\"${TARGET_DIR}\" SKIP_STRIP=y oldconfig" +touch ${PKGBUILD_DIR}/.stamp_kconfig_fixup_done + +# 对于 busybox 来说没有使用 configure 脚本 +stamp_configured + +step_start build +eval "${TARGET_MAKE_ENV} CFLAGS=\"-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g0 -D_FORTIFY_SOURCE=1\" CFLAGS_busybox=\"\" /usr/bin/make -j${MAXNUM_CPUS} AR=\"${CROSS_COMPILE}gcc-ar\" NM=\"${CROSS_COMPILE}${CROSS_COMPILE}gcc-nm\" RANLIB=\"${CROSS_COMPILE}gcc-ranlib\" CC=\"${CROSS_COMPILE}gcc\" ARCH=riscv PREFIX=\"${TARGET_DIR}\" EXTRA_LDFLAGS=\"\" CROSS_COMPILE=\"${CROSS_COMPILE}\" CONFIG_PREFIX=\"${TARGET_DIR}\" SKIP_STRIP=y -C ${PKGBUILD_DIR}" +step_end build + +step_start install-target +eval "${TARGET_MAKE_ENV} CFLAGS=\"-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g0 -D_FORTIFY_SOURCE=1\" CFLAGS_busybox=\"\" /usr/bin/make -j${MAXNUM_CPUS} AR=\"${CROSS_COMPILE}gcc-ar\" NM=\"${CROSS_COMPILE}gcc-nm\" RANLIB=\"${CROSS_COMPILE}gcc-ranlib\" CC=\"${CROSS_COMPILE}gcc\" ARCH=riscv PREFIX=\"${TARGET_DIR}\" EXTRA_LDFLAGS=\"\" CROSS_COMPILE=\"${CROSS_COMPILE}\" CONFIG_PREFIX=\"${TARGET_DIR}\" SKIP_STRIP=y -C ${PKGBUILD_DIR} install-noclobber" +if test ! -e ${TARGET_DIR}/etc/inittab; then + /usr/bin/install -D -m 0644 ${PROJECT_DIR}/package/busybox/inittab ${TARGET_DIR}/etc/inittab; +fi +if grep -q CONFIG_UDHCPC=y ${PKGBUILD_DIR}/.config; then + /usr/bin/install -m 0755 -D ${PROJECT_DIR}/package/busybox/udhcpc.script ${TARGET_DIR}/usr/share/udhcpc/default.script; + /usr/bin/install -m 0755 -d ${TARGET_DIR}/usr/share/udhcpc/default.script.d; +fi +if grep -q CONFIG_ZCIP=y ${PKGBUILD_DIR}/.config; then + /usr/bin/install -m 0755 -D ${PKGBUILD_DIR}/examples/zcip.script ${TARGET_DIR}/usr/share/zcip/default.script; +fi +if grep -q CONFIG_SYSLOGD=y ${PKGBUILD_DIR}/.config; then + /usr/bin/install -m 0755 -D ${PROJECT_DIR}/package/busybox/S01syslogd ${TARGET_DIR}/etc/init.d/S01syslogd; +fi; +if grep -q CONFIG_KLOGD=y ${PKGBUILD_DIR}/.config; then + /usr/bin/install -m 0755 -D ${PROJECT_DIR}/package/busybox/S02klogd ${TARGET_DIR}/etc/init.d/S02klogd; +fi +if grep -q CONFIG_BB_SYSCTL=y ${PKGBUILD_DIR}/.config; then + /usr/bin/install -m 0755 -D ${PROJECT_DIR}/package/busybox/S02sysctl ${TARGET_DIR}/etc/init.d/S02sysctl ; +fi +if grep -q CONFIG_IFPLUGD=y ${PKGBUILD_DIR}/.config; then + /usr/bin/install -m 0755 -D ${PROJECT_DIR}/package/busybox/S41ifplugd ${TARGET_DIR}/etc/init.d/S41ifplugd; +fi; +if grep -q CONFIG_CROND=y ${PKGBUILD_DIR}/.config; then + mkdir -p ${TARGET_DIR}/etc/cron/crontabs + /usr/bin/install -m 0755 -D ${PROJECT_DIR}/package/busybox/S50crond ${TARGET_DIR}/etc/init.d/S50crond +fi; +if grep -q CONFIG_FEATURE_TELNETD_STANDALONE=y ${PKGBUILD_DIR}/.config; then + /usr/bin/install -m 0755 -D ${PROJECT_DIR}/package/busybox/S50telnet ${TARGET_DIR}/etc/init.d/S50telnet ; +fi +step_end install-target + +stamp_installed + +echo "<---- ${PKGBUILDNAME} build complete." diff --git a/package/busybox/udhcpc.script b/package/busybox/udhcpc.script new file mode 100755 index 0000000..74dc553 --- /dev/null +++ b/package/busybox/udhcpc.script @@ -0,0 +1,122 @@ +#!/bin/sh + +# udhcpc script edited by Tim Riker + +[ -z "$1" ] && echo "Error: should be called from udhcpc" && exit 1 + +ACTION="$1" +RESOLV_CONF="/etc/resolv.conf" +[ -e $RESOLV_CONF ] || touch $RESOLV_CONF +[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast" +[ -n "$subnet" ] && NETMASK="netmask $subnet" +# Handle stateful DHCPv6 like DHCPv4 +[ -n "$ipv6" ] && ip="$ipv6/128" + +if [ -z "${IF_WAIT_DELAY}" ]; then + IF_WAIT_DELAY=10 +fi + +wait_for_ipv6_default_route() { + printf "Waiting for IPv6 default route to appear" + while [ $IF_WAIT_DELAY -gt 0 ]; do + if ip -6 route list | grep -q default; then + printf "\n" + return + fi + sleep 1 + printf "." + : $((IF_WAIT_DELAY -= 1)) + done + printf " timeout!\n" +} + +case "$ACTION" in + deconfig) + /sbin/ifconfig $interface up + /sbin/ifconfig $interface 0.0.0.0 + + # drop info from this interface + # resolv.conf may be a symlink to /tmp/, so take care + TMPFILE=$(mktemp) + grep -vE "# $interface\$" $RESOLV_CONF > $TMPFILE + cat $TMPFILE > $RESOLV_CONF + rm -f $TMPFILE + + if [ -x /usr/sbin/avahi-autoipd ]; then + /usr/sbin/avahi-autoipd -c $interface && /usr/sbin/avahi-autoipd -k $interface + fi + ;; + + leasefail|nak) + if [ -x /usr/sbin/avahi-autoipd ]; then + /usr/sbin/avahi-autoipd -c $interface || /usr/sbin/avahi-autoipd -wD $interface --no-chroot + fi + ;; + + renew|bound) + if [ -x /usr/sbin/avahi-autoipd ]; then + /usr/sbin/avahi-autoipd -c $interface && /usr/sbin/avahi-autoipd -k $interface + fi + /sbin/ifconfig $interface $ip $BROADCAST $NETMASK + if [ -n "$ipv6" ] ; then + wait_for_ipv6_default_route + fi + + # RFC3442: If the DHCP server returns both a Classless + # Static Routes option and a Router option, the DHCP + # client MUST ignore the Router option. + if [ -n "$staticroutes" ]; then + echo "deleting routers" + route -n | while read dest gw mask flags metric ref use iface; do + [ "$iface" != "$interface" -o "$gw" = "0.0.0.0" ] || \ + route del -net "$dest" netmask "$mask" gw "$gw" dev "$interface" + done + + # format: dest1/mask gw1 ... destn/mask gwn + set -- $staticroutes + while [ -n "$1" -a -n "$2" ]; do + route add -net "$1" gw "$2" dev "$interface" + shift 2 + done + elif [ -n "$router" ] ; then + echo "deleting routers" + while route del default gw 0.0.0.0 dev $interface 2> /dev/null; do + : + done + + for i in $router ; do + route add default gw $i dev $interface + done + fi + + # drop info from this interface + # resolv.conf may be a symlink to /tmp/, so take care + TMPFILE=$(mktemp) + grep -vE "# $interface\$" $RESOLV_CONF > $TMPFILE + cat $TMPFILE > $RESOLV_CONF + rm -f $TMPFILE + + # prefer rfc3397 domain search list (option 119) if available + if [ -n "$search" ]; then + search_list=$search + elif [ -n "$domain" ]; then + search_list=$domain + fi + + [ -n "$search_list" ] && + echo "search $search_list # $interface" >> $RESOLV_CONF + + for i in $dns ; do + echo adding dns $i + echo "nameserver $i # $interface" >> $RESOLV_CONF + done + ;; +esac + +HOOK_DIR="$0.d" +for hook in "${HOOK_DIR}/"*; do + [ -f "${hook}" -a -x "${hook}" ] || continue + "${hook}" "$ACTION" +done + +exit 0 diff --git a/package/common.sh b/package/common.sh new file mode 100644 index 0000000..ff643a3 --- /dev/null +++ b/package/common.sh @@ -0,0 +1,341 @@ +if [ "${TRACE}" = "1" ] ; then + exit 0 +fi + +if [ "${DEBUG}" = "1" ] ; then + set -x +fi + +ARCH=riscv64 +TARGET_VENDOR=unknown +TARGET_OS=linux +LIBC=gnu +ABI= +# riscv64-unknown-linux-gnu +GNU_TARGET_NAME=${ARCH}-${TARGET_VENDOR}-${TARGET_OS}-${LIBC}${ABI} + +SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd) +PROJECT_DIR=$(realpath "${SCRIPT_DIR}/../..") +OUTPUT_DIR=${PROJECT_DIR}/output +DL_DIR=${PROJECT_DIR}/dl +HOST_DIR=${OUTPUT_DIR}/host +BUILD_DIR=${OUTPUT_DIR}/build +TARGET_DIR=${OUTPUT_DIR}/target +IMAGES_DIR=${OUTPUT_DIR}/images +STAGING_DIR=${HOST_DIR}/${GNU_TARGET_NAME}/sysroot +STAGING_SUBDIR=${GNU_TARGET_NAME}/sysroot + +MAXNUM_CPUS=$(nproc) + +CROSS_COMPILE=${HOST_DIR}/bin/${GNU_TARGET_NAME}- + +export HOST_DIR TARGET_DIR STAGING_DIR + +# FIXME: 我们目前假设 DL_DIR 已经存在, 其创建不作为构建的一部分。 +# 以后获取可以考虑为 download 专门写个脚本来创建 DL_DIR 并下载所需的所有的包。 + +# UPDATE_CONFIG_HOOK +function update_config_guess_sub() { + echo ">>> ${PKGBUILDNAME} ${PKGVERSION} Updating config.sub and config.guess" + for file in config.guess config.sub; do + for i in $(find $1 -name $file); do + cp ${PROJECT_DIR}/support/gnuconfig/$file $i + done + done +} + +# LIBTOOL_PATCH_HOOK +function patch_libtool() { + echo ">>> ${PKGBUILDNAME} ${PKGVERSION} Patching libtool" + for i in `find $1 -name ltmain.sh`; do + ltmain_version=`sed -n '/^[ \t]*VERSION=/{s/^[ \t]*VERSION=//;p;q;}' $i | \ + sed -e 's/\([0-9]*\.[0-9]*\).*/\1/' -e 's/\"//'`; + ltmain_patchlevel=`sed -n '/^[ \t]*VERSION=/{s/^[ \t]*VERSION=//;p;q;}' $i | \ + sed -e 's/\([0-9]*\.[0-9]*\.*\)\([0-9]*\).*/\2/' -e 's/\"//'`; + if test ${ltmain_version} = '1.5'; then + patch -i ${PROJECT_DIR}/support/libtool/buildroot-libtool-v1.5.patch ${i}; + elif test ${ltmain_version} = "2.2"; then + patch -i ${PROJECT_DIR}/support/libtool/buildroot-libtool-v2.2.patch ${i}; + elif test ${ltmain_version} = "2.4"; then + if test ${ltmain_patchlevel:-0} -gt 2; then + patch -i ${PROJECT_DIR}/support/libtool/buildroot-libtool-v2.4.4.patch ${i}; + else + patch -i ${PROJECT_DIR}/support/libtool/buildroot-libtool-v2.4.patch ${i}; + fi + elif test ${ltmain_version} = "2.5"; then + patch -i ${PROJECT_DIR}/support/libtool/buildroot-libtool-v2.4.4.patch ${i}; + fi + done +} + +# Fixing package configuration files when do staging installing. +# parameter: 1 - the package config file name, e.g., pkg-config, cmake +function fix_package_config_files_for_staging_install() { + if [ -n "${1}" ] ; then + echo ">>> ${PKGBUILDNAME} ${PKGVERSION} Fixing package configuration files" ;\ + /usr/bin/sed -i -e "s,${HOST_DIR},@HOST_DIR@,g" \ + -e "s,${OUTPUT_DIR},@BASE_DIR@,g" \ + -e "s,^\(exec_\)\?prefix=.*,\1prefix=@STAGING_DIR@/usr,g" \ + -e "s,-I/usr/,-I@STAGING_DIR@/usr/,g" \ + -e "s,-L/usr/,-L@STAGING_DIR@/usr/,g" \ + -e 's,@STAGING_DIR@,$(dirname $(readlink -e $0))/../..,g' \ + -e 's,@HOST_DIR@,$(dirname $(readlink -e $0))/../../../..,g' \ + -e "s,@BASE_DIR@,${OUTPUT_DIR},g" \ + ${STAGING_DIR}/usr/bin/${1} ; + fi +} + +# Fixing libtool files when do staging installing. +function fix_libtool_files_for_staging_install() { + echo ">>> ${PKGBUILDNAME} ${PKGVERSION} Fixing libtool files" + for la in $(find ${STAGING_DIR}/usr/lib* -name "*.la"); do + cp -a "${la}" "${la}.fixed" && \ + /usr/bin/sed -i -e "s:${OUTPUT_DIR}:@BASE_DIR@:g" \ + -e "s:${STAGING_DIR}:@STAGING_DIR@:g" \ + -e "s:\(['= ]\)/usr:\\1@STAGING_DIR@/usr:g" \ + -e "s:\(['= ]\)/lib:\\1@STAGING_DIR@/lib:g" \ + -e "s:@STAGING_DIR@:${STAGING_DIR}:g" \ + -e "s:@BASE_DIR@:${OUTPUT_DIR}:g" \ + "${la}.fixed" && \ + if cmp -s "${la}" "${la}.fixed"; then \ + rm -f "${la}.fixed"; \ + else \ + mv "${la}.fixed" "${la}"; \ + fi || exit 1; + done +} + +# Check the specified kernel headers version actually matches the +# version in the toolchain. +# toolchain/helpers.mk +function check_kernel_headers_version() { + if ! ${PROJECT_DIR}/support/scripts/check-kernel-headers.sh ${1} ${2} ${3} ${4}; then + exit 1; + fi +} + +# Defined in toolchain/helpers.mk +function copy_toolchain_lib_root() { + LIBPATTERN="${1}" + LIBPATHS=`find ${STAGING_DIR} -name "${LIBPATTERN}" 2>/dev/null` + for LIBPATH in ${LIBPATHS} ; do + while true ; do + LIBNAME=`basename ${LIBPATH}` + DESTDIR=`echo ${LIBPATH} | sed "s,^${STAGING_DIR},," | xargs dirname` + mkdir -p ${TARGET_DIR}/${DESTDIR} + rm -fr ${TARGET_DIR}/${DESTDIR}/${LIBNAME} + if test -h ${LIBPATH} ; then + cp -d ${LIBPATH} ${TARGET_DIR}/${DESTDIR}/${LIBNAME} + OLD_LIBPATH="${LIBPATH}" + LIBPATH="`readlink -f ${LIBPATH}`" + if [ "${LIBPATH}" = "" ]; then + echo "LIBPATH empty after trying to resolve symlink ${OLD_LIBPATH}" 1>&2 + exit 1 + fi + elif test -f ${LIBPATH}; then + /usr/bin/install -D -m0755 ${LIBPATH} ${TARGET_DIR}/${DESTDIR}/${LIBNAME} + break + else + exit -1 + fi + done + done +} + +function kconfig_enable_option() { + if ! grep -q "^${1}=[my]" ${PKGBUILD_DIR}/.config; then + /usr/bin/sed -i -e "/^\(# \)\?${1}\>/d" ${PKGBUILD_DIR}/.config && echo "${1}=y" >> ${PKGBUILD_DIR}/.config; + fi +} + +function kconfig_disable_option() { + /usr/bin/sed -i -e "/^\(# \)\?${1}\>/d" ${PKGBUILD_DIR}/.config && echo "# ${1} is not set" >> ${PKGBUILD_DIR}/.config +} + +# ${1}: base directory to search in +# ${2}: suffix of file (optional) +# example: +# cd ${TARGET_DIR}; +# LC_ALL=C find . -not -path './riscv64-unknown-linux-gnu/sysroot/*' \( -type f -o -type l \) -printf '%T@:%i:%#m:%y:%s,%p\n' \ +# | LC_ALL=C sort > ${PKGBUILD_DIR}/.files-list.before +function pkg_size_before() { + cd ${1}; + LC_ALL=C find . -not -path "./${STAGING_SUBDIR}/*" \( -type f -o -type l \) -printf '%T@:%i:%#m:%y:%s,%p\n' \ + | LC_ALL=C sort > ${PKGBUILD_DIR}/.files-list${2}.before; +} + +# ${1}: base directory to search in +# ${2}: suffix of file (optional) +function pkg_size_after() { + cd ${1}; \ + LC_ALL=C find . -not -path "./${STAGING_SUBDIR}/*" \( -type f -o -type l \) -printf '%T@:%i:%#m:%y:%s,%p\n' \ + | LC_ALL=C sort > ${PKGBUILD_DIR}/.files-list${2}.after + LC_ALL=C comm -13 \ + ${PKGBUILD_DIR}/.files-list${2}.before \ + ${PKGBUILD_DIR}/.files-list${2}.after \ + | sed -r -e "s/^[^,]+/${PKGBUILDNAME}/" \ + > ${PKGBUILD_DIR}/.files-list${2}.txt + rm -f ${PKGBUILD_DIR}/.files-list${2}.before + rm -f ${PKGBUILD_DIR}/.files-list${2}.after +} + +# ${1} step name +function step_start() { + printf "%s:%-5.5s:%-20.20s: %s\n" "$(date +%s.%N)" "start" "${1}" "${PKGBUILDNAME}" >>"${BUILD_DIR}/build-time.log" + if [ "${1}" == "download" ]; then + echo ">>> ${PKGBUILDNAME} ${PKGVERSION} Downloading" + elif [ "${1}" == "extract" ]; then + echo ">>> ${PKGBUILDNAME} ${PKGVERSION} Extracting" + elif [ "${1}" == "patch" ]; then + echo ">>> ${PKGBUILDNAME} ${PKGVERSION} Patching" + elif [ "${1}" == "configure" ]; then + echo ">>> ${PKGBUILDNAME} ${PKGVERSION} Configuring" + elif [ "${1}" == "build" ]; then + echo ">>> ${PKGBUILDNAME} ${PKGVERSION} Building" + elif [ "${1}" == "install-host" ]; then + echo ">>> ${PKGBUILDNAME} ${PKGVERSION} Installing to host directory" + elif [ "${1}" == "install-staging" ]; then + echo ">>> ${PKGBUILDNAME} ${PKGVERSION} Installing to staging directory" + elif [ "${1}" == "install-target" ]; then + echo ">>> ${PKGBUILDNAME} ${PKGVERSION} Installing to target" + elif [ "${1}" == "install-image" ]; then + echo ">>> ${PKGBUILDNAME} ${PKGVERSION} Installing to images directory" + fi + + if [ "${1}" == "configure" ]; then + mkdir -p ${HOST_DIR} ${TARGET_DIR} ${STAGING_DIR} ${IMAGES_DIR} + pkg_size_before ${TARGET_DIR} + pkg_size_before ${STAGING_DIR} -staging + pkg_size_before ${IMAGES_DIR} -images + pkg_size_before ${HOST_DIR} -host + fi +} + +# ${1} step name +# ${2} 如果 ${1} 为 "patch", 则可能存在 ${2},用于标识构建类型;目前支持的有效值为 +# "autotool", 其他情况不给出则默认为不适用 autotools,譬如采用 kconfig 的, +# 如 linux,busybox 等。 +# 对于该分支,如果 ${2} 为空则 ${3} 也必须为空 +# 如果 ${1} 为 "install-staging", 则可能存在 ${2} +# ${3} 如果 ${1} 为 "patch" 并且 ${2} 为 "autotools",则可以继续指定 ${3} 用于指 +# 定是否需要忽略给 libtool 打补丁,"ignore_libtool_patch" 表示忽略。默认如果 +# 不指明则缺省要给 libtool 打补丁 +function step_end() { + if [ "${1}" == "patch" ]; then + # 如果是采用 autotools 方式构建才有可能需要更新 config.guess + # 以及对 libtool 打补丁。 + # 但也有几种情况是不需要在 patch 阶段对 libtool 打补丁的 + # 一种是 configure 阶段会运行 autoreconf,对该种情况我们会在 + # 运行完 autoreconf 后再对 libtool 打补丁 + # 还有一种情况是明确不需要对 libtool 打补丁的,譬如本身就是在 + # 构建 libtool。 + if [ "${2}" == "autotools" ]; then + update_config_guess_sub ${PKGBUILD_DIR} + if [ "${3}" != "ignore_libtool_patch" ]; then + patch_libtool ${PKGBUILD_DIR} + fi + fi + elif [ "${1}" == "install-host" ]; then + rm -f -rf ${HOST_DIR}/share/info/dir + elif [ "${1}" == "install-staging" ]; then + rm -f -rf ${STAGING_DIR}/share/info/dir + fix_package_config_files_for_staging_install ${2} + fix_libtool_files_for_staging_install + elif [ "${1}" == "install-target" ]; then + rm -f -rf ${TARGET_DIR}/share/info/dir + fi + printf "%s:%-5.5s:%-20.20s: %s\n" "$(date +%s.%N)" "end" "${1}" "${PKGBUILDNAME}" >>"${BUILD_DIR}/build-time.log" + if [ "${1}" == "install-host" ]; then + ${PROJECT_DIR}/support/scripts/check-host-rpath ${PKGBUILDNAME} ${HOST_DIR} ${OUTPUT_DIR}/per-package + fi + # 这里应该有一步 step_check_build_dir,但从 make 的 log 看感觉这里传入的 $(STAGING_DIR)/$(O) 会有问题 + # FIXME,先不加这个 check + mkdir -p ${PKGBUILD_DIR} + if [ "${1}" == "download" ]; then + touch ${PKGBUILD_DIR}/.stamp_downloaded + elif [ "${1}" == "extract" ]; then + touch ${PKGBUILD_DIR}/.stamp_extracted + elif [ "${1}" == "patch" ]; then + touch ${PKGBUILD_DIR}/.stamp_patched + elif [ "${1}" == "configure" ]; then + touch ${PKGBUILD_DIR}/.stamp_configured + elif [ "${1}" == "build" ]; then + touch ${PKGBUILD_DIR}/.stamp_built + elif [ "${1}" == "install-host" ]; then + touch ${PKGBUILD_DIR}/.stamp_host_installed + elif [ "${1}" == "install-staging" ]; then + touch ${PKGBUILD_DIR}/.stamp_staging_installed + elif [ "${1}" == "install-target" ]; then + touch ${PKGBUILD_DIR}/.stamp_target_installed + elif [ "${1}" == "install-image" ]; then + touch ${PKGBUILD_DIR}/.stamp_images_installed + fi +} + +function stamp_downloaded() { + local STARTED=n + # PKGSOURCE is MUST to have; PKGSOURCE2 is OPTIONAL + if [ ! -z "${PKGSOURCE}" ]; then + for p in ${PKGURL}; do + f=`basename ${p}` + if [ ! -e "${DL_DIR}/${PKGSOURCE_DIR}/${f}" ] ; then + if [ ${STARTED} = "n" ]; then + step_start download + STARTED=y + fi + mkdir -p ${DL_DIR}/${PKGSOURCE_DIR} + (cd ${DL_DIR}/${PKGSOURCE_DIR}; wget ${PKGURL}) + if [ $? -ne 0 ]; then + echo ">>> ${PKGBUILDNAME} ${PKGVERSION} Downloading FAILED!!!" + exit 1 + fi + fi + done + if [ ${STARTED} = "y" ]; then + step_end download + fi + fi + if [ "${ONLY_DOWNLOAD}" = "y" ] ; then + exit 0 + fi +} + +function stamp_extracted() { + step_start extract + step_end extract +} + +# ${1}: see comments for ${2} of step_end +function stamp_patched() { + step_start patch + step_end patch ${1} +} + +function stamp_configured() { + step_start configure + step_end configure +} + +function stamp_built() { + step_start build + step_end build +} + +function stamp_installed() { + pkg_size_after ${TARGET_DIR} + pkg_size_after ${STAGING_DIR} -staging + pkg_size_after ${IMAGES_DIR} -images + pkg_size_after ${HOST_DIR} -host + ${PROJECT_DIR}/support/scripts/check-bin-arch -p ${PKGBUILDNAME} -l ${PKGBUILD_DIR}/.files-list.txt -r ${CROSS_COMPILE}readelf -a "RISC-V" + touch ${PKGBUILD_DIR}/.stamp_installed +} + +HOST_MAKE_ENV='GIT_DIR=. PATH="${HOST_DIR}/bin:${HOST_DIR}/sbin:${PATH}" PKG_CONFIG="${HOST_DIR}/bin/pkg-config" PKG_CONFIG_SYSROOT_DIR="/" PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 PKG_CONFIG_LIBDIR="${HOST_DIR}/lib/pkgconfig:${HOST_DIR}/share/pkgconfig"' + +HOST_CONFIGURE_OPTS='GIT_DIR=. PATH="${HOST_DIR}/bin:${HOST_DIR}/sbin:${PATH}" PKG_CONFIG="${HOST_DIR}/bin/pkg-config" PKG_CONFIG_SYSROOT_DIR="/" PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 PKG_CONFIG_LIBDIR="${HOST_DIR}/lib/pkgconfig:${HOST_DIR}/share/pkgconfig" AR="/usr/bin/ar" AS="/usr/bin/as" LD="/usr/bin/ld" NM="/usr/bin/nm" CC="/usr/bin/gcc" GCC="/usr/bin/gcc" CXX="/usr/bin/g++" CPP="/usr/bin/cpp" OBJCOPY="/usr/bin/objcopy" RANLIB="/usr/bin/ranlib" CPPFLAGS="-I${HOST_DIR}/include" CFLAGS="-O2 -I${HOST_DIR}/include" CXXFLAGS="-O2 -I${HOST_DIR}/include" LDFLAGS="-L${HOST_DIR}/lib -Wl,-rpath,${HOST_DIR}/lib" INTLTOOL_PERL=/usr/bin/perl' + +AUTORECONF_OPTS='GIT_DIR=. PATH="${HOST_DIR}/bin:${HOST_DIR}/sbin:${PATH}" PKG_CONFIG="${HOST_DIR}/bin/pkg-config" PKG_CONFIG_SYSROOT_DIR="/" PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 PKG_CONFIG_LIBDIR="${HOST_DIR}/lib/pkgconfig:${HOST_DIR}/share/pkgconfig" AR="/usr/bin/ar" AS="/usr/bin/as" LD="/usr/bin/ld" NM="/usr/bin/nm" CC="/usr/bin/gcc" GCC="/usr/bin/gcc" CXX="/usr/bin/g++" CPP="/usr/bin/cpp" OBJCOPY="/usr/bin/objcopy" RANLIB="/usr/bin/ranlib" CPPFLAGS="-I${HOST_DIR}/include" CFLAGS="-O2 -I${HOST_DIR}/include" CXXFLAGS="-O2 -I${HOST_DIR}/include" LDFLAGS="-L${HOST_DIR}/lib -Wl,-rpath,${HOST_DIR}/lib" INTLTOOL_PERL=/usr/bin/perl ACLOCAL="${HOST_DIR}/bin/aclocal" AUTOCONF="${HOST_DIR}/bin/autoconf -I "${STAGING_DIR}/usr/share/aclocal" -I "${HOST_DIR}/share/aclocal"" AUTOHEADER="${HOST_DIR}/bin/autoheader -I "${STAGING_DIR}/usr/share/aclocal" -I "${HOST_DIR}/share/aclocal"" AUTOMAKE="${HOST_DIR}/bin/automake" GTKDOCIZE=/bin/true' + +TARGET_MAKE_ENV='GIT_DIR=. PATH="${HOST_DIR}/bin:${HOST_DIR}/sbin:${PATH}"' + +TARGET_CONFIGURE_OPTS='GIT_DIR=. PATH="${HOST_DIR}/bin:${HOST_DIR}/sbin:${PATH}" AR="${CROSS_COMPILE}gcc-ar" AS="${CROSS_COMPILE}as" LD="${CROSS_COMPILE}ld" NM="${CROSS_COMPILE}gcc-nm" CC="${CROSS_COMPILE}gcc" GCC="${CROSS_COMPILE}gcc" CPP="${CROSS_COMPILE}cpp" CXX="${CROSS_COMPILE}g++" FC="${CROSS_COMPILE}gfortran" F77="${CROSS_COMPILE}gfortran" RANLIB="${CROSS_COMPILE}gcc-ranlib" READELF="${CROSS_COMPILE}readelf" STRIP="${CROSS_COMPILE}strip" OBJCOPY="${CROSS_COMPILE}objcopy" OBJDUMP="${CROSS_COMPILE}objdump" AR_FOR_BUILD="/usr/bin/ar" AS_FOR_BUILD="/usr/bin/as" CC_FOR_BUILD="/usr/bin/gcc" GCC_FOR_BUILD="/usr/bin/gcc" CXX_FOR_BUILD="/usr/bin/g++" LD_FOR_BUILD="/usr/bin/ld" CPPFLAGS_FOR_BUILD="-I${HOST_DIR}/include" CFLAGS_FOR_BUILD="-O2 -I${HOST_DIR}/include" CXXFLAGS_FOR_BUILD="-O2 -I${HOST_DIR}/include" LDFLAGS_FOR_BUILD="-L${HOST_DIR}/lib -Wl,-rpath,${HOST_DIR}/lib" FCFLAGS_FOR_BUILD="" DEFAULT_ASSEMBLER="${CROSS_COMPILE}as" DEFAULT_LINKER="${CROSS_COMPILE}ld" CPPFLAGS="-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64" CFLAGS="-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g0 -D_FORTIFY_SOURCE=1" CXXFLAGS="-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g0 -D_FORTIFY_SOURCE=1" LDFLAGS="" FCFLAGS=" -O2 -g0" FFLAGS=" -O2 -g0" PKG_CONFIG="${HOST_DIR}/bin/pkg-config" STAGING_DIR="${STAGING_DIR}" INTLTOOL_PERL=/usr/bin/perl' \ No newline at end of file diff --git a/package/e2fsprogs/make-host.sh b/package/e2fsprogs/make-host.sh new file mode 100755 index 0000000..413420c --- /dev/null +++ b/package/e2fsprogs/make-host.sh @@ -0,0 +1,41 @@ +#!/usr/bin/bash +source $(dirname "$0")/../common.sh + +PKGNAME=e2fsprogs +PKGVERSION=1.47.2 +PKGSOURCE_DIR=e2fsprogs +PKGSOURCE=e2fsprogs-1.47.2.tar.xz +PKGURL=http://mirrors.ustc.edu.cn/kernel.org/linux/kernel/people/tytso/e2fsprogs/v1.47.2/e2fsprogs-1.47.2.tar.xz + +PKGBUILDNAME=host-${PKGNAME} +PKGBUILD_DIR=${BUILD_DIR}/${PKGBUILDNAME}-${PKGVERSION} + +echo "----> Building ${PKGBUILDNAME} ..." + +stamp_downloaded + +step_start extract +mkdir -p ${PKGBUILD_DIR} +xzcat ${DL_DIR}/${PKGSOURCE_DIR}/${PKGSOURCE} | tar --strip-components=1 -C ${PKGBUILD_DIR} -xf - +chmod -R +rw ${PKGBUILD_DIR} +step_end extract + +stamp_patched autotools + +step_start configure +(cd ${PKGBUILD_DIR} && rm -rf config.cache; eval "${HOST_CONFIGURE_OPTS} ac_cv_path_LDCONFIG=true CONFIG_SITE=/dev/null ./configure --prefix=\"${HOST_DIR}\" --sysconfdir=\"${HOST_DIR}/etc\" --localstatedir=\"${HOST_DIR}/var\" --enable-shared --disable-static --disable-gtk-doc --disable-gtk-doc-html --disable-doc --disable-docs --disable-documentation --disable-debug --with-xmlto=no --with-fop=no --disable-nls --disable-dependency-tracking --disable-defrag --disable-e2initrd-helper --disable-fuse2fs --disable-fsck --disable-libblkid --disable-libuuid --disable-testio-debug --enable-symlink-install --enable-elf-shlibs --with-crond-dir=no --with-udev-rules-dir=no --with-systemd-unit-dir=no") +step_end configure + +step_start build +eval "${HOST_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} -C ${PKGBUILD_DIR}" +step_end build + +step_start install-host +eval "${HOST_MAKE_ENV} /usr/bin/make -j1 -C ${PKGBUILD_DIR} install install-libs" +# Remove compile_et which raises a build failure with samba4 +rm -f ${HOST_DIR}/bin/compile_et +step_end install-host + +stamp_installed + +echo "<---- ${PKGBUILDNAME} build complete." diff --git a/package/fakeroot/make-host.sh b/package/fakeroot/make-host.sh new file mode 100755 index 0000000..0a346b0 --- /dev/null +++ b/package/fakeroot/make-host.sh @@ -0,0 +1,41 @@ +#!/usr/bin/bash +source $(dirname "$0")/../common.sh + +PKGNAME=fakeroot +PKGVERSION=1.37.1.1 +PKGSOURCE_DIR=fakeroot +PKGSOURCE=fakeroot_1.37.1.1.orig.tar.gz +PKGURL=https://snapshot.debian.org/archive/debian/20250329T150348Z/pool/main/f/fakeroot/fakeroot_1.37.1.1.orig.tar.gz + +PKGBUILDNAME=host-${PKGNAME} +PKGBUILD_DIR=${BUILD_DIR}/${PKGBUILDNAME}-${PKGVERSION} + +echo "----> Building ${PKGBUILDNAME} ..." + +stamp_downloaded + +step_start extract +mkdir -p ${PKGBUILD_DIR} +gzip -d -c ${DL_DIR}/${PKGSOURCE_DIR}/${PKGSOURCE} | tar --strip-components=1 -C ${PKGBUILD_DIR} -xf - +chmod -R +rw ${PKGBUILD_DIR} +step_end extract + +step_start patch +TAR="tar" PATH=${HOST_DIR}/bin:$PATH ${PROJECT_DIR}/support/scripts/apply-patches.sh ${PKGBUILD_DIR} ${PROJECT_DIR}/package/${PKGNAME} \*.patch +step_end patch autotools + +step_start configure +(cd ${PKGBUILD_DIR} && rm -rf config.cache; eval "${HOST_CONFIGURE_OPTS} ac_cv_header_sys_capability_h=no ac_cv_func_capset=no CONFIG_SITE=/dev/null ./configure --prefix=\"${HOST_DIR}\" --sysconfdir=\"${HOST_DIR}/etc\" --localstatedir=\"${HOST_DIR}/var\" --enable-shared --disable-static --disable-gtk-doc --disable-gtk-doc-html --disable-doc --disable-docs --disable-documentation --disable-debug --with-xmlto=no --with-fop=no --disable-nls --disable-dependency-tracking") +step_end configure + +step_start build +eval "${HOST_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} -C ${PKGBUILD_DIR}" +step_end build + +step_start install-host +eval "${HOST_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} install -C ${PKGBUILD_DIR}" +step_end install-host + +stamp_installed + +echo "<---- ${PKGBUILDNAME} build complete." diff --git a/package/flex/0001-build-AC_USE_SYSTEM_EXTENSIONS-in-configure.ac.patch b/package/flex/0001-build-AC_USE_SYSTEM_EXTENSIONS-in-configure.ac.patch new file mode 100644 index 0000000..06747a3 --- /dev/null +++ b/package/flex/0001-build-AC_USE_SYSTEM_EXTENSIONS-in-configure.ac.patch @@ -0,0 +1,35 @@ +From ffa886a580929f26fd5e5a40c9c5334955c48553 Mon Sep 17 00:00:00 2001 +From: Explorer09 +Date: Mon, 4 Sep 2017 10:47:33 +0800 +Subject: [PATCH] build: AC_USE_SYSTEM_EXTENSIONS in configure.ac. + +This would, e.g. define _GNU_SOURCE in config.h, enabling the +reallocarray() prototype in glibc 2.26+ on Linux systems with that +version of glibc. + +Fixes #241. + +Backported from: 24fd0551333e7eded87b64dd36062da3df2f6380 +Signed-off-by: Adrian Perez de Castro +--- + configure.ac | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/configure.ac b/configure.ac +index 55e774b..c879fe1 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -25,8 +25,10 @@ + # autoconf requirements and initialization + + AC_INIT([the fast lexical analyser generator],[2.6.4],[flex-help@lists.sourceforge.net],[flex]) ++AC_PREREQ([2.60]) + AC_CONFIG_SRCDIR([src/scan.l]) + AC_CONFIG_AUX_DIR([build-aux]) ++AC_USE_SYSTEM_EXTENSIONS + LT_INIT + AM_INIT_AUTOMAKE([1.11.3 -Wno-portability foreign check-news std-options dist-lzip parallel-tests subdir-objects]) + AC_CONFIG_HEADER([src/config.h]) +-- +2.14.1 + diff --git a/package/flex/0002-build-make-it-possible-to-disable-the-build-of-the-f.patch b/package/flex/0002-build-make-it-possible-to-disable-the-build-of-the-f.patch new file mode 100644 index 0000000..19f5a77 --- /dev/null +++ b/package/flex/0002-build-make-it-possible-to-disable-the-build-of-the-f.patch @@ -0,0 +1,76 @@ +From da21733178b34eea303964db5a05e8a3ee4095b4 Mon Sep 17 00:00:00 2001 +From: Thomas Petazzoni +Date: Sat, 26 Aug 2017 15:17:06 +0200 +Subject: [PATCH] build: make it possible to disable the build of the flex + program + +The flex program uses fork(), which isn't available on noMMU +systems. However, the libfl library does not use fork(), and be used +by other programs/libraries. + +Therefore, it makes sense to provide an option to disable the build of +the flex program. + +Signed-off-by: Thomas Petazzoni +Signed-off-by: "Yann E. MORIN" + +--- +Submitted-upstream: https://github.com/westes/flex/pull/256 +Refused. We'll have to adapt when they do a new release... +--- + Makefile.am | 2 ++ + configure.ac | 6 ++++++ + doc/Makefile.am | 4 ++++ + src/Makefile.am | 3 +++ + 4 files changed, 15 insertions(+) + +diff --git a/Makefile.am b/Makefile.am +index e790e9d..8b57bc9 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -62,8 +62,10 @@ ChangeLog: $(srcdir)/tools/git2cl + indent: + cd src && $(MAKE) $(AM_MAKEFLAGS) indent + ++if ENABLE_PROGRAM + install-exec-hook: + cd $(DESTDIR)$(bindir) && \ + $(LN_S) -f flex$(EXEEXT) flex++$(EXEEXT) ++endif + + .PHONY: ChangeLog indent +diff --git a/configure.ac b/configure.ac +index 8882016..f49872b 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -75,6 +75,12 @@ AC_ARG_ENABLE([libfl], + [], [enable_libfl=yes]) + AM_CONDITIONAL([ENABLE_LIBFL], [test "x$enable_libfl" = xyes]) + ++AC_ARG_ENABLE([program], ++ [AS_HELP_STRING([--disable-program], ++ [do not build the flex program, only the libfl library])], ++ [], [enable_program=yes]) ++AM_CONDITIONAL([ENABLE_PROGRAM], [test "x$enable_program" = xyes]) ++ + # --disable-bootstrap is intended only to workaround problems with bootstrap + # (e.g. when cross-compiling flex or when bootstrapping has bugs). + # Ideally we should be able to bootstrap even when cross-compiling. +diff --git a/src/Makefile.am b/src/Makefile.am +index 0d13a5a..c73bc17 100644 +--- a/src/Makefile.am ++++ b/src/Makefile.am +@@ -4,7 +4,10 @@ LIBS = @LIBS@ + + m4 = @M4@ + ++if ENABLE_PROGRAM + bin_PROGRAMS = flex ++endif ++ + if ENABLE_BOOTSTRAP + noinst_PROGRAMS = stage1flex + endif +-- +2.9.4 + diff --git a/package/flex/0003-build-make-it-possible-to-disable-the-build-of-the-d.patch b/package/flex/0003-build-make-it-possible-to-disable-the-build-of-the-d.patch new file mode 100644 index 0000000..30a782e --- /dev/null +++ b/package/flex/0003-build-make-it-possible-to-disable-the-build-of-the-d.patch @@ -0,0 +1,58 @@ +From b89b8475a5b2f9444c32f7d254b35968da3c8a23 Mon Sep 17 00:00:00 2001 +From: "Yann E. MORIN" +Date: Fri, 29 Sep 2017 18:03:51 +0200 +Subject: [PATCH] build: make it possible to disable the build of the + documentation + +When targeting embedded devices, the documentation is not needed. + +Building the documentation default to whether the program is built. + +Signed-off-by: "Yann E. MORIN" +Cc: Thomas Petazzoni +--- + Makefile.am | 8 +++++++- + configure.ac | 6 ++++++ + 2 files changed, 13 insertions(+), 1 deletion(-) + +diff --git a/Makefile.am b/Makefile.am +index fce30b2..ee75b64 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -41,9 +41,15 @@ EXTRA_DIST = \ + .indent.pro \ + autogen.sh + ++MAYBE_SUBDIRS = ++ ++if ENABLE_DOC ++MAYBE_SUBDIRS += doc ++endif ++ + SUBDIRS = \ + src \ +- doc \ ++ $(MAYBE_SUBDIRS) \ + examples \ + po \ + tests \ +diff --git a/configure.ac b/configure.ac +index c54e98f..b3ae450 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -80,6 +80,12 @@ AC_ARG_ENABLE([program], + [], [enable_program=yes]) + AM_CONDITIONAL([ENABLE_PROGRAM], [test "x$enable_program" = xyes]) + ++AC_ARG_ENABLE([doc], ++ [AS_HELP_STRING([--disable-doc], ++ [do not build the documentation])], ++ [], [enable_doc=${enable_program}]) ++AM_CONDITIONAL([ENABLE_DOC], [test "x$enable_doc" = xyes -a "x$enable_program" = xyes]) ++ + # --disable-bootstrap is intended only to workaround problems with bootstrap + # (e.g. when cross-compiling flex or when bootstrapping has bugs). + # Ideally we should be able to bootstrap even when cross-compiling. +-- +2.11.0 + diff --git a/package/flex/0004-Match-malloc-signature-to-its-use.patch b/package/flex/0004-Match-malloc-signature-to-its-use.patch new file mode 100644 index 0000000..ac57e3b --- /dev/null +++ b/package/flex/0004-Match-malloc-signature-to-its-use.patch @@ -0,0 +1,27 @@ +From 4b142954b54a57a9b0af0a9661056a9c39a8fa95 Mon Sep 17 00:00:00 2001 +From: Richard Barnes +Date: Wed, 2 Oct 2024 10:35:09 -0700 +Subject: [PATCH] Match `malloc` signature to its use + +Upstream: https://github.com/westes/flex/pull/674 +Signed-off-by: Peter Korsgaard +--- + lib/malloc.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lib/malloc.c b/lib/malloc.c +index 75e8ef9..701b9b3 100755 +--- a/lib/malloc.c ++++ b/lib/malloc.c +@@ -3,7 +3,7 @@ + + #include + +- void *malloc (); ++ void *malloc (size_t n); + + /* Allocate an N-byte block of memory from the heap. + If N is zero, allocate a 1-byte block. */ +-- +2.39.5 + diff --git a/package/flex/make-host.sh b/package/flex/make-host.sh new file mode 100755 index 0000000..28ae67f --- /dev/null +++ b/package/flex/make-host.sh @@ -0,0 +1,44 @@ +#!/usr/bin/bash +source $(dirname "$0")/../common.sh + +PKGNAME=flex +PKGVERSION=2.6.4 +PKGSOURCE_DIR=flex +PKGSOURCE=flex-2.6.4.tar.gz +PKGURL=https://github.com/westes/flex/files/981163/flex-2.6.4.tar.gz + +PKGBUILDNAME=host-${PKGNAME} +PKGBUILD_DIR=${BUILD_DIR}/${PKGBUILDNAME}-${PKGVERSION} + +echo "----> Building ${PKGBUILDNAME} ..." + +stamp_downloaded + +step_start extract +mkdir -p ${PKGBUILD_DIR} +gzip -d -c ${DL_DIR}/${PKGSOURCE_DIR}/${PKGSOURCE} | tar --strip-components=1 -C ${PKGBUILD_DIR} -xf - +chmod -R +rw ${PKGBUILD_DIR} +step_end extract + +step_start patch +TAR="tar" PATH=${HOST_DIR}/bin:$PATH ${PROJECT_DIR}/support/scripts/apply-patches.sh ${PKGBUILD_DIR} ${PROJECT_DIR}/package/${PKGNAME} \*.patch +step_end patch autotools ignore_libtool_patch + +step_start configure +echo ">>> ${PKGBUILDNAME} ${PKGVERSION} Autoreconfiguring" +cd ${PKGBUILD_DIR} && eval "AUTOPOINT=${HOST_DIR}/bin/autopoint ${AUTORECONF_OPTS} ${HOST_DIR}/bin/autoreconf -f -i" +patch_libtool ${PKGBUILD_DIR} +(cd ${PKGBUILD_DIR} && rm -rf config.cache; eval "${HOST_CONFIGURE_OPTS} CONFIG_SITE=/dev/null ./configure --prefix=\"${HOST_DIR}\" --sysconfdir=\"${HOST_DIR}/etc\" --localstatedir=\"${HOST_DIR}/var\" --enable-shared --disable-static --disable-gtk-doc --disable-gtk-doc-html --disable-doc --disable-docs --disable-documentation --disable-debug --with-xmlto=no --with-fop=no --disable-nls --disable-dependency-tracking --disable-doc") +step_end configure + +step_start build +eval "${HOST_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} -C ${PKGBUILD_DIR}" +step_end build + +step_start install-host +eval "${HOST_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} install -C ${PKGBUILD_DIR}" +step_end install-host + +stamp_installed + +echo "<---- ${PKGBUILDNAME} build complete." diff --git a/package/gawk/make-host.sh b/package/gawk/make-host.sh new file mode 100755 index 0000000..06a7e2d --- /dev/null +++ b/package/gawk/make-host.sh @@ -0,0 +1,40 @@ +#!/usr/bin/bash +source $(dirname "$0")/../common.sh + +PKGNAME=gawk +PKGVERSION=5.3.1 +PKGSOURCE_DIR=gawk +PKGSOURCE=gawk-5.3.1.tar.xz +PKGURL=http://mirrors.ustc.edu.cn/gnu/gawk/gawk-5.3.1.tar.xz + +PKGBUILDNAME=host-${PKGNAME} +PKGBUILD_DIR=${BUILD_DIR}/${PKGBUILDNAME}-${PKGVERSION} + +echo "----> Building ${PKGBUILDNAME} ..." + +stamp_downloaded + +step_start extract +mkdir -p ${PKGBUILD_DIR} +xzcat ${DL_DIR}/${PKGSOURCE_DIR}/${PKGSOURCE} | tar --strip-components=1 -C ${PKGBUILD_DIR} -xf - +chmod -R +rw ${PKGBUILD_DIR} +step_end extract + +stamp_patched autotools + +step_start configure +(cd ${PKGBUILD_DIR} && rm -rf config.cache; eval "${HOST_CONFIGURE_OPTS} CONFIG_SITE=/dev/null ./configure --prefix=\"${HOST_DIR}\" --sysconfdir=\"${HOST_DIR}/etc\" --localstatedir=\"${HOST_DIR}/var\" --enable-shared --disable-static --disable-gtk-doc --disable-gtk-doc-html --disable-doc --disable-docs --disable-documentation --disable-debug --with-xmlto=no --with-fop=no --disable-nls --disable-dependency-tracking --without-readline --without-mpfr") +step_end configure + +step_start build +eval "${HOST_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} -C ${PKGBUILD_DIR}" +step_end build + +step_start install-host +eval "${HOST_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} install -C ${PKGBUILD_DIR}" +ln -sf gawk ${HOST_DIR}/bin/awk +step_end install-host + +stamp_installed + +echo "<---- ${PKGBUILDNAME} build complete." diff --git a/package/gcc/14.3.0/0001-disable-split-stack-for-non-thread-builds.patch b/package/gcc/14.3.0/0001-disable-split-stack-for-non-thread-builds.patch new file mode 100644 index 0000000..e801085 --- /dev/null +++ b/package/gcc/14.3.0/0001-disable-split-stack-for-non-thread-builds.patch @@ -0,0 +1,26 @@ +From 4f67134e0b1404fef4ea72342be8fab4c37ca8c8 Mon Sep 17 00:00:00 2001 +From: Waldemar Brodkorb +Date: Mon, 25 Jul 2022 00:29:55 +0200 +Subject: [PATCH] disable split-stack for non-thread builds + +Signed-off-by: Waldemar Brodkorb +[Romain: convert to git format] +Signed-off-by: Romain Naour +--- + libgcc/config/t-stack | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/libgcc/config/t-stack b/libgcc/config/t-stack +index cc0366b4cd8..f3f97e86d60 100644 +--- a/libgcc/config/t-stack ++++ b/libgcc/config/t-stack +@@ -1,4 +1,6 @@ + # Makefile fragment to provide generic support for -fsplit-stack. + # This should be used in config.host for any host which supports + # -fsplit-stack. ++ifeq ($(enable_threads),yes) + LIB2ADD_ST += $(srcdir)/generic-morestack.c $(srcdir)/generic-morestack-thread.c ++endif +-- +2.34.3 + diff --git a/package/gcc/14.3.0/0002-libsanitizer-also-undef-_TIME_BITS-in-sanitizer_proc.patch b/package/gcc/14.3.0/0002-libsanitizer-also-undef-_TIME_BITS-in-sanitizer_proc.patch new file mode 100644 index 0000000..b9dfcd0 --- /dev/null +++ b/package/gcc/14.3.0/0002-libsanitizer-also-undef-_TIME_BITS-in-sanitizer_proc.patch @@ -0,0 +1,53 @@ +From 71de45698f60f8feabc0e91336f1e2fb387902df Mon Sep 17 00:00:00 2001 +From: Thomas Petazzoni +Date: Thu, 18 Jul 2024 23:13:41 +0200 +Subject: [PATCH] libsanitizer: also undef _TIME_BITS in + sanitizer_procmaps_solaris.cpp + +Upstream commit +https://github.com/llvm/llvm-project/commit/26800a2c7e7996dc773b4e990dd5cca41c45e1a9 +of LLVM added a #undef _TIME_BITS in +libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp to +fix the build on 32-bit Linux platforms that have enabled 64-bit +time_t using _TIME_BITS=64. + +Indeed, _TIME_BITS=64 can only be used when _FILE_OFFSET_BITS=64, but +sanitizer_platform_limits_posix.cpp undefines _FILE_OFFSET_BITS before +including any header file. To fix this, the upstream fix was to also +undef _TIME_BITS. + +This commit simply does the same in sanitizer_procmaps_solaris.cpp, +which also gets compiled under Linux (despite what the file name +says). In practice on Linux hosts (where _TIME_BITS=64 matters), +sanitizer_procmaps_solaris.cpp will expand to nothing, as pretty much +the rest of the file is inside a #ifdef SANITIZER_SOLARIS...#endif. So +the #undef _FILE_OFFSET_BITS and #undef _TIME_BITS are only here +before including sanitizer_platform.h, which will set the +SANITIZER_LINUX/SANITIZER_SOLARIS define depending on the platform. + +Fixes: + +armeb-buildroot-linux-gnueabi/sysroot/usr/include/features-time64.h:26:5: error: #error "_TIME_BITS=64 is allowed only with _FILE_OFFSET_BITS=64" + 26 | # error "_TIME_BITS=64 is allowed only with _FILE_OFFSET_BITS=64" + +Upstream: https://gcc.gnu.org/pipermail/gcc-patches/2024-July/657811.html +Signed-off-by: Thomas Petazzoni +--- + libsanitizer/sanitizer_common/sanitizer_procmaps_solaris.cpp | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/libsanitizer/sanitizer_common/sanitizer_procmaps_solaris.cpp b/libsanitizer/sanitizer_common/sanitizer_procmaps_solaris.cpp +index eeb49e2afe3..1b23fd4d512 100644 +--- a/libsanitizer/sanitizer_common/sanitizer_procmaps_solaris.cpp ++++ b/libsanitizer/sanitizer_common/sanitizer_procmaps_solaris.cpp +@@ -11,6 +11,7 @@ + + // Before Solaris 11.4, doesn't work in a largefile environment. + #undef _FILE_OFFSET_BITS ++#undef _TIME_BITS + #include "sanitizer_platform.h" + #if SANITIZER_SOLARIS + # include +-- +2.45.2 + diff --git a/package/gcc/14.3.0/0003-microblaze-add-atomic-test-and-set-support.patch b/package/gcc/14.3.0/0003-microblaze-add-atomic-test-and-set-support.patch new file mode 100644 index 0000000..db6aefa --- /dev/null +++ b/package/gcc/14.3.0/0003-microblaze-add-atomic-test-and-set-support.patch @@ -0,0 +1,286 @@ +From cd01b277c4a9e03c83427290228e4b289a169431 Mon Sep 17 00:00:00 2001 +From: Gopi Kumar Bulusu +Date: Thu, 10 Jul 2025 12:44:44 +0530 +Subject: [PATCH] MicroBlaze : Enhance support for atomics. Fix PR118280 + +Atomic support enhanced to fix existing atomic_compare_and_swapsi pattern +to handle side effects; new patterns atomic_fetch_op and atomic_test_and_set +added. As MicroBlaze has no QImode test/set instruction, use shift magic +to implement atomic_test_and_set. This fixes PR118280. + +Files Changed + +* gcc/config/microblaze/iterators.md: New +* microblaze-protos.h/microblaze.cc : Add microblaze_subword_address +* gcc/config/microblaze/microblaze.md: constants: Add UNSPECV_CAS_BOOL, + UNSPECV_CAS_MEM, UNSPECV_CAS_VAL, UNSPECV_ATOMIC_FETCH_OP + type: add atomic +* gcc/config/microblaze/sync.md: Add atomic_fetch_si + atomic_test_and_set + +Fixes: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118280 +Upstream: https://patchwork.ozlabs.org/project/gcc/list/?series=466193 + +Signed-off-by: Kirk Meyer +Signed-off-by: David Holsgrove +Signed-off-by: Gopi Kumar Bulusu +--- + gcc/config/microblaze/iterators.md | 25 +++++ + gcc/config/microblaze/microblaze-protos.h | 1 + + gcc/config/microblaze/microblaze.cc | 28 ++++++ + gcc/config/microblaze/microblaze.h | 2 +- + gcc/config/microblaze/microblaze.md | 7 +- + gcc/config/microblaze/sync.md | 107 ++++++++++++++++++---- + 6 files changed, 150 insertions(+), 20 deletions(-) + create mode 100644 gcc/config/microblaze/iterators.md + +diff --git a/gcc/config/microblaze/iterators.md b/gcc/config/microblaze/iterators.md +new file mode 100644 +index 00000000000..2ffc2422a0a +--- /dev/null ++++ b/gcc/config/microblaze/iterators.md +@@ -0,0 +1,25 @@ ++;; Iterator definitions for GCC MicroBlaze machine description files. ++;; Copyright (C) 2012-2024 Free Software Foundation, Inc. ++;; ++;; This file is part of GCC. ++;; ++;; GCC is free software; you can redistribute it and/or modify ++;; it under the terms of the GNU General Public License as published by ++;; the Free Software Foundation; either version 3, or (at your option) ++;; any later version. ++;; ++;; GCC is distributed in the hope that it will be useful, ++;; but WITHOUT ANY WARRANTY; without even the implied warranty of ++;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++;; GNU General Public License for more details. ++;; ++;; You should have received a copy of the GNU General Public License ++;; along with GCC; see the file COPYING3. If not see ++;; . ++ ++; atomics code iterator ++(define_code_iterator any_atomic [plus ior xor and]) ++ ++; atomics code attribute ++(define_code_attr atomic_optab ++ [(plus "add") (ior "or") (xor "xor") (and "and")]) +diff --git a/gcc/config/microblaze/microblaze-protos.h b/gcc/config/microblaze/microblaze-protos.h +index 90b79cfe716..1cee0b3096c 100644 +--- a/gcc/config/microblaze/microblaze-protos.h ++++ b/gcc/config/microblaze/microblaze-protos.h +@@ -62,6 +62,7 @@ extern int symbol_mentioned_p (rtx); + extern int label_mentioned_p (rtx); + extern bool microblaze_cannot_force_const_mem (machine_mode, rtx); + extern void microblaze_eh_return (rtx op0); ++extern void microblaze_subword_address (rtx, rtx *, rtx *); + #endif /* RTX_CODE */ + + /* Declare functions in microblaze-c.cc. */ +diff --git a/gcc/config/microblaze/microblaze.cc b/gcc/config/microblaze/microblaze.cc +index 2ab5ada4ec9..80d10ab60e0 100644 +--- a/gcc/config/microblaze/microblaze.cc ++++ b/gcc/config/microblaze/microblaze.cc +@@ -1299,6 +1299,34 @@ microblaze_expand_block_move (rtx dest, rtx src, rtx length, rtx align_rtx) + return false; + } + ++/* Compute memory address *aligned_mem and corresponding shift value (*shift) ++ from a QImode memory reference MEM */ ++void ++microblaze_subword_address (rtx mem, rtx *aligned_mem, rtx *shift) ++{ ++ /* Align the memory address to a word. */ ++ rtx addr = force_reg (Pmode, XEXP (mem, 0)); ++ ++ rtx addr_mask = gen_int_mode (-4, Pmode); ++ ++ rtx aligned_addr = gen_reg_rtx (Pmode); ++ ++ emit_move_insn (aligned_addr, gen_rtx_AND (Pmode, addr, addr_mask)); ++ ++ *aligned_mem = change_address (mem, SImode, aligned_addr); ++ ++ /* Calculate the shift amount. */ ++ emit_move_insn (*shift, gen_rtx_AND (SImode, addr, gen_int_mode (3, SImode))); ++ ++ if (TARGET_LITTLE_ENDIAN == 0) { ++ emit_move_insn (*shift, ++ gen_rtx_MINUS (SImode, gen_int_mode (3, SImode), *shift)); ++ } ++ ++ emit_move_insn (*shift, gen_rtx_ASHIFT (SImode, *shift, ++ gen_int_mode (3, SImode))); ++} ++ + static bool + microblaze_rtx_costs (rtx x, machine_mode mode, int outer_code ATTRIBUTE_UNUSED, + int opno ATTRIBUTE_UNUSED, int *total, +diff --git a/gcc/config/microblaze/microblaze.h b/gcc/config/microblaze/microblaze.h +index 2390542434b..b2e9ccde363 100644 +--- a/gcc/config/microblaze/microblaze.h ++++ b/gcc/config/microblaze/microblaze.h +@@ -57,7 +57,7 @@ extern enum pipeline_type microblaze_pipe; + + /* Default target_flags if no switches are specified */ + #define TARGET_DEFAULT (MASK_SOFT_MUL | MASK_SOFT_DIV | MASK_SOFT_FLOAT \ +- | TARGET_ENDIAN_DEFAULT) ++ | TARGET_ENDIAN_DEFAULT) + + /* Do we have CLZ? */ + #define TARGET_HAS_CLZ (TARGET_PATTERN_COMPARE && microblaze_has_clz) +diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md +index 45c48a71e8d..270df8da0c5 100644 +--- a/gcc/config/microblaze/microblaze.md ++++ b/gcc/config/microblaze/microblaze.md +@@ -21,6 +21,7 @@ + + (include "constraints.md") + (include "predicates.md") ++(include "iterators.md") + + ;;---------------------------------------------------- + ;; Constants +@@ -43,6 +44,10 @@ + (UNSPEC_TLS 106) ;; jump table + (UNSPEC_SET_TEXT 107) ;; set text start + (UNSPEC_TEXT 108) ;; data text relative ++ (UNSPECV_CAS_BOOL 201) ;; compare and swap (bool) ++ (UNSPECV_CAS_VAL 202) ;; compare and swap (val) ++ (UNSPECV_CAS_MEM 203) ;; compare and swap (mem) ++ (UNSPECV_ATOMIC_FETCH_OP 204) ;; atomic fetch op + ]) + + (define_c_enum "unspec" [ +@@ -79,7 +84,7 @@ + ;; bshift Shift operations + + (define_attr "type" +- "unknown,branch,jump,call,load,store,move,arith,darith,imul,idiv,icmp,multi,nop,no_delay_arith,no_delay_load,no_delay_store,no_delay_imul,no_delay_move,bshift,fadd,frsub,fmul,fdiv,fcmp,fsl,fsqrt,fcvt,trap" ++ "unknown,branch,jump,call,load,store,move,arith,darith,imul,idiv,icmp,multi,nop,no_delay_arith,no_delay_load,no_delay_store,no_delay_imul,no_delay_move,bshift,fadd,frsub,fmul,fdiv,fcmp,fsl,fsqrt,fcvt,trap,atomic" + (const_string "unknown")) + + ;; Main data type used by the insn +diff --git a/gcc/config/microblaze/sync.md b/gcc/config/microblaze/sync.md +index db7b11e5379..6478ab6dcac 100644 +--- a/gcc/config/microblaze/sync.md ++++ b/gcc/config/microblaze/sync.md +@@ -18,26 +18,97 @@ + ;; . + + (define_insn "atomic_compare_and_swapsi" +- [(match_operand:SI 0 "register_operand" "=&d") ;; bool output +- (match_operand:SI 1 "register_operand" "=&d") ;; val output +- (match_operand:SI 2 "nonimmediate_operand" "+Q") ;; memory +- (match_operand:SI 3 "register_operand" "d") ;; expected value +- (match_operand:SI 4 "register_operand" "d") ;; desired value +- (match_operand:SI 5 "const_int_operand" "") ;; is_weak +- (match_operand:SI 6 "const_int_operand" "") ;; mod_s +- (match_operand:SI 7 "const_int_operand" "") ;; mod_f ++ [(set (match_operand:SI 0 "register_operand" "=&d") ;; bool output ++ (unspec_volatile:SI ++ [(match_operand:SI 2 "nonimmediate_operand" "+Q") ;; memory ++ (match_operand:SI 3 "register_operand" "d") ;; expected value ++ (match_operand:SI 4 "register_operand" "d")] ;; desired value ++ UNSPECV_CAS_BOOL)) ++ (set (match_operand:SI 1 "register_operand" "=&d") ;; val output ++ (unspec_volatile:SI [(const_int 0)] UNSPECV_CAS_VAL)) ++ (set (match_dup 2) ++ (unspec_volatile:SI [(const_int 0)] UNSPECV_CAS_MEM)) ++ (match_operand:SI 5 "const_int_operand" "") ;; is_weak ++ (match_operand:SI 6 "const_int_operand" "") ;; mod_s ++ (match_operand:SI 7 "const_int_operand" "") ;; mod_f + (clobber (match_scratch:SI 8 "=&d"))] + "" + { +- output_asm_insn ("addc \tr0,r0,r0", operands); +- output_asm_insn ("lwx \t%1,%y2,r0", operands); +- output_asm_insn ("addic\t%8,r0,0", operands); +- output_asm_insn ("bnei \t%8,.-8", operands); +- output_asm_insn ("cmp \t%0,%1,%3", operands); +- output_asm_insn ("bnei \t%0,.+16", operands); +- output_asm_insn ("swx \t%4,%y2,r0", operands); +- output_asm_insn ("addic\t%8,r0,0", operands); +- output_asm_insn ("bnei \t%8,.-28", operands); +- return ""; ++ return "add \t%0,r0,r0\n\t" ++ "lwx \t%1,%y2,r0\n\t" ++ "addic\t%8,r0,0\n\t" ++ "bnei \t%8,.-8\n\t" ++ "cmp \t%8,%1,%3\n\t" ++ "bnei \t%8,.+20\n\t" ++ "swx \t%4,%y2,r0\n\t" ++ "addic\t%8,r0,0\n\t" ++ "bnei \t%8,.-28\n\t" ++ "addi \t%0,r0,1"; + } ++ [(set_attr "type" "atomic") ++ (set_attr "mode" "SI") ++ (set_attr "length" "40")] + ) ++ ++;; ++;; ++;; ++;; ++(define_insn "atomic_fetch_si" ++ [(set (match_operand:SI 0 "register_operand" "=&d") ++ (match_operand:SI 1 "memory_operand" "+Q")) ++ (set (match_dup 1) ++ (unspec_volatile:SI ++ [(any_atomic:SI (match_dup 1) ++ (match_operand:SI 2 "register_operand" "d")) ++ (match_operand:SI 3 "const_int_operand")] ;; model ++ UNSPECV_ATOMIC_FETCH_OP)) ++ (clobber (match_scratch:SI 4 "=&d"))] ;; tmp_1 ++ "" ++ { ++ return ++ "lwx \t%0,%y1,r0\n\t" ++ "addic\t%4,r0,0\n\t" ++ "bnei \t%4,.-8\n\t" ++ "\t%4,%0,%2\n\t" ++ "swx \t%4,%y1,r0\n\t" ++ "addic\t%4,r0,0\n\t" ++ "bnei \t%4,.-24"; ++ } ++ [(set_attr "type" "atomic") ++ (set_attr "mode" "SI") ++ (set_attr "length" "28")]) ++ ++;; ++;; MicroBlaze only supports lx/sx instructions for word mode only ++;; ++;; Use shift|mask magic to implement atomic_test_and_set using lwx/swx ++;; ++(define_expand "atomic_test_and_set" ++ [(match_operand:QI 0 "register_operand" "") ;; bool output ++ (match_operand:QI 1 "memory_operand" "m") ;; memory ++ (match_operand:SI 2 "const_int_operand" "")] ;; model ++ "" ++{ ++ rtx old = gen_reg_rtx (SImode); ++ rtx mem = operands[1]; ++ rtx model = operands[2]; ++ rtx set = gen_reg_rtx (SImode); ++ rtx aligned_mem = gen_reg_rtx (SImode); ++ rtx shift = gen_reg_rtx (SImode); ++ ++ microblaze_subword_address (mem, &aligned_mem, &shift); ++ ++ emit_move_insn (set, GEN_INT (1)); ++ rtx shifted_set = gen_reg_rtx (SImode); ++ ++ emit_move_insn (shifted_set, gen_rtx_ASHIFT (SImode, set, shift)); ++ ++ emit_insn (gen_atomic_fetch_orsi (old, aligned_mem, shifted_set, model)); ++ ++ emit_move_insn (old, gen_rtx_ASHIFTRT (SImode, old, shift)); ++ ++ emit_move_insn (operands[0], gen_lowpart (QImode, old)); ++ ++ DONE; ++}) +-- +2.43.5 + diff --git a/package/gcc/make-final.sh b/package/gcc/make-final.sh new file mode 100755 index 0000000..951981b --- /dev/null +++ b/package/gcc/make-final.sh @@ -0,0 +1,41 @@ +#!/usr/bin/bash +source $(dirname "$0")/../common.sh + +PKGNAME=gcc +PKGVERSION=14.3.0 +PKGSOURCE_DIR=gcc +PKGSOURCE=gcc-14.3.0.tar.xz +PKGURL=http://mirrors.ustc.edu.cn/gnu/gcc/gcc-14.3.0/gcc-14.3.0.tar.xz + +PKGBUILDNAME=${PKGNAME}-final +PKGBUILD_DIR=${BUILD_DIR}/${PKGBUILDNAME}-${PKGVERSION} + +echo "----> Building ${PKGBUILDNAME} ..." + +stamp_downloaded + +step_start extract +mkdir -p ${PKGBUILD_DIR} +chmod -R +rw ${PKGBUILD_DIR} +step_end extract + +stamp_patched + +stamp_configured + +stamp_built + +step_start install-staging +cp -dpf ${HOST_DIR}/${GNU_TARGET_NAME}/lib*/libatomic* ${STAGING_DIR}/lib/ +cp -dpf ${HOST_DIR}/${GNU_TARGET_NAME}/lib*/libgcc_s* ${STAGING_DIR}/lib/ +step_end install-staging + +step_start install-target +mkdir -p ${TARGET_DIR}/lib ${TARGET_DIR}/usr/lib +cp -dpf ${HOST_DIR}/${GNU_TARGET_NAME}/lib*/libatomic.so* ${TARGET_DIR}/lib/ +cp -dpf ${HOST_DIR}/${GNU_TARGET_NAME}/lib*/libgcc_s.so* ${TARGET_DIR}/lib/ +step_end install-target + +stamp_installed + +echo "<---- ${PKGBUILDNAME} build complete." diff --git a/package/gcc/make-host-final.sh b/package/gcc/make-host-final.sh new file mode 100755 index 0000000..91c67dd --- /dev/null +++ b/package/gcc/make-host-final.sh @@ -0,0 +1,68 @@ +#!/usr/bin/bash +source $(dirname "$0")/../common.sh + +PKGNAME=gcc +PKGVERSION=14.3.0 +PKGSOURCE_DIR=gcc +PKGSOURCE=gcc-14.3.0.tar.xz +PKGURL=http://mirrors.ustc.edu.cn/gnu/gcc/gcc-14.3.0/gcc-14.3.0.tar.xz + +PKGBUILDNAME=host-${PKGNAME}-final +PKGBUILD_DIR=${BUILD_DIR}/${PKGBUILDNAME}-${PKGVERSION} + +echo "----> Building ${PKGBUILDNAME} ..." + +stamp_downloaded + +step_start extract +mkdir -p ${PKGBUILD_DIR} +xzcat ${DL_DIR}/${PKGSOURCE_DIR}/${PKGSOURCE} | tar --strip-components=1 -C ${PKGBUILD_DIR} --exclude='libjava/*' --exclude='libgo/*' -xf - +chmod -R +rw ${PKGBUILD_DIR} +step_end extract + +step_start patch +TAR="tar" PATH=${HOST_DIR}/bin:$PATH ${PROJECT_DIR}/support/scripts/apply-patches.sh ${PKGBUILD_DIR} ${PROJECT_DIR}/package/${PKGNAME}/14.3.0 \*.patch || exit 1 +step_end patch autotools + +step_start configure +mkdir -p ${PKGBUILD_DIR}/build +ln -sf ../configure ${PKGBUILD_DIR}/build/configure +(cd ${PKGBUILD_DIR}/build && rm -rf config.cache; eval "${HOST_CONFIGURE_OPTS} CFLAGS=\"-O2 -I${HOST_DIR}/include\" LDFLAGS=\"-L${HOST_DIR}/lib -Wl,-rpath,${HOST_DIR}/lib\" MAKEINFO=missing CFLAGS_FOR_TARGET=\"-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g0 -D_FORTIFY_SOURCE=1 \" CXXFLAGS_FOR_TARGET=\"-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g0 -D_FORTIFY_SOURCE=1 \" LDFLAGS_FOR_TARGET=\" \" AR_FOR_TARGET=gcc-ar NM_FOR_TARGET=gcc-nm RANLIB_FOR_TARGET=gcc-ranlib ./configure --prefix=\"${HOST_DIR}\" --sysconfdir=\"${HOST_DIR}/etc\" --enable-static --target=${GNU_TARGET_NAME} --with-sysroot=${STAGING_DIR} --enable-__cxa_atexit --with-gnu-ld --disable-libssp --disable-multilib --disable-decimal-float --enable-plugins --enable-lto --with-gmp=${HOST_DIR} --with-mpc=${HOST_DIR} --with-mpfr=${HOST_DIR} --without-zstd --disable-libquadmath --disable-libquadmath-support --enable-tls --enable-threads --without-isl --without-cloog --with-arch=\"rv64imafd_zicsr_zifencei\" --with-abi=\"lp64d\" --enable-languages=c --with-build-time-tools=${HOST_DIR}/${GNU_TARGET_NAME}/bin --enable-shared --disable-libgomp") +step_end configure + +step_start build +eval "${HOST_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} gcc_cv_prog_makeinfo_modern=no gcc_cv_libc_provides_ssp=yes -C ${PKGBUILD_DIR}/build" +/usr/bin/gcc -O2 -I${HOST_DIR}/include -DBR_CROSS_PATH_SUFFIX='".br_real"' -DBR_SYSROOT="\"${STAGING_SUBDIR}\"" -DBR_ADDITIONAL_CFLAGS='"-fstack-protector-strong",' -DBR2_PIC_PIE -DBR2_RELRO_FULL -s -Wl,--hash-style=both ${PROJECT_DIR}/package/${PKGNAME}/toolchain-wrapper.c -o ${PKGBUILD_DIR}/toolchain-wrapper +step_end build + +step_start install-host +eval "${HOST_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} install -C ${PKGBUILD_DIR}/build" +if [ ! -e ${HOST_DIR}/bin/${GNU_TARGET_NAME}-cc ]; then + ln -f ${HOST_DIR}/bin/${GNU_TARGET_NAME}-gcc ${HOST_DIR}/bin/${GNU_TARGET_NAME}-cc; +fi +/usr/bin/install -D -m 0755 ${PKGBUILD_DIR}/toolchain-wrapper ${HOST_DIR}/bin/toolchain-wrapper +cd ${HOST_DIR}/bin; +for i in ${GNU_TARGET_NAME}-*; do + case "$i" in + *.br_real) + ;; + *-ar|*-ranlib|*-nm) + ln -snf $i ${ARCH}-linux${i##${GNU_TARGET_NAME}}; + ;; + *cc|*cc-*|*++|*++-*|*cpp|*-gfortran|*-gdc) + rm -f $i.br_real; + mv $i $i.br_real; + ln -sf toolchain-wrapper $i; + ln -sf toolchain-wrapper ${ARCH}-linux${i##${GNU_TARGET_NAME}}; + ln -snf $i.br_real ${ARCH}-linux${i##${GNU_TARGET_NAME}}.br_real; + ;; + *) + ln -snf $i ${ARCH}-linux${i##${GNU_TARGET_NAME}}; + ;; + esac; +done +step_end install-host + +stamp_installed + +echo "<---- ${PKGBUILDNAME} build complete." diff --git a/package/gcc/make-host-initial.sh b/package/gcc/make-host-initial.sh new file mode 100755 index 0000000..481e9a3 --- /dev/null +++ b/package/gcc/make-host-initial.sh @@ -0,0 +1,65 @@ +#!/usr/bin/bash +source $(dirname "$0")/../common.sh + +PKGNAME=gcc +PKGVERSION=14.3.0 +PKGSOURCE_DIR=gcc +PKGSOURCE=gcc-14.3.0.tar.xz +PKGURL=http://mirrors.ustc.edu.cn/gnu/gcc/gcc-14.3.0/gcc-14.3.0.tar.xz + +PKGBUILDNAME=host-${PKGNAME}-initial +PKGBUILD_DIR=${BUILD_DIR}/${PKGBUILDNAME}-${PKGVERSION} + +echo "----> Building ${PKGBUILDNAME} ..." + +stamp_downloaded + +step_start extract +mkdir -p ${PKGBUILD_DIR} +xzcat ${DL_DIR}/${PKGSOURCE_DIR}/${PKGSOURCE} | tar --strip-components=1 -C ${PKGBUILD_DIR} --exclude='libjava/*' --exclude='libgo/*' -xf - +chmod -R +rw ${PKGBUILD_DIR} +step_end extract + +step_start patch +TAR="tar" PATH=${HOST_DIR}/bin:$PATH ${PROJECT_DIR}/support/scripts/apply-patches.sh ${PKGBUILD_DIR} ${PROJECT_DIR}/package/${PKGNAME}/14.3.0 \*.patch || exit 1 +step_end patch autotools + +step_start configure +mkdir -p ${PKGBUILD_DIR}/build +ln -sf ../configure ${PKGBUILD_DIR}/build/configure +(cd ${PKGBUILD_DIR}/build && rm -rf config.cache; eval "${HOST_CONFIGURE_OPTS} MAKEINFO=missing CFLAGS_FOR_TARGET=\"-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g0 -D_FORTIFY_SOURCE=1 \" CXXFLAGS_FOR_TARGET=\"-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g0 -D_FORTIFY_SOURCE=1 \" LDFLAGS_FOR_TARGET=\" \" AR_FOR_TARGET=gcc-ar NM_FOR_TARGET=gcc-nm RANLIB_FOR_TARGET=gcc-ranlib CONFIG_SITE=/dev/null ./configure --prefix=\"${HOST_DIR}\" --sysconfdir=\"${HOST_DIR}/etc\" --localstatedir=\"${HOST_DIR}/var\" --enable-shared --disable-static --disable-gtk-doc --disable-gtk-doc-html --disable-doc --disable-docs --disable-documentation --disable-debug --with-xmlto=no --with-fop=no --disable-nls --disable-dependency-tracking --target=${GNU_TARGET_NAME} --with-sysroot=${STAGING_DIR} --enable-__cxa_atexit --with-gnu-ld --disable-libssp --disable-multilib --disable-decimal-float --enable-plugins --enable-lto --with-gmp=${HOST_DIR} --with-mpc=${HOST_DIR} --with-mpfr=${HOST_DIR} --without-zstd --disable-libquadmath --disable-libquadmath-support --enable-tls --enable-threads --without-isl --without-cloog --with-arch=\"rv64imafd_zicsr_zifencei\" --with-abi=\"lp64d\" --enable-languages=c --disable-shared --without-headers --disable-threads --with-newlib --disable-largefile") +step_end configure + +step_start build +eval "${HOST_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} gcc_cv_prog_makeinfo_modern=no gcc_cv_libc_provides_ssp=yes all-gcc all-target-libgcc -C ${PKGBUILD_DIR}/build" +/usr/bin/gcc -O2 -I${HOST_DIR}/include -DBR_CROSS_PATH_SUFFIX='".br_real"' -DBR_SYSROOT="\"${STAGING_SUBDIR}\"" -DBR_ADDITIONAL_CFLAGS='"-fstack-protector-strong",' -DBR2_PIC_PIE -DBR2_RELRO_FULL -s -Wl,--hash-style=both ${PROJECT_DIR}/package/${PKGNAME}/toolchain-wrapper.c -o ${PKGBUILD_DIR}/toolchain-wrapper +step_end build + +step_start install-host +eval "${HOST_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} install-gcc install-target-libgcc -C ${PKGBUILD_DIR}/build" +/usr/bin/install -D -m 0755 ${PKGBUILD_DIR}/toolchain-wrapper ${HOST_DIR}/bin/toolchain-wrapper +cd ${HOST_DIR}/bin; +for i in ${GNU_TARGET_NAME}-*; do + case "$i" in + *.br_real) + ;; + *-ar|*-ranlib|*-nm) + ln -snf $i ${ARCH}-linux${i##${GNU_TARGET_NAME}}; + ;; + *cc|*cc-*|*++|*++-*|*cpp|*-gfortran|*-gdc) + rm -f $i.br_real; + mv $i $i.br_real; + ln -sf toolchain-wrapper $i; + ln -sf toolchain-wrapper ${ARCH}-linux${i##${GNU_TARGET_NAME}}; + ln -snf $i.br_real ${ARCH}-linux${i##${GNU_TARGET_NAME}}.br_real; + ;; + *) + ln -snf $i ${ARCH}-linux${i##${GNU_TARGET_NAME}}; + ;; + esac; +done +step_end install-host + +stamp_installed + +echo "<---- ${PKGBUILDNAME} build complete." diff --git a/package/gcc/toolchain-wrapper.c b/package/gcc/toolchain-wrapper.c new file mode 100644 index 0000000..5b30619 --- /dev/null +++ b/package/gcc/toolchain-wrapper.c @@ -0,0 +1,554 @@ +/** + * Buildroot wrapper for toolchains. This simply executes the real toolchain + * with a number of arguments (sysroot/arch/..) hardcoded, to ensure the + * toolchain uses the correct configuration. + * The hardcoded path arguments are defined relative to the actual location + * of the binary. + * + * (C) 2011 Peter Korsgaard + * (C) 2011 Daniel Nyström + * (C) 2012 Arnout Vandecappelle (Essensium/Mind) + * (C) 2013 Spenser Gilliland + * + * This file is licensed under the terms of the GNU General Public License + * version 2. This program is licensed "as is" without any warranty of any + * kind, whether express or implied. + */ + +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef BR_CCACHE +static char ccache_path[PATH_MAX]; +#endif +static char path[PATH_MAX]; +static char sysroot[PATH_MAX]; +/* As would be defined by gcc: + * https://gcc.gnu.org/onlinedocs/cpp/Standard-Predefined-Macros.html + * sizeof() on string literals includes the terminating \0. */ +static char _time_[sizeof("-D__TIME__=\"HH:MM:SS\"")]; +static char _date_[sizeof("-D__DATE__=\"MMM DD YYYY\"")]; + +/* Maximum amount of arguments to reserve space for by default. + Must be > predef_args */ +#define DEFAULT_MAX_ARGS 1024 + +static char *predef_args[] = { +#ifdef BR_CCACHE + ccache_path, +#endif + path, + "--sysroot", sysroot, +#ifdef BR_CLANG_CONFIG_FILE + BR_CLANG_CONFIG_FILE, +#endif +#ifdef BR_ABI + "-mabi=" BR_ABI, +#endif +#ifdef BR_NAN + "-mnan=" BR_NAN, +#endif +#ifdef BR_FPU + "-mfpu=" BR_FPU, +#endif +#ifdef BR_SOFTFLOAT + "-msoft-float", +#endif /* BR_SOFTFLOAT */ +#ifdef BR_SIMD + "-msimd=" BR_SIMD, +#endif +#ifdef BR_MODE + "-m" BR_MODE, +#endif +#ifdef BR_64 + "-m64", +#endif +#ifdef BR_OMIT_LOCK_PREFIX + "-Wa,-momit-lock-prefix=yes", +#endif +#ifdef BR_NO_FUSED_MADD + "-mno-fused-madd", +#endif +#ifdef BR_FP_CONTRACT_OFF + "-ffp-contract=off", +#endif +#ifdef BR_BINFMT_FLAT + "-Wl,-elf2flt", +#endif +#ifdef BR_MIPS_TARGET_LITTLE_ENDIAN + "-EL", +#endif +#if defined(BR_MIPS_TARGET_BIG_ENDIAN) || defined(BR_ARC_TARGET_BIG_ENDIAN) + "-EB", +#endif +#ifdef BR_ADDITIONAL_CFLAGS + BR_ADDITIONAL_CFLAGS +#endif +}; + +/* A {string,length} tuple, to avoid computing strlen() on constants. + * - str must be a \0-terminated string + * - len does not account for the terminating '\0' + */ +struct str_len_s { + const char *str; + size_t len; +}; + +/* Define a {string,length} tuple. Takes an unquoted constant string as + * parameter. sizeof() on a string literal includes the terminating \0, + * but we don't want to count it. + */ +#define STR_LEN(s) { #s, sizeof(#s)-1 } + +/* List of paths considered unsafe for cross-compilation. + * + * An unsafe path is one that points to a directory with libraries or + * headers for the build machine, which are not suitable for the target. + */ +static const struct str_len_s unsafe_paths[] = { + STR_LEN(/lib), + STR_LEN(/usr/include), + STR_LEN(/usr/lib), + STR_LEN(/usr/local/include), + STR_LEN(/usr/local/lib), + STR_LEN(/usr/X11R6/include), + STR_LEN(/usr/X11R6/lib), + { NULL, 0 }, +}; + +/* Unsafe options are options that specify a potentially unsafe path, + * that will be checked by check_unsafe_path(), below. + */ +static const struct str_len_s unsafe_opts[] = { + STR_LEN(-I), + STR_LEN(-idirafter), + STR_LEN(-iquote), + STR_LEN(-isystem), + STR_LEN(-L), + { NULL, 0 }, +}; + +/* Check if path is unsafe for cross-compilation. Unsafe paths are those + * pointing to the standard native include or library paths. + * + * We print the arguments leading to the failure. For some options, gcc + * accepts the path to be concatenated to the argument (e.g. -I/foo/bar) + * or separated (e.g. -I /foo/bar). In the first case, we need only print + * the argument as it already contains the path (arg_has_path), while in + * the second case we need to print both (!arg_has_path). + */ +static void check_unsafe_path(const char *arg, + const char *path, + int arg_has_path) +{ + const struct str_len_s *p; + + for (p=unsafe_paths; p->str; p++) { + if (strncmp(path, p->str, p->len)) + continue; + fprintf(stderr, + "%s: ERROR: unsafe header/library path used in cross-compilation: '%s%s%s'\n", + program_invocation_short_name, + arg, + arg_has_path ? "" : "' '", /* close single-quote, space, open single-quote */ + arg_has_path ? "" : path); /* so that arg and path are properly quoted. */ + exit(1); + } +} + +#ifdef BR_NEED_SOURCE_DATE_EPOCH +/* Returns false if SOURCE_DATE_EPOCH was not defined in the environment. + * + * Returns true if SOURCE_DATE_EPOCH is in the environment and represent + * a valid timestamp, in which case the timestamp is formatted into the + * global variables _date_ and _time_. + * + * Aborts if SOURCE_DATE_EPOCH was set in the environment but did not + * contain a valid timestamp. + * + * Valid values are defined in the spec: + * https://reproducible-builds.org/specs/source-date-epoch/ + * but we further restrict them to be positive or null. + */ +bool parse_source_date_epoch_from_env(void) +{ + char *epoch_env, *endptr; + time_t epoch; + struct tm epoch_tm; + + if ((epoch_env = getenv("SOURCE_DATE_EPOCH")) == NULL) + return false; + errno = 0; + epoch = (time_t) strtoll(epoch_env, &endptr, 10); + /* We just need to test if it is incorrect, but we do not + * care why it is incorrect. + */ + if ((errno != 0) || !*epoch_env || *endptr || (epoch < 0)) { + fprintf(stderr, "%s: invalid SOURCE_DATE_EPOCH='%s'\n", + program_invocation_short_name, + epoch_env); + exit(1); + } + tzset(); /* For localtime_r(), below. */ + if (localtime_r(&epoch, &epoch_tm) == NULL) { + fprintf(stderr, "%s: cannot parse SOURCE_DATE_EPOCH=%s\n", + program_invocation_short_name, + getenv("SOURCE_DATE_EPOCH")); + exit(1); + } + if (!strftime(_time_, sizeof(_time_), "-D__TIME__=\"%T\"", &epoch_tm)) { + fprintf(stderr, "%s: cannot set time from SOURCE_DATE_EPOCH=%s\n", + program_invocation_short_name, + getenv("SOURCE_DATE_EPOCH")); + exit(1); + } + if (!strftime(_date_, sizeof(_date_), "-D__DATE__=\"%b %e %Y\"", &epoch_tm)) { + fprintf(stderr, "%s: cannot set date from SOURCE_DATE_EPOCH=%s\n", + program_invocation_short_name, + getenv("SOURCE_DATE_EPOCH")); + exit(1); + } + return true; +} +#else +bool parse_source_date_epoch_from_env(void) +{ + /* The compiler is recent enough to handle SOURCE_DATE_EPOCH itself + * so we do not need to do anything here. + */ + return false; +} +#endif + +int main(int argc, char **argv) +{ + char **args, **cur, **exec_args; + char *relbasedir, *absbasedir; + char *progpath = argv[0]; + char *basename; + char *env_debug; + int ret, i, count = 0, debug = 0, found_shared = 0, found_nonoption = 0; + size_t n_args; + + /* Debug the wrapper to see arguments it was called with. + * If environment variable BR2_DEBUG_WRAPPER is: + * unset, empty, or 0: do not trace + * set to 1 : trace all arguments on a single line + * set to 2 : trace one argument per line + */ + if ((env_debug = getenv("BR2_DEBUG_WRAPPER"))) { + debug = atoi(env_debug); + } + if (debug > 0) { + fprintf(stderr, "Toolchain wrapper was called with:"); + for (i = 0; i < argc; i++) + fprintf(stderr, "%s'%s'", + (debug == 2) ? "\n " : " ", argv[i]); + fprintf(stderr, "\n"); + } + + /* Calculate the relative paths */ + basename = strrchr(progpath, '/'); + if (basename) { + *basename = '\0'; + basename++; + relbasedir = malloc(strlen(progpath) + 7); + if (relbasedir == NULL) { + perror(__FILE__ ": malloc"); + return 2; + } + sprintf(relbasedir, "%s/..", argv[0]); + absbasedir = realpath(relbasedir, NULL); + } else { + basename = progpath; + absbasedir = malloc(PATH_MAX + 1); + ret = readlink("/proc/self/exe", absbasedir, PATH_MAX); + if (ret < 0) { + perror(__FILE__ ": readlink"); + return 2; + } + absbasedir[ret] = '\0'; + for (i = ret; i > 0; i--) { + if (absbasedir[i] == '/') { + absbasedir[i] = '\0'; + if (++count == 2) + break; + } + } + } + if (absbasedir == NULL) { + perror(__FILE__ ": realpath"); + return 2; + } + + /* Fill in the relative paths */ +#ifdef BR_CROSS_PATH_REL + ret = snprintf(path, sizeof(path), "%s/" BR_CROSS_PATH_REL "/%s" BR_CROSS_PATH_SUFFIX, absbasedir, basename); +#elif defined(BR_CROSS_PATH_ABS) + ret = snprintf(path, sizeof(path), BR_CROSS_PATH_ABS "/%s" BR_CROSS_PATH_SUFFIX, basename); +#else + ret = snprintf(path, sizeof(path), "%s/bin/%s" BR_CROSS_PATH_SUFFIX, absbasedir, basename); +#endif + if (ret >= sizeof(path)) { + perror(__FILE__ ": overflow"); + return 3; + } + + /* any non-option (E.G. source / object files) arguments passed? */ + for (i = 1; i < argc; i++) { + if (argv[i][0] != '-') { + found_nonoption = 1; + break; + } + } + + /* Check for unsafe library and header paths */ + for (i = 1; i < argc; i++) { + const struct str_len_s *opt; + for (opt=unsafe_opts; opt->str; opt++ ) { + /* Skip any non-unsafe option. */ + if (strncmp(argv[i], opt->str, opt->len)) + continue; + + /* Handle both cases: + * - path is a separate argument, + * - path is concatenated with option. + */ + if (argv[i][opt->len] == '\0') { + i++; + if (i == argc) + break; + check_unsafe_path(argv[i-1], argv[i], 0); + } else + check_unsafe_path(argv[i], argv[i] + opt->len, 1); + } + } + +#ifdef BR_CCACHE + ret = snprintf(ccache_path, sizeof(ccache_path), "%s/bin/ccache", absbasedir); + if (ret >= sizeof(ccache_path)) { + perror(__FILE__ ": overflow"); + return 3; + } +#endif + ret = snprintf(sysroot, sizeof(sysroot), "%s/" BR_SYSROOT, absbasedir); + if (ret >= sizeof(sysroot)) { + perror(__FILE__ ": overflow"); + return 3; + } + + cur = args = malloc(DEFAULT_MAX_ARGS * sizeof(char *)); + if (args == NULL) { + perror(__FILE__ ": malloc"); + return 2; + } + + /* start with predefined args */ + for (i = 0; i < sizeof(predef_args) / sizeof(predef_args[0]); i++) { + /* skip linker flags when we know we are not linking */ + if (found_nonoption || strncmp(predef_args[i], "-Wl,", strlen("-Wl,"))) + *cur++ = predef_args[i]; + } + +#ifdef BR_FLOAT_ABI + /* add float abi if not overridden in args */ + for (i = 1; i < argc; i++) { + if (!strncmp(argv[i], "-mfloat-abi=", strlen("-mfloat-abi=")) || + !strcmp(argv[i], "-msoft-float") || + !strcmp(argv[i], "-mhard-float")) + break; + } + + if (i == argc) + *cur++ = "-mfloat-abi=" BR_FLOAT_ABI; +#endif + +#ifdef BR_FP32_MODE + /* add fp32 mode if soft-float is not args or hard-float overrides soft-float */ + int add_fp32_mode = 1; + for (i = 1; i < argc; i++) { + if (!strcmp(argv[i], "-msoft-float")) + add_fp32_mode = 0; + else if (!strcmp(argv[i], "-mhard-float")) + add_fp32_mode = 1; + } + + if (add_fp32_mode == 1) + *cur++ = "-mfp" BR_FP32_MODE; +#endif + +#if defined(BR_ARCH) || \ + defined(BR_CPU) + /* Add our -march/cpu flags, but only if none of + * -march/mtune/mcpu are already specified on the commandline + */ + for (i = 1; i < argc; i++) { + if (!strncmp(argv[i], "-march=", strlen("-march=")) || + !strncmp(argv[i], "-mtune=", strlen("-mtune=")) || + !strncmp(argv[i], "-mcpu=", strlen("-mcpu=" ))) + break; + } + if (i == argc) { +#ifdef BR_ARCH + *cur++ = "-march=" BR_ARCH; +#endif +#ifdef BR_CPU + *cur++ = "-mcpu=" BR_CPU; +#endif + } +#endif /* ARCH || CPU */ + + if (parse_source_date_epoch_from_env()) { + *cur++ = _time_; + *cur++ = _date_; + /* This has existed since gcc-4.4.0. */ + *cur++ = "-Wno-builtin-macro-redefined"; + } + +#ifdef BR2_PIC_PIE + /* Patterned after Fedora/Gentoo hardening approaches. + * https://fedoraproject.org/wiki/Changes/Harden_All_Packages + * https://wiki.gentoo.org/wiki/Hardened/Toolchain#Position_Independent_Executables_.28PIEs.29 + * + * A few checks are added to allow disabling of PIE + * 1) -fno-pie and -no-pie are used by other distros to disable PIE in + * cases where the compiler enables it by default. The logic below + * maintains that behavior. + * Ref: https://wiki.ubuntu.com/SecurityTeam/PIE + * 2) A check for -fno-PIE has been used in older Linux Kernel builds + * in a similar way to -fno-pie or -no-pie. + * 3) A check is added for Kernel and U-boot defines + * (-D__KERNEL__ and -D__UBOOT__). + */ + for (i = 1; i < argc; i++) { + /* Apply all incompatible link flag and disable checks first */ + if (!strcmp(argv[i], "-r") || + !strcmp(argv[i], "-Wl,-r") || + !strcmp(argv[i], "-static") || + !strcmp(argv[i], "-D__KERNEL__") || + !strcmp(argv[i], "-D__UBOOT__") || + !strcmp(argv[i], "-fno-pie") || + !strcmp(argv[i], "-fno-PIE") || + !strcmp(argv[i], "-no-pie")) + break; + /* Record that shared was present which disables -pie but don't + * break out of loop as a check needs to occur that possibly + * still allows -fPIE to be set + */ + if (!strcmp(argv[i], "-shared")) + found_shared = 1; + } + + if (i == argc) { + /* Compile and link condition checking have been kept split + * between these two loops, as there maybe already are valid + * compile flags set for position independence. In that case + * the wrapper just adds the -pie for link. + */ + for (i = 1; i < argc; i++) { + if (!strcmp(argv[i], "-fpie") || + !strcmp(argv[i], "-fPIE") || + !strcmp(argv[i], "-fpic") || + !strcmp(argv[i], "-fPIC")) + break; + } + /* Both args below can be set at compile/link time + * and are ignored correctly when not used + */ + if (i == argc) + *cur++ = "-fPIE"; + + if (!found_shared) + *cur++ = "-pie"; + } +#endif + /* Are we building the Linux Kernel or U-Boot? */ + for (i = 1; i < argc; i++) { + if (!strcmp(argv[i], "-D__KERNEL__") || + !strcmp(argv[i], "-D__UBOOT__")) + break; + } + if (i == argc && found_nonoption) { + /* https://wiki.gentoo.org/wiki/Hardened/Toolchain#Mark_Read-Only_Appropriate_Sections */ +#ifdef BR2_RELRO_PARTIAL + *cur++ = "-Wl,-z,relro"; +#endif +#ifdef BR2_RELRO_FULL + *cur++ = "-Wl,-z,now"; + *cur++ = "-Wl,-z,relro"; +#endif + } + + n_args = (cur - args); + if ((n_args + argc) > DEFAULT_MAX_ARGS) { + args = realloc(args, (n_args + argc) * sizeof(char *)); + if (args == NULL) { + perror(__FILE__ ": realloc"); + return 2; + } + } + + /* append forward args and terminating NULL */ + memcpy(&args[n_args], &argv[1], sizeof(char *) * argc); + + exec_args = args; +#ifdef BR_CCACHE + /* If BR2_USE_CCACHE is set and its value is 1, enable ccache + * usage */ + char *br_use_ccache = getenv("BR2_USE_CCACHE"); + bool ccache_enabled = br_use_ccache && !strncmp(br_use_ccache, "1", strlen("1")); + + if (ccache_enabled) { +#ifdef BR_CCACHE_HASH + /* Allow compilercheck to be overridden through the environment */ + if (setenv("CCACHE_COMPILERCHECK", "string:" BR_CCACHE_HASH, 0)) { + perror(__FILE__ ": Failed to set CCACHE_COMPILERCHECK"); + return 3; + } +#endif +#ifdef BR_CCACHE_BASEDIR + /* Allow basedir to be overridden through the environment */ + if (setenv("CCACHE_BASEDIR", BR_CCACHE_BASEDIR, 0)) { + perror(__FILE__ ": Failed to set CCACHE_BASEDIR"); + return 3; + } +#endif + } else + /* ccache is disabled, skip it */ + exec_args++; +#endif + + /* Debug the wrapper to see final arguments passed to the real compiler. */ + if (debug > 0) { + fprintf(stderr, "Toolchain wrapper executing:"); +#ifdef BR_CCACHE_HASH + if (ccache_enabled) + fprintf(stderr, "%sCCACHE_COMPILERCHECK='string:" BR_CCACHE_HASH "'", + (debug == 2) ? "\n " : " "); +#endif +#ifdef BR_CCACHE_BASEDIR + if (ccache_enabled) + fprintf(stderr, "%sCCACHE_BASEDIR='" BR_CCACHE_BASEDIR "'", + (debug == 2) ? "\n " : " "); +#endif + for (i = 0; exec_args[i]; i++) + fprintf(stderr, "%s'%s'", + (debug == 2) ? "\n " : " ", exec_args[i]); + fprintf(stderr, "\n"); + } + + if (execv(exec_args[0], exec_args)) + perror(path); + + free(args); + + return 2; +} diff --git a/package/gettext-tiny/make-host.sh b/package/gettext-tiny/make-host.sh new file mode 100755 index 0000000..bbd705c --- /dev/null +++ b/package/gettext-tiny/make-host.sh @@ -0,0 +1,81 @@ +#!/usr/bin/bash +source $(dirname "$0")/../common.sh + +PKGNAME=gettext-tiny +PKGVERSION=0.3.2 +PKGSOURCE_DIR=gettext-tiny +PKGSOURCE=gettext-tiny-0.3.2.tar.gz +PKGSOURCE2=gettext-0.22.4.tar.xz +PKGURL="https://github.com/sabotage-linux/gettext-tiny/archive/v0.3.2/gettext-tiny-0.3.2.tar.gz http://mirrors.ustc.edu.cn/gnu/gettext/gettext-0.22.4.tar.xz" + +PKGBUILDNAME=host-${PKGNAME} +PKGBUILD_DIR=${BUILD_DIR}/${PKGBUILDNAME}-${PKGVERSION} + +echo "----> Building ${PKGBUILDNAME} ..." + +stamp_downloaded + +step_start extract +mkdir -p ${PKGBUILD_DIR} +gzip -d -c ${DL_DIR}/${PKGSOURCE_DIR}/${PKGSOURCE} | tar --strip-components=1 -C ${PKGBUILD_DIR} -xf - +chmod -R +rw ${PKGBUILD_DIR} +mkdir -p ${PKGBUILD_DIR}/gettext-gnu +xzcat ${DL_DIR}/${PKGSOURCE_DIR}/${PKGSOURCE2} | tar --strip-components=1 -C ${PKGBUILD_DIR}/gettext-gnu -xf - +step_end extract + +step_start patch +/usr/bin/install -D -m 0644 ${PKGBUILD_DIR}/gettext-gnu/gettext-tools/misc/gettextize.in ${PKGBUILD_DIR}/extra/gettextize.in +/usr/bin/install -D -m 0644 ${PKGBUILD_DIR}/gettext-gnu/gettext-tools/po/Makevars.template ${PKGBUILD_DIR}/extra/Makevars.template +/usr/bin/install -D -m 0644 ${PKGBUILD_DIR}/gettext-gnu/gettext-runtime/po/boldquot.sed ${PKGBUILD_DIR}/extra/boldquot.sed +/usr/bin/install -D -m 0644 ${PKGBUILD_DIR}/gettext-gnu/gettext-runtime/po/en@boldquot.header ${PKGBUILD_DIR}/extra/en@boldquot.header +/usr/bin/install -D -m 0644 ${PKGBUILD_DIR}/gettext-gnu/gettext-runtime/po/en@quot.header ${PKGBUILD_DIR}/extra/en@quot.header +/usr/bin/install -D -m 0644 ${PKGBUILD_DIR}/gettext-gnu/gettext-runtime/po/insert-header.sin ${PKGBUILD_DIR}/extra/insert-header.sin +/usr/bin/install -D -m 0644 ${PKGBUILD_DIR}/gettext-gnu/gettext-runtime/po/quot.sed ${PKGBUILD_DIR}/extra/quot.sed +/usr/bin/install -D -m 0644 ${PKGBUILD_DIR}/gettext-gnu/gettext-runtime/po/remove-potcdate.sin ${PKGBUILD_DIR}/extra/remove-potcdate.sin +/usr/bin/install -D -m 0644 ${PKGBUILD_DIR}/gettext-gnu/gettext-runtime/po/Rules-quot ${PKGBUILD_DIR}/extra/Rules-quot +/usr/bin/install -D -m 0644 ${PKGBUILD_DIR}/gettext-gnu/gettext-runtime/po/Makefile.in.in ${PKGBUILD_DIR}/extra/Makefile.in.in +/usr/bin/install -D -m 0644 ${PKGBUILD_DIR}/gettext-gnu/COPYING ${PKGBUILD_DIR}/extra/COPYING +/usr/bin/install -D -m 0755 ${PKGBUILD_DIR}/gettext-gnu/build-aux/config.rpath ${PKGBUILD_DIR}/build-aux/config.rpath +step_end patch + +stamp_configured + +step_start build +eval "${HOST_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} -C ${PKGBUILD_DIR} ${HOST_CONFIGURE_OPTS} prefix=${HOST_DIR} CFLAGS=\"-O2 -I${HOST_DIR}/include -fPIC\" LIBINTL=NONE" +cp ${PKGBUILD_DIR}/extra/gettextize.in ${PKGBUILD_DIR}/gettextize +/usr/bin/sed -i -e 's,@PACKAGE@,gettext-tools,g;' ${PKGBUILD_DIR}/gettextize +/usr/bin/sed -i -e 's,@VERSION@,0.22.4,g;' ${PKGBUILD_DIR}/gettextize +/usr/bin/sed -i -e 's,@ARCHIVE_VERSION@,0.22.4,' ${PKGBUILD_DIR}/gettextize +/usr/bin/sed -i -e "s,@prefix@,${HOST_DIR},g;" ${PKGBUILD_DIR}/gettextize +/usr/bin/sed -i -e 's,@datarootdir@,${prefix}/share,g;' ${PKGBUILD_DIR}/gettextize +/usr/bin/sed -i -e 's,@datadir@,${prefix}/share,g;' ${PKGBUILD_DIR}/gettextize +/usr/bin/sed -i -e 's,@PATH_SEPARATOR@,:,g;' ${PKGBUILD_DIR}/gettextize +/usr/bin/sed -i -e 's,@RELOCATABLE@,no,g;' ${PKGBUILD_DIR}/gettextize +/usr/bin/sed -i -e 's,@exec_prefix@,${prefix},g;' ${PKGBUILD_DIR}/gettextize +/usr/bin/sed -i -e 's,@bindir@,${exec_prefix}/bin,g;' ${PKGBUILD_DIR}/gettextize +step_end build + +step_start install-host +mkdir -p ${HOST_DIR}/share/gettext-tiny/po +mkdir -p ${HOST_DIR}/share/gettext-tiny/m4 +eval "${HOST_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} -C ${PKGBUILD_DIR} ${HOST_CONFIGURE_OPTS} prefix=${HOST_DIR} LIBINTL=NONE install" +/usr/bin/sed -i -e '/read dummy/d' ${PKGBUILD_DIR}/gettextize +/usr/bin/install -m 0755 -D ${PKGBUILD_DIR}/gettextize ${HOST_DIR}/bin/gettextize +/usr/bin/install -m 0644 -D ${PKGBUILD_DIR}/build-aux/config.rpath ${HOST_DIR}/share/gettext-tiny/config.rpath +/usr/bin/install -m 0644 -D ${PKGBUILD_DIR}/extra/Makefile.in.in ${HOST_DIR}/share/gettext-tiny/po/Makefile.in.in +/usr/bin/install -m 0644 -D ${PKGBUILD_DIR}/extra/boldquot.sed ${HOST_DIR}/share/gettext-tiny/po/boldquot.sed +/usr/bin/install -m 0644 -D ${PKGBUILD_DIR}/extra/en@boldquot.header ${HOST_DIR}/share/gettext-tiny/po/en@boldquot.header +/usr/bin/install -m 0644 -D ${PKGBUILD_DIR}/extra/en@quot.header ${HOST_DIR}/share/gettext-tiny/po/en@quot.header +/usr/bin/install -m 0644 -D ${PKGBUILD_DIR}/extra/insert-header.sin ${HOST_DIR}/share/gettext-tiny/po/insert-header.sin +/usr/bin/install -m 0644 -D ${PKGBUILD_DIR}/extra/quot.sed ${HOST_DIR}/share/gettext-tiny/po/quot.sed +/usr/bin/install -m 0644 -D ${PKGBUILD_DIR}/extra/remove-potcdate.sin ${HOST_DIR}/share/gettext-tiny/po/remove-potcdate.sin +/usr/bin/install -m 0644 -D ${PKGBUILD_DIR}/extra/Rules-quot ${HOST_DIR}/share/gettext-tiny/po/Rules-quot +/usr/bin/install -m 0644 -D ${PKGBUILD_DIR}/extra/Makevars.template ${HOST_DIR}/share/gettext-tiny/po/Makevars.template +touch ${HOST_DIR}/share/gettext-tiny/ABOUT-NLS +# for gettextize +ln -sf ${HOST_DIR}/share/gettext-tiny ${HOST_DIR}/share/gettext +step_end install-host + +stamp_installed + +echo "<---- ${PKGBUILDNAME} build complete." diff --git a/package/glibc/make.sh b/package/glibc/make.sh new file mode 100755 index 0000000..d077d59 --- /dev/null +++ b/package/glibc/make.sh @@ -0,0 +1,50 @@ +#!/usr/bin/bash +source $(dirname "$0")/../common.sh + +PKGNAME=glibc +PKGVERSION=2.41-70-g1502c248d58cb99a203731707987a4342926e830 +PKGSOURCE_DIR=glibc +PKGSOURCE=glibc-2.41-70-g1502c248d58cb99a203731707987a4342926e830.tar.gz +PKGURL=https://github.com/bminor/glibc/archive/2.41-70-g1502c248d58cb99a203731707987a4342926e830/glibc-2.41-70-g1502c248d58cb99a203731707987a4342926e830.tar.gz + +PKGBUILDNAME=${PKGNAME} +PKGBUILD_DIR=${BUILD_DIR}/${PKGBUILDNAME}-${PKGVERSION} + +echo "----> Building ${PKGBUILDNAME} ..." + +stamp_downloaded + +step_start extract +mkdir -p ${PKGBUILD_DIR} +gzip -d -c ${DL_DIR}/${PKGSOURCE_DIR}/${PKGSOURCE} | tar --strip-components=1 -C ${PKGBUILD_DIR} -xf - +chmod -R +rw ${PKGBUILD_DIR} +step_end extract + +step_start patch +/usr/bin/sed -i -e 's/$"/"/g' ${PKGBUILD_DIR}/elf/ldd.bash.in +step_end patch autotools + +tep_start configure +mkdir -p ${PKGBUILD_DIR}/build +(cd ${PKGBUILD_DIR}/build; eval "${TARGET_CONFIGURE_OPTS} CXX=no CFLAGS=\"-O2 -fno-lto\" CPPFLAGS=\"\" CXXFLAGS=\"-O2 -fno-lto\" ac_cv_path_BASH_SHELL=/bin/sh libc_cv_forced_unwind=yes libc_cv_ssp=no libc_cv_slibdir=/lib64 libc_cv_rtlddir=/lib ac_cv_prog_MAKE=\"/usr/bin/make -j9\" /bin/bash ${PKGBUILD_DIR}/configure --target=${GNU_TARGET_NAME} --host=${GNU_TARGET_NAME} --build=x86_64-pc-linux-gnu --prefix=/usr --enable-shared --disable-profile --disable-werror --without-gd --with-headers=${STAGING_DIR}/usr/include --enable-kernel=6.12") +mkdir -p ${STAGING_DIR}/usr/include/gnu +touch ${STAGING_DIR}/usr/include/gnu/stubs.h +step_end configure + +step_start build +eval "${TARGET_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} -C ${PKGBUILD_DIR}/build" +step_end build + +step_start install-staging +eval "${TARGET_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} install_root=${STAGING_DIR} install -C ${PKGBUILD_DIR}/build" +step_end install-staging + +step_start install-target +for libpattern in ld*.so.* libanl.so.* libc.so.* libdl.so.* libgcc_s.so.* libm.so.* libpthread.so.* libresolv.so.* librt.so.* libutil.so.* libnss_files.so.* libnss_dns.so.* libmvec.so.*; do + copy_toolchain_lib_root ${libpattern} +done +step_end install-target + +stamp_installed + +echo "<---- ${PKGBUILDNAME} build complete." diff --git a/package/glibc/nsswitch.conf b/package/glibc/nsswitch.conf new file mode 100644 index 0000000..5c38491 --- /dev/null +++ b/package/glibc/nsswitch.conf @@ -0,0 +1,13 @@ +# /etc/nsswitch.conf + +passwd: files +group: files +shadow: files + +hosts: files dns +networks: files dns + +protocols: files +services: files +ethers: files +rpc: files diff --git a/package/gmp/0001-Complete-function-prototype-in-acinclude.m4-for-C23-.patch b/package/gmp/0001-Complete-function-prototype-in-acinclude.m4-for-C23-.patch new file mode 100644 index 0000000..129a4a8 --- /dev/null +++ b/package/gmp/0001-Complete-function-prototype-in-acinclude.m4-for-C23-.patch @@ -0,0 +1,51 @@ +From 9cd0c36d0110191a5f42e268d7bd21a95a2aa883 Mon Sep 17 00:00:00 2001 +From: Marc Glisse +Date: Wed, 29 Jan 2025 22:38:02 +0100 +Subject: [PATCH] Complete function prototype in acinclude.m4 for C23 + compatibility + +Add parameter names to function prototype + +Upstream: https://gmplib.org/repo/gmp/rev/d66d66d82dbb +Upstream: https://gmplib.org/repo/gmp/rev/8e7bb4ae7a18 +Signed-off-by: Marc Glisse +[Julien: git patch adapted from two upstream mercurial changesets] +Signed-off-by: Julien Olivain +--- + ChangeLog | 9 +++++++++ + acinclude.m4 | 2 +- + 2 files changed, 10 insertions(+), 1 deletion(-) + +diff --git a/ChangeLog b/ChangeLog +index 2902cd2..d808a8b 100644 +--- a/ChangeLog ++++ b/ChangeLog +@@ -1,3 +1,12 @@ ++2025-03-15 Khem Raj ++ ++ * acinclude.m4: Add parameter names to function prototype. ++ ++2025-01-29 Rudi Heitbaum ++ Marc Glisse ++ ++ * acinclude.m4: Complete function prototype. ++ + 2023-07-29 Torbjörn Granlund + + * Version 6.3.0 released. +diff --git a/acinclude.m4 b/acinclude.m4 +index 9cf9483..b79a431 100644 +--- a/acinclude.m4 ++++ b/acinclude.m4 +@@ -609,7 +609,7 @@ GMP_PROG_CC_WORKS_PART([$1], [long long reliability test 1], + + #if defined (__GNUC__) && ! defined (__cplusplus) + typedef unsigned long long t1;typedef t1*t2; +-void g(){} ++void g(int a,t1 const*b,t1 c,t2 d,t1 const*e,int f){} + void h(){} + static __inline__ t1 e(t2 rp,t2 up,int n,t1 v0) + {t1 c,x,r;int i;if(v0){c=1;for(i=1;i Building ${PKGBUILDNAME} ..." + +stamp_downloaded + +step_start extract +mkdir -p ${PKGBUILD_DIR} +xzcat ${DL_DIR}/${PKGSOURCE_DIR}/${PKGSOURCE} | tar --strip-components=1 -C ${PKGBUILD_DIR} -xf - +chmod -R +rw ${PKGBUILD_DIR} +step_end extract + +step_start patch +TAR="tar" PATH=${HOST_DIR}/bin:$PATH ${PROJECT_DIR}/support/scripts/apply-patches.sh ${PKGBUILD_DIR} ${PROJECT_DIR}/package/${PKGNAME} \*.patch +step_end patch autotools ignore_libtool_patch + +step_start configure +echo ">>> ${PKGBUILDNAME} ${PKGVERSION} Autoreconfiguring" +cd ${PKGBUILD_DIR} && eval "AUTOPOINT=/bin/true ${AUTORECONF_OPTS} ${HOST_DIR}/bin/autoreconf -f -i" +patch_libtool ${PKGBUILD_DIR} +(cd ${PKGBUILD_DIR} && rm -rf config.cache; eval "${HOST_CONFIGURE_OPTS} CONFIG_SITE=/dev/null ./configure --prefix=\"${HOST_DIR}\" --sysconfdir=\"${HOST_DIR}/etc\" --localstatedir=\"${HOST_DIR}/var\" --enable-shared --disable-static --disable-gtk-doc --disable-gtk-doc-html --disable-doc --disable-docs --disable-documentation --disable-debug --with-xmlto=no --with-fop=no --disable-nls --disable-dependency-tracking") +step_end configure + +step_start build +eval "${HOST_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} -C ${PKGBUILD_DIR}" +step_end build + +step_start install-host +eval "${HOST_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} install -C ${PKGBUILD_DIR}" +step_end install-host + +stamp_installed + +echo "<---- ${PKGBUILDNAME} build complete." diff --git a/package/host-finalize/make.sh b/package/host-finalize/make.sh new file mode 100755 index 0000000..d369a4a --- /dev/null +++ b/package/host-finalize/make.sh @@ -0,0 +1,15 @@ +#!/usr/bin/bash +source $(dirname "$0")/../common.sh + +echo ">>> Finalizing host directory" + +# see host-finalize in Makefile +PATCHELF=${HOST_DIR}/bin/patchelf \ +PARALLEL_JOBS=${MAXNUM_CPUS} \ +PER_PACKAGE_DIR=${OUTPUT_DIR}/per-package \ +${PROJECT_DIR}/support/scripts/fix-rpath host + +PATCHELF=${HOST_DIR}/bin/patchelf \ +PARALLEL_JOBS=${MAXNUM_CPUS} \ +PER_PACKAGE_DIR=${OUTPUT_DIR}/per-package \ +${PROJECT_DIR}/support/scripts/fix-rpath staging diff --git a/package/kmod/0001-fix-O_CLOEXEC.patch b/package/kmod/0001-fix-O_CLOEXEC.patch new file mode 100644 index 0000000..145ac34 --- /dev/null +++ b/package/kmod/0001-fix-O_CLOEXEC.patch @@ -0,0 +1,48 @@ +From b39a62f6682463bcd47480348fac3dcd209a19a5 Mon Sep 17 00:00:00 2001 +From: Robert Yang +Date: Wed, 22 Jan 2014 01:06:40 -0500 +Subject: [PATCH] Add dummy definition of O_CLOEXEC + +O_CLOEXEC is introduced from Linux 2.6.23, so old kernel doesn't have +it, we need check before use. + +This patch is much more like a workaround, since it may need fcntl() use +FD_CLOEXEC to replace. + +This problem was reported by "Ting Liu " + +[Thomas De Schampheleire +Signed-off-by: Vicente Olivert Riera + +Upstream-status: rejected, suggests to add in buildroot instead [1] + +[1] http://news.gmane.org/find-root.php?message_id=1412062906%2d27378%2d1%2dgit%2dsend%2demail%2dpatrickdepinguin%40gmail.com + +--- + shared/missing.h | 4 ++++ + 1 files changed, 4 insertions(+), 0 deletions(-) + +diff --git a/shared/missing.h b/shared/missing.h +index 4c0d136..e123e98 100644 +--- a/shared/missing.h ++++ b/shared/missing.h +@@ -19,6 +19,10 @@ + # define __NR_finit_module -1 + #endif + ++#ifndef O_CLOEXEC ++#define O_CLOEXEC 0 ++#endif ++ + #ifndef HAVE_FINIT_MODULE + #include + +-- +1.7.1 + diff --git a/package/kmod/make-host.sh b/package/kmod/make-host.sh new file mode 100755 index 0000000..8bc2bbd --- /dev/null +++ b/package/kmod/make-host.sh @@ -0,0 +1,43 @@ +#!/usr/bin/bash +source $(dirname "$0")/../common.sh + +PKGNAME=kmod +PKGVERSION=33 +PKGSOURCE_DIR=kmod +PKGSOURCE=kmod-33.tar.xz +PKGURL=http://mirrors.ustc.edu.cn/kernel.org/linux/utils/kernel/kmod/kmod-33.tar.xz + +PKGBUILDNAME=host-${PKGNAME} +PKGBUILD_DIR=${BUILD_DIR}/${PKGBUILDNAME}-${PKGVERSION} + +echo "----> Building ${PKGBUILDNAME} ..." + +stamp_downloaded + +step_start extract +mkdir -p ${PKGBUILD_DIR} +xzcat ${DL_DIR}/${PKGSOURCE_DIR}/${PKGSOURCE} | tar --strip-components=1 -C ${PKGBUILD_DIR} -xf - +chmod -R +rw ${PKGBUILD_DIR} +step_end extract + +step_start patch +TAR="tar" PATH=${HOST_DIR}/bin:$PATH ${PROJECT_DIR}/support/scripts/apply-patches.sh ${PKGBUILD_DIR} ${PROJECT_DIR}/package/${PKGNAME} \*.patch +step_end patch autotools + +step_start configure +(cd ${PKGBUILD_DIR} && rm -rf config.cache; eval "${HOST_CONFIGURE_OPTS} CONFIG_SITE=/dev/null ./configure --prefix=\"${HOST_DIR}\" --sysconfdir=\"${HOST_DIR}/etc\" --localstatedir=\"${HOST_DIR}/var\" --enable-shared --disable-static --disable-gtk-doc --disable-gtk-doc-html --disable-doc --disable-docs --disable-documentation --disable-debug --with-xmlto=no --with-fop=no --disable-nls --disable-dependency-tracking --disable-manpages --without-zlib --without-zstd --without-xz") +step_end configure + +step_start build +eval "${HOST_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} -C ${PKGBUILD_DIR}" +step_end build + +step_start install-host +eval "${HOST_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} install -C ${PKGBUILD_DIR}" +mkdir -p ${HOST_DIR}/sbin/ +ln -sf ../bin/kmod ${HOST_DIR}/sbin/depmod +step_end install-host + +stamp_installed + +echo "<---- ${PKGBUILDNAME} build complete." diff --git a/package/libtool/make-host.sh b/package/libtool/make-host.sh new file mode 100755 index 0000000..5efce66 --- /dev/null +++ b/package/libtool/make-host.sh @@ -0,0 +1,48 @@ +#!/usr/bin/bash +source $(dirname "$0")/../common.sh + +PKGNAME=libtool +PKGVERSION=2.4.6 +PKGSOURCE_DIR=libtool +PKGSOURCE=libtool-2.4.6.tar.xz +PKGURL=http://mirrors.ustc.edu.cn/gnu/libtool/libtool-2.4.6.tar.xz + +PKGBUILDNAME=host-${PKGNAME} +PKGBUILD_DIR=${BUILD_DIR}/${PKGBUILDNAME}-${PKGVERSION} + +echo "----> Building ${PKGBUILDNAME} ..." + +stamp_downloaded + +step_start extract +mkdir -p ${PKGBUILD_DIR} +xzcat ${DL_DIR}/${PKGSOURCE_DIR}/${PKGSOURCE} | tar --strip-components=1 -C ${PKGBUILD_DIR} -xf - +chmod -R +rw ${PKGBUILD_DIR} +step_end extract + +step_start patch +step_end patch autotools ignore_libtool_patch + +step_start configure +# 下面四条语句的含义是在 ${PKGBUILD_DIR} 目录及其子目录中搜索 -name +# 指定的同名文件,对每个找到的文件执行 touch 命令,'{}':被替换为找到的文件路径 +# 注意需要在最后加上 \; 或 + 来结束 +# 这个命令通常在软件包构建过程中使用,通过更新文件的时间戳来防止因文件时间戳问题导致的构建错误。 +find ${PKGBUILD_DIR} -name aclocal.m4 -exec touch '{}' \; +find ${PKGBUILD_DIR} -name config-h.in -exec touch '{}' \; +find ${PKGBUILD_DIR} -name configure -exec touch '{}' \; +find ${PKGBUILD_DIR} -name Makefile.in -exec touch '{}' \; +(cd ${PKGBUILD_DIR} && rm -rf config.cache; eval "${HOST_CONFIGURE_OPTS} MAKEINFO=true CONFIG_SITE=/dev/null ./configure --prefix=\"${HOST_DIR}\" --sysconfdir=\"${HOST_DIR}/etc\" --localstatedir=\"${HOST_DIR}/var\" --enable-shared --disable-static --disable-gtk-doc --disable-gtk-doc-html --disable-doc --disable-docs --disable-documentation --disable-debug --with-xmlto=no --with-fop=no --disable-nls --disable-dependency-tracking") +step_end configure + +step_start build +eval "${HOST_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} -C ${PKGBUILD_DIR}" +step_end build + +step_start install-host +eval "${HOST_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} install -C ${PKGBUILD_DIR}" +step_end install-host + +stamp_installed + +echo "<---- ${PKGBUILDNAME} build complete." diff --git a/package/libzlib/make-host.sh b/package/libzlib/make-host.sh new file mode 100755 index 0000000..fe6b4bb --- /dev/null +++ b/package/libzlib/make-host.sh @@ -0,0 +1,39 @@ +#!/usr/bin/bash +source $(dirname "$0")/../common.sh + +PKGNAME=libzlib +PKGVERSION=1.3.1 +PKGSOURCE_DIR=libzlib +PKGSOURCE=zlib-1.3.1.tar.xz +PKGURL=https://www.zlib.net/zlib-1.3.1.tar.xz + +PKGBUILDNAME=host-${PKGNAME} +PKGBUILD_DIR=${BUILD_DIR}/${PKGBUILDNAME}-${PKGVERSION} + +echo "----> Building ${PKGBUILDNAME} ..." + +stamp_downloaded + +step_start extract +mkdir -p ${PKGBUILD_DIR} +xzcat ${DL_DIR}/${PKGSOURCE_DIR}/${PKGSOURCE} | tar --strip-components=1 -C ${PKGBUILD_DIR} -xf - +chmod -R +rw ${PKGBUILD_DIR} +step_end extract + +stamp_patched + +step_start configure +(cd ${PKGBUILD_DIR}; rm -rf config.cache; eval "${HOST_CONFIGURE_OPTS} ./configure --prefix=\"${HOST_DIR}\" --sysconfdir=\"${HOST_DIR}/etc\"") +step_end configure + +step_start build +eval "${HOST_MAKE_ENV} /usr/bin/make -j1 -C ${PKGBUILD_DIR}" +step_end build + +step_start install-host +eval "${HOST_MAKE_ENV} /usr/bin/make -j1 -C ${PKGBUILD_DIR} LDCONFIG=true install" +step_end install-host + +stamp_installed + +echo "<---- ${PKGBUILDNAME} build complete." diff --git a/package/linux-headers/make.sh b/package/linux-headers/make.sh new file mode 100755 index 0000000..3fc2f21 --- /dev/null +++ b/package/linux-headers/make.sh @@ -0,0 +1,36 @@ +#!/usr/bin/bash +source $(dirname "$0")/../common.sh + +PKGNAME=linux-headers +PKGVERSION=6.12.47 +PKGSOURCE_DIR=linux +PKGSOURCE=linux-6.12.47.tar.xz +PKGURL=http://mirrors.ustc.edu.cn/kernel.org/linux/kernel/v6.x/linux-6.12.47.tar.xz + +PKGBUILDNAME=${PKGNAME} +PKGBUILD_DIR=${BUILD_DIR}/${PKGBUILDNAME}-${PKGVERSION} + +echo "----> Building ${PKGBUILDNAME} ..." + +stamp_downloaded + +step_start extract +mkdir -p ${PKGBUILD_DIR} +xzcat ${DL_DIR}/${PKGSOURCE_DIR}/${PKGSOURCE} | tar --strip-components=1 -C ${PKGBUILD_DIR} -xf - +chmod -R +rw ${PKGBUILD_DIR} +step_end extract + +stamp_patched + +stamp_configured + +stamp_built + +step_start install-staging +(cd ${PKGBUILD_DIR}; eval "${TARGET_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} ARCH=riscv HOSTCC=\"/usr/bin/gcc\" HOSTCFLAGS=\"\" HOSTCXX=\"/usr/bin/g++\" INSTALL_HDR_PATH=${STAGING_DIR}/usr headers_install") +HOSTCC="/usr/bin/gcc" check_kernel_headers_version ${BUILD_DIR} ${STAGING_DIR} 6.12 strict +step_end install-staging + +stamp_installed + +echo "<---- ${PKGBUILDNAME} build complete." diff --git a/package/linux/make.sh b/package/linux/make.sh new file mode 100755 index 0000000..1865bf8 --- /dev/null +++ b/package/linux/make.sh @@ -0,0 +1,74 @@ +#!/usr/bin/bash +source $(dirname "$0")/../common.sh + +PKGNAME=linux +PKGVERSION=6.12.47 +PKGSOURCE_DIR=linux +PKGSOURCE=linux-6.12.47.tar.xz +PKGURL=http://mirrors.ustc.edu.cn/kernel.org/linux/kernel/v6.x/linux-6.12.47.tar.xz + +PKGBUILDNAME=${PKGNAME} +PKGBUILD_DIR=${BUILD_DIR}/${PKGBUILDNAME}-${PKGVERSION} + +echo "----> Building ${PKGBUILDNAME} ..." + +stamp_downloaded + +step_start extract +mkdir -p ${PKGBUILD_DIR} +xzcat ${DL_DIR}/${PKGSOURCE_DIR}/${PKGSOURCE} | tar --strip-components=1 -C ${PKGBUILD_DIR} -xf - +chmod -R +rw ${PKGBUILD_DIR} +step_end extract + +stamp_patched + +# Before running configure, the configuration file should be present and fixed +eval "${HOST_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} -C ${PKGBUILD_DIR} ARCH=riscv KCFLAGS=\"-Wno-attribute-alias\" INSTALL_MOD_PATH=${TARGET_DIR} CROSS_COMPILE=\"${CROSS_COMPILE}\" WERROR=0 REGENERATE_PARSERS=1 DEPMOD=${HOST_DIR}/sbin/depmod INSTALL_MOD_STRIP=1 HOSTCC=\"/usr/bin/gcc\" defconfig" +touch ${PKGBUILD_DIR}/.stamp_dotconfig +echo ">>> ${PKGBUILDNAME} ${PKGVERSION} Updating kernel config with fixups" +kconfig_enable_option CONFIG_KERNEL_GZIP +kconfig_enable_option CONFIG_CPU_LITTLE_ENDIAN +kconfig_enable_option CONFIG_DEVTMPFS +kconfig_enable_option CONFIG_DEVTMPFS_MOUNT +kconfig_disable_option CONFIG_KERNEL_LZ4 +kconfig_disable_option CONFIG_KERNEL_LZMA +kconfig_disable_option CONFIG_KERNEL_LZO +kconfig_disable_option CONFIG_KERNEL_XZ +kconfig_disable_option CONFIG_KERNEL_ZSTD +kconfig_disable_option CONFIG_KERNEL_UNCOMPRESSED +kconfig_disable_option CONFIG_GCC_PLUGINS +kconfig_disable_option CONFIG_WERROR +eval "${HOST_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} -C ${PKGBUILD_DIR} ARCH=riscv KCFLAGS=\"-Wno-attribute-alias\" INSTALL_MOD_PATH=${TARGET_DIR} CROSS_COMPILE=\"${CROSS_COMPILE}\" WERROR=0 REGENERATE_PARSERS=1 DEPMOD=${HOST_DIR}/sbin/depmod INSTALL_MOD_STRIP=1 HOSTCC=\"/usr/bin/gcc\" olddefconfig" +touch ${PKGBUILD_DIR}/.stamp_kconfig_fixup_done + +# 对于 linux 来说没有使用 configure 脚本 +stamp_configured + +step_start build +eval "${HOST_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} HOSTCC=\"/usr/bin/gcc -O2 -isystem ${HOST_DIR}/include -L${HOST_DIR}/lib -Wl,-rpath,${HOST_DIR}/lib\" ARCH=riscv KCFLAGS=\"-Wno-attribute-alias\" INSTALL_MOD_PATH=${TARGET_DIR} CROSS_COMPILE=\"${CROSS_COMPILE}\" WERROR=0 REGENERATE_PARSERS=1 DEPMOD=${HOST_DIR}/sbin/depmod INSTALL_MOD_STRIP=1 -C ${PKGBUILD_DIR} all" +eval "${HOST_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} HOSTCC=\"/usr/bin/gcc -O2 -isystem ${HOST_DIR}/include -L${HOST_DIR}/lib -Wl,-rpath,${HOST_DIR}/lib\" ARCH=riscv KCFLAGS=\"-Wno-attribute-alias\" INSTALL_MOD_PATH=${TARGET_DIR} CROSS_COMPILE=\"${CROSS_COMPILE}\" WERROR=0 REGENERATE_PARSERS=1 DEPMOD=${HOST_DIR}/sbin/depmod INSTALL_MOD_STRIP=1 -C ${PKGBUILD_DIR} Image" +step_end build + +step_start install-target +# Install modules and remove symbolic links pointing to build +# directories, not relevant on the target +if grep -q "CONFIG_MODULES=y" ${PKGBUILD_DIR}/.config; then + eval "${HOST_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} HOSTCC=\"/usr/bin/gcc -O2 -isystem ${HOST_DIR}/include -L${HOST_DIR}/lib -Wl,-rpath,${HOST_DIR}/lib\" ARCH=riscv KCFLAGS=\"-Wno-attribute-alias\" INSTALL_MOD_PATH=${TARGET_DIR} CROSS_COMPILE=\"${CROSS_COMPILE}\" WERROR=0 REGENERATE_PARSERS=1 DEPMOD=${HOST_DIR}/sbin/depmod INSTALL_MOD_STRIP=1 -C ${PKGBUILD_DIR} modules_install" ; + rm -f ${TARGET_DIR}/lib/modules/${PKGVERSION}/build ; + rm -f ${TARGET_DIR}/lib/modules/${PKGVERSION}/source ; +fi +# Installing dtc (device tree compiler) as host tool, if selected +if grep -q "CONFIG_DTC=y" ${PKGBUILD_DIR}/.config; then + /usr/bin/install -D -m 0755 ${PKGBUILD_DIR}/scripts/dtc/dtc ${HOST_DIR}/bin/linux-dtc ; + ln -sf linux-dtc ${HOST_DIR}/bin/dtc; +fi +step_end install-target + +# Image Install +step_start install-image +/usr/bin/install -m 0644 -D ${PKGBUILD_DIR}/arch/riscv/boot/Image ${IMAGES_DIR}/Image +step_end install-image + +stamp_installed + +echo "<---- ${PKGBUILDNAME} build complete." diff --git a/package/m4/make-host.sh b/package/m4/make-host.sh new file mode 100755 index 0000000..6d1cf4d --- /dev/null +++ b/package/m4/make-host.sh @@ -0,0 +1,39 @@ +#!/usr/bin/bash +source $(dirname "$0")/../common.sh + +PKGNAME=m4 +PKGVERSION=1.4.20 +PKGSOURCE_DIR=m4 +PKGSOURCE=m4-1.4.20.tar.xz +PKGURL=http://mirrors.ustc.edu.cn/gnu/m4/m4-1.4.20.tar.xz + +PKGBUILDNAME=host-${PKGNAME} +PKGBUILD_DIR=${BUILD_DIR}/${PKGBUILDNAME}-${PKGVERSION} + +echo "----> Building ${PKGBUILDNAME} ..." + +stamp_downloaded + +step_start extract +mkdir -p ${PKGBUILD_DIR} +xzcat ${DL_DIR}/${PKGSOURCE_DIR}/${PKGSOURCE} | tar --strip-components=1 -C ${PKGBUILD_DIR} -xf - +chmod -R +rw ${PKGBUILD_DIR} +step_end extract + +stamp_patched autotools + +step_start configure +(cd ${PKGBUILD_DIR} && rm -rf config.cache; eval "${HOST_CONFIGURE_OPTS} CONFIG_SITE=/dev/null ./configure --prefix=\"${HOST_DIR}\" --sysconfdir=\"${HOST_DIR}/etc\" --localstatedir=\"${HOST_DIR}/var\" --enable-shared --disable-static --disable-gtk-doc --disable-gtk-doc-html --disable-doc --disable-docs --disable-documentation --disable-debug --with-xmlto=no --with-fop=no --disable-nls --disable-dependency-tracking") +step_end configure + +step_start build +eval "${HOST_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} -C ${PKGBUILD_DIR}" +step_end build + +step_start install-host +eval "${HOST_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} install -C ${PKGBUILD_DIR}" +step_end install-host + +stamp_installed + +echo "<---- ${PKGBUILDNAME} build complete." diff --git a/package/makedevs/make-host.sh b/package/makedevs/make-host.sh new file mode 100755 index 0000000..58dbc9a --- /dev/null +++ b/package/makedevs/make-host.sh @@ -0,0 +1,36 @@ +#!/usr/bin/bash +source $(dirname "$0")/../common.sh + +PKGNAME=makedevs +PKGVERSION= +PKGSOURCE_DIR=makedevs +PKGSOURCE= + +PKGBUILDNAME=host-${PKGNAME} +PKGBUILD_DIR=${BUILD_DIR}/${PKGBUILDNAME} + +echo "----> Building ${PKGBUILDNAME} ..." + +stamp_downloaded + +step_start extract +mkdir -p ${PKGBUILD_DIR} +cp ${PROJECT_DIR}/package/${PKGNAME}/makedevs.c ${PKGBUILD_DIR} +chmod -R +rw ${PKGBUILD_DIR} +step_end extract + +stamp_patched + +stamp_configured + +step_start build +/usr/bin/gcc -O2 -I${HOST_DIR}/include ${PKGBUILD_DIR}/makedevs.c -o ${PKGBUILD_DIR}/makedevs -L${HOST_DIR}/lib -Wl,-rpath,${HOST_DIR}/lib +step_end build + +step_start install-host +/usr/bin/install -D -m 755 ${PKGBUILD_DIR}/makedevs ${HOST_DIR}/bin/makedevs +step_end install-host + +stamp_installed + +echo "<---- ${PKGBUILDNAME} build complete." diff --git a/package/makedevs/makedevs.c b/package/makedevs/makedevs.c new file mode 100644 index 0000000..be76155 --- /dev/null +++ b/package/makedevs/makedevs.c @@ -0,0 +1,650 @@ +/* vi: set sw=4 ts=4: */ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifndef __APPLE__ +#include /* major() and minor() */ +#endif +#include +#ifdef EXTENDED_ATTRIBUTES +#include +#endif /* EXTENDED_ATTRIBUTES */ + +const char *bb_applet_name; +uid_t recursive_uid; +gid_t recursive_gid; +unsigned int recursive_mode; +#define PASSWD_PATH "etc/passwd" /* MUST be relative */ +#define GROUP_PATH "etc/group" /* MUST be relative */ + +void bb_verror_msg(const char *s, va_list p) +{ + fflush(stdout); + fprintf(stderr, "%s: ", bb_applet_name); + vfprintf(stderr, s, p); +} + +void bb_error_msg(const char *s, ...) +{ + va_list p; + + va_start(p, s); + bb_verror_msg(s, p); + va_end(p); + putc('\n', stderr); +} + +void bb_error_msg_and_die(const char *s, ...) +{ + va_list p; + + va_start(p, s); + bb_verror_msg(s, p); + va_end(p); + putc('\n', stderr); + exit(1); +} + +void bb_vperror_msg(const char *s, va_list p) +{ + int err=errno; + if(s == 0) s = ""; + bb_verror_msg(s, p); + if (*s) s = ": "; + fprintf(stderr, "%s%s\n", s, strerror(err)); +} + +void bb_perror_msg(const char *s, ...) +{ + va_list p; + + va_start(p, s); + bb_vperror_msg(s, p); + va_end(p); +} + +void bb_perror_msg_and_die(const char *s, ...) +{ + va_list p; + + va_start(p, s); + bb_vperror_msg(s, p); + va_end(p); + exit(1); +} + +FILE *bb_xfopen(const char *path, const char *mode) +{ + FILE *fp; + if ((fp = fopen(path, mode)) == NULL) + bb_perror_msg_and_die("%s", path); + return fp; +} + +enum { + FILEUTILS_PRESERVE_STATUS = 1, + FILEUTILS_DEREFERENCE = 2, + FILEUTILS_RECUR = 4, + FILEUTILS_FORCE = 8, + FILEUTILS_INTERACTIVE = 16 +}; +int bb_make_directory (char *path, long mode, int flags) +{ + mode_t mask; + const char *fail_msg; + char *s = path; + char c; + struct stat st; + + mask = umask(0); + if (mode == -1) { + umask(mask); + mode = (S_IXUSR | S_IXGRP | S_IXOTH | + S_IWUSR | S_IWGRP | S_IWOTH | + S_IRUSR | S_IRGRP | S_IROTH) & ~mask; + } else { + umask(mask & ~0300); + } + + do { + c = 0; + + if (flags & FILEUTILS_RECUR) { /* Get the parent. */ + /* Bypass leading non-'/'s and then subsequent '/'s. */ + while (*s) { + if (*s == '/') { + do { + ++s; + } while (*s == '/'); + c = *s; /* Save the current char */ + *s = 0; /* and replace it with nul. */ + break; + } + ++s; + } + } + + if (mkdir(path, 0777) < 0) { + /* If we failed for any other reason than the directory + * already exists, output a diagnostic and return -1.*/ + if ((errno != EEXIST && errno != EISDIR) + || !(flags & FILEUTILS_RECUR) + || (stat(path, &st) < 0 || !S_ISDIR(st.st_mode))) { + fail_msg = "create"; + umask(mask); + break; + } + /* Since the directory exists, don't attempt to change + * permissions if it was the full target. Note that + * this is not an error condition. */ + if (!c) { + umask(mask); + return 0; + } + } + + if (!c) { + /* Done. If necessary, updated perms on the newly + * created directory. Failure to update here _is_ + * an error.*/ + umask(mask); + if ((mode != -1) && (chmod(path, mode) < 0)){ + fail_msg = "set permissions of"; + break; + } + return 0; + } + + /* Remove any inserted nul from the path (recursive mode). */ + *s = c; + + } while (1); + + bb_perror_msg ("Cannot %s directory `%s'", fail_msg, path); + return -1; +} + +const char * const bb_msg_memory_exhausted = "memory exhausted"; + +void *xmalloc(size_t size) +{ + void *ptr = malloc(size); + if (ptr == NULL && size != 0) + bb_error_msg_and_die(bb_msg_memory_exhausted); + return ptr; +} + +void *xcalloc(size_t nmemb, size_t size) +{ + void *ptr = calloc(nmemb, size); + if (ptr == NULL && nmemb != 0 && size != 0) + bb_error_msg_and_die(bb_msg_memory_exhausted); + return ptr; +} + +void *xrealloc(void *ptr, size_t size) +{ + ptr = realloc(ptr, size); + if (ptr == NULL && size != 0) + bb_error_msg_and_die(bb_msg_memory_exhausted); + return ptr; +} + +char *private_get_line_from_file(FILE *file, int c) +{ +#define GROWBY (80) /* how large we will grow strings by */ + + int ch; + int idx = 0; + char *linebuf = NULL; + int linebufsz = 0; + + while ((ch = getc(file)) != EOF) { + /* grow the line buffer as necessary */ + if (idx > linebufsz - 2) { + linebuf = xrealloc(linebuf, linebufsz += GROWBY); + } + linebuf[idx++] = (char)ch; + if (!ch) return linebuf; + if (c<2 && ch == '\n') { + if (c) { + --idx; + } + break; + } + } + if (linebuf) { + if (ferror(file)) { + free(linebuf); + return NULL; + } + linebuf[idx] = 0; + } + return linebuf; +} + +char *bb_get_chomped_line_from_file(FILE *file) +{ + return private_get_line_from_file(file, 1); +} + +long my_getpwnam(const char *name) +{ + struct passwd *myuser; + FILE *stream; + + stream = bb_xfopen(PASSWD_PATH, "r"); + while(1) { + errno = 0; + myuser = fgetpwent(stream); + if (myuser == NULL) + bb_error_msg_and_die("unknown user name: %s", name); + if (errno) + bb_perror_msg_and_die("fgetpwent"); + if (!strcmp(name, myuser->pw_name)) + break; + } + fclose(stream); + + return myuser->pw_uid; +} + +long my_getgrnam(const char *name) +{ + struct group *mygroup; + FILE *stream; + + stream = bb_xfopen(GROUP_PATH, "r"); + while(1) { + errno = 0; + mygroup = fgetgrent(stream); + if (mygroup == NULL) + bb_error_msg_and_die("unknown group name: %s", name); + if (errno) + bb_perror_msg_and_die("fgetgrent"); + if (!strcmp(name, mygroup->gr_name)) + break; + } + fclose(stream); + + return mygroup->gr_gid; +} + +unsigned long get_ug_id(const char *s, long (*my_getxxnam)(const char *)) +{ + unsigned long r; + char *p; + + r = strtoul(s, &p, 10); + if (*p || (s == p)) { + r = my_getxxnam(s); + } + + return r; +} + +char * last_char_is(const char *s, int c) +{ + char *sret = (char *)s; + if (sret) { + sret = strrchr(sret, c); + if(sret != NULL && *(sret+1) != 0) + sret = NULL; + } + return sret; +} + +void bb_xasprintf(char **string_ptr, const char *format, ...) +{ + va_list p; + int r; + + va_start(p, format); + r = vasprintf(string_ptr, format, p); + va_end(p); + + if (r < 0) { + bb_perror_msg_and_die("bb_xasprintf"); + } +} + +char *concat_path_file(const char *path, const char *filename) +{ + char *outbuf; + char *lc; + + if (!path) + path = ""; + lc = last_char_is(path, '/'); + while (*filename == '/') + filename++; + bb_xasprintf(&outbuf, "%s%s%s", path, (lc==NULL ? "/" : ""), filename); + + return outbuf; +} + +#ifdef EXTENDED_ATTRIBUTES +int bb_set_xattr(const char *fpath, const char *xattr) +{ + cap_t cap, cap_file, cap_new; + char *cap_file_text, *cap_new_text; + ssize_t length; + + cap = cap_from_text(xattr); + if (cap == NULL) + bb_perror_msg_and_die("cap_from_text failed for %s", xattr); + + cap_file = cap_get_file(fpath); + if (cap_file == NULL) { + /* if no capability was set before, we initialize cap_file */ + if (errno != ENODATA) + bb_perror_msg_and_die("cap_get_file failed on %s", fpath); + + cap_file = cap_init(); + if (!cap_file) + bb_perror_msg_and_die("cap_init failed"); + } + + if ((cap_file_text = cap_to_text(cap_file, &length)) == NULL) + bb_perror_msg_and_die("cap_to_name failed on %s", fpath); + + bb_xasprintf(&cap_new_text, "%s %s", cap_file_text, xattr); + + if ((cap_new = cap_from_text(cap_new_text)) == NULL) + bb_perror_msg_and_die("cap_from_text failed on %s", cap_new_text); + + if (cap_set_file(fpath, cap_new) == -1) + bb_perror_msg_and_die("cap_set_file failed for %s (xattr = %s)", fpath, xattr); + + cap_free(cap); + cap_free(cap_file); + cap_free(cap_file_text); + cap_free(cap_new); + cap_free(cap_new_text); + + return 0; +} +#endif /* EXTENDED_ATTRIBUTES */ + +void bb_show_usage(void) +{ + fprintf(stderr, "%s: [-d device_table] rootdir\n\n", bb_applet_name); + fprintf(stderr, "Creates a batch of special files as specified in a device table.\n"); + fprintf(stderr, "Device table entries take the form of:\n"); + fprintf(stderr, "name type mode user group major minor start increment count\n\n"); + fprintf(stderr, "Where name is the file name, type can be one of:\n"); + fprintf(stderr, " f A regular file\n"); + fprintf(stderr, " d Directory\n"); + fprintf(stderr, " r Directory recursively\n"); + fprintf(stderr, " c Character special device file\n"); + fprintf(stderr, " b Block special device file\n"); + fprintf(stderr, " p Fifo (named pipe)\n"); + fprintf(stderr, "uid is the user id for the target file, gid is the group id for the\n"); + fprintf(stderr, "target file. The rest of the entries (major, minor, etc) apply to\n"); + fprintf(stderr, "to device special files. A '-' may be used for blank entries.\n\n"); + fprintf(stderr, "For example:\n"); + fprintf(stderr, " \n"); + fprintf(stderr, "/dev d 755 0 0 - - - - -\n"); + fprintf(stderr, "/dev/console c 666 0 0 5 1 - - -\n"); + fprintf(stderr, "/dev/null c 666 0 0 1 3 0 0 -\n"); + fprintf(stderr, "/dev/zero c 666 0 0 1 5 0 0 -\n"); + fprintf(stderr, "/dev/hda b 640 0 0 3 0 0 0 -\n"); + fprintf(stderr, "/dev/hda b 640 0 0 3 1 1 1 15\n"); + fprintf(stderr, "/dev/rtp b 640 0 0 250 0 0 1 5\n"); + fprintf(stderr, "/dev/gps b 640 0 0 251 0 1 1 5\n"); + fprintf(stderr, "/dev/uio b 640 0 0 252 0 1 2 5\n"); + fprintf(stderr, "/dev/uio b 640 0 0 252 1 6 2 5\n\n"); + fprintf(stderr, "Will Produce:\n"); + fprintf(stderr, "/dev\n"); + fprintf(stderr, "/dev/console\n"); + fprintf(stderr, "/dev/null\n"); + fprintf(stderr, "/dev/zero\n"); + fprintf(stderr, "/dev/hda\n"); + fprintf(stderr, "/dev/hda[1-15] with minor numbers [1-15]\n"); + fprintf(stderr, "/dev/rtp[0-4] with minor numbers [0-4]\n"); + fprintf(stderr, "/dev/gps[1-5] with minor numbers [0-4]\n"); + fprintf(stderr, "/dev/uio[1-5] with minor numbers 0,2,4,6,8\n"); + fprintf(stderr, "/dev/uio[6-10] with minor numbers 1,3,5,7,9\n"); + exit(1); +} + +int bb_recursive(const char *fpath, const struct stat *sb, + int tflag, struct FTW *ftwbuf){ + + if (lchown(fpath, recursive_uid, recursive_gid) == -1) { + bb_perror_msg("chown failed for %s", fpath); + return -1; + } + + /* chmod() is optional, also skip if dangling symlink */ + if (recursive_mode == -1 || (tflag == FTW_SL && !access(fpath, F_OK))) + return 0; + + if (chmod(fpath, recursive_mode) < 0) { + bb_perror_msg("chmod failed for %s", fpath); + return -1; + } + + return 0; +} + +int main(int argc, char **argv) +{ + int opt; + FILE *table = stdin; + char *rootdir = NULL; + char *full_name = NULL; + char *line = NULL; + int linenum = 0; + int ret = EXIT_SUCCESS; + + bb_applet_name = basename(argv[0]); + + while ((opt = getopt(argc, argv, "d:")) != -1) { + switch(opt) { + case 'd': + table = bb_xfopen((line=optarg), "r"); + break; + default: + bb_show_usage(); + } + } + + if (optind >= argc || (rootdir=argv[optind])==NULL) { + bb_error_msg_and_die("root directory not specified"); + } + + if (chdir(rootdir) != 0) { + bb_perror_msg_and_die("Could not chdir to %s", rootdir); + } + + umask(0); + + printf("rootdir=%s\n", rootdir); + if (line) { + printf("table='%s'\n", line); + } else { + printf("table=\n"); + } + + while ((line = bb_get_chomped_line_from_file(table))) { + char type; + unsigned int mode = 0755; + unsigned int major = 0; + unsigned int minor = 0; + unsigned int count = 0; + unsigned int increment = 0; + unsigned int start = 0; + char xattr[255]; + char name[4096]; + char user[41]; + char group[41]; + uid_t uid; + gid_t gid; + + linenum++; + + if (1 == sscanf(line, " |xattr %254s", xattr)) { +#ifdef EXTENDED_ATTRIBUTES + if (!full_name) + bb_error_msg_and_die("line %d should be after a file\n", linenum); + + if (bb_set_xattr(full_name, xattr) < 0) + bb_error_msg_and_die("can't set cap %s on file %s\n", xattr, full_name); +#else + bb_error_msg_and_die("line %d not supported: '%s'\nDid you forget to enable " + "BR2_ROOTFS_DEVICE_TABLE_SUPPORTS_EXTENDED_ATTRIBUTES?\n", + linenum, line); +#endif /* EXTENDED_ATTRIBUTES */ + continue; + } + + if ((2 > sscanf(line, "%4095s %c %o %40s %40s %u %u %u %u %u", name, + &type, &mode, user, group, &major, + &minor, &start, &increment, &count)) || + ((major | minor | start | count | increment) > 0xfffff)) + { + if (*line=='\0' || *line=='#' || isspace(*line)) + continue; + bb_error_msg("line %d invalid: '%s'\n", linenum, line); + ret = EXIT_FAILURE; + continue; + } + if (name[0] == '#') { + continue; + } + if (*group) { + gid = get_ug_id(group, my_getgrnam); + } else { + gid = getgid(); + } + if (*user) { + uid = get_ug_id(user, my_getpwnam); + } else { + uid = getuid(); + } + + /* + * free previous full name + * we don't de-allocate full_name at the end of the parsing, + * because we may need it if the next line is an xattr. + */ + free(full_name); + full_name = concat_path_file(rootdir, name); + + if (type == 'd') { + bb_make_directory(full_name, mode | S_IFDIR, FILEUTILS_RECUR); + if (chown(full_name, uid, gid) == -1) { + bb_perror_msg("line %d: chown failed for %s", linenum, full_name); + ret = EXIT_FAILURE; + goto loop; + } + if ((mode != -1) && (chmod(full_name, mode) < 0)){ + bb_perror_msg("line %d: chmod failed for %s", linenum, full_name); + ret = EXIT_FAILURE; + goto loop; + } + } else if (type == 'f' || type == 'F') { + struct stat st; + if ((stat(full_name, &st) < 0 || !S_ISREG(st.st_mode))) { + if (type == 'F') { + continue; /*Ignore optional files*/ + } + bb_perror_msg("line %d: regular file '%s' does not exist", linenum, full_name); + ret = EXIT_FAILURE; + goto loop; + } + if (chown(full_name, uid, gid) == -1) { + bb_perror_msg("line %d: chown failed for %s", linenum, full_name); + ret = EXIT_FAILURE; + goto loop; + } + if ((mode != -1) && (chmod(full_name, mode) < 0)){ + bb_perror_msg("line %d: chmod failed for %s", linenum, full_name); + ret = EXIT_FAILURE; + goto loop; + } + } else if (type == 'r') { + recursive_uid = uid; + recursive_gid = gid; + recursive_mode = mode; + if (nftw(full_name, bb_recursive, 20, FTW_MOUNT | FTW_PHYS) < 0) { + bb_perror_msg("line %d: recursive failed for %s", linenum, full_name); + ret = EXIT_FAILURE; + goto loop; + } + } else + { + dev_t rdev; + unsigned i; + char *full_name_inc; + + if (type == 'p') { + mode |= S_IFIFO; + } + else if (type == 'c') { + mode |= S_IFCHR; + } + else if (type == 'b') { + mode |= S_IFBLK; + } else { + bb_error_msg("line %d: Unsupported file type %c", linenum, type); + ret = EXIT_FAILURE; + goto loop; + } + + full_name_inc = xmalloc(strlen(full_name) + sizeof(int)*3 + 2); + if (count) + count--; + for (i = start; i <= start + count; i++) { + sprintf(full_name_inc, count ? "%s%u" : "%s", full_name, i); + rdev = makedev(major, minor + (i - start) * increment); + if (mknod(full_name_inc, mode, rdev) < 0) { + bb_perror_msg("line %d: can't create node %s", linenum, full_name_inc); + ret = EXIT_FAILURE; + } else if (lchown(full_name_inc, uid, gid) < 0) { + bb_perror_msg("line %d: can't chown %s", linenum, full_name_inc); + ret = EXIT_FAILURE; + } else if (chmod(full_name_inc, mode) < 0) { + bb_perror_msg("line %d: can't chmod %s", linenum, full_name_inc); + ret = EXIT_FAILURE; + } + } + free(full_name_inc); + } +loop: + free(line); + } + fclose(table); + + return ret; +} diff --git a/package/mpc/make-host.sh b/package/mpc/make-host.sh new file mode 100755 index 0000000..d7e7102 --- /dev/null +++ b/package/mpc/make-host.sh @@ -0,0 +1,39 @@ +#!/usr/bin/bash +source $(dirname "$0")/../common.sh + +PKGNAME=mpc +PKGVERSION=1.3.1 +PKGSOURCE_DIR=mpc +PKGSOURCE=mpc-1.3.1.tar.gz +PKGURL=http://mirrors.ustc.edu.cn/gnu/mpc/mpc-1.3.1.tar.gz + +PKGBUILDNAME=host-${PKGNAME} +PKGBUILD_DIR=${BUILD_DIR}/${PKGBUILDNAME}-${PKGVERSION} + +echo "----> Building ${PKGBUILDNAME} ..." + +stamp_downloaded + +step_start extract +mkdir -p ${PKGBUILD_DIR} +gzip -d -c ${DL_DIR}/${PKGSOURCE_DIR}/${PKGSOURCE} | tar --strip-components=1 -C ${PKGBUILD_DIR} -xf - +chmod -R +rw ${PKGBUILD_DIR} +step_end extract + +stamp_patched autotools + +step_start configure +(cd ${PKGBUILD_DIR} && rm -rf config.cache; eval "${HOST_CONFIGURE_OPTS} CONFIG_SITE=/dev/null ./configure --prefix=\"${HOST_DIR}\" --sysconfdir=\"${HOST_DIR}/etc\" --localstatedir=\"${HOST_DIR}/var\" --enable-shared --disable-static --disable-gtk-doc --disable-gtk-doc-html --disable-doc --disable-docs --disable-documentation --disable-debug --with-xmlto=no --with-fop=no --disable-nls --disable-dependency-tracking") +step_end configure + +step_start build +eval "${HOST_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} -C ${PKGBUILD_DIR}" +step_end build + +step_start install-host +eval "${HOST_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} install -C ${PKGBUILD_DIR}" +step_end install-host + +stamp_installed + +echo "<---- ${PKGBUILDNAME} build complete." diff --git a/package/mpfr/make-host.sh b/package/mpfr/make-host.sh new file mode 100755 index 0000000..43e0eb2 --- /dev/null +++ b/package/mpfr/make-host.sh @@ -0,0 +1,39 @@ +#!/usr/bin/bash +source $(dirname "$0")/../common.sh + +PKGNAME=mpfr +PKGVERSION=4.1.1 +PKGSOURCE_DIR=mpfr +PKGSOURCE=mpfr-4.1.1.tar.xz +PKGURL=http://www.mpfr.org/mpfr-4.1.1/mpfr-4.1.1.tar.xz + +PKGBUILDNAME=host-${PKGNAME} +PKGBUILD_DIR=${BUILD_DIR}/${PKGBUILDNAME}-${PKGVERSION} + +echo "----> Building ${PKGBUILDNAME} ..." + +stamp_downloaded + +step_start extract +mkdir -p ${PKGBUILD_DIR} +xzcat ${DL_DIR}/${PKGSOURCE_DIR}/${PKGSOURCE} | tar --strip-components=1 -C ${PKGBUILD_DIR} -xf - +chmod -R +rw ${PKGBUILD_DIR} +step_end extract + +stamp_patched autotools + +step_start configure +(cd ${PKGBUILD_DIR} && rm -rf config.cache; eval "${HOST_CONFIGURE_OPTS} CONFIG_SITE=/dev/null ./configure --prefix=\"${HOST_DIR}\" --sysconfdir=\"${HOST_DIR}/etc\" --localstatedir=\"${HOST_DIR}/var\" --enable-shared --disable-static --disable-gtk-doc --disable-gtk-doc-html --disable-doc --disable-docs --disable-documentation --disable-debug --with-xmlto=no --with-fop=no --disable-nls --disable-dependency-tracking") +step_end configure + +step_start build +eval "${HOST_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} -C ${PKGBUILD_DIR}" +step_end build + +step_start install-host +eval "${HOST_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} install -C ${PKGBUILD_DIR}" +step_end install-host + +stamp_installed + +echo "<---- ${PKGBUILDNAME} build complete." diff --git a/package/opensbi/hello.s b/package/opensbi/hello.s new file mode 100644 index 0000000..75aa5be --- /dev/null +++ b/package/opensbi/hello.s @@ -0,0 +1,79 @@ +# hello.s - RISC-V 64 位裸机程序, 打印 "hello world!" 到控制台 + +.section .text +.global _start +_start: + # 0x80000000 <- OpenSBI + # 0x80200000 <- hello.bin + # 0x80210000 <- 栈顶 + + # 设置栈指针 + li sp, 0x80210000 + + # 调用打印函数 + call print_hello + + # 无限循环(退出 qemu 需要按 Ctrl+A X) +1: j 1b + +# 打印 "hello world!" 函数 +print_hello: + # 保存返回地址 + addi sp, sp, -8 + sd ra, 0(sp) + + # 加载字符串地址 + la a0, hello_string + + # 调用字符串打印函数 + call puts + + # 恢复返回地址 + ld ra, 0(sp) + addi sp, sp, 8 + ret + +# 字符串打印函数 void puts(char *str) +# a0: 字符串地址 +puts: + # 保存寄存器 + addi sp, sp, -16 + sd ra, 8(sp) + sd s0, 0(sp) + + mv s0, a0 # 保存字符串地址 + +PRINT_LOOP: + # 读取一个字符 + lb a0, 0(s0) + beq a0, zero, PRINT_DONE # 直到遇到 '\0' 结束 + + # 调用字符打印函数 + call putc + + # 下一个字符 + addi s0, s0, 1 + j PRINT_LOOP + +PRINT_DONE: + # 恢复寄存器 + ld s0, 0(sp) + ld ra, 8(sp) + addi sp, sp, 16 + ret + +# 字符打印函数 void putc(char c) +# a0: 要打印的字符 +putc: + # 使用 SBI 调用 (console_putchar) + li a7, 0x01 # SBI_EXT_0_1_CONSOLE_PUTCHAR + ecall + ret + +# 数据段 +.section .rodata +hello_string: + .asciz "\nHello RISC-V world!\n" + +# 对齐到4字节边界 +.align 2 diff --git a/package/opensbi/hello.sh b/package/opensbi/hello.sh new file mode 100755 index 0000000..84a49ff --- /dev/null +++ b/package/opensbi/hello.sh @@ -0,0 +1,19 @@ +#!/usr/bin/bash +source $(dirname "$0")/../common.sh + +rm -f hello.o hello.elf hello.bin + +# 编译 +${CROSS_COMPILE}as hello.s -o hello.o +${CROSS_COMPILE}ld hello.o -Ttext=0x80200000 -o hello.elf +${CROSS_COMPILE}objcopy -O binary hello.elf hello.bin + +# 运行 +echo "Running in QEMU..." +echo "Press Ctrl+A then X to exit" +qemu-system-riscv64 \ + -M virt \ + -m 256M \ + -nographic \ + -bios ${IMAGES_DIR}/fw_jump.bin \ + -kernel hello.bin diff --git a/package/opensbi/make.sh b/package/opensbi/make.sh new file mode 100755 index 0000000..ac31289 --- /dev/null +++ b/package/opensbi/make.sh @@ -0,0 +1,37 @@ +#!/usr/bin/bash +source $(dirname "$0")/../common.sh + +PKGNAME=opensbi +PKGVERSION=1.6 +PKGSOURCE_DIR=opensbi +PKGSOURCE=opensbi-1.6.tar.gz +PKGURL=https://github.com/riscv-software-src/opensbi/archive/v1.6/opensbi-1.6.tar.gz + +PKGBUILDNAME=${PKGNAME} +PKGBUILD_DIR=${BUILD_DIR}/${PKGBUILDNAME}-${PKGVERSION} + +echo "----> Building ${PKGBUILDNAME} ..." + +stamp_downloaded + +step_start extract +mkdir -p ${PKGBUILD_DIR} +gzip -d -c ${DL_DIR}/${PKGSOURCE_DIR}/${PKGSOURCE} | tar --strip-components=1 -C ${PKGBUILD_DIR} -xf - +chmod -R +rw ${PKGBUILD_DIR} +step_end extract + +stamp_patched + +stamp_configured + +step_start build +eval "${TARGET_MAKE_ENV} CROSS_COMPILE=${CROSS_COMPILE} PLATFORM=generic /usr/bin/make -j${MAXNUM_CPUS} -C ${PKGBUILD_DIR}" +step_end build + +step_start install-image +/usr/bin/install -m 0644 -D ${PKGBUILD_DIR}/build/platform/generic/firmware/fw_jump.bin ${IMAGES_DIR}/fw_jump.bin +step_end install-image + +stamp_installed + +echo "<---- ${PKGBUILDNAME} build complete." diff --git a/package/patchelf/0001-Add-option-to-make-the-rpath-relative-under-a-specif.patch b/package/patchelf/0001-Add-option-to-make-the-rpath-relative-under-a-specif.patch new file mode 100644 index 0000000..c29fac7 --- /dev/null +++ b/package/patchelf/0001-Add-option-to-make-the-rpath-relative-under-a-specif.patch @@ -0,0 +1,340 @@ +From 6e8915572db65cf63b7a82f9b24af6f9cad92ba7 Mon Sep 17 00:00:00 2001 +From: Wolfgang Grandegger +Date: Mon, 20 Feb 2017 16:29:24 +0100 +Subject: [PATCH] Add option to make the rpath relative under a specified root + directory + +Running "patchelf" with the option "--make-rpath-relative ROOTDIR" will +modify or delete the RPATHDIRs according the following rules +similar to Martin's patches [1] making the Buildroot toolchaing/SDK +relocatable. + +RPATHDIR starts with "$ORIGIN": + The original build-system already took care of setting a relative + RPATH, resolve it and test if it's valid (does exist) + +RPATHDIR starts with ROOTDIR: + The original build-system added some absolute RPATH (absolute on + the build machine). Test if it's valid (does exist). + +ROOTDIR/RPATHDIR exists: + The original build-system already took care of setting an absolute + RPATH (absolute in the final rootfs), resolve it and test if it's + valid (does exist). + +RPATHDIR points somewhere else: + (can be anywhere: build trees, staging tree, host location, + non-existing location, etc.). Just discard such a path. + +The option "--no-standard-libs" will discard RPATHDIRs ROOTDIR/lib and +ROOTDIR/usr/lib. Like "--shrink-rpath", RPATHDIRs are also discarded +if the directories do not contain a library referenced by the +DT_NEEDED fields. +If the option "--relative-to-file" is given, the rpath will start +with "$ORIGIN" making it relative to the ELF file, otherwise an +absolute path relative to ROOTDIR will be used. + +A pull request for a similar patch [2] for mainline inclusion is +pending. + +[1] http://lists.busybox.net/pipermail/buildroot/2016-April/159422.html +[2] https://github.com/NixOS/patchelf/pull/118 + +Signed-off-by: Wolfgang Grandegger +[Fabrice: update for 0.13] +Signed-off-by: Fabrice Fontaine +[Dario: make the patch to be applied with fuzz factor 0] +Signed-off-by: Dario Binacchi +--- + src/patchelf.cc | 199 +++++++++++++++++++++++++++++++++++++++++------- + 1 file changed, 171 insertions(+), 28 deletions(-) + +diff --git a/src/patchelf.cc b/src/patchelf.cc +index fd1e7b7b61c3..f3b7ba8867bf 100644 +--- a/src/patchelf.cc ++++ b/src/patchelf.cc +@@ -45,6 +45,10 @@ static bool debugMode = false; + + static bool forceRPath = false; + ++static bool noStandardLibDirs = false; ++ ++static bool relativeToFile = false; ++ + static std::vector fileNames; + static std::string outputFileName; + static bool alwaysWrite = false; +@@ -81,6 +85,49 @@ static bool hasAllowedPrefix(const std::string & s, const std::vector + class ElfFile +@@ -197,9 +244,13 @@ public: + + void setInterpreter(const std::string & newInterpreter); + +- typedef enum { rpPrint, rpShrink, rpSet, rpAdd, rpRemove } RPathOp; ++ typedef enum { rpPrint, rpShrink, rpMakeRelative, rpSet, rpAdd, rpRemove} RPathOp; + +- void modifyRPath(RPathOp op, const std::vector & allowedRpathPrefixes, std::string newRPath); ++ bool libFoundInRPath(const std::string & dirName, ++ const std::vector neededLibs, ++ std::vector & neededLibFound); ++ ++ void modifyRPath(RPathOp op, std::string rootDir, const std::vector & allowedRpathPrefixes, std::string newRPath, const std::string & fileName); + + void addNeeded(const std::set & libs); + +@@ -1267,8 +1318,28 @@ static void concatToRPath(std::string & rpath, const std::string & path) + + + template +-void ElfFile::modifyRPath(RPathOp op, +- const std::vector & allowedRpathPrefixes, std::string newRPath) ++bool ElfFile::libFoundInRPath(const std::string & dirName, ++ const std::vector neededLibs, std::vector & neededLibFound) ++{ ++ /* For each library that we haven't found yet, see if it ++ exists in this directory. */ ++ bool libFound = false; ++ for (unsigned int j = 0; j < neededLibs.size(); ++j) ++ if (!neededLibFound[j]) { ++ std::string libName = dirName + "/" + neededLibs[j]; ++ struct stat st; ++ if (stat(libName.c_str(), &st) == 0) { ++ neededLibFound[j] = true; ++ libFound = true; ++ } ++ } ++ return libFound; ++} ++ ++ ++template ++void ElfFile::modifyRPath(RPathOp op, std::string rootDir, ++ const std::vector & allowedRpathPrefixes, std::string newRPath, const std::string & fileName) + { + auto shdrDynamic = findSection(".dynamic"); + +@@ -1314,6 +1385,11 @@ void ElfFile::modifyRPath(RPathOp op, + return; + } + ++ if (op == rpMakeRelative && !rpath) { ++ debug("no RPATH to make relative\n"); ++ return; ++ } ++ + if (op == rpShrink && !rpath) { + debug("no RPATH to shrink\n"); + return; +@@ -1343,31 +1419,80 @@ void ElfFile::modifyRPath(RPathOp op, + continue; + } + +- /* For each library that we haven't found yet, see if it +- exists in this directory. */ +- bool libFound = false; +- for (unsigned int j = 0; j < neededLibs.size(); ++j) +- if (!neededLibFound[j]) { +- std::string libName = dirName + "/" + neededLibs[j]; +- try { +- Elf32_Half library_e_machine = getElfType(readFile(libName, sizeof(Elf32_Ehdr))).machine; +- if (rdi(library_e_machine) == rdi(hdr->e_machine)) { +- neededLibFound[j] = true; +- libFound = true; +- } else +- debug("ignoring library '%s' because its machine type differs\n", libName.c_str()); +- } catch (SysError & e) { +- if (e.errNo != ENOENT) throw; +- } +- } +- +- if (!libFound) ++ if (!libFoundInRPath(dirName, neededLibs, neededLibFound)) + debug("removing directory '%s' from RPATH\n", dirName.c_str()); + else + concatToRPath(newRPath, dirName); + } + } + ++ /* Make the the RPATH relative to the specified path */ ++ if (op == rpMakeRelative) { ++ std::vector neededLibFound(neededLibs.size(), false); ++ std::string fileDir = fileName.substr(0, fileName.find_last_of("/")); ++ ++ newRPath = ""; ++ ++ std::vector rpathDirs = splitColonDelimitedString(rpath); ++ for (std::vector::iterator it = rpathDirs.begin(); it != rpathDirs.end(); ++it) { ++ const std::string & dirName = *it; ++ ++ std::string canonicalPath; ++ ++ /* Figure out if we should keep or discard the path. There are several ++ cases to be handled: ++ "dirName" starts with "$ORIGIN": ++ The original build-system already took care of setting a relative ++ RPATH. Resolve it and test if it's valid (does exist). ++ "dirName" start with "rootDir": ++ The original build-system added some absolute RPATH (absolute on ++ the build machine). Test if it's valid (does exist). ++ "rootDir"/"dirName" exists: ++ The original build-system already took care of setting an absolute ++ RPATH (absolute in the final rootfs). Resolve it and test if it's ++ valid (does exist). ++ "dirName" points somewhere else: ++ (can be anywhere: build trees, staging tree, host location, ++ non-existing location, etc.). Just discard such a path. */ ++ if (!dirName.compare(0, 7, "$ORIGIN")) { ++ std::string path = fileDir + dirName.substr(7); ++ if (!absolutePathExists(path, canonicalPath)) { ++ debug("removing directory '%s' from RPATH because '%s' doesn't exist\n", ++ dirName.c_str(), path.c_str()); ++ continue; ++ } ++ } else if (!dirName.compare(0, rootDir.length(), rootDir)) { ++ if (!absolutePathExists(dirName, canonicalPath)) { ++ debug("removing directory '%s' from RPATH because it doesn't exist\n", dirName.c_str()); ++ continue; ++ } ++ } else { ++ std::string path = rootDir + dirName; ++ if (!absolutePathExists(path, canonicalPath)) { ++ debug("removing directory '%s' from RPATH because it's not in rootdir\n", ++ dirName.c_str()); ++ continue; ++ } ++ } ++ ++ if (noStandardLibDirs) { ++ if (!canonicalPath.compare(rootDir + "/lib") || ++ !canonicalPath.compare(rootDir + "/usr/lib")) { ++ debug("removing directory '%s' from RPATH because it's a standard library directory\n", ++ dirName.c_str()); ++ continue; ++ } ++ } ++ ++ /* Finally make "canonicalPath" relative to "filedir" in "rootDir" */ ++ if (relativeToFile) ++ concatToRPath(newRPath, makePathRelative(canonicalPath, fileDir)); ++ else ++ concatToRPath(newRPath, canonicalPath.substr(rootDir.length())); ++ debug("keeping relative path of %s\n", canonicalPath.c_str()); ++ } ++ } ++ + if (op == rpRemove) { + if (!rpath) { + debug("no RPATH to delete\n"); +@@ -1736,7 +1861,9 @@ static bool removeRPath = false; + static bool setRPath = false; + static bool addRPath = false; + static bool printRPath = false; ++static bool makeRPathRelative = false; + static std::string newRPath; ++static std::string rootDir; + static std::set neededLibsToRemove; + static std::map neededLibsToReplace; + static std::set neededLibsToAdd; +@@ -1760,16 +1887,18 @@ static void patchElf2(ElfFile && elfFile, const FileContents & fileContents, con + elfFile.setInterpreter(newInterpreter); + + if (printRPath) +- elfFile.modifyRPath(elfFile.rpPrint, {}, ""); ++ elfFile.modifyRPath(elfFile.rpPrint, "", {}, "", fileName); + + if (shrinkRPath) +- elfFile.modifyRPath(elfFile.rpShrink, allowedRpathPrefixes, ""); ++ elfFile.modifyRPath(elfFile.rpShrink, "", allowedRpathPrefixes, "", fileName); + else if (removeRPath) +- elfFile.modifyRPath(elfFile.rpRemove, {}, ""); ++ elfFile.modifyRPath(elfFile.rpRemove, "", {}, "", fileName); + else if (setRPath) +- elfFile.modifyRPath(elfFile.rpSet, {}, newRPath); ++ elfFile.modifyRPath(elfFile.rpSet, "", {}, newRPath, fileName); + else if (addRPath) +- elfFile.modifyRPath(elfFile.rpAdd, {}, newRPath); ++ elfFile.modifyRPath(elfFile.rpAdd, "", {}, newRPath, fileName); ++ else if (makeRPathRelative) ++ elfFile.modifyRPath(elfFile.rpMakeRelative, rootDir, {}, "", fileName); + + if (printNeeded) elfFile.printNeededLibs(); + +@@ -1821,6 +1950,9 @@ void showHelp(const std::string & progName) + [--remove-rpath]\n\ + [--shrink-rpath]\n\ + [--allowed-rpath-prefixes PREFIXES]\t\tWith '--shrink-rpath', reject rpath entries not starting with the allowed prefix\n\ ++ [--make-rpath-relative ROOTDIR]\n\ ++ [--no-standard-lib-dirs]\n\ ++ [--relative-to-file]\n\ + [--print-rpath]\n\ + [--force-rpath]\n\ + [--add-needed LIBRARY]\n\ +@@ -1889,6 +2021,17 @@ int mainWrapped(int argc, char * * argv) + addRPath = true; + newRPath = argv[i]; + } ++ else if (arg == "--make-rpath-relative") { ++ if (++i == argc) error("missing argument to --make-rpath-relative"); ++ makeRPathRelative = true; ++ rootDir = argv[i]; ++ } ++ else if (arg == "--no-standard-lib-dirs") { ++ noStandardLibDirs = true; ++ } ++ else if (arg == "--relative-to-file") { ++ relativeToFile = true; ++ } + else if (arg == "--print-rpath") { + printRPath = true; + } +-- +2.43.0 + diff --git a/package/patchelf/make-host.sh b/package/patchelf/make-host.sh new file mode 100755 index 0000000..5be4063 --- /dev/null +++ b/package/patchelf/make-host.sh @@ -0,0 +1,41 @@ +#!/usr/bin/bash +source $(dirname "$0")/../common.sh + +PKGNAME=patchelf +PKGVERSION=0.13 +PKGSOURCE_DIR=patchelf +PKGSOURCE=patchelf-0.13.tar.bz2 +PKGURL=https://github.com/NixOS/patchelf/releases/download/0.13/patchelf-0.13.tar.bz2 + +PKGBUILDNAME=host-${PKGNAME} +PKGBUILD_DIR=${BUILD_DIR}/${PKGBUILDNAME}-${PKGVERSION} + +echo "----> Building ${PKGBUILDNAME} ..." + +stamp_downloaded + +step_start extract +mkdir -p ${PKGBUILD_DIR} +bzcat ${DL_DIR}/${PKGSOURCE_DIR}/${PKGSOURCE} | tar --strip-components=1 -C ${PKGBUILD_DIR} -xf - +chmod -R +rw ${PKGBUILD_DIR} +step_end extract + +step_start patch +TAR="tar" PATH=${HOST_DIR}/bin:$PATH ${PROJECT_DIR}/support/scripts/apply-patches.sh ${PKGBUILD_DIR} ${PROJECT_DIR}/package/${PKGNAME} \*.patch +step_end patch autotools + +step_start configure +(cd ${PKGBUILD_DIR} && rm -rf config.cache; eval "${HOST_CONFIGURE_OPTS} CONFIG_SITE=/dev/null ./configure --prefix=\"${HOST_DIR}\" --sysconfdir=\"${HOST_DIR}/etc\" --localstatedir=\"${HOST_DIR}/var\" --enable-shared --disable-static --disable-gtk-doc --disable-gtk-doc-html --disable-doc --disable-docs --disable-documentation --disable-debug --with-xmlto=no --with-fop=no --disable-nls --disable-dependency-tracking") +step_end configure + +step_start build +eval "${HOST_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} -C ${PKGBUILD_DIR}" +step_end build + +step_start install-host +eval "${HOST_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} install -C ${PKGBUILD_DIR}" +step_end install-host + +stamp_installed + +echo "<---- ${PKGBUILDNAME} build complete." diff --git a/package/pkgconf/0001-Only-prefix-with-the-sysroot-a-subset-of-variables.patch b/package/pkgconf/0001-Only-prefix-with-the-sysroot-a-subset-of-variables.patch new file mode 100644 index 0000000..986058d --- /dev/null +++ b/package/pkgconf/0001-Only-prefix-with-the-sysroot-a-subset-of-variables.patch @@ -0,0 +1,150 @@ +From c912e9bb8d5be414fda74b2019deb2a6d2d041a0 Mon Sep 17 00:00:00 2001 +From: Thomas Petazzoni +Date: Sun, 16 Dec 2018 11:52:18 +0100 +Subject: [PATCH] Only prefix with the sysroot a subset of variables + +The standard logic of pkg-config is to prefix all absolute paths by +the sysroot defined in PKG_CONFIG_SYSROOT_DIR. However, while some +paths (like includedir, libdir, and paths used in -L and -I options) +indeed need to be prefixed by the sysroot, it is not necessarily the +case for paths that are used on the target. If they get prefixed by +the sysroot, the runtime path on the target is incorrect. + +Unfortunately, pkg-config doesn't have a sense of which path needs to +be prefixed by the sysroot, and which path should not be prefixed by +the sysroot. + +So, let's simply have a whitelist of paths that should be prefixed: +g_ir_scanner, g_ir_compiler, g_ir_generate, includedir, libdir, mapdir, +pkgdatadir and sdkdir. This list of variables was collected over years of +Buildroot development. All other paths are not prefixed by the sysroot. + +Signed-off-by: Thomas Petazzoni +[Updated to include gobject-introspection paths] +Signed-off-by: Adam Duskett +[Dropped the pkgdatadir path] +Signed-off-by: Thomas Devoogdt +--- + libpkgconf/tuple.c | 64 ++++++++++++++++++++++++++++++++-------------- + 1 file changed, 45 insertions(+), 19 deletions(-) + +diff --git a/libpkgconf/tuple.c b/libpkgconf/tuple.c +index 83f6a47..d56fcec 100644 +--- a/libpkgconf/tuple.c ++++ b/libpkgconf/tuple.c +@@ -178,6 +178,20 @@ dequote(const char *value) + return buf; + } + ++static char * ++pkgconf_tuple_parse_sysroot(const pkgconf_client_t *client, pkgconf_list_t *vars, const char *value, unsigned int flags, bool add_sysroot); ++ ++const char *sysrooted_keys[] = { ++ "g_ir_scanner", ++ "g_ir_compiler", ++ "g_ir_generate", ++ "includedir", ++ "libdir", ++ "mapdir", ++ "sdkdir", ++ NULL, ++}; ++ + static const char * + find_sysroot(const pkgconf_client_t *client, pkgconf_list_t *vars) + { +@@ -237,14 +251,20 @@ pkgconf_tuple_add(const pkgconf_client_t *client, pkgconf_list_t *list, const ch + { + char *dequote_value; + pkgconf_tuple_t *tuple = calloc(1, sizeof(pkgconf_tuple_t)); ++ bool add_sysroot = false; ++ int i; + + pkgconf_tuple_find_delete(list, key); + + dequote_value = dequote(value); + ++ for (i = 0; sysrooted_keys[i] != NULL; i++) ++ if (!strcmp(key, sysrooted_keys[i])) ++ add_sysroot = true; ++ + tuple->key = strdup(key); + if (parse) +- tuple->value = pkgconf_tuple_parse(client, list, dequote_value, flags); ++ tuple->value = pkgconf_tuple_parse_sysroot(client, list, dequote_value, flags, add_sysroot); + else + tuple->value = strdup(dequote_value); + +@@ -294,22 +314,8 @@ pkgconf_tuple_find(const pkgconf_client_t *client, pkgconf_list_t *list, const c + return NULL; + } + +-/* +- * !doc +- * +- * .. c:function:: char *pkgconf_tuple_parse(const pkgconf_client_t *client, pkgconf_list_t *vars, const char *value, unsigned int flags) +- * +- * Parse an expression for variable substitution. +- * +- * :param pkgconf_client_t* client: The pkgconf client object to access. +- * :param pkgconf_list_t* list: The variable list to search for variables (along side the global variable list). +- * :param char* value: The ``key=value`` string to parse. +- * :param uint flags: Any flags to consider while parsing. +- * :return: the variable data with any variables substituted +- * :rtype: char * +- */ +-char * +-pkgconf_tuple_parse(const pkgconf_client_t *client, pkgconf_list_t *vars, const char *value, unsigned int flags) ++static char * ++pkgconf_tuple_parse_sysroot(const pkgconf_client_t *client, pkgconf_list_t *vars, const char *value, unsigned int flags, bool add_sysroot) + { + char buf[PKGCONF_BUFSIZE]; + const char *ptr; +@@ -318,7 +324,7 @@ pkgconf_tuple_parse(const pkgconf_client_t *client, pkgconf_list_t *vars, const + if (!(client->flags & PKGCONF_PKG_PKGF_FDO_SYSROOT_RULES) && + (!(flags & PKGCONF_PKG_PROPF_UNINSTALLED) || (client->flags & PKGCONF_PKG_PKGF_PKGCONF1_SYSROOT_RULES))) + { +- if (*value == '/' && client->sysroot_dir != NULL && strncmp(value, client->sysroot_dir, strlen(client->sysroot_dir))) ++ if (add_sysroot && *value == '/' && client->sysroot_dir != NULL && strncmp(value, client->sysroot_dir, strlen(client->sysroot_dir))) + bptr += pkgconf_strlcpy(buf, client->sysroot_dir, sizeof buf); + } + +@@ -381,7 +387,7 @@ pkgconf_tuple_parse(const pkgconf_client_t *client, pkgconf_list_t *vars, const + { + size_t nlen; + +- parsekv = pkgconf_tuple_parse(client, vars, kv, flags); ++ parsekv = pkgconf_tuple_parse_sysroot(client, vars, kv, flags, add_sysroot); + nlen = pkgconf_strlcpy(bptr, parsekv, remain); + free(parsekv); + +@@ -432,6 +438,26 @@ pkgconf_tuple_parse(const pkgconf_client_t *client, pkgconf_list_t *vars, const + return strdup(buf); + } + ++/* ++ * !doc ++ * ++ * .. c:function:: char *pkgconf_tuple_parse(const pkgconf_client_t *client, pkgconf_list_t *vars, const char *value, unsigned int flags) ++ * ++ * Parse an expression for variable substitution. ++ * ++ * :param pkgconf_client_t* client: The pkgconf client object to access. ++ * :param pkgconf_list_t* list: The variable list to search for variables (along side the global variable list). ++ * :param char* value: The ``key=value`` string to parse. ++ * :param uint flags: Any flags to consider while parsing. ++ * :return: the variable data with any variables substituted ++ * :rtype: char * ++ */ ++char * ++pkgconf_tuple_parse(const pkgconf_client_t *client, pkgconf_list_t *vars, const char *value, unsigned int flags) ++{ ++ return pkgconf_tuple_parse_sysroot(client, vars, value, flags, true); ++} ++ + /* + * !doc + * +-- +2.43.0 + diff --git a/package/pkgconf/make-host.sh b/package/pkgconf/make-host.sh new file mode 100755 index 0000000..11698e0 --- /dev/null +++ b/package/pkgconf/make-host.sh @@ -0,0 +1,44 @@ +#!/usr/bin/bash +source $(dirname "$0")/../common.sh + +PKGNAME=pkgconf +PKGVERSION=2.3.0 +PKGSOURCE_DIR=pkgconf +PKGSOURCE=pkgconf-2.3.0.tar.xz +PKGURL=https://distfiles.ariadne.space/pkgconf/pkgconf-2.3.0.tar.xz + +PKGBUILDNAME=host-${PKGNAME} +PKGBUILD_DIR=${BUILD_DIR}/${PKGBUILDNAME}-${PKGVERSION} + +echo "----> Building ${PKGBUILDNAME} ..." + +stamp_downloaded + +step_start extract +mkdir -p ${PKGBUILD_DIR} +xzcat ${DL_DIR}/${PKGSOURCE_DIR}/${PKGSOURCE} | tar --strip-components=1 -C ${PKGBUILD_DIR} -xf - +chmod -R +rw ${PKGBUILD_DIR} +step_end extract + +step_start patch +TAR="tar" PATH=${HOST_DIR}/bin:$PATH ${PROJECT_DIR}/support/scripts/apply-patches.sh ${PKGBUILD_DIR} ${PROJECT_DIR}/package/${PKGNAME} \*.patch +step_end patch autotools + +step_start configure +(cd ${PKGBUILD_DIR} && rm -rf config.cache; eval "${HOST_CONFIGURE_OPTS} CC=\"/usr/bin/gcc\" CXX=\"/usr/bin/g++\" CONFIG_SITE=/dev/null ./configure --prefix=\"${HOST_DIR}\" --sysconfdir=\"${HOST_DIR}/etc\" --localstatedir=\"${HOST_DIR}/var\" --enable-shared --disable-static --disable-gtk-doc --disable-gtk-doc-html --disable-doc --disable-docs --disable-documentation --disable-debug --with-xmlto=no --with-fop=no --disable-nls --disable-dependency-tracking") +step_end configure + +step_start build +eval "${HOST_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} -C ${PKGBUILD_DIR}" +step_end build + +step_start install-host +eval "${HOST_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} install -C ${PKGBUILD_DIR}" +/usr/bin/install -m 0755 -D ${PROJECT_DIR}/package/pkgconf/pkg-config.in ${HOST_DIR}/bin/pkg-config +/usr/bin/sed -i -e "s,@STAGING_SUBDIR@,${STAGING_SUBDIR},g" ${HOST_DIR}/bin/pkg-config +/usr/bin/sed -i -e 's,@STATIC@,,' ${HOST_DIR}/bin/pkg-config +step_end install-host + +stamp_installed + +echo "<---- ${PKGBUILDNAME} build complete." diff --git a/package/pkgconf/pkg-config.in b/package/pkgconf/pkg-config.in new file mode 100644 index 0000000..e5a23a1 --- /dev/null +++ b/package/pkgconf/pkg-config.in @@ -0,0 +1,12 @@ +#!/bin/sh +PKGCONFDIR=$(dirname $0) +DEFAULT_PKG_CONFIG_LIBDIR=${PKGCONFDIR}/../@STAGING_SUBDIR@/usr/lib/pkgconfig:${PKGCONFDIR}/../@STAGING_SUBDIR@/usr/share/pkgconfig +DEFAULT_PKG_CONFIG_SYSROOT_DIR=${PKGCONFDIR}/../@STAGING_SUBDIR@ +DEFAULT_PKG_CONFIG_SYSTEM_INCLUDE_PATH=${PKGCONFDIR}/../@STAGING_SUBDIR@/usr/include +DEFAULT_PKG_CONFIG_SYSTEM_LIBRARY_PATH=${PKGCONFDIR}/../@STAGING_SUBDIR@/usr/lib + +PKG_CONFIG_LIBDIR=${PKG_CONFIG_LIBDIR:-${DEFAULT_PKG_CONFIG_LIBDIR}} \ + PKG_CONFIG_SYSROOT_DIR=${PKG_CONFIG_SYSROOT_DIR:-${DEFAULT_PKG_CONFIG_SYSROOT_DIR}} \ + PKG_CONFIG_SYSTEM_INCLUDE_PATH=${PKG_CONFIG_SYSTEM_INCLUDE_PATH:-${DEFAULT_PKG_CONFIG_SYSTEM_INCLUDE_PATH}} \ + PKG_CONFIG_SYSTEM_LIBRARY_PATH=${PKG_CONFIG_SYSTEM_LIBRARY_PATH:-${DEFAULT_PKG_CONFIG_SYSTEM_LIBRARY_PATH}} \ + exec ${PKGCONFDIR}/pkgconf --keep-system-libs @STATIC@ "$@" diff --git a/package/prepare-env/make.sh b/package/prepare-env/make.sh new file mode 100755 index 0000000..b30d0bb --- /dev/null +++ b/package/prepare-env/make.sh @@ -0,0 +1,11 @@ +#!/usr/bin/bash +source $(dirname "$0")/../common.sh + +mkdir -p ${BUILD_DIR} +if [ -f ${BUILD_DIR}/build-time.log ]; then + touch ${BUILD_DIR}/build-time.log +fi +mkdir -p ${HOST_DIR} +mkdir -p ${STAGING_DIR} +ln -snf ${STAGING_DIR} ${OUTPUT_DIR}/staging +mkdir -p ${TARGET_DIR} diff --git a/package/rootfs-ext2/device_table.txt b/package/rootfs-ext2/device_table.txt new file mode 100644 index 0000000..dc1af51 --- /dev/null +++ b/package/rootfs-ext2/device_table.txt @@ -0,0 +1,21 @@ +# See package/makedevs/README for details +# +# This device table is used to assign proper ownership and permissions +# on various files. It doesn't create any device file, as it is used +# in both static device configurations (where /dev/ is static) and in +# dynamic configurations (where devtmpfs, mdev or udev are used). +# +# +/dev d 755 0 0 - - - - - +/tmp d 1777 0 0 - - - - - +/etc d 755 0 0 - - - - - +/root d 700 0 0 - - - - - +/var/www d 755 33 33 - - - - - +/etc/shadow f 600 0 0 - - - - - +/etc/passwd f 644 0 0 - - - - - +/etc/network/if-up.d d 755 0 0 - - - - - +/etc/network/if-pre-up.d d 755 0 0 - - - - - +/etc/network/if-down.d d 755 0 0 - - - - - +/etc/network/if-post-down.d d 755 0 0 - - - - - +# uncomment this to allow starting x as non-root +#/usr/X11R6/bin/Xfbdev f 4755 0 0 - - - - - diff --git a/package/rootfs-ext2/make.sh b/package/rootfs-ext2/make.sh new file mode 100755 index 0000000..b4f5a65 --- /dev/null +++ b/package/rootfs-ext2/make.sh @@ -0,0 +1,69 @@ +#!/usr/bin/bash +source $(dirname "$0")/../common.sh + +ROOTFS_EXT2_SIZE=60M + +echo ">>> Generating root filesystems common tables" +rm -rf ${BUILD_DIR}/buildroot-fs +mkdir -p ${BUILD_DIR}/buildroot-fs +printf ' \n' >> ${BUILD_DIR}/buildroot-fs/full_users_table.txt +printf ' /bin/busybox f 4755 0 0 - - - - -\n\n' > ${BUILD_DIR}/buildroot-fs/full_devices_table.txt +cat ${PROJECT_DIR}/package/rootfs-ext2/device_table.txt >> ${BUILD_DIR}/buildroot-fs/full_devices_table.txt + +echo ">>> Generating filesystem image rootfs.ext2" +mkdir -p ${IMAGES_DIR} +rm -rf ${BUILD_DIR}/buildroot-fs/ext2 +mkdir -p ${BUILD_DIR}/buildroot-fs/ext2 +rsync -auH --exclude=/THIS_IS_NOT_YOUR_ROOT_FILESYSTEM ${TARGET_DIR}/ ${BUILD_DIR}/buildroot-fs/ext2/target +echo '#!/bin/sh' > ${BUILD_DIR}/buildroot-fs/ext2/fakeroot +echo "set -e" >> ${BUILD_DIR}/buildroot-fs/ext2/fakeroot +echo "chown -h -R 0:0 ${BUILD_DIR}/buildroot-fs/ext2/target" >> ${BUILD_DIR}/buildroot-fs/ext2/fakeroot +PATH="${HOST_DIR}/bin:${HOST_DIR}/sbin:${PATH}" ${PROJECT_DIR}/support/scripts/mkusers ${BUILD_DIR}/buildroot-fs/full_users_table.txt ${BUILD_DIR}/buildroot-fs/ext2/target >> ${BUILD_DIR}/buildroot-fs/ext2/fakeroot +echo "${HOST_DIR}/bin/makedevs -d ${BUILD_DIR}/buildroot-fs/full_devices_table.txt ${BUILD_DIR}/buildroot-fs/ext2/target" >> ${BUILD_DIR}/buildroot-fs/ext2/fakeroot +printf " rm -rf ${BUILD_DIR}/buildroot-fs/ext2/target/usr/lib/udev/hwdb.d/ ${BUILD_DIR}/buildroot-fs/ext2/target/etc/udev/hwdb.d/\n" >>${BUILD_DIR}/buildroot-fs/ext2/fakeroot +echo "find ${BUILD_DIR}/buildroot-fs/ext2/target/run/ -mindepth 1 -prune -print0 | xargs -0r rm -rf --" >> ${BUILD_DIR}/buildroot-fs/ext2/fakeroot +echo "find ${BUILD_DIR}/buildroot-fs/ext2/target/tmp/ -mindepth 1 -prune -print0 | xargs -0r rm -rf --" >> ${BUILD_DIR}/buildroot-fs/ext2/fakeroot +printf ' \n' >> ${BUILD_DIR}/buildroot-fs/ext2/fakeroot +printf ' \n' >> ${BUILD_DIR}/buildroot-fs/ext2/fakeroot +printf " rm -f ${IMAGES_DIR}/rootfs.ext2\n ${HOST_DIR}/sbin/mkfs.ext2 -d ${BUILD_DIR}/buildroot-fs/ext2/target -N 0 -m 5 -L \"rootfs\" -I 256 -O ^64bit ${IMAGES_DIR}/rootfs.ext2 \"${ROOTFS_EXT2_SIZE}\" || { ret=\$?; echo \"*** Maybe you need to increase the filesystem size (ROOTFS_EXT2_SIZE)\" 1>&2; exit \$ret; }\n" >> ${BUILD_DIR}/buildroot-fs/ext2/fakeroot +chmod a+x ${BUILD_DIR}/buildroot-fs/ext2/fakeroot +PATH="${HOST_DIR}/bin:${HOST_DIR}/sbin:${PATH}" FAKEROOTDONTTRYCHOWN=1 ${HOST_DIR}/bin/fakeroot -- ${BUILD_DIR}/buildroot-fs/ext2/fakeroot +rm -rf ${BUILD_DIR}/buildroot-fs/ext2/target + +echo ">>> Generating filesystem image rootfs.tar" +mkdir -p ${IMAGES_DIR} +rm -rf ${BUILD_DIR}/buildroot-fs/tar +mkdir -p ${BUILD_DIR}/buildroot-fs/tar +rsync -auH --exclude=/THIS_IS_NOT_YOUR_ROOT_FILESYSTEM ${TARGET_DIR}/ ${BUILD_DIR}/buildroot-fs/tar/target +echo '#!/bin/sh' > ${BUILD_DIR}/buildroot-fs/tar/fakeroot +echo "set -e" >> ${BUILD_DIR}/buildroot-fs/tar/fakeroot +echo "chown -h -R 0:0 ${BUILD_DIR}/buildroot-fs/tar/target" >> ${BUILD_DIR}/buildroot-fs/tar/fakeroot +PATH="${HOST_DIR}/bin:${HOST_DIR}/sbin:${PATH}" ${PROJECT_DIR}/support/scripts/mkusers ${BUILD_DIR}/buildroot-fs/full_users_table.txt ${BUILD_DIR}/buildroot-fs/tar/target >> ${BUILD_DIR}/buildroot-fs/tar/fakeroot +echo "${HOST_DIR}/bin/makedevs -d ${BUILD_DIR}/buildroot-fs/full_devices_table.txt ${BUILD_DIR}/buildroot-fs/tar/target" >> ${BUILD_DIR}/buildroot-fs/tar/fakeroot +printf " rm -rf ${BUILD_DIR}/buildroot-fs/tar/target/usr/lib/udev/hwdb.d/ ${BUILD_DIR}/buildroot-fs/tar/target/etc/udev/hwdb.d/\n" >> ${BUILD_DIR}/buildroot-fs/tar/fakeroot +echo "find ${BUILD_DIR}/buildroot-fs/tar/target/run/ -mindepth 1 -prune -print0 | xargs -0r rm -rf --" >> ${BUILD_DIR}/buildroot-fs/tar/fakeroot +echo "find ${BUILD_DIR}/buildroot-fs/tar/target/tmp/ -mindepth 1 -prune -print0 | xargs -0r rm -rf --" >> ${BUILD_DIR}/buildroot-fs/tar/fakeroot +printf ' \n' >> ${BUILD_DIR}/buildroot-fs/tar/fakeroot +printf ' \n' >> ${BUILD_DIR}/buildroot-fs/tar/fakeroot +printf " (cd ${BUILD_DIR}/buildroot-fs/tar/target; find -print0 | LC_ALL=C sort -z | tar --pax-option=exthdr.name=%%d/PaxHeaders/%%f,atime:=0,ctime:=0 -cf ${IMAGES_DIR}/rootfs.tar --null --xattrs-include='*' --no-recursion -T - --numeric-owner)\n" >> ${BUILD_DIR}/buildroot-fs/tar/fakeroot +chmod a+x ${BUILD_DIR}/buildroot-fs/tar/fakeroot +PATH="${HOST_DIR}/bin:${HOST_DIR}/sbin:${PATH}" FAKEROOTDONTTRYCHOWN=1 ${HOST_DIR}/bin/fakeroot -- ${BUILD_DIR}/buildroot-fs/tar/fakeroot +rm -rf ${BUILD_DIR}/buildroot-fs/tar/target + +echo ">>> Generating Init RAM Disk initrd.img" +pushd ${TARGET_DIR} +find . | cpio --create --format='newc' > ${IMAGES_DIR}/initrd.img +popd + + +echo ">>> Executing post-image"; +# Ubuntu 22.04 上默认安装的 qemu 是 6.2.0 +# Ubuntu 24.04 上默认安装的 qemu 是 8.2.2 +QEMU_CMD="qemu-system-riscv64 -M virt -m 256M -nographic -bios fw_jump.bin -kernel Image -drive file=rootfs.ext2,format=raw,id=hd0 -device virtio-blk-device,drive=hd0 -append \"nokaslr root=/dev/vda rw console=ttyS0\" -netdev user,id=net0 -device virtio-net-device,netdev=net0" +echo ${QEMU_CMD} > ${IMAGES_DIR}/start-qemu.sh +chmod +x ${IMAGES_DIR}/start-qemu.sh + +# 如果是 initramfs 启动,在构建出 initrd.img 后可以采用如下 +QEMU_CMD_INITRAMFS="qemu-system-riscv64 -M virt -m 256M -nographic -bios fw_jump.bin -kernel Image -initrd initrd.img -append \"nokaslr rdinit=/sbin/init console=ttyS0\" -netdev user,id=net0 -device virtio-net-device,netdev=net0" +echo ${QEMU_CMD_INITRAMFS} > ${IMAGES_DIR}/start-qemu-initramfs.sh +chmod +x ${IMAGES_DIR}/start-qemu-initramfs.sh diff --git a/package/skeleton/make.sh b/package/skeleton/make.sh new file mode 100755 index 0000000..4e18a2e --- /dev/null +++ b/package/skeleton/make.sh @@ -0,0 +1,55 @@ +#!/usr/bin/bash +source $(dirname "$0")/../common.sh + +PKGNAME=skeleton +PKGVERSION= +PKGSOURCE_DIR= +PKGSOURCE= + +PKGBUILDNAME=host-${PKGNAME} +PKGBUILD_DIR=${BUILD_DIR}/${PKGBUILDNAME} + +echo "----> Building ${PKGBUILDNAME} ..." + +stamp_downloaded + +stamp_extracted + +stamp_patched + +stamp_configured + +stamp_built + +step_start install-host +ln -snf . ${HOST_DIR}/usr +mkdir -p ${HOST_DIR}/lib +mkdir -p ${HOST_DIR}/include +ln -snf lib ${HOST_DIR}/lib64 +step_end install-host + +step_start install-staging +rsync -a --ignore-times --exclude .svn --exclude .git --exclude .hg --exclude .bzr --exclude CVS --chmod=u=rwX,go=rX --exclude .empty --exclude '*~' ${PROJECT_DIR}/package/${PKGNAME}/system/skeleton/ ${STAGING_DIR} +/usr/bin/install -d -m 0755 ${STAGING_DIR}/bin +/usr/bin/install -d -m 0755 ${STAGING_DIR}/sbin +/usr/bin/install -d -m 0755 ${STAGING_DIR}/lib +ln -snf lib ${STAGING_DIR}/lib64 +ln -snf lib ${STAGING_DIR}/usr/lib64 +/usr/bin/install -d -m 0755 ${STAGING_DIR}/usr/include +step_end install-staging + +step_start install-target +rsync -a --ignore-times --exclude .svn --exclude .git --exclude .hg --exclude .bzr --exclude CVS --chmod=u=rwX,go=rX --exclude .empty --exclude '*~' ${PROJECT_DIR}/package/${PKGNAME}/system/skeleton/ ${TARGET_DIR} +/usr/bin/install -d -m 0755 ${TARGET_DIR}/bin +/usr/bin/install -d -m 0755 ${TARGET_DIR}/sbin +/usr/bin/install -d -m 0755 ${TARGET_DIR}/lib +ln -snf lib ${TARGET_DIR}/lib64 +ln -snf lib ${TARGET_DIR}/usr/lib64 +/usr/bin/sed -i -e 's,@PATH@,"/bin:/sbin:/usr/bin:/usr/sbin",' ${TARGET_DIR}/etc/profile +# setup sysv +rsync -a --ignore-times --exclude .svn --exclude .git --exclude .hg --exclude .bzr --exclude CVS --chmod=u=rwX,go=rX --exclude .empty --exclude '*~' ${PROJECT_DIR}/package/${PKGNAME}/skeleton/ ${TARGET_DIR} +step_end install-target + +stamp_installed + +echo "<---- ${PKGBUILDNAME} build complete." diff --git a/package/skeleton/skeleton/dev/log b/package/skeleton/skeleton/dev/log new file mode 120000 index 0000000..d96b3b1 --- /dev/null +++ b/package/skeleton/skeleton/dev/log @@ -0,0 +1 @@ +../tmp/log \ No newline at end of file diff --git a/package/skeleton/skeleton/dev/pts/.empty b/package/skeleton/skeleton/dev/pts/.empty new file mode 100644 index 0000000..e69de29 diff --git a/package/skeleton/skeleton/dev/shm/.empty b/package/skeleton/skeleton/dev/shm/.empty new file mode 100644 index 0000000..e69de29 diff --git a/package/skeleton/skeleton/etc/fstab b/package/skeleton/skeleton/etc/fstab new file mode 100644 index 0000000..06c20fe --- /dev/null +++ b/package/skeleton/skeleton/etc/fstab @@ -0,0 +1,8 @@ +# +/dev/root / ext2 rw,noauto 0 1 +proc /proc proc defaults 0 0 +devpts /dev/pts devpts defaults,gid=5,mode=620,ptmxmode=0666 0 0 +tmpfs /dev/shm tmpfs mode=1777 0 0 +tmpfs /tmp tmpfs mode=1777 0 0 +tmpfs /run tmpfs mode=0755,nosuid,nodev 0 0 +sysfs /sys sysfs defaults 0 0 diff --git a/package/skeleton/skeleton/var/cache b/package/skeleton/skeleton/var/cache new file mode 120000 index 0000000..1431b0e --- /dev/null +++ b/package/skeleton/skeleton/var/cache @@ -0,0 +1 @@ +../tmp \ No newline at end of file diff --git a/package/skeleton/skeleton/var/lib/misc b/package/skeleton/skeleton/var/lib/misc new file mode 120000 index 0000000..f1fde8c --- /dev/null +++ b/package/skeleton/skeleton/var/lib/misc @@ -0,0 +1 @@ +../../tmp \ No newline at end of file diff --git a/package/skeleton/skeleton/var/lock b/package/skeleton/skeleton/var/lock new file mode 120000 index 0000000..386c09e --- /dev/null +++ b/package/skeleton/skeleton/var/lock @@ -0,0 +1 @@ +../run/lock \ No newline at end of file diff --git a/package/skeleton/skeleton/var/log b/package/skeleton/skeleton/var/log new file mode 120000 index 0000000..1431b0e --- /dev/null +++ b/package/skeleton/skeleton/var/log @@ -0,0 +1 @@ +../tmp \ No newline at end of file diff --git a/package/skeleton/skeleton/var/run b/package/skeleton/skeleton/var/run new file mode 120000 index 0000000..84ba55b --- /dev/null +++ b/package/skeleton/skeleton/var/run @@ -0,0 +1 @@ +../run \ No newline at end of file diff --git a/package/skeleton/skeleton/var/spool b/package/skeleton/skeleton/var/spool new file mode 120000 index 0000000..1431b0e --- /dev/null +++ b/package/skeleton/skeleton/var/spool @@ -0,0 +1 @@ +../tmp \ No newline at end of file diff --git a/package/skeleton/skeleton/var/tmp b/package/skeleton/skeleton/var/tmp new file mode 120000 index 0000000..1431b0e --- /dev/null +++ b/package/skeleton/skeleton/var/tmp @@ -0,0 +1 @@ +../tmp \ No newline at end of file diff --git a/package/skeleton/system/skeleton/dev/.empty b/package/skeleton/system/skeleton/dev/.empty new file mode 100644 index 0000000..e69de29 diff --git a/package/skeleton/system/skeleton/dev/fd b/package/skeleton/system/skeleton/dev/fd new file mode 120000 index 0000000..10e8ab7 --- /dev/null +++ b/package/skeleton/system/skeleton/dev/fd @@ -0,0 +1 @@ +../proc/self/fd \ No newline at end of file diff --git a/package/skeleton/system/skeleton/dev/stderr b/package/skeleton/system/skeleton/dev/stderr new file mode 120000 index 0000000..c67586e --- /dev/null +++ b/package/skeleton/system/skeleton/dev/stderr @@ -0,0 +1 @@ +../proc/self/fd/2 \ No newline at end of file diff --git a/package/skeleton/system/skeleton/dev/stdin b/package/skeleton/system/skeleton/dev/stdin new file mode 120000 index 0000000..2825dc0 --- /dev/null +++ b/package/skeleton/system/skeleton/dev/stdin @@ -0,0 +1 @@ +../proc/self/fd/0 \ No newline at end of file diff --git a/package/skeleton/system/skeleton/dev/stdout b/package/skeleton/system/skeleton/dev/stdout new file mode 120000 index 0000000..35e0f62 --- /dev/null +++ b/package/skeleton/system/skeleton/dev/stdout @@ -0,0 +1 @@ +../proc/self/fd/1 \ No newline at end of file diff --git a/package/skeleton/system/skeleton/etc/group b/package/skeleton/system/skeleton/etc/group new file mode 100644 index 0000000..6822a27 --- /dev/null +++ b/package/skeleton/system/skeleton/etc/group @@ -0,0 +1,26 @@ +root:x:0: +daemon:x:1: +bin:x:2: +sys:x:3: +adm:x:4: +tty:x:5: +disk:x:6: +lp:x:7: +mail:x:8: +kmem:x:9: +wheel:x:10:root +cdrom:x:11: +dialout:x:18: +floppy:x:19: +video:x:28: +audio:x:29: +tape:x:32: +www-data:x:33: +operator:x:37: +utmp:x:43: +plugdev:x:46: +staff:x:50: +lock:x:54: +netdev:x:82: +users:x:100: +nobody:x:65534: diff --git a/package/skeleton/system/skeleton/etc/hosts b/package/skeleton/system/skeleton/etc/hosts new file mode 100644 index 0000000..ba712fe --- /dev/null +++ b/package/skeleton/system/skeleton/etc/hosts @@ -0,0 +1 @@ +127.0.0.1 localhost diff --git a/package/skeleton/system/skeleton/etc/mtab b/package/skeleton/system/skeleton/etc/mtab new file mode 120000 index 0000000..5c4677a --- /dev/null +++ b/package/skeleton/system/skeleton/etc/mtab @@ -0,0 +1 @@ +../proc/self/mounts \ No newline at end of file diff --git a/package/skeleton/system/skeleton/etc/passwd b/package/skeleton/system/skeleton/etc/passwd new file mode 100644 index 0000000..d8281d2 --- /dev/null +++ b/package/skeleton/system/skeleton/etc/passwd @@ -0,0 +1,9 @@ +root:x:0:0:root:/root:/bin/sh +daemon:x:1:1:daemon:/usr/sbin:/bin/false +bin:x:2:2:bin:/bin:/bin/false +sys:x:3:3:sys:/dev:/bin/false +sync:x:4:100:sync:/bin:/bin/sync +mail:x:8:8:mail:/var/spool/mail:/bin/false +www-data:x:33:33:www-data:/var/www:/bin/false +operator:x:37:37:Operator:/var:/bin/false +nobody:x:65534:65534:nobody:/home:/bin/false diff --git a/package/skeleton/system/skeleton/etc/profile b/package/skeleton/system/skeleton/etc/profile new file mode 100644 index 0000000..0545277 --- /dev/null +++ b/package/skeleton/system/skeleton/etc/profile @@ -0,0 +1,19 @@ +export PATH=@PATH@ + +if [ "$PS1" ]; then + if [ "`id -u`" -eq 0 ]; then + export PS1='# ' + else + export PS1='$ ' + fi +fi + +export EDITOR='/bin/vi' + +# Source configuration files from /etc/profile.d +for i in /etc/profile.d/*.sh ; do + if [ -r "$i" ]; then + . $i + fi +done +unset i diff --git a/package/skeleton/system/skeleton/etc/profile.d/umask.sh b/package/skeleton/system/skeleton/etc/profile.d/umask.sh new file mode 100644 index 0000000..8e71ad5 --- /dev/null +++ b/package/skeleton/system/skeleton/etc/profile.d/umask.sh @@ -0,0 +1 @@ +umask 022 diff --git a/package/skeleton/system/skeleton/etc/protocols b/package/skeleton/system/skeleton/etc/protocols new file mode 100644 index 0000000..cfdd5ad --- /dev/null +++ b/package/skeleton/system/skeleton/etc/protocols @@ -0,0 +1,61 @@ +# Internet (IP) protocols +# +# Updated from http://www.iana.org/assignments/protocol-numbers and other +# sources. + +ip 0 IP # internet protocol, pseudo protocol number +hopopt 0 HOPOPT # IPv6 Hop-by-Hop Option [RFC1883] +icmp 1 ICMP # internet control message protocol +igmp 2 IGMP # Internet Group Management +ggp 3 GGP # gateway-gateway protocol +ipencap 4 IP-ENCAP # IP encapsulated in IP (officially ``IP'') +st 5 ST # ST datagram mode +tcp 6 TCP # transmission control protocol +egp 8 EGP # exterior gateway protocol +igp 9 IGP # any private interior gateway (Cisco) +pup 12 PUP # PARC universal packet protocol +udp 17 UDP # user datagram protocol +hmp 20 HMP # host monitoring protocol +xns-idp 22 XNS-IDP # Xerox NS IDP +rdp 27 RDP # "reliable datagram" protocol +iso-tp4 29 ISO-TP4 # ISO Transport Protocol class 4 [RFC905] +dccp 33 DCCP # Datagram Congestion Control Prot. [RFC4340] +xtp 36 XTP # Xpress Transfer Protocol +ddp 37 DDP # Datagram Delivery Protocol +idpr-cmtp 38 IDPR-CMTP # IDPR Control Message Transport +ipv6 41 IPv6 # Internet Protocol, version 6 +ipv6-route 43 IPv6-Route # Routing Header for IPv6 +ipv6-frag 44 IPv6-Frag # Fragment Header for IPv6 +idrp 45 IDRP # Inter-Domain Routing Protocol +rsvp 46 RSVP # Reservation Protocol +gre 47 GRE # General Routing Encapsulation +esp 50 IPSEC-ESP # Encap Security Payload [RFC2406] +ah 51 IPSEC-AH # Authentication Header [RFC2402] +skip 57 SKIP # SKIP +ipv6-icmp 58 IPv6-ICMP # ICMP for IPv6 +ipv6-nonxt 59 IPv6-NoNxt # No Next Header for IPv6 +ipv6-opts 60 IPv6-Opts # Destination Options for IPv6 +rspf 73 RSPF CPHB # Radio Shortest Path First (officially CPHB) +vmtp 81 VMTP # Versatile Message Transport +eigrp 88 EIGRP # Enhanced Interior Routing Protocol (Cisco) +ospf 89 OSPFIGP # Open Shortest Path First IGP +ax.25 93 AX.25 # AX.25 frames +ipip 94 IPIP # IP-within-IP Encapsulation Protocol +etherip 97 ETHERIP # Ethernet-within-IP Encapsulation [RFC3378] +encap 98 ENCAP # Yet Another IP encapsulation [RFC1241] +# 99 # any private encryption scheme +pim 103 PIM # Protocol Independent Multicast +ipcomp 108 IPCOMP # IP Payload Compression Protocol +vrrp 112 VRRP # Virtual Router Redundancy Protocol [RFC5798] +l2tp 115 L2TP # Layer Two Tunneling Protocol [RFC2661] +isis 124 ISIS # IS-IS over IPv4 +sctp 132 SCTP # Stream Control Transmission Protocol +fc 133 FC # Fibre Channel +mobility-header 135 Mobility-Header # Mobility Support for IPv6 [RFC3775] +udplite 136 UDPLite # UDP-Lite [RFC3828] +mpls-in-ip 137 MPLS-in-IP # MPLS-in-IP [RFC4023] +manet 138 # MANET Protocols [RFC5498] +hip 139 HIP # Host Identity Protocol +shim6 140 Shim6 # Shim6 Protocol [RFC5533] +wesp 141 WESP # Wrapped Encapsulating Security Payload +rohc 142 ROHC # Robust Header Compression diff --git a/package/skeleton/system/skeleton/etc/resolv.conf b/package/skeleton/system/skeleton/etc/resolv.conf new file mode 120000 index 0000000..2ce2910 --- /dev/null +++ b/package/skeleton/system/skeleton/etc/resolv.conf @@ -0,0 +1 @@ +../run/resolv.conf \ No newline at end of file diff --git a/package/skeleton/system/skeleton/etc/services b/package/skeleton/system/skeleton/etc/services new file mode 100644 index 0000000..b287b63 --- /dev/null +++ b/package/skeleton/system/skeleton/etc/services @@ -0,0 +1,302 @@ +# /etc/services: +# $Id: services,v 1.1 2004/10/09 02:49:18 andersen Exp $ +# +# Network services, Internet style +# +# Note that it is presently the policy of IANA to assign a single well-known +# port number for both TCP and UDP; hence, most entries here have two entries +# even if the protocol doesn't support UDP operations. +# Updated from RFC 1700, ``Assigned Numbers'' (October 1994). Not all ports +# are included, only the more common ones. + +tcpmux 1/tcp # TCP port service multiplexer +echo 7/tcp +echo 7/udp +discard 9/tcp sink null +discard 9/udp sink null +systat 11/tcp users +daytime 13/tcp +daytime 13/udp +netstat 15/tcp +qotd 17/tcp quote +msp 18/tcp # message send protocol +msp 18/udp # message send protocol +chargen 19/tcp ttytst source +chargen 19/udp ttytst source +ftp-data 20/tcp +ftp 21/tcp +fsp 21/udp fspd +ssh 22/tcp # SSH Remote Login Protocol +ssh 22/udp # SSH Remote Login Protocol +telnet 23/tcp +# 24 - private +smtp 25/tcp mail +# 26 - unassigned +time 37/tcp timserver +time 37/udp timserver +rlp 39/udp resource # resource location +nameserver 42/tcp name # IEN 116 +whois 43/tcp nicname +re-mail-ck 50/tcp # Remote Mail Checking Protocol +re-mail-ck 50/udp # Remote Mail Checking Protocol +domain 53/tcp nameserver # name-domain server +domain 53/udp nameserver +mtp 57/tcp # deprecated +bootps 67/tcp # BOOTP server +bootps 67/udp +bootpc 68/tcp # BOOTP client +bootpc 68/udp +tftp 69/udp +gopher 70/tcp # Internet Gopher +gopher 70/udp +rje 77/tcp netrjs +finger 79/tcp +www 80/tcp http # WorldWideWeb HTTP +www 80/udp # HyperText Transfer Protocol +link 87/tcp ttylink +kerberos 88/tcp kerberos5 krb5 # Kerberos v5 +kerberos 88/udp kerberos5 krb5 # Kerberos v5 +supdup 95/tcp +# 100 - reserved +hostnames 101/tcp hostname # usually from sri-nic +iso-tsap 102/tcp tsap # part of ISODE. +csnet-ns 105/tcp cso-ns # also used by CSO name server +csnet-ns 105/udp cso-ns +# unfortunately the poppassd (Eudora) uses a port which has already +# been assigned to a different service. We list the poppassd as an +# alias here. This should work for programs asking for this service. +# (due to a bug in inetd the 3com-tsmux line is disabled) +#3com-tsmux 106/tcp poppassd +#3com-tsmux 106/udp poppassd +rtelnet 107/tcp # Remote Telnet +rtelnet 107/udp +pop-2 109/tcp postoffice # POP version 2 +pop-2 109/udp +pop-3 110/tcp # POP version 3 +pop-3 110/udp +sunrpc 111/tcp portmapper # RPC 4.0 portmapper TCP +sunrpc 111/udp portmapper # RPC 4.0 portmapper UDP +auth 113/tcp authentication tap ident +sftp 115/tcp +uucp-path 117/tcp +nntp 119/tcp readnews untp # USENET News Transfer Protocol +ntp 123/tcp +ntp 123/udp # Network Time Protocol +netbios-ns 137/tcp # NETBIOS Name Service +netbios-ns 137/udp +netbios-dgm 138/tcp # NETBIOS Datagram Service +netbios-dgm 138/udp +netbios-ssn 139/tcp # NETBIOS session service +netbios-ssn 139/udp +imap2 143/tcp # Interim Mail Access Proto v2 +imap2 143/udp +snmp 161/udp # Simple Net Mgmt Proto +snmp-trap 162/udp snmptrap # Traps for SNMP +cmip-man 163/tcp # ISO mgmt over IP (CMOT) +cmip-man 163/udp +cmip-agent 164/tcp +cmip-agent 164/udp +xdmcp 177/tcp # X Display Mgr. Control Proto +xdmcp 177/udp +nextstep 178/tcp NeXTStep NextStep # NeXTStep window +nextstep 178/udp NeXTStep NextStep # server +bgp 179/tcp # Border Gateway Proto. +bgp 179/udp +prospero 191/tcp # Cliff Neuman's Prospero +prospero 191/udp +irc 194/tcp # Internet Relay Chat +irc 194/udp +smux 199/tcp # SNMP Unix Multiplexer +smux 199/udp +at-rtmp 201/tcp # AppleTalk routing +at-rtmp 201/udp +at-nbp 202/tcp # AppleTalk name binding +at-nbp 202/udp +at-echo 204/tcp # AppleTalk echo +at-echo 204/udp +at-zis 206/tcp # AppleTalk zone information +at-zis 206/udp +qmtp 209/tcp # The Quick Mail Transfer Protocol +qmtp 209/udp # The Quick Mail Transfer Protocol +z3950 210/tcp wais # NISO Z39.50 database +z3950 210/udp wais +ipx 213/tcp # IPX +ipx 213/udp +imap3 220/tcp # Interactive Mail Access +imap3 220/udp # Protocol v3 +ulistserv 372/tcp # UNIX Listserv +ulistserv 372/udp +https 443/tcp # MCom +https 443/udp # MCom +snpp 444/tcp # Simple Network Paging Protocol +snpp 444/udp # Simple Network Paging Protocol +saft 487/tcp # Simple Asynchronous File Transfer +saft 487/udp # Simple Asynchronous File Transfer +npmp-local 610/tcp dqs313_qmaster # npmp-local / DQS +npmp-local 610/udp dqs313_qmaster # npmp-local / DQS +npmp-gui 611/tcp dqs313_execd # npmp-gui / DQS +npmp-gui 611/udp dqs313_execd # npmp-gui / DQS +hmmp-ind 612/tcp dqs313_intercell# HMMP Indication / DQS +hmmp-ind 612/udp dqs313_intercell# HMMP Indication / DQS +# +# UNIX specific services +# +exec 512/tcp +biff 512/udp comsat +login 513/tcp +who 513/udp whod +shell 514/tcp cmd # no passwords used +syslog 514/udp +printer 515/tcp spooler # line printer spooler +talk 517/udp +ntalk 518/udp +route 520/udp router routed # RIP +timed 525/udp timeserver +tempo 526/tcp newdate +courier 530/tcp rpc +conference 531/tcp chat +netnews 532/tcp readnews +netwall 533/udp # -for emergency broadcasts +uucp 540/tcp uucpd # uucp daemon +afpovertcp 548/tcp # AFP over TCP +afpovertcp 548/udp # AFP over TCP +remotefs 556/tcp rfs_server rfs # Brunhoff remote filesystem +klogin 543/tcp # Kerberized `rlogin' (v5) +kshell 544/tcp krcmd # Kerberized `rsh' (v5) +kerberos-adm 749/tcp # Kerberos `kadmin' (v5) +# +webster 765/tcp # Network dictionary +webster 765/udp +# +# From ``Assigned Numbers'': +# +#> The Registered Ports are not controlled by the IANA and on most systems +#> can be used by ordinary user processes or programs executed by ordinary +#> users. +# +#> Ports are used in the TCP [45,106] to name the ends of logical +#> connections which carry long term conversations. For the purpose of +#> providing services to unknown callers, a service contact port is +#> defined. This list specifies the port used by the server process as its +#> contact port. While the IANA can not control uses of these ports it +#> does register or list uses of these ports as a convienence to the +#> community. +# +nfsdstatus 1110/tcp +nfsd-keepalive 1110/udp + +ingreslock 1524/tcp +ingreslock 1524/udp +prospero-np 1525/tcp # Prospero non-privileged +prospero-np 1525/udp +datametrics 1645/tcp old-radius # datametrics / old radius entry +datametrics 1645/udp old-radius # datametrics / old radius entry +sa-msg-port 1646/tcp old-radacct # sa-msg-port / old radacct entry +sa-msg-port 1646/udp old-radacct # sa-msg-port / old radacct entry +radius 1812/tcp # Radius +radius 1812/udp # Radius +radacct 1813/tcp # Radius Accounting +radacct 1813/udp # Radius Accounting +nfsd 2049/tcp nfs +nfsd 2049/udp nfs +cvspserver 2401/tcp # CVS client/server operations +cvspserver 2401/udp # CVS client/server operations +mysql 3306/tcp # MySQL +mysql 3306/udp # MySQL +rfe 5002/tcp # Radio Free Ethernet +rfe 5002/udp # Actually uses UDP only +cfengine 5308/tcp # CFengine +cfengine 5308/udp # CFengine +bbs 7000/tcp # BBS service +# +# +# Kerberos (Project Athena/MIT) services +# Note that these are for Kerberos v4, and are unofficial. Sites running +# v4 should uncomment these and comment out the v5 entries above. +# +kerberos4 750/udp kerberos-iv kdc # Kerberos (server) udp +kerberos4 750/tcp kerberos-iv kdc # Kerberos (server) tcp +kerberos_master 751/udp # Kerberos authentication +kerberos_master 751/tcp # Kerberos authentication +passwd_server 752/udp # Kerberos passwd server +krb_prop 754/tcp # Kerberos slave propagation +krbupdate 760/tcp kreg # Kerberos registration +kpasswd 761/tcp kpwd # Kerberos "passwd" +kpop 1109/tcp # Pop with Kerberos +knetd 2053/tcp # Kerberos de-multiplexor +zephyr-srv 2102/udp # Zephyr server +zephyr-clt 2103/udp # Zephyr serv-hm connection +zephyr-hm 2104/udp # Zephyr hostmanager +eklogin 2105/tcp # Kerberos encrypted rlogin +# +# Unofficial but necessary (for NetBSD) services +# +supfilesrv 871/tcp # SUP server +supfiledbg 1127/tcp # SUP debugging +# +# Datagram Delivery Protocol services +# +rtmp 1/ddp # Routing Table Maintenance Protocol +nbp 2/ddp # Name Binding Protocol +echo 4/ddp # AppleTalk Echo Protocol +zip 6/ddp # Zone Information Protocol +# +# Services added for the Debian GNU/Linux distribution +poppassd 106/tcp # Eudora +poppassd 106/udp # Eudora +mailq 174/tcp # Mailer transport queue for Zmailer +mailq 174/tcp # Mailer transport queue for Zmailer +omirr 808/tcp omirrd # online mirror +omirr 808/udp omirrd # online mirror +rmtcfg 1236/tcp # Gracilis Packeten remote config server +xtel 1313/tcp # french minitel +coda_opcons 1355/udp # Coda opcons (Coda fs) +coda_venus 1363/udp # Coda venus (Coda fs) +coda_auth 1357/udp # Coda auth (Coda fs) +coda_udpsrv 1359/udp # Coda udpsrv (Coda fs) +coda_filesrv 1361/udp # Coda filesrv (Coda fs) +codacon 1423/tcp venus.cmu # Coda Console (Coda fs) +coda_aux1 1431/tcp # coda auxiliary service (Coda fs) +coda_aux1 1431/udp # coda auxiliary service (Coda fs) +coda_aux2 1433/tcp # coda auxiliary service (Coda fs) +coda_aux2 1433/udp # coda auxiliary service (Coda fs) +coda_aux3 1435/tcp # coda auxiliary service (Coda fs) +coda_aux3 1435/udp # coda auxiliary service (Coda fs) +cfinger 2003/tcp # GNU Finger +afbackup 2988/tcp # Afbackup system +afbackup 2988/udp # Afbackup system +icp 3130/tcp # Internet Cache Protocol (Squid) +icp 3130/udp # Internet Cache Protocol (Squid) +postgres 5432/tcp # POSTGRES +postgres 5432/udp # POSTGRES +fax 4557/tcp # FAX transmission service (old) +hylafax 4559/tcp # HylaFAX client-server protocol (new) +noclog 5354/tcp # noclogd with TCP (nocol) +noclog 5354/udp # noclogd with UDP (nocol) +hostmon 5355/tcp # hostmon uses TCP (nocol) +hostmon 5355/udp # hostmon uses TCP (nocol) +ircd 6667/tcp # Internet Relay Chat +ircd 6667/udp # Internet Relay Chat +webcache 8080/tcp # WWW caching service +webcache 8080/udp # WWW caching service +tproxy 8081/tcp # Transparent Proxy +tproxy 8081/udp # Transparent Proxy +mandelspawn 9359/udp mandelbrot # network mandelbrot +amanda 10080/udp # amanda backup services +amandaidx 10082/tcp # amanda backup services +amidxtape 10083/tcp # amanda backup services +isdnlog 20011/tcp # isdn logging system +isdnlog 20011/udp # isdn logging system +vboxd 20012/tcp # voice box system +vboxd 20012/udp # voice box system +binkp 24554/tcp # Binkley +binkp 24554/udp # Binkley +asp 27374/tcp # Address Search Protocol +asp 27374/udp # Address Search Protocol +tfido 60177/tcp # Ifmail +tfido 60177/udp # Ifmail +fido 60179/tcp # Ifmail +fido 60179/udp # Ifmail + +# Local services + diff --git a/package/skeleton/system/skeleton/etc/shadow b/package/skeleton/system/skeleton/etc/shadow new file mode 100644 index 0000000..37de977 --- /dev/null +++ b/package/skeleton/system/skeleton/etc/shadow @@ -0,0 +1,9 @@ +root:::::::: +daemon:*::::::: +bin:*::::::: +sys:*::::::: +sync:*::::::: +mail:*::::::: +www-data:*::::::: +operator:*::::::: +nobody:*::::::: diff --git a/package/skeleton/system/skeleton/media/.empty b/package/skeleton/system/skeleton/media/.empty new file mode 100644 index 0000000..e69de29 diff --git a/package/skeleton/system/skeleton/mnt/.empty b/package/skeleton/system/skeleton/mnt/.empty new file mode 100644 index 0000000..e69de29 diff --git a/package/skeleton/system/skeleton/opt/.empty b/package/skeleton/system/skeleton/opt/.empty new file mode 100644 index 0000000..e69de29 diff --git a/package/skeleton/system/skeleton/proc/.empty b/package/skeleton/system/skeleton/proc/.empty new file mode 100644 index 0000000..e69de29 diff --git a/package/skeleton/system/skeleton/root/.empty b/package/skeleton/system/skeleton/root/.empty new file mode 100644 index 0000000..e69de29 diff --git a/package/skeleton/system/skeleton/run/lock/.empty b/package/skeleton/system/skeleton/run/lock/.empty new file mode 100644 index 0000000..e69de29 diff --git a/package/skeleton/system/skeleton/sys/.empty b/package/skeleton/system/skeleton/sys/.empty new file mode 100644 index 0000000..e69de29 diff --git a/package/skeleton/system/skeleton/tmp/.empty b/package/skeleton/system/skeleton/tmp/.empty new file mode 100644 index 0000000..e69de29 diff --git a/package/skeleton/system/skeleton/usr/bin/.empty b/package/skeleton/system/skeleton/usr/bin/.empty new file mode 100644 index 0000000..e69de29 diff --git a/package/skeleton/system/skeleton/usr/lib/.empty b/package/skeleton/system/skeleton/usr/lib/.empty new file mode 100644 index 0000000..e69de29 diff --git a/package/skeleton/system/skeleton/usr/sbin/.empty b/package/skeleton/system/skeleton/usr/sbin/.empty new file mode 100644 index 0000000..e69de29 diff --git a/package/target-finalize/ifupdown-scripts/S40network b/package/target-finalize/ifupdown-scripts/S40network new file mode 100644 index 0000000..642c501 --- /dev/null +++ b/package/target-finalize/ifupdown-scripts/S40network @@ -0,0 +1,30 @@ +#!/bin/sh +# +# Start the network.... +# + +# Debian ifupdown needs the /run/network lock directory +mkdir -p /run/network + +case "$1" in + start) + printf "Starting network: " + /sbin/ifup -a + [ $? = 0 ] && echo "OK" || echo "FAIL" + ;; + stop) + printf "Stopping network: " + /sbin/ifdown -a + [ $? = 0 ] && echo "OK" || echo "FAIL" + ;; + restart|reload) + "$0" stop + "$0" start + ;; + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 +esac + +exit $? + diff --git a/package/target-finalize/ifupdown-scripts/network/if-down.d/.empty b/package/target-finalize/ifupdown-scripts/network/if-down.d/.empty new file mode 100644 index 0000000..e69de29 diff --git a/package/target-finalize/ifupdown-scripts/network/if-post-down.d/.empty b/package/target-finalize/ifupdown-scripts/network/if-post-down.d/.empty new file mode 100644 index 0000000..e69de29 diff --git a/package/target-finalize/ifupdown-scripts/network/if-pre-up.d/wait_iface b/package/target-finalize/ifupdown-scripts/network/if-pre-up.d/wait_iface new file mode 100755 index 0000000..ebccff2 --- /dev/null +++ b/package/target-finalize/ifupdown-scripts/network/if-pre-up.d/wait_iface @@ -0,0 +1,21 @@ +#!/bin/sh + +# In case we have a slow-to-appear interface (e.g. eth-over-USB), +# and we need to configure it, wait until it appears, but not too +# long either. IF_WAIT_DELAY is in seconds. + +if [ "${IF_WAIT_DELAY}" -a ! -e "/sys/class/net/${IFACE}" ]; then + printf "Waiting for interface %s to appear" "${IFACE}" + while [ ${IF_WAIT_DELAY} -gt 0 ]; do + if [ -e "/sys/class/net/${IFACE}" ]; then + printf "\n" + exit 0 + fi + sleep 1 + printf "." + : $((IF_WAIT_DELAY -= 1)) + done + printf " timeout!\n" + exit 1 +fi + diff --git a/package/target-finalize/ifupdown-scripts/network/if-up.d/.empty b/package/target-finalize/ifupdown-scripts/network/if-up.d/.empty new file mode 100644 index 0000000..e69de29 diff --git a/package/target-finalize/ifupdown-scripts/nfs_check b/package/target-finalize/ifupdown-scripts/nfs_check new file mode 100755 index 0000000..dfa0cbf --- /dev/null +++ b/package/target-finalize/ifupdown-scripts/nfs_check @@ -0,0 +1,20 @@ +#!/bin/sh + +# This allows NFS booting to work while also being able to configure +# the network interface via DHCP when not NFS booting. Otherwise, a +# NFS booted system will likely hang during DHCP configuration. + +# Attempting to configure the network interface used for NFS will +# initially bring that network down. Since the root filesystem is +# accessed over this network, the system hangs. + +# This script is run by ifup and will attempt to detect if a NFS root +# mount uses the interface to be configured (IFACE), and if so does +# not configure it. This should allow the same build to be disk/flash +# booted or NFS booted. + +nfsip=`sed -n '/^[^ ]*:.* \/ nfs.*[ ,]addr=\([0-9.]\+\).*/s//\1/p' /proc/mounts` +if [ -n "$nfsip" ] && ip route get to "$nfsip" | grep -q "dev $IFACE"; then + echo Skipping $IFACE, used for NFS from $nfsip + exit 1 +fi diff --git a/package/target-finalize/initscripts/init.d/rcK b/package/target-finalize/initscripts/init.d/rcK new file mode 100755 index 0000000..59e9c54 --- /dev/null +++ b/package/target-finalize/initscripts/init.d/rcK @@ -0,0 +1,27 @@ +#!/bin/sh + + +# Stop all init scripts in /etc/init.d +# executing them in reversed numerical order. +# +for i in $(ls -r /etc/init.d/S??*) ;do + + # Ignore dangling symlinks (if any). + [ ! -f "$i" ] && continue + + case "$i" in + *.sh) + # Source shell script for speed. + ( + trap - INT QUIT TSTP + set stop + . $i + ) + ;; + *) + # No sh extension, so fork subprocess. + $i stop + ;; + esac +done + diff --git a/package/target-finalize/initscripts/init.d/rcS b/package/target-finalize/initscripts/init.d/rcS new file mode 100755 index 0000000..de41153 --- /dev/null +++ b/package/target-finalize/initscripts/init.d/rcS @@ -0,0 +1,27 @@ +#!/bin/sh + + +# Start all init scripts in /etc/init.d +# executing them in numerical order. +# +for i in /etc/init.d/S??* ;do + + # Ignore dangling symlinks (if any). + [ ! -f "$i" ] && continue + + case "$i" in + *.sh) + # Source shell script for speed. + ( + trap - INT QUIT TSTP + set start + . $i + ) + ;; + *) + # No sh extension, so fork subprocess. + $i start + ;; + esac +done + diff --git a/package/target-finalize/make.sh b/package/target-finalize/make.sh new file mode 100755 index 0000000..f216e80 --- /dev/null +++ b/package/target-finalize/make.sh @@ -0,0 +1,95 @@ +#!/usr/bin/bash +source $(dirname "$0")/../common.sh + +PKGNAME=target-finalize + +mkdir -p ${TARGET_DIR}/etc + +echo ">>> Installing ifupdown-scripts" +/usr/bin/install -m 0755 -D ${PROJECT_DIR}/package/${PKGNAME}/ifupdown-scripts/nfs_check ${TARGET_DIR}/etc/network/nfs_check +rsync -a --ignore-times --exclude .svn --exclude .git --exclude .hg --exclude .bzr --exclude CVS --chmod=u=rwX,go=rX --exclude .empty --exclude '*~' ${PROJECT_DIR}/package/${PKGNAME}/ifupdown-scripts/network/ ${TARGET_DIR}/etc/network/ +/usr/bin/install -D -m 0755 ${PROJECT_DIR}/package/${PKGNAME}/ifupdown-scripts/S40network ${TARGET_DIR}/etc/init.d/S40network +echo "# interface file" > ${TARGET_DIR}/etc/network/interfaces +( echo ; echo "auto lo"; echo "iface lo inet loopback"; ) >> ${TARGET_DIR}/etc/network/interfaces +( echo ; echo "auto eth0"; echo "iface eth0 inet dhcp"; echo " pre-up /etc/network/nfs_check"; echo " wait-delay 15"; echo " hostname \$(hostname)"; ) >> ${TARGET_DIR}/etc/network/interfaces + +echo ">>> Installing initscripts" +mkdir -p ${TARGET_DIR}/etc/init.d +/usr/bin/install -D -m 0755 ${PROJECT_DIR}/package/${PKGNAME}/initscripts/init.d/* ${TARGET_DIR}/etc/init.d/ + +echo ">>> Installing urandom-scripts" +/usr/bin/install -D -m 0755 ${PROJECT_DIR}/package/${PKGNAME}/urandom-scripts/S01seedrng ${TARGET_DIR}/etc/init.d/S01seedrng + +echo ">>> Finalizing target directory" +/usr/bin/sed -i -e '/# GENERIC_SERIAL$/s~^.*#~console::respawn:/sbin/getty -L console 0 vt100 #~' ${TARGET_DIR}/etc/inittab +/usr/bin/sed -i -e '/^#.*-o remount,rw \/$/s~^#\+~~' ${TARGET_DIR}/etc/inittab +if grep -q CONFIG_ASH=y ${BUILD_DIR}/busybox-1.37.0/.config; then grep -qsE '^/bin/ash$' ${TARGET_DIR}/etc/shells || echo "/bin/ash" >> ${TARGET_DIR}/etc/shells; fi +if grep -q CONFIG_HUSH=y ${BUILD_DIR}/busybox-1.37.0/.config; then grep -qsE '^/bin/hush$' ${TARGET_DIR}/etc/shells || echo "/bin/hush" >> ${TARGET_DIR}/etc/shells; fi +grep -qsE '^/bin/sh$' ${TARGET_DIR}/etc/shells || echo "/bin/sh" >> ${TARGET_DIR}/etc/shells +echo "buildlinux" > ${TARGET_DIR}/etc/hostname +/usr/bin/sed -i -e '$a \127.0.1.1\tbuildlinux' -e '/^127.0.1.1/d' ${TARGET_DIR}/etc/hosts +echo "Welcome to Build Linux System From Scratch" > ${TARGET_DIR}/etc/issue +/usr/bin/sed -i -e s,^root:[^:]*:,root::, ${TARGET_DIR}/etc/shadow +if [ -x ${TARGET_DIR}/sbin/swapon -a -x ${TARGET_DIR}/sbin/swapoff ]; then + /usr/bin/sed -i -e '/^#.*\/sbin\/swap/s/^#\+[[:blank:]]*//' ${TARGET_DIR}/etc/inittab; +else + /usr/bin/sed -i -e '/^[^#].*\/sbin\/swap/s/^/#/' ${TARGET_DIR}/etc/inittab; +fi +if test -d ${TARGET_DIR}/lib/modules/6.12.47 && grep -q "CONFIG_MODULES=y" ${BUILD_DIR}/linux-6.12.47/.config; then + ${HOST_DIR}/sbin/depmod -a -b ${TARGET_DIR} 6.12.47; +fi +printf '%s\n' C en_US locale-archive > ${BUILD_DIR}/locales.nopurge +for dir in ${TARGET_DIR}/usr/share/locale ${TARGET_DIR}/usr/share/X11/locale ${TARGET_DIR}/usr/lib/locale; do + if [ ! -d $dir ]; then continue; fi; + for langdir in $dir/*; do + if [ -e "${langdir}" ]; then + grep -qx "${langdir##*/}" ${BUILD_DIR}/locales.nopurge || rm -rf $langdir; + fi + done; +done +if [ -d ${TARGET_DIR}/usr/share/X11/locale ]; then + for lang in C en_US; do + if [ -f ${TARGET_DIR}/usr/share/X11/locale/$lang/XLC_LOCALE ]; then + echo "$lang/XLC_LOCALE: $lang"; + fi + done > ${TARGET_DIR}/usr/share/X11/locale/locale.dir; +fi +rm -rf ${TARGET_DIR}/usr/include ${TARGET_DIR}/usr/share/aclocal \ + ${TARGET_DIR}/usr/lib/pkgconfig ${TARGET_DIR}/usr/share/pkgconfig \ + ${TARGET_DIR}/usr/lib/cmake ${TARGET_DIR}/usr/share/cmake \ + ${TARGET_DIR}/usr/lib/rpm ${TARGET_DIR}/usr/doc +find ${TARGET_DIR}/usr/{lib,share}/ -name '*.cmake' -print0 | xargs -0 rm -f +find ${TARGET_DIR}/lib/ ${TARGET_DIR}/usr/lib/ ${TARGET_DIR}/usr/libexec/ \ + \( -name '*.a' -o -name '*.la' -o -name '*.prl' \) -print0 | xargs -0 rm -f +rm -rf ${TARGET_DIR}/usr/share/gdb +rm -rf ${TARGET_DIR}/usr/share/bash-completion +rm -rf ${TARGET_DIR}/etc/bash_completion.d +rm -rf ${TARGET_DIR}/usr/share/zsh +rm -rf ${TARGET_DIR}/usr/man ${TARGET_DIR}/usr/share/man +rm -rf ${TARGET_DIR}/usr/info ${TARGET_DIR}/usr/share/info +rm -rf ${TARGET_DIR}/usr/doc ${TARGET_DIR}/usr/share/doc +rm -rf ${TARGET_DIR}/usr/share/gtk-doc +rmdir ${TARGET_DIR}/usr/share 2>/dev/null || true +rm -rf ${TARGET_DIR}/lib/debug ${TARGET_DIR}/usr/lib/debug +find ${TARGET_DIR} -type f \( -perm /111 -o -name '*.so*' \) -not \( -name 'libpthread*.so*' -o -name 'ld-*.so*' -o -name '*.ko' \) -print0 | xargs -0 ${CROSS_COMPILE}strip --remove-section=.comment --remove-section=.note 2>/dev/null || true +find ${TARGET_DIR} \( -name 'ld-*.so*' -o -name 'libpthread*.so*' \) -print0 | xargs -0 -r ${CROSS_COMPILE}strip --remove-section=.comment --remove-section=.note --strip-debug 2>/dev/null || true +test -f ${TARGET_DIR}/etc/ld.so.conf && \ + { echo "ERROR: we shouldn't have a /etc/ld.so.conf file"; exit 1; } || true +test -d ${TARGET_DIR}/etc/ld.so.conf.d && \ + { echo "ERROR: we shouldn't have a /etc/ld.so.conf.d directory"; exit 1; } || true +( \ + echo "NAME=BuildLinux"; \ + echo "VERSION=1"; \ + echo "ID=buildlinux"; \ + echo "VERSION_ID=2025.08.1"; \ + echo "PRETTY_NAME=\"Build Linux System From Scratch\"" \ +) > ${TARGET_DIR}/usr/lib/os-release +ln -sf ../usr/lib/os-release ${TARGET_DIR}/etc + +echo ">>> Sanitizing RPATH in target tree" +PATCHELF=${HOST_DIR}/bin/patchelf \ +PARALLEL_JOBS=${MAXNUM_CPUS} \ +PER_PACKAGE_DIR=${OUTPUT_DIR}/per-package \ +${PROJECT_DIR}/support/scripts/fix-rpath target + +touch ${TARGET_DIR}/usr \ No newline at end of file diff --git a/package/target-finalize/urandom-scripts/S01seedrng b/package/target-finalize/urandom-scripts/S01seedrng new file mode 100644 index 0000000..0fea0be --- /dev/null +++ b/package/target-finalize/urandom-scripts/S01seedrng @@ -0,0 +1,40 @@ +#! /bin/sh +# +# Preserve the random seed between reboots. See urandom(4). +# +# This script can be called multiple times during operation (e.g. with +# "reload" argument) to refresh the seed. + +# The following arguments can be added to SEEDRNG_ARGS in +# /etc/default/seedrng: +# --seed-dir=/path/to/seed/directory +# Path to the directory where the seed and the lock files are stored. +# for optimal operation, this should be a persistent, writeable +# location. Default is /var/lib/seedrng +# +# --skip-credit +# Set this to true only if you do not want seed files to actually +# credit the RNG, for example if you plan to replicate this file +# system image and do not have the wherewithal to first delete the +# contents of /var/lib/seedrng. +# +# Example: +# SEEDRNG_ARGS="--seed-dir=/data/seedrng --skip-credit" +# + +DAEMON="seedrng" +SEEDRNG_ARGS="" + +# shellcheck source=/dev/null +[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON" + +case "$1" in + start|stop|restart|reload) + # Never fail, as this isn't worth making a fuss + # over if it doesn't go as planned. + # shellcheck disable=SC2086 # we need the word splitting + seedrng $SEEDRNG_ARGS || true;; + *) + echo "Usage: $0 {start|stop|restart|reload}" + exit 1 +esac diff --git a/package/toolchain/make.sh b/package/toolchain/make.sh new file mode 100755 index 0000000..1f7bbe7 --- /dev/null +++ b/package/toolchain/make.sh @@ -0,0 +1,63 @@ +#!/usr/bin/bash +source $(dirname "$0")/../common.sh + +PKGNAME=toolchain +PKGVERSION= +PKGSOURCE_DIR= +PKGSOURCE= + +PKGBUILDNAME=${PKGNAME} +PKGBUILD_DIR=${BUILD_DIR}/${PKGBUILDNAME} + +echo "----> Building ${PKGBUILDNAME} ..." + +stamp_downloaded + +stamp_extracted + +stamp_patched + +stamp_configured + +stamp_built + +step_start install-target +# /etc/nsswitch.conf 的全称是 Name Service Switch configuration file(名称服务切换配置文件)。 +# 它的主要作用是告诉操作系统,当需要查询某类信息(比如用户名、主机名、组信息等)时, +# 应该按照什么顺序、从哪些数据源去查找。可以把它看作是一个 “查询路由表” 或 “信息查找指南” +# 至于为何会存在这个需求,是因为在现代操作系统中,同一种信息可能存在于多个地方。 +# 例如,用户名和用户ID(UID)可能存在于:本地文件:如 /etc/passwd, /etc/group;或者 +# 网络服务:如 LDAP(轻型目录访问协议)、NIS(网络信息服务)、Active Directory(AD); +# 或者 DNS(域名系统):用于主机名解析 +# 当系统运行一个命令(如 ls -l,它会显示文件所有者用户名)或一个程序调用一个函数 +# (如 getpwuid() 来通过UID查找用户名)时,系统需要知道:先查哪里? 是先查本地文件还是先查网络服务? +# 如果第一个源查不到或出错了,怎么办? 是继续查下一个源,还是直接报错?nsswitch.conf 就是为 +# 了解决这些问题而生的。 +# 这个文件的内容通常由很多行组成,每行对应一种信息的查询配置。其基本格式是: +# <数据库类型>: <查找顺序> +# 例子:passwd: files systemd +# 当需要查询用户信息时,首先,查询本地文件 /etc/passwd (files),如果没找到,再去 systemd 的动态用户库中查找。 +# 更多例子不再赘述。 +# 注意这个 Name Service Switch 服务(NSS)是由 glibc 提供的,由一系列系统数据库查询函数组成,譬如: +# getpwnam(), getpwuid() - 获取用户信息(/etc/passwd) +# getgrnam(), getgrgid() - 获取用户组信息(/etc/group) +# gethostbyname(), getaddrinfo() - 获取主机名和IP地址信息(/etc/hosts, DNS) +# getservbyname() - 获取网络服务信息(/etc/services) +# 该服务的核心组件包括: +# - 配置文件:/etc/nsswitch.conf +# - 一系列共享库模块:位于/lib或/lib64目录下,名称通常为libnss_*.so.2(例如 libnss_files.so.2, +# libnss_dns.so.2, libnss_ldap.so.2)。 +# 由以上分析,我们可以得知,由于 nsswitch.conf 主要被 glibc 使用,所以我们将其视为工具链的一部分 +# 如果我们工具链使用的是其他 C 库(如 uClibc、musl),这个文件通常不是必需的 +# 构建 glibc 后会生成 nsswitch.conf 文件,但我们没有直接用,而是提供了一个自己定义的版本。 +# 这里的 nsswitch.conf 是一个 默认的安全配置。这个默认配置通常比较简单,例如对于 hosts 数据库, +# 配置可能是 files dns,意味着先查找 /etc/hosts 文件,再使用 DNS 查询 +# 同时它只在 目标系统 /etc/ 目录下尚不存在 nsswitch.conf 时 才拷贝默认文件, +if [ ! -f "${TARGET_DIR}/etc/nsswitch.conf" ]; then + /usr/bin/install -D -m 0644 ${PROJECT_DIR}/package/glibc/nsswitch.conf ${TARGET_DIR}/etc/nsswitch.conf +fi +step_end install-target + +stamp_installed + +echo "<---- ${PKGBUILDNAME} build complete." diff --git a/package/util-linux/make-host.sh b/package/util-linux/make-host.sh new file mode 100755 index 0000000..7ed3315 --- /dev/null +++ b/package/util-linux/make-host.sh @@ -0,0 +1,39 @@ +#!/usr/bin/bash +source $(dirname "$0")/../common.sh + +PKGNAME=util-linux +PKGVERSION=2.41.1 +PKGSOURCE_DIR=util-linux +PKGSOURCE=util-linux-2.41.1.tar.xz +PKGURL=http://mirrors.ustc.edu.cn/kernel.org/linux/utils/util-linux/v2.41/util-linux-2.41.1.tar.xz + +PKGBUILDNAME=host-${PKGNAME} +PKGBUILD_DIR=${BUILD_DIR}/${PKGBUILDNAME}-${PKGVERSION} + +echo "----> Building ${PKGBUILDNAME} ..." + +stamp_downloaded + +step_start extract +mkdir -p ${PKGBUILD_DIR} +xzcat ${DL_DIR}/${PKGSOURCE_DIR}/${PKGSOURCE} | tar --strip-components=1 -C ${PKGBUILD_DIR} -xf - +chmod -R +rw ${PKGBUILD_DIR} +step_end extract + +stamp_patched autotools + +step_start configure +(cd ${PKGBUILD_DIR} && rm -rf config.cache; eval "${HOST_CONFIGURE_OPTS} CONFIG_SITE=/dev/null ./configure --prefix=\"${HOST_DIR}\" --sysconfdir=\"${HOST_DIR}/etc\" --localstatedir=\"${HOST_DIR}/var\" --enable-shared --disable-static --disable-gtk-doc --disable-gtk-doc-html --disable-doc --disable-docs --disable-documentation --disable-debug --with-xmlto=no --with-fop=no --disable-nls --disable-dependency-tracking --without-systemd --with-systemdsystemunitdir=no --without-python --enable-libblkid --enable-libmount --enable-libuuid --without-libmagic --without-ncurses --without-ncursesw --without-tinfo --disable-raw --disable-makeinstall-chown --disable-agetty --disable-chfn-chsh --disable-chmem --disable-ipcmk --disable-liblastlog2 --disable-login --disable-lsfd --disable-lslogins --disable-mesg --disable-more --disable-newgrp --disable-nologin --disable-nsenter --disable-pg --disable-rfkill --disable-runuser --disable-schedutils --disable-setpriv --disable-setterm --disable-su --disable-sulogin --disable-tunelp --disable-ul --disable-unshare --disable-uuidd --disable-vipw --disable-wall --disable-wdctl --disable-write --disable-zramctl") +step_end configure + +step_start build +eval "${HOST_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} -C ${PKGBUILD_DIR}" +step_end build + +step_start install-host +eval "${HOST_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} install -C ${PKGBUILD_DIR}" +step_end install-host + +stamp_installed + +echo "<---- ${PKGBUILDNAME} build complete." diff --git a/qq-group.png b/qq-group.png new file mode 100644 index 0000000..7d540fb Binary files /dev/null and b/qq-group.png differ diff --git a/slides/ch00-foreword.pdf b/slides/ch00-foreword.pdf new file mode 100644 index 0000000..d90885b Binary files /dev/null and b/slides/ch00-foreword.pdf differ diff --git a/slides/ch01-linux-system-overview.pdf b/slides/ch01-linux-system-overview.pdf new file mode 100644 index 0000000..21d2427 Binary files /dev/null and b/slides/ch01-linux-system-overview.pdf differ diff --git a/slides/ch02-build-system.pdf b/slides/ch02-build-system.pdf new file mode 100644 index 0000000..675b369 Binary files /dev/null and b/slides/ch02-build-system.pdf differ diff --git a/slides/ch03-before-building.pdf b/slides/ch03-before-building.pdf new file mode 100644 index 0000000..c360e06 Binary files /dev/null and b/slides/ch03-before-building.pdf differ diff --git a/slides/ch04-hosttools.pdf b/slides/ch04-hosttools.pdf new file mode 100644 index 0000000..618bf8e Binary files /dev/null and b/slides/ch04-hosttools.pdf differ diff --git a/slides/ch05-cross-toolchain.pdf b/slides/ch05-cross-toolchain.pdf new file mode 100644 index 0000000..5a2434b Binary files /dev/null and b/slides/ch05-cross-toolchain.pdf differ diff --git a/slides/ch06-opensbi.pdf b/slides/ch06-opensbi.pdf new file mode 100644 index 0000000..8c79529 Binary files /dev/null and b/slides/ch06-opensbi.pdf differ diff --git a/slides/ch07-linux.pdf b/slides/ch07-linux.pdf new file mode 100644 index 0000000..86e9f8f Binary files /dev/null and b/slides/ch07-linux.pdf differ diff --git a/slides/ch08-filesystem.pdf b/slides/ch08-filesystem.pdf new file mode 100644 index 0000000..55d76b8 Binary files /dev/null and b/slides/ch08-filesystem.pdf differ diff --git a/source.sh b/source.sh new file mode 100755 index 0000000..e1b73ad --- /dev/null +++ b/source.sh @@ -0,0 +1,30 @@ +#!/usr/bin/bash + +export ONLY_DOWNLOAD=y + +./package/bison/make-host.sh || exit 1 +./package/gcc/make-final.sh || exit 1 +./package/glibc/make.sh || exit 1 +./package/m4/make-host.sh || exit 1 +./package/gawk/make-host.sh || exit 1 +./package/binutils/make-host.sh || exit 1 +./package/gmp/make-host.sh || exit 1 +./package/autoconf/make-host.sh || exit 1 +./package/libtool/make-host.sh || exit 1 +./package/automake/make-host.sh || exit 1 +./package/mpc/make-host.sh || exit 1 +./package/mpfr/make-host.sh || exit 1 +./package/linux/make.sh || exit 1 +./package/busybox/make.sh || exit 1 +./package/e2fsprogs/make-host.sh || exit 1 +./package/pkgconf/make-host.sh || exit 1 +./package/util-linux/make-host.sh || exit 1 +./package/libzlib/make-host.sh || exit 1 +./package/kmod/make-host.sh || exit 1 +./package/patchelf/make-host.sh || exit 1 +./package/opensbi/make.sh || exit 1 +./package/acl/make-host.sh || exit 1 +./package/attr/make-host.sh || exit 1 +./package/fakeroot/make-host.sh || exit 1 +./package/flex/make-host.sh || exit 1 +./package/gettext-tiny/make-host.sh || exit 1 diff --git a/support/gnuconfig/config.guess b/support/gnuconfig/config.guess new file mode 100755 index 0000000..f6d217a --- /dev/null +++ b/support/gnuconfig/config.guess @@ -0,0 +1,1812 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright 1992-2024 Free Software Foundation, Inc. + +# shellcheck disable=SC2006,SC2268 # see below for rationale + +timestamp='2024-01-01' + +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see . +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that +# program. This Exception is an additional permission under section 7 +# of the GNU General Public License, version 3 ("GPLv3"). +# +# Originally written by Per Bothner; maintained since 2000 by Ben Elliston. +# +# You can get the latest version of this script from: +# https://git.savannah.gnu.org/cgit/config.git/plain/config.guess +# +# Please send patches to . + + +# The "shellcheck disable" line above the timestamp inhibits complaints +# about features and limitations of the classic Bourne shell that were +# superseded or lifted in POSIX. However, this script identifies a wide +# variety of pre-POSIX systems that do not have POSIX shells at all, and +# even some reasonably current systems (Solaris 10 as case-in-point) still +# have a pre-POSIX /bin/sh. + + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] + +Output the configuration name of the system '$me' is run on. + +Options: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.guess ($timestamp) + +Originally written by Per Bothner. +Copyright 1992-2024 Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try '$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" >&2 + exit 1 ;; + * ) + break ;; + esac +done + +if test $# != 0; then + echo "$me: too many arguments$help" >&2 + exit 1 +fi + +# Just in case it came from the environment. +GUESS= + +# CC_FOR_BUILD -- compiler used by this script. Note that the use of a +# compiler to aid in system detection is discouraged as it requires +# temporary files to be created and, as you can see below, it is a +# headache to deal with in a portable fashion. + +# Historically, 'CC_FOR_BUILD' used to be named 'HOST_CC'. We still +# use 'HOST_CC' if defined, but it is deprecated. + +# Portable tmp directory creation inspired by the Autoconf team. + +tmp= +# shellcheck disable=SC2172 +trap 'test -z "$tmp" || rm -fr "$tmp"' 0 1 2 13 15 + +set_cc_for_build() { + # prevent multiple calls if $tmp is already set + test "$tmp" && return 0 + : "${TMPDIR=/tmp}" + # shellcheck disable=SC2039,SC3028 + { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir "$tmp" 2>/dev/null) ; } || + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir "$tmp" 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } + dummy=$tmp/dummy + case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in + ,,) echo "int x;" > "$dummy.c" + for driver in cc gcc c89 c99 ; do + if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then + CC_FOR_BUILD=$driver + break + fi + done + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; + esac +} + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi@noc.rutgers.edu 1994-08-24) +if test -f /.attbin/uname ; then + PATH=$PATH:/.attbin ; export PATH +fi + +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +case $UNAME_SYSTEM in +Linux|GNU|GNU/*) + LIBC=unknown + + set_cc_for_build + cat <<-EOF > "$dummy.c" + #if defined(__ANDROID__) + LIBC=android + #else + #include + #if defined(__UCLIBC__) + LIBC=uclibc + #elif defined(__dietlibc__) + LIBC=dietlibc + #elif defined(__GLIBC__) + LIBC=gnu + #elif defined(__LLVM_LIBC__) + LIBC=llvm + #else + #include + /* First heuristic to detect musl libc. */ + #ifdef __DEFINED_va_list + LIBC=musl + #endif + #endif + #endif + EOF + cc_set_libc=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` + eval "$cc_set_libc" + + # Second heuristic to detect musl libc. + if [ "$LIBC" = unknown ] && + command -v ldd >/dev/null && + ldd --version 2>&1 | grep -q ^musl; then + LIBC=musl + fi + + # If the system lacks a compiler, then just pick glibc. + # We could probably try harder. + if [ "$LIBC" = unknown ]; then + LIBC=gnu + fi + ;; +esac + +# Note: order is significant - the case branches are not exclusive. + +case $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in + *:NetBSD:*:*) + # NetBSD (nbsd) targets should (where applicable) match one or + # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, + # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently + # switched to ELF, *-*-netbsd* would select the old + # object file format. This provides both forward + # compatibility and a consistent mechanism for selecting the + # object file format. + # + # Note: NetBSD doesn't particularly care about the vendor + # portion of the name. We always set it to "unknown". + UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ + /sbin/sysctl -n hw.machine_arch 2>/dev/null || \ + /usr/sbin/sysctl -n hw.machine_arch 2>/dev/null || \ + echo unknown)` + case $UNAME_MACHINE_ARCH in + aarch64eb) machine=aarch64_be-unknown ;; + armeb) machine=armeb-unknown ;; + arm*) machine=arm-unknown ;; + sh3el) machine=shl-unknown ;; + sh3eb) machine=sh-unknown ;; + sh5el) machine=sh5le-unknown ;; + earmv*) + arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'` + endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'` + machine=${arch}${endian}-unknown + ;; + *) machine=$UNAME_MACHINE_ARCH-unknown ;; + esac + # The Operating System including object format, if it has switched + # to ELF recently (or will in the future) and ABI. + case $UNAME_MACHINE_ARCH in + earm*) + os=netbsdelf + ;; + arm*|i386|m68k|ns32k|sh3*|sparc|vax) + set_cc_for_build + if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ELF__ + then + # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). + # Return netbsd for either. FIX? + os=netbsd + else + os=netbsdelf + fi + ;; + *) + os=netbsd + ;; + esac + # Determine ABI tags. + case $UNAME_MACHINE_ARCH in + earm*) + expr='s/^earmv[0-9]/-eabi/;s/eb$//' + abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"` + ;; + esac + # The OS release + # Debian GNU/NetBSD machines have a different userland, and + # thus, need a distinct triplet. However, they do not need + # kernel version information, so it can be replaced with a + # suitable tag, in the style of linux-gnu. + case $UNAME_VERSION in + Debian*) + release='-gnu' + ;; + *) + release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2` + ;; + esac + # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: + # contains redundant information, the shorter form: + # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. + GUESS=$machine-${os}${release}${abi-} + ;; + *:Bitrig:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` + GUESS=$UNAME_MACHINE_ARCH-unknown-bitrig$UNAME_RELEASE + ;; + *:OpenBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` + GUESS=$UNAME_MACHINE_ARCH-unknown-openbsd$UNAME_RELEASE + ;; + *:SecBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/SecBSD.//'` + GUESS=$UNAME_MACHINE_ARCH-unknown-secbsd$UNAME_RELEASE + ;; + *:LibertyBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'` + GUESS=$UNAME_MACHINE_ARCH-unknown-libertybsd$UNAME_RELEASE + ;; + *:MidnightBSD:*:*) + GUESS=$UNAME_MACHINE-unknown-midnightbsd$UNAME_RELEASE + ;; + *:ekkoBSD:*:*) + GUESS=$UNAME_MACHINE-unknown-ekkobsd$UNAME_RELEASE + ;; + *:SolidBSD:*:*) + GUESS=$UNAME_MACHINE-unknown-solidbsd$UNAME_RELEASE + ;; + *:OS108:*:*) + GUESS=$UNAME_MACHINE-unknown-os108_$UNAME_RELEASE + ;; + macppc:MirBSD:*:*) + GUESS=powerpc-unknown-mirbsd$UNAME_RELEASE + ;; + *:MirBSD:*:*) + GUESS=$UNAME_MACHINE-unknown-mirbsd$UNAME_RELEASE + ;; + *:Sortix:*:*) + GUESS=$UNAME_MACHINE-unknown-sortix + ;; + *:Twizzler:*:*) + GUESS=$UNAME_MACHINE-unknown-twizzler + ;; + *:Redox:*:*) + GUESS=$UNAME_MACHINE-unknown-redox + ;; + mips:OSF1:*.*) + GUESS=mips-dec-osf1 + ;; + alpha:OSF1:*:*) + # Reset EXIT trap before exiting to avoid spurious non-zero exit code. + trap '' 0 + case $UNAME_RELEASE in + *4.0) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + ;; + *5.*) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` + ;; + esac + # According to Compaq, /usr/sbin/psrinfo has been available on + # OSF/1 and Tru64 systems produced since 1995. I hope that + # covers most systems running today. This code pipes the CPU + # types through head -n 1, so we only detect the type of CPU 0. + ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` + case $ALPHA_CPU_TYPE in + "EV4 (21064)") + UNAME_MACHINE=alpha ;; + "EV4.5 (21064)") + UNAME_MACHINE=alpha ;; + "LCA4 (21066/21068)") + UNAME_MACHINE=alpha ;; + "EV5 (21164)") + UNAME_MACHINE=alphaev5 ;; + "EV5.6 (21164A)") + UNAME_MACHINE=alphaev56 ;; + "EV5.6 (21164PC)") + UNAME_MACHINE=alphapca56 ;; + "EV5.7 (21164PC)") + UNAME_MACHINE=alphapca57 ;; + "EV6 (21264)") + UNAME_MACHINE=alphaev6 ;; + "EV6.7 (21264A)") + UNAME_MACHINE=alphaev67 ;; + "EV6.8CB (21264C)") + UNAME_MACHINE=alphaev68 ;; + "EV6.8AL (21264B)") + UNAME_MACHINE=alphaev68 ;; + "EV6.8CX (21264D)") + UNAME_MACHINE=alphaev68 ;; + "EV6.9A (21264/EV69A)") + UNAME_MACHINE=alphaev69 ;; + "EV7 (21364)") + UNAME_MACHINE=alphaev7 ;; + "EV7.9 (21364A)") + UNAME_MACHINE=alphaev79 ;; + esac + # A Pn.n version is a patched version. + # A Vn.n version is a released version. + # A Tn.n version is a released field test version. + # A Xn.n version is an unreleased experimental baselevel. + # 1.2 uses "1.2" for uname -r. + OSF_REL=`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` + GUESS=$UNAME_MACHINE-dec-osf$OSF_REL + ;; + Amiga*:UNIX_System_V:4.0:*) + GUESS=m68k-unknown-sysv4 + ;; + *:[Aa]miga[Oo][Ss]:*:*) + GUESS=$UNAME_MACHINE-unknown-amigaos + ;; + *:[Mm]orph[Oo][Ss]:*:*) + GUESS=$UNAME_MACHINE-unknown-morphos + ;; + *:OS/390:*:*) + GUESS=i370-ibm-openedition + ;; + *:z/VM:*:*) + GUESS=s390-ibm-zvmoe + ;; + *:OS400:*:*) + GUESS=powerpc-ibm-os400 + ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + GUESS=arm-acorn-riscix$UNAME_RELEASE + ;; + arm*:riscos:*:*|arm*:RISCOS:*:*) + GUESS=arm-unknown-riscos + ;; + SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) + GUESS=hppa1.1-hitachi-hiuxmpp + ;; + Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) + # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. + case `(/bin/universe) 2>/dev/null` in + att) GUESS=pyramid-pyramid-sysv3 ;; + *) GUESS=pyramid-pyramid-bsd ;; + esac + ;; + NILE*:*:*:dcosx) + GUESS=pyramid-pyramid-svr4 + ;; + DRS?6000:unix:4.0:6*) + GUESS=sparc-icl-nx6 + ;; + DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) + case `/usr/bin/uname -p` in + sparc) GUESS=sparc-icl-nx7 ;; + esac + ;; + s390x:SunOS:*:*) + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=$UNAME_MACHINE-ibm-solaris2$SUN_REL + ;; + sun4H:SunOS:5.*:*) + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=sparc-hal-solaris2$SUN_REL + ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=sparc-sun-solaris2$SUN_REL + ;; + i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) + GUESS=i386-pc-auroraux$UNAME_RELEASE + ;; + i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) + set_cc_for_build + SUN_ARCH=i386 + # If there is a compiler, see if it is configured for 64-bit objects. + # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. + # This test works for both compilers. + if test "$CC_FOR_BUILD" != no_compiler_found; then + if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -m64 -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + SUN_ARCH=x86_64 + fi + fi + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=$SUN_ARCH-pc-solaris2$SUN_REL + ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=sparc-sun-solaris3$SUN_REL + ;; + sun4*:SunOS:*:*) + case `/usr/bin/arch -k` in + Series*|S4*) + UNAME_RELEASE=`uname -v` + ;; + esac + # Japanese Language versions have a version number like '4.1.3-JL'. + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/'` + GUESS=sparc-sun-sunos$SUN_REL + ;; + sun3*:SunOS:*:*) + GUESS=m68k-sun-sunos$UNAME_RELEASE + ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3 + case `/bin/arch` in + sun3) + GUESS=m68k-sun-sunos$UNAME_RELEASE + ;; + sun4) + GUESS=sparc-sun-sunos$UNAME_RELEASE + ;; + esac + ;; + aushp:SunOS:*:*) + GUESS=sparc-auspex-sunos$UNAME_RELEASE + ;; + # The situation for MiNT is a little confusing. The machine name + # can be virtually everything (everything which is not + # "atarist" or "atariste" at least should have a processor + # > m68000). The system name ranges from "MiNT" over "FreeMiNT" + # to the lowercase version "mint" (or "freemint"). Finally + # the system name "TOS" denotes a system which is actually not + # MiNT. But MiNT is downward compatible to TOS, so this should + # be no problem. + atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) + GUESS=m68k-atari-mint$UNAME_RELEASE + ;; + atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) + GUESS=m68k-atari-mint$UNAME_RELEASE + ;; + *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) + GUESS=m68k-atari-mint$UNAME_RELEASE + ;; + milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) + GUESS=m68k-milan-mint$UNAME_RELEASE + ;; + hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) + GUESS=m68k-hades-mint$UNAME_RELEASE + ;; + *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) + GUESS=m68k-unknown-mint$UNAME_RELEASE + ;; + m68k:machten:*:*) + GUESS=m68k-apple-machten$UNAME_RELEASE + ;; + powerpc:machten:*:*) + GUESS=powerpc-apple-machten$UNAME_RELEASE + ;; + RISC*:Mach:*:*) + GUESS=mips-dec-mach_bsd4.3 + ;; + RISC*:ULTRIX:*:*) + GUESS=mips-dec-ultrix$UNAME_RELEASE + ;; + VAX*:ULTRIX*:*:*) + GUESS=vax-dec-ultrix$UNAME_RELEASE + ;; + 2020:CLIX:*:* | 2430:CLIX:*:*) + GUESS=clipper-intergraph-clix$UNAME_RELEASE + ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" +#ifdef __cplusplus +#include /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif + #if defined (host_mips) && defined (MIPSEB) + #if defined (SYSTYPE_SYSV) + printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_SVR4) + printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) + printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0); + #endif + #endif + exit (-1); + } +EOF + $CC_FOR_BUILD -o "$dummy" "$dummy.c" && + dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=`"$dummy" "$dummyarg"` && + { echo "$SYSTEM_NAME"; exit; } + GUESS=mips-mips-riscos$UNAME_RELEASE + ;; + Motorola:PowerMAX_OS:*:*) + GUESS=powerpc-motorola-powermax + ;; + Motorola:*:4.3:PL8-*) + GUESS=powerpc-harris-powermax + ;; + Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) + GUESS=powerpc-harris-powermax + ;; + Night_Hawk:Power_UNIX:*:*) + GUESS=powerpc-harris-powerunix + ;; + m88k:CX/UX:7*:*) + GUESS=m88k-harris-cxux7 + ;; + m88k:*:4*:R4*) + GUESS=m88k-motorola-sysv4 + ;; + m88k:*:3*:R3*) + GUESS=m88k-motorola-sysv3 + ;; + AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if test "$UNAME_PROCESSOR" = mc88100 || test "$UNAME_PROCESSOR" = mc88110 + then + if test "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx || \ + test "$TARGET_BINARY_INTERFACE"x = x + then + GUESS=m88k-dg-dgux$UNAME_RELEASE + else + GUESS=m88k-dg-dguxbcs$UNAME_RELEASE + fi + else + GUESS=i586-dg-dgux$UNAME_RELEASE + fi + ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + GUESS=m88k-dolphin-sysv3 + ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 + GUESS=m88k-motorola-sysv3 + ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) + GUESS=m88k-tektronix-sysv3 + ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) + GUESS=m68k-tektronix-bsd + ;; + *:IRIX*:*:*) + IRIX_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/g'` + GUESS=mips-sgi-irix$IRIX_REL + ;; + ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. + GUESS=romp-ibm-aix # uname -m gives an 8 hex-code CPU id + ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + i*86:AIX:*:*) + GUESS=i386-ibm-aix + ;; + ia64:AIX:*:*) + if test -x /usr/bin/oslevel ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=$UNAME_VERSION.$UNAME_RELEASE + fi + GUESS=$UNAME_MACHINE-ibm-aix$IBM_REV + ;; + *:AIX:2:3) + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" + #include + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` + then + GUESS=$SYSTEM_NAME + else + GUESS=rs6000-ibm-aix3.2.5 + fi + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + GUESS=rs6000-ibm-aix3.2.4 + else + GUESS=rs6000-ibm-aix3.2 + fi + ;; + *:AIX:*:[4567]) + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` + if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if test -x /usr/bin/lslpp ; then + IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | \ + awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` + else + IBM_REV=$UNAME_VERSION.$UNAME_RELEASE + fi + GUESS=$IBM_ARCH-ibm-aix$IBM_REV + ;; + *:AIX:*:*) + GUESS=rs6000-ibm-aix + ;; + ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*) + GUESS=romp-ibm-bsd4.4 + ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and + GUESS=romp-ibm-bsd$UNAME_RELEASE # 4.3 with uname added to + ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) + GUESS=rs6000-bull-bosx + ;; + DPX/2?00:B.O.S.:*:*) + GUESS=m68k-bull-sysv3 + ;; + 9000/[34]??:4.3bsd:1.*:*) + GUESS=m68k-hp-bsd + ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + GUESS=m68k-hp-bsd4.4 + ;; + 9000/[34678]??:HP-UX:*:*) + HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'` + case $UNAME_MACHINE in + 9000/31?) HP_ARCH=m68000 ;; + 9000/[34]??) HP_ARCH=m68k ;; + 9000/[678][0-9][0-9]) + if test -x /usr/bin/getconf; then + sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case $sc_cpu_version in + 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0 + 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case $sc_kernel_bits in + 32) HP_ARCH=hppa2.0n ;; + 64) HP_ARCH=hppa2.0w ;; + '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20 + esac ;; + esac + fi + if test "$HP_ARCH" = ""; then + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" + + #define _HPUX_SOURCE + #include + #include + + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); + + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } +EOF + (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"` + test -z "$HP_ARCH" && HP_ARCH=hppa + fi ;; + esac + if test "$HP_ARCH" = hppa2.0w + then + set_cc_for_build + + # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating + # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler + # generating 64-bit code. GNU and HP use different nomenclature: + # + # $ CC_FOR_BUILD=cc ./config.guess + # => hppa2.0w-hp-hpux11.23 + # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess + # => hppa64-hp-hpux11.23 + + if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | + grep -q __LP64__ + then + HP_ARCH=hppa2.0w + else + HP_ARCH=hppa64 + fi + fi + GUESS=$HP_ARCH-hp-hpux$HPUX_REV + ;; + ia64:HP-UX:*:*) + HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'` + GUESS=ia64-hp-hpux$HPUX_REV + ;; + 3050*:HI-UX:*:*) + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" + #include + int + main () + { + long cpu = sysconf (_SC_CPU_VERSION); + /* The order matters, because CPU_IS_HP_MC68K erroneously returns + true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct + results, however. */ + if (CPU_IS_PA_RISC (cpu)) + { + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; + case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; + default: puts ("hppa-hitachi-hiuxwe2"); break; + } + } + else if (CPU_IS_HP_MC68K (cpu)) + puts ("m68k-hitachi-hiuxwe2"); + else puts ("unknown-hitachi-hiuxwe2"); + exit (0); + } +EOF + $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` && + { echo "$SYSTEM_NAME"; exit; } + GUESS=unknown-hitachi-hiuxwe2 + ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*) + GUESS=hppa1.1-hp-bsd + ;; + 9000/8??:4.3bsd:*:*) + GUESS=hppa1.0-hp-bsd + ;; + *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) + GUESS=hppa1.0-hp-mpeix + ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*) + GUESS=hppa1.1-hp-osf + ;; + hp8??:OSF1:*:*) + GUESS=hppa1.0-hp-osf + ;; + i*86:OSF1:*:*) + if test -x /usr/sbin/sysversion ; then + GUESS=$UNAME_MACHINE-unknown-osf1mk + else + GUESS=$UNAME_MACHINE-unknown-osf1 + fi + ;; + parisc*:Lites*:*:*) + GUESS=hppa1.1-hp-lites + ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) + GUESS=c1-convex-bsd + ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + GUESS=c34-convex-bsd + ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + GUESS=c38-convex-bsd + ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + GUESS=c4-convex-bsd + ;; + CRAY*Y-MP:*:*:*) + CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` + GUESS=ymp-cray-unicos$CRAY_REL + ;; + CRAY*[A-Z]90:*:*:*) + echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ + -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*TS:*:*:*) + CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` + GUESS=t90-cray-unicos$CRAY_REL + ;; + CRAY*T3E:*:*:*) + CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` + GUESS=alphaev5-cray-unicosmk$CRAY_REL + ;; + CRAY*SV1:*:*:*) + CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` + GUESS=sv1-cray-unicos$CRAY_REL + ;; + *:UNICOS/mp:*:*) + CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` + GUESS=craynv-cray-unicosmp$CRAY_REL + ;; + F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) + FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` + FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` + FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'` + GUESS=${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL} + ;; + 5000:UNIX_System_V:4.*:*) + FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` + FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` + GUESS=sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL} + ;; + i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) + GUESS=$UNAME_MACHINE-pc-bsdi$UNAME_RELEASE + ;; + sparc*:BSD/OS:*:*) + GUESS=sparc-unknown-bsdi$UNAME_RELEASE + ;; + *:BSD/OS:*:*) + GUESS=$UNAME_MACHINE-unknown-bsdi$UNAME_RELEASE + ;; + arm:FreeBSD:*:*) + UNAME_PROCESSOR=`uname -p` + set_cc_for_build + if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_PCS_VFP + then + FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` + GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabi + else + FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` + GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabihf + fi + ;; + *:FreeBSD:*:*) + UNAME_PROCESSOR=`uname -p` + case $UNAME_PROCESSOR in + amd64) + UNAME_PROCESSOR=x86_64 ;; + i386) + UNAME_PROCESSOR=i586 ;; + esac + FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` + GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL + ;; + i*:CYGWIN*:*) + GUESS=$UNAME_MACHINE-pc-cygwin + ;; + *:MINGW64*:*) + GUESS=$UNAME_MACHINE-pc-mingw64 + ;; + *:MINGW*:*) + GUESS=$UNAME_MACHINE-pc-mingw32 + ;; + *:MSYS*:*) + GUESS=$UNAME_MACHINE-pc-msys + ;; + i*:PW*:*) + GUESS=$UNAME_MACHINE-pc-pw32 + ;; + *:SerenityOS:*:*) + GUESS=$UNAME_MACHINE-pc-serenity + ;; + *:Interix*:*) + case $UNAME_MACHINE in + x86) + GUESS=i586-pc-interix$UNAME_RELEASE + ;; + authenticamd | genuineintel | EM64T) + GUESS=x86_64-unknown-interix$UNAME_RELEASE + ;; + IA64) + GUESS=ia64-unknown-interix$UNAME_RELEASE + ;; + esac ;; + i*:UWIN*:*) + GUESS=$UNAME_MACHINE-pc-uwin + ;; + amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) + GUESS=x86_64-pc-cygwin + ;; + prep*:SunOS:5.*:*) + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=powerpcle-unknown-solaris2$SUN_REL + ;; + *:GNU:*:*) + # the GNU system + GNU_ARCH=`echo "$UNAME_MACHINE" | sed -e 's,[-/].*$,,'` + GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's,/.*$,,'` + GUESS=$GNU_ARCH-unknown-$LIBC$GNU_REL + ;; + *:GNU/*:*:*) + # other systems with GNU libc and userland + GNU_SYS=`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"` + GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` + GUESS=$UNAME_MACHINE-unknown-$GNU_SYS$GNU_REL-$LIBC + ;; + x86_64:[Mm]anagarm:*:*|i?86:[Mm]anagarm:*:*) + GUESS="$UNAME_MACHINE-pc-managarm-mlibc" + ;; + *:[Mm]anagarm:*:*) + GUESS="$UNAME_MACHINE-unknown-managarm-mlibc" + ;; + *:Minix:*:*) + GUESS=$UNAME_MACHINE-unknown-minix + ;; + aarch64:Linux:*:*) + set_cc_for_build + CPU=$UNAME_MACHINE + LIBCABI=$LIBC + if test "$CC_FOR_BUILD" != no_compiler_found; then + ABI=64 + sed 's/^ //' << EOF > "$dummy.c" + #ifdef __ARM_EABI__ + #ifdef __ARM_PCS_VFP + ABI=eabihf + #else + ABI=eabi + #endif + #endif +EOF + cc_set_abi=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^ABI' | sed 's, ,,g'` + eval "$cc_set_abi" + case $ABI in + eabi | eabihf) CPU=armv8l; LIBCABI=$LIBC$ABI ;; + esac + fi + GUESS=$CPU-unknown-linux-$LIBCABI + ;; + aarch64_be:Linux:*:*) + UNAME_MACHINE=aarch64_be + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' /proc/cpuinfo 2>/dev/null` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; + PCA57) UNAME_MACHINE=alphapca56 ;; + EV6) UNAME_MACHINE=alphaev6 ;; + EV67) UNAME_MACHINE=alphaev67 ;; + EV68*) UNAME_MACHINE=alphaev68 ;; + esac + objdump --private-headers /bin/sh | grep -q ld.so.1 + if test "$?" = 0 ; then LIBC=gnulibc1 ; fi + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + arc:Linux:*:* | arceb:Linux:*:* | arc32:Linux:*:* | arc64:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + arm*:Linux:*:*) + set_cc_for_build + if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_EABI__ + then + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + else + if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_PCS_VFP + then + GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabi + else + GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabihf + fi + fi + ;; + avr32*:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + cris:Linux:*:*) + GUESS=$UNAME_MACHINE-axis-linux-$LIBC + ;; + crisv32:Linux:*:*) + GUESS=$UNAME_MACHINE-axis-linux-$LIBC + ;; + e2k:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + frv:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + hexagon:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + i*86:Linux:*:*) + GUESS=$UNAME_MACHINE-pc-linux-$LIBC + ;; + ia64:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + k1om:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + kvx:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + kvx:cos:*:*) + GUESS=$UNAME_MACHINE-unknown-cos + ;; + kvx:mbr:*:*) + GUESS=$UNAME_MACHINE-unknown-mbr + ;; + loongarch32:Linux:*:* | loongarch64:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + m32r*:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + m68*:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + mips:Linux:*:* | mips64:Linux:*:*) + set_cc_for_build + IS_GLIBC=0 + test x"${LIBC}" = xgnu && IS_GLIBC=1 + sed 's/^ //' << EOF > "$dummy.c" + #undef CPU + #undef mips + #undef mipsel + #undef mips64 + #undef mips64el + #if ${IS_GLIBC} && defined(_ABI64) + LIBCABI=gnuabi64 + #else + #if ${IS_GLIBC} && defined(_ABIN32) + LIBCABI=gnuabin32 + #else + LIBCABI=${LIBC} + #endif + #endif + + #if ${IS_GLIBC} && defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6 + CPU=mipsisa64r6 + #else + #if ${IS_GLIBC} && !defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6 + CPU=mipsisa32r6 + #else + #if defined(__mips64) + CPU=mips64 + #else + CPU=mips + #endif + #endif + #endif + + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + MIPS_ENDIAN=el + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + MIPS_ENDIAN= + #else + MIPS_ENDIAN= + #endif + #endif +EOF + cc_set_vars=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI'` + eval "$cc_set_vars" + test "x$CPU" != x && { echo "$CPU${MIPS_ENDIAN}-unknown-linux-$LIBCABI"; exit; } + ;; + mips64el:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + openrisc*:Linux:*:*) + GUESS=or1k-unknown-linux-$LIBC + ;; + or32:Linux:*:* | or1k*:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + padre:Linux:*:*) + GUESS=sparc-unknown-linux-$LIBC + ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + GUESS=hppa64-unknown-linux-$LIBC + ;; + parisc:Linux:*:* | hppa:Linux:*:*) + # Look for CPU level + case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in + PA7*) GUESS=hppa1.1-unknown-linux-$LIBC ;; + PA8*) GUESS=hppa2.0-unknown-linux-$LIBC ;; + *) GUESS=hppa-unknown-linux-$LIBC ;; + esac + ;; + ppc64:Linux:*:*) + GUESS=powerpc64-unknown-linux-$LIBC + ;; + ppc:Linux:*:*) + GUESS=powerpc-unknown-linux-$LIBC + ;; + ppc64le:Linux:*:*) + GUESS=powerpc64le-unknown-linux-$LIBC + ;; + ppcle:Linux:*:*) + GUESS=powerpcle-unknown-linux-$LIBC + ;; + riscv32:Linux:*:* | riscv32be:Linux:*:* | riscv64:Linux:*:* | riscv64be:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + s390:Linux:*:* | s390x:Linux:*:*) + GUESS=$UNAME_MACHINE-ibm-linux-$LIBC + ;; + sh64*:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + sh*:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + sparc:Linux:*:* | sparc64:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + tile*:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + vax:Linux:*:*) + GUESS=$UNAME_MACHINE-dec-linux-$LIBC + ;; + x86_64:Linux:*:*) + set_cc_for_build + CPU=$UNAME_MACHINE + LIBCABI=$LIBC + if test "$CC_FOR_BUILD" != no_compiler_found; then + ABI=64 + sed 's/^ //' << EOF > "$dummy.c" + #ifdef __i386__ + ABI=x86 + #else + #ifdef __ILP32__ + ABI=x32 + #endif + #endif +EOF + cc_set_abi=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^ABI' | sed 's, ,,g'` + eval "$cc_set_abi" + case $ABI in + x86) CPU=i686 ;; + x32) LIBCABI=${LIBC}x32 ;; + esac + fi + GUESS=$CPU-pc-linux-$LIBCABI + ;; + xtensa*:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + i*86:DYNIX/ptx:4*:*) + # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. + # earlier versions are messed up and put the nodename in both + # sysname and nodename. + GUESS=i386-sequent-sysv4 + ;; + i*86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + GUESS=$UNAME_MACHINE-pc-sysv4.2uw$UNAME_VERSION + ;; + i*86:OS/2:*:*) + # If we were able to find 'uname', then EMX Unix compatibility + # is probably installed. + GUESS=$UNAME_MACHINE-pc-os2-emx + ;; + i*86:XTS-300:*:STOP) + GUESS=$UNAME_MACHINE-unknown-stop + ;; + i*86:atheos:*:*) + GUESS=$UNAME_MACHINE-unknown-atheos + ;; + i*86:syllable:*:*) + GUESS=$UNAME_MACHINE-pc-syllable + ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) + GUESS=i386-unknown-lynxos$UNAME_RELEASE + ;; + i*86:*DOS:*:*) + GUESS=$UNAME_MACHINE-pc-msdosdjgpp + ;; + i*86:*:4.*:*) + UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'` + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + GUESS=$UNAME_MACHINE-univel-sysv$UNAME_REL + else + GUESS=$UNAME_MACHINE-pc-sysv$UNAME_REL + fi + ;; + i*86:*:5:[678]*) + # UnixWare 7.x, OpenUNIX and OpenServer 6. + case `/bin/uname -X | grep "^Machine"` in + *486*) UNAME_MACHINE=i486 ;; + *Pentium) UNAME_MACHINE=i586 ;; + *Pent*|*Celeron) UNAME_MACHINE=i686 ;; + esac + GUESS=$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + ;; + i*86:*:3.2:*) + if test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` + (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ + && UNAME_MACHINE=i686 + (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ + && UNAME_MACHINE=i686 + GUESS=$UNAME_MACHINE-pc-sco$UNAME_REL + else + GUESS=$UNAME_MACHINE-pc-sysv32 + fi + ;; + pc:*:*:*) + # Left here for compatibility: + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i586. + # Note: whatever this is, it MUST be the same as what config.sub + # prints for the "djgpp" host, or else GDB configure will decide that + # this is a cross-build. + GUESS=i586-pc-msdosdjgpp + ;; + Intel:Mach:3*:*) + GUESS=i386-pc-mach3 + ;; + paragon:*:*:*) + GUESS=i860-intel-osf1 + ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then + GUESS=i860-stardent-sysv$UNAME_RELEASE # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + GUESS=i860-unknown-sysv$UNAME_RELEASE # Unknown i860-SVR4 + fi + ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + GUESS=m68010-convergent-sysv + ;; + mc68k:UNIX:SYSTEM5:3.51m) + GUESS=m68k-convergent-sysv + ;; + M680?0:D-NIX:5.3:*) + GUESS=m68k-diab-dnix + ;; + M68*:*:R3V[5678]*:*) + test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; + 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) + OS_REL='' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4; exit; } ;; + NCR*:*:4.2:* | MPRAS*:*:4.2:*) + OS_REL='.3' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } + /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; + m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) + GUESS=m68k-unknown-lynxos$UNAME_RELEASE + ;; + mc68030:UNIX_System_V:4.*:*) + GUESS=m68k-atari-sysv4 + ;; + TSUNAMI:LynxOS:2.*:*) + GUESS=sparc-unknown-lynxos$UNAME_RELEASE + ;; + rs6000:LynxOS:2.*:*) + GUESS=rs6000-unknown-lynxos$UNAME_RELEASE + ;; + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) + GUESS=powerpc-unknown-lynxos$UNAME_RELEASE + ;; + SM[BE]S:UNIX_SV:*:*) + GUESS=mips-dde-sysv$UNAME_RELEASE + ;; + RM*:ReliantUNIX-*:*:*) + GUESS=mips-sni-sysv4 + ;; + RM*:SINIX-*:*:*) + GUESS=mips-sni-sysv4 + ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + GUESS=$UNAME_MACHINE-sni-sysv4 + else + GUESS=ns32k-sni-sysv + fi + ;; + PENTIUM:*:4.0*:*) # Unisys 'ClearPath HMP IX 4000' SVR4/MP effort + # says + GUESS=i586-unisys-sysv4 + ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes . + # How about differentiating between stratus architectures? -djm + GUESS=hppa1.1-stratus-sysv4 + ;; + *:*:*:FTX*) + # From seanf@swdc.stratus.com. + GUESS=i860-stratus-sysv4 + ;; + i*86:VOS:*:*) + # From Paul.Green@stratus.com. + GUESS=$UNAME_MACHINE-stratus-vos + ;; + *:VOS:*:*) + # From Paul.Green@stratus.com. + GUESS=hppa1.1-stratus-vos + ;; + mc68*:A/UX:*:*) + GUESS=m68k-apple-aux$UNAME_RELEASE + ;; + news*:NEWS-OS:6*:*) + GUESS=mips-sony-newsos6 + ;; + R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) + if test -d /usr/nec; then + GUESS=mips-nec-sysv$UNAME_RELEASE + else + GUESS=mips-unknown-sysv$UNAME_RELEASE + fi + ;; + BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. + GUESS=powerpc-be-beos + ;; + BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. + GUESS=powerpc-apple-beos + ;; + BePC:BeOS:*:*) # BeOS running on Intel PC compatible. + GUESS=i586-pc-beos + ;; + BePC:Haiku:*:*) # Haiku running on Intel PC compatible. + GUESS=i586-pc-haiku + ;; + ppc:Haiku:*:*) # Haiku running on Apple PowerPC + GUESS=powerpc-apple-haiku + ;; + *:Haiku:*:*) # Haiku modern gcc (not bound by BeOS compat) + GUESS=$UNAME_MACHINE-unknown-haiku + ;; + SX-4:SUPER-UX:*:*) + GUESS=sx4-nec-superux$UNAME_RELEASE + ;; + SX-5:SUPER-UX:*:*) + GUESS=sx5-nec-superux$UNAME_RELEASE + ;; + SX-6:SUPER-UX:*:*) + GUESS=sx6-nec-superux$UNAME_RELEASE + ;; + SX-7:SUPER-UX:*:*) + GUESS=sx7-nec-superux$UNAME_RELEASE + ;; + SX-8:SUPER-UX:*:*) + GUESS=sx8-nec-superux$UNAME_RELEASE + ;; + SX-8R:SUPER-UX:*:*) + GUESS=sx8r-nec-superux$UNAME_RELEASE + ;; + SX-ACE:SUPER-UX:*:*) + GUESS=sxace-nec-superux$UNAME_RELEASE + ;; + Power*:Rhapsody:*:*) + GUESS=powerpc-apple-rhapsody$UNAME_RELEASE + ;; + *:Rhapsody:*:*) + GUESS=$UNAME_MACHINE-apple-rhapsody$UNAME_RELEASE + ;; + arm64:Darwin:*:*) + GUESS=aarch64-apple-darwin$UNAME_RELEASE + ;; + *:Darwin:*:*) + UNAME_PROCESSOR=`uname -p` + case $UNAME_PROCESSOR in + unknown) UNAME_PROCESSOR=powerpc ;; + esac + if command -v xcode-select > /dev/null 2> /dev/null && \ + ! xcode-select --print-path > /dev/null 2> /dev/null ; then + # Avoid executing cc if there is no toolchain installed as + # cc will be a stub that puts up a graphical alert + # prompting the user to install developer tools. + CC_FOR_BUILD=no_compiler_found + else + set_cc_for_build + fi + if test "$CC_FOR_BUILD" != no_compiler_found; then + if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + case $UNAME_PROCESSOR in + i386) UNAME_PROCESSOR=x86_64 ;; + powerpc) UNAME_PROCESSOR=powerpc64 ;; + esac + fi + # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc + if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_PPC >/dev/null + then + UNAME_PROCESSOR=powerpc + fi + elif test "$UNAME_PROCESSOR" = i386 ; then + # uname -m returns i386 or x86_64 + UNAME_PROCESSOR=$UNAME_MACHINE + fi + GUESS=$UNAME_PROCESSOR-apple-darwin$UNAME_RELEASE + ;; + *:procnto*:*:* | *:QNX:[0123456789]*:*) + UNAME_PROCESSOR=`uname -p` + if test "$UNAME_PROCESSOR" = x86; then + UNAME_PROCESSOR=i386 + UNAME_MACHINE=pc + fi + GUESS=$UNAME_PROCESSOR-$UNAME_MACHINE-nto-qnx$UNAME_RELEASE + ;; + *:QNX:*:4*) + GUESS=i386-pc-qnx + ;; + NEO-*:NONSTOP_KERNEL:*:*) + GUESS=neo-tandem-nsk$UNAME_RELEASE + ;; + NSE-*:NONSTOP_KERNEL:*:*) + GUESS=nse-tandem-nsk$UNAME_RELEASE + ;; + NSR-*:NONSTOP_KERNEL:*:*) + GUESS=nsr-tandem-nsk$UNAME_RELEASE + ;; + NSV-*:NONSTOP_KERNEL:*:*) + GUESS=nsv-tandem-nsk$UNAME_RELEASE + ;; + NSX-*:NONSTOP_KERNEL:*:*) + GUESS=nsx-tandem-nsk$UNAME_RELEASE + ;; + *:NonStop-UX:*:*) + GUESS=mips-compaq-nonstopux + ;; + BS2000:POSIX*:*:*) + GUESS=bs2000-siemens-sysv + ;; + DS/*:UNIX_System_V:*:*) + GUESS=$UNAME_MACHINE-$UNAME_SYSTEM-$UNAME_RELEASE + ;; + *:Plan9:*:*) + # "uname -m" is not consistent, so use $cputype instead. 386 + # is converted to i386 for consistency with other x86 + # operating systems. + if test "${cputype-}" = 386; then + UNAME_MACHINE=i386 + elif test "x${cputype-}" != x; then + UNAME_MACHINE=$cputype + fi + GUESS=$UNAME_MACHINE-unknown-plan9 + ;; + *:TOPS-10:*:*) + GUESS=pdp10-unknown-tops10 + ;; + *:TENEX:*:*) + GUESS=pdp10-unknown-tenex + ;; + KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) + GUESS=pdp10-dec-tops20 + ;; + XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) + GUESS=pdp10-xkl-tops20 + ;; + *:TOPS-20:*:*) + GUESS=pdp10-unknown-tops20 + ;; + *:ITS:*:*) + GUESS=pdp10-unknown-its + ;; + SEI:*:*:SEIUX) + GUESS=mips-sei-seiux$UNAME_RELEASE + ;; + *:DragonFly:*:*) + DRAGONFLY_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` + GUESS=$UNAME_MACHINE-unknown-dragonfly$DRAGONFLY_REL + ;; + *:*VMS:*:*) + UNAME_MACHINE=`(uname -p) 2>/dev/null` + case $UNAME_MACHINE in + A*) GUESS=alpha-dec-vms ;; + I*) GUESS=ia64-dec-vms ;; + V*) GUESS=vax-dec-vms ;; + esac ;; + *:XENIX:*:SysV) + GUESS=i386-pc-xenix + ;; + i*86:skyos:*:*) + SKYOS_REL=`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'` + GUESS=$UNAME_MACHINE-pc-skyos$SKYOS_REL + ;; + i*86:rdos:*:*) + GUESS=$UNAME_MACHINE-pc-rdos + ;; + i*86:Fiwix:*:*) + GUESS=$UNAME_MACHINE-pc-fiwix + ;; + *:AROS:*:*) + GUESS=$UNAME_MACHINE-unknown-aros + ;; + x86_64:VMkernel:*:*) + GUESS=$UNAME_MACHINE-unknown-esx + ;; + amd64:Isilon\ OneFS:*:*) + GUESS=x86_64-unknown-onefs + ;; + *:Unleashed:*:*) + GUESS=$UNAME_MACHINE-unknown-unleashed$UNAME_RELEASE + ;; + *:Ironclad:*:*) + GUESS=$UNAME_MACHINE-unknown-ironclad + ;; +esac + +# Do we have a guess based on uname results? +if test "x$GUESS" != x; then + echo "$GUESS" + exit +fi + +# No uname command or uname output not recognized. +set_cc_for_build +cat > "$dummy.c" < +#include +#endif +#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__) +#if defined (vax) || defined (__vax) || defined (__vax__) || defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__) +#include +#if defined(_SIZE_T_) || defined(SIGLOST) +#include +#endif +#endif +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + if (version < 4) + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + else + printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); +#endif + +#if defined (vax) +#if !defined (ultrix) +#include +#if defined (BSD) +#if BSD == 43 + printf ("vax-dec-bsd4.3\n"); exit (0); +#else +#if BSD == 199006 + printf ("vax-dec-bsd4.3reno\n"); exit (0); +#else + printf ("vax-dec-bsd\n"); exit (0); +#endif +#endif +#else + printf ("vax-dec-bsd\n"); exit (0); +#endif +#else +#if defined(_SIZE_T_) || defined(SIGLOST) + struct utsname un; + uname (&un); + printf ("vax-dec-ultrix%s\n", un.release); exit (0); +#else + printf ("vax-dec-ultrix\n"); exit (0); +#endif +#endif +#endif +#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__) +#if defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__) +#if defined(_SIZE_T_) || defined(SIGLOST) + struct utsname *un; + uname (&un); + printf ("mips-dec-ultrix%s\n", un.release); exit (0); +#else + printf ("mips-dec-ultrix\n"); exit (0); +#endif +#endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +$CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=`"$dummy"` && + { echo "$SYSTEM_NAME"; exit; } + +# Apollos put the system type in the environment. +test -d /usr/apollo && { echo "$ISP-apollo-$SYSTYPE"; exit; } + +echo "$0: unable to guess system type" >&2 + +case $UNAME_MACHINE:$UNAME_SYSTEM in + mips:Linux | mips64:Linux) + # If we got here on MIPS GNU/Linux, output extra information. + cat >&2 <&2 <&2 </dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null` + +hostinfo = `(hostinfo) 2>/dev/null` +/bin/universe = `(/bin/universe) 2>/dev/null` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` +/bin/arch = `(/bin/arch) 2>/dev/null` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` + +UNAME_MACHINE = "$UNAME_MACHINE" +UNAME_RELEASE = "$UNAME_RELEASE" +UNAME_SYSTEM = "$UNAME_SYSTEM" +UNAME_VERSION = "$UNAME_VERSION" +EOF +fi + +exit 1 + +# Local variables: +# eval: (add-hook 'before-save-hook 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/support/gnuconfig/config.sub b/support/gnuconfig/config.sub new file mode 100755 index 0000000..2c6a07a --- /dev/null +++ b/support/gnuconfig/config.sub @@ -0,0 +1,1971 @@ +#! /bin/sh +# Configuration validation subroutine script. +# Copyright 1992-2024 Free Software Foundation, Inc. + +# shellcheck disable=SC2006,SC2268 # see below for rationale + +timestamp='2024-01-01' + +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see . +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that +# program. This Exception is an additional permission under section 7 +# of the GNU General Public License, version 3 ("GPLv3"). + + +# Please send patches to . +# +# Configuration subroutine to validate and canonicalize a configuration type. +# Supply the specified configuration type as an argument. +# If it is invalid, we print an error message on stderr and exit with code 1. +# Otherwise, we print the canonical config type on stdout and succeed. + +# You can get the latest version of this script from: +# https://git.savannah.gnu.org/cgit/config.git/plain/config.sub + +# This file is supposed to be the same for all GNU packages +# and recognize all the CPU types, system types and aliases +# that are meaningful with *any* GNU software. +# Each package is responsible for reporting which valid configurations +# it does not support. The user should be able to distinguish +# a failure to support a valid configuration from a meaningless +# configuration. + +# The goal of this file is to map all the various variations of a given +# machine specification into a single specification in the form: +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or in some cases, the newer four-part form: +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# It is wrong to echo any other type of specification. + +# The "shellcheck disable" line above the timestamp inhibits complaints +# about features and limitations of the classic Bourne shell that were +# superseded or lifted in POSIX. However, this script identifies a wide +# variety of pre-POSIX systems that do not have POSIX shells at all, and +# even some reasonably current systems (Solaris 10 as case-in-point) still +# have a pre-POSIX /bin/sh. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS + +Canonicalize a configuration name. + +Options: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.sub ($timestamp) + +Copyright 1992-2024 Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try '$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" >&2 + exit 1 ;; + + *local*) + # First pass through any local machine types. + echo "$1" + exit ;; + + * ) + break ;; + esac +done + +case $# in + 0) echo "$me: missing argument$help" >&2 + exit 1;; + 1) ;; + *) echo "$me: too many arguments$help" >&2 + exit 1;; +esac + +# Split fields of configuration type +# shellcheck disable=SC2162 +saved_IFS=$IFS +IFS="-" read field1 field2 field3 field4 <&2 + exit 1 + ;; + *-*-*-*) + basic_machine=$field1-$field2 + basic_os=$field3-$field4 + ;; + *-*-*) + # Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two + # parts + maybe_os=$field2-$field3 + case $maybe_os in + nto-qnx* | linux-* | uclinux-uclibc* \ + | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \ + | netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \ + | storm-chaos* | os2-emx* | rtmk-nova* | managarm-* \ + | windows-* ) + basic_machine=$field1 + basic_os=$maybe_os + ;; + android-linux) + basic_machine=$field1-unknown + basic_os=linux-android + ;; + *) + basic_machine=$field1-$field2 + basic_os=$field3 + ;; + esac + ;; + *-*) + # A lone config we happen to match not fitting any pattern + case $field1-$field2 in + decstation-3100) + basic_machine=mips-dec + basic_os= + ;; + *-*) + # Second component is usually, but not always the OS + case $field2 in + # Prevent following clause from handling this valid os + sun*os*) + basic_machine=$field1 + basic_os=$field2 + ;; + zephyr*) + basic_machine=$field1-unknown + basic_os=$field2 + ;; + # Manufacturers + dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \ + | att* | 7300* | 3300* | delta* | motorola* | sun[234]* \ + | unicom* | ibm* | next | hp | isi* | apollo | altos* \ + | convergent* | ncr* | news | 32* | 3600* | 3100* \ + | hitachi* | c[123]* | convex* | sun | crds | omron* | dg \ + | ultra | tti* | harris | dolphin | highlevel | gould \ + | cbm | ns | masscomp | apple | axis | knuth | cray \ + | microblaze* | sim | cisco \ + | oki | wec | wrs | winbond) + basic_machine=$field1-$field2 + basic_os= + ;; + *) + basic_machine=$field1 + basic_os=$field2 + ;; + esac + ;; + esac + ;; + *) + # Convert single-component short-hands not valid as part of + # multi-component configurations. + case $field1 in + 386bsd) + basic_machine=i386-pc + basic_os=bsd + ;; + a29khif) + basic_machine=a29k-amd + basic_os=udi + ;; + adobe68k) + basic_machine=m68010-adobe + basic_os=scout + ;; + alliant) + basic_machine=fx80-alliant + basic_os= + ;; + altos | altos3068) + basic_machine=m68k-altos + basic_os= + ;; + am29k) + basic_machine=a29k-none + basic_os=bsd + ;; + amdahl) + basic_machine=580-amdahl + basic_os=sysv + ;; + amiga) + basic_machine=m68k-unknown + basic_os= + ;; + amigaos | amigados) + basic_machine=m68k-unknown + basic_os=amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + basic_os=sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + basic_os=sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + basic_os=bsd + ;; + aros) + basic_machine=i386-pc + basic_os=aros + ;; + aux) + basic_machine=m68k-apple + basic_os=aux + ;; + balance) + basic_machine=ns32k-sequent + basic_os=dynix + ;; + blackfin) + basic_machine=bfin-unknown + basic_os=linux + ;; + cegcc) + basic_machine=arm-unknown + basic_os=cegcc + ;; + convex-c1) + basic_machine=c1-convex + basic_os=bsd + ;; + convex-c2) + basic_machine=c2-convex + basic_os=bsd + ;; + convex-c32) + basic_machine=c32-convex + basic_os=bsd + ;; + convex-c34) + basic_machine=c34-convex + basic_os=bsd + ;; + convex-c38) + basic_machine=c38-convex + basic_os=bsd + ;; + cray) + basic_machine=j90-cray + basic_os=unicos + ;; + crds | unos) + basic_machine=m68k-crds + basic_os= + ;; + da30) + basic_machine=m68k-da30 + basic_os= + ;; + decstation | pmax | pmin | dec3100 | decstatn) + basic_machine=mips-dec + basic_os= + ;; + delta88) + basic_machine=m88k-motorola + basic_os=sysv3 + ;; + dicos) + basic_machine=i686-pc + basic_os=dicos + ;; + djgpp) + basic_machine=i586-pc + basic_os=msdosdjgpp + ;; + ebmon29k) + basic_machine=a29k-amd + basic_os=ebmon + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + basic_os=ose + ;; + gmicro) + basic_machine=tron-gmicro + basic_os=sysv + ;; + go32) + basic_machine=i386-pc + basic_os=go32 + ;; + h8300hms) + basic_machine=h8300-hitachi + basic_os=hms + ;; + h8300xray) + basic_machine=h8300-hitachi + basic_os=xray + ;; + h8500hms) + basic_machine=h8500-hitachi + basic_os=hms + ;; + harris) + basic_machine=m88k-harris + basic_os=sysv3 + ;; + hp300 | hp300hpux) + basic_machine=m68k-hp + basic_os=hpux + ;; + hp300bsd) + basic_machine=m68k-hp + basic_os=bsd + ;; + hppaosf) + basic_machine=hppa1.1-hp + basic_os=osf + ;; + hppro) + basic_machine=hppa1.1-hp + basic_os=proelf + ;; + i386mach) + basic_machine=i386-mach + basic_os=mach + ;; + isi68 | isi) + basic_machine=m68k-isi + basic_os=sysv + ;; + m68knommu) + basic_machine=m68k-unknown + basic_os=linux + ;; + magnum | m3230) + basic_machine=mips-mips + basic_os=sysv + ;; + merlin) + basic_machine=ns32k-utek + basic_os=sysv + ;; + mingw64) + basic_machine=x86_64-pc + basic_os=mingw64 + ;; + mingw32) + basic_machine=i686-pc + basic_os=mingw32 + ;; + mingw32ce) + basic_machine=arm-unknown + basic_os=mingw32ce + ;; + monitor) + basic_machine=m68k-rom68k + basic_os=coff + ;; + morphos) + basic_machine=powerpc-unknown + basic_os=morphos + ;; + moxiebox) + basic_machine=moxie-unknown + basic_os=moxiebox + ;; + msdos) + basic_machine=i386-pc + basic_os=msdos + ;; + msys) + basic_machine=i686-pc + basic_os=msys + ;; + mvs) + basic_machine=i370-ibm + basic_os=mvs + ;; + nacl) + basic_machine=le32-unknown + basic_os=nacl + ;; + ncr3000) + basic_machine=i486-ncr + basic_os=sysv4 + ;; + netbsd386) + basic_machine=i386-pc + basic_os=netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + basic_os=linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + basic_os=newsos + ;; + news1000) + basic_machine=m68030-sony + basic_os=newsos + ;; + necv70) + basic_machine=v70-nec + basic_os=sysv + ;; + nh3000) + basic_machine=m68k-harris + basic_os=cxux + ;; + nh[45]000) + basic_machine=m88k-harris + basic_os=cxux + ;; + nindy960) + basic_machine=i960-intel + basic_os=nindy + ;; + mon960) + basic_machine=i960-intel + basic_os=mon960 + ;; + nonstopux) + basic_machine=mips-compaq + basic_os=nonstopux + ;; + os400) + basic_machine=powerpc-ibm + basic_os=os400 + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + basic_os=ose + ;; + os68k) + basic_machine=m68k-none + basic_os=os68k + ;; + paragon) + basic_machine=i860-intel + basic_os=osf + ;; + parisc) + basic_machine=hppa-unknown + basic_os=linux + ;; + psp) + basic_machine=mipsallegrexel-sony + basic_os=psp + ;; + pw32) + basic_machine=i586-unknown + basic_os=pw32 + ;; + rdos | rdos64) + basic_machine=x86_64-pc + basic_os=rdos + ;; + rdos32) + basic_machine=i386-pc + basic_os=rdos + ;; + rom68k) + basic_machine=m68k-rom68k + basic_os=coff + ;; + sa29200) + basic_machine=a29k-amd + basic_os=udi + ;; + sei) + basic_machine=mips-sei + basic_os=seiux + ;; + sequent) + basic_machine=i386-sequent + basic_os= + ;; + sps7) + basic_machine=m68k-bull + basic_os=sysv2 + ;; + st2000) + basic_machine=m68k-tandem + basic_os= + ;; + stratus) + basic_machine=i860-stratus + basic_os=sysv4 + ;; + sun2) + basic_machine=m68000-sun + basic_os= + ;; + sun2os3) + basic_machine=m68000-sun + basic_os=sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + basic_os=sunos4 + ;; + sun3) + basic_machine=m68k-sun + basic_os= + ;; + sun3os3) + basic_machine=m68k-sun + basic_os=sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + basic_os=sunos4 + ;; + sun4) + basic_machine=sparc-sun + basic_os= + ;; + sun4os3) + basic_machine=sparc-sun + basic_os=sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + basic_os=sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + basic_os=solaris2 + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + basic_os= + ;; + sv1) + basic_machine=sv1-cray + basic_os=unicos + ;; + symmetry) + basic_machine=i386-sequent + basic_os=dynix + ;; + t3e) + basic_machine=alphaev5-cray + basic_os=unicos + ;; + t90) + basic_machine=t90-cray + basic_os=unicos + ;; + toad1) + basic_machine=pdp10-xkl + basic_os=tops20 + ;; + tpf) + basic_machine=s390x-ibm + basic_os=tpf + ;; + udi29k) + basic_machine=a29k-amd + basic_os=udi + ;; + ultra3) + basic_machine=a29k-nyu + basic_os=sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + basic_os=none + ;; + vaxv) + basic_machine=vax-dec + basic_os=sysv + ;; + vms) + basic_machine=vax-dec + basic_os=vms + ;; + vsta) + basic_machine=i386-pc + basic_os=vsta + ;; + vxworks960) + basic_machine=i960-wrs + basic_os=vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + basic_os=vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + basic_os=vxworks + ;; + xbox) + basic_machine=i686-pc + basic_os=mingw32 + ;; + ymp) + basic_machine=ymp-cray + basic_os=unicos + ;; + *) + basic_machine=$1 + basic_os= + ;; + esac + ;; +esac + +# Decode 1-component or ad-hoc basic machines +case $basic_machine in + # Here we handle the default manufacturer of certain CPU types. It is in + # some cases the only manufacturer, in others, it is the most popular. + w89k) + cpu=hppa1.1 + vendor=winbond + ;; + op50n) + cpu=hppa1.1 + vendor=oki + ;; + op60c) + cpu=hppa1.1 + vendor=oki + ;; + ibm*) + cpu=i370 + vendor=ibm + ;; + orion105) + cpu=clipper + vendor=highlevel + ;; + mac | mpw | mac-mpw) + cpu=m68k + vendor=apple + ;; + pmac | pmac-mpw) + cpu=powerpc + vendor=apple + ;; + + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + cpu=m68000 + vendor=att + ;; + 3b*) + cpu=we32k + vendor=att + ;; + bluegene*) + cpu=powerpc + vendor=ibm + basic_os=cnk + ;; + decsystem10* | dec10*) + cpu=pdp10 + vendor=dec + basic_os=tops10 + ;; + decsystem20* | dec20*) + cpu=pdp10 + vendor=dec + basic_os=tops20 + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + cpu=m68k + vendor=motorola + ;; + dpx2*) + cpu=m68k + vendor=bull + basic_os=sysv3 + ;; + encore | umax | mmax) + cpu=ns32k + vendor=encore + ;; + elxsi) + cpu=elxsi + vendor=elxsi + basic_os=${basic_os:-bsd} + ;; + fx2800) + cpu=i860 + vendor=alliant + ;; + genix) + cpu=ns32k + vendor=ns + ;; + h3050r* | hiux*) + cpu=hppa1.1 + vendor=hitachi + basic_os=hiuxwe2 + ;; + hp3k9[0-9][0-9] | hp9[0-9][0-9]) + cpu=hppa1.0 + vendor=hp + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + cpu=m68000 + vendor=hp + ;; + hp9k3[2-9][0-9]) + cpu=m68k + vendor=hp + ;; + hp9k6[0-9][0-9] | hp6[0-9][0-9]) + cpu=hppa1.0 + vendor=hp + ;; + hp9k7[0-79][0-9] | hp7[0-79][0-9]) + cpu=hppa1.1 + vendor=hp + ;; + hp9k78[0-9] | hp78[0-9]) + # FIXME: really hppa2.0-hp + cpu=hppa1.1 + vendor=hp + ;; + hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) + # FIXME: really hppa2.0-hp + cpu=hppa1.1 + vendor=hp + ;; + hp9k8[0-9][13679] | hp8[0-9][13679]) + cpu=hppa1.1 + vendor=hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + cpu=hppa1.0 + vendor=hp + ;; + i*86v32) + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + basic_os=sysv32 + ;; + i*86v4*) + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + basic_os=sysv4 + ;; + i*86v) + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + basic_os=sysv + ;; + i*86sol2) + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + basic_os=solaris2 + ;; + j90 | j90-cray) + cpu=j90 + vendor=cray + basic_os=${basic_os:-unicos} + ;; + iris | iris4d) + cpu=mips + vendor=sgi + case $basic_os in + irix*) + ;; + *) + basic_os=irix4 + ;; + esac + ;; + miniframe) + cpu=m68000 + vendor=convergent + ;; + *mint | mint[0-9]* | *MiNT | *MiNT[0-9]*) + cpu=m68k + vendor=atari + basic_os=mint + ;; + news-3600 | risc-news) + cpu=mips + vendor=sony + basic_os=newsos + ;; + next | m*-next) + cpu=m68k + vendor=next + case $basic_os in + openstep*) + ;; + nextstep*) + ;; + ns2*) + basic_os=nextstep2 + ;; + *) + basic_os=nextstep3 + ;; + esac + ;; + np1) + cpu=np1 + vendor=gould + ;; + op50n-* | op60c-*) + cpu=hppa1.1 + vendor=oki + basic_os=proelf + ;; + pa-hitachi) + cpu=hppa1.1 + vendor=hitachi + basic_os=hiuxwe2 + ;; + pbd) + cpu=sparc + vendor=tti + ;; + pbb) + cpu=m68k + vendor=tti + ;; + pc532) + cpu=ns32k + vendor=pc532 + ;; + pn) + cpu=pn + vendor=gould + ;; + power) + cpu=power + vendor=ibm + ;; + ps2) + cpu=i386 + vendor=ibm + ;; + rm[46]00) + cpu=mips + vendor=siemens + ;; + rtpc | rtpc-*) + cpu=romp + vendor=ibm + ;; + sde) + cpu=mipsisa32 + vendor=sde + basic_os=${basic_os:-elf} + ;; + simso-wrs) + cpu=sparclite + vendor=wrs + basic_os=vxworks + ;; + tower | tower-32) + cpu=m68k + vendor=ncr + ;; + vpp*|vx|vx-*) + cpu=f301 + vendor=fujitsu + ;; + w65) + cpu=w65 + vendor=wdc + ;; + w89k-*) + cpu=hppa1.1 + vendor=winbond + basic_os=proelf + ;; + none) + cpu=none + vendor=none + ;; + leon|leon[3-9]) + cpu=sparc + vendor=$basic_machine + ;; + leon-*|leon[3-9]-*) + cpu=sparc + vendor=`echo "$basic_machine" | sed 's/-.*//'` + ;; + + *-*) + # shellcheck disable=SC2162 + saved_IFS=$IFS + IFS="-" read cpu vendor <&2 + exit 1 + ;; + esac + ;; +esac + +# Here we canonicalize certain aliases for manufacturers. +case $vendor in + digital*) + vendor=dec + ;; + commodore*) + vendor=cbm + ;; + *) + ;; +esac + +# Decode manufacturer-specific aliases for certain operating systems. + +if test x"$basic_os" != x +then + +# First recognize some ad-hoc cases, or perhaps split kernel-os, or else just +# set os. +obj= +case $basic_os in + gnu/linux*) + kernel=linux + os=`echo "$basic_os" | sed -e 's|gnu/linux|gnu|'` + ;; + os2-emx) + kernel=os2 + os=`echo "$basic_os" | sed -e 's|os2-emx|emx|'` + ;; + nto-qnx*) + kernel=nto + os=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'` + ;; + *-*) + # shellcheck disable=SC2162 + saved_IFS=$IFS + IFS="-" read kernel os <&2 + fi + ;; + *) + echo "Invalid configuration '$1': OS '$os' not recognized" 1>&2 + exit 1 + ;; +esac + +case $obj in + aout* | coff* | elf* | pe*) + ;; + '') + # empty is fine + ;; + *) + echo "Invalid configuration '$1': Machine code format '$obj' not recognized" 1>&2 + exit 1 + ;; +esac + +# Here we handle the constraint that a (synthetic) cpu and os are +# valid only in combination with each other and nowhere else. +case $cpu-$os in + # The "javascript-unknown-ghcjs" triple is used by GHC; we + # accept it here in order to tolerate that, but reject any + # variations. + javascript-ghcjs) + ;; + javascript-* | *-ghcjs) + echo "Invalid configuration '$1': cpu '$cpu' is not valid with os '$os$obj'" 1>&2 + exit 1 + ;; +esac + +# As a final step for OS-related things, validate the OS-kernel combination +# (given a valid OS), if there is a kernel. +case $kernel-$os-$obj in + linux-gnu*- | linux-android*- | linux-dietlibc*- | linux-llvm*- \ + | linux-mlibc*- | linux-musl*- | linux-newlib*- \ + | linux-relibc*- | linux-uclibc*- ) + ;; + uclinux-uclibc*- ) + ;; + managarm-mlibc*- | managarm-kernel*- ) + ;; + windows*-msvc*-) + ;; + -dietlibc*- | -llvm*- | -mlibc*- | -musl*- | -newlib*- | -relibc*- \ + | -uclibc*- ) + # These are just libc implementations, not actual OSes, and thus + # require a kernel. + echo "Invalid configuration '$1': libc '$os' needs explicit kernel." 1>&2 + exit 1 + ;; + -kernel*- ) + echo "Invalid configuration '$1': '$os' needs explicit kernel." 1>&2 + exit 1 + ;; + *-kernel*- ) + echo "Invalid configuration '$1': '$kernel' does not support '$os'." 1>&2 + exit 1 + ;; + *-msvc*- ) + echo "Invalid configuration '$1': '$os' needs 'windows'." 1>&2 + exit 1 + ;; + kfreebsd*-gnu*- | kopensolaris*-gnu*-) + ;; + vxworks-simlinux- | vxworks-simwindows- | vxworks-spe-) + ;; + nto-qnx*-) + ;; + os2-emx-) + ;; + *-eabi*- | *-gnueabi*-) + ;; + none--*) + # None (no kernel, i.e. freestanding / bare metal), + # can be paired with an machine code file format + ;; + -*-) + # Blank kernel with real OS is always fine. + ;; + --*) + # Blank kernel and OS with real machine code file format is always fine. + ;; + *-*-*) + echo "Invalid configuration '$1': Kernel '$kernel' not known to work with OS '$os'." 1>&2 + exit 1 + ;; +esac + +# Here we handle the case where we know the os, and the CPU type, but not the +# manufacturer. We pick the logical manufacturer. +case $vendor in + unknown) + case $cpu-$os in + *-riscix*) + vendor=acorn + ;; + *-sunos*) + vendor=sun + ;; + *-cnk* | *-aix*) + vendor=ibm + ;; + *-beos*) + vendor=be + ;; + *-hpux*) + vendor=hp + ;; + *-mpeix*) + vendor=hp + ;; + *-hiux*) + vendor=hitachi + ;; + *-unos*) + vendor=crds + ;; + *-dgux*) + vendor=dg + ;; + *-luna*) + vendor=omron + ;; + *-genix*) + vendor=ns + ;; + *-clix*) + vendor=intergraph + ;; + *-mvs* | *-opened*) + vendor=ibm + ;; + *-os400*) + vendor=ibm + ;; + s390-* | s390x-*) + vendor=ibm + ;; + *-ptx*) + vendor=sequent + ;; + *-tpf*) + vendor=ibm + ;; + *-vxsim* | *-vxworks* | *-windiss*) + vendor=wrs + ;; + *-aux*) + vendor=apple + ;; + *-hms*) + vendor=hitachi + ;; + *-mpw* | *-macos*) + vendor=apple + ;; + *-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*) + vendor=atari + ;; + *-vos*) + vendor=stratus + ;; + esac + ;; +esac + +echo "$cpu-$vendor${kernel:+-$kernel}${os:+-$os}${obj:+-$obj}" +exit + +# Local variables: +# eval: (add-hook 'before-save-hook 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/support/libtool/buildroot-libtool-v1.5.patch b/support/libtool/buildroot-libtool-v1.5.patch new file mode 100644 index 0000000..cdd9c5a --- /dev/null +++ b/support/libtool/buildroot-libtool-v1.5.patch @@ -0,0 +1,91 @@ +--- a/ltmain.sh 2014-07-31 10:43:01.634568799 -0300 ++++ b/ltmain.sh 2014-07-31 10:44:14.032018999 -0300 +@@ -226,8 +226,9 @@ + # line option must be used. + if test -z "$tagname"; then + $echo "$modename: unable to infer tagged configuration" +- $echo "$modename: specify a tag with \`--tag'" 1>&2 +- exit $EXIT_FAILURE ++ $echo "$modename: defaulting to \`CC'" ++ $echo "$modename: if this is not correct, specify a tag with \`--tag'" ++# exit $EXIT_FAILURE + # else + # $echo "$modename: using $tagname tagged configuration" + fi +@@ -247,6 +248,11 @@ + arg="$1" + shift + ++ # Make -static behave as -all-static ++ case $arg in ++ -static) arg="-all-static" ;; ++ esac ++ + case $arg in + -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;; + *) optarg= ;; +@@ -1238,7 +1244,8 @@ + prevarg="$arg" + + case $arg in +- -all-static) ++ # Make -static behave like -all-static ++ -all-static | -static) + if test -n "$link_static_flag"; then + compile_command="$compile_command $link_static_flag" + finalize_command="$finalize_command $link_static_flag" +@@ -2146,8 +2153,14 @@ + absdir="$abs_ladir" + libdir="$abs_ladir" + else +- dir="$libdir" +- absdir="$libdir" ++ # Adding 'libdir' from the .la file to our library search paths ++ # breaks crosscompilation horribly. We cheat here and don't add ++ # it, instead adding the path where we found the .la. -CL ++ dir="$abs_ladir" ++ absdir="$abs_ladir" ++ libdir="$abs_ladir" ++ #dir="$libdir" ++ #absdir="$libdir" + fi + else + dir="$ladir/$objdir" +@@ -2272,7 +2285,7 @@ + { test "$prefer_static_libs" = no || test -z "$old_library"; }; then + if test "$installed" = no; then + notinst_deplibs="$notinst_deplibs $lib" +- need_relink=yes ++ need_relink=no + fi + # This is a shared library + +@@ -5169,6 +5182,10 @@ + # Replace all uninstalled libtool libraries with the installed ones + newdependency_libs= + for deplib in $dependency_libs; do ++ # Replacing uninstalled with installed can easily break crosscompilation, ++ # since the installed path is generally the wrong architecture. -CL ++ newdependency_libs="$newdependency_libs $deplib" ++ continue + case $deplib in + *.la) + name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'` +@@ -5487,10 +5504,13 @@ + # At present, this check doesn't affect windows .dll's that + # are installed into $libdir/../bin (currently, that works fine) + # but it's something to keep an eye on. +- if test "$inst_prefix_dir" = "$destdir"; then +- $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2 +- exit $EXIT_FAILURE +- fi ++ # ++ # This breaks install into our staging area. -PB ++ # ++ # if test "$inst_prefix_dir" = "$destdir"; then ++ # $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2 ++ # exit $EXIT_FAILURE ++ # fi + + if test -n "$inst_prefix_dir"; then + # Stick the inst_prefix_dir data into the link command. diff --git a/support/libtool/buildroot-libtool-v2.2.patch b/support/libtool/buildroot-libtool-v2.2.patch new file mode 100644 index 0000000..8bb7826 --- /dev/null +++ b/support/libtool/buildroot-libtool-v2.2.patch @@ -0,0 +1,106 @@ +--- a/ltmain.sh 2010-06-09 15:08:53.000000000 +0200 ++++ b/ltmain.sh 2014-07-30 22:33:41.176710372 +0200 +@@ -1214,8 +1214,8 @@ + # was found and let the user know that the "--tag" command + # line option must be used. + if test -z "$tagname"; then +- func_echo "unable to infer tagged configuration" +- func_fatal_error "specify a tag with \`--tag'" ++ func_echo "defaulting to \`CC'" ++ func_echo "if this is not correct, specify a tag with \`--tag'" + # else + # func_verbose "using $tagname tagged configuration" + fi +@@ -2239,8 +2239,11 @@ + # At present, this check doesn't affect windows .dll's that + # are installed into $libdir/../bin (currently, that works fine) + # but it's something to keep an eye on. +- test "$inst_prefix_dir" = "$destdir" && \ +- func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" ++ # ++ # This breaks install into our staging area. -PB ++ # ++ # test "$inst_prefix_dir" = "$destdir" && \ ++ # func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" + + if test -n "$inst_prefix_dir"; then + # Stick the inst_prefix_dir data into the link command. +@@ -4429,7 +4432,8 @@ + ;; + -all-static | -static | -static-libtool-libs) + case $arg in +- -all-static) ++ # Make -static behave like -all-static ++ -all-static | -static) + if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then + func_warning "complete static linking is impossible in this configuration" + fi +@@ -4438,12 +4442,6 @@ + fi + prefer_static_libs=yes + ;; +- -static) +- if test -z "$pic_flag" && test -n "$link_static_flag"; then +- dlopen_self=$dlopen_self_static +- fi +- prefer_static_libs=built +- ;; + -static-libtool-libs) + if test -z "$pic_flag" && test -n "$link_static_flag"; then + dlopen_self=$dlopen_self_static +@@ -4726,7 +4724,8 @@ + prevarg="$arg" + + case $arg in +- -all-static) ++ # Make -static behave like -all-static ++ -all-static | -static) + if test -n "$link_static_flag"; then + # See comment for -static flag below, for more details. + func_append compile_command " $link_static_flag" +@@ -4995,7 +4994,7 @@ + continue + ;; + +- -static | -static-libtool-libs) ++ -static-libtool-libs) + # The effects of -static are defined in a previous loop. + # We used to do the same as -all-static on platforms that + # didn't have a PIC flag, but the assumption that the effects +@@ -5739,8 +5738,14 @@ + absdir="$abs_ladir" + libdir="$abs_ladir" + else +- dir="$libdir" +- absdir="$libdir" ++ # Adding 'libdir' from the .la file to our library search paths ++ # breaks crosscompilation horribly. We cheat here and don't add ++ # it, instead adding the path where we found the .la. -CL ++ dir="$abs_ladir" ++ absdir="$abs_ladir" ++ libdir="$abs_ladir" ++ #dir="$libdir" ++ #absdir="$libdir" + fi + test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes + else +@@ -5891,7 +5896,7 @@ + *) + if test "$installed" = no; then + notinst_deplibs="$notinst_deplibs $lib" +- need_relink=yes ++ need_relink=no + fi + ;; + esac +@@ -8373,6 +8378,10 @@ + # Replace all uninstalled libtool libraries with the installed ones + newdependency_libs= + for deplib in $dependency_libs; do ++ # Replacing uninstalled with installed can easily break crosscompilation, ++ # since the installed path is generally the wrong architecture. -CL ++ newdependency_libs="$newdependency_libs $deplib" ++ continue + case $deplib in + *.la) + func_basename "$deplib" diff --git a/support/libtool/buildroot-libtool-v2.4.4.patch b/support/libtool/buildroot-libtool-v2.4.4.patch new file mode 100644 index 0000000..bcdf30c --- /dev/null +++ b/support/libtool/buildroot-libtool-v2.4.4.patch @@ -0,0 +1,95 @@ +Libtool fixes for cross-compilation, many past contributors/authors. +Update based on libtool-2.4.4, useful for 2.4.3 as well but not 2.4.2. + +Signed-off-by: Gustavo Zacarias + +--- a/ltmain.sh 2014-12-16 09:51:23.068441045 -0300 ++++ b/ltmain.sh 2014-12-16 09:57:10.509430339 -0300 +@@ -2687,8 +2687,8 @@ + # was found and let the user know that the "--tag" command + # line option must be used. + if test -z "$tagname"; then +- func_echo "unable to infer tagged configuration" +- func_fatal_error "specify a tag with '--tag'" ++ func_echo "defaulting to \`CC'" ++ func_echo "if this is not correct, specify a tag with \`--tag'" + # else + # func_verbose "using $tagname tagged configuration" + fi +@@ -4277,8 +4277,12 @@ + # At present, this check doesn't affect windows .dll's that + # are installed into $libdir/../bin (currently, that works fine) + # but it's something to keep an eye on. +- test "$inst_prefix_dir" = "$destdir" && \ +- func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" ++ ++ # ++ # This breaks install into our staging area. -PB ++ # ++ #test "$inst_prefix_dir" = "$destdir" && \ ++ # func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" + + if test -n "$inst_prefix_dir"; then + # Stick the inst_prefix_dir data into the link command. +@@ -6550,7 +6554,8 @@ + ;; + -all-static | -static | -static-libtool-libs) + case $arg in +- -all-static) ++ # Make -static behave like -all-static -GZ ++ -all-static | -static) + if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then + func_warning "complete static linking is impossible in this configuration" + fi +@@ -6559,12 +6564,6 @@ + fi + prefer_static_libs=yes + ;; +- -static) +- if test -z "$pic_flag" && test -n "$link_static_flag"; then +- dlopen_self=$dlopen_self_static +- fi +- prefer_static_libs=built +- ;; + -static-libtool-libs) + if test -z "$pic_flag" && test -n "$link_static_flag"; then + dlopen_self=$dlopen_self_static +@@ -6858,7 +6857,8 @@ + prevarg=$arg + + case $arg in +- -all-static) ++ # Make -static behave like -all-static -GZ ++ -all-static | -static) + if test -n "$link_static_flag"; then + # See comment for -static flag below, for more details. + func_append compile_command " $link_static_flag" +@@ -7149,7 +7149,7 @@ + continue + ;; + +- -static | -static-libtool-libs) ++ -static-libtool-libs) + # The effects of -static are defined in a previous loop. + # We used to do the same as -all-static on platforms that + # didn't have a PIC flag, but the assumption that the effects +@@ -8112,7 +8112,7 @@ + *) + if test no = "$installed"; then + func_append notinst_deplibs " $lib" +- need_relink=yes ++ need_relink=no + fi + ;; + esac +@@ -10710,6 +10710,10 @@ + # Replace all uninstalled libtool libraries with the installed ones + newdependency_libs= + for deplib in $dependency_libs; do ++ # Replacing uninstalled with installed can easily break crosscompilation, ++ # since the installed path is generally the wrong architecture. -CL ++ newdependency_libs="$newdependency_libs $deplib" ++ continue + case $deplib in + *.la) + func_basename "$deplib" diff --git a/support/libtool/buildroot-libtool-v2.4.patch b/support/libtool/buildroot-libtool-v2.4.patch new file mode 100644 index 0000000..f610b1b --- /dev/null +++ b/support/libtool/buildroot-libtool-v2.4.patch @@ -0,0 +1,89 @@ +--- a/ltmain.sh 2014-07-30 22:21:24.664684143 +0200 ++++ b/ltmain.sh 2014-07-30 22:23:02.440687625 +0200 +@@ -1417,8 +1417,8 @@ + # was found and let the user know that the "--tag" command + # line option must be used. + if test -z "$tagname"; then +- func_echo "unable to infer tagged configuration" +- func_fatal_error "specify a tag with \`--tag'" ++ func_echo "defaulting to \`CC'" ++ func_echo "if this is not correct, specify a tag with \`--tag'" + # else + # func_verbose "using $tagname tagged configuration" + fi +@@ -2963,8 +2963,11 @@ + # At present, this check doesn't affect windows .dll's that + # are installed into $libdir/../bin (currently, that works fine) + # but it's something to keep an eye on. +- test "$inst_prefix_dir" = "$destdir" && \ +- func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" ++ # ++ # This breaks install into our staging area. -PB ++ # ++ # test "$inst_prefix_dir" = "$destdir" && \ ++ # func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" + + if test -n "$inst_prefix_dir"; then + # Stick the inst_prefix_dir data into the link command. +@@ -5176,7 +5179,8 @@ + ;; + -all-static | -static | -static-libtool-libs) + case $arg in +- -all-static) ++ # Make -static behave like -all-static ++ -all-static | -static) + if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then + func_warning "complete static linking is impossible in this configuration" + fi +@@ -5185,12 +5189,6 @@ + fi + prefer_static_libs=yes + ;; +- -static) +- if test -z "$pic_flag" && test -n "$link_static_flag"; then +- dlopen_self=$dlopen_self_static +- fi +- prefer_static_libs=built +- ;; + -static-libtool-libs) + if test -z "$pic_flag" && test -n "$link_static_flag"; then + dlopen_self=$dlopen_self_static +@@ -5473,7 +5471,8 @@ + prevarg="$arg" + + case $arg in +- -all-static) ++ # Make -static behave like -all-static ++ -all-static | -static) + if test -n "$link_static_flag"; then + # See comment for -static flag below, for more details. + func_append compile_command " $link_static_flag" +@@ -5754,7 +5753,7 @@ + continue + ;; + +- -static | -static-libtool-libs) ++ -static-libtool-libs) + # The effects of -static are defined in a previous loop. + # We used to do the same as -all-static on platforms that + # didn't have a PIC flag, but the assumption that the effects +@@ -6697,7 +6696,7 @@ + *) + if test "$installed" = no; then + func_append notinst_deplibs " $lib" +- need_relink=yes ++ need_relink=no + fi + ;; + esac +@@ -9275,6 +9274,10 @@ + # Replace all uninstalled libtool libraries with the installed ones + newdependency_libs= + for deplib in $dependency_libs; do ++ # Replacing uninstalled with installed can easily break crosscompilation, ++ # since the installed path is generally the wrong architecture. -CL ++ newdependency_libs="$newdependency_libs $deplib" ++ continue + case $deplib in + *.la) + func_basename "$deplib" diff --git a/support/scripts/apply-patches.sh b/support/scripts/apply-patches.sh new file mode 100755 index 0000000..2acaa63 --- /dev/null +++ b/support/scripts/apply-patches.sh @@ -0,0 +1,167 @@ +#!/usr/bin/env bash +# A little script I whipped up to make it easy to +# patch source trees and have sane error handling +# -Erik +# +# (c) 2002 Erik Andersen +# +# Parameters: +# - "-s", optional. Silent operation, don't print anything if there +# isn't any error. +# - the build directory, optional, default value is '.'. The place where are +# the package sources. +# - the patch directory, optional, default '../kernel-patches'. The place +# where are the scripts you want to apply. +# - other parameters are the patch name patterns, optional, default value is +# '*'. Pattern(s) describing the patch names you want to apply. +# +# The script will look recursively for patches from the patch directory. If a +# file named 'series' exists then the patches mentioned in it will be applied +# as plain patches, regardless of their file name. If no 'series' file exists, +# the script will look for file names matching pattern(s). If the name +# ends with '.tar.*', '.tbz2' or '.tgz', the file is considered as an archive +# and will be uncompressed into a directory named +# '.patches-name_of_the_archive-unpacked'. It's the turn of this directory to +# be scanned with '*' as pattern. Remember that scanning is recursive. Other +# files than series file and archives are considered as a patch. +# +# Once a patch is found, the script will try to apply it. If its name doesn't +# end with '.gz', '.bz', '.bz2', '.xz', '.zip', '.Z', '.diff*' or '.patch*', +# it will be skipped. If necessary, the patch will be uncompressed before being +# applied. The list of the patches applied is stored in '.applied_patches_list' +# file in the build directory. + +set -e + +silent= +if [ "$1" = "-s" ] ; then + # add option to be used by the patch tool + silent=-s + shift +fi + +# Set directories from arguments, or use defaults. +builddir=${1-.} +patchdir=${2-../kernel-patches} +shift 2 +patchpattern=${@-*} + +export TAR=${TAR:-tar} + +# use a well defined sorting order +export LC_COLLATE=C + +if [ ! -d "${builddir}" ] ; then + echo "Aborting. '${builddir}' is not a directory." + exit 1 +fi +if [ ! -d "${patchdir}" ] ; then + echo "Aborting. '${patchdir}' is not a directory." + exit 1 +fi + +# Remove any rejects present BEFORE patching - Because if there are +# any, even if patches are well applied, at the end it will complain +# about rejects in builddir. +find ${builddir}/ '(' -name '*.rej' -o -name '.*.rej' ')' -print0 | \ + xargs -0 -r rm -f + +function apply_patch { + path="${1%%/}" + patch="${2}" + case "${path}" in + /*) ;; + *) path="$PWD/${path}";; + esac + if [ "$3" ]; then + type="series"; uncomp="cat" + else + case "$patch" in + *.gz) + type="gzip"; uncomp="gunzip -dc"; ;; + *.bz) + type="bzip"; uncomp="bunzip -dc"; ;; + *.bz2) + type="bzip2"; uncomp="bunzip2 -dc"; ;; + *.xz) + type="xz"; uncomp="unxz -dc"; ;; + *.zip) + type="zip"; uncomp="unzip -d"; ;; + *.Z) + type="compress"; uncomp="uncompress -c"; ;; + *.diff*) + type="diff"; uncomp="cat"; ;; + *.patch*) + type="patch"; uncomp="cat"; ;; + *) + echo "Unsupported file type for ${path}/${patch}, skipping"; + return 0 + ;; + esac + fi + if [ -z "$silent" ] ; then + echo "" + echo "Applying $patch using ${type}: " + fi + if [ ! -e "${path}/$patch" ] ; then + echo "Error: missing patch file ${path}/$patch" + exit 1 + fi + existing="$(grep -E "/${patch}\$" ${builddir}/.applied_patches_list || true)" + if [ -n "${existing}" ]; then + echo "Error: duplicate filename '${patch}'" + echo "Conflicting files are:" + echo " already applied: ${existing}" + echo " to be applied : ${path}/${patch}" + exit 1 + fi + echo "${path}/${patch}" >> ${builddir}/.applied_patches_list + ${uncomp} "${path}/$patch" | patch -F0 -g0 -p1 --no-backup-if-mismatch -d "${builddir}" -t -N $silent + if [ $? != 0 ] ; then + echo "Patch failed! Please fix ${patch}!" + exit 1 + fi +} + +function scan_patchdir { + local path=$1 + shift 1 + patches=${@-*} + + # If there is a series file, use it instead of using ls sort order + # to apply patches. Skip line starting with a dash. + if [ -e "${path}/series" ] ; then + # The format of a series file accepts a second field that is + # used to specify the number of directory components to strip + # when applying the patch, in the form -pN (N an integer >= 0) + # We assume this field to always be -p1 whether it is present + # or missing. + series_patches="`grep -Ev "^#" ${path}/series | cut -d ' ' -f1 2> /dev/null`" + for i in $series_patches; do + apply_patch "$path" "$i" series + done + else + for i in `cd $path; ls -d $patches 2> /dev/null` ; do + if [ -d "${path}/$i" ] ; then + scan_patchdir "${path}/$i" + elif echo "$i" | grep -q -E "\.tar(\..*)?$|\.tbz2?$|\.tgz$" ; then + unpackedarchivedir="$builddir/.patches-$(basename $i)-unpacked" + rm -rf "$unpackedarchivedir" 2> /dev/null + mkdir "$unpackedarchivedir" + ${TAR} -C "$unpackedarchivedir" -xaf "${path}/$i" + scan_patchdir "$unpackedarchivedir" + else + apply_patch "$path" "$i" + fi + done + fi +} + +touch ${builddir}/.applied_patches_list +scan_patchdir "$patchdir" "$patchpattern" + +# Check for rejects... +if [ "`find $builddir/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; then + echo "Aborting. Reject files found." + exit 1 +fi diff --git a/support/scripts/check-bin-arch b/support/scripts/check-bin-arch new file mode 100755 index 0000000..27cc59b --- /dev/null +++ b/support/scripts/check-bin-arch @@ -0,0 +1,96 @@ +#!/usr/bin/env bash + +# List of hardcoded paths that should be ignored, as they may +# contain binaries for an architecture different from the +# architecture of the target. +declare -a IGNORES=( + # Skip firmware files, they could be ELF files for other + # architectures + "/lib/firmware" + "/usr/lib/firmware" + + # Skip kernel modules + # When building a 32-bit userland on 64-bit architectures, the kernel + # and its modules may still be 64-bit. To keep the basic + # check-bin-arch logic simple, just skip this directory. + "/lib/modules" + "/usr/lib/modules" + + # Skip files in /usr/share, several packages (qemu, + # pru-software-support) legitimately install ELF binaries that + # are not for the target architecture + "/usr/share" + + # Skip files in {/usr,}/lib/grub, since it is possible to have + # it for a different architecture (e.g. i386 grub on x86_64). + "/lib/grub" + "/usr/lib/grub" + + # Guile modules are ELF files, with a "None" machine + "/usr/lib/guile" +) + +while getopts p:l:r:a:i: OPT ; do + case "${OPT}" in + p) package="${OPTARG}";; + l) pkg_list="${OPTARG}";; + r) readelf="${OPTARG}";; + a) arch_name="${OPTARG}";; + i) + # Ensure we do have single '/' as separators, + # and that we have a leading and a trailing one. + pattern="$(sed -r -e 's:/+:/:g; s:^/*:/:; s:/*$:/:;' <<<"${OPTARG}")" + IGNORES+=("${pattern}") + ;; + :) error "option '%s' expects a mandatory argument\n" "${OPTARG}";; + \?) error "unknown option '%s'\n" "${OPTARG}";; + esac +done + +if test -z "${package}" -o -z "${pkg_list}" -o -z "${readelf}" -o -z "${arch_name}" ; then + echo "Usage: $0 -p -l -r -a [-i PATH ...]" + exit 1 +fi + +exitcode=0 + +# Only split on new lines, for filenames-with-spaces +IFS=" +" + +while read f; do + for ignore in "${IGNORES[@]}"; do + if [[ "${f}" =~ ^"${ignore}" ]]; then + continue 2 + fi + done + + # Skip symlinks. Some symlinks may have absolute paths as + # target, pointing to host binaries while we're building. + if [[ -L "${TARGET_DIR}/${f}" ]]; then + continue + fi + + # Get architecture using readelf. We pipe through 'head -1' so + # that when the file is a static library (.a), we only take + # into account the architecture of the first object file. + arch=$(LC_ALL=C ${readelf} -h "${TARGET_DIR}/${f}" 2>&1 | \ + sed -r -e '/^ Machine: +(.+)/!d; s//\1/;' | head -1) + + # If no architecture found, assume it was not an ELF file + if test "${arch}" = "" ; then + continue + fi + + # Architecture is correct + if test "${arch}" = "${arch_name}" ; then + continue + fi + + printf 'ERROR: architecture for "%s" is "%s", should be "%s"\n' \ + "${f}" "${arch}" "${arch_name}" + + exitcode=1 +done < <( sed -r -e "/^${package},\.(.+)$/!d; s//\1/;" ${pkg_list} ) + +exit ${exitcode} diff --git a/support/scripts/check-host-rpath b/support/scripts/check-host-rpath new file mode 100755 index 0000000..41aa0aa --- /dev/null +++ b/support/scripts/check-host-rpath @@ -0,0 +1,111 @@ +#!/usr/bin/env bash + +# This script scans $(HOST_DIR)/{bin,sbin} for all ELF files, and checks +# they have an RPATH to $(HOST_DIR)/lib if they need libraries from +# there. + +# Override the user's locale so we are sure we can parse the output of +# readelf(1) and file(1) +export LC_ALL=C + +main() { + local pkg="${1}" + local hostdir="${2}" + local perpackagedir="${3}" + local file ret + + # Remove duplicate and trailing '/' for proper match + hostdir="$( sed -r -e 's:/+:/:g; s:/$::;' <<<"${hostdir}" )" + + ret=0 + while read file; do + is_elf "${file}" || continue + elf_needs_rpath "${file}" "${hostdir}" || continue + check_elf_has_rpath "${file}" "${hostdir}" "${perpackagedir}" && continue + if [ ${ret} -eq 0 ]; then + ret=1 + printf "***\n" + printf "*** ERROR: package %s installs executables without proper RPATH:\n" "${pkg}" + fi + printf "*** %s\n" "${file}" + done < <( find "${hostdir}"/{bin,sbin} -type f 2>/dev/null ) + + return ${ret} +} + +is_elf() { + local f="${1}" + + readelf -l "${f}" 2>/dev/null \ + |grep -E 'Requesting program interpreter:' >/dev/null 2>&1 +} + +# This function tells whether a given ELF executable (first argument) +# needs a RPATH pointing to the host library directory or not. It +# needs such an RPATH if at least of the libraries used by the ELF +# executable is available in the host library directory. This function +# returns 0 when a RPATH is needed, 1 otherwise. +# +# With per-package directory support, ${hostdir} will point to the +# current package per-package host directory, and this is where this +# function will check if the libraries needed by the executable are +# located (or not). In practice, the ELF executable RPATH may point to +# another package per-package host directory, but that is fine because +# if such an executable is within the current package per-package host +# directory, its libraries will also have been copied into the current +# package per-package host directory. +elf_needs_rpath() { + local file="${1}" + local hostdir="${2}" + local lib + + while read lib; do + [ -e "${hostdir}/lib/${lib}" ] && return 0 + done < <( readelf -d "${file}" 2>/dev/null \ + |sed -r -e '/^.* \(NEEDED\) .*Shared library: \[(.+)\]$/!d;' \ + -e 's//\1/;' \ + ) + + return 1 +} + +# This function checks whether at least one of the RPATH of the given +# ELF executable (first argument) properly points to the host library +# directory (second argument), either through an absolute RPATH or a +# relative RPATH. In the context of per-package directory support, +# ${hostdir} (second argument) points to the current package host +# directory. However, it is perfectly valid for an ELF binary to have +# a RPATH pointing to another package per-package host directory, +# which is why such RPATH is also accepted (the per-package directory +# gets passed as third argument). Having a RPATH pointing to the host +# directory will make sure the ELF executable will find at runtime the +# shared libraries it depends on. This function returns 0 when a +# proper RPATH was found, or 1 otherwise. +check_elf_has_rpath() { + local file="${1}" + local hostdir="${2}" + local perpackagedir="${3}" + local rpath dir + + while read rpath; do + for dir in ${rpath//:/ }; do + # Remove duplicate and trailing '/' for proper match + dir="$( sed -r -e 's:/+:/:g; s:/$::;' <<<"${dir}" )" + [ "${dir}" = "${hostdir}/lib" ] && return 0 + [ "${dir}" = "\$ORIGIN/../lib" ] && return 0 + # This check is done even for builds where + # BR2_PER_PACKAGE_DIRECTORIES is disabled. In this case, + # PER_PACKAGE_DIR and therefore ${perpackagedir} points to + # a non-existent directory, and this check will always be + # false. + [[ ${dir} =~ "${perpackagedir}/"[^/]+/host/lib ]] && return 0 + done + done < <( readelf -d "${file}" 2>/dev/null \ + |sed -r -e '/.* \(R(UN)?PATH\) +Library r(un)?path: \[(.+)\]$/!d' \ + -e 's//\3/;' \ + ) + + return 1 +} + +main "${@}" diff --git a/support/scripts/check-kernel-headers.sh b/support/scripts/check-kernel-headers.sh new file mode 100755 index 0000000..4e6dce5 --- /dev/null +++ b/support/scripts/check-kernel-headers.sh @@ -0,0 +1,69 @@ +#!/bin/sh + +# This script (and the embedded C code) will check that the actual +# headers version match the user told us they were: +# +# - if both versions are the same, all is well. +# +# - if the actual headers are older than the user told us, this is +# an error. +# +# - if the actual headers are more recent than the user told us, and +# we are doing a strict check, then this is an error. +# +# - if the actual headers are more recent than the user told us, and +# we are doing a loose check, then a warning is printed, but this is +# not an error. + +BUILDDIR="${1}" +SYSROOT="${2}" +# Make sure we have enough version components +HDR_VER="${3}.0.0" +CHECK="${4}" # 'strict' or 'loose' + +HDR_M="${HDR_VER%%.*}" +HDR_V="${HDR_VER#*.}" +HDR_m="${HDR_V%%.*}" + +# Exit on any error, so we don't try to run an unexisting program if the +# compilation fails. +set -e + +# Set the clean-up trap in advance to prevent a race condition in which we +# create the file but get a SIGTERM before setting it. Notice that we don't +# need to care about EXEC being empty, since 'rm -f ""' does nothing. +trap 'rm -f "${EXEC}"' EXIT + +EXEC="$(mktemp -p "${BUILDDIR}" -t .check-headers.XXXXXX)" + +# We do not want to account for the patch-level, since headers are +# not supposed to change for different patchlevels, so we mask it out. +# This only applies to kernels >= 3.0, but those are the only one +# we actually care about; we treat all 2.6.x kernels equally. +${HOSTCC} -imacros "${SYSROOT}/usr/include/linux/version.h" \ + -x c -o "${EXEC}" - <<_EOF_ +#include +#include +#include + +int main(int argc __attribute__((unused)), + char** argv __attribute__((unused))) +{ + int l = LINUX_VERSION_CODE & ~0xFF; + int h = KERNEL_VERSION(${HDR_M},${HDR_m},0); + + if ((l >= h) && !strcmp("${CHECK}", "loose")) + return 0; + + if (l != h) { + printf("Incorrect selection of kernel headers: "); + printf("expected %d.%d.x, got %d.%d.x\n", ${HDR_M}, ${HDR_m}, + ((LINUX_VERSION_CODE>>16) & 0xFF), + ((LINUX_VERSION_CODE>>8) & 0xFF)); + return 1; + } + return 0; +} +_EOF_ + +"${EXEC}" diff --git a/support/scripts/fix-rpath b/support/scripts/fix-rpath new file mode 100755 index 0000000..afca707 --- /dev/null +++ b/support/scripts/fix-rpath @@ -0,0 +1,193 @@ +#!/usr/bin/env bash + +# Copyright (C) 2016 Samuel Martin +# Copyright (C) 2017 Wolfgang Grandegger +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +usage() { + cat <&2 +Usage: ${0} TREE_KIND + +Description: + + This script scans a tree and sanitize ELF files' RPATH found in there. + + Sanitization behaves the same whatever the kind of the processed tree, + but the resulting RPATH differs. The rpath sanitization is done using + "patchelf --make-rpath-relative". + +Arguments: + + TREE_KIND Kind of tree to be processed. + Allowed values: host, target, staging + +Environment: + + PATCHELF patchelf program to use + (default: HOST_DIR/bin/patchelf) + + HOST_DIR host directory + STAGING_DIR staging directory + TARGET_DIR target directory + + TOOLCHAIN_EXTERNAL_DOWNLOAD_INSTALL_DIR + (default HOST_DIR/opt/ext-toolchain) + + PARALLEL_JOBS number of parallel jobs to run + +Returns: 0 if success or 1 in case of error + +EOF +} + +: "${PATCHELF:=${HOST_DIR}/bin/patchelf}" + +# ELF files should not be in these sub-directories +HOST_EXCLUDEPATHS="/share/terminfo" +STAGING_EXCLUDEPATHS="/usr/include /usr/share/terminfo" +TARGET_EXCLUDEPATHS="/lib/firmware" + +declare -a sanitize_extra_args +rootdir= + +patch_file() { + local file="${1}" + + # check if it's an ELF file + rpath="$("${PATCHELF}" --print-rpath "${file}" 2>&1)" + if test $? -ne 0 ; then + return 0 + fi + + # make files writable if necessary + changed="$(chmod -c u+w "${file}")" + + # With per-package directory support, most RPATH of host + # binaries will point to per-package directories. This won't + # work with the --make-rpath-relative ${rootdir} invocation as + # the per-package host directory is not within ${rootdir}. So, + # we rewrite all RPATHs pointing to per-package directories so + # that they point to the global host directory. + # shellcheck disable=SC2001 # ${var//search/replace} hard when search or replace have / in them + changed_rpath="$(echo "${rpath}" | sed "s@${PER_PACKAGE_DIR}/[^/]\+/host@${HOST_DIR}@g")" + if test "${rpath}" != "${changed_rpath}" ; then + "${PATCHELF}" --set-rpath "${changed_rpath}" "${file}" + fi + + # call patchelf to sanitize the rpath + "${PATCHELF}" --make-rpath-relative "${rootdir}" "${sanitize_extra_args[@]}" "${file}" + # restore the original permission + test "${changed}" != "" && chmod u-w "${file}" +} + +patch_files() { + while read -r -d $'\0' file; do + # for performance reasons, we want to do as little work as + # possible on non-ELF files. therefore, make sure that the + # file at least starts with the ELF magic before handing it of + # to patchelf, which will then perform the proper validation. + read -r -n4 magic <"${file}" && test "${magic}" != $'\x7fELF' && continue + + patch_file "${file}" + done +} + +main() { + local tree + local -a find_args + + tree="${1}" + + if ! "${PATCHELF}" --version > /dev/null 2>&1; then + echo "Error: can't execute patchelf utility '${PATCHELF}'" + exit 1 + fi + + case "${tree}" in + host) + rootdir="${HOST_DIR}" + + # do not process the sysroot (only contains target binaries) + find_args+=( "-path" "${STAGING_DIR}" "-prune" "-o" ) + + # do not process the external toolchain installation directory to + # avoid breaking it. + test "${TOOLCHAIN_EXTERNAL_DOWNLOAD_INSTALL_DIR}" != "" && \ + find_args+=( "-path" "${TOOLCHAIN_EXTERNAL_DOWNLOAD_INSTALL_DIR}" "-prune" "-o" ) + + for excludepath in ${HOST_EXCLUDEPATHS}; do + find_args+=( "-path" "${HOST_DIR}""${excludepath}" "-prune" "-o" ) + done + + # do not process the patchelf binary but a copy to work-around "file in use" + find_args+=( "-path" "${PATCHELF}" "-prune" "-o" ) + cp "${PATCHELF}" "${PATCHELF}.__to_be_patched" + + # we always want $ORIGIN-based rpaths to make it relocatable. + sanitize_extra_args+=( "--relative-to-file" ) + ;; + + staging) + rootdir="${STAGING_DIR}" + + # ELF files should not be in these sub-directories + for excludepath in ${STAGING_EXCLUDEPATHS}; do + find_args+=( "-path" "${STAGING_DIR}""${excludepath}" "-prune" "-o" ) + done + + # should be like for the target tree below + sanitize_extra_args+=( "--no-standard-lib-dirs" ) + ;; + + target) + rootdir="${TARGET_DIR}" + + for excludepath in ${TARGET_EXCLUDEPATHS}; do + find_args+=( "-path" "${TARGET_DIR}""${excludepath}" "-prune" "-o" ) + done + + # we don't want $ORIGIN-based rpaths but absolute paths without rootdir. + # we also want to remove rpaths pointing to /lib or /usr/lib. + sanitize_extra_args+=( "--no-standard-lib-dirs" ) + ;; + + *) + usage + exit 1 + ;; + esac + + work=$(mktemp --tmpdir -d fix-rpath.XXXXXXXX) + + find_args+=( "-type" "f" "-print0" ) + find "${rootdir}" "${find_args[@]}" \ + | split -t '\0' -a4 -d -n "r/${PARALLEL_JOBS:-1}" "-" "${work}/part" + + for part in "${work}/part"*; do + patch_files <"${part}" & + done + wait + + rm -rf "${work}" + + # Restore patched patchelf utility + test "${tree}" = "host" && mv "${PATCHELF}.__to_be_patched" "${PATCHELF}" + + # ignore errors + return 0 +} + +main "${@}" diff --git a/support/scripts/mkusers b/support/scripts/mkusers new file mode 100755 index 0000000..91c8aa0 --- /dev/null +++ b/support/scripts/mkusers @@ -0,0 +1,486 @@ +#!/usr/bin/env bash +set -e +myname="${0##*/}" + +#---------------------------------------------------------------------------- +# Configurable items +FIRST_USER_UID=1000 +LAST_USER_UID=1999 +FIRST_USER_GID=1000 +LAST_USER_GID=1999 +# use names from /etc/adduser.conf +FIRST_SYSTEM_UID=100 +LAST_SYSTEM_UID=999 +FIRST_SYSTEM_GID=100 +LAST_SYSTEM_GID=999 +# argument to automatically crease system/user id +AUTO_SYSTEM_ID=-1 +AUTO_USER_ID=-2 + +# No more is configurable below this point +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +error() { + local fmt="${1}" + shift + + printf "%s: " "${myname}" >&2 + # shellcheck disable=SC2059 # fmt is the format passed to error() + printf "${fmt}" "${@}" >&2 +} +fail() { + error "$@" + exit 1 +} + +#---------------------------------------------------------------------------- +if [ ${#} -ne 2 ]; then + fail "usage: %s USERS_TABLE TARGET_DIR\n" +fi +USERS_TABLE="${1}" +TARGET_DIR="${2}" +shift 2 +PASSWD="${TARGET_DIR}/etc/passwd" +SHADOW="${TARGET_DIR}/etc/shadow" +GROUP="${TARGET_DIR}/etc/group" +# /etc/gshadow is not part of the standard skeleton, so not everybody +# will have it, but some may have it, and its content must be in sync +# with /etc/group, so any use of gshadow must be conditional. +GSHADOW="${TARGET_DIR}/etc/gshadow" + +# We can't simply source ${BR2_CONFIG} as it may contains constructs +# such as: +# BR2_DEFCONFIG="$(CONFIG_DIR)/defconfig" +# which when sourced from a shell script will eventually try to execute +# a command named 'CONFIG_DIR', which is plain wrong for virtually every +# systems out there. +# So, we have to scan that file instead. Sigh... :-( +PASSWD_METHOD="sha-256" +# PASSWD_METHOD="$( sed -r -e '/^BR2_TARGET_GENERIC_PASSWD_METHOD="(.*)"$/!d;' \ +# -e 's//\1/;' \ +# "${BR2_CONFIG}" \ +# )" + +#---------------------------------------------------------------------------- +get_uid() { + local username="${1}" + + awk -F: -v username="${username}" \ + '$1 == username { printf( "%d\n", $3 ); }' "${PASSWD}" +} + +#---------------------------------------------------------------------------- +get_ugid() { + local username="${1}" + + awk -F: -v username="${username}" \ + '$1 == username { printf( "%d\n", $4 ); }' "${PASSWD}" +} + +#---------------------------------------------------------------------------- +get_gid() { + local group="${1}" + + awk -F: -v group="${group}" \ + '$1 == group { printf( "%d\n", $3 ); }' "${GROUP}" +} + +#---------------------------------------------------------------------------- +get_members() { + local group="${1}" + + awk -F: -v group="${group}" \ + '$1 == group { printf( "%s\n", $4 ); }' "${GROUP}" +} + +#---------------------------------------------------------------------------- +get_username() { + local uid="${1}" + + awk -F: -v uid="${uid}" \ + '$3 == uid { printf( "%s\n", $1 ); }' "${PASSWD}" +} + +#---------------------------------------------------------------------------- +get_group() { + local gid="${1}" + + awk -F: -v gid="${gid}" \ + '$3 == gid { printf( "%s\n", $1 ); }' "${GROUP}" +} + +#---------------------------------------------------------------------------- +get_ugroup() { + local username="${1}" + local ugid + + ugid="$( get_ugid "${username}" )" + if [ -n "${ugid}" ]; then + get_group "${ugid}" + fi +} + +#---------------------------------------------------------------------------- +# Sanity-check the new user/group: +# - check the gid is not already used for another group +# - check the group does not already exist with another gid +# - check the user does not already exist with another gid +# - check the uid is not already used for another user +# - check the user does not already exist with another uid +# - check the user does not already exist in another group +check_user_validity() { + local username="${1}" + local uid="${2}" + local group="${3}" + local gid="${4}" + local _uid _ugid _gid _username _group _ugroup + + _group="$( get_group "${gid}" )" + _gid="$( get_gid "${group}" )" + _ugid="$( get_ugid "${username}" )" + _username="$( get_username "${uid}" )" + _uid="$( get_uid "${username}" )" + _ugroup="$( get_ugroup "${username}" )" + + if [ "${username}" = "root" ]; then + fail "invalid username '%s\n'" "${username}" + fi + + # shellcheck disable=SC2086 # gid is a non-empty int + # shellcheck disable=SC2166 # [ .. -o .. ] works well in this case + if [ ${gid} -lt -2 -o ${gid} -eq 0 ]; then + fail "invalid gid '%d' for '%s'\n" ${gid} "${username}" + elif [ ${gid} -ge 0 ]; then + # check the gid is not already used for another group + if [ -n "${_group}" -a "${_group}" != "${group}" ]; then + fail "gid '%d' for '%s' is already used by group '%s'\n" \ + ${gid} "${username}" "${_group}" + fi + + # check the group does not already exists with another gid + # Need to split the check in two, otherwise '[' complains it + # is missing arguments when _gid is empty + if [ -n "${_gid}" ] && [ ${_gid} -ne ${gid} ]; then + fail "group '%s' for '%s' already exists with gid '%d' (wants '%d')\n" \ + "${group}" "${username}" ${_gid} ${gid} + fi + + # check the user does not already exists with another gid + # Need to split the check in two, otherwise '[' complains it + # is missing arguments when _ugid is empty + if [ -n "${_ugid}" ] && [ ${_ugid} -ne ${gid} ]; then + fail "user '%s' already exists with gid '%d' (wants '%d')\n" \ + "${username}" ${_ugid} ${gid} + fi + fi + + # shellcheck disable=SC2086 # uid is a non-empty int + # shellcheck disable=SC2166 # [ .. -o .. ] works well in this case + if [ ${uid} -lt -2 -o ${uid} -eq 0 ]; then + fail "invalid uid '%d' for '%s'\n" ${uid} "${username}" + elif [ ${uid} -ge 0 ]; then + # check the uid is not already used for another user + if [ -n "${_username}" -a "${_username}" != "${username}" ]; then + fail "uid '%d' for '%s' already used by user '%s'\n" \ + ${uid} "${username}" "${_username}" + fi + + # check the user does not already exists with another uid + # Need to split the check in two, otherwise '[' complains it + # is missing arguments when _uid is empty + if [ -n "${_uid}" ] && [ ${_uid} -ne ${uid} ]; then + fail "user '%s' already exists with uid '%d' (wants '%d')\n" \ + "${username}" ${_uid} ${uid} + fi + fi + + # check the user does not already exist in another group + # shellcheck disable=SC2166 # [ .. -a .. ] works well in this case + if [ -n "${_ugroup}" -a "${_ugroup}" != "${group}" ]; then + fail "user '%s' already exists with group '%s' (wants '%s')\n" \ + "${username}" "${_ugroup}" "${group}" + fi + + return 0 +} + +#---------------------------------------------------------------------------- +# Generate a unique GID for given group. If the group already exists, +# then simply report its current GID. Otherwise, generate the lowest GID +# that is: +# - not 0 +# - comprised in [$2..$3] +# - not already used by a group +generate_gid() { + local group="${1}" + local mingid="${2}" + local maxgid="${3}" + local gid + + gid="$( get_gid "${group}" )" + if [ -z "${gid}" ]; then + for(( gid=mingid; gid<=maxgid; gid++ )); do + if [ -z "$( get_group "${gid}" )" ]; then + break + fi + done + # shellcheck disable=SC2086 # gid and maxgid are non-empty ints + if [ ${gid} -gt ${maxgid} ]; then + fail "can not allocate a GID for group '%s'\n" "${group}" + fi + fi + printf "%d\n" "${gid}" +} + +#---------------------------------------------------------------------------- +# Add a group; if it does already exist, remove it first +add_one_group() { + local group="${1}" + local gid="${2}" + local members + + # Generate a new GID if needed + # shellcheck disable=SC2086 # gid is a non-empty int + if [ ${gid} -eq ${AUTO_USER_ID} ]; then + gid="$( generate_gid "${group}" $FIRST_USER_GID $LAST_USER_GID )" + elif [ ${gid} -eq ${AUTO_SYSTEM_ID} ]; then + gid="$( generate_gid "${group}" $FIRST_SYSTEM_GID $LAST_SYSTEM_GID )" + fi + + members=$(get_members "$group") + # Remove any previous instance of this group, and re-add the new one + sed -i --follow-symlinks -e '/^'"${group}"':.*/d;' "${GROUP}" + printf "%s:x:%d:%s\n" "${group}" "${gid}" "${members}" >>"${GROUP}" + + # Ditto for /etc/gshadow if it exists + if [ -f "${GSHADOW}" ]; then + sed -i --follow-symlinks -e '/^'"${group}"':.*/d;' "${GSHADOW}" + printf "%s:*::\n" "${group}" >>"${GSHADOW}" + fi +} + +#---------------------------------------------------------------------------- +# Generate a unique UID for given username. If the username already exists, +# then simply report its current UID. Otherwise, generate the lowest UID +# that is: +# - not 0 +# - comprised in [$2..$3] +# - not already used by a user +generate_uid() { + local username="${1}" + local minuid="${2}" + local maxuid="${3}" + + local uid + + uid="$( get_uid "${username}" )" + if [ -z "${uid}" ]; then + for(( uid=minuid; uid<=maxuid; uid++ )); do + if [ -z "$( get_username "${uid}" )" ]; then + break + fi + done + # shellcheck disable=SC2086 # uid is a non-empty int + if [ ${uid} -gt ${maxuid} ]; then + fail "can not allocate a UID for user '%s'\n" "${username}" + fi + fi + printf "%d\n" "${uid}" +} + +#---------------------------------------------------------------------------- +# Add given user to given group, if not already the case +add_user_to_group() { + local username="${1}" + local group="${2}" + local _f + + for _f in "${GROUP}" "${GSHADOW}"; do + [ -f "${_f}" ] || continue + sed -r -i --follow-symlinks \ + -e 's/^('"${group}"':.*:)(([^:]+,)?)'"${username}"'(,[^:]+*)?$/\1\2\4/;' \ + -e 's/^('"${group}"':.*)$/\1,'"${username}"'/;' \ + -e 's/,+/,/' \ + -e 's/:,/:/' \ + "${_f}" + done +} + +#---------------------------------------------------------------------------- +# Encode a password +encode_password() { + local passwd="${1}" + + mkpasswd -m "${PASSWD_METHOD}" "${passwd}" +} + +#---------------------------------------------------------------------------- +# Add a user; if it does already exist, remove it first +add_one_user() { + local username="${1}" + local uid="${2}" + local group="${3}" + local gid="${4}" + local passwd="${5}" + local home="${6}" + local shell="${7}" + local groups="${8}" + local comment="${9}" + local _f _group _home _shell _gid _passwd + + # First, sanity-check the user + check_user_validity "${username}" "${uid}" "${group}" "${gid}" + + # Generate a new UID if needed + # shellcheck disable=SC2086 # uid is a non-empty int + if [ ${uid} -eq ${AUTO_USER_ID} ]; then + uid="$( generate_uid "${username}" $FIRST_USER_UID $LAST_USER_UID )" + elif [ ${uid} -eq ${AUTO_SYSTEM_ID} ]; then + uid="$( generate_uid "${username}" $FIRST_SYSTEM_UID $LAST_SYSTEM_UID )" + fi + + # Remove any previous instance of this user + for _f in "${PASSWD}" "${SHADOW}"; do + sed -r -i --follow-symlinks -e '/^'"${username}"':.*/d;' "${_f}" + done + + _gid="$( get_gid "${group}" )" + _shell="${shell}" + if [ "${shell}" = "-" ]; then + _shell="/bin/false" + fi + case "${home}" in + -) _home="/";; + /) fail "home can not explicitly be '/'\n";; + /*) _home="${home}";; + *) fail "home must be an absolute path\n";; + esac + case "${passwd}" in + -) + _passwd="" + ;; + !=*) + _passwd='!'"$( encode_password "${passwd#!=}" )" + ;; + =*) + _passwd="$( encode_password "${passwd#=}" )" + ;; + *) + _passwd="${passwd}" + ;; + esac + + printf "%s:x:%d:%d:%s:%s:%s\n" \ + "${username}" "${uid}" "${_gid}" \ + "${comment}" "${_home}" "${_shell}" \ + >>"${PASSWD}" + printf "%s:%s:::::::\n" \ + "${username}" "${_passwd}" \ + >>"${SHADOW}" + + # Add the user to its additional groups + if [ "${groups}" != "-" ]; then + for _group in ${groups//,/ }; do + add_user_to_group "${username}" "${_group}" + done + fi + + # If the user has a home, chown it + # (Note: stdout goes to the fakeroot-script) + if [ "${home}" != "-" ]; then + mkdir -p "${TARGET_DIR}/${home}" + printf "chown -h -R %d:%d '%s'\n" "${uid}" "${_gid}" "${TARGET_DIR}/${home}" + fi +} + +#---------------------------------------------------------------------------- +main() { + local username uid group gid passwd home shell groups comment + local line + local auto_id + local -a ENTRIES + + # Some sanity checks + if [ ${FIRST_USER_UID} -le 0 ]; then + fail "FIRST_USER_UID must be >0 (currently %d)\n" ${FIRST_USER_UID} + fi + if [ ${FIRST_USER_GID} -le 0 ]; then + fail "FIRST_USER_GID must be >0 (currently %d)\n" ${FIRST_USER_GID} + fi + + # Read in all the file in memory, exclude empty lines and comments + # mapfile reads all lines, even the last one if it is missing a \n + mapfile -t ENTRIES < <( sed -r -e 's/#.*//; /^[[:space:]]*$/d;' "${USERS_TABLE}" ) + + # We first create groups whose gid is positive, and then we create groups + # whose gid is automatic, so that, if a group is defined both with + # a specified gid and an automatic gid, we ensure the specified gid is + # used, rather than a different automatic gid is computed. + + # First, create all the main groups which gid is *not* automatic + for line in "${ENTRIES[@]}"; do + read -r username uid group gid passwd home shell groups comment <<<"${line}" + # shellcheck disable=SC2086 # gid is a non-empty int + [ ${gid} -ge 0 ] || continue # Automatic gid + add_one_group "${group}" "${gid}" + done + + # Then, create all the main groups which gid *is* automatic + for line in "${ENTRIES[@]}"; do + read -r username uid group gid passwd home shell groups comment <<<"${line}" + # shellcheck disable=SC2086 # gid is a non-empty int + [ ${gid} -lt 0 ] || continue # Non-automatic gid + add_one_group "${group}" "${gid}" + done + + # Then, create all the additional groups + # If any additional group is already a main group, we should use + # the gid of that main group; otherwise, we can use any gid - a + # system gid if the uid is a system user (<= LAST_SYSTEM_UID), + # otherwise a user gid. + for line in "${ENTRIES[@]}"; do + read -r username uid group gid passwd home shell groups comment <<<"${line}" + if [ "${groups}" != "-" ]; then + # shellcheck disable=SC2086 # uid is a non-empty int + if [ ${uid} -le 0 ]; then + auto_id=${uid} + elif [ ${uid} -le ${LAST_SYSTEM_UID} ]; then + auto_id=${AUTO_SYSTEM_ID} + else + auto_id=${AUTO_USER_ID} + fi + for g in ${groups//,/ }; do + add_one_group "${g}" "${auto_id}" + done + fi + done + + # When adding users, we do as for groups, in case two packages create + # the same user, one with an automatic uid, the other with a specified + # uid, to ensure the specified uid is used, rather than an incompatible + # uid be generated. + + # Now, add users whose uid is *not* automatic + for line in "${ENTRIES[@]}"; do + read -r username uid group gid passwd home shell groups comment <<<"${line}" + [ "${username}" != "-" ] || continue # Magic string to skip user creation + # shellcheck disable=SC2086 # uid is a non-empty int + [ ${uid} -ge 0 ] || continue # Automatic uid + add_one_user "${username}" "${uid}" "${group}" "${gid}" "${passwd}" \ + "${home}" "${shell}" "${groups}" "${comment}" + done + + # Finally, add users whose uid *is* automatic + for line in "${ENTRIES[@]}"; do + read -r username uid group gid passwd home shell groups comment <<<"${line}" + [ "${username}" != "-" ] || continue # Magic string to skip user creation + # shellcheck disable=SC2086 # uid is a non-empty int + [ ${uid} -lt 0 ] || continue # Non-automatic uid + add_one_user "${username}" "${uid}" "${group}" "${gid}" "${passwd}" \ + "${home}" "${shell}" "${groups}" "${comment}" + done +} + +#---------------------------------------------------------------------------- +main "${@}"