题
我必须将一个RPM(为Fedora制作)作为deb包移植到Ubuntu。
在RPM .spec文件中,我使用了几个变量( $ RPM_BUILD_ROOT,%{_ libdir},%{name},%{version}
)来创建符号链接:
%install
...
(cd $RPM_BUILD_ROOT/%{_bindir}; ln -sf %{_libdir}/%{name}-%{version}/%{name} . )
(相对符号链接被禁止(请不要问为什么) - 这就是为什么 ln
命令看起来很奇怪。)
那么, debian / rules
makefile中那些变量的等价物是什么?
提前致谢。
解决方案
(旁白:这似乎是上游Makefile应该做的事情,而不是下游包装。)
取决于您用于 rules
文件的框架。
在 CDBS 中,这样的事情应该有效......
#!/usr/bin/make -f
include /usr/share/cdbs/1/rules/debhelper.mk
# probably what you want (automagic happens),
# but I don't know details of your package
#include /usr/share/cdbs/1/class/automake.mk
DEBVERS := $(shell dpkg-parsechangelog | sed -n -e 's/^Version: //p')
VERSION := $(shell echo '$(DEBVERS)' | sed -e 's/^[[:digit:]]*://' -e 's/[~-].*//')
install/$(DEB_ALL_PACKAGES)::
dh_link -p$(cdbs_curpkg) \
/usr/lib/$(cdbs_curpkg)-$(VERSION)/$(cdbs_curpkg) \
/usr/bin/$(cdbs_curpkg)
如果您有更好的获取版本的方法(例如, $(shell cat version.txt))
),请使用它。 Debian版本并不总是源包版本;在这里,我删除了纪元和包装版本,如果有的话,但这并不总是正确的。
其他CDBS类可能会定义 $$ {libdir}
和 $$ {bindir}
,但我没有看到任何常见的东西。
请注意, dh_link
将尽可能建立相对链接,即使给定绝对路径也是如此。如果这是一个问题,你可能不得不诉诸一些非常讨厌的东西,如
cd debian/$(cdbs_curpkg) && ln -s ...
其他提示
在较新版本的dpkg(1.17.0+)中,您可以获得完整版本:
DEBVER := $(shell dpkg-parsechangelog -SVersion)
假设您有 SHELL:= / bin / bash
,则无需使用sed来提取部件。只需使用bash字符串插值,如下所示:
DEBVERSION := $(shell debver="$(DEBVER)"; echo "${debver%-*}")
不隶属于 StackOverflow