Skip to content

Commit

Permalink
Merge pull request #2064 from TwitchCaptain/main
Browse files Browse the repository at this point in the history
Create FreeBSD packages with correct architecture
  • Loading branch information
jordansissel authored Sep 12, 2024
2 parents fd06d93 + bf0aa55 commit d81a1ad
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 12 deletions.
6 changes: 6 additions & 0 deletions docs/cli-reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@ General Options
* ``--freebsd-origin ABI``
- (freebsd only) Sets the FreeBSD 'origin' pkg field

* ``--freebsd-osversion VERSION``
- (freebsd only) Sets the FreeBSD 'version' pkg field, ie. 12 or 13, use '*' for all.

* ``--gem-bin-path DIRECTORY``
- (gem only) The directory to install gem executables

Expand Down Expand Up @@ -766,6 +769,9 @@ freebsd
* ``--freebsd-origin ABI``
- Sets the FreeBSD 'origin' pkg field

* ``--freebsd-osversion VERSION``
- Sets the FreeBSD 'version' pkg field, ie. 12 or 13, use '*' for all.

gem
---

Expand Down
7 changes: 6 additions & 1 deletion docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,15 @@ when it lists the FPM gem:
If your system doesn't have `bsdtar` by default, make sure to install it or some
tests will fail:

apt-get install bsdtar
apt-get install bsdtar || apt install libarchive-tools

yum install bsdtar


You also need these tools:

apt-get install lintian cpanminus

Next, run make in root of the FPM repo. If there are any problems (such as
missing dependencies) you should receive an error

Expand Down
2 changes: 2 additions & 0 deletions docs/packages/cli/freebsd.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
* ``--freebsd-origin ABI``
- Sets the FreeBSD 'origin' pkg field
* ``--freebsd-osversion VERSION``
- Sets the FreeBSD 'version' pkg field, ie. 12 or 13, use '*' for all.

34 changes: 23 additions & 11 deletions lib/fpm/package/freebsd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ class FPM::Package::FreeBSD < FPM::Package
"Sets the FreeBSD 'origin' pkg field",
:default => "fpm/<name>"

option "--osversion", "VERSION",
"Sets the FreeBSD 'version' pkg field, ie 12 or 13, use '*' for all.",
:default => "13"

def output(output_path)
output_check(output_path)

Expand Down Expand Up @@ -90,28 +94,36 @@ def output(output_path)
end # def output

# Handle architecture naming conversion:
# <osname>:<osversion>:<arch>:<wordsize>[.other]
# <osname>:<osversion>:<arch>
def architecture
osname = %x{uname -s}.chomp
osversion = %x{uname -r}.chomp.split('.').first

# Essentially because no testing on other platforms
arch = 'x86'
osname = 'FreeBSD'

wordsize = case @architecture
arch = case @architecture
when nil, 'native'
%x{getconf LONG_BIT}.chomp # 'native' is current arch
when 'arm64'
'64'
'arm64'
when 'aarch64'
'arm64'
when 'amd64'
'64'
'amd64'
when 'x86_64'
'amd64'
when 'i386'
'32'
'i386'
when 'i686'
'i386'
when 'any'
'*'
when 'all'
'*'
when 'noarch'
'*'
else
%x{getconf LONG_BIT}.chomp # default to native, the current arch
end

return [osname, osversion, arch, wordsize].join(':')
return [osname, attributes[:freebsd_osversion], arch].join(':')
end

def add_path(tar, tar_path, path)
Expand Down

0 comments on commit d81a1ad

Please sign in to comment.