Commit Graph

10495 Commits

Author SHA1 Message Date
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 cf802b677e ...and finally eliminate the spec crapola from transaction set for good 2010-09-01 17:20:48 +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 cbd5d98a84 Update callers to use the new rpmSpecParse() interface 2010-09-01 16:59:22 +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
Panu Matilainen 628de71cde Sanitize buildSpec() arguments a bit 2010-09-01 13:46:49 +03:00
Panu Matilainen bd9e1b9d9b Replace buildSpec() with a new interface in the API
- Accept the entire build arguments structure along with a spec, these
  contain everything that we'll need
- Just a convenience wrapper for buildSpec() for now, more things
  to follow...
- Update the sole existing caller accordingly
2010-09-01 13:37:37 +03:00
Panu Matilainen 05dd62aba9 Lift remaining build-related stuff out of librpm over to build-side
- none of this belongs to librpm headers and ABI
2010-09-01 12:34:33 +03:00
Panu Matilainen 76600e5389 Eliminate useless hardwired build debug foo 2010-09-01 10:48:02 +03:00
Panu Matilainen 6cd0bb2b31 Passed-in values are const for every headerPutType() variant
- Silly oversight back then, oh well... this shouldn't affect any callers,
  just avoids dumb warnings where none should be seen
2010-09-01 10:46:57 +03:00
Panu Matilainen 04fce4963c Update translations to pick up new messages 2010-09-01 10:25:06 +03:00
Panu Matilainen 0f79048c66 Add newly added files to POTFILES.in too 2010-09-01 10:24:11 +03:00
Anssi Hannula 7e7ca4b366 debugedit: fix incorrect error messages regarding -b and -d 2010-09-01 10:01:13 +03:00
Steve Lawrence d06449dbaf Add files for testing SELinux collection/plugin
This adds two basic tarballs, one containing two minimal executables
(foo & bar), and one contain a simple policy for the two executables.
This also adds a new spec file with a policy subpackage, the new
%sepolicy section, and the sepolicy collection.
2010-09-01 09:31:10 +03:00
Steve Lawrence 46cdd1b507 Add SELinux policy plugin
This adds a new plugin specifically for a collection to load SELinux
policy. This implements the post_add and pre_remove plugin hooks. The
only time anything happens during the pre_remove hook is if post_add was
not called (i.e.  if the transaction only removes policies).

This plugin extracts all the policy information from packages in the
sepolicy collection during the open te hook. It then determines which
policies should be installed/removed based on if the package is being
installed/removed and the type of the policy and the system policy. It
then executes semodule (or uses libsemanage if semodule cannot be
executed or installing in a chroot) to remove and install the necessary
policies. It then reloads the selinux state, reloads the file contexts,
and if necessary, relabels the file system.
2010-09-01 09:31:03 +03:00
Steve Lawrence 34b5d67c2d Use selabel interfaces instead of matchpathcon
This replaces the old matchpathcon interfaces with the new selabel
interfaces for relabeling files, storing an selabel handle in the
transaction set.

With this change, also comes an added distinction between --nocontexts
being specified and a failure to read the load file contexts.
Previously, there was no distinction, and both cases used the
RPMTRANS_FLAG_NOCONTEXTS flag.

However, with the new policy plugin, it is necessary to make such a
distinction. This is because matchpathcon_init (now selabel interfaces)
can fail at the beginning of the transaction, but succeed later after
new policy is installed. Because of this, we may need to enable/disable
RPMTRANS_FLAG_NOCONTEXTS multiple times. However, because this flag
could also mean --nocontexts, we cannot do that. By storing the selabel
handle in the rpmts, we can easily keep track if the handle has been
successfully created, rather than overloading RPMTRANS_FLAG_NOCONTEXTS
with two meanings.
2010-09-01 09:30:51 +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
Steve Lawrence 5779fb12e2 Remove the existing %policy directive
Remove the existing %policy directive, to be replaced with a new
%sepolicy section with more configurable options.
2010-09-01 09:04:15 +03:00
Steve Lawrence 883f13c8b7 Update the plugin architecture to allow for remembering state
This moves most of the plugin logic to a new rpmplugins file with a
struct and functions for managing plugins, allowing for plugins to carry
state. This also adds init and cleanup hooks for plugins to initialize
and cleanup their state, and a new 'open te' hook allowing plugins to
read and save information from transaction elements.

This also generalizes the plugin architecture a bit so it isn't so
specific to collections.
2010-09-01 09:04:05 +03:00
Panu Matilainen d010ec1c90 Permit packages with no files to omit %files entirely
- Fixes the long standing obscure behavior of missing %files
  section causes build to complete without errors but without producing
  any packages either. Packages without files in them are perfectly
  valid (eg metapackages), requiring empty %files section for those
  is just unnecessary spec noise.
- Remove %files section on one of the test-suite specs to create
  a test-case for this as a side-effect.
- This of course introduces a slight incompatibility with older rpm's,
  if compatibility is required then just add those empty %files in the
  spec, they dont hurt anything but the readers eyes.
2010-08-26 12:31:01 +03:00
Panu Matilainen e38efea49c Clean up newPackage() a bit
- No much point explicitly NULL'ing calloc()'ed memory, only initialize
  the values that are something else + other cosmetics.
2010-08-26 11:58:24 +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 3b15d08cff Stuff the remaining truly internal structure defs out of sight
- All these are internal implementation details that no callers
  should mess with. Bury inside rpmbuild_internal.h.
- spec, package and source structures are tougher nuts as python
  bindings expect to expose some of the information, we'll need
  at least some api to cover walking over package headers etc before
  shutting the door completely.
2010-08-25 16:10:44 +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 94a58d3864 Eliminate unused spec argument from addReqProv()
- addReqProv() only operates on the header, not spec
2010-08-25 15:06:47 +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 8d448745f0 Eliminate freePackage() from librpmbuild API
- The only thing that should ever call this is freePackages() which
  was already made static. As newPackage() links the package structure
  with the spec, its not safe for others to call it.
2010-08-25 14:13:10 +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
Panu Matilainen 68beb82e9f Eliminate ancient leftover initSourceHeader() call
- processSourceFiles() is only ever called through buildSpec(),
  and if you throw unparsed spec into that you're pretty much screwed
  anyway. rpmbuild always called initSourceHeader() anyway, and now
  its ensured for all successfully parsed specs.
2010-08-25 13:51:42 +03:00
Panu Matilainen aafd1d217d Initialize source header from parseSpec() instead of caller(s)
- This is where it logically seems to belong to, after all parseSpec()
  similarly populates all other metadata of the binaries etc too.
  No point requiring callers to do this obscure extra call.
2010-08-25 13:33:15 +03:00
Panu Matilainen b6eb24ebc1 Move source+patch tag insertion into initSourceHeader()
- processSourceFiles() is more about processing the physical files
  ending up in the srpm payload, source + patch tags are mostly just
  informational and can be added early
2010-08-25 13:20:15 +03:00
Panu Matilainen 7209fb6179 Eliminate an exit point from parseSpec() 2010-08-25 12:25:55 +03:00
Panu Matilainen 9ed9daf93e Eliminate doRmSource() from librpmbuild API again
- buildSpec() is sufficient interface for accomplishing the same,
  avoid exposing internal helpers
2010-08-25 11:06:26 +03:00
Panu Matilainen fd893bf69e Fix RhBug:452477 differently to avoid doRmSource() 2010-08-25 11:03:26 +03:00
Panu Matilainen ddee17551f Eliminate addChangelogEntry() from librpmbuild API
- This is just an internal helper for parseChangelog(), no point
  exporting it
2010-08-24 13:56:29 +03:00
Panu Matilainen 692945f29e Eliminate buildHost() and getBuildTime() from librpmbuild API
- Neither is needed anywhere outside pack.c, bury there and make static
2010-08-24 13:54:04 +03:00
Panu Matilainen 64a1351844 Eliminate checkPackages() from librpmbuild API
- No needs outside pack.c, make it static
2010-08-24 13:39:42 +03:00
Panu Matilainen 398df91274 Eliminate parseExpressionString() from librpmbuild
- This has been unused since its introduction in 1998...
2010-08-24 13:37:16 +03:00
Panu Matilainen 0d50dde3d7 Eliminate freePackages() from librpmbuild API
- This is a spec-internal cleanup task, no need outside spec.c
2010-08-24 13:30:12 +03:00
Panu Matilainen 3a765b98b6 Eliminate now unnecessary buildio.h
- readRPM() is not used or needed by anything, shred it
- make writeRPM() static inside the only place needing it: pack.c
- move struct cpioSourceArchive_s inside pack.c
2010-08-24 13:25:49 +03:00
Panu Matilainen 1e1a56ee74 Send the mostly broken rpminject and rpmsort "test programs" to shredder 2010-08-24 13:15:29 +03:00
Panu Matilainen 1719b2f341 Eliminate newOpenFileInfo() from librpmbuild API
- Nothing outside parseSpec.c needs, bury it there and make static
2010-08-24 12:38:50 +03:00
Panu Matilainen 5ed685425e Eliminate addSource() from librpmbuild API
- Nothing outside parsePreamble.c needs, bury it there and make static
2010-08-24 12:35:59 +03:00
Panu Matilainen 38a8700db8 Eliminate parseNoSource() from librpmbuild API
- Nothing outside parsePreamble.c needs, bury it there and make static
2010-08-24 12:31:13 +03:00