Skip to content

Commit

Permalink
Add detection of %posttrans and %pretrans scriptlet from rpm header
Browse files Browse the repository at this point in the history
In specs files, user may use %posttrans and %pretrans scriptlet like this:
Requires(pretrans): test_pkg
Requires(posttrans): test_pkg
This commit add detection to the above special scriptlet

Signed-off-by: Shuo Wang <[email protected]>
  • Loading branch information
Shuo Wang committed Mar 18, 2024
1 parent a0d5953 commit 3796d57
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/parsehdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,8 @@ cr_package_from_header(Header hdr,
// Calculate pre value
if (num_flags & (RPMSENSE_PREREQ |
RPMSENSE_SCRIPT_PRE |
RPMSENSE_POSTTRANS |
RPMSENSE_PRETRANS |
RPMSENSE_SCRIPT_POST))
{
pre = 1;
Expand Down
4 changes: 3 additions & 1 deletion tests/python/tests/test_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ def test_package_archer(self):
('fooc', 'EQ', '0', '3', None, False),
('food', 'LT', '0', '4', None, False),
('fooe', 'GT', '0', '5', None, False),
('foof', 'EQ', '0', '6', None, True)
('foof', 'EQ', '0', '6', None, True),
('foog', 'EQ', '0', '7', None, True),
('fooh', 'EQ', '0', '8', None, True)
])
self.assertEqual(pkg.provides, [
('bara', 'LE', '0', '22', None, False),
Expand Down
4 changes: 3 additions & 1 deletion tests/python/tests/test_sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,9 @@ def test_sqlite_primary(self):
(u'fooc', u'EQ', u'0', u'3', None, 1, u'FALSE'),
(u'food', u'LT', u'0', u'4', None, 1, u'FALSE'),
(u'fooe', u'GT', u'0', u'5', None, 1, u'FALSE'),
(u'foof', u'EQ', u'0', u'6', None, 1, u'TRUE')])
(u'foof', u'EQ', u'0', u'6', None, 1, u'TRUE'),
(u'foog', u'EQ', u'0', u'7', None, 1, u'TRUE'),
(u'fooh', u'EQ', u'0', u'8', None, 1, u'TRUE')])

# Check files table
self.assertEqual(con.execute("select * from files").fetchall(),
Expand Down
2 changes: 2 additions & 0 deletions tests/python/tests/test_xml_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ def test_xmlfile_add_pkg(self):
<rpm:entry name="food" flags="LT" epoch="0" ver="4"/>
<rpm:entry name="fooe" flags="GT" epoch="0" ver="5"/>
<rpm:entry name="foof" flags="EQ" epoch="0" ver="6" pre="1"/>
<rpm:entry name="foog" flags="EQ" epoch="0" ver="7" pre="1"/>
<rpm:entry name="fooh" flags="EQ" epoch="0" ver="8" pre="1"/>
</rpm:requires>
<rpm:conflicts>
<rpm:entry name="bba" flags="LE" epoch="0" ver="2222"/>
Expand Down
Binary file modified tests/testdata/packages/Archer-3.4.5-6.x86_64.rpm
Binary file not shown.
2 changes: 2 additions & 0 deletions tests/testdata/specs/fake-Archer.spec
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Requires: fooc = 3
Requires: food < 4
Requires: fooe > 5
Requires(pre): foof = 6
Requires(pretrans): foog = 7
Requires(posttrans): fooh = 8

Provides: bara <= 22
Provides: barb >= 11.22.33-44
Expand Down

0 comments on commit 3796d57

Please sign in to comment.