如何将 .sh Shell 脚本转换为 AutoConf 配置.ac 文件?

发布于 2025-01-10 17:27:25 字数 796 浏览 0 评论 0原文

我想向 GitHub 存储库提交补丁,但他们使用configure.ac 生成配置文件。我能够在 Shell 脚本中编写补丁,但我不知道如何将其转换为Configure.ac 可以接受的内容。请帮助

我想要转换的shell脚本代码片段

distroname=`lsb_release -i | cut -f 2-`
ubuntudistro="Ubuntu"
poposdistro="Pop"
debiandistro="Debian"
elementaryosdistro="elementary"
kalilinuxdistro="Kali"
mxlinuxdistro="MX"
parrotosdistro="Parrot"
pclinuxosdistro="PCLinuxOS"
zorinosdistro="Zorin"

if [ $distroname -eq $ubuntudistro -o $distroname -eq $poposdistro -o $distroname -eq $debiandistro -o $distroname -eq $elementaryosdistro -o $distroname -eq $kalilinuxdistro -o $distroname -eq $mxlinuxdistro -o $distroname -eq $parrotosdistro -o $distroname -eq $pclinuxosdistro -o $distroname -eq $zorinosdistro ]
then
        sudo apt-get install libssl-dev liblzo2-dev libpam0g-dev
fi

I wanted to submit a PATCH to a GitHub repo but they use configure.ac to generate CONFIGURE files. I was able to write the patch in Shell Script but I don't know how to convert it to something that Configure.ac would accept. Please help

The shell script code snippet I want to get converted

distroname=`lsb_release -i | cut -f 2-`
ubuntudistro="Ubuntu"
poposdistro="Pop"
debiandistro="Debian"
elementaryosdistro="elementary"
kalilinuxdistro="Kali"
mxlinuxdistro="MX"
parrotosdistro="Parrot"
pclinuxosdistro="PCLinuxOS"
zorinosdistro="Zorin"

if [ $distroname -eq $ubuntudistro -o $distroname -eq $poposdistro -o $distroname -eq $debiandistro -o $distroname -eq $elementaryosdistro -o $distroname -eq $kalilinuxdistro -o $distroname -eq $mxlinuxdistro -o $distroname -eq $parrotosdistro -o $distroname -eq $pclinuxosdistro -o $distroname -eq $zorinosdistro ]
then
        sudo apt-get install libssl-dev liblzo2-dev libpam0g-dev
fi

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

極樂鬼 2025-01-17 17:27:25

虽然您可以将 shell 代码添加到 configure.ac,但无论如何不要configure脚本。

configure 脚本始终由不具备 sudo 能力的用户运行,需要为他们工作,即使运行 configure 的用户可以 sudo,运行 configure 脚本的期望是它不会更改它正在配置的构建目录之外的任何 - 当然也不会在系统范围内安装软件。

configure 脚本检查是否安装了必要的东西,以及是否安装了一些可选的东西。如果缺少某些重要内容,configure 应该会中止,并在 AC_MSG_ERROR([...]) 中显示一条正确的错误消息。

这样的错误消息很可能包含安装像 libpam0g-dev 这样的软件包的建议,特别是如果常用的发行版软件包名称与上游的软件包名称不同。

While you can just add shell code to configure.ac, HOWEVER, DO NOT sudo install software system wide from a configure script.

configure scripts are run by non-sudo-capable users all the time and need to work for them, and even if the user running configure can sudo, the expectation for running the configure script is that it does not change anything outside of the build directory it is configuring -- and certainly not that it installs software system wide.

The configure script checks whether the necessary things are installed, and whether some optional things are installed. If something essential is missing, configure then should abort with a good error message in AC_MSG_ERROR([...]).

Such an error message might very well include a suggestion to install a package like libpam0g-dev, especially if commonly used distro package names differ from upstream's package name.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文