如何将 .sh Shell 脚本转换为 AutoConf 配置.ac 文件?
我想向 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
虽然您可以将 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 aconfigure
script.configure
scripts are run by non-sudo-capable users all the time and need to work for them, and even if the user runningconfigure
cansudo
, the expectation for running theconfigure
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 inAC_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.