chuckcharlie / cups-avahi-airprint

Docker image for CUPS intended as an AirPrint relay
GNU General Public License v3.0
118 stars 66 forks source link

Add defaults for CUPSADMIN and CUPSPASSWORD #2

Closed thoschworks closed 3 years ago

thoschworks commented 4 years ago

If the variables CUPSADMIN and/or CUPSPASSWORD are not provided on start adding the cups admin will fail, but the container will nevertheless start.

With this change CUPSADMIN - if missing - will be set to "cupsadmin" and CUPSPASSWORD - if missing - will be set to the name of the cups admin.

thoschworks commented 4 years ago

I must confess that I forgot to test the changes in your project before I submitted the pull request.

I tested it in my project thoschworks/cups-airprint-bjnp and all worked fine.

Today I wanted to catch up, but it is not possible to build the image:

...
Installing collected packages: pycups
    Running setup.py install for pycups: started
    Running setup.py install for pycups: finished with status 'error'
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python2 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ika7w9/pycups/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ika7w9/pycups/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-tVicwe/install-record.txt --single-version-externally-managed --compile --install-headers /usr/include/python2.7/pycups
         cwd: /tmp/pip-install-ika7w9/pycups/
    Complete output (159 lines):
    running install
    running build
    running build_ext
    building 'cups' extension
    creating build
    creating build/temp.linux-x86_64-2.7
    gcc -fno-strict-aliasing -Os -fomit-frame-pointer -g -DNDEBUG -Os -fomit-frame-pointer -g -DTHREAD_STACK_SIZE=0x100000 -fPIC -DVERSION="2.0.1" -I/usr/include/python2.7 -c cupsmodule.c -o build/temp.linux-x86_64-2.7/cupsmodule.o
    cupsmodule.c: In function 'cups_modelSort':
    cupsmodule.c:184:30: warning: implicit declaration of function 'PyUnicode_GetLength'; did you mean 'PyUnicode_GetMax'? [-Wimplicit-function-declaration]
      184 |   len_a = 1 + (long unsigned)PyUnicode_GetLength (a);
          |                              ^~~~~~~~~~~~~~~~~~~
          |                              PyUnicode_GetMax
    cupsmodule.c:212:25: warning: passing argument 1 of 'PyUnicodeUCS4_AsWideChar' from incompatible pointer type [-Wincompatible-pointer-types]
      212 |   PyUnicode_AsWideChar (a, wca, size_a);
          |                         ^
          |                         |
          |                         PyObject * {aka struct _object *}
    In file included from /usr/include/python2.7/Python.h:88,
                     from cupsmodule.c:23:
    /usr/include/python2.7/unicodeobject.h:592:22: note: expected 'PyUnicodeObject *' {aka 'struct <anonymous> *'} but argument is of type 'PyObject *' {aka 'struct _object *'}
      592 |     PyUnicodeObject *unicode,   /* Unicode object */
          |     ~~~~~~~~~~~~~~~~~^~~~~~~
    cupsmodule.c:213:25: warning: passing argument 1 of 'PyUnicodeUCS4_AsWideChar' from incompatible pointer type [-Wincompatible-pointer-types]
      213 |   PyUnicode_AsWideChar (b, wcb, size_b);
          |                         ^
          |                         |
          |                         PyObject * {aka struct _object *}
    In file included from /usr/include/python2.7/Python.h:88,
                     from cupsmodule.c:23:
    /usr/include/python2.7/unicodeobject.h:592:22: note: expected 'PyUnicodeObject *' {aka 'struct <anonymous> *'} but argument is of type 'PyObject *' {aka 'struct _object *'}
      592 |     PyUnicodeObject *unicode,   /* Unicode object */
          |     ~~~~~~~~~~~~~~~~~^~~~~~~
    cupsmodule.c: In function 'cups_ppdSetConformance':
    cupsmodule.c:378:3: warning: 'ppdSetConformance' is deprecated: Use cupsCopyDestInfo and friends instead. [-Wdeprecated-declarations]
      378 |   ppdSetConformance (level);
          |   ^~~~~~~~~~~~~~~~~
    In file included from cupsppd.h:24,
                     from cupsmodule.c:35:
    /usr/include/cups/ppd.h:415:14: note: declared here
      415 | extern void  ppdSetConformance(ppd_conform_t c) _PPD_DEPRECATED;
          |              ^~~~~~~~~~~~~~~~~
    In file included from /usr/include/python2.7/Python.h:84,
                     from cupsmodule.c:23:
    cupsmodule.c: In function 'cups_traverse':
    cupsmodule.c:602:44: warning: implicit declaration of function 'PyModule_GetState'; did you mean 'PyModule_GetName'? [-Wimplicit-function-declaration]
      602 | #define GETSTATE(m) ((struct module_state*)PyModule_GetState(m))
          |                                            ^~~~~~~~~~~~~~~~~
    /usr/include/python2.7/objimpl.h:341:13: note: in definition of macro 'Py_VISIT'
      341 |         if (op) {                                                       \
          |             ^~
    cupsmodule.c:741:14: note: in expansion of macro 'GETSTATE'
      741 |     Py_VISIT(GETSTATE(m)->error);
          |              ^~~~~~~~
    cupsmodule.c:602:22: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
      602 | #define GETSTATE(m) ((struct module_state*)PyModule_GetState(m))
          |                      ^
    /usr/include/python2.7/objimpl.h:341:13: note: in definition of macro 'Py_VISIT'
      341 |         if (op) {                                                       \
          |             ^~
    cupsmodule.c:741:14: note: in expansion of macro 'GETSTATE'
      741 |     Py_VISIT(GETSTATE(m)->error);
          |              ^~~~~~~~
    cupsmodule.c:602:22: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
      602 | #define GETSTATE(m) ((struct module_state*)PyModule_GetState(m))
          |                      ^
    /usr/include/python2.7/objimpl.h:342:43: note: in definition of macro 'Py_VISIT'
      342 |             int vret = visit((PyObject *)(op), arg);                    \
          |                                           ^~
    cupsmodule.c:741:14: note: in expansion of macro 'GETSTATE'
      741 |     Py_VISIT(GETSTATE(m)->error);
          |              ^~~~~~~~
    In file included from /usr/include/python2.7/Python.h:83,
                     from cupsmodule.c:23:
    cupsmodule.c: In function 'cups_clear':
    cupsmodule.c:602:22: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
      602 | #define GETSTATE(m) ((struct module_state*)PyModule_GetState(m))
          |                      ^
    /usr/include/python2.7/object.h:816:13: note: in definition of macro 'Py_CLEAR'
      816 |         if (op) {                               \
          |             ^~
    cupsmodule.c:746:14: note: in expansion of macro 'GETSTATE'
      746 |     Py_CLEAR(GETSTATE(m)->error);
          |              ^~~~~~~~
    cupsmodule.c:602:22: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
      602 | #define GETSTATE(m) ((struct module_state*)PyModule_GetState(m))
          |                      ^
    /usr/include/python2.7/object.h:817:46: note: in definition of macro 'Py_CLEAR'
      817 |             PyObject *_py_tmp = (PyObject *)(op);               \
          |                                              ^~
    cupsmodule.c:746:14: note: in expansion of macro 'GETSTATE'
      746 |     Py_CLEAR(GETSTATE(m)->error);
          |              ^~~~~~~~
    cupsmodule.c:602:22: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
      602 | #define GETSTATE(m) ((struct module_state*)PyModule_GetState(m))
          |                      ^
    /usr/include/python2.7/object.h:818:14: note: in definition of macro 'Py_CLEAR'
      818 |             (op) = NULL;                        \
          |              ^~
    cupsmodule.c:746:14: note: in expansion of macro 'GETSTATE'
      746 |     Py_CLEAR(GETSTATE(m)->error);
          |              ^~~~~~~~
    cupsmodule.c: At top level:
    cupsmodule.c:751:15: error: variable 'moduledef' has initializer but incomplete type
      751 | static struct PyModuleDef moduledef = {
          |               ^~~~~~~~~~~
    cupsmodule.c:752:9: error: 'PyModuleDef_HEAD_INIT' undeclared here (not in a function)
      752 |         PyModuleDef_HEAD_INIT,
          |         ^~~~~~~~~~~~~~~~~~~~~
    cupsmodule.c:752:9: warning: excess elements in struct initializer
    cupsmodule.c:752:9: note: (near initialization for 'moduledef')
    cupsmodule.c:753:9: warning: excess elements in struct initializer
      753 |         "cups",
          |         ^~~~~~
    cupsmodule.c:753:9: note: (near initialization for 'moduledef')
    cupsmodule.c:754:9: warning: excess elements in struct initializer
      754 |         NULL,
          |         ^~~~
    cupsmodule.c:754:9: note: (near initialization for 'moduledef')
    cupsmodule.c:755:9: warning: excess elements in struct initializer
      755 |         sizeof(struct module_state),
          |         ^~~~~~
    cupsmodule.c:755:9: note: (near initialization for 'moduledef')
    cupsmodule.c:756:9: warning: excess elements in struct initializer
      756 |         cups_methods,
          |         ^~~~~~~~~~~~
    cupsmodule.c:756:9: note: (near initialization for 'moduledef')
    cupsmodule.c:757:9: warning: excess elements in struct initializer
      757 |         NULL,
          |         ^~~~
    cupsmodule.c:757:9: note: (near initialization for 'moduledef')
    cupsmodule.c:758:9: warning: excess elements in struct initializer
      758 |         cups_traverse,
          |         ^~~~~~~~~~~~~
    cupsmodule.c:758:9: note: (near initialization for 'moduledef')
    cupsmodule.c:759:9: warning: excess elements in struct initializer
      759 |         cups_clear,
          |         ^~~~~~~~~~
    cupsmodule.c:759:9: note: (near initialization for 'moduledef')
    cupsmodule.c:760:9: warning: excess elements in struct initializer
      760 |         NULL
          |         ^~~~
    cupsmodule.c:760:9: note: (near initialization for 'moduledef')
    cupsmodule.c: In function 'PyInit_cups':
    cupsmodule.c:768:19: warning: implicit declaration of function 'PyModule_Create'; did you mean 'PyModule_Check'? [-Wimplicit-function-declaration]
      768 |     PyObject *m = PyModule_Create(&moduledef);
          |                   ^~~~~~~~~~~~~~~
          |                   PyModule_Check
    cupsmodule.c:768:19: warning: initialization of 'PyObject *' {aka 'struct _object *'} from 'int' makes pointer from integer without a cast [-Wint-conversion]
    cupsmodule.c:602:22: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
      602 | #define GETSTATE(m) ((struct module_state*)PyModule_GetState(m))
          |                      ^
    cupsmodule.c:772:29: note: in expansion of macro 'GETSTATE'
      772 |   struct module_state *st = GETSTATE(m);
          |                             ^~~~~~~~
    cupsmodule.c: At top level:
    cupsmodule.c:751:27: error: storage size of 'moduledef' isn't known
      751 | static struct PyModuleDef moduledef = {
          |                           ^~~~~~~~~
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python2 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ika7w9/pycups/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ika7w9/pycups/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-tVicwe/install-record.txt --single-version-externally-managed --compile --install-headers /usr/include/python2.7/pycups Check the logs for full command output.
The command '/bin/sh -c echo "http://nl.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories &&    apk add --update cups   cups-libs   cups-pdf    cups-client     cups-filters    cups-dev    ghostscript     avahi   inotify-tools   python  python-dev  py-pip  build-base  wget    rsync && pip --no-cache-dir install --upgrade pip   && pip install pycups   && rm -rf /var/cache/apk/*' returned a non-zero code: 1
chuckcharlie commented 4 years ago

Weird that you couldn’t build. My computers are packed away right now due to a move, but I should be able to test it out in the next few weeks. Default passwords is a good idea.

thoschworks commented 4 years ago

Uhhm, I did only copy the error-txt which was printed in red, so I missed a important message a few lines above:

Collecting pycups
  Downloading pycups-2.0.1.tar.gz (62 kB)
Could not build wheels for pycups, since package 'wheel' is not installed.
Installing collected packages: pycups
    Running setup.py install for pycups: started
    Running setup.py install for pycups: finished with status 'error'
    ERROR: Command errored out with exit status 1:

(3rd line...)

Looks like a package is missing.

thoschworks commented 4 years ago

I added

&& pip install wheel \

before the line with the installation of pycups, but it failed again. I added the console-output.

build_pr_cupsadmin-defaults.log