Commit Graph

112 Commits

Author SHA1 Message Date
Panu Matilainen 3db12291fa Implement --json query format
The existing --xml output is extremely useful when inspecting oddities,
but the format is such an eyesore. JSON is much saner to look at.
2024-02-19 11:47:54 +02:00
Daan De Meyer aa0d6d8109 Add aliases for weak dependency queries to rpmspec.
These are all available on the rpm CLI so let's make them available
on the rpmspec CLI as well.
2023-08-21 12:10:13 +03:00
Dirk Müller 2240955422 Rewrite --last to just use sed for formatting
This is the only dependency on awk in the runtime commandline part of
rpm, which is bloating minimal container images a bit. We can rewrite
that into a single sed statement. We love you anyway, awk.
2023-08-10 09:57:42 +03:00
Łukasz Stelmach 0dad385cbc Conditionally display VCS tag in --info query 2023-03-30 12:15:25 +03:00
Panu Matilainen 97c9d8903c Call RPM_CONFIGDIR just that consistently
For whatever historical reasons RPMCONFIGDIR was used in automake
whereas the environment variable is RPM_CONFIGDIR. Just call it that
everywhere.
2023-03-30 11:52:59 +03:00
Panu Matilainen e7b2478ffb Use cmake native PROJECT_FOO to pass around names and versions
Rids us of one layer of autotools compat, yay.
2022-10-21 14:39:03 +03:00
Panu Matilainen db46bd8bd1 Add support for %preuntrans and %postuntrans scriptlets
These are obviously the long lost uninstall-time counterparts of
%pretrans and %posttrans.

%preuntrans is easy but %postuntrans is the reason this hasn't been
implemented so far: by the time it's supposed to execute, the header will
be gone. Work around this by allowing the rpmte to hold on to its header
if it has a %postuntrans scriptlet.

Cheapskate on transaction flags and reuse pre/posttrans flags for these
uninstall counterparts too, adding separate flags and disablers just
doesn't seem worth it, especially as we're quite short of free bits.

Fixes: #2119
2022-09-26 13:00:05 +02:00
Panu Matilainen 2a8d89a1c3 Reimplement --restore as a transaction element, obsolete --setperms & co
--setperms, --setugids and --setcaps were fun demos of alias capabilities
in the nineties, but they can be downright dangerous when used
separately, are blisfully unaware of all state in rpm yet try to
duplicate functionality existing in C, and thus are a constant source
of bugs that are between hard to impossible to fix in the alias space.

Add a new transaction element type for the restore operation, wire
through all the necessary places. In places (like ordering) this is
an overkill but otherwise it seems like a natural thing to be able
to process restore alongside package install/remove. The restore
operation is a cross between install and erase codepath-wise so touches
some funny places, but FA_TOUCH does just the thing, and now all the
regular disablers like --nocontext and --nocaps can be used if
necessary, plugins get to do their work and also timestamps are
restored.

Remove the dangerous shell implementations of things and just make them
aliases to --restore.

Fixes: #965
2022-02-03 13:47:28 +02:00
Michal Domonkos ed07a18773 Skip recorded symlinks in --setperms (RhBug:1900662)
If a package contains a symlink in the buildroot which is declared as a
ghost or config file but is a regular file or directory on the system
where it's installed, a --setperms call will reset its permissions to
those of a symlink (777 on Linux), which almost certainly is not the
correct thing to do.

To fix that, just skip files that were recorded as symlinks.

This is a special case of a general issue in --setperms; since file
permission semantics may change depending on the file type, to stay on
the safe side, any (ghost or config) file whose type changes after
installation should probably be skipped.  However, symlinks are the most
prominent case here, so let's just focus on that now and avoid adding
too much cleverness to a popt alias (this got us into trouble not too
long ago, see commits 38c2f6e and 0d83637).  We may revisit this in the
eventual C implementation.
2022-01-21 16:07:32 +02:00
Florian Festi 8896e81b40 Remove --sign from rpmbuild
When splitting rpmsign from rpmbuild this command line parameter was kept
as an popt alias. But this limits what other parameter can be passed to
the rpmsign command in a difficult to understand way. In the end everyone
is better off using the rpmsign command directly.

Issue a error message stating the parameter is no longer supported and
exit rpmbuild.

Resolves: #153
2020-01-31 10:02:57 +02:00
Peter Jones 1896e58ffd Add all of the rpmbuild macro aliases to rpmspec as well
This adds all of the rpmbuild popt aliases that expand to defines to
rpmspec as well.

It also changes --trace to include --POPTdesc argument help.

[v2: fix an error that broke rpmbuild --trace]

Signed-off-by: Peter Jones <pjones@redhat.com>
2019-09-23 10:52:38 +03:00
Andreas Scherer 3d8a29a9d9 Add --scm option for %autosetup SCM selection
Allow selecting %autosetup SCM backend from cli in case it's not
hardwired in the spec, handy for eg rediffing patches.
2018-11-05 14:52:26 +02:00
Vladimir D. Seleznev a427785734 rpmpopt: make query info command display DistTag if it is non-null
In ALT there can be different builds of the same NEVR which only
differ in DistTag, so it is useful to print its value as part of
package information.

Signed-off-by: Vladimir D. Seleznev <vseleznv@altlinux.org>
2018-11-05 12:05:48 +01:00
Markus Linnala b4178c979f Remove capabilities instead of setting empty caps via. --setcaps
If a file in a package does not have any capabilities rpm --setcaps should
remove capabilities of the file. Prior to this patch capabilities of the file
were set as empty.

Empty capabilities mean more than no capabilities. A file with no capabilities
can inherit capabilities, but file with empty capabilities can not.

When ever package does not have any capabilities set %|FILECAPS? is false.
If some files have capabilities, %|FILECAPS? is true but %{FILECAPS} is ''
when the file does not have capabilities and '= <capstring>' when there is some.

Reported and patch created by Markus Linnala
Commit message edited by Pavlina Moravcova Varekova and Florian Festi.

Fixes #585
Fixes #586
2018-11-05 11:52:03 +01:00
Panu Matilainen 0d83637769 Fix nasty --setperms/--setugids regression in 4.14.2 (RhBug: 1640470)
Commit 38c2f6e160 causes --setperms and
--setugids follow symlinks instead of skipping them.

In case of --setperms, all encountered symlinks will have their
target file/directory permissions set to the 0777 of the link itself
(so world writable etc but suid/sgid stripped), temporarily or permanently,
depending on whether the symlink occurs before or after it's target in the
package file list. When the link occurs before its target, there's a short
window where the target is world writable before having it's permissions
reset to original, making it particularly bad for suid/sgid binaries.

--setugids is similarly affected with link targets owner/group changing
to that of the symlink.

Add missing parentheses to the conditions introduced in commit
38c2f6e160 to fix.
Reported by Karel Srot, patch by Pavlina Moravcova Varekova.
2018-10-22 12:08:46 +03:00
Zbigniew Jędrzejewski-Szmek 1bf40dd21d Skip showing empty Relocations line in rpm -qi
Almost nobody uses them, so the
"Relocations : (not relocatable)" line is a waste of screen estate.
Just output the line if there's something interesting to show.
2018-08-24 13:12:32 +03:00
Filipe Brandenburger 15cf62488b Add shortcut to --nodebuginfo
Currenlty, the incantation to skip creating debuginfo RPMs is:

  $ rpmbuild -ba --define "debug_package %{nil}" hello.spec

Which looks ad-hoc and always requires me to go back and check my notes...

This commit adds a shortcut by making it possible to run:

  $ rpmbuild -ba --nodebuginfo hello.spec

Also add test coverage for the new feature.
2018-08-20 14:20:25 +03:00
Panu Matilainen bc91962b6a Bring ftp/http documentation up to date, eliminate leftovers (#521)
%_ftpport and %_ftpproxy have been unused since 2007 or so, and the
cli options --ftpport and --ftpproxy have been pointing to http proxy,
but ftp- and http-proxy is not interchangable. Eliminate the broken
options, http-proxy settings are used for everything. Update the manual
accordingly, claryifying a few things on the way.
2018-08-20 12:54:58 +03:00
Pavlina Moravcova Varekova 38c2f6e160 Remove misleading --setperms and --setugids warnings (RhBug: 1538610)
Non-existent %ghost or %missingok files should not cause warnings
generated by rpm --setperms or rpm --setugids.
2018-06-28 08:58:31 +02:00
Pavlina Moravcova Varekova af1fcf0b0a Add popt-based options --setcaps and --restore (RhBug:1550745)
--setcaps resets capabilities of package files.

Because the opotion is popt-based it has some drawbacks -
it does not know about %ghost files, file states, etc.

--restore regenerate owner, group, permissions and capabilities
of package files.

It uses 3 already defined options in the correct order.
rpm --setugids is used first of all, because it may change permissions
or capabilities. rpm --setperms is used before rpm --setcaps, but the
opposite order is right too.
2018-04-24 10:30:12 +02:00
Florian Festi 95310111d1 Make coloring of output configurable
Default is never to keep old behaviour
2017-08-09 11:19:05 +02:00
Peter Jones 17d5ae8ed3 Add --trace macros to enable %trace on the command line.
This allows you to do 'rpmspec --trace -P foo.spec", which is much more
natural than editing the .spec itself to add %trace, and much more
convenient than using --eval yourself.

Signed-off-by: Peter Jones <pjones@redhat.com>
2017-02-24 13:23:16 +01:00
Neal Gompa (ニール・ゴンパ) edd380384c Add --changes to read changelog with full timestamps
As of 57f94a5826, it's now possible
to have proper changelogs with dates and times properly set.
Thus, it makes sense to offer an option to render this information.
2016-10-21 11:19:47 +02:00
Florian Festi 2b3f0dbf01 Make help strings a bit nicer 2016-04-12 13:59:58 +02:00
Florian Festi eef69b6093 Remove obsolete --fscontext popt alias 2016-04-12 13:59:58 +02:00
Thierry Vignaud 90da220a4c alias -P on --provides
let's make it symetric/constistent with -R/--requires
2016-01-28 12:51:25 +01:00
fin@linux.vnet.ibm.com dd19c19572 Add file signature support to rpmsign command
This patch extends the rpmsign tool to sign package files. It defines a new
rpmsign option called "signfiles".

rpm --addsign [--signfiles] PACKAGE

Signfiles signs all the file digests included in the package and stores
the signatures in the package header. The file signing key, used to sign
the file digests, can be provided one the command line with --fskpath or
in a macro file with %_file_signing_key. After including file signatures,
the package is signed normally.

The package needs to be built with SHA-1 or SHA-2 digests before package
files are signed, this prerequisite is noted in rpmsign man page.

Changelog:
- throw argerror when --fskpath is used without --signfiles

Signed-off-by: Lubos Kardos <lkardos@redhat.com>
2015-08-12 14:23:31 +02:00
Lubos Kardos d18fdd7f89 Add --filetriggers option to show info about file triggers. 2015-08-06 15:16:30 +02:00
Lubos Kardos 1cf58b30c8 Fix regression in "--sign" option of rpmbuild command (rhbz:#1239039)
Regression from 0bce5fcf27
2015-07-14 10:06:31 +02:00
Lubos Kardos 5dd555adbe Add deprecation warning to description of "--addsign" 2015-03-27 10:05:44 +01:00
Denis Ollier 5573511317 Fix --last sorting with non-en locales
On some locales (e.g: french), sort interprets the space character as a
thousands separator. As a result, digit(s) at the beginning of package
names (e.g: '0' for 0ad), are merged with package installation
timestamp and the output of rpm -qa --last is wrong.

For instance, the following list:

    1398777401 0ad-0.0.15-3.fc20.x86_64
    1397901236 kernel-3.13.10-200.fc20.x86_64
    1399198174 kernel-3.14.2-200.fc20.x86_64

is sorted like this:

    1398777401 0ad-0.0.15-3.fc20.x86_64
    1399198174 kernel-3.14.2-200.fc20.x86_64
    1397901236 kernel-3.13.10-200.fc20.x86_64

instead of:

    1399198174 kernel-3.14.2-200.fc20.x86_64
    1398777401 0ad-0.0.15-3.fc20.x86_64
    1397901236 kernel-3.13.10-200.fc20.x86_64

This patch ensures that the space character is not interpreted as a
thousands separator anymore by setting the environment variable
LC_NUMERIC to C locale for numeric sorts.
2015-03-27 09:56:58 +01:00
Florian Festi 9eb9581d3c Add --recommends, --suggests, --supplements and --enhances aliases to rpm -q 2014-02-19 12:11:27 +01:00
Panu Matilainen 4c90c79e3f Unbreak --setperms (RhBug:881835)
- Fixes a regression introduced in rpm >= 4.10 caused by query format
  simplification (loss of zero padding support), in commit
  1f1e5e88a1.
- 'chmod' command doesn't need zero padding, just remove the formatting.
  In fact we shouldn't be passing the entire mode to it but just the
  permission bits, but fortunately chmod isn't too picky here.
2012-11-30 08:23:51 +02:00
Tim Landscheidt 1825e8863c Don't call "rpm --addsign" if rpmbuild didn't create RPMs.
Signed-off-by: Panu Matilainen <pmatilai@redhat.com>
2012-11-01 11:08:23 +02:00
Panu Matilainen cb2894b361 Show arch in --last output too (RhBug:768516) 2012-01-12 09:52:34 +02:00
Panu Matilainen 9e363dba03 Show all interpreter arguments on --scripts query (ticket #847)
- Previously any arguments to interpreter were invisible unless
  you happened to know that RPMTAG_FOOPROG are actually string
  arrays despite their type showing plain string, and queried
  as arrays. This makes all the arguments for all scriptlets
  supporting interpreter arguments visible on --scripts query
  and also serves as an example on how to properly query them.i
- Perhaps worth noting is the exact formatting of the query:
  "(using[ %{PRETRANSPROG}]" instead of the more typical style of
  "(using [%{PRETRANSPROG} ]" to avoid extra trailing blanks.
2011-09-12 12:28:58 +03:00
Panu Matilainen 527fa4a730 Show possible %verifyscript interpreter similarly to other scriptlets 2011-09-12 12:10:29 +03:00
Panu Matilainen d0198dac5a Use the new FOO_NEVRS extensions for --requires etc popt aliases
- Makes the popt foobar somewhat saner and fixes RhBug:717534 and
  RhBug:735801 while at it.
2011-09-06 16:12:15 +03:00
Panu Matilainen 9f3a0debb6 Fix rpmsign --key-id popt alias typo 2011-01-10 14:09:57 +02:00
Panu Matilainen 90440e2036 Remove absolute paths from our popt exec aliases now that we can
- poptExecPath() pointing to meaningful place allows removal of these.
- Make test-suite rely on the --initdb exec alias so we catch out
 if anything here breaks
2010-11-15 10:23:27 +02:00
Panu Matilainen ad0687bd57 Kill broken --rebuilddbpath popt alias
- It's been broken because of a typo for the last ten years and nobody
  noticed, doesn't seem like a particularly useful switch...
2010-11-09 15:57:02 +02:00
Panu Matilainen 7bc9cc79d1 Move --dbpath into common rpm popt options table
- This ensures its available in all our executables without adding
  umphteen copies into rpmpopt (after the cli splits, this was missing
  in eg rpmdb executable...)
2010-11-09 09:23:14 +02:00
Panu Matilainen f9a32ac3de Lose the remaining dbapi references in code + configuration
- Changing db_api to db_ver to force breakage on anything using the
  value, db_ver containing the BDB major version just to put something
  in the error messages where the dbapi version used to be.
2010-11-04 15:55:19 +02:00
Panu Matilainen 73de3a22f0 Add --requires etc popt aliases for rpmspec too
- In addition to the regular dependencies, add --buildrequires
  and --buildconflicts which are just --srpm --requires and
  --srpm --conflicts in reality
2010-10-12 15:39:52 +03:00
Panu Matilainen 0048c39479 Add cli switches to override signing key and digest algorithm 2010-10-04 16:04:47 +03:00
Panu Matilainen e8a1f5da3e Lift specfile query out of main rpm(query) into separate binary
- Avoids having to link /bin/rpm with librpmbuild and everything it
  might bring in (eg libmagic) which are not needed for core operation.
- Minimally preserve backwards compatibility with popt exec alias
2010-10-04 14:31:55 +03:00
Panu Matilainen 9f68c7958f Rip IAM_RPMDB, ie --initdb, --rebuilddb etc modes out of rpmqv.c and librpm
- Add popt exec aliases to rpmdb for backwards compatibility
- Change test-suite to use 'rpmdb --initdb' instead of 'rpm --initdb'
  as popt exec aliases with absolute paths dont play very well
  with the test-suite, duh...
2010-09-03 17:13:10 +03:00
Panu Matilainen 3cbda9c03f Rip IAM_RPMK, ie --import and --checksig modes out of rpmqv.c + librpm
- Add popt exec aliases to rpmkeys for backwards compatibility
2010-09-03 16:32:43 +03:00
Panu Matilainen c382cd5373 Rrrriiip the addsign/resign/delsign bits out of rpmqv.c + friends
- Add popt exec aliases to rpmsign for backwards compatibility (dejavu...)
2010-09-03 15:12:12 +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