Commit Graph

2272 Commits

Author SHA1 Message Date
Jordan Sissel ac0ecdd101 Move `require` closer to where it is used.
This helps avoid a startup crash on Ruby 1.9.3 where the `rexml` gem
crashes when loaded due to syntax errors.

Fixes #1798, #1800, #1784
2022-11-02 21:47:47 -07:00
Jordan Sissel afc7c6f434 Call String#dup on RUBY_VERSION to avoid crashing on older ruby versions
On older versions of rubygems, `Gem::Version.new(...)` calls
`String#strip!` on the argument in the constructor. This causes a
problem on Ruby 1.9.3 where the RUBY_VERSION constant is a frozen
string.

The workaround is to make a copy of this string that is unfrozen, and
`String#dup` seems to work :)
2022-11-02 21:47:47 -07:00
Jordan Sissel 0a07c00639 Remove 'json' gem dependency.
The original `json` gem dependency was added in the original fpm.gemspec
because, at the time, Ruby 1.8.7 was common and required an external
`json` dependency for parsing JSON.

Later, Ruby releases since 1.9.1 have bundled `json`[1].

Therefore, it feels safe to remove this dependency. As a bonus, the
rubygems `json` gem places requirements on the minimum version of Ruby.
At this time, the latest `json` gem requires Ruby >= 2.3.

If the `json` gem dependency is removed, fpm will still retain the
ability to process JSON while lowering the minimum required Ruby version
to Ruby 1.9.x -- It's not perfect, but it's a start! :)

[1] https://docs.ruby-lang.org/en/2.3.0/NEWS-1_9_1.html

The idea for this change change came originally from a discussion
with @edolnx in #1949

Fixes #1741, #1264, #1949
2022-11-02 21:47:47 -07:00
Nicholas Hubbard 56a97c43be Fixed typo: stdin_w_close -> stdin_w.close 2022-10-31 15:17:48 -07:00
Jordan Sissel cd7a6855d3 Try to improve the flag description 2022-10-28 23:11:25 -07:00
Jordan Sissel c6b85be6a2 Improve tests and raise exception when the flags file is too large. 2022-10-28 23:11:25 -07:00
Jordan Sissel ce8fd6cb64 Remove debug print 2022-10-28 23:11:25 -07:00
Jordan Sissel 16c7e280a7 Support single-character flags in option files. 2022-10-28 23:11:25 -07:00
Jordan Sissel 7d6b5cd58c Add test coverage for --fpm-options-file
Cases:
* Option ordering (the flag operates in-place)
* Multiple --long-flags on a single line
* Multiple single flags on a single line (both like '-ff' and '-f -f')
* File self-reference errors
2022-10-28 23:11:25 -07:00
Jordan Sissel ec82bc649b Add option --fpm-options-file
This option flag will cause fpm to load additional flags, in place, from
the given file.

For example, if a file "foo" contains one line, "--version 5.10", then
`fpm -s empty -t deb -n example --fpm-options-file foo` act as if
`--version 5.10` was given on the command-line in the same position as
the `--fpm-options-file` flag.

Error conditions checked:
* Has the file already been loaded?
* Does the file exist?
* Is the file readable?

No tests included at this time. This code is likely missing some edge
cases (combined single-letter flags, multiple flag entries on a line,
etc).
2022-10-28 23:11:25 -07:00
Nicholas Hubbard 110419b695 Test unpack method directly 2022-10-28 16:06:34 -07:00
Nicholas Hubbard 11175cc47f Add test for building Alien::astyle version 0.010000 2022-10-28 16:06:34 -07:00
Nicholas Hubbard c8d364b0ab Fix broken tar command 2022-10-28 16:06:34 -07:00
Jordan Sissel 3fcaefb9fd Remove `git` gem dependency.
Folks are reporting that fpm cannot be installed easily (or at all) on
older systems because a transitive dependency(1) rejects ruby versions
older than 2.6.

(1) rubygem git depends on addressable which depends on public_suffix

Since the `git` dependency is only used in the `gem` source when
using a git repo as a installation source, and that usage seems pretty
simple -- clone a repo, checkout a branch, etc -- it feels safe to
remove this dependency while still keeping the same functionality.

Fixes #1923
2022-10-26 14:48:12 -07:00
Jordan Sissel d16b531a2f Trying GitHub Actions for testing
Attempting to figure out why rspec passes but the action still fails.
2022-10-24 20:38:08 -07:00
Jordan Sissel 6c87589f32
Update ruby.yml 2022-10-24 19:07:08 -07:00
Jordan Sissel 72b2f26ad3
Create ruby.yml 2022-10-24 19:04:51 -07:00
Nicholas Hubbard bfb192c417 Add test for CPAN dist with missing author 2022-10-21 17:23:36 -07:00
Jordan Sissel f168571abf Support newer version of lintian in the test suite.
Fixes #1907
2022-10-16 17:44:17 -07:00
Nicholas Hubbard 409a3b27df Prevent crash if CPAN distribution has blank author field 2022-10-16 16:23:07 -07:00
loic.chabert 788387c0d2 Add space on changes.erb to conform with debian specs 2022-10-03 13:34:22 -07:00
loic.chabert 37f56269c3 Replace whatever in changelog.erb and deb.changes.erb
In order to support packaging upload, the distribution must be
set/aligned in changelog and changes files.
Required for example inside dput-ng repo upload app.
2022-10-03 13:34:22 -07:00
Evgeny Stambulchik c40f6818f8 Recognize "--pleaserun-user" option 2022-07-05 16:26:24 -07:00
Chris Novakovic 9b32d9a116 Change default Debian package priority to optional
Since Debian Policy version 4.0.1, the "extra" priority has been
deprecated and replaced with "optional"; this triggers Lintian warnings
for Debian packages built by FPM. Make this the new default for Debian
package outputs when no value of --deb-priority is given.

Fixes #1398.
2022-06-24 13:49:32 -07:00
Jordan Sissel 40795d4d85 Load gem specifications using YAML's safe loading
On older rubies, YAML.load _is_ the unsafe load method. At some point,
Ruby 3.1.0 / Psych 4(?) made two renames:

* YAML.load -> YAML.unsafe_load
* YAML.safe_load -> YAML.load

A quick test is to try converting a gem. This would fail if `YAML.load`
was the "safe" method because it would fail with this message:

    Tried to load unspecified class: Gem::Specification (Psych::DisallowedClass

`fpm -s gem -t empty rails` will crash on Ruby 3.1.0 prior to this
commit.

Fixes #1895

Add necessary classes to safely load yaml from gem specs
2022-05-19 20:19:44 -07:00
Jordan Sissel 7881705985 Call ERB.new correctly depending on the RUBY_VERSION
* On Ruby 3.0.x and older, call ERB.new(template_code, nil, "-")
* On Ruby 3.1.0 and newer, call ERB.new(template_code, trim_mode: "-")

Fixes #1894
2022-05-01 22:39:04 -07:00
Jordan Sissel 5d2b4854d3 Fix failing test.
Looks like at some point django changed the admin tool from
"django-admin" to "django-admin.py"

Possibly this changed in upstream in Django on this commit, though I
don't know for certain:
85efc14a2e
2022-05-01 21:53:54 -07:00
Jordan Sissel 7f4718f9c2 Run `pip` without the `--build` flag
Previously, fpm would use `pip download ... --build ...` to instruct pip
to unpack a given python package to a specific directory for the purpose
of running something like `python setup.py` from it.

However, somewhere in 2021, pip removed this flag. First, I think, it
was deprecated and ignored, then finally removed. One reference to
this removal in the upstream pip project is this issue:
https://github.com/pypa/pip/issues/8333

Without `--build`, pip will place a single tarball in the destination
directory. Fpm cannot easily predict the name of this file because we
don't know the "real" name of the python package nor do we know the
version number being downloaded.

For example:

```
% python3 -m pip download --no-binary :all: --no-deps --no-clean django
...
Successfully downloaded django
% ls
Django-4.0.4.tar.gz
```

Best guess:
* we can expect exactly one file in the previously-empty target directory
* we can also expect that it is a .tar.gz

I don't know if these guesses are always correct, but it's a start.

As of this commit, the following command generates a Debian package:

`fpm -s python --python-bin python3 -t deb django`

Prior to this commit, with a newer version of pip, the command would
fail.

Fixes #1831
2022-05-01 21:53:54 -07:00
Jordan Sissel 82284c7a4b Rerun `make release-prep` 2022-03-31 00:15:23 -07:00
Jordan Sissel 60b4bd30b3 Add additional changelog entries 2022-03-31 00:09:25 -07:00
Jordan Sissel 377fcaf871 Add note about new documentation pages 2022-03-31 00:09:25 -07:00
Jordan Sissel 2943d82581 Version bump and update changelog 2022-03-31 00:09:25 -07:00
mszprejda f5d07520b7 pacman.rb: Fix typo in compression type matching 2022-03-30 23:52:51 -07:00
Jordan Sissel 0dfe21bab7 Add test case for files with spaces and quotatation marks.
Testing, this new test case fails on v1.14.1 and *succeeds* as expected
after #1882 was merged.

Fixes #1886
2022-03-30 23:50:55 -07:00
John Bollinger b2ba5c4a59 Fix filename mangling for RPM targets
Fixes the mangling FPM performs on the contents of RPM %files lists
to better match RPM's idiosyncratic filename handling.  FPM now
recognizes more cases that require special handling, and it
correctly distinguishes between the glob and non-glob cases,
which RPM itself treates differently.

Fixes #1385
2022-03-30 23:47:02 -07:00
Jordan Sissel 521d030420 Fix reStructuredText header length syntax 2022-03-30 23:15:59 -07:00
Jordan Sissel 106828fc12 Add description in header 2022-03-30 23:15:59 -07:00
Jordan Sissel 0c84173de0 Add description in header 2022-03-30 23:15:59 -07:00
Jordan Sissel 9b9a1b365f Add very basic package docs for each type of package.
Thanks to @alanc and _msw_ for quickly helping me figure out good words
to write to describe Solaris' p5p format.

For #1884.
2022-03-30 23:15:59 -07:00
John Howard eb5370d16e Fix `--deb-compression none`
Previously, we would pass the literal `""` as an argument to `tar`.
`tar` would interpret this as a file name, which does not exist, and
fail.

This fixes the command to just pass no compression flag at all to tar
when `--deb-compression none` is set.

I did not add tests since I couldn't figure out how to execute them -
this is my first time working in ruby.
2022-03-21 15:20:08 -07:00
Jordan Sissel 92886d922d Restore development_dependency on `rake`
A prior commit removed `rake` as a development dependency on the
assumption that nothing in fpm's development process actually required
the use of `rake`.

However, I had forgotten about #756 (year 2014) which adds FPM::RakeTask
and some test coverage. FPM::RakeTask was added to allow folks to more
easily invoke FPM from within a Rake task.

At this time, I see no reason to remove FPM::RakeTask. Further, because
`rake` is typically (in my experience) used only in development
environments. Therefore, I believe the right solution is to restore
`rake` as a development_dependency in order to allow the test suite to
pass. For users of FPM::RakeTask, I would assume (hopefully correctly!)
that they already have `rake` installed as a dependency in their own
project, so the `fpm` gem has no need to specify `rake` as a general-use
dependency.

When studying newer versions of Rake, I found:
* Rake v13 requires Ruby 2.2 or newer.
* Rake v12.xx and older are flagged as having security vulnerabilities.

In order to minimize chaos, this commit adds an unversioned dependency
on rake. This is to help fpm service more versions of Ruby and resist
efforts by any dependency to dictate which version of Ruby is used.

This reverts db9db670c3.

Fixes #1877
2022-02-23 18:04:51 -08:00
Corey Quinn 9aa1c1cb64 Update README to modernize the given example. 2022-02-07 15:26:36 -08:00
Geoff Beier 7a1302d1e8 fix typo in "perl" 2022-01-26 12:22:04 -08:00
Jordan Sissel 53f669219c Version bump 2021-11-10 15:01:34 -08:00
Jordan Sissel 20e754adfb Update changelog after #1854 was fixed. 2021-11-10 15:01:04 -08:00
Jordan Sissel d819e59a80 Require fpm/package/dir to make FPM::Package::Dir available (for #1854) 2021-11-10 14:58:50 -08:00
Jordan Sissel 021fc45047 Add requires so that other package types are available
When converting, we check if the original package was of a certain type.
In order for those types/constants to be available, we have to require
those files.

Test cases which now work correctly with this commit, but had failed
prior:

    % bundle exec ruby -r./lib/fpm/package/rpm.rb -e 'FPM::Package::RPM.new.tap { |x| x.name = "fancy" }.convert(FPM::Package::RPM)'
    % bundle exec ruby -r./lib/fpm/package/deb.rb -e 'FPM::Package::Deb.new.tap { |x| x.name = "fancy" }.convert(FPM::Package::Deb)'

Fixes #1854
2021-11-10 14:58:50 -08:00
Jordan Sissel 121989e0a0 Version bump 2021-11-09 22:30:01 -08:00
Jordan Sissel bba3114075 Regenerate in prep for release 2021-11-09 22:29:16 -08:00
Jordan Sissel 329b4758a6 Also regen per-package-type cli pages 2021-11-09 22:29:06 -08:00