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

Move changelog to markdown and add unreleased changes #18

Closed
wants to merge 48 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
df8cb50
Detect librpm.so.9
agrare Jan 22, 2025
c58b7d4
Rename rpm gem to rpm2
agrare Jan 30, 2025
7eb9883
Add .whitesource configuration file
mend-bolt-for-github[bot] Jan 30, 2025
74a524a
Merge pull request #1 from agrare/rename_gem_rpm2
Fryguy Jan 30, 2025
56493e3
Merge pull request #2 from ManageIQ/whitesource/configure
Fryguy Jan 30, 2025
8468e85
Replace .travis.yml with GitHub Actions
agrare Jan 30, 2025
d0348ce
Skip known failing tests
agrare Jan 31, 2025
a96a0d9
Merge pull request #3 from agrare/add_gihub_actions
Fryguy Jan 31, 2025
b5d9a1e
Merge pull request #5 from agrare/detect_librpm_9
Fryguy Jan 31, 2025
2e74a76
Do not use headerNVR in Package.version
pterjan Jan 5, 2025
2b0a9d2
Drop skipped failing tests due to .to_s exception
agrare Jan 31, 2025
2937fb2
Merge pull request #4 from agrare/fix_rpm_package_version
Fryguy Jan 31, 2025
be38e2c
Update copyright
Fryguy Jan 31, 2025
abde5d6
Add workflow_dispatch to GitHub action
Fryguy Jan 31, 2025
b241823
Split docker build from docker test in CI
Fryguy Jan 31, 2025
77c0de7
Expose rake tasks to rake -T
Fryguy Jan 31, 2025
85099a8
Merge pull request #7 from Fryguy/copyright_update
agrare Jan 31, 2025
e2c8391
Merge pull request #8 from Fryguy/add_workflow_dispatch
agrare Jan 31, 2025
580e552
Merge pull request #9 from Fryguy/split_test_setup
agrare Jan 31, 2025
0d115f1
Merge pull request #10 from Fryguy/expose_rake_tasks
agrare Jan 31, 2025
600cae4
Remove unsused variables
Fryguy Jan 31, 2025
95aff1a
Fix issue where incorrect class names would clobber each other
Fryguy Jan 31, 2025
33131e0
Remove useless assertion of nothing raised
Fryguy Jan 31, 2025
77bac13
Remove unused variables
Fryguy Jan 31, 2025
f310242
Remove duplicate function definitions
Fryguy Jan 31, 2025
ba18599
Fix deprecated minitest assert_equal(nil, ...)
Fryguy Jan 31, 2025
407fc40
Merge pull request #11 from Fryguy/cleanup_warnings
agrare Jan 31, 2025
d51f372
Use rpmExpandMacros on rpm v4.14+
agrare Jan 31, 2025
17fc3e9
Skip possibly hanging tests
agrare Jan 31, 2025
4a09322
Raise on rpmExpandMacros/expandMacros errors
agrare Jan 31, 2025
07ddb88
Merge pull request #12 from agrare/fix_rpm_expand_macros
Fryguy Jan 31, 2025
016fafd
Add timeout-minutes: 5 to CI workflow
agrare Jan 31, 2025
79609c1
Add CODEOWNERS
agrare Jan 31, 2025
7575e4d
Update rpmExpandMacros MemoryPointer usage
agrare Jan 31, 2025
e2ccd3b
Merge pull request #13 from agrare/add_timeout_minutes_to_ci
Fryguy Jan 31, 2025
a5e7874
Merge pull request #14 from agrare/add_codeowners
Fryguy Jan 31, 2025
2e367b8
Merge pull request #15 from agrare/update_rpm_expand_macros
Fryguy Jan 31, 2025
cf14a22
Split tests by platform
Fryguy Jan 31, 2025
f390e0a
Cleanup the dangling podman runs from test
Fryguy Jan 31, 2025
20020f5
Merge pull request #16 from Fryguy/split_tests_by_platform
agrare Jan 31, 2025
6bf9a8f
Force the platform to linux/amd64 in tests
Fryguy Jan 31, 2025
976aeb0
Prefer registry.access.redhat.cm
Fryguy Jan 31, 2025
5d87ead
Fully qualify the docker tag to the localhost registry
Fryguy Jan 31, 2025
078927b
Merge pull request #17 from Fryguy/force_arch
agrare Jan 31, 2025
fd14513
Drop skip for test_flag_install
agrare Feb 3, 2025
73676f0
Merge pull request #18 from agrare/fix_test_flag_install
Fryguy Feb 3, 2025
744247e
Move CHANGELOG to markdown and add missing versions
agrare Feb 3, 2025
be6d3d2
Add unreleased changes to new CHANGELOG
agrare Feb 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @agrare @Fryguy
25 changes: 25 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: CI

on:
push:
pull_request:
schedule:
- cron: '0 0 * * 0'
workflow_dispatch:

jobs:
ci:
timeout-minutes: 5
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform:
- ubi8
- ubi9
steps:
- uses: actions/checkout@v4
- name: Build docker image
run: rake docker_images[${{ matrix.platform }}]
- name: Run tests
run: rake docker_test[${{ matrix.platform }}]
20 changes: 0 additions & 20 deletions .travis.yml

This file was deleted.

3 changes: 3 additions & 0 deletions .whitesource
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"settingsInheritedFrom": "ManageIQ/whitesource-config@master"
}
63 changes: 63 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Change Log

All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
### Added
- Detect librpm.so.8
- Make rpm_version_macro available in c/rpmmacro
- Attach addMacro/delMacro as rpmPushMacro and rpmPopMacro in >= 4.14.0
- Detect librpm.so.9 ([#5](https://github.com/ManageIQ/ruby-rpm-ffi2/pull/5))

### Changed
- MiniTest::Unit::TestCase is now Minitest::Test
- Rename rpm gem to rpm2 ([#1](https://github.com/ManageIQ/ruby-rpm-ffi2/pull/1))
- Replace TravisCI with Github Actions ([#3](https://github.com/ManageIQ/ruby-rpm-ffi2/pull/3))

### Fixed
- Do not attach deprecated headerNVR on >= 4.14.0
- Handle deprecated addMacro/delMacro
- Do not use headerNVR in Package.version ([#4](https://github.com/ManageIQ/ruby-rpm-ffi2/pull/4))
- Use rpmExpandMacros on rpm v4.14+ for `RPM#[]` ([#12](https://github.com/ManageIQ/ruby-rpm-ffi2/pull/12))

## [0.0.5] - 2016-07-09
### Added
- Add rake for travis
- Search for librpm.so.3 too

### Changed
- Moved to minitest
- ruby 1.9.x not supported anymore

## [0.0.4] - 2013-10-24
### Fixed
- Bugfix: too many open files on transaction with blocks
- Fixing the access to FileAttrs and FileState constants from RPM::File

## [0.0.3] - 2012-02-23
### Changed
- RPM::FFI module is now RPM::C

### Added
- implement Trasaction#commit, Trasaction#install, Trasaction#upgrade,

## [0.0.2] - 2012-01-04
### Added
- Add MatchIterator support and expose it in Transaction
- Implement transaction callback
- Implemented RPM::File
- implement RPM#[]=

### Changed
- Renamed RPM::Header to RPM::Package

### Fixed
- Fix name not getting set. Better use headerPutString
- Fix RPM#[]

[Unreleased]: https://github.com/ManageIQ/ruby-rpm-ffi2/compare/v0.0.5...HEAD
[0.0.5]: https://github.com/ManageIQ/ruby-rpm-ffi2/compare/v0.0.4...v0.0.5
[0.0.4]: https://github.com/ManageIQ/ruby-rpm-ffi2/compare/v0.0.3...v0.0.4
[0.0.3]: https://github.com/ManageIQ/ruby-rpm-ffi2/compare/v0.0.2...v0.0.3
[0.0.2]: https://github.com/ManageIQ/ruby-rpm-ffi2/compare/aa5c84efc5...v0.0.2
10 changes: 0 additions & 10 deletions ChangeLog

This file was deleted.

9 changes: 4 additions & 5 deletions MIT-LICENSE
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@

Copyright © 2025 ManageIQ Authors
Copyright © 2011 Duncan Mac-Vicar Prett <[email protected]>
Copyright © 2011 SUSE Linux Products GmbH
Copyright © 2002 Kenta Murata

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@

# RPM bindings for ruby

![maintained](https://img.shields.io/maintenance/yes/2016.svg) [![Build Status](https://travis-ci.org/dmacvicar/ruby-rpm-ffi.svg?branch=master)](https://travis-ci.org/dmacvicar/ruby-rpm-ffi)

* http://github.com/dmacvicar/ruby-rpm-ffi
[![CI](https://github.com/ManageIQ/ruby-rpm-ffi2/actions/workflows/ci.yaml/badge.svg)](https://github.com/ManageIQ/ruby-rpm-ffi2/actions/workflows/ci.yaml)

# WARNING

Expand Down Expand Up @@ -70,7 +68,7 @@ This gem:

* Is pure ruby
* Is documented
* Has as a goal to support only the latest rpm version plus the ones in
* Has as a goal to support only the latest rpm version plus the ones in
use some releases back in popular rpm based distros
* Uses FFI, so it should work with other interpreters
(Because https://github.com/rubinius/rubinius/issues/682 it currently does
Expand Down Expand Up @@ -366,11 +364,11 @@ rake docker_test

# LICENSE

* Copyright © 2025 ManageIQ Authors
* Copyright © 2011 Duncan Mac-Vicar Prett <[email protected]>
* Copyright © 2011 SUSE Linux Products GmbH

* This gem is a pure-ruby rewrite of ruby-rpm:
Copyright © 2002 Kenta Murata. Relicensed with his permission.

Licensed under the MIT license. See MIT-LICENSE for details.

26 changes: 16 additions & 10 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,24 @@ rescue LoadError
end
end

task :docker_images do
Dir.chdir('_docker') do
Dir.glob('Dockerfile.*').each do |dockerfile|
tag = 'ruby-rpm-ffi:' + File.extname(dockerfile).delete('.')
sh %(docker build -f #{dockerfile} -t #{tag} .)
end
def each_dockerfile(platform)
platform ||= "*"
Dir.glob("_docker/Dockerfile.#{platform}").each do |dockerfile|
tag = "localhost/ruby-rpm-ffi:#{File.extname(dockerfile).delete('.')}"
yield dockerfile, tag
end
end

desc "Build the docker images for test"
task :docker_images, [:platform] do |_t, args|
each_dockerfile(args[:platform]) do |dockerfile, tag|
sh "podman build --platform=linux/amd64 -f #{dockerfile} -t #{tag} ."
end
end

task :docker_test do
Dir.glob('_docker/Dockerfile.*').each do |dockerfile|
tag = 'ruby-rpm-ffi:' + File.extname(dockerfile).delete('.')
sh %(docker run -ti -v #{Dir.pwd}:/src #{tag} rake test)
desc "Run the tests from within the docker images"
task :docker_test, [:platform] do |_t, args|
each_dockerfile(args[:platform]) do |dockerfile, tag|
sh "podman run --platform=linux/amd64 --rm -ti -v #{Dir.pwd}:/src #{tag} rake test"
end
end
4 changes: 0 additions & 4 deletions _docker/Dockerfile.leap

This file was deleted.

4 changes: 0 additions & 4 deletions _docker/Dockerfile.tumbleweed

This file was deleted.

8 changes: 8 additions & 0 deletions _docker/Dockerfile.ubi8
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM registry.access.redhat.com/ubi8/ubi
RUN dnf module -y enable ruby:3.1
RUN dnf install -y ruby git
RUN gem install bundler
WORKDIR /src
RUN ls -lR
COPY ../ /src
RUN bundle install
8 changes: 8 additions & 0 deletions _docker/Dockerfile.ubi9
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM registry.access.redhat.com/ubi9/ubi
RUN dnf module -y enable ruby:3.3
RUN dnf install -y ruby git
RUN gem install bundler
WORKDIR /src
RUN ls -lR
COPY ../ /src
RUN bundle install
21 changes: 16 additions & 5 deletions lib/rpm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,22 @@ def self.transaction(root = '/')
# @param [String] name Name of the macro
# @return [String] value of macro +name+
def self.[](name)
val = ''
buffer = ::FFI::MemoryPointer.new(:pointer, 1024)
buffer.write_string("%{#{name}}")
ret = RPM::C.expandMacros(nil, nil, buffer, 1024)
buffer.read_string
if C::rpm_version_code >= ((4 << 16) + (14 << 8) + (0 << 0))
obuf = ::FFI::MemoryPointer.new(:pointer, 1)
sbuf = FFI::MemoryPointer.from_string("%{#{name}}")
ret = RPM::C.rpmExpandMacros(nil, sbuf, obuf, 0)
raise if ret < 0

val = obuf.read_pointer
val.nil? ? nil : val.read_string
else
buffer = ::FFI::MemoryPointer.new(:pointer, 1024)
buffer.write_string("%{#{name}}")
ret = RPM::C.expandMacros(nil, nil, buffer, 1024)
raise if ret < 0

buffer.read_string
end
end

# Setup a macro
Expand Down
1 change: 1 addition & 0 deletions lib/rpm/c.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module C

begin
ffi_lib ['rpm',
'librpm.so.9',
'librpm.so.8', # Tumbleweed
'librpm.so.7', # fedora 23
'librpm.so.3', 'librpm.so.2', 'librpm.so.1']
Expand Down
2 changes: 0 additions & 2 deletions lib/rpm/c/rpmio.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ module C

attach_function 'fdDup', [:int], :FD_t

attach_function 'Fstrerror', [:FD_t], :string

attach_function 'fdLink', [:pointer], :FD_t
end
end
1 change: 1 addition & 0 deletions lib/rpm/c/rpmmacro.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module C
if rpm_version_code >= ((4 << 16) + (14 << 8) + (0 << 0))
attach_function 'rpmPushMacro', [:pointer, :string, :string, :string, :int], :void
attach_function 'rpmPopMacro', [:pointer, :string], :void
attach_function 'rpmExpandMacros', [:pointer, :pointer, :pointer, :int], :int
else
attach_function 'addMacro', [:pointer, :string, :string, :string, :int], :void
attach_function 'delMacro', [:pointer, :string], :void
Expand Down
2 changes: 0 additions & 2 deletions lib/rpm/c/rpmts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ module C
attach_function 'rpmtsFlags', [:rpmts], :rpmtransFlags
attach_function 'rpmtsSetFlags', %i[rpmts rpmtransFlags], :rpmtransFlags
# ...
attach_function 'rpmtsSetNotifyCallback', %i[rpmts rpmCallbackFunction rpmCallbackData], :int
# ...
attach_function 'rpmtsCreate', [], :rpmts
attach_function 'rpmtsAddInstallElement', %i[rpmts header fnpyKey int rpmRelocation], :int
attach_function 'rpmtsAddEraseElement', %i[rpmts header int], :int
Expand Down
13 changes: 2 additions & 11 deletions lib/rpm/package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ def changelog
# @return [String, Fixnum, Array<String>, Array<Fixnum>, nil]
# The value of the entry
def [](tag)
val = nil
tagc = ::FFI::AutoPointer.new(RPM::C.rpmtdNew, Package.method(:release_td))

return nil if RPM::C.headerGet(ptr, tag, tagc,
Expand Down Expand Up @@ -261,15 +260,7 @@ def arch

# @return [Version] Version for this package
def version
v_ptr = ::FFI::MemoryPointer.new(:pointer, 1)
r_ptr = ::FFI::MemoryPointer.new(:pointer, 1)

RPM::C.headerNVR(ptr, nil, v_ptr, r_ptr)
v = v_ptr.read_pointer.read_string
r = r_ptr.read_pointer.read_string
v_ptr.free
r_ptr.free
Version.new(v, r, self[:epoch])
Version.new(self[:version], self[:release], self[:epoch])
end

# String representation of the package: "name-version-release-arch"
Expand Down Expand Up @@ -324,7 +315,7 @@ def initialize_from_filename(filename)
fd = RPM::C.Fopen(filename, 'r')
raise "#{filename} : #{RPM::C.Fstrerror(fd)}" if RPM::C.Ferror(fd) != 0
RPM.transaction do |ts|
rc = RPM::C.rpmReadPackageFile(ts.ptr, fd, filename, hdr)
RPM::C.rpmReadPackageFile(ts.ptr, fd, filename, hdr)
end
ensure
RPM::C.Fclose(fd) unless fd.nil?
Expand Down
2 changes: 0 additions & 2 deletions lib/rpm/transaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,6 @@ def check
# end
# @yield [CallbackData] sig Transaction progress
def commit
flags = RPM::C::TransFlags[:none]

callback = proc do |hdr, type, amount, total, key_ptr, data_ignored|
key_id = key_ptr.address
key = @keys.include?(key_id) ? @keys[key_id] : nil
Expand Down
8 changes: 4 additions & 4 deletions lib/rpm/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def initialize(*argv)
#
def <=>(other)
RPM::Utils.check_type(other, RPM::Version)
ret = RPM::C.rpmvercmp(to_vre_epoch_zero, other.to_vre_epoch_zero)
RPM::C.rpmvercmp(to_vre_epoch_zero, other.to_vre_epoch_zero)
end

# @param [Version] other Version to compare against
Expand All @@ -110,15 +110,15 @@ def older?(other)
# @return [String]
# @note The epoch is not included
def to_vr
vr = @r.nil? ? @v.to_s : "#{@v}-#{@r}"
@r.nil? ? @v.to_s : "#{@v}-#{@r}"
end

# String representation in the form "e:v-r"
# @return [String]
# @note The epoch is included if present
def to_vre(_opts = {})
vr = to_vr
vre = @e.nil? ? vr : "#{@e}:#{vr}"
@e.nil? ? vr : "#{@e}:#{vr}"
end

# Alias for +to_vr+
Expand All @@ -140,7 +140,7 @@ def hash
# @note The epoch is included always. As 0 if not present
def to_vre_epoch_zero
vr = to_vr
vre = @e.nil? ? "0:#{vr}" : "#{@e}:#{vr}"
@e.nil? ? "0:#{vr}" : "#{@e}:#{vr}"
end
end
end
1 change: 1 addition & 0 deletions lib/rpm2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require_relative "./rpm"
Loading