From 58467b6c6e2017ad5e4f102474cebfd53a1853e6 Mon Sep 17 00:00:00 2001 From: Li2nOnline <23146169+Lienol@users.noreply.github.com> Date: Mon, 10 Jan 2022 16:56:30 +0800 Subject: [PATCH 1/5] luci-app-kodexplorer: sync to my upstream (#8657) --- package/lean/luci-app-kodexplorer/Makefile | 8 +- .../luasrc/controller/kodexplorer.lua | 55 ++--- .../luasrc/model/cbi/kodexplorer/settings.lua | 103 +++++++--- .../luasrc/view/kodexplorer/download.htm | 175 ---------------- .../luasrc/view/kodexplorer/status.htm | 34 +++- .../luasrc/view/kodexplorer/version.htm | 191 +++++++++++++++++- .../po/zh-cn/kodexplorer.po | 89 ++++---- .../root/etc/config/kodexplorer | 9 +- .../root/etc/init.d/kodexplorer | 176 ++++------------ .../root/etc/kodexplorer/nginx.conf.template | 38 ++++ .../etc/kodexplorer/php-fpm.conf.template | 14 ++ .../root/etc/kodexplorer/php.ini.template | 55 +++++ .../root/etc/uci-defaults/luci-kodexplorer | 5 +- 13 files changed, 511 insertions(+), 441 deletions(-) delete mode 100644 package/lean/luci-app-kodexplorer/luasrc/view/kodexplorer/download.htm create mode 100644 package/lean/luci-app-kodexplorer/root/etc/kodexplorer/nginx.conf.template create mode 100644 package/lean/luci-app-kodexplorer/root/etc/kodexplorer/php-fpm.conf.template create mode 100644 package/lean/luci-app-kodexplorer/root/etc/kodexplorer/php.ini.template diff --git a/package/lean/luci-app-kodexplorer/Makefile b/package/lean/luci-app-kodexplorer/Makefile index 83d34670590fb4..ede5c977f22665 100644 --- a/package/lean/luci-app-kodexplorer/Makefile +++ b/package/lean/luci-app-kodexplorer/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 2018-2020 Lienol +# Copyright (C) 2018-2022 Lienol # # This is free software, licensed under the GNU General Public License v3. # @@ -6,10 +6,10 @@ include $(TOPDIR)/rules.mk LUCI_TITLE:=LuCI support for KodExplorer -LUCI_DEPENDS:=+nginx-ssl +unzip +zoneinfo-asia +php8 +php8-fpm +php8-mod-curl +php8-mod-gd +php8-mod-iconv +php8-mod-mbstring +php8-mod-opcache +php8-mod-session +php8-mod-zip +php8-mod-sqlite3 +php8-mod-pdo +php8-mod-pdo-sqlite +php8-mod-pdo-mysql +php8-cgi +php8-mod-dom +LUCI_DEPENDS:=+nginx-ssl +unzip +zoneinfo-asia +php8 +php8-fastcgi +php8-fpm +php8-mod-curl +php8-mod-dom +php8-mod-gd +php8-mod-iconv +php8-mod-mbstring +php8-mod-opcache +php8-mod-session +php8-mod-zip +php8-mod-sqlite3 +php8-mod-pdo +php8-mod-pdo-sqlite +php8-mod-pdo-mysql +php8-mod-xml +php8-mod-xmlreader +php8-mod-xmlwriter LUCI_PKGARCH:=all -PKG_VERSION:=14 -PKG_DATE:=20210505 +PKG_VERSION:=20220109 +PKG_RELEASE:=1 include $(TOPDIR)/feeds/luci/luci.mk diff --git a/package/lean/luci-app-kodexplorer/luasrc/controller/kodexplorer.lua b/package/lean/luci-app-kodexplorer/luasrc/controller/kodexplorer.lua index 911340be9bf411..10a0e3bee4e413 100644 --- a/package/lean/luci-app-kodexplorer/luasrc/controller/kodexplorer.lua +++ b/package/lean/luci-app-kodexplorer/luasrc/controller/kodexplorer.lua @@ -1,48 +1,49 @@ --- Copyright 2018-2020 Lienol +-- Copyright 2018-2022 Lienol module("luci.controller.kodexplorer", package.seeall) local http = require "luci.http" local api = require "luci.model.cbi.kodexplorer.api" function index() - if not nixio.fs.access("/etc/config/kodexplorer") then - return - end + if not nixio.fs.access("/etc/config/kodexplorer") then return end - entry({"admin", "nas"}, firstchild(), "NAS", 44).dependent = false - entry({"admin", "nas", "kodexplorer"}, cbi("kodexplorer/settings"), _("KodExplorer"), 3).dependent = true + entry({"admin", "nas"}, firstchild(), "NAS", 44).dependent = false - entry({"admin", "nas", "kodexplorer", "check"}, call("action_check")).leaf = true - entry({"admin", "nas", "kodexplorer", "download"}, call("action_download")).leaf = true - entry({"admin", "nas", "kodexplorer", "status"}, call("act_status")).leaf = true + e = entry({"admin", "nas", "kodexplorer"}, cbi("kodexplorer/settings"), _("KodExplorer"), 3) + e.dependent = true + e.acl_depends = { "luci-app-kodexplorer" } + + entry({"admin", "nas", "kodexplorer", "check"}, call("action_check")).leaf = true + entry({"admin", "nas", "kodexplorer", "download"}, call("action_download")).leaf = true + entry({"admin", "nas", "kodexplorer", "status"}, call("act_status")).leaf = true end local function http_write_json(content) - http.prepare_content("application/json") - http.write_json(content or {code = 1}) + http.prepare_content("application/json") + http.write_json(content or {code = 1}) end function act_status() - local e = {} - e.nginx_status = luci.sys.call("ps -w | grep nginx | grep kodexplorer | grep -v grep > /dev/null") == 0 - e.php_status = luci.sys.call("ps -w | grep php | grep kodexplorer | grep -v grep > /dev/null") == 0 - http_write_json(e) + local e = {} + e.nginx_status = luci.sys.call("ps -w | grep nginx | grep kodexplorer | grep -v grep > /dev/null") == 0 + e.php_status = luci.sys.call("ps -w | grep php | grep kodexplorer | grep -v grep > /dev/null") == 0 + http_write_json(e) end function action_check() - local json = api.to_check() - http_write_json(json) + local json = api.to_check() + http_write_json(json) end function action_download() - local json = nil - local task = http.formvalue("task") - if task == "extract" then - json = api.to_extract(http.formvalue("file")) - elseif task == "move" then - json = api.to_move(http.formvalue("file")) - else - json = api.to_download(http.formvalue("url")) - end - http_write_json(json) + local json = nil + local task = http.formvalue("task") + if task == "extract" then + json = api.to_extract(http.formvalue("file")) + elseif task == "move" then + json = api.to_move(http.formvalue("file")) + else + json = api.to_download(http.formvalue("url")) + end + http_write_json(json) end diff --git a/package/lean/luci-app-kodexplorer/luasrc/model/cbi/kodexplorer/settings.lua b/package/lean/luci-app-kodexplorer/luasrc/model/cbi/kodexplorer/settings.lua index 33ba0dedb277a3..19f4c594fa9029 100644 --- a/package/lean/luci-app-kodexplorer/luasrc/model/cbi/kodexplorer/settings.lua +++ b/package/lean/luci-app-kodexplorer/luasrc/model/cbi/kodexplorer/settings.lua @@ -1,53 +1,96 @@ -m = Map("kodexplorer") -m.title = translate("KodExplorer") -m.description = translate("KodExplorer is a fast and efficient private cloud and online document management system that provides secure, controllable, easy-to-use and highly customizable private cloud products for personal websites, enterprise private cloud deployment, network storage, online document management, and online office. With Windows style interface and operation habits, it can be used quickly without adaptation. It supports online preview of hundreds of common file formats and is extensible and easy to customize.") - +m = Map("kodexplorer", translate("KodExplorer"), translate("KodExplorer is a fast and efficient private cloud and online document management system that provides secure, controllable, easy-to-use and highly customizable private cloud products for personal websites, enterprise private cloud deployment, network storage, online document management, and online office. With Windows style interface and operation habits, it can be used quickly without adaptation. It supports online preview of hundreds of common file formats and is extensible and easy to customize.")) m:append(Template("kodexplorer/status")) -s = m:section(TypedSection, "global", translate("Global Settings")) +s = m:section(TypedSection, "global") s.anonymous = true s.addremove = false -o = s:option(Flag, "enable", translate("Enable")) +s:tab("global", translate("Global Settings")) +s:tab("template", translate("Edit Template")) + +php_fpm = s:taboption("template", Value, "_php_fpm", + translatef("Edit the template that is used for generating the %s configuration.", "php-fpm"), + translatef("This is the content of the file '%s'", "/etc/kodexplorer/php-fpm.conf.template") .. + translatef("Values enclosed by pipe symbols ('|') should not be changed. They get their values from the '%s' tab.", translate("Global Settings"))) +php_fpm.template = "cbi/tvalue" +php_fpm.rows = 10 + +function php_fpm.cfgvalue(self, section) + return nixio.fs.readfile("/etc/kodexplorer/php-fpm.conf.template") +end + +function php_fpm.write(self, section, value) + value = value:gsub("\r\n?", "\n") + nixio.fs.writefile("/etc/kodexplorer/php-fpm.conf.template", value) +end + +php = s:taboption("template", Value, "_php", + translatef("Edit the template that is used for generating the %s configuration.", "php"), + translatef("This is the content of the file '%s'", "/etc/kodexplorer/php.ini.template") .. + translatef("Values enclosed by pipe symbols ('|') should not be changed. They get their values from the '%s' tab.", translate("Global Settings"))) +php.template = "cbi/tvalue" +php.rows = 10 + +function php.cfgvalue(self, section) + return nixio.fs.readfile("/etc/kodexplorer/php.ini.template") +end + +function php.write(self, section, value) + value = value:gsub("\r\n?", "\n") + nixio.fs.writefile("/etc/kodexplorer/php.ini.template", value) +end + +nginx = s:taboption("template", Value, "_nginx", + translatef("Edit the template that is used for generating the %s configuration.", "nginx"), + translatef("This is the content of the file '%s'", "/etc/kodexplorer/nginx.conf.template") .. + translatef("Values enclosed by pipe symbols ('|') should not be changed. They get their values from the '%s' tab.", translate("Global Settings"))) +nginx.template = "cbi/tvalue" +nginx.rows = 10 + +function nginx.cfgvalue(self, section) + return nixio.fs.readfile("/etc/kodexplorer/nginx.conf.template") +end + +function nginx.write(self, section, value) + value = value:gsub("\r\n?", "\n") + nixio.fs.writefile("/etc/kodexplorer/nginx.conf.template", value) +end + +o = s:taboption("global", Flag, "enable", translate("Enable")) +o.rmempty = false + +o = s:taboption("global", Flag, "ipv6", translate("Listen IPv6")) o.rmempty = false -o = s:option(Value, "port", translate("Nginx Port")) +o = s:taboption("global", Value, "port", translate("Nginx Port")) o.datatype = "port" o.default = 8081 o.rmempty = false -o = s:option(Value, "memory_limit", translate("Maximum memory usage")) -o.description = translate("If your device has a lot of memory, you can increase it.") -o.default = "8M" +o = s:taboption("global", Flag, "https", translate("HTTPS")) o.rmempty = false -o = s:option(Value, "post_max_size", translate("Maximum POST capacity")) -o.description = translate("This value cannot be greater than the maximum memory usage") -o.default = "12M" +o = s:taboption("global", FileUpload, "certificate", translate("certificate")) +o:depends("https", 1) + +o = s:taboption("global", FileUpload, "key", translate("key")) +o:depends("https", 1) + +o = s:taboption("global", Value, "memory_limit", translate("Maximum memory usage"), translate("If your device has a lot of memory, you can increase it.")) +o.default = "32M" o.rmempty = false -o = s:option(Value, "upload_max_filesize", translate("Maximum memory usage for uploading files")) -o.description = translate("This value cannot be greater than the POST maximum capacity") -o.default = "12M" +o = s:taboption("global", Value, "upload_max_filesize", translate("Maximum memory usage for uploading files")) +o.default = "32M" o.rmempty = false -o = s:option(Value, "storage_device_path", translate("Storage device path")) -o.description = translate("It is recommended to insert a usb flash drive or hard disk and enter the path. For example, /mnt/sda1/") -o.default = "/mnt/sda1/" +o = s:taboption("global", DynamicList, "open_basedir", translate("Accessible directory")) o.rmempty = false -o = s:option(Value, "project_directory", translate("Project directory")) -o.description = translate("It is recommended to insert a usb flash drive or hard disk and enter the path. For example, /mnt/sda1/kodexplorer") +o = s:taboption("global", Value, "project_directory", translate("Project directory"), translate("It is recommended to insert a usb flash drive or hard disk and enter the path. For example, /mnt/sda1/kodexplorer")) o.default = "/mnt/sda1/kodexplorer" o.rmempty = false -s:append(Template("kodexplorer/version")) - -o = s:option(Button, "_download", translate("Manually update")) -o.description = translate("Make sure you have enough space.
Be sure to fill out the device path and store path for the first run, and then save the application. Then manually download, otherwise can not use!") -o.template = "kodexplorer/download" -o.inputstyle = "apply" -o.btnclick = "downloadClick(this);" -o.id = "download_btn" - +o = s:taboption("global", Button, "_update") +o.template = "kodexplorer/version" return m diff --git a/package/lean/luci-app-kodexplorer/luasrc/view/kodexplorer/download.htm b/package/lean/luci-app-kodexplorer/luasrc/view/kodexplorer/download.htm deleted file mode 100644 index 07effc605d4f13..00000000000000 --- a/package/lean/luci-app-kodexplorer/luasrc/view/kodexplorer/download.htm +++ /dev/null @@ -1,175 +0,0 @@ - - -<%+cbi/valueheader%> - <% if self:cfgvalue(section) ~= false then %> - " type="button"<%= - attr("name", cbid) .. - attr("id", self.id or cbid) .. - attr("value", self.inputtitle or self.title) .. - ifattr(self.btnclick, "onclick", self.btnclick) .. - ifattr(self.placeholder, "placeholder") - %> /> - - <% else %> - - - <% end %> -<%+cbi/valuefooter%> diff --git a/package/lean/luci-app-kodexplorer/luasrc/view/kodexplorer/status.htm b/package/lean/luci-app-kodexplorer/luasrc/view/kodexplorer/status.htm index d5b9c4ccd975c4..31a6211e4baaff 100644 --- a/package/lean/luci-app-kodexplorer/luasrc/view/kodexplorer/status.htm +++ b/package/lean/luci-app-kodexplorer/luasrc/view/kodexplorer/status.htm @@ -1,7 +1,3 @@ -<% -local dsp = require "luci.dispatcher" --%> -
<%:Running Status%>
@@ -13,17 +9,30 @@
<%:Collecting data...%>
+
+ +
+ +
+
+//]]> \ No newline at end of file diff --git a/package/lean/luci-app-kodexplorer/luasrc/view/kodexplorer/version.htm b/package/lean/luci-app-kodexplorer/luasrc/view/kodexplorer/version.htm index 5529f24493eb0e..e54409e81f996e 100644 --- a/package/lean/luci-app-kodexplorer/luasrc/view/kodexplorer/version.htm +++ b/package/lean/luci-app-kodexplorer/luasrc/view/kodexplorer/version.htm @@ -1,17 +1,188 @@ <% -local api = require "luci.model.cbi.kodexplorer.api" -local app_version = api.get_version() +local app_version = require "luci.model.cbi.kodexplorer.api".get_version() -%> <% if app_version and app_version ~= "" then %> -
- -
-
- 【 <%=app_version%> 】 +
+ +
+
+ 【 <%=app_version%> 】 +
+
+
+<% else %> +
+ +
+ + +
+ <%:Make sure you have enough space.%> +
+ + <%:Be sure to fill out the device path and store path for the first run, and then save the application. Then manually download, otherwise can not use!%> + +
-
<% end %> + + \ No newline at end of file diff --git a/package/lean/luci-app-kodexplorer/po/zh-cn/kodexplorer.po b/package/lean/luci-app-kodexplorer/po/zh-cn/kodexplorer.po index 24e3e7839b5ed5..19f60c1cbc7ffe 100644 --- a/package/lean/luci-app-kodexplorer/po/zh-cn/kodexplorer.po +++ b/package/lean/luci-app-kodexplorer/po/zh-cn/kodexplorer.po @@ -1,25 +1,45 @@ -msgid "" -msgstr "" -"Project-Id-Version: \n" -"POT-Creation-Date: \n" -"PO-Revision-Date: \n" -"Last-Translator: dingpengyu \n" -"Language-Team: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Language: zh_CN\n" -"X-Generator: Poedit 2.3.1\n" - msgid "KodExplorer" msgstr "可道云" +msgid "Running Status" +msgstr "运行状态" + +msgid "Status" +msgstr "状态" + +msgid "Collecting data..." +msgstr "正在收集数据..." + +msgid "NOT RUNNING" +msgstr "未运行" + +msgid "RUNNING" +msgstr "运行中" + +msgid "If you need external network access, please open the port by yourself." +msgstr "如需外网访问,请自行放行端口。" + msgid "Global Settings" msgstr "全局设置" msgid "KodExplorer is a fast and efficient private cloud and online document management system that provides secure, controllable, easy-to-use and highly customizable private cloud products for personal websites, enterprise private cloud deployment, network storage, online document management, and online office. With Windows style interface and operation habits, it can be used quickly without adaptation. It supports online preview of hundreds of common file formats and is extensible and easy to customize." msgstr "KodExplorer是一款快捷高效的私有云和在线文档管理系统,为个人网站、企业私有云部署、网络存储、在线文档管理、在线办公等提供安全可控,简便易用、可高度定制的私有云产品。采用windows风格界面、操作习惯,无需适应即可快速上手,支持几百种常用文件格式的在线预览,可扩展易定制。" +msgid "Edit Template" +msgstr "编辑模板" + +msgid "Edit the template that is used for generating the %s configuration." +msgstr "编辑生成 %s 的模板" + +msgid "This is the content of the file '%s'" +msgstr "这是文件内容:%s" + +msgid "Values enclosed by pipe symbols ('|') should not be changed. They get their values from the '%s' tab." +msgstr "由管道符(“|”)包围的值不应更改。它们将从 '%s' 标签中获取其值。" + +msgid "Listen IPv6" +msgstr "监听IPv6" + msgid "Nginx Port" msgstr "Nginx监听端口" @@ -29,23 +49,11 @@ msgstr "内存最大使用" msgid "If your device has a lot of memory, you can increase it." msgstr "如果你的设备内存较大的话,可以适当增加。" -msgid "Maximum POST capacity" -msgstr "POST最大容量" - -msgid "This value cannot be greater than the maximum memory usage" -msgstr "该值不能大于 内存最大使用" - msgid "Maximum memory usage for uploading files" msgstr "上传文件最大使用内存" -msgid "This value cannot be greater than the POST maximum capacity" -msgstr "该值不能大于 POST最大容量" - -msgid "Storage device path" -msgstr "存储设备路径" - -msgid "It is recommended to insert a usb flash drive or hard disk and enter the path. For example, /mnt/sda1/" -msgstr "建议插入U盘或硬盘,然后输入路径。例如:/mnt/sda1/" +msgid "Accessible directory" +msgstr "可访问的目录" msgid "Project directory" msgstr "项目存放目录" @@ -53,8 +61,11 @@ msgstr "项目存放目录" msgid "It is recommended to insert a usb flash drive or hard disk and enter the path. For example, /mnt/sda1/kodexplorer" msgstr "建议插入U盘或硬盘,然后输入路径。例如:/mnt/sda1/kodexplorer" -msgid "Make sure you have enough space.
Be sure to fill out the device path and store path for the first run, and then save the application. Then manually download, otherwise can not use!" -msgstr "请确保具有足够的空间。
第一次运行务必填好设备路径和存放路径,然后保存应用。再手动下载,否则无法使用!" +msgid "Make sure you have enough space." +msgstr "请确保具有足够的空间。" + +msgid "Be sure to fill out the device path and store path for the first run, and then save the application. Then manually download, otherwise can not use!" +msgstr "第一次运行务必填好设备路径和存放路径,然后保存应用。再手动下载,否则无法使用!" msgid "Manually update" msgstr "手动更新" @@ -69,7 +80,7 @@ msgid "Click to update" msgstr "点击更新" msgid "Updating..." -msgstr "更新中..." +msgstr "更新中" msgid "Unexpected error" msgstr "意外错误" @@ -78,26 +89,20 @@ msgid "Updating, are you sure to close?" msgstr "正在更新,你确认要关闭吗?" msgid "Downloading..." -msgstr "下载中..." +msgstr "下载中" msgid "Unpacking..." -msgstr "解压中..." +msgstr "解压中" msgid "Moving..." -msgstr "移动中..." +msgstr "移动中" msgid "The latest version:" msgstr "最新版本:" -msgid "Can't determine ARCH, or ARCH not supported." -msgstr "无法确认ARCH架构,或是不支持。" - msgid "Get remote version info failed." msgstr "获取远程版本信息失败。" -msgid "New version found, but failed to get new version download url." -msgstr "发现新版本,但未能获得新版本的下载地址。" - msgid "Download url is required." msgstr "请指定下载地址。" @@ -107,14 +112,8 @@ msgstr "文件下载失败或超时:%s" msgid "File path required." msgstr "请指定文件路径。" -msgid "Can't find client in file: %s" -msgstr "无法在文件中找到客户端:%s" - msgid "Client file is required." msgstr "请指定客户端文件。" -msgid "The client file is not suitable for current device." -msgstr "客户端文件不适合当前设备。" - msgid "Can't move new file to path: %s" msgstr "无法移动新文件到:%s" diff --git a/package/lean/luci-app-kodexplorer/root/etc/config/kodexplorer b/package/lean/luci-app-kodexplorer/root/etc/config/kodexplorer index b049415ba1f538..70969ad57347d6 100644 --- a/package/lean/luci-app-kodexplorer/root/etc/config/kodexplorer +++ b/package/lean/luci-app-kodexplorer/root/etc/config/kodexplorer @@ -1,10 +1,11 @@ config global option port '8080' - option storage_device_path '/opt/kodexplorer/' + option upload_max_filesize '100M' + list open_basedir '/' + option https '0' option project_directory '/opt/kodexplorer' - option enable '0' + option ipv6 '0' option memory_limit '120M' - option post_max_size '100M' - option upload_max_filesize '100M' + option enable '0' diff --git a/package/lean/luci-app-kodexplorer/root/etc/init.d/kodexplorer b/package/lean/luci-app-kodexplorer/root/etc/init.d/kodexplorer index aa8eeb8b722b86..eaed2f341a92e9 100755 --- a/package/lean/luci-app-kodexplorer/root/etc/init.d/kodexplorer +++ b/package/lean/luci-app-kodexplorer/root/etc/init.d/kodexplorer @@ -1,15 +1,15 @@ #!/bin/sh /etc/rc.common -# Copyright (C) 2018-2020 Lienol +# Copyright (C) 2018-2022 Lienol START=99 CONFIG="kodexplorer" -TEMP_PATH="/var/etc/kodexplorer" +TEMP_PATH="/var/etc/$CONFIG" NGINX_CONFIG="$TEMP_PATH/nginx.conf" +PHP_CONFIG="$TEMP_PATH/php.ini" PHP_FPM_CONFIG="$TEMP_PATH/php-fpm.conf" -PHP_CONFIG="/etc/php.ini" -PHP_BACKUP_CONFIG="/etc/php.ini.backup" +PHP_FPM_SOCK="$TEMP_PATH/php-fpm.sock" config_t_get() { local index=0 @@ -19,153 +19,61 @@ config_t_get() { } gen_nginx_config() { + ipv6=$(config_t_get global ipv6 0) port=$(config_t_get global port) - project_directory=$(config_t_get global project_directory) - cat <<-EOF > $1 - user root root; - worker_processes 1; - pid /var/run/nginx_kodexplorer.pid; - events { - worker_connections 1024; - } - http { - include /etc/nginx/mime.types; - sendfile on; - keepalive_timeout 65; - server { - listen $port; - listen [::]:$port; - server_name localhost; - location / { - root $project_directory; - index index.html index.htm index.php; - } - error_page 500 502 503 504 /50x.html; - location = /50x.html { - root html; - } - location ~ \.php(.*)$ { - root $project_directory; - try_files \$uri = 404; # PHP 文件不存在返回404 - fastcgi_pass unix:/var/run/php8-fpm.sock; # 通过 Unix 套接字执行 PHP - fastcgi_index index.php; - fastcgi_split_path_info ^(.+\.php)(.*)$; - fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name; # 修复 Nginx fastcgi 漏洞 - fastcgi_param PATH_INFO \$fastcgi_path_info; - include /etc/nginx/fastcgi_params; - } - } - } - EOF + [ "$(config_t_get global https 0)" == "1" ] && { + port="$port ssl" + ssl_certificate="ssl_certificate $(config_t_get global certificate);" + ssl_certificate_key="ssl_certificate_key $(config_t_get global key);" + } + sed -e "s#|PID|#$TEMP_PATH/nginx.pid#g" \ + -e "s#|PORT|#$port#g" \ + -e "s#|ssl_certificate|#$ssl_certificate#g" \ + -e "s#|ssl_certificate_key|#$ssl_certificate_key#g" \ + -e "s#|project_directory|#$project_directory#g" \ + -e "s#|SOCK|#$PHP_FPM_SOCK#g" \ + -e "s#|upload_max_filesize|#$upload_max_filesize#g" \ + -e "s#|temp_path|#$TEMP_PATH/temp#g" \ + /etc/$CONFIG/nginx.conf.template > $1 + + [ "$ipv6" = "0" ] && sed -i '/listen \[::\]:/d' $1 } gen_php_config() { - storage_device_path=$(config_t_get global storage_device_path) - memory_limit=$(config_t_get global memory_limit) - post_max_size=$(config_t_get global post_max_size) - upload_max_filesize=$(config_t_get global upload_max_filesize) - cp $PHP_CONFIG $PHP_BACKUP_CONFIG - cat <<-EOF >$PHP_CONFIG - [PHP] - zend.ze1_compatibility_mode = Off - engine = On - precision = 12 - y2k_compliance = On - output_buffering = Off - zlib.output_compression = Off - implicit_flush = Off - unserialize_callback_func = - serialize_precision = 100 - - open_basedir = $storage_device_path:/tmp/:/proc/:/usr/bin/ - disable_functions = - disable_classes = - expose_php = On - max_execution_time = 30 - max_input_time = 60 - memory_limit = $memory_limit - error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT - - display_errors = On - display_startup_errors = Off - log_errors = Off - log_errors_max_len = 1024 - ignore_repeated_errors = Off - ignore_repeated_source = Off - report_memleaks = On - track_errors = Off - - variables_order = "EGPCS" - request_order = "GP" - register_globals = Off - register_long_arrays = Off - register_argc_argv = On - auto_globals_jit = On - post_max_size = $post_max_size - magic_quotes_runtime = Off - magic_quotes_sybase = Off - auto_prepend_file = - auto_append_file = - default_mimetype = "text/html" - - ;doc_root = "/www" - user_dir = - extension_dir = "/usr/lib/php" - enable_dl = On - cgi.fix_pathinfo=1 - - file_uploads = On - upload_tmp_dir = "/tmp" - upload_max_filesize = $upload_max_filesize - max_file_uploads = 20 - - allow_url_fopen = On - allow_url_include = Off - default_socket_timeout = 60 - EOF - - cat <<-EOF >$PHP_FPM_CONFIG - [global] - pid = /var/run/kodexplorer_php8-fpm.pid - error_log = /var/log/kodexplorer_php8-fpm.log - [www] - user = root - listen = /var/run/php8-fpm.sock - listen.mode = 0666 - listen.allowed_clients = 127.0.0.1 - pm = dynamic - pm.max_children = 5 - pm.start_servers = 2 - pm.min_spare_servers = 1 - pm.max_spare_servers = 3 - chdir = / - EOF + sed -e "s#|project_directory|#$project_directory#g" \ + -e "s#|open_basedir|#$open_basedir#g" \ + -e "s#|memory_limit|#$memory_limit#g" \ + -e "s#|upload_max_filesize|#$upload_max_filesize#g" \ + /etc/$CONFIG/php.ini.template > $PHP_CONFIG + + sed -e "s#|PID|#$TEMP_PATH/php-fpm.pid#g" \ + -e "s#|ERROR_LOG|#$TEMP_PATH/php-fpm.log#g" \ + -e "s#|SOCK|#$PHP_FPM_SOCK#g" \ + /etc/$CONFIG/php-fpm.conf.template > $PHP_FPM_CONFIG } start() { ENABLED=$(config_t_get global enable 0) [ "$ENABLED" = "0" ] && return 0 - mkdir -p $TEMP_PATH /var/log/nginx /var/lib/nginx + mkdir -p $TEMP_PATH $TEMP_PATH/temp /var/log/nginx /var/lib/nginx + memory_limit=$(config_t_get global memory_limit 64M) + upload_max_filesize=$(config_t_get global upload_max_filesize 64M) + project_directory=$(config_t_get global project_directory) + open_basedir=$(config_t_get global open_basedir "/") + open_basedir=$(echo $open_basedir | sed "s/ /:/g") gen_php_config - /usr/bin/php-fpm -R -y $PHP_FPM_CONFIG -g "/var/run/php8-fpm.pid" + /usr/bin/php8-fpm -c $PHP_CONFIG -R -y $PHP_FPM_CONFIG gen_nginx_config $NGINX_CONFIG /usr/sbin/nginx -c $NGINX_CONFIG >/dev/null 2>&1 & } stop() { - /usr/sbin/nginx -c $NGINX_CONFIG -s stop >/dev/null 2>&1 & - killall -9 php-fpm >/dev/null 2>&1 & - rm -f /var/run/kodexplorer_php8-fpm.pid - rm -f /var/log/kodexplorer_php8-fpm.log - rm -f /var/run/php8-fpm.sock - [ -f "$PHP_BACKUP_CONFIG" -a -f "$PHP_CONFIG" ] && { - rm -f $PHP_CONFIG - cp $PHP_BACKUP_CONFIG $PHP_CONFIG - rm -f $PHP_BACKUP_CONFIG - } + /usr/sbin/nginx -c $NGINX_CONFIG -s stop >/dev/null 2>&1 + [ -f "$TEMP_PATH/php-fpm.pid" ] && kill -2 $(cat $TEMP_PATH/php-fpm.pid) >/dev/null 2>&1 + rm -rf $TEMP_PATH } restart() { stop start -} +} \ No newline at end of file diff --git a/package/lean/luci-app-kodexplorer/root/etc/kodexplorer/nginx.conf.template b/package/lean/luci-app-kodexplorer/root/etc/kodexplorer/nginx.conf.template new file mode 100644 index 00000000000000..7cbf752457ec23 --- /dev/null +++ b/package/lean/luci-app-kodexplorer/root/etc/kodexplorer/nginx.conf.template @@ -0,0 +1,38 @@ +user root root; +worker_processes auto; +pid |PID|; +events { + worker_connections 1024; +} +http { + include /etc/nginx/mime.types; + sendfile on; + keepalive_timeout 65; + server { + listen |PORT|; + listen [::]:|PORT|; + |ssl_certificate| + |ssl_certificate_key| + ssl_session_cache shared:SSL:1m; + ssl_session_timeout 5m; + ssl_ciphers HIGH:!aNULL:!MD5; + ssl_prefer_server_ciphers on; + server_name localhost; + root |project_directory|; + index index.html index.htm index.php; + location ~ \.php(.*)$ { + fastcgi_pass unix:|SOCK|; # 通过 Unix 套接字执行 PHP + fastcgi_index index.php; + fastcgi_split_path_info ^(.+\.php)(.*)$; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; # 修复 Nginx fastcgi 漏洞 + fastcgi_param PATH_INFO $fastcgi_path_info; + include /etc/nginx/fastcgi_params; + client_max_body_size |upload_max_filesize|; + client_body_temp_path |temp_path|; + client_body_timeout 3600s; + fastcgi_connect_timeout 3600s; + fastcgi_send_timeout 3600s; + fastcgi_read_timeout 3600s; + } + } +} diff --git a/package/lean/luci-app-kodexplorer/root/etc/kodexplorer/php-fpm.conf.template b/package/lean/luci-app-kodexplorer/root/etc/kodexplorer/php-fpm.conf.template new file mode 100644 index 00000000000000..509c7f4176d3df --- /dev/null +++ b/package/lean/luci-app-kodexplorer/root/etc/kodexplorer/php-fpm.conf.template @@ -0,0 +1,14 @@ +[global] +pid = |PID| +error_log = |ERROR_LOG| +[www] +user = root +listen = |SOCK| +listen.mode = 0666 +listen.allowed_clients = 127.0.0.1 +pm = dynamic +pm.max_children = 5 +pm.start_servers = 2 +pm.min_spare_servers = 1 +pm.max_spare_servers = 3 +chdir = / diff --git a/package/lean/luci-app-kodexplorer/root/etc/kodexplorer/php.ini.template b/package/lean/luci-app-kodexplorer/root/etc/kodexplorer/php.ini.template new file mode 100644 index 00000000000000..84dc006989cf3d --- /dev/null +++ b/package/lean/luci-app-kodexplorer/root/etc/kodexplorer/php.ini.template @@ -0,0 +1,55 @@ +[PHP] +zend.ze1_compatibility_mode = Off +engine = On +precision = 12 +y2k_compliance = On +output_buffering = Off +zlib.output_compression = Off +implicit_flush = Off +unserialize_callback_func = +serialize_precision = 100 + +open_basedir = /tmp:|project_directory|:|open_basedir|:/usr/bin/ +disable_functions = +disable_classes = +expose_php = On +max_execution_time = 3600 +max_input_time = 3600 +memory_limit = |memory_limit| +error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT + +display_errors = On +display_startup_errors = Off +log_errors = Off +ignore_repeated_errors = Off +ignore_repeated_source = Off +report_memleaks = On +track_errors = Off + +variables_order = "EGPCS" +request_order = "GP" +register_globals = Off +register_long_arrays = Off +register_argc_argv = On +auto_globals_jit = On +post_max_size = |upload_max_filesize| +magic_quotes_runtime = Off +magic_quotes_sybase = Off +auto_prepend_file = +auto_append_file = +default_mimetype = "text/html" + +;doc_root = "/www" +user_dir = +extension_dir = "/usr/lib/php8" +enable_dl = On +cgi.fix_pathinfo=1 + +file_uploads = On +upload_tmp_dir = "/tmp" +upload_max_filesize = |upload_max_filesize| +max_file_uploads = 1000 + +allow_url_fopen = On +allow_url_include = Off +default_socket_timeout = 60 diff --git a/package/lean/luci-app-kodexplorer/root/etc/uci-defaults/luci-kodexplorer b/package/lean/luci-app-kodexplorer/root/etc/uci-defaults/luci-kodexplorer index 3010f358af729c..618c4a0096c4e4 100755 --- a/package/lean/luci-app-kodexplorer/root/etc/uci-defaults/luci-kodexplorer +++ b/package/lean/luci-app-kodexplorer/root/etc/uci-defaults/luci-kodexplorer @@ -7,6 +7,7 @@ uci -q batch <<-EOF >/dev/null commit ucitrack EOF -/etc/init.d/php8-fpm disable && /etc/init.d/php8-fpm stop -rm -rf /tmp/luci-* +/etc/init.d/php8-fpm stop +/etc/init.d/php8-fpm disable +rm -rf /tmp/luci-*cache exit 0 From c01c9b96b13758353a17b105b9ab26a98a2e1c73 Mon Sep 17 00:00:00 2001 From: aakkll <94471752+aakkll@users.noreply.github.com> Date: Mon, 10 Jan 2022 16:56:47 +0800 Subject: [PATCH 2/5] utils/mdadm: fix build on hosts without /run dir (#8651) CHECK_RUN_DIR=0 must be a part of MAKE_FLAGS, not MAKE_VARS, otherwise it is not possible to compile mdadm on host without /run dir. Signed-off-by: Sergey V. Lobanov Co-authored-by: Sergey V. Lobanov --- package/utils/mdadm/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/utils/mdadm/Makefile b/package/utils/mdadm/Makefile index f20a58b7046c48..f6696bf21cb38b 100644 --- a/package/utils/mdadm/Makefile +++ b/package/utils/mdadm/Makefile @@ -52,7 +52,7 @@ TARGET_CFLAGS += \ TARGET_LDFLAGS += -Wl,--gc-sections -MAKE_VARS += CHECK_RUN_DIR=0 +MAKE_FLAGS += CHECK_RUN_DIR=0 define Build/Compile $(call Build/Compile/Default,mdadm) From 4e2155b05d6468543b938107e3ffd87d708484ef Mon Sep 17 00:00:00 2001 From: aakkll <94471752+aakkll@users.noreply.github.com> Date: Mon, 10 Jan 2022 16:57:24 +0800 Subject: [PATCH 3/5] binutils: sync upstream (#8660) * binutils: Update to version 2.37 This matches the version used in the toolchain. Signed-off-by: Hauke Mehrtens * binutils: fix compiling with arch-based distros Arch Linux users have encountered problems with packages that have a dependency on binutils. This error happens when libtool is doing: libtool: relink: ... So change PKG_FIXUP to "patch-libtool". Fixes error in the form of: libtool: install: error: relink `libctf.la' with the above command before installing it Upstream Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28545 OpenWrt Bug: https://bugs.openwrt.org/index.php?do=details&task_id=4149 Acked-by: John Audia Signed-off-by: Nick Hainke Co-authored-by: Hauke Mehrtens Co-authored-by: Nick Hainke --- package/devel/binutils/Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package/devel/binutils/Makefile b/package/devel/binutils/Makefile index ca1099349c12b7..522a971051d9cf 100644 --- a/package/devel/binutils/Makefile +++ b/package/devel/binutils/Makefile @@ -8,15 +8,15 @@ include $(TOPDIR)/rules.mk PKG_NAME:=binutils -PKG_VERSION:=2.35.2 -PKG_RELEASE:=1 +PKG_VERSION:=2.37 +PKG_RELEASE:=2 PKG_SOURCE_URL:=@GNU/binutils PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_VERSION:=$(PKG_VERSION) -PKG_HASH:=dcd5b0416e7b0a9b24bed76cd8c6c132526805761863150a26d016415b8bdc7b +PKG_HASH:=820d9724f020a3e69cb337893a0b63c2db161dadcb0e06fc11dc29eb1e84a32c -PKG_FIXUP:=autoreconf +PKG_FIXUP:=patch-libtool PKG_LIBTOOL_PATHS:=. gas bfd opcodes gprof binutils ld libiberty gold intl PKG_REMOVE_FILES:=libtool.m4 PKG_INSTALL:=1 From 5afa82e64f59d4102cdd302afe392e56135a4fa6 Mon Sep 17 00:00:00 2001 From: aakkll <94471752+aakkll@users.noreply.github.com> Date: Mon, 10 Jan 2022 16:57:37 +0800 Subject: [PATCH 4/5] toolchain/binutils: sync upstream (#8661) * toolchain/binutils: switch to version 2.36.1 by default Runtime-tested on: * ath79 * bcm27xx/bcm2708 * bcm27xx/bcm2709 * bcm27xx/bcm2711 * mvebu/cortexa53 * octeon * realtek * x86/64 Signed-off-by: Stijn Tintel Acked-by: Hauke Mehrtens * toolchain/binutils: switch to version 2.37 by default Compile tests: * all Runtime tests: * ipq806x/generic * lantiq/mt7621 * lantiq/xrx200 * x86/64 Signed-off-by: Paul Spooren Tested-by: Paul Spooren Tested-by: Rosen Penev Tested-by: Andre Heider Tested-by: Ansuel Smith Tested-by: Rui Salvaterra Signed-off-by: Paul Spooren * toolchain/binutils: v2.37 Close the file descriptor if there is no archive fd This fixes the following build error: /home/build/openwrt/staging_dir/toolchain-aarch64_cortex-a53_gcc-11.2.0_musl/lib/gcc/aarch64-openwrt-linux-musl/11.2.0/../../../../aarch64-openwrt-linux-musl/bin/ld: /home/sergey/openwrt2/build_dir/target-aarch64_cortex-a53_musl/node-v14.18.2/out/Release/obj.target/tools/v8_gypfiles/libv8_base_without_compiler.a: error adding symbols: malformed archive collect2: error: ld returned 1 exit status It's a bad error handling related to -EMFILE (too many open files). nodejs is probably just very close to open file limit. https://sourceware.org/bugzilla/show_bug.cgi?id=28138 https://github.com/nodejs/node/issues/39452 https://github.com/openwrt/packages/issues/17496 https://github.com/openwrt/packages/issues/16729 https://github.com/openwrt/packages/issues/17164 Signed-off-by: Hirokazu MORIKAWA [Take full patch from 2.37 branch and refresh] Signed-off-by: Hauke Mehrtens Co-authored-by: Stijn Tintel Co-authored-by: Paul Spooren Co-authored-by: Hirokazu MORIKAWA --- toolchain/binutils/Config.in | 2 +- toolchain/binutils/Config.version | 2 +- .../2.37/600-Close_the_file_descriptor.patch | 184 ++++++++++++++++++ 3 files changed, 186 insertions(+), 2 deletions(-) create mode 100644 toolchain/binutils/patches/2.37/600-Close_the_file_descriptor.patch diff --git a/toolchain/binutils/Config.in b/toolchain/binutils/Config.in index 4b9579379c74e3..493b6e4f5a225d 100644 --- a/toolchain/binutils/Config.in +++ b/toolchain/binutils/Config.in @@ -2,7 +2,7 @@ choice prompt "Binutils Version" if TOOLCHAINOPTS - default BINUTILS_USE_VERSION_2_34 + default BINUTILS_USE_VERSION_2_37 help Select the version of binutils you wish to use. diff --git a/toolchain/binutils/Config.version b/toolchain/binutils/Config.version index 985e3b1b326d63..db727b78bc59e7 100644 --- a/toolchain/binutils/Config.version +++ b/toolchain/binutils/Config.version @@ -2,7 +2,6 @@ config BINUTILS_VERSION_2_32 bool config BINUTILS_VERSION_2_34 - default y if !TOOLCHAINOPTS bool config BINUTILS_VERSION_2_35_2 @@ -12,6 +11,7 @@ config BINUTILS_VERSION_2_36_1 bool config BINUTILS_VERSION_2_37 + default y if !TOOLCHAINOPTS bool config BINUTILS_VERSION diff --git a/toolchain/binutils/patches/2.37/600-Close_the_file_descriptor.patch b/toolchain/binutils/patches/2.37/600-Close_the_file_descriptor.patch new file mode 100644 index 00000000000000..fef86a9cb5aa13 --- /dev/null +++ b/toolchain/binutils/patches/2.37/600-Close_the_file_descriptor.patch @@ -0,0 +1,184 @@ +From: H.J. Lu +Date: Mon, 26 Jul 2021 12:59:55 +0000 (-0700) +Subject: bfd: Close the file descriptor if there is no archive fd +X-Git-Url: https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff_plain;h=1c611b40e6bfc8029bff7696814330b5bc0ee5c0 + +bfd: Close the file descriptor if there is no archive fd + +Close the file descriptor if there is no archive plugin file descriptor +to avoid running out of file descriptors on thin archives with many +archive members. + +bfd/ + + PR ld/28138 + * plugin.c (bfd_plugin_close_file_descriptor): Close the file + descriptor there is no archive plugin file descriptor. + +ld/ + + PR ld/28138 + * testsuite/ld-plugin/lto.exp: Run tmpdir/pr28138 only for + native build. + + PR ld/28138 + * testsuite/ld-plugin/lto.exp: Run ld/28138 tests. + * testsuite/ld-plugin/pr28138.c: New file. + * testsuite/ld-plugin/pr28138-1.c: Likewise. + * testsuite/ld-plugin/pr28138-2.c: Likewise. + * testsuite/ld-plugin/pr28138-3.c: Likewise. + * testsuite/ld-plugin/pr28138-4.c: Likewise. + * testsuite/ld-plugin/pr28138-5.c: Likewise. + * testsuite/ld-plugin/pr28138-6.c: Likewise. + * testsuite/ld-plugin/pr28138-7.c: Likewise. + +(cherry picked from commit 5a98fb7513b559e20dfebdbaa2a471afda3b4742) +(cherry picked from commit 7dc37e1e1209c80e0bab784df6b6bac335e836f2) +--- + +--- a/bfd/plugin.c ++++ b/bfd/plugin.c +@@ -291,6 +291,14 @@ bfd_plugin_close_file_descriptor (bfd *a + && !bfd_is_thin_archive (abfd->my_archive)) + abfd = abfd->my_archive; + ++ /* Close the file descriptor if there is no archive plugin file ++ descriptor. */ ++ if (abfd->archive_plugin_fd == -1) ++ { ++ close (fd); ++ return; ++ } ++ + abfd->archive_plugin_fd_open_count--; + /* Dup the archive plugin file descriptor for later use, which + will be closed by _bfd_archive_close_and_cleanup. */ +--- a/ld/testsuite/ld-plugin/lto.exp ++++ b/ld/testsuite/ld-plugin/lto.exp +@@ -687,6 +687,40 @@ if { [is_elf_format] && [check_lto_share + } + } + ++run_cc_link_tests [list \ ++ [list \ ++ "Build pr28138.a" \ ++ "-T" "" \ ++ {pr28138-1.c pr28138-2.c pr28138-3.c pr28138-4.c pr28138-5.c \ ++ pr28138-6.c pr28138-7.c} {} "pr28138.a" \ ++ ] \ ++ [list \ ++ "Build pr28138.o" \ ++ "" "" \ ++ {pr28138.c} {} \ ++ ] \ ++] ++ ++set exec_output [run_host_cmd "sh" \ ++ "-c \"ulimit -n 20; \ ++ $CC -Btmpdir/ld -o tmpdir/pr28138 \ ++ tmpdir/pr28138.o tmpdir/pr28138.a\""] ++set exec_output [prune_warnings $exec_output] ++if [string match "" $exec_output] then { ++ if { [isnative] } { ++ set exec_output [run_host_cmd "tmpdir/pr28138" ""] ++ if [string match "PASS" $exec_output] then { ++ pass "PR ld/28138" ++ } else { ++ fail "PR ld/28138" ++ } ++ } else { ++ pass "PR ld/28138" ++ } ++} else { ++ fail "PR ld/28138" ++} ++ + set testname "Build liblto-11.a" + remote_file host delete "tmpdir/liblto-11.a" + set catch_output [run_host_cmd "$ar" "rc $plug_opt tmpdir/liblto-11.a tmpdir/lto-11a.o tmpdir/lto-11b.o tmpdir/lto-11c.o"] +--- /dev/null ++++ b/ld/testsuite/ld-plugin/pr28138-1.c +@@ -0,0 +1,6 @@ ++extern int a0(void); ++int ++a1(void) ++{ ++ return 1 + a0(); ++} +--- /dev/null ++++ b/ld/testsuite/ld-plugin/pr28138-2.c +@@ -0,0 +1,6 @@ ++extern int a1(void); ++int ++a2(void) ++{ ++ return 1 + a1(); ++} +--- /dev/null ++++ b/ld/testsuite/ld-plugin/pr28138-3.c +@@ -0,0 +1,6 @@ ++extern int a2(void); ++int ++a3(void) ++{ ++ return 1 + a2(); ++} +--- /dev/null ++++ b/ld/testsuite/ld-plugin/pr28138-4.c +@@ -0,0 +1,6 @@ ++extern int a3(void); ++int ++a4(void) ++{ ++ return 1 + a3(); ++} +--- /dev/null ++++ b/ld/testsuite/ld-plugin/pr28138-5.c +@@ -0,0 +1,6 @@ ++extern int a4(void); ++int ++a5(void) ++{ ++ return 1 + a4(); ++} +--- /dev/null ++++ b/ld/testsuite/ld-plugin/pr28138-6.c +@@ -0,0 +1,6 @@ ++extern int a5(void); ++int ++a6(void) ++{ ++ return 1 + a5(); ++} +--- /dev/null ++++ b/ld/testsuite/ld-plugin/pr28138-7.c +@@ -0,0 +1,6 @@ ++extern int a6(void); ++int ++a7(void) ++{ ++ return 1 + a6(); ++} +--- /dev/null ++++ b/ld/testsuite/ld-plugin/pr28138.c +@@ -0,0 +1,20 @@ ++#include ++ ++extern int a7(void); ++ ++int ++a0(void) ++{ ++ return 0; ++} ++ ++int ++main() ++{ ++ if (a7() == 7) ++ { ++ printf ("PASS\n"); ++ return 0; ++ } ++ return 1; ++} From b0c25b7d38a9f1bd65382d454e296f913a2a3652 Mon Sep 17 00:00:00 2001 From: aakkll <94471752+aakkll@users.noreply.github.com> Date: Mon, 10 Jan 2022 16:57:52 +0800 Subject: [PATCH 5/5] elfutils: sync upstream (#8652) * elfutils: enable host build frr 8.0 needs host libelf dev add option for host build tested on x86, ramips, kirkwood Signed-off-by: Lucian Cristian [changed commit author's email] Signed-off-by: Christian Lamparter * elfutils: update to 0.186 Upstreamed patches (deleted): 0001-ppc_initreg.c-Incliude-asm-ptrace.h-for-pt_regs-defi.patch - https://sourceware.org/git/?p=elfutils.git;a=commitdiff;h=8382833a257b57b0d288be07d2d5e7af6c102869 110-no-cdefs.patch - https://sourceware.org/git/?p=elfutils.git;a=commitdiff;h=d390548df1942e98a1d836269a5e41ba52e121f1 Auto-refreshed: 006-Fix-build-on-aarch64-musl.patch 101-no-fts.patch Manually updated and refreshed: 005-build_only_libs.patch 003-libintl-compatibility.patch 100-musl-compat.patch Disabled _obstack_free check (via configure vars) Signed-off-by: Sergey V. Lobanov * elfutils: Add missing musl-fts dependency libdw depends on libfts.so when building with the musl-libc library, add this missing dependency. Fixes: 6835ea13f0fa ("elfutils: update to 0.186") Signed-off-by: Florian Fainelli Co-authored-by: Lucian Cristian Co-authored-by: Sergey V. Lobanov Co-authored-by: Florian Fainelli --- package/libs/elfutils/Makefile | 20 +++++-- ...cliude-asm-ptrace.h-for-pt_regs-defi.patch | 29 ---------- .../patches/003-libintl-compatibility.patch | 54 ++----------------- .../patches/005-build_only_libs.patch | 2 +- .../elfutils/patches/100-musl-compat.patch | 48 ++++++----------- .../libs/elfutils/patches/101-no-fts.patch | 6 +-- .../libs/elfutils/patches/110-no-cdefs.patch | 26 --------- 7 files changed, 39 insertions(+), 146 deletions(-) delete mode 100644 package/libs/elfutils/patches/0001-ppc_initreg.c-Incliude-asm-ptrace.h-for-pt_regs-defi.patch delete mode 100644 package/libs/elfutils/patches/110-no-cdefs.patch diff --git a/package/libs/elfutils/Makefile b/package/libs/elfutils/Makefile index d595e4caf22cc3..9aa78d8352b997 100644 --- a/package/libs/elfutils/Makefile +++ b/package/libs/elfutils/Makefile @@ -7,12 +7,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=elfutils -PKG_VERSION:=0.182 +PKG_VERSION:=0.186 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 PKG_SOURCE_URL:=https://sourceware.org/$(PKG_NAME)/ftp/$(PKG_VERSION) -PKG_HASH:=ecc406914edf335f0b7fc084ebe6c460c4d6d5175bfdd6688c1c78d9146b8858 +PKG_HASH:=7f6fb9149b1673d38d9178a0d3e0fb8a1ec4f53a9f4c2ff89469609879641177 PKG_MAINTAINER:=Luiz Angelo Daros de Luca PKG_LICENSE:=GPL-3.0-or-later @@ -26,6 +26,7 @@ PKG_BUILD_DEPENDS:=!USE_GLIBC:argp-standalone include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/nls.mk +include $(INCLUDE_DIR)/host-build.mk define Package/elfutils/Default SECTION:=libs @@ -43,7 +44,7 @@ endef define Package/libdw $(call Package/elfutils/Default) - DEPENDS:=+libelf +libbz2 + DEPENDS:=+libelf +libbz2 +USE_MUSL:musl-fts TITLE+= (libdw) endef @@ -60,6 +61,12 @@ else CONFIGURE_ARGS += --disable-nls endif +HOST_CONFIGURE_ARGS += \ + --disable-debuginfod \ + --disable-libdebuginfod \ + --without-lzma \ + --without-zstd + CONFIGURE_ARGS += \ --program-prefix=eu- \ --disable-debuginfod \ @@ -67,6 +74,12 @@ CONFIGURE_ARGS += \ --without-lzma \ --without-zstd +HOST_CONFIGURE_VARS += \ + ac_cv_search__obstack_free=yes + +CONFIGURE_VARS += \ + ac_cv_search__obstack_free=yes + TARGET_CFLAGS += -D_GNU_SOURCE -Wno-unused-result -Wno-format-nonliteral define Build/InstallDev @@ -97,6 +110,7 @@ define Package/libelf/install endef # these lines need to be ordered by dependency because of ABI versioning +$(eval $(call HostBuild)) $(eval $(call BuildPackage,libelf)) $(eval $(call BuildPackage,libdw)) $(eval $(call BuildPackage,libasm)) diff --git a/package/libs/elfutils/patches/0001-ppc_initreg.c-Incliude-asm-ptrace.h-for-pt_regs-defi.patch b/package/libs/elfutils/patches/0001-ppc_initreg.c-Incliude-asm-ptrace.h-for-pt_regs-defi.patch deleted file mode 100644 index 839f86ee6a32e6..00000000000000 --- a/package/libs/elfutils/patches/0001-ppc_initreg.c-Incliude-asm-ptrace.h-for-pt_regs-defi.patch +++ /dev/null @@ -1,29 +0,0 @@ -From http://cgit.openembedded.org/openembedded-core/plain/meta/recipes-devtools/elfutils/files/0001-ppc_initreg.c-Incliude-asm-ptrace.h-for-pt_regs-defi.patch - -From 2e2232d0935bf8ef6e66ebffba3be68a73b5b3e5 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Sun, 8 Sep 2019 15:57:59 -0700 -Subject: [PATCH] ppc_initreg.c: Incliude asm/ptrace.h for pt_regs definition - -Fixes -| ../../elfutils-0.176/backends/ppc_initreg.c:79:22: error: field 'r' has incomplete type -| struct pt_regs r; -| ^ - -Upstream-Status: Pending - -Signed-off-by: Khem Raj ---- - backends/ppc_initreg.c | 1 + - 1 file changed, 1 insertion(+) - ---- a/backends/ppc_initreg.c -+++ b/backends/ppc_initreg.c -@@ -33,6 +33,7 @@ - #include - #if defined(__powerpc__) && defined(__linux__) - # include -+# include - # include - #endif - diff --git a/package/libs/elfutils/patches/003-libintl-compatibility.patch b/package/libs/elfutils/patches/003-libintl-compatibility.patch index 26fcc85c8b6388..3254dcffb2613a 100644 --- a/package/libs/elfutils/patches/003-libintl-compatibility.patch +++ b/package/libs/elfutils/patches/003-libintl-compatibility.patch @@ -11,9 +11,9 @@ Requires.private: zlib --- a/configure.ac +++ b/configure.ac -@@ -590,6 +590,9 @@ AC_CONFIG_FILES([config/libelf.pc config - AC_SUBST(USE_NLS, yes) - AM_PO_SUBDIRS +@@ -610,6 +610,9 @@ dnl AM_GNU_GETTEXT_REQUIRE_VERSION suppo + AM_GNU_GETTEXT_VERSION([0.19.6]) + AM_GNU_GETTEXT_REQUIRE_VERSION([0.19.6]) +case "$USE_NLS" in yes) intl_LDFLAGS="-lintl" ;; esac +AC_SUBST([intl_LDFLAGS]) @@ -21,51 +21,3 @@ dnl Appended to the config.h file. dnl We hide all kinds of configuration magic in lib/eu-config.h. AH_BOTTOM([#include ]) ---- a/libasm/libasmP.h -+++ b/libasm/libasmP.h -@@ -36,6 +36,9 @@ - - #include "libdwelf.h" - -+#ifdef _ /* fix libintl-stub */ -+#undef _ -+#endif - /* gettext helper macros. */ - #define _(Str) dgettext ("elfutils", Str) - ---- a/libdw/libdwP.h -+++ b/libdw/libdwP.h -@@ -37,6 +37,9 @@ - #include - #include "atomics.h" - -+#ifdef _ /* fix libintl-stub */ -+#undef _ -+#endif - - /* gettext helper macros. */ - #define _(Str) dgettext ("elfutils", Str) ---- a/libdwfl/libdwflP.h -+++ b/libdwfl/libdwflP.h -@@ -47,6 +47,9 @@ - - typedef struct Dwfl_Process Dwfl_Process; - -+#ifdef _ /* fix libintl-stub */ -+#undef _ -+#endif - /* gettext helper macros. */ - #define _(Str) dgettext ("elfutils", Str) - ---- a/libelf/libelfP.h -+++ b/libelf/libelfP.h -@@ -39,6 +39,9 @@ - #include - #include - -+#ifdef _ /* fix libintl-stub */ -+#undef _ -+#endif - /* gettext helper macros. */ - #define _(Str) dgettext ("elfutils", Str) - diff --git a/package/libs/elfutils/patches/005-build_only_libs.patch b/package/libs/elfutils/patches/005-build_only_libs.patch index 501348f21cfb0a..304b85c47a1df2 100644 --- a/package/libs/elfutils/patches/005-build_only_libs.patch +++ b/package/libs/elfutils/patches/005-build_only_libs.patch @@ -3,7 +3,7 @@ @@ -27,7 +27,7 @@ AM_MAKEFLAGS = --no-print-directory pkginclude_HEADERS = version.h - SUBDIRS = config m4 lib libelf libcpu backends libebl libdwelf libdwfl libdw \ + SUBDIRS = config lib libelf libcpu backends libebl libdwelf libdwfl libdw \ - libasm debuginfod src po doc tests + libasm diff --git a/package/libs/elfutils/patches/100-musl-compat.patch b/package/libs/elfutils/patches/100-musl-compat.patch index 508ff9e946f474..52b9f2c43b7ecc 100644 --- a/package/libs/elfutils/patches/100-musl-compat.patch +++ b/package/libs/elfutils/patches/100-musl-compat.patch @@ -1,27 +1,3 @@ -https://sourceware.org/bugzilla/show_bug.cgi?id=21002 - ---- a/lib/system.h -+++ b/lib/system.h -@@ -30,7 +30,18 @@ - #define LIB_SYSTEM_H 1 - - #include --#include -+#ifdef HAVE_ERROR_H -+#include "error.h" -+#else -+#include "err.h" -+#include -+#define error(status, errno, ...) \ -+ do { \ -+ fflush(stdout); \ -+ warn(__VA_ARGS__); \ -+ if (status) exit(status); \ -+ } while(0) -+#endif - #include - #include - #include --- a/libdw/libdw_alloc.c +++ b/libdw/libdw_alloc.c @@ -152,5 +152,5 @@ __attribute ((noreturn)) attribute_hidde @@ -33,15 +9,21 @@ https://sourceware.org/bugzilla/show_bug.cgi?id=21002 } --- a/libdwfl/dwfl_error.c +++ b/libdwfl/dwfl_error.c -@@ -154,7 +154,11 @@ dwfl_errmsg (int error) - switch (error &~ 0xffff) - { - case OTHER_ERROR (ERRNO): +@@ -140,6 +140,7 @@ __libdwfl_seterrno (Dwfl_Error error) + static const char * + errnomsg(int error) + { +#if defined(__GLIBC__) && !defined(__UCLIBC__) - return strerror_r (error & 0xffff, "bad", 0); + /* Won't be changed by strerror_r, but not const so compiler doesn't throw warning */ + static char unknown[] = "unknown error"; + +@@ -150,6 +151,9 @@ errnomsg(int error) + static __thread char msg[128]; + return strerror_r (error, msg, sizeof (msg)) ? unknown : msg; + #endif +#else -+ return strerror (error & 0xffff); ++ return strerror (error & 0xffff); +#endif - case OTHER_ERROR (LIBELF): - return elf_errmsg (error & 0xffff); - case OTHER_ERROR (LIBDW): + } + + const char * diff --git a/package/libs/elfutils/patches/101-no-fts.patch b/package/libs/elfutils/patches/101-no-fts.patch index 29ec9ecac045cd..c4f0b88233f235 100644 --- a/package/libs/elfutils/patches/101-no-fts.patch +++ b/package/libs/elfutils/patches/101-no-fts.patch @@ -1,6 +1,6 @@ --- a/libdwfl/argp-std.c +++ b/libdwfl/argp-std.c -@@ -56,9 +56,6 @@ static const struct argp_option options[ +@@ -53,9 +53,6 @@ static const struct argp_option options[ { "linux-process-map", 'M', "FILE", 0, N_("Find addresses in files mapped as read from FILE" " in Linux /proc/PID/maps format"), 0 }, @@ -10,7 +10,7 @@ { "debuginfo-path", OPT_DEBUGINFO, "PATH", 0, N_("Search path for separate debuginfo files"), 0 }, { NULL, 0, NULL, 0, NULL, 0 } -@@ -85,15 +82,6 @@ static const Dwfl_Callbacks proc_callbac +@@ -82,15 +79,6 @@ static const Dwfl_Callbacks proc_callbac .find_elf = INTUSE(dwfl_linux_proc_find_elf), }; @@ -26,7 +26,7 @@ /* Structure held at state->HOOK. */ struct parse_opt { -@@ -226,43 +214,6 @@ parse_opt (int key, char *arg, struct ar +@@ -223,43 +211,6 @@ parse_opt (int key, char *arg, struct ar } break; diff --git a/package/libs/elfutils/patches/110-no-cdefs.patch b/package/libs/elfutils/patches/110-no-cdefs.patch deleted file mode 100644 index d66f1e924f0ec0..00000000000000 --- a/package/libs/elfutils/patches/110-no-cdefs.patch +++ /dev/null @@ -1,26 +0,0 @@ -From e399540ab67ffe83ca3c4cb768a2f0f2f32a9057 Mon Sep 17 00:00:00 2001 -From: Rosen Penev -Date: Sun, 5 Apr 2020 15:56:59 -0700 -Subject: [PATCH] libelf: remove usage of sys/cdefs - -sys/cdefs is a deprecated glibc header that is unavailable with other -libc implementations such as musl. - -features.h under glibc includes sys/cdefs whereas it does not under musl. - -Signed-off-by: Rosen Penev ---- - lib/fixedsizehash.h | 1 - - libelf/elf.h | 10 ++++++---- - 2 files changed, 6 insertions(+), 5 deletions(-) - ---- a/lib/fixedsizehash.h -+++ b/lib/fixedsizehash.h -@@ -30,7 +30,6 @@ - #include - #include - #include --#include - - #include -