···11-# Building RPMs
22-33-1. Install `docker` and `docker-compose`
44-2. `cd rpm`
55-3. Build the docker image: `docker-compose build rpm`
66-3. Build the rpms: `docker-compose run rpm` (Can take over half an hour)
77-4. Now you can run `dnf install RPMS/x84_64/darling*.rpm`
88-5. `setsebool -P mmap_low_allowed 1` to allow darling low level access and run
99-1010-## Building on other operating systems
1111-1212-By default, it will build for Fedora 29. To use a different OS, simply
1313-1414- RPM_OS=fedora:27 docker-compose build rpm
1515-1616-## Future improvements
1717-1818-- Everything is based off of dnf. Supporting zypper and yum will reach others
1919-- Because of the way the submodules are handled, this isn't quite ready for official releasing but this can be solved using [%autosetup in the %prep to checkout the submodules.](https://fedoraproject.org/wiki/Packaging:SourceURL#Git_Submodules)
···11+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
22+/*
33+ * Copyright (C) 2012 ARM Ltd.
44+ *
55+ * This program is free software; you can redistribute it and/or modify
66+ * it under the terms of the GNU General Public License version 2 as
77+ * published by the Free Software Foundation.
88+ *
99+ * This program is distributed in the hope that it will be useful,
1010+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1111+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212+ * GNU General Public License for more details.
1313+ *
1414+ * You should have received a copy of the GNU General Public License
1515+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1616+ */
1717+1818+#define __ARCH_WANT_RENAMEAT
1919+#define __ARCH_WANT_NEW_STAT
2020+#define __ARCH_WANT_SET_GET_RLIMIT
2121+#define __ARCH_WANT_TIME32_SYSCALLS
2222+#define __ARCH_WANT_SYS_CLONE3
2323+2424+// #include <asm-generic/unistd.h>
2525+#include "linux-generic.h"
···11-#ifndef _ASM_X86_UNISTD_H
22-#define _ASM_X86_UNISTD_H
11+#ifndef _ASM_GENERAL_UNISTD_H
22+#define _ASM_GENERAL_UNISTD_H
3344# ifdef __i386__
55-# include "linux-x86.h"
55+// # include <asm/unistd_32.h>
66+ # include "linux-x86.h"
67# elif defined(__x86_64__)
77-# include "linux-x86_64.h"
88+// # include <asm/unistd_64.h>
99+ # include "linux-x86_64.h"
1010+# elif defined(__arm64__)
1111+// # include <asm/unistd.h>
1212+ # include "linux-arm64.h"
813# else
99-# error Missing Linux sc numbers for this arch
1414+// look in <asm/unistd.h> if you are unsure
1515+ # error Missing Linux sc numbers for this arch
1016# endif
11171212-#endif /* _ASM_X86_UNISTD_H */
1818+#endif /* _ASM_GENERAL_UNISTD_H */
···1818 if (ret < 0)
1919 return errno_linux_to_bsd(ret);
20202121- ret = LINUX_SYSCALL(__NR_chmod, vc.path, mode);
2121+ #if defined(__NR_chmod)
2222+ ret = LINUX_SYSCALL(__NR_chmod, vc.path, mode);
2323+ #else
2424+ ret = LINUX_SYSCALL(__NR_fchmodat, LINUX_AT_FDCWD, vc.path, mode, 0);
2525+ #endif
2226 if (ret < 0)
2327 return errno_linux_to_bsd(ret);
24282525- ret = LINUX_SYSCALL(__NR_chown, vc.path, uid, gid);
2929+ #if defined(__NR_chown)
3030+ ret = LINUX_SYSCALL(__NR_chown, vc.path, uid, gid);
3131+ #else
3232+ ret = LINUX_SYSCALL(__NR_fchownat, LINUX_AT_FDCWD, vc.path, uid, gid, 0);
3333+ #endif
2634 if (ret < 0)
2735 return errno_linux_to_bsd(ret);
2836
+11-1
src/kernel/emulation/linux/unistd/dup2.c
···22#include "../base.h"
33#include "../errno.h"
44#include <linux-syscalls/linux.h>
55+#include "../duct_errno.h"
5667extern void kqueue_dup(int oldfd, int newfd);
7889long sys_dup2(int fd_from, int fd_to)
910{
1011 int ret;
1212+1313+ #if defined(__NR_dup2)
1414+ ret = LINUX_SYSCALL2(__NR_dup2, fd_from, fd_to);
1515+ #else
1616+ // It's not clear if 0 is offically a valid flag argument.
1717+ // But we don't really have a choice.
1818+ ret = LINUX_SYSCALL(__NR_dup3, fd_from, fd_to, 0);
11191212- ret = LINUX_SYSCALL2(__NR_dup2, fd_from, fd_to);
2020+ if (ret == LINUX_EINVAL && fd_from == fd_to)
2121+ ret = fd_to;
2222+ #endif
1323 if (ret < 0)
1424 ret = errno_linux_to_bsd(ret);
1525 else
+9-5
src/kernel/emulation/linux/unistd/getpgrp.c
···5566long sys_getpgrp(void)
77{
88- int ret;
88+ #if defined(__NR_getpgrp)
99+ int ret;
9101010- ret = LINUX_SYSCALL0(__NR_getpgrp);
1111- if (ret < 0)
1212- ret = errno_linux_to_bsd(ret);
1111+ ret = LINUX_SYSCALL0(__NR_getpgrp);
1212+ if (ret < 0)
1313+ ret = errno_linux_to_bsd(ret);
13141414- return ret;
1515+ return ret;
1616+ #else
1717+ return sys_getpgid(0);
1818+ #endif
1519}
1620
+5-1
src/kernel/emulation/linux/unistd/mknod.c
···2121 if (ret < 0)
2222 return errno_linux_to_bsd(ret);
23232424- ret = LINUX_SYSCALL(__NR_mknod, vc.path, mode, dev);
2424+ #if defined(__NR_mknod)
2525+ ret = LINUX_SYSCALL(__NR_mknod, vc.path, mode, dev);
2626+ #else
2727+ ret = LINUX_SYSCALL(__NR_mknodat, LINUX_AT_FDCWD, vc.path, mode, dev);
2828+ #endif
2529 if (ret < 0)
2630 ret = errno_linux_to_bsd(ret);
2731
+5-1
src/kernel/emulation/linux/unistd/pipe.c
···77{
88 int ret;
991010- ret = LINUX_SYSCALL(__NR_pipe, fd);
1010+ #if defined(__NR_pipe)
1111+ ret = LINUX_SYSCALL(__NR_pipe, fd);
1212+ #else
1313+ ret = LINUX_SYSCALL(__NR_pipe2, fd, 0);
1414+ #endif
1115 if (ret < 0)
1216 return errno_linux_to_bsd(ret);
1317