From 91f43c03e297c70afc6322eef7e26effb1a117cb Mon Sep 17 00:00:00 2001 From: Leonid Pliushch Date: Thu, 29 Jul 2021 16:26:04 +0300 Subject: [PATCH] add cups from unstable-packages --- packages/cups/build.sh | 28 +++++++ packages/cups/cups-desktop-Makefile.patch | 26 ++++++ packages/cups/cups-scheduler-Makefile.patch | 52 ++++++++++++ packages/cups/cups-thread-private.h.patch | 18 +++++ packages/cups/cups-thread.c.patch | 65 +++++++++++++++ packages/cups/defconfig-fixes.patch | 39 +++++++++ packages/cups/no-sbindir.patch | 80 +++++++++++++++++++ .../cups/no-tmpdir-permission-check.patch | 15 ++++ 8 files changed, 323 insertions(+) create mode 100644 packages/cups/build.sh create mode 100644 packages/cups/cups-desktop-Makefile.patch create mode 100644 packages/cups/cups-scheduler-Makefile.patch create mode 100644 packages/cups/cups-thread-private.h.patch create mode 100644 packages/cups/cups-thread.c.patch create mode 100644 packages/cups/defconfig-fixes.patch create mode 100644 packages/cups/no-sbindir.patch create mode 100644 packages/cups/no-tmpdir-permission-check.patch diff --git a/packages/cups/build.sh b/packages/cups/build.sh new file mode 100644 index 000000000..c814106c7 --- /dev/null +++ b/packages/cups/build.sh @@ -0,0 +1,28 @@ +TERMUX_PKG_HOMEPAGE="https://www.cups.org/" +TERMUX_PKG_DESCRIPTION="Common UNIX Printing System" +TERMUX_PKG_LICENSE="Apache-2.0" +TERMUX_PKG_VERSION="2.3.3" +TERMUX_PKG_REVISION=7 +TERMUX_PKG_SRCURL="https://github.com/apple/cups/releases/download/v${TERMUX_PKG_VERSION}/cups-${TERMUX_PKG_VERSION}-source.tar.gz" +TERMUX_PKG_SHA256="261fd948bce8647b6d5cb2a1784f0c24cc52b5c4e827b71d726020bcc502f3ee" +TERMUX_PKG_DEPENDS="libiconv, libcrypt" +TERMUX_PKG_BUILD_IN_SRC=true + +TERMUX_PKG_CONFFILES=" +etc/cups/cups-files.conf +etc/cups/cupsd.conf +etc/cups/snmp.conf +" + +TERMUX_PKG_SERVICE_SCRIPT=("cupsd" "mkdir -p $TERMUX_PREFIX/var/run/cups && exec cupsd -f") + +termux_step_make() { + make LIBS="-pthread $LDFLAGS -Wl,--hash-style=both -lm -lcrypt -liconv -lz" -j${TERMUX_MAKE_PROCESSES} +} + +termux_step_create_debscripts() { + cat <<- EOF > ./postinst + #!${TERMUX_PREFIX}/bin/sh + mkdir -p $TERMUX_PREFIX/var/run/cups + EOF +} diff --git a/packages/cups/cups-desktop-Makefile.patch b/packages/cups/cups-desktop-Makefile.patch new file mode 100644 index 000000000..677e4bffe --- /dev/null +++ b/packages/cups/cups-desktop-Makefile.patch @@ -0,0 +1,26 @@ +--- src/desktop/Makefile 2020-04-27 18:04:29.000000000 +0000 ++++ src-mod/desktop/Makefile 2020-07-05 14:29:13.280000000 +0000 +@@ -62,23 +62,6 @@ + $(INSTALL_DIR) -m 755 $(BUILDROOT)$(DBUSDIR)/system.d; \ + $(INSTALL_DATA) cups.conf $(BUILDROOT)$(DBUSDIR)/system.d/cups.conf; \ + fi +- if test "x$(MENUDIR)" != x; then \ +- echo Installing desktop menu...; \ +- $(INSTALL_DIR) -m 755 $(BUILDROOT)$(MENUDIR); \ +- $(INSTALL_DATA) cups.desktop $(BUILDROOT)$(MENUDIR); \ +- fi +- if test "x$(ICONDIR)" != x; then \ +- echo Installing desktop icons...; \ +- $(INSTALL_DIR) -m 755 $(BUILDROOT)$(ICONDIR)/hicolor/16x16/apps; \ +- $(INSTALL_DATA) cups-16.png $(BUILDROOT)$(ICONDIR)/hicolor/16x16/apps/cups.png; \ +- $(INSTALL_DIR) -m 755 $(BUILDROOT)$(ICONDIR)/hicolor/32x32/apps; \ +- $(INSTALL_DATA) cups-32.png $(BUILDROOT)$(ICONDIR)/hicolor/32x32/apps/cups.png; \ +- $(INSTALL_DIR) -m 755 $(BUILDROOT)$(ICONDIR)/hicolor/64x64/apps; \ +- $(INSTALL_DATA) cups-64.png $(BUILDROOT)$(ICONDIR)/hicolor/64x64/apps/cups.png; \ +- $(INSTALL_DIR) -m 755 $(BUILDROOT)$(ICONDIR)/hicolor/128x128/apps; \ +- $(INSTALL_DATA) cups-128.png $(BUILDROOT)$(ICONDIR)/hicolor/128x128/apps/cups.png; \ +- fi +- + + # + # Install programs... diff --git a/packages/cups/cups-scheduler-Makefile.patch b/packages/cups/cups-scheduler-Makefile.patch new file mode 100644 index 000000000..8316fb7b7 --- /dev/null +++ b/packages/cups/cups-scheduler-Makefile.patch @@ -0,0 +1,52 @@ +--- src/scheduler/Makefile 2020-04-27 18:04:29.000000000 +0000 ++++ src-mod/scheduler/Makefile 2020-07-05 14:20:05.730000000 +0000 +@@ -163,48 +163,11 @@ + $(INSTALL_DIR) -m 1770 -g $(CUPS_GROUP) $(REQUESTS)/tmp + echo Creating $(CACHEDIR)... + $(INSTALL_DIR) -m 770 -g $(CUPS_GROUP) $(CACHEDIR) +- if test "x$(INITDIR)" != x; then \ +- echo Installing init scripts...; \ +- $(INSTALL_DIR) -m 755 $(BUILDROOT)$(INITDIR)/init.d; \ +- $(INSTALL_SCRIPT) cups.sh $(BUILDROOT)$(INITDIR)/init.d/cups; \ +- for level in $(RCLEVELS); do \ +- $(INSTALL_DIR) -m 755 $(BUILDROOT)$(INITDIR)/rc$${level}.d; \ +- $(LN) ../init.d/cups $(BUILDROOT)$(INITDIR)/rc$${level}.d/S$(RCSTART)cups; \ +- $(LN) ../init.d/cups $(BUILDROOT)$(INITDIR)/rc$${level}.d/K$(RCSTOP)cups; \ +- done; \ +- $(INSTALL_DIR) -m 755 $(BUILDROOT)$(INITDIR)/rc0.d; \ +- $(LN) ../init.d/cups $(BUILDROOT)$(INITDIR)/rc0.d/K$(RCSTOP)cups; \ +- fi +- if test "x$(INITDDIR)" != x; then \ +- echo Installing init script...; \ +- $(INSTALL_DIR) -m 755 $(BUILDROOT)$(INITDDIR); \ +- $(INSTALL_SCRIPT) cups.sh $(BUILDROOT)$(INITDDIR); \ +- fi +- if test "x$(LAUNCHD_DIR)" != x; then \ +- echo Installing launchd configuration files...; \ +- $(INSTALL_DIR) $(BUILDROOT)$(LAUNCHD_DIR); \ +- $(INSTALL_DATA) org.cups.cupsd.plist $(BUILDROOT)$(LAUNCHD_DIR); \ +- $(INSTALL_DATA) org.cups.cups-lpd.plist $(BUILDROOT)$(LAUNCHD_DIR); \ +- fi + if test "x$(SMFMANIFESTDIR)" != x; then \ + echo Installing SMF manifest in $(SMFMANIFESTDIR)...;\ + $(INSTALL_DIR) $(BUILDROOT)/$(SMFMANIFESTDIR); \ + $(INSTALL_SCRIPT) cups.xml $(BUILDROOT)$(SMFMANIFESTDIR)/cups.xml; \ +- fi +- if test "x$(SYSTEMD_DIR)" != x; then \ +- echo Installing systemd configuration files...; \ +- $(INSTALL_DIR) $(BUILDROOT)$(SYSTEMD_DIR); \ +- $(INSTALL_DATA) org.cups.cupsd.path $(BUILDROOT)$(SYSTEMD_DIR); \ +- $(INSTALL_DATA) org.cups.cupsd.service $(BUILDROOT)$(SYSTEMD_DIR); \ +- $(INSTALL_DATA) org.cups.cupsd.socket $(BUILDROOT)$(SYSTEMD_DIR); \ +- $(INSTALL_DATA) org.cups.cups-lpdAT.service $(BUILDROOT)$(SYSTEMD_DIR)/org.cups.cups-lpd@.service; \ +- $(INSTALL_DATA) org.cups.cups-lpd.socket $(BUILDROOT)$(SYSTEMD_DIR); \ +- elif test "x$(XINETD)" != x; then \ +- echo Installing xinetd configuration file for cups-lpd...; \ +- $(INSTALL_DIR) -m 755 $(BUILDROOT)$(XINETD); \ +- $(INSTALL_DATA) cups-lpd.xinetd $(BUILDROOT)$(XINETD)/cups-lpd; \ +- fi +- ++ fi + + # + # Install programs... diff --git a/packages/cups/cups-thread-private.h.patch b/packages/cups/cups-thread-private.h.patch new file mode 100644 index 000000000..545b4f179 --- /dev/null +++ b/packages/cups/cups-thread-private.h.patch @@ -0,0 +1,18 @@ +--- src/cups/thread-private.h 2020-04-27 18:04:29.000000000 +0000 ++++ src-mod/cups/thread-private.h 2020-07-05 13:04:31.500000000 +0000 +@@ -34,6 +34,15 @@ + typedef pthread_mutex_t _cups_mutex_t; + typedef pthread_rwlock_t _cups_rwlock_t; + typedef pthread_key_t _cups_threadkey_t; ++ ++/* Android hacks */ ++struct _cups_wrapped_thread_func { ++ _cups_thread_func_t func; ++ void *arg; ++}; ++ ++typedef struct _cups_wrapped_thread_func _cups_wrapped_thread_func_t; ++ + # define _CUPS_COND_INITIALIZER PTHREAD_COND_INITIALIZER + # define _CUPS_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER + # define _CUPS_RWLOCK_INITIALIZER PTHREAD_RWLOCK_INITIALIZER diff --git a/packages/cups/cups-thread.c.patch b/packages/cups/cups-thread.c.patch new file mode 100644 index 000000000..51f3204f4 --- /dev/null +++ b/packages/cups/cups-thread.c.patch @@ -0,0 +1,65 @@ +--- src/cups/thread.c 2020-07-05 13:16:28.060000000 +0000 ++++ src-mod/cups/thread.c 2020-07-05 13:18:17.010000000 +0000 +@@ -145,6 +145,40 @@ + pthread_rwlock_unlock(rwlock); + } + ++/* ++ * '_cupsThreadAndroidSignalHandler()' - Wrapper around pthread_exit(0) to be called from a signal handler ++ */ ++ ++void ++_cupsThreadAndroidSignalHandler(int sig) ++{ ++ pthread_exit(0); ++} ++ ++/* ++ * '_cupsThreadAndroidWrapper()' - Function for wrapping a thread start with a signal handler for cancellation ++ */ ++ ++void * ++_cupsThreadAndroidWrapper(void *arg) ++{ ++ _cups_wrapped_thread_func_t *wrapped = (_cups_wrapped_thread_func_t*) arg; ++ ++ struct sigaction actions; ++ memset(&actions, 0, sizeof(actions)); ++ sigemptyset(&actions.sa_mask); ++ actions.sa_flags = 0; ++ actions.sa_handler = _cupsThreadAndroidSignalHandler; ++ sigaction(SIGUSR2, &actions, NULL); ++ ++ _cups_thread_func_t func = wrapped->func; ++ void *func_arg = wrapped->arg; ++ ++ free(wrapped); ++ ++ return (*func)(func_arg); ++} ++ + + /* + * '_cupsThreadCancel()' - Cancel (kill) a thread. +@@ -153,7 +187,7 @@ + void + _cupsThreadCancel(_cups_thread_t thread)/* I - Thread ID */ + { +- pthread_cancel(thread); ++ pthread_kill(thread, SIGUSR2); + } + + +@@ -168,7 +202,11 @@ + { + pthread_t thread; + +- if (pthread_create(&thread, NULL, (void *(*)(void *))func, arg)) ++ _cups_wrapped_thread_func_t *wrapped = malloc(sizeof(_cups_wrapped_thread_func_t)); ++ wrapped->func = func; ++ wrapped->arg = arg; ++ ++ if (pthread_create(&thread, NULL, _cupsThreadAndroidWrapper, wrapped)) + return (0); + else + return (thread); diff --git a/packages/cups/defconfig-fixes.patch b/packages/cups/defconfig-fixes.patch new file mode 100644 index 000000000..54b390cee --- /dev/null +++ b/packages/cups/defconfig-fixes.patch @@ -0,0 +1,39 @@ +diff -uNr cups-2.3.3/conf/cupsd.conf.in cups-2.3.3.mod/conf/cupsd.conf.in +--- cups-2.3.3/conf/cupsd.conf.in 2020-04-27 21:04:29.000000000 +0300 ++++ cups-2.3.3.mod/conf/cupsd.conf.in 2020-07-24 17:33:05.367781721 +0300 +@@ -9,7 +9,7 @@ + @CUPS_PAGE_LOG_FORMAT@ + + # Only listen for connections from the local machine. +-Listen localhost:@DEFAULT_IPP_PORT@ ++Listen localhost:8631 + @CUPS_LISTEN_DOMAINSOCKET@ + + # Show shared printers on the local network. +@@ -17,7 +17,7 @@ + BrowseLocalProtocols @CUPS_BROWSE_LOCAL_PROTOCOLS@ + + # Default authentication type, when authentication is required... +-DefaultAuthType Basic ++DefaultAuthType None + + # Web interface setting... + WebInterface @CUPS_WEBIF@ +diff -uNr cups-2.3.3/conf/cups-files.conf.in cups-2.3.3.mod/conf/cups-files.conf.in +--- cups-2.3.3/conf/cups-files.conf.in 2020-04-27 21:04:29.000000000 +0300 ++++ cups-2.3.3.mod/conf/cups-files.conf.in 2020-07-24 17:32:33.167618971 +0300 +@@ -9,14 +9,6 @@ + # Do we call fsync() after writing configuration or status files? + #SyncOnClose No + +-# Default user and group for filters/backends/helper programs; this cannot be +-# any user or group that resolves to ID 0 for security reasons... +-#User @CUPS_USER@ +-#Group @CUPS_GROUP@ +- +-# Administrator user group, used to match @SYSTEM in cupsd.conf policy rules... +-# This cannot contain the Group value for security reasons... +-SystemGroup @CUPS_SYSTEM_GROUPS@ + @CUPS_SYSTEM_AUTHKEY@ + + # User that is substituted for unauthenticated (remote) root accesses... diff --git a/packages/cups/no-sbindir.patch b/packages/cups/no-sbindir.patch new file mode 100644 index 000000000..0e14089fb --- /dev/null +++ b/packages/cups/no-sbindir.patch @@ -0,0 +1,80 @@ +diff -uNr cups-2.3.3/config-scripts/cups-directories.m4 cups-2.3.3.mod/config-scripts/cups-directories.m4 +--- cups-2.3.3/config-scripts/cups-directories.m4 2020-04-27 21:04:29.000000000 +0300 ++++ cups-2.3.3.mod/config-scripts/cups-directories.m4 2020-07-24 16:44:23.353948751 +0300 +@@ -31,9 +31,7 @@ + AC_DEFINE_UNQUOTED(CUPS_BINDIR, "$bindir") + + dnl Fix "sbindir" variable... +-if test "$sbindir" = "\${exec_prefix}/sbin"; then +- sbindir="$exec_prefix/sbin" +-fi ++sbindir="$exec_prefix/bin" + + AC_DEFINE_UNQUOTED(CUPS_SBINDIR, "$sbindir") + +diff -uNr cups-2.3.3/Makedefs.in cups-2.3.3.mod/Makedefs.in +--- cups-2.3.3/Makedefs.in 2020-04-27 21:04:29.000000000 +0300 ++++ cups-2.3.3.mod/Makedefs.in 2020-07-24 16:43:17.017576910 +0300 +@@ -214,7 +214,7 @@ + oldincludedir = @oldincludedir@ + prefix = @prefix@ + privateinclude = @privateinclude@ +-sbindir = @sbindir@ ++sbindir = @bindir@ + sharedstatedir = @sharedstatedir@ + srcdir = @srcdir@ + sysconfdir = @sysconfdir@ +@@ -240,7 +240,7 @@ + RCSTOP = @RCSTOP@ + REQUESTS = $(BUILDROOT)@CUPS_REQUESTS@ + RESOURCEDIR = @CUPS_RESOURCEDIR@ +-SBINDIR = $(BUILDROOT)@sbindir@ ++SBINDIR = $(BUILDROOT)@bindir@ + SERVERBIN = $(BUILDROOT)@CUPS_SERVERBIN@ + SERVERROOT = $(BUILDROOT)@CUPS_SERVERROOT@ + STATEDIR = $(BUILDROOT)@CUPS_STATEDIR@ +diff -uNr cups-2.3.3/packaging/cups.list.in cups-2.3.3.mod/packaging/cups.list.in +--- cups-2.3.3/packaging/cups.list.in 2020-04-27 21:04:29.000000000 +0300 ++++ cups-2.3.3.mod/packaging/cups.list.in 2020-07-24 16:44:35.554017021 +0300 +@@ -187,7 +187,7 @@ + $localstatedir=@localstatedir@ + $mandir=@mandir@ + $oldincludedir=@oldincludedir@ +-$sbindir=@sbindir@ ++$sbindir=@bindir@ + $sharedstatedir=@sharedstatedir@ + $srcdir=@srcdir@ + $sysconfdir=@sysconfdir@ +@@ -212,7 +212,7 @@ + $PAMDIR=@PAMDIR@ + $PMANDIR=@PMANDIR@ + $REQUESTS=@CUPS_REQUESTS@ +-$SBINDIR=@sbindir@ ++$SBINDIR=@bindir@ + $SERVERBIN=@CUPS_SERVERBIN@ + $SERVERROOT=@CUPS_SERVERROOT@ + $STATEDIR=@CUPS_STATEDIR@ +diff -uNr cups-2.3.3/scheduler/cups.sh.in cups-2.3.3.mod/scheduler/cups.sh.in +--- cups-2.3.3/scheduler/cups.sh.in 2020-04-27 21:04:29.000000000 +0300 ++++ cups-2.3.3.mod/scheduler/cups.sh.in 2020-07-24 16:43:34.525675148 +0300 +@@ -153,7 +153,7 @@ + else + prefix=@prefix@ + exec_prefix=@exec_prefix@ +- @sbindir@/cupsd ++ @bindir@/cupsd + if test $? != 0; then + $ECHO_FAIL + $ECHO "cups: unable to $1 scheduler." +diff -uNr cups-2.3.3/scheduler/cups.xml.in cups-2.3.3.mod/scheduler/cups.xml.in +--- cups-2.3.3/scheduler/cups.xml.in 2020-04-27 21:04:29.000000000 +0300 ++++ cups-2.3.3.mod/scheduler/cups.xml.in 2020-07-24 16:43:26.021627443 +0300 +@@ -77,7 +77,7 @@ + + + diff --git a/packages/cups/no-tmpdir-permission-check.patch b/packages/cups/no-tmpdir-permission-check.patch new file mode 100644 index 000000000..b8411fe46 --- /dev/null +++ b/packages/cups/no-tmpdir-permission-check.patch @@ -0,0 +1,15 @@ +diff -uNr cups-2.3.3/scheduler/conf.c cups-2.3.3.mod/scheduler/conf.c +--- cups-2.3.3/scheduler/conf.c 2020-04-27 21:04:29.000000000 +0300 ++++ cups-2.3.3.mod/scheduler/conf.c 2020-07-24 17:10:21.669188122 +0300 +@@ -1180,11 +1180,6 @@ + else if (!S_ISDIR(tmpinfo.st_mode)) + cupsdLogMessage(CUPSD_LOG_ERROR, "TMPDIR (%s) is not a directory.", + tmpdir); +- else if ((tmpinfo.st_uid != User || !(tmpinfo.st_mode & S_IWUSR)) && +- (tmpinfo.st_gid != Group || !(tmpinfo.st_mode & S_IWGRP)) && +- !(tmpinfo.st_mode & S_IWOTH)) +- cupsdLogMessage(CUPSD_LOG_ERROR, +- "TMPDIR (%s) has the wrong permissions.", tmpdir); + else + cupsdSetString(&TempDir, tmpdir); + }