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

RPM Improvements #1445

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
34 changes: 27 additions & 7 deletions rpm/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,41 @@
ARG OS=fedora:37
FROM ${OS}

SHELL ["bash", "-euxvc"]
SHELL ["/bin/sh", "-euxvc"]

RUN dnf install -y rpm-build dnf-utils rpmdevtools git; \
source /etc/os-release; \
dnf install -y https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-${VERSION_ID}.noarch.rpm; \
RUN . /etc/os-release; \
if [ -e /etc/fedora-release ]; then \
dist=fedora; \
else \
dist=el; \
fi; \
dnf install -y --setopt=install_weak_deps=False --setopt=tsflags=nodocs \
dnf-plugins-core git-core rpm-build sudo \
"https://mirrors.rpmfusion.org/free/${dist}/rpmfusion-free-release-${VERSION_ID%%.*}.noarch.rpm"; \
dnf clean all

COPY SPECS/darling.spec /darling.spec

# Bootstrap
RUN yum-builddep -y /darling.spec; \
RUN . /etc/os-release; \
dnf_options='-y --setopt=install_weak_deps=False --setopt=tsflags=nodocs'; \
if [ -e /etc/fedora-release ]; then \
if [ "${VERSION_ID}" -le 38 ]; then \
dnf install ${dnf_options} python2; \
fi; \
else \
if [ "${VERSION_ID%%.*}" -ge 9 ]; then \
dnf_options="${dnf_options} --enablerepo=crb --enablerepo=devel"; \
else \
dnf install ${dnf_options} python2; \
dnf_options="${dnf_options} --enablerepo=powertools --enablerepo=devel"; \
fi; \
fi; \
dnf builddep ${dnf_options} /darling.spec; \
dnf clean all

RUN rm /darling.spec

RUN mkdir -p /root/rpmbuild/SOURCES
VOLUME /src /root/rpmbuild

CMD bash -xv /src/rpm/build.bsh
CMD /src/rpm/build.sh
17 changes: 11 additions & 6 deletions rpm/SPECS/darling-cli-devenv.spec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
%if "%{commit_date}" == ""
%define commit_date 0
%endif
%global _buildshell /bin/bash

Name: darling-cli-devenv
Version: 0.1.%{commit_date}
Expand All @@ -21,9 +20,6 @@ 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-python2 darling-ruby darling-perl darling-cli-devenv-gui-common darling-cli-devenv-gui-stubs-common darling-iosurface
Conflicts: darling-gui darling-gui-stubs
Expand All @@ -38,13 +34,22 @@ A Darling environment for CLI-only programs for building and developing using th
true

%install
[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
cp -rla . %{?buildroot}/
%if "%{?buildroot}" != "" && "%{?buildroot}" != "/"
%{__rm} -Rf "%{buildroot}"
%{__mkdir_p} "%{dirname:%{buildroot}}"
%endif

%{__cp} -PRp . %{?buildroot}/

%files
%{_libexecdir}/darling

%changelog
* Wed Oct 25 2023 Benjamin Gaillard <[email protected]> - 0.1.20231025-1
- Use default build root
- Use appropriate RPM macros
- Make regular copy instead of hard links to avoid filesystem issues

* Tue May 02 2023 Ariel Abreu <[email protected]> - 0.1.20230502-1
- Initial version working for Fedora 37
- Split package off from `darling` package
18 changes: 11 additions & 7 deletions rpm/SPECS/darling-macho-deps.spec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
%if "%{commit_date}" == ""
%define commit_date 0
%endif
%global _buildshell /bin/bash

Name: darling-macho-deps
Version: 0.1.%{commit_date}
Expand All @@ -17,9 +16,6 @@ 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
Expand All @@ -31,15 +27,23 @@ An RPM dependency generator for Mach-O files, used by Darling to generate ELF de
true

%install
[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
%if "%{?buildroot}" != "" && "%{?buildroot}" != "/"
%{__rm} -Rf "%{buildroot}"
%{__mkdir_p} "%{dirname:%{buildroot}}"
%endif

%{__mkdir_p} %{?buildroot}/usr/lib/rpm/fileattrs
cp darling.attr %{?buildroot}/usr/lib/rpm/fileattrs/
cp darling-deps.req %{?buildroot}/usr/lib/rpm/
%{__cp} -p darling.attr %{?buildroot}/usr/lib/rpm/fileattrs/
%{__cp} -p darling-deps.req %{?buildroot}/usr/lib/rpm/

%files
/usr/lib/rpm/fileattrs/darling.attr
/usr/lib/rpm/darling-deps.req

%changelog
* Wed Oct 25 2023 Benjamin Gaillard <[email protected]> - 0.1.20231025-1
- Use default build root
- Use appropriate RPM macros

* Tue May 02 2023 Ariel Abreu <[email protected]> - 0.1.20230502-1
- Initial version working for Fedora 37
150 changes: 76 additions & 74 deletions rpm/SPECS/darling.spec
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
%if "%{commit_date}" == ""
%define commit_date 0
%endif
%global _buildshell /bin/bash

# explicitly ignore all the bogus dependencies that the auto-scanner finds in `/usr/libexec/darling`
#
Expand All @@ -25,9 +24,8 @@ 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: cmake clang bison flex python2 glibc-devel(x86-64) glibc-devel(x86-32)
BuildRequires: cmake clang bison flex glibc-devel(x86-64) glibc-devel(x86-32)
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
Expand All @@ -38,7 +36,7 @@ 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
BuildRequires: vulkan-headers llvm-devel libcap-devel bash vulkan-loader-devel
BuildRequires: vulkan-headers llvm-devel libcap-devel vulkan-loader-devel

Requires: darling-cli darling-python2 darling-ruby darling-perl darling-gui darling-gui-stubs darling-pyobjc

Expand Down Expand Up @@ -210,84 +208,79 @@ GUI stub components of Darling

%build
%{__mkdir_p} build
pushd build
# 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
cd build
# Release is broken https://github.com/darlinghq/darling/issues/331
# -DCMAKE_BUILD_TYPE=Release \
unset CFLAGS CXXFLAGS CPPFLAGS LDFLAGS
%{__cmake} -DCMAKE_INSTALL_PREFIX=%{_prefix} \
-DOpenGL_GL_PREFERENCE=GLVND \
-DDEBIAN_PACKAGING=ON \
-DJSC_UNIFIED_BUILD=ON \
..
%{make_build}

%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
iosurface
cli_dev_gui_stubs_common
gui_stubs
)
PACKAGE_SUFFIXES=(
core
system
cli
ffi
cli-gui-common
iokitd
cli-devenv-gui-common
cli-extra
gui
python2
cli-python2-common
pyobjc
ruby
perl
jsc-webkit-common
jsc
iosurface
cli-devenv-gui-stubs-common
gui-stubs
)
pushd build
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
%if "%{?buildroot}" != "" && "%{?buildroot}" != "/"
%{__rm} -Rf "%{buildroot}"
%{__mkdir_p} "%{dirname:%{buildroot}}"
%endif

cd build

for component in \
core \
system \
cli \
ffi \
cli_gui_common \
iokitd \
cli_dev_gui_common:cli-devenv-gui-common \
cli_extra \
gui \
python:python2 \
cli_python_common:cli-python2-common \
pyobjc \
ruby \
perl \
jsc_webkit_common \
jsc \
iosurface \
cli_dev_gui_stubs_common:cli-devenv-gui-stubs-common \
gui_stubs
do
case "${component}" in
*:*) package="${component#*:}" component="${component%:*}" ;;
*) package="$(printf %s "${component}" | tr _ -)" ;;
esac
export DESTDIR="tmp/${package}"
%{__rm} -Rf "${DESTDIR}"
%{__cmake} -D COMPONENT="${component}" -P cmake_install.cmake
(
cd "${DESTDIR}"
echo "%attr(-, root, root)"
find * -type d -empty | LC_ALL=C sort | sed -e 's|^|%dir "/|' -e 's|$|"|'
find * ! -type d | LC_ALL=C sort | sed -e 's|^|"/|' -e 's|$|"|'
) >"files.${package}.txt"
%{__cp} -PRp "${DESTDIR}/." %{?buildroot}/
%{__rm} -Rf "${DESTDIR}"
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.
export DESTDIR=tmp/cli-devenv
%{__rm} -Rf "${DESTDIR}"
%{__cmake} -D COMPONENT=cli_dev -P cmake_install.cmake
%{__tar} --transform "s|^\.|darling-cli-devenv|S" -caf %{_sourcedir}/darling-cli-devenv.tar.gz -C "${DESTDIR}" .
%{__rm} -Rf "${DESTDIR}"

%files
%doc LICENSE

%files extra

%files core -f build/files.core.txt
%attr(-, root, root)
%license LICENSE

%files system -f build/files.system.txt
%files cli -f build/files.cli.txt
%files ffi -f build/files.ffi.txt
Expand All @@ -308,6 +301,15 @@ popd
%files gui-stubs -f build/files.gui-stubs.txt

%changelog
* Wed Oct 25 2023 Benjamin Gaillard <[email protected]> - 0.1.20231025-1
- Use default build root
- Honor tar compression according to file extension
- Move license file to the core package
- Use appropriate RPM macros
- Make regular copy instead of hard links to avoid filesystem issues
- Use standard POSIX shell and utilities instead of Bash
- Remove Python 2 build dependency

* Tue May 02 2023 Ariel Abreu <[email protected]> - 0.1.20230502-1
- Update to latest version and Fedora 37
- Split package into multiple packages (one for each component of Darling)
Expand Down
33 changes: 0 additions & 33 deletions rpm/build.bsh

This file was deleted.

32 changes: 32 additions & 0 deletions rpm/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/sh

set -euxv

mkdir -p ~/rpmbuild/SOURCES

if [ -e /src/rpm/SOURCES/darling.tar.gz ]; then
ln -sf /src/rpm/SOURCES/darling.tar.gz ~/rpmbuild/SOURCES/
else
# Preparing tarball
tar --transform "s|^\.|darling|S" -caf ~/rpmbuild/SOURCES/darling.tar.gz -C /src --exclude .git --exclude SOURCES --exclude=SRPMS --exclude RPMS --exclude BUILD .
fi

if [ -e /src/rpm/SOURCES/darling-macho-deps.tar.gz ]; then
ln -sf /src/rpm/SOURCES/darling-macho-deps.tar.gz ~/rpmbuild/SOURCES/
else
tar --transform "s|^\.|darling-macho-deps|S" -caf ~/rpmbuild/SOURCES/darling-macho-deps.tar.gz -C /src/tools/rpm .
fi

if DARLING_COMMIT_DATE="$(git -C /src log -1 --pretty=format:%cs HEAD)"; then
export DARLING_COMMIT_DATE="$(echo "${DARLING_COMMIT_DATE}" | tr -d -)"
else
# default to the current date
export DARLING_COMMIT_DATE="$(date +%Y%m%d)"
fi

rpmbuild -bb /src/rpm/SPECS/darling-macho-deps.spec
sudo rpm -U --force ~/rpmbuild/RPMS/$(uname -m)/darling-macho-deps*.rpm

#spectool -g -R /src/rpm/SPECS/darling.spec
rpmbuild -bb /src/rpm/SPECS/darling.spec
rpmbuild -bb /src/rpm/SPECS/darling-cli-devenv.spec
Loading