Commit Graph

22 Commits

Author SHA1 Message Date
Alexey Tourbin
34f4788fb2 scripts/functions: invoke av_action with </dev/null 2010-10-04 02:13:53 +04:00
77a7f3cc55 Merge branch 'altlinux-4.0'
Conflicts:

	rpm-4_0.spec
2008-07-08 17:57:45 +00:00
af29ee4d70 fixup-libtool, fixup-pkgconfig: Quote substitution text (ALT#11437) 2008-07-07 22:07:40 +00:00
Alexey Tourbin
e0598b6fe3 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...
2008-02-19 06:28:14 +03:00
Alexey Tourbin
bf4a93fd36 s/\.packaged-files:/.files:/g 2008-02-18 18:26:21 +03:00
Alexey Tourbin
4c187ca387 functions: added new function PackagedFiles() 2008-01-23 01:22:45 +03:00
Alexey Tourbin
11c666284f functions (Fatal): added "ERROR:" prefix 2008-01-22 19:51:11 +03:00
Alexey Tourbin
9ad1babe6a functions: new function: Warning() 2007-12-03 11:39:48 +03:00
Alexey Tourbin
e56761c95f functions (CanonPath): fixed `CanonPath "/"'
was:
$ sh -c '. /usr/lib/rpm/functions; CanonPath /'
readlink: : No such file or directory
$

now:
$ sh -c '. scripts/functions; CanonPath /'
/
$
2007-11-23 11:47:47 +03:00
Alexey Tourbin
d2eedf0fd3 functions: use $(dirname "$0") for /usr/lib/rpm 2007-11-18 08:02:31 +03:00
Alexey Tourbin
78a8d8e533 funcionts (CanonPath): use two-pass canonicalization
This removes the ambiguity with directories.  Note that before this change,
e.g. [ -L /etc/init.d ] and [ -L /etc/init.d/ ] would yield different
result, which required ad hock -d test to keep things consistent.
With first-pass "blind" (cleanup-only) canonicalization, ad hock
test for directories is no longer required, and things are yet more
consistent.

The things are now consistent with documented behaviour -- "canonicalize
each path component except for the last".  This actually changed previous
behaviour:
was:	/etc/init.d -> /etc/rc.d/init.d
now:	/etc/init.d -> /etc/init.d

Generally, if we have some path for which we should yield a dependency,
CanonPath is probably the best we can do before running e.g. contents_index
search.
2007-11-18 02:49:44 +03:00
5e023d62c1 scripts/functions: Minor code cleanup
Fatal, Verbose, Debug: Use Info().
ValidateBuildRoot: Use single quotes for constant string.
SetupMethods: Do not initialize loop variable. Use "tr -s".
RunMethods: Do not initialize loop variable. Use "echo ''" trick. Cleanup "$@" use.
ArgvFileAction: Do not initialize auto variable.
2007-11-10 20:46:29 +00:00
Alexey Tourbin
fddaf81544 functions (SetupMethods): "[!" in shell pattern is better than "[^" 2007-09-24 03:14:24 +04:00
Alexey Tourbin
5a5bd82133 scripts/functions: CanonPath: new function (canonicalize each path component except for the last)
This is actually a DWIM-style hack.  It does what we want but I cannot
think of a better name.  The idea is that sometimes we want to clean
up path name, possibly following symbolic links, except for the last
component, which we want to keep as is.

$ sh -c '. scripts/functions; CanonPath /etc/init.d/functions'
/etc/rc.d/init.d/functions
$ sh -c '. scripts/functions; CanonPath /usr/bin/../bin/perl'
/usr/bin/perl
$

So actually it does a few different things: 1) prepend $PWD if needed;
2) cleanup dirname; 3) canonicalize dirname with respect to symbolic links.

Now the question is how to process symbolic links which
targets are directories, e.g. /etc/init.d ?  My answer is that
both "/etc/init.d" and "/etc/init.d/", as well as "/etc/init.d/."
should yield the same result, which is "/etc/rc.d/init.d".
2007-08-27 21:00:00 +04:00
Alexey Tourbin
ac29fd993a scripts/functions: implemented ArgvFileAction()
This function provides "standard calling conventions" for req/prov methods.
The idea is that the shell script which implements a req/prov method need
not know how exactly it was called and how it should process its arguments.
Instead, it should impelment a function which takes exactly one argument,
which is filename, say MyReq, and finally just call

	ArgvFileAction MyReq "$@"

Standard input to argv conversion is then done automatically and transparently.

This will also enable scripts to process real argv arguments, if any,
instead of standard input (but fall back to standard input otherwise).
I also added --help and -v|--verbose options.  Surprisingly enough,
the latter increases RPM_SCRIPTS_DEBUG level.

Also added non-intrusive canonicalization of pathnames, hence the name
ArgvFileAction.  This is not going to affect rpm-build, but hopefully
this can help when the script is invoked manually.
2007-03-11 15:00:21 +03:00
Alexey Tourbin
844f420037 scripts/functions: implemented SetupMethods() and RunMethods()
I want some rpm scripts to be modular, so that e.g. adding new automatic
dependencies does not require ad hoc modifications.

The plan is as follows: I am going to manage methods.  Methods
are scripts which e.g. implement particular dependency detection.
The set of methods is defined by its suffix, so that /usr/lib/rpm/*.req
are all "req" methods (the "req" method set).

Hereby I provide two functions which abstract the usage of method sets.

1)
methods=$(SetupMethods SETID WANTED_METHODS)

Returns (prints) the list of active methods identified by SETID.
The SETID argument, according to the above, should be filename suffix.

Performs a check if all WANTED_METHODS are available.  WANTED_METHODS is
a space and/or comma separated list of method basenames, e.g. "perl" for
/usr/lib/rpm/perl.req.  The list of WANTED_METHODS is also interpreted
according to AutoReqProv tag rules, i.e. "yes" to enable all methods,
"no" to disable all methods, "noperl" to exclude "perl" etc.

When no methods are active, the output string is guaranteed to be empty.

2)
RunMethods SETID "$methods" [CMD...]

Executes method set scripts identified by SETID; the list of methods
"$methods" must be obtained from SetupMethods.  CMD can warp method script
execution.
2007-03-11 14:59:44 +03:00
Alexey Tourbin
c7a5905b8e scripts/functions: always validate non-empty RPM_BUILD_ROOT
I am going to make certain req/prov scripts work even with empty
RPM_BUILD_ROOT (so that I can analyze the dependencies within the
host system).  This probably means that I will remove ValidateBuildRoot
clause from the script.  However, since non-empty RPM_BUILD_ROOT still
must be valid, I place the check here.
2007-03-06 17:31:31 +03:00
Alexey Tourbin
1490bfdfd8 enhanced RPM_SCRIPTS_DEBUG support, implemented debug levels
Just setting -x is very noisy.  Here is a better plan.  I implement 3
debug levels: verbose (1), debug (2, implies verbose) and -x (3, implies
debug).  I move RPM_SCRIPTS_DEBUG test from scripts to scripts/functions,
as well as provide Verbose() and Debug() shell functions for use in scripts.

Furthermore, _scripts_debug macro is now automatically set when rpmbuild
is invoked with --verbose option.  Use -vv for debug and -vvv for -x.
2007-03-06 17:23:41 +03:00
5416277102 Removed cvsid tags. 2006-05-14 17:05:34 +04:00
ac79bcb3c5 added ValidateBuildRoot() 2003-11-09 16:09:42 +00:00
645bc48c54 added: Info(), Fatal() 2003-11-09 14:27:11 +00:00
b2e513a7ab added functions 2003-11-09 14:26:05 +00:00