Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dependencies to rpm #4084

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

alok1304
Copy link

@alok1304 alok1304 commented Jan 10, 2025

Added dependencies to rpm.

Reference: #649

Fixes #649

Tasks

  • Reviewed contribution guidelines
  • PR is descriptively titled 📑 and links the original issue above 🔗
  • Tests pass -- look for a green checkbox ✔️ a few minutes after opening your PR
    Run tests locally to check for errors.
  • Commits are in uniquely-named feature branch and has no merge conflicts 📁
  • Updated documentation pages (if applicable)
  • Updated CHANGELOG.rst (if applicable)

Signed-off-by: Alok Kumar [email protected]

@alok1304 alok1304 force-pushed the 649-add-dependencies-to-rpm branch from f9c5a17 to 7b69733 Compare January 10, 2025 11:28
@alok1304
Copy link
Author

@pombredanne please review this PR, also all test cases have been successfully executed and passed.

@alok1304 alok1304 force-pushed the 649-add-dependencies-to-rpm branch from 1c0e2b1 to 9bb48db Compare January 10, 2025 12:33
Added dependencies to rpm.

Reference: aboutcode-org#649
Signed-off-by: Alok Kumar <[email protected]>

Signed-off-by: Alok Kumar <[email protected]>
@alok1304 alok1304 force-pushed the 649-add-dependencies-to-rpm branch from 9bb48db to e16372a Compare January 10, 2025 14:26
Copy link
Member

@pombredanne pombredanne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this effort. Please see comments for feedback:

  1. This code cannot and does not work as it is: .rpm archives and installed RPM dbs are not the same.
  2. There is a lot of code duplication
  3. A package cannot be its own dependency
  4. Please start by crafting proper tests first so you can set expectations with carefully reviewed cases.

src/packagedcode/rpm.py Show resolved Hide resolved
@@ -135,13 +134,45 @@ def parse(cls, location, package_only=False):
loc_path = Path(location)
rpmdb_loc = str(loc_path.parent)

rpm_tags = get_rpm_tags(location, include_desc=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This cannot work. By constructions, an installed RPM database is one a binary database in of these formats: ndb, bdb or sqlite. In all cases the payloads are further encoded as binaries, but the DB is NOT accessible by the rpm headers parsing code from get_rpm_tags. This code above may work, but not when parsing an installed database.

src/packagedcode/rpm.py Show resolved Hide resolved
src/packagedcode/rpm.py Show resolved Hide resolved
)

# Prepare the dependent package model
dependencies.append(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks not right at all: you are adding the package as a dependency to itself ?

@@ -253,8 +323,48 @@ class RpmInstalledSqliteDatabaseHandler(BaseRpmInstalledDatabaseHandler):
description = 'RPM installed package SQLite database'
documentation_url = 'https://fedoraproject.org/wiki/Changes/Sqlite_Rpmdb'

@classmethod
def parse(cls, location, package_only=False):
rpm_tags = get_rpm_tags(location, include_desc=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -267,6 +377,47 @@ class RpmInstalledBdbDatabaseHandler(BaseRpmInstalledDatabaseHandler):
description = 'RPM installed package BDB database'
documentation_url = 'https://man7.org/linux/man-pages/man8/rpmdb.8.html'

@classmethod
def parse(cls, location, package_only=False):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

)

# Prepare the dependent package model
dependencies.append(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since when there is a single dependency?

Copy link
Author

@alok1304 alok1304 Jan 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pombredanne Can you suggest how I proceed to find multiple dependencies, I tried by Adding RPMTAG_REQUIRES and RPMTAG_REQUIREVERSION in RPMtags in pyrpm.py but in RPMTAG_REQUIRES I got this like eg: ['/bin/sh', '/bin/sh', '/bin/sh', '/bin/sh', '/bin/sh', 'rpmlib(PayloadFilesHavePrefix)', 'rpmlib(CompressedFileNames)', 'rpmlib(PayloadIsBzip2)']
corresponding I got require_version=[None, None, None, None, None, '4.0-1', '3.0.4-1', '3.0.5-1']
source: http://ftp.rpm.org/max-rpm/ch-queryformat-tags.html (For rpm tages)

can you tell how I proceed to find out their package name and their version, in rmp_requires, these represent capabilities or libraries, not actual packages

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since when there is a single dependency?

I do for single dependency only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add dependencies to RPMs
2 participants