Commit Graph

204 Commits

Author SHA1 Message Date
Panu Matilainen 2bcdeae52e Add return code to handleComments() 2014-02-18 12:38:41 +02:00
Alexander Kanevskiy 91d2bdce5b Include %{VCS} in src.rpm
It is valuable to include VCS information in source rpm packages.

Signed-off-by: Panu Matilainen <pmatilai@redhat.com>
2013-05-14 11:16:03 +03:00
Panu Matilainen e4b7d44eac Use addReqProv() for adding package self-provides too
- We have a function for this stuff so use it. This also ensures
  the per-package rpmds'es and the data in header stay in sync
  and that manually added self-provides wont cause duplicates.
2013-04-16 09:55:19 +03:00
Panu Matilainen 0db12898c5 Use newPackage() to initialize source package too
- As newPackage() initializes the pkg header too, we now need
  a different way of checking whether initSourceHeader() has
  already been called. Checking RPMTAG_NAME should suffice for the job...
2013-04-15 15:16:11 +03:00
Panu Matilainen a3e35ad4c7 Use struct Package for source package too
- Makes the src.rpm that little bit more like other packages.
  Doesn't make things any saner here but we'll want to pass around
  package structs instead of headers later on.
2013-04-15 13:26:01 +03:00
Panu Matilainen e06177ee65 Fix bogus "unclosed %if" error when %include is used in conditionals
- All rpm versions log a bogus "unclosed %if" error when %include
  is used inside %if-%endif (and rpm >= 4.10 actually aborts the
  parse): the check for unclosed if occurs before checking whether
  there's more to come.
- Move the error check into readLine() EOF path along with the other
  similar check to fix, and to consolidate the error handling to
  a single spot.
2012-08-08 09:43:42 +03:00
Panu Matilainen 9c26bd05ea Report starting line for unclosed %if in specs 2012-07-31 16:20:16 +03:00
Panu Matilainen 89ce186258 Dynamically grow spec line buffer on line continuations
- Allows arbitrary length line continuation constructs in specs, but
  probably the more useful side-effect is cleanly handling unterminated
  macros and the like (instead of segfaulting) on large spec files,
  there was a bug on this somewhere but cant find it atm.
- This also has a wee bit silly effect on the maximum macro expansion size:
  after very long constructs the max expansion gets is bigger than
  at the beginning of spec parse, but properly fixing the resizing wrt
  macros is a different issue.
- Watch out for possible fallout from spec->line etc tracking, they
  *seem* to be ok even with the potentially moving buffer location but...
2012-07-31 14:22:08 +03:00
Panu Matilainen e5ea5dcd2d Minor cleanups: const pedantry and helper variable scoping
- Make the reading pointers const, push helpers to scope where needed
2012-07-31 13:27:30 +03:00
Panu Matilainen 729fd554ee Allocate spec line buffer separately from spec struct
- Further preliminaries for dynamic buffer resizing
2012-07-31 11:56:01 +03:00
Panu Matilainen 0c737f72b2 Track spec parse buffer position by offset instead of pointer
- Preliminaries for dynamically reallocating the buffer
2012-07-31 11:12:27 +03:00
Panu Matilainen 55bf9abee2 Initial support for "special" %license, similar to %doc (ticket #116)
- Now that this is relatively sanely doable... make %license with
  non-absolute paths behave similarly to %doc, only installing to a
  different directory (%_licensedir) and with different flags:
  licenses are not generic documentation and should not be skipped
  on installation even if --nodocs is used. The common practise of
  stuffing licenses into %doc actually violates various licenses
  which require the license text to always accompany the software.
- While ticket #116 suggests various schemes to reduce disk usage,
  adding some very special logic to installation code just to deal
  with these doesn't seem justifiable, given how small the licenses
  generally are. However with licenses now in their own directory
  structure (/usr/share/licenses by default), running hardlink on
  them is trivial for cases where disk space is tight
  (live images, embedded systems etc)
2012-05-28 16:55:57 +03:00
Panu Matilainen 06cd93832d Fix spec parsing memleak from source header on buildarch recursion 2012-05-28 12:03:43 +03:00
Panu Matilainen a29c15cb05 Improve spec %include error detection and message
- Besides excess arguments, catch missing argument too
- Log filename and line number like with other error messages
2012-05-11 11:57:09 +03:00
Panu Matilainen 06d9825f4c Unify pops from spec file stack to a function
- Previously done in two different places, calls for a function eh?
2012-05-11 11:30:26 +03:00
Panu Matilainen b3f5959a47 Simplify / sanitize pushing new files on spec file stack
- Replace the rather useless newOpenFileInfo() "constructor" with
  a function to push a new filename on spec stack, creating the
  OFI struct as we go. forceIncludeFile() becomes so simple its
  no longer necessary at all.
2012-05-11 11:08:31 +03:00
Panu Matilainen 9defc922e9 Don't process spec %include in false branch of %if clauses (RhBug:782970) 2012-02-28 12:18:10 +02:00
Panu Matilainen d9932aa63c Also add RPMTAG_OPTFLAGS during spec parse since we easily can... 2011-10-06 11:15:40 +03:00
Panu Matilainen 6c7b53b108 Add implicit self-provides during spec parse already
- Makes the self-provides accessible on spec parse queries, shouldn't
  affect anything else.
2011-10-06 11:02:31 +03:00
Panu Matilainen 1e1bd6709a Avoid extra newlines in parsed spec output outside preamble 2011-06-17 14:25:44 +03:00
Panu Matilainen c38504c4ba Support retrieving the spec contents in parsed format
- Collect the preprocessed (conditionals, macros etc evaluated)
  lines to a separate stringbuf, make rpmSpecGetSection() return
  that on RPMBUILD_NONE "section" (hack, but so is abusing RPMBUILD_FOO
  for the section here so shrug)
2011-06-17 13:52:27 +03:00
Panu Matilainen 7e067c3ed9 Error on unclosed macros & trailing line continuations in spec (RhBug:681567)
- Track the starting line in case copyNextLineFromOFI() indicates
  a multiline-construct. If we get an EOF from readLineFromOFI()
  while inside multiline read, its an illegal construct of some kind
  and we can even spit out a reasonably meaningful error pointing
  out the starting line number of the bad construct.
2011-06-16 19:30:34 +03:00
Panu Matilainen c43cea23e0 Eliminate dead NULL-assignments from rpmSpecFree() 2011-05-27 15:25:05 +03:00
Panu Matilainen b07cfa3365 Eliminate dead NULL-assignments on OFI frees on spec parsing 2011-05-27 15:24:57 +03:00
Panu Matilainen 45522ad7f0 Move build restriction header copying to local scope
- Eliminates accidental use of the variables, eliminating any
  need for NULL'ing the iterator
2011-05-27 15:24:34 +03:00
Panu Matilainen 6123adcb45 Eliminate a couple more dead increments in spec parsing code 2011-05-27 15:05:34 +03:00
Jindrich Novy 00a9450edb Distinguish between macro primitives with and w/o arguments
- do argument presence checks only for those requiring arguments
2011-05-23 14:13:36 +02:00
Jindrich Novy 3a10220715 Unbreak %if, %if(n)arch, %if(n)os handling
- having those expressions without argument is no more allowed
- white space between expression and argument is mandatory
- rpmbuild no more confuses %ifabcd macro with %if abcd
- fix criptic message in case of invalid %if condition
2011-05-20 13:55:39 +02:00
Panu Matilainen 0b36a1f18e Eliminate bogus ferror() checks
- fopen() returns NULL on errors, never an opened stream with error
  flag set. These are leftovers from past where rpmio fd was used
  instead of FILE and probably the checks were bogus even back then too.
2011-05-18 10:59:54 +03:00
Panu Matilainen b4bc5e778e Eliminate unused spectag and speclines goo from spec
- These were used, back in the day, to implement a hidden --specedit
  switch, which in all its glory did: print a copy of a spec file,
  with group, summary and description looked up from specspo.
  This huge pile of junk was left behind from kicking out the
  useless "feature" in commits 7b95061d3b and
  0f991a1420.
2010-10-29 10:12:53 +03:00
Panu Matilainen 94ea5ee25f Fix the remaining enum abuse over rpmParseState in librpmbuild
- rpmParseState uses might actually qualify for a true enum here
  but changing it would require changing half of librpmbuild and
  many of them mix the parse states, other error codes and whatnot
  in their types... just not worth the trouble, so use an int.
2010-10-28 12:01:42 +03:00
Panu Matilainen 7c44f57977 Brute-force s/rpmTag/rpmTagVal/ in entire librpmbuild
- Many of these cases would be true enums from preambleList & similar,
  except for the list terminating sentinel. Just switch all the
  remaining rpmTag's to rpmTagVals to bring our enum-whacking to
  a grande finale.
2010-10-22 13:50:05 +03:00
Panu Matilainen 8274b41ee6 Remove leftover trap for RPMRC_FAIL errors where none should be seen
- Been 2.5 years now without seeing that trap trigger, should be safe
  to remove now ... to silence a warning about comparing to non-existent
  enumeration value.
2010-09-28 22:35:10 +03:00
Panu Matilainen af57879ea0 Remove bunch of double consts in librpmbuild 2010-09-21 16:18:22 +03:00
Panu Matilainen 99b44e35e5 Use actual rpmTags in place of the old HEADER_FOO defines everywhere 2010-09-21 11:58:08 +03:00
Panu Matilainen f9ae396a43 Handle --nolang as another spec parse flag 2010-09-01 18:07:19 +03:00
Panu Matilainen 1c00fe0b5f Combine spec parsing options into a common flag bitfield 2010-09-01 18:03:05 +03:00
Panu Matilainen 2c4976a528 Rename freeSpec() -> rpmSpecFree() for namespacing
- librpmbuild actually now has what remotely resembles an API, after
  we broke every single thing there was ;)
2010-09-01 17:29:27 +03:00
Panu Matilainen 305a476624 Eliminate transaction set from spec parsing internals 2010-09-01 17:18:11 +03:00
Panu Matilainen 5ead64bcd0 Pass flags directly to the lower level parseSpec() helper 2010-09-01 17:13:26 +03:00
Panu Matilainen f579dadf3a Eliminate parseSpec() from librpmbuild, trim unused arguments
- We can't keep compatibility while eliminating goo like transaction set
  from the arguments so dont bother trying.
2010-09-01 17:09:34 +03:00
Panu Matilainen c7ccdea638 A new saner interface for parsing spec files
- For now just a wrapper around parseSpec() that returns *gasp*
  a pointer to a parsed spec structure.
- Limit the amount of goo that needs passing - optimally we'd only need
  the spec + parsing flags, but due to %{buildroot} macro abuse in specs
  we'll need that for now too.
2010-09-01 16:49:43 +03:00
Panu Matilainen c22fff5b93 Eliminate silly and unused timecheck feature from (lib)rpmbuild
- This was broken for years without anybody complaining, should
  be safe to conclude nobody will miss it later either. And if
  somebody misses it, this is a job for rpmlint really.
2010-09-01 16:48:16 +03:00
Panu Matilainen f9740318a8 Spec rootDir is only relevant for building, eliminate from parseSpec()
- The whole rootDir seems dubious for build purposes, but in any case its
  only relevant during the actual build process, not for spec parsing.
  Set spec->rootDir from buildSpec() for the duration of the
  build to avoid having to refactor doScript() and all right now.
2010-09-01 14:31:49 +03:00
Panu Matilainen 4acb8866ef Eliminate cookie from spec structure
- Cookies are not a property of spec but a given build, handle this
  internally to buildSpec() except for --rebuild which passes the
  srpm identifier cookie through buildArgs
2010-09-01 14:00:54 +03:00
Steve Lawrence 383e275648 Add new %sepolicy section to the spec file format
The %sepolicy section is used to describe SELinux policy to be included
in a package. It's syntax is similar to other sections (%files, %pre,
%post, etc.) in that you can provide a string and -n after the
declaration to specify policy should be added to a subpackage.

For example:

%sepolicy
 # policy in this section will be added to the main package

%sepolicy foo
 # policy in this section will be added to the '<mainpackage>-foo' subpackage

%sepolicy -n bar
 # policy in this section will be added to the 'bar' subpackage

The %sepolicy section contains zero or more %semodule directives, with the
following format:

%semodule [OPTIONS] path/to/module.pp

The available options are:

-b, --base
	The module is a base module

-n, --name=NAME
	The name of the module. If not given, assumes the name is the basename of
	the module file with file extensions removed.

-t, --types=TYPES
	One or more comma-separated strings specifying which policy types the
	module can work with. To explicitly state that a module can work with any
	policy type, "default" can be specified as the value. If not specified,
	assumes the module can work with any policy type, and assigns the types as
	"default".

Below is an example of this new format:

  %sepolicy
  %semodule -n foo -t mls policy/foo.pp
  %semodule -n bar -t strict,targeted,mls -b policy/bar.pp

This also adds new header tags to store the new information:
 RPMTAG_POLICYNAMES        (string array)
 RPMTAG_POLICYTYPES        (string array)
 RPMTAG_POLICYTYPESINDEXES (uint32 array)
 RPMTAG_POLICYFLAGS        (uint32 array)

The index of NAMES and FLAGS maps directly to the index of RPMTAG_POLICIES.
However, because a single policy can have multiple types, the mapping for
TYPES is not direct. For this, the index maps to TYPESINDEXES, which
contains the index of the policy that the type maps to. This is similar to
how DIRINDEXES is used to map DIRNAMES and BASENAMES. As an example, the
previous %sepolicy section would have the following header tags:

RPMTAG_POLICIES:
 0: <foo.pp data, base64 encoded>
 1: <bar.pp data, base64 encoded>

RPMTAG_POLICYNAMES:
 0: foo
 1: bar

RPMTAG_POLICYFLAGS:
 0: 0
 1: 1	# assumes flag 1 == BASE

RPMTAG_POILCYTYPES:        RPMTAG_POLICYTYPESINDEXES:
 0: mls                     0: 0
 1: strict                  1: 1
 2: targeted                2: 1
 3: mls                     3: 1
2010-09-01 09:04:27 +03:00
Panu Matilainen a0950b6013 Split arch/os/platform adding out of parseSpec()
- Combining description /checking/ and arch/os/platform /adding/
  into same for-loop (to save cycles or lines, dunno) makes no sense
  whatsoever. No functional changes.
2010-08-26 11:57:49 +03:00
Panu Matilainen 555f699f11 Mass eviction of remaining internal helpers in librpmbuild API
- Yank everything qualifying as "internal helper function" into
  internal-only headers, loosely grouped as follows:
  1) Everything involving spec-manipulation goes into rpmbuild_internal.h
  2) All other miscellaneous helpers go into rpmbuild_misc.h
- This leaves us a rather minimal, and nearly useful API into librpmbuild:
  Users need to be able to parse a spec, query or build (parts of) it
  and free up the spec structure when done. This is what we have now,
  various still exposed structures not counting.
2010-08-25 15:41:09 +03:00
Panu Matilainen 2a6efbca7e Bury OpenFileInfo inside parseSpec.c
- Nothing outside spec parsing machinery needs this nor should mess
  with it, enforce with opaque pointer.
2010-08-25 14:52:58 +03:00
Panu Matilainen e677ea1ea8 Eliminate initSourceHeader() from librpmbuild API
- This is a funky little implementation detail which no caller should
  have to bother with. Move it to parseSpec.c which is the only place
  needing it now and make static.
2010-08-25 14:04:52 +03:00