Major overhaul for RPM packaging

First of all, the RPM packaging code hadn't been updated in quite a
while (it was still using the LKM), so this updates it to build with
darlingserver instead of the LKM.

Second, this update also adds a dependency generator that is used at
build time to automatically pick up the ELF dependencies in installed
Mach-Os. I prefer Debian's approach to this (simply having the option to
dynamically generate the requirements into a file at build time). This
seems like a convoluted approach (having to install a `fileattribute`
globally on the build machine), but at least it works.

Finally, this update also splits the package into multiple component
packages like the Debian packages. Note that `darling-cli-devenv` needs
to install files with the same names as those installed by
`darling-gui`, so it has to be built as a completely separate package. To
avoid having to rebuild a large portion of the project (about 8000
files), we simply generate a binary "source" tarball when building the
main Darling packages and then use this as the source for
`darling-cli-devenv`.
This commit is contained in:
Ariel Abreu 2023-05-02 19:24:02 -04:00 committed by Thomas A
parent 0d3e01769a
commit f1153d9b1a
12 changed files with 398 additions and 69 deletions

1
.gitignore vendored
View File

@ -38,6 +38,7 @@ build
rpm/SOURCES
rpm/RPMS
rpm/SRPMS
rpm/BUILD
debbuild
debian/changelog

View File

@ -1,4 +1,4 @@
ARG OS=fedora:31
ARG OS=fedora:37
FROM ${OS}
SHELL ["bash", "-euxvc"]
@ -9,15 +9,16 @@ RUN dnf install -y rpm-build dnf-utils rpmdevtools; \
dnf clean all
# Bootstrap
RUN dnf install -y bison cairo-devel clang cmake dkms flex fontconfig-devel.x86_64 \
RUN dnf install -y bison cairo-devel clang cmake flex fontconfig-devel.x86_64 \
fontconfig-devel.i686 freetype-devel.x86_64 freetype-devel.i686 \
fuse-devel glibc-devel glibc-devel.i686 kernel-devel \
fuse-devel glibc-devel glibc-devel.i686 \
libglvnd-devel libjpeg-turbo-devel libjpeg-turbo-devel.i686 \
libtiff-devel libtiff-devel.i686 mesa-libGL-devel mesa-libEGL-devel \
python2 systemd-devel make libxml2-devel elfutils-libelf-devel \
libbsd-devel ffmpeg-devel pulseaudio-libs-devel openssl-devel \
giflib-devel libXrandr-devel libXcursor-devel libxkbfile-devel \
dbus-devel mesa-libGLU-devel \
dbus-devel mesa-libGLU-devel vulkan-headers llvm-devel libcap-devel \
vulkan-loader-devel \
# git - so I can determine the describe of the last commit, not an rpm dependency
git; \
dnf clean all

View File

@ -1,10 +0,0 @@
PACKAGE_NAME=darling-mach
# PACKAGE_VERSION is rewritten by the darling.spec file, so this value is really a place holder
PACKAGE_VERSION=0.1
BUILT_MODULE_NAME="$PACKAGE_NAME"
BUILT_MODULE_LOCATION=lkm/
DEST_MODULE_LOCATION[0]=/extra
MAKE[0]="'make' -C lkm/ MIGDIR=/usr/src/${PACKAGE_NAME}-${PACKAGE_VERSION}/miggen MIGDIR_REL=../miggen KERNELVERSION=${kernelver}"
CLEAN="'make' -C lkm/ MIGDIR=/usr/src/${PACKAGE_NAME}-${PACKAGE_VERSION}/miggen MIGDIR_REL=../miggen clean"
REMAKE_INITRD=no
AUTOINSTALL=yes

View File

@ -0,0 +1,50 @@
# NOTE: this package MUST be built after building the main `darling` package
#disable binary striping, in case this is a problem
%global __os_install_post %{nil}
#Disable debug packages, since these are emulated files mostly
%define debug_package %{nil}
%define commit_date %{getenv:DARLING_COMMIT_DATE}
%if "%{commit_date}" == ""
%define commit_date 0
%endif
%global _buildshell /bin/bash
Name: darling-cli-devenv
Version: 0.1.%{commit_date}
Release: 1%{?dist}
Summary: Darling developer environment
Group: Utility
License: GPLv3
URL: https://www.darlinghq.org/
# Use this line for Source0 if there are ever official versions.
# Source0: https://github.com/darlinghq/darling/archive/%%{version}/%%{name}-%%{version}.tar.gz
Source0: %{name}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: bash
Requires: darling-cli darling-python darling-ruby darling-perl darling-cli-devenv-gui-common darling-cli-devenv-gui-stubs-common darling-iokitd-cli-devenv-gui-common
Conflicts: darling-gui darling-gui-stubs
%description
A Darling environment for CLI-only programs for building and developing using the command line developer tools
%prep
%setup -q -n %{name}
%build
true
%install
[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
cp -rla . %{?buildroot}/
%files
%{_libexecdir}/darling
%changelog
* Tue May 02 2023 Ariel Abreu <facekapow@outlook.com> - 0.1.20230502-1
- Initial version working for Fedora 37
- Split package off from `darling` package

View File

@ -0,0 +1,45 @@
%global __os_install_post %{nil}
%define debug_package %{nil}
%define commit_date %{getenv:DARLING_COMMIT_DATE}
%if "%{commit_date}" == ""
%define commit_date 0
%endif
%global _buildshell /bin/bash
Name: darling-macho-deps
Version: 0.1.%{commit_date}
Release: 1%{?dist}
Summary: Dependency generator for Mach-O files (used by Darling)
Group: Utility
License: GPLv3
URL: https://www.darlinghq.org/
# Use this line for Source0 if there are ever official versions.
# Source0: https://github.com/darlinghq/darling/archive/%%{version}/%%{name}-%%{version}.tar.gz
Source0: %{name}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: bash
%description
An RPM dependency generator for Mach-O files, used by Darling to generate ELF dependencies for the library it builds
%prep
%setup -q -n %{name}
%build
true
%install
[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
%{__mkdir_p} %{?buildroot}/usr/lib/rpm/fileattrs
cp darling.attr %{?buildroot}/usr/lib/rpm/fileattrs/
cp darling-deps.req %{?buildroot}/usr/lib/rpm/
%files
/usr/lib/rpm/fileattrs/darling.attr
/usr/lib/rpm/darling-deps.req
%changelog
* Tue May 02 2023 Ariel Abreu <facekapow@outlook.com> - 0.1.20230502-1
- Initial version working for Fedora 37

View File

@ -4,8 +4,15 @@
%define debug_package %{nil}
%define commit_date %{getenv:DARLING_COMMIT_DATE}
%if "%{commit_date}" == ""
%define commit_date 0
%define commit_date 0
%endif
%global _buildshell /bin/bash
# explicitly ignore all the bogus dependencies that the auto-scanner finds in `/usr/libexec/darling`
#
# note that we *don't* want to simply use `__requires_exclude_from` to exclude `/usr/libexec/darling` from scanning,
# since we *do* want our Mach-O scanner to scan that tree (and there's no way to only exclude paths for some dependency generators; it's all or nothing).
%global __requires_exclude ^(/bin/sed|/bin/sh|/usr/bin/perl|/usr/bin/python2.7|/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7|/usr/bin/python|/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby|/usr/bin/env|/usr/bin/ruby)$
Name: darling
Version: 0.1.%{commit_date}
@ -18,11 +25,10 @@ URL: https://www.darlinghq.org/
# Use this line for Source0 if there are ever official versions.
# Source0: https://github.com/darlinghq/darling/archive/%%{version}/%%{name}-%%{version}.tar.gz
Source0: %{name}.tar.gz
Source1: dkms.conf
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: cmake clang bison flex python2 glibc-devel(x86-64) glibc-devel(x86-32)
BuildRequires: fuse-devel systemd-devel kernel-devel dkms
BuildRequires: fuse-devel systemd-devel
BuildRequires: cairo-devel freetype-devel(x86-64) fontconfig-devel(x86-64)
BuildRequires: freetype-devel(x86-32) fontconfig-devel(x86-32) make
BuildRequires: libjpeg-turbo-devel(x86-64) libtiff-devel(x86-64)
@ -32,20 +38,172 @@ BuildRequires: libxml2-devel elfutils-libelf-devel
BuildRequires: libbsd-devel
BuildRequires: ffmpeg-devel pulseaudio-libs-devel openssl-devel giflib-devel
BuildRequires: libXrandr-devel libXcursor-devel libxkbfile-devel dbus-devel mesa-libGLU-devel
# Normally rpm will pick up all the mac pieces as dependencies. Disable that.
AutoReqProv: no
BuildRequires: vulkan-headers llvm-devel libcap-devel bash vulkan-loader-devel
Requires: darling-cli darling-python darling-ruby darling-perl darling-gui darling-gui-stubs darling-pyobjc
%description
Darling macOS emulator
macOS emulation layer for Linux
%package mach
Summary: Darling mach dkms module
Group: Utility
Requires: dkms make gcc kernel-devel
AutoReqProv: no
%package extra
Summary: Extra components for Darling
Group: Utility
Requires: darling darling-jsc darling-cli-extra
%description mach
Linux kernel module for darling-mach
%description extra
Extra components for Darling that are not part of a typical ("stock") installation
%package core
Summary: Darling core components
Group: Utility
Requires: xdg-user-dirs
%description core
Core components of Darling
%package system
Summary: Darling system components
Group: Utility
Requires: darling-core
%description system
System components of Darling
%package cli
Summary: Darling CLI components
Group: Utility
Requires: darling-system darling-cli-gui-common darling-cli-python-common
%description cli
CLI components of Darling
%package ffi
Summary: libffi for Darling
Group: Utility
Requires: darling-core
%description ffi
libffi built for use within Darling
%package cli-gui-common
Summary: Darling CLI and GUI common components
Group: Utility
Requires: darling-system
%description cli-gui-common
Components of Darling that are shared between the CLI and GUI components
%package iokitd
Summary: Darling IOKit daemon
Group: Utility
Requires: darling-system darling-iokitd-cli-devenv-gui-common
%description iokitd
IOKit daemon for Darling
%package cli-devenv-gui-common
Summary: Darling developer environment and GUI common components
Group: Utility
Requires: darling-system
%description cli-devenv-gui-common
Components of Darling that are shared between the developer environment and the GUI components
%package cli-extra
Summary: Extra Darling CLI components
Group: Utility
Requires: darling-cli
%description cli-extra
Non-standard CLI components of Darling
%package gui
Summary: Darling GUI components
Group: Utility
Requires: darling-system darling-cli-devenv-gui-common darling-iokitd darling-cli-gui-common darling-iokitd-cli-devenv-gui-common
%description gui
GUI components of Darling
%package python
Summary: Python for Darling
Group: Utility
Requires: darling-core darling-cli-python-common darling-ffi
%description python
Python (and associated programs) built for use within Darling
%package cli-python-common
Summary: Darling CLI and Python common components
Group: Utility
Requires: darling-core
%description cli-python-common
Components of Darling that are shared between the CLI and Python components
%package pyobjc
Summary: PyObjC for Darling
Group: Utility
Requires: darling-gui-stubs darling-python
%description pyobjc
PyObjC built for use within Darling
%package ruby
Summary: Ruby for Darling
Group: Utility
Requires: darling-core darling-ffi
%description ruby
Ruby built for use within Darling
%package perl
Summary: Perl for Darling
Group: Utility
Requires: darling-core
%description perl
Perl built for use within Darling
%package jsc-webkit-common
Summary: Darling JavaScriptCore and WebKit common components
Group: Utility
Requires: darling-system
%description jsc-webkit-common
Components of Darling that are shared between JavaScriptCore and WebKit
%package jsc
Summary: JavaScriptCore for Darling
Group: Utility
Requires: darling-system darling-jsc-webkit-common
%description jsc
JavaScriptCore built for use within Darling
%package iokitd-cli-devenv-gui-common
Summary: Darling IOKit daemon, developer environment, and GUI common components
Group: Utility
Requires: darling-system
%description iokitd-cli-devenv-gui-common
Components of Darling that are shared between the IOKit daemon, developer environment, and GUI components
%package cli-devenv-gui-stubs-common
Summary: Darling developer environment and GUI stubs common components
Group: Utility
Requires: darling-cli-devenv-gui-common
%description cli-devenv-gui-stubs-common
Components of Darling that are shared between the developer environment and GUI stub components
%package gui-stubs
Summary: Darling GUI stub components
Group: Utility
Requires: darling-gui darling-cli-devenv-gui-stubs-common
%description gui-stubs
GUI stub components of Darling
%prep
%setup -q -n %{name}
@ -53,53 +211,107 @@ Linux kernel module for darling-mach
%build
%{__mkdir_p} build
pushd build
# Release is broken https://github.com/darlinghq/darling/issues/331
# -DCMAKE_BUILD_TYPE=Release \
%{__cmake} -DCMAKE_INSTALL_PREFIX=/usr \
-DOpenGL_GL_PREFERENCE=GLVND \
..
%{make_build} -j `nproc`
# Release is broken https://github.com/darlinghq/darling/issues/331
# -DCMAKE_BUILD_TYPE=Release \
CFLAGS="" CXXFLAGS="" CPPFLAGS="" LDFLAGS="" \
%{__cmake} -DCMAKE_INSTALL_PREFIX=%{_prefix} \
-DOpenGL_GL_PREFERENCE=GLVND \
-DDEBIAN_PACKAGING=ON \
-DJSC_UNIFIED_BUILD=ON \
..
%{make_build} -j `nproc`
popd
%install
[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
DARLING_COMPONENTS=(
core
system
cli
ffi
cli_gui_common
iokitd
cli_dev_gui_common
cli_extra
gui
python
cli_python_common
pyobjc
ruby
perl
jsc_webkit_common
jsc
iokitd_cli_dev_gui_common
cli_dev_gui_stubs_common
gui_stubs
)
PACKAGE_SUFFIXES=(
core
system
cli
ffi
cli-gui-common
iokitd
cli-devenv-gui-common
cli-extra
gui
python
cli-python-common
pyobjc
ruby
perl
jsc-webkit-common
jsc
iokitd-cli-devenv-gui-common
cli-devenv-gui-stubs-common
gui-stubs
)
pushd build
%{make_install}
%{make_build} lkm_generate
for index in {0..18}; do
rm -rf tmp/${PACKAGE_SUFFIXES[index]}
DESTDIR=tmp/${PACKAGE_SUFFIXES[index]} %{__cmake} -DCOMPONENT=${DARLING_COMPONENTS[index]} -P cmake_install.cmake
find tmp/${PACKAGE_SUFFIXES[index]} \( ! -type d -o -type d -empty \) -printf '"/%%P"\n' > files.${PACKAGE_SUFFIXES[index]}.txt
cp -rla tmp/${PACKAGE_SUFFIXES[index]}/. %{?buildroot}/
done
# pack up a "source" (actually binary) tarball for `darling-cli-devenv`
# NOTE: this is probably not the best approach. fix this if something better comes up.
rm -rf tmp/cli-devenv
DESTDIR=tmp/cli-devenv %{__cmake} -DCOMPONENT=cli_dev -P cmake_install.cmake
rm -f %{_sourcedir}/darling-cli-devenv.tar.gz
tar --transform "s|^\./|darling-cli-devenv/|" -cf %{_sourcedir}/darling-cli-devenv.tar.gz -C tmp/cli-devenv .
popd
%{__install} -d -m 755 %{?buildroot}/usr/src/%{name}-mach-%{version}/miggen
cp -dr --no-preserve=ownership src/external/lkm %{?buildroot}/usr/src/%{name}-mach-%{version}/lkm
cp -dr --no-preserve=ownership build/src/external/lkm/osfmk %{?buildroot}/usr/src/%{name}-mach-%{version}/miggen/osfmk
# Copy rtsig.h
cp -dr --no-preserve=ownership build/src/startup/rtsig.h %{?buildroot}/usr/src/%{name}-mach-%{version}/lkm/darling/
sed 's|^PACKAGE_VERSION=.*|PACKAGE_VERSION=%{version}|' %{SOURCE1} > dkms.conf
%{__install} -m 644 dkms.conf %{?buildroot}/usr/src/%{name}-mach-%{version}
# https://github.com/dell/dkms/issues/25
%preun mach
/usr/sbin/dkms remove -m %{name}-mach -v %{version} --all --rpm_safe_upgrade || :
%pre mach
occurrences=$(/usr/sbin/dkms status "%{name}/%{version}" | wc -l)
if [ ! ${occurrences} -gt 0 ]; then
/usr/sbin/dkms remove -m %{name}-mach -v %{version} --all --rpm_safe_upgrade || :
fi
%post mach
/usr/sbin/dkms add -m %{name}-mach -v %{version} --rpm_safe_upgrade || :
/usr/sbin/dkms build -m %{name}-mach -v %{version} || :
/usr/sbin/dkms install -m %{name}-mach -v %{version} || :
%files
%doc LICENSE
%{_bindir}/darling
%{_libexecdir}/darling
%files mach
%{_prefix}/src/%{name}-mach-%{version}
%files extra
%files core -f build/files.core.txt
%files system -f build/files.system.txt
%files cli -f build/files.cli.txt
%files ffi -f build/files.ffi.txt
%files cli-gui-common -f build/files.cli-gui-common.txt
%files iokitd -f build/files.iokitd.txt
%files cli-devenv-gui-common -f build/files.cli-devenv-gui-common.txt
%files cli-extra -f build/files.cli-extra.txt
%files gui -f build/files.gui.txt
%files python -f build/files.python.txt
%files cli-python-common -f build/files.cli-python-common.txt
%files pyobjc -f build/files.pyobjc.txt
%files ruby -f build/files.ruby.txt
%files perl -f build/files.perl.txt
%files jsc-webkit-common -f build/files.jsc-webkit-common.txt
%files jsc -f build/files.jsc.txt
%files iokitd-cli-devenv-gui-common -f build/files.iokitd-cli-devenv-gui-common.txt
%files cli-devenv-gui-stubs-common -f build/files.cli-devenv-gui-stubs-common.txt
%files gui-stubs -f build/files.gui-stubs.txt
%changelog
* Tue May 02 2023 Ariel Abreu <facekapow@outlook.com> - 0.1.20230502-1
- Update to latest version and Fedora 37
- Split package into multiple packages (one for each component of Darling)
* Tue Aug 18 2020 Andy Neff <andy@visionsystemsinc.com> - 0.1.20200331-1
- Update for latest version and Fedora 31

24
rpm/build.bsh Normal file → Executable file
View File

@ -4,15 +4,29 @@ set -eu
yum-builddep -y /src/rpm/SPECS/darling.spec
if [ -e "/src/rpm/SOURCES/darling.tar.gz" ]; then
ln -s /src/rpm/SOURCES/darling.tar.gz /root/rpmbuild/SOURCES/
ln -sf /src/rpm/SOURCES/darling.tar.gz /root/rpmbuild/SOURCES/
else
# Preparing tarball
tar --transform "s|^\./|./darling/|" -cf /root/rpmbuild/SOURCES/darling.tar.gz -C /src --exclude=.git --exclude SOURCES --exclude SRPMS --exclude RPMS .
tar --transform "s|^\./|./darling/|" -cf /root/rpmbuild/SOURCES/darling.tar.gz -C /src --exclude=.git --exclude SOURCES --exclude SRPMS --exclude RPMS --exclude BUILD .
fi
ln -s /src/rpm/SOURCES/dkms.conf /root/rpmbuild/SOURCES/
DARLING_COMMIT_DATE="$(cd /src; git describe --tags HEAD)"
export DARLING_COMMIT_DATE="${DARLING_COMMIT_DATE//-/}"
if [ -e "/src/rpm/SOURCES/darling-macho-deps.tar.gz" ]; then
ln -sf /src/rpm/SOURCES/darling-macho-deps.tar.gz /root/rpmbuild/SOURCES/
else
tar --transform "s|^\./|darling-macho-deps/|" -cf /root/rpmbuild/SOURCES/darling-macho-deps.tar.gz -C /src/tools/rpm .
fi
if (cd /src && git describe --tags HEAD); then
DARLING_COMMIT_DATE="$(cd /src; git describe --tags HEAD)"
export DARLING_COMMIT_DATE="${DARLING_COMMIT_DATE//-/}"
else
# default to the current date
export DARLING_COMMIT_DATE="$(printf '%(%Y%m%d)T\n' -1)"
fi
rpmbuild -ba /src/rpm/SPECS/darling-macho-deps.spec
rpm -U --force /root/rpmbuild/RPMS/x86_64/darling-macho-deps*.rpm
#spectool -g -R /src/rpm/SPECS/darling.spec
rpmbuild -ba /src/rpm/SPECS/darling.spec
rpmbuild -ba /src/rpm/SPECS/darling-cli-devenv.spec

5
rpm/darling.repo Normal file
View File

@ -0,0 +1,5 @@
[darling]
name=Darling
baseurl=file:///data/git/darling-update/rpm/RPMS/x86_64
enabled=1
gpgcheck=0

View File

@ -5,7 +5,7 @@ services:
build:
context: .
args:
- OS=${RPM_OS-fedora:31}
- OS=${RPM_OS-fedora:37}
volumes:
- ..:/src:ro
- ./RPMS:/root/rpmbuild/RPMS

View File

@ -6,4 +6,8 @@ CWD="$(cd "$(dirname "${BASH_SOURCE[0]}")"; pwd)"
if [ -e "${CWD}/SOURCES/darling.tar.gz" ]; then
rm "${CWD}/SOURCES/darling.tar.gz"
fi
tar --transform "s|^\./|darling/|" -cf "${CWD}/SOURCES/darling.tar.gz" -C "${CWD}/.." --exclude=.git --exclude SOURCES --exclude SRPMS --exclude RPMS .
if [ -e "${CWD}/SOURCES/darling-macho-deps.tar.gz" ]; then
rm "${CWD}/SOURCES/darling-macho-deps.tar.gz"
fi
tar --transform "s|^\./|darling/|" -cf "${CWD}/SOURCES/darling.tar.gz" -C "${CWD}/.." --exclude=.git --exclude SOURCES --exclude SRPMS --exclude RPMS --exclude BUILD .
tar --transform "s|^\./|darling-macho-deps/|" -cf "${CWD}/SOURCES/darling-macho-deps.tar.gz" -C "${CWD}/../tools/rpm" .

5
tools/rpm/darling-deps.req Executable file
View File

@ -0,0 +1,5 @@
#!/usr/bin/sh
while read filename; do
"$1" "$filename"
done

2
tools/rpm/darling.attr Normal file
View File

@ -0,0 +1,2 @@
%__darling_magic ^Mach-O.*$
%__darling_requires %{_rpmconfigdir}/darling-deps.req %{_builddir}/darling/build/src/buildtools/elfdep