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

Create FreeBSD packages with correct architecture #2064

Merged
merged 1 commit into from
Sep 12, 2024
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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