From e0598b6fe35fa42ef3737001d1ff38161c6bca84 Mon Sep 17 00:00:00 2001 From: Alexey Tourbin Date: Tue, 19 Feb 2008 02:38:42 +0300 Subject: [PATCH] functions (ValidateBuildRoot): require canonical RPM_BUILD_ROOT Some scripts like lib.req rely on the fact that RPM_BUILD_ROOT should not end with trailing slashes or something. Other scripts like find-package explicitly assume that RPM_BUILD_ROOT can be relocated within filesystem; they use something like "real_buildroot" variables. The code gets complicated, fragile, and error-prone. Therefore, guys, hereby I FORBID non-canonical RPM_BUILD_ROOT path. Note that RPM_BUILD_ROOT actually does not have to exist. This is another problem... --- scripts/functions | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/functions b/scripts/functions index 9ffa7f0..636ef74 100644 --- a/scripts/functions +++ b/scripts/functions @@ -57,8 +57,16 @@ Debug() ValidateBuildRoot() { + [ -n "${RPM_BUILD_ROOT-}" ] || + Fatal 'RPM_BUILD_ROOT not set' [ -n "$(printf %s "$RPM_BUILD_ROOT" |tr -d ' /.')" ] || - Fatal 'invalid $RPM_BUILD_ROOT' + Fatal "bogus RPM_BUILD_ROOT=$RPM_BUILD_ROOT" + local real_buildroot + # There could be simply no %install section... + # I pretend that non-existent buildroot is just canonical enough. + real_buildroot=$(readlink -vm -- "$RPM_BUILD_ROOT") + [ "$RPM_BUILD_ROOT" = "$real_buildroot" ] || + Fatal "non-canonical RPM_BUILD_ROOT=$RPM_BUILD_ROOT real_buildroot=$real_buildroot" } [ -z "${RPM_BUILD_ROOT-}" ] || ValidateBuildRoot