Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
12 changes: 0 additions & 12 deletions .github/FUNDING.yml

This file was deleted.

31 changes: 0 additions & 31 deletions .github/workflows/ci.yml

This file was deleted.

49 changes: 49 additions & 0 deletions .github/workflows/rake.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: rake

on:
push:
branches: [ master, main ]
tags: [ v* ]
pull_request:

permissions:
contents: write

jobs:
rake-alpine:
name: Test on Ruby ${{ matrix.ruby.version }} ${{ matrix.os }}-${{ matrix.env.CC }}
runs-on: ubuntu-latest
env: ${{ matrix.env }}
container:
image: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- alpine:3.18
- alpine:3.16
env:
- CC: gcc
CXX: g++
- CC: clang
CXX: clang++

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Ruby
run: |
apk --no-cache --upgrade add build-base cmake git bash \
autoconf make binutils-dev pkgconfig tar ruby-dev clang

- name: Install Bundler
run: |
gem install bundler
bundle install

- run: bundle exec rake

rake:
needs: rake-alpine
uses: fontist/support/.github/workflows/rake.yml@main
21 changes: 21 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: release

on:
workflow_dispatch:
inputs:
next_version:
description: |
Next release version. Possible values: x.y.z, major, minor, patch (or pre|rc|etc).
Also, you can pass 'skip' to skip 'git tag' and do 'gem push' for the current version
required: true
default: 'skip'
repository_dispatch:
types: [ do-release ]

jobs:
release:
uses: fontist/support/.github/workflows/release.yml@main
with:
next_version: ${{ github.event.inputs.next_version }}
secrets:
rubygems-api-key: ${{ secrets.FONTIST_CI_RUBYGEMS_API_KEY }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ InstalledFiles
_yardoc
coverage
doc/
pkg/
lib/bundler/man
rdoc
spec/reports
Expand All @@ -24,3 +25,4 @@ ext/seven_zip_ruby/Makefile
ext/seven_zip_ruby/*.def
ext/seven_zip_ruby/*.pdb
ext/p7zip/makefile.machine
.vscode
35 changes: 0 additions & 35 deletions .travis.yml

This file was deleted.

25 changes: 3 additions & 22 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
Copyright (c) 2013 Masamitsu MURASE
Copyright (c) 2022, Ribose Inc.

SevenZipRuby

The GNU LGPL + unRAR restriction means that you must follow both
GNU LGPL rules and unRAR restriction rules.
seven-zip

GNU LGPL information
--------------------
Expand All @@ -18,22 +16,5 @@ SevenZipRuby
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You can receive a copy of the GNU Lesser General Public License from
You can receive a copy of the GNU Lesser General Public License from
http://www.gnu.org/


unRAR restriction
-----------------

The decompression engine for RAR archives was developed using source
code of unRAR program.
All copyrights to original unRAR code are owned by Alexander Roshal.

The license for original unRAR code has the following restriction:

The unRAR sources cannot be used to re-create the RAR compression algorithm,
which is proprietary. Distribution of modified unRAR sources in separate form
or as a part of other software is permitted, provided that it is clearly
stated in the documentation and source comments that the code may
not be used to develop a RAR (WinRAR) compatible archiver.

53 changes: 31 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# SevenZipRuby ![Logo](https://raw.github.com/masamitsu-murase/seven_zip_ruby/master/resources/seven_zip_ruby_logo.png)
# SevenZipRuby ![Logo](https://raw.github.com/fontist/seven_zip_ruby/master/resources/seven_zip_ruby_logo.png)

![Rspec](https://github.com/masamitsu-murase/seven_zip_ruby/workflows/Rspec/badge.svg) [![Gem Version](https://badge.fury.io/rb/seven_zip_ruby.png)](http://badge.fury.io/rb/seven_zip_ruby)
![RSpec](https://github.com/fontist/seven_zip_ruby/workflows/test-and-release/badge.svg) [![Gem Version](https://badge.fury.io/rb/seven-zip.png)](http://badge.fury.io/rb/seven-zip)

This is a Ruby gem library to extract/compress [7-Zip](http://www.7-zip.org) archives.

This extension calls the native library, 7z.dll or 7z.so, internally and these libraries are included in this gem.

## Features
* Uses official DLL, 7z.dll, internally.
* Uses official shared library, 7z.dll or 7z.so, internally.
* Supports extracting data into memory.

## Document
[RDoc](http://rubydoc.info/gems/seven_zip_ruby/frames) shows you the details.
[RDoc](http://rubydoc.info/gems/seven-zip/frames) shows you the details.

## Examples

Expand Down Expand Up @@ -61,7 +61,7 @@ File.open("filename.7z", "rb") do |file|
SevenZipRuby::Reader.extract_all(file, "path_to_dir", { password: "Password String" })
end
```

If the password is invalid or missing no data will be returned for encrypted archive entries.

### Verify archives

Expand Down Expand Up @@ -99,8 +99,7 @@ SevenZipRuby supports the following platforms.

SevenZipRuby supports the following Ruby engines on each platform.

* MRI 2.0.0 and later
* Rubinius 2.2.1 and later
* MRI 2.5.0 and later

## More examples

Expand Down Expand Up @@ -161,7 +160,7 @@ end

### Set compression mode

7zip supports LZMA, LZMA2, PPMD, BZIP2, DEFLATE and COPY.
7zip supports LZMA, LZMA2, PPMD, BZIP2, DEFLATE and COPY.

```ruby
# random data
Expand All @@ -188,23 +187,33 @@ p(Time.now - start)
# => 3.607563 # Faster than single-threaded compression.
```


## TODO

* Support file attributes on Linux and Mac OSX.
* Support update of an archive.
* Support extract of a rar archive.


## License
LGPL and unRAR license. Please refer to LICENSE.txt.
LGPL license. Please refer to LICENSE.txt.

## Releases

* 1.2.*
> The last version published at rubygems.org is 1.4.2
> Should you need the latest version please install it from this repo
* 1.6.2
- GCC 12 compatibility fix
- Tests for Ruby 3.2
- Test on Alpine Linux
* 1.6.1
- [https://github.com/niloufar] 7z update to 19.00, p7zip update to 16.02
* 1.5.0
- [https://github.com/niloufar] Secure loading of libraries to prevent DLL preloading attacks
https://support.microsoft.com/en-us/help/2389418/secure-loading-of-libraries-to-prevent-dll-preloading-attacks
* 1.4.2
- CI improvement, cleanup of debug output
* 1.4.1
- Fixed minor rubygems.org issues
* 1.4.0
- seven-zip gem forked from seven_zip_ruby
- Fixed C++17 compatibility (https://github.com/masamitsu-murase/seven_zip_ruby/issues/36).
- 7z.so (p7zip module) converted to Ruby extension in order to facilitate Ruby 3.0 compatiblity.
* 1.3.0
* 1.2.*
- Fixed cosmetic bugs.
* 1.1.0
* 1.1.0
- Fixed a bug. Raises an exception when wrong password is specified.
* 1.0.0
* 1.0.0
- Initial release.

52 changes: 33 additions & 19 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@ require "fileutils"
require "tempfile"
require "bundler/gem_tasks"

BINARY_FILES = [ "seven_zip_archive.so", "seven_zip_archive.bundle" ]
begin
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
rescue LoadError
end

BINARY_FILES = [ "seven_zip_ruby/seven_zip_archive.so", "p7zip/bin/7z.so", "seven_zip_ruby/seven_zip_archive.bundle" ]
EXTENSIONS = [ "seven_zip_ruby", "p7zip" ]
MAKE = (ENV["MAKE"] || ENV["make"] || (RUBY_PLATFORM.include?("mswin") ? "nmake" : "make"))

task :build_platform => [ :pre_platform, :build, :post_platform ]
Expand All @@ -25,43 +32,50 @@ task :post_platform do
end


task :build_local_all => [ :build_local_clean, :build_local ]
task :build_local_all => [ :clean_local, :build_local ]
task :build_local => [ :build_binary, :copy_binary ]

task :build_local_clean do
Dir.chdir "ext/seven_zip_ruby" do
sh("#{MAKE} clean") if (File.exist?("Makefile"))
task :clean_local do
EXTENSIONS.each do |ext|
Dir.chdir "ext/#{ext}" do
sh("#{MAKE} clean") if (File.exist?("Makefile"))
end
end

[ "ext/seven_zip_ruby", "lib/seven_zip_ruby" ].each do |dir|
FileUtils.rmtree(BINARY_FILES.map{ |i| "#{dir}/#{i}" })
end
FileUtils.rm_f(BINARY_FILES.map{ |i| "ext/#{i}" })
end

task :build_binary do
Dir.chdir "ext/seven_zip_ruby" do
FileUtils.rmtree BINARY_FILES
FileUtils.cp "ext/p7zip/makefile","ext/p7zip/makefile.old"
EXTENSIONS.each do |ext|
Dir.chdir "ext/#{ext}" do
FileUtils.rm_f(BINARY_FILES.map{ |i| "ext/#{i}" })

Tempfile.open([ "site", ".rb" ], Dir.pwd) do |temp|
temp.puts <<"EOS"
Tempfile.open([ "site", ".rb" ], Dir.pwd) do |temp|
temp.puts <<"EOS"
require('rbconfig')
RbConfig::CONFIG['sitearchdir'] = "../../lib"
EOS
temp.flush
temp.flush

sh "ruby -r#{File.expand_path(temp.path)} extconf.rb"
temp.unlink
sh "ruby -r#{File.expand_path(temp.path)} extconf.rb"
temp.unlink
end
sh "#{MAKE}"
end

sh "#{MAKE}"
end
FileUtils.rm_f "ext/p7zip/Makefile"
FileUtils.mv "ext/p7zip/makefile.old","ext/p7zip/makefile"
end

task :copy_binary do
BINARY_FILES.each do |file|
src = File.join("ext", "seven_zip_ruby", file)
dest = File.join("lib", "seven_zip_ruby", file)
dest = File.join("lib", "seven_zip_ruby", File.basename(file))
FileUtils.rmtree(dest) if (File.exist?(dest))

src = File.join("ext", file)
FileUtils.cp(src, dest) if (File.exist?(src))
end
end

task default: %i[build_local spec]
Loading