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

fix: allow fedora based packages #3479

Merged
merged 3 commits into from
Oct 12, 2023

Conversation

philcali
Copy link
Contributor

@philcali philcali commented Aug 1, 2023

Fixes aboutcode-org/scancode.io#831

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 📁
  • Looked for possible updates in documentation and added updates if applicable
  • Updated CHANGELOG.rst

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! This is exactly what is needed! ❤️
Do you mind adding your DCO signoff?

Also we need some tests to avoid a regression.
It does not have to be a full end-to-end test as it would be enough to "recognize" an A SQLite db ... may something like one of these tests? https://github.com/nexB/scancode-toolkit/blob/develop/tests/packagedcode/test_recognize.py that could use a super small rpmdb (eventually trimmed down to get only one or two RPMs)

Another test we would need is an end-to-end test from the CLI using the --system-package option,

@@ -231,8 +231,7 @@ class RpmInstalledNdbDatabaseHandler(BaseRpmInstalledDatabaseHandler):
class RpmInstalledSqliteDatabaseHandler(BaseRpmInstalledDatabaseHandler):
# used by newer RHEL/CentOS/Fedora
datasource_id = 'rpm_installed_database_sqlite'
path_patterns = ('*var/lib/rpm/rpmdb.sqlite',)
filetypes = ('berkeley',)
path_patterns = ('*var/lib/rpm/rpmdb.sqlite', '*usr/lib/sysimage/rpm/rpmdb.sqlite',)
Copy link
Member

Choose a reason for hiding this comment

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

We could also relax it even more like in:

Suggested change
path_patterns = ('*var/lib/rpm/rpmdb.sqlite', '*usr/lib/sysimage/rpm/rpmdb.sqlite',)
path_patterns = ('*rpm/rpmdb.sqlite',)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like that. I'll make the change. Also. I have a pending change to support rpm-ostree variants too.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks!

Copy link
Contributor Author

@philcali philcali Aug 3, 2023

Choose a reason for hiding this comment

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

I created a unit test, but I noted that unrelated tests seem to fail (unsure about those). Also, I was not sure about the --system-package testing. Happy to author, but would need a pointer to the starting thread.

Signed-off-by: Philip Cali <philip.cali@gmail.com>
Signed-off-by: Philip Cali <philip.cali@gmail.com>
@@ -196,3 +196,9 @@ def test_recognize_go_sum(self):
packages = recognize_package_data(test_file)
assert packages
assert isinstance(packages[0], models.PackageData)

def test_recognize_rpmdb_sqlite(self):
test_file = self.get_test_loc('rpm/rpmdb.sqlite')
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we could get a much smaller test file for this? we only need a few packages not everything.

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.

LGTM! Let's try to find a smaller test SQLite DB and let's merge.

@philcali
Copy link
Contributor Author

philcali commented Aug 7, 2023

Updated the DB! Thanks!

Signed-off-by: Philip Cali <philip.cali@gmail.com>
Copy link
Member

@AyanSinhaMahapatra AyanSinhaMahapatra left a comment

Choose a reason for hiding this comment

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

LGTM!
Thanks for the fix @philcali
Merging!

@AyanSinhaMahapatra AyanSinhaMahapatra merged commit 1088337 into aboutcode-org:develop Oct 12, 2023
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.

System package scan for fedora distro does not work
3 participants