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

Add macOS support to OpenZFS #12110

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
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
  •  
  •  
  •  
54 changes: 54 additions & 0 deletions .github/workflows/macos-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Build on macOS
on: push

jobs:
build:
runs-on: macos-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
#- name: csrutil disable
# run: |
# sudo csrutil disable
#- name: csrutil enable
# run: |
# sudo csrutil enable --without kext
#- name: spctl kext-consent disable
# run: |
# sudo spctl kext-consent disable
- name: install deps
run: |
brew install automake libtool gawk coreutils
- name: install deps
run: |
#brew install openssl@3
- name: autogen
run: |
./autogen.sh
- name: configure
run: |
#https://stackoverflow.com/a/62591864
./configure CPPFLAGS="-I${HOMEBREW_PREFIX}/opt/gettext/include -I${HOMEBREW_PREFIX}/opt/openssl/include" LDFLAGS="-L${HOMEBREW_PREFIX}/opt/gettext/lib/ -L${HOMEBREW_PREFIX}/opt/openssl/lib"
- name: build
run: |
make -j $(($(sysctl -n hw.ncpu)+1))
#- name: install
# run: |
# sudo make install DESTDIR=///

#- name: load
# run: |
# sudo kextload -v /Library/Extensions/zfs.kext

#- name: ls
# run: |
# sudo ls -Rla
# ls -Rla
#- name: rsync
# run: |
# rsync -avx --exclude /out/ ${{github.workspace}}/ ${{github.workspace}}/out/ --no-links
#- name: Upload dev build
# uses: actions/[email protected]
# with:
# name: dev_build
# path: ${{github.workspace}}/out/*
9 changes: 8 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ if BUILD_LINUX
include $(srcdir)/%D%/rpm/Makefile.am
endif

if BUILD_MACOS
bin_PROGRAMS=
noinst_PROGRAMS=
include $(srcdir)/%D%/module/os/macos/Makefile.am
endif

if CONFIG_USER
include $(srcdir)/%D%/cmd/Makefile.am
include $(srcdir)/%D%/contrib/Makefile.am
Expand Down Expand Up @@ -194,11 +200,12 @@ cscopelist:
PHONY += tags
tags: ctags etags

PHONY += pkg pkg-dkms pkg-kmod pkg-utils
PHONY += pkg pkg-dkms pkg-kmod pkg-utils pkg-macos
pkg: @DEFAULT_PACKAGE@
pkg-dkms: @DEFAULT_PACKAGE@-dkms
pkg-kmod: @DEFAULT_PACKAGE@-kmod
pkg-utils: @DEFAULT_PACKAGE@-utils
pkg-macos: @DEFAULT_PACKAGE@-macos

include config/rpm.am
include config/deb.am
Expand Down
5 changes: 4 additions & 1 deletion cmd/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ SHELLCHECKSCRIPTS += %D%/zvol_wait
include $(srcdir)/%D%/zed/Makefile.am
endif

if BUILD_MACOS
include $(srcdir)/%D%/zed/Makefile.am
include $(srcdir)/%D%/os/Makefile.am
endif

if USING_PYTHON
bin_SCRIPTS += arc_summary arcstat dbufstat zilstat
Expand All @@ -111,6 +115,5 @@ arc_summary: %D%/arc_summary
$(AM_V_at)cp $< $@
endif


PHONY += cmd
cmd: $(bin_SCRIPTS) $(bin_PROGRAMS) $(sbin_SCRIPTS) $(sbin_PROGRAMS) $(dist_bin_SCRIPTS) $(zfsexec_PROGRAMS) $(mounthelper_PROGRAMS)
16 changes: 16 additions & 0 deletions cmd/arcstat.in
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,23 @@ elif sys.platform.startswith('linux'):

name, unused, value = s.split()
kstat[name] = int(value)
elif sys.platform.startswith('darwin'):
import subprocess

def kstat_update():
global kstat

process = subprocess.Popen(['sysctl', 'kstat.zfs.misc.arcstats'],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
kstats = process.communicate()[0].decode('ascii').splitlines()

kstat = {}
for l in kstats:
items = l.split(':')
name = items[0]
value = items[1].strip()
kstat[name[24:]] = int(value)

def detailed_usage():
sys.stderr.write("%s\n" % cmd)
Expand Down
2 changes: 2 additions & 0 deletions cmd/os/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

include $(srcdir)/%D%/macos/Makefile.am
3 changes: 3 additions & 0 deletions cmd/os/macos/InvariantDisks/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/DerivedData/
*.xcworkspace/
xcuserdata/
27 changes: 27 additions & 0 deletions cmd/os/macos/InvariantDisks/BSD.LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Copyright (c) 2014, Gerhard Röthlin
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name of the Project nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Loading