Skip to content

Commit

Permalink
Upstream: Add macOS support
Browse files Browse the repository at this point in the history
Add source files to enable macOS support
Change autoconf/Makefiles to compile
Prepare zfs-tests for macOS but changes come later

Signed-off-by: Jorgen Lundman <lundman@lundman.net>
  • Loading branch information
lundman committed Feb 2, 2023
1 parent 973934b commit 0d6b74c
Show file tree
Hide file tree
Showing 472 changed files with 122,603 additions and 180 deletions.
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/usr/local/opt/gettext/include -I/usr/local/opt/openssl/include" LDFLAGS="-L/usr/local/opt/gettext/lib/ -L/usr/local/opt/openssl/lib"
- name: build
run: |
make -j 2
#- 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/upload-artifact@v3.1.0
# 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
12 changes: 12 additions & 0 deletions appveryor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 1.0.{build}
branches:
only:
- macos
image: macOS
build_script:
- sh: >-
pwd
ls -l
sh autoconf.sh
./configure CPPFLAGS="-I/usr/local/opt/gettext/include -I/usr/local/opt/openssl@1.1/include" LDFLAGS="-L/usr/local/opt/gettext/lib/ -L/usr/local/opt/openssl@1.1/lib"
make
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

0 comments on commit 0d6b74c

Please sign in to comment.