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

Introduces CUPS Packaging with Snapcraft and Rockcraft #1137

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

rudra-iitm
Copy link
Contributor

This PR enhances the packaging process for CUPS by introducing two distinct methods for deployment:

  1. Snapcraft: Packages CUPS as a Snap, already maintained by @tillkamppeter in the OpenPrinting/cups-snap repository.
  2. Rockcraft: Adds the necessary code and configurations to build and deploy an OCI image of CUPS using Rockcraft.

Key Changes

Packages Configuration

  • Added packages/rockcraft.yaml, containing all the configurations required to build the Rock for CUPS.
  • Added packages/snapcraft.yaml, containing all the configurations required for the CUPS Snap.

GitHub Workflows

  • Introduced packages-ci.yml workflow to build and test the Rockcraft and Snapcraft packages.
  • Added the auto-update.yml workflow with the latest changes from desktop-snaps#813.
  • Implemented a CI pipeline (registry-actions.yml) to automatically push newly built Docker images to GitHub Packages.
    (Note: Publishing to Docker Hub is commented out until OpenPrinting's Docker Hub setup is finalized.)

Testing Instructions

  • Added TESTING.md with detailed instructions on how to test the CUPS Rock package.

@michaelrsweet michaelrsweet self-assigned this Jan 13, 2025
@michaelrsweet michaelrsweet added enhancement New feature or request priority-high platform issue Issue is specific to an OS or desktop labels Jan 13, 2025
@michaelrsweet michaelrsweet added this to the v2.5 milestone Jan 13, 2025
@michaelrsweet
Copy link
Member

Thanks for this, will probably have a chance to start reviewing this tomorrow...

Copy link
Member

@michaelrsweet michaelrsweet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! In general this looks OK, but there is still some reorg/refactoring to do to make this supportable in the long term - see the comments for some specific issues.

I would like to see some of the sub-directories like "scripts" to be renamed. For example, scripts for the Snap packaging could be placed under "snap-scripts" or "snap/scripts". The "packaging" directory also has packaging files for RPM and EPM already, and you have mixed both snap-specific and OCI-specific content together which is confusing, sometimes with almost identical names.

All of the scripts should have both a copyright/license header (see DEVELOPING.md) and a short description of what they do and where they are used. There are a lot of moving parts here, and we have a lot of developers poking around at various times. A little bit of documentation and organization goes a long way towards maintaining a project over 25+ years...

@@ -166,3 +166,10 @@
/xcode/CUPS.xcodeproj/xcuserdata/
.DS_store
container-config
packages/parts
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So these should probably have a leading / (for that matter, so should container-config above).

@@ -0,0 +1,481 @@
# OpenPrinting CUPS: Snap and OCI Image
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the packaging directory is about more than just making Snap or OCI images, this should either have a different name or mention the EPM list and RPM spec files as well. Ditto for the TESTING.md file.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is right, the README.md at the top of packaging/ should cover all contained packaging methods. Or one makes subdirectories, packaging/rpm, packaging/epm, packaging/snap, ... Each one having their own README.md files then.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, we can have two README files: one for Snap and the other for Rock, named SNAP.md and ROCK.md, respectively, inside the packaging directory.

@@ -0,0 +1,69 @@
#
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would feel more comfortable having this in a separate OpenPrinting repository, version it, and then import the corresponding sources when building the snap/OCI image.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These C programs, cups-proxyd and scripts/port-occupied are only for the Snap and OCI packaging and do not make sense separately. So they are a little bit like the scripts the package uses at run time, but they are written in C as writing these as scripts is awkward or even impossible. To avoid clutter in OpenPrinting's GitHub site (unfortunately GitHub does not allow to organize the repos in something directory-tree-like) I have kept them being a part of cups-snap and the most intuitive is to move cups-snap into the CUPS repository altogether instead of creating 2 new mini repos for the 2 C programs and only moving the scripts and snapcraft.yaml into CUPS. So the attempt of doing reduction of clutter on the OpenPrinting GitHub leads to even more clutter.

Perhaps it could be arranged differently, as CUPS (2.x) already has several directories for C source code (systemv, ppdc, ...) one could have an extra C source directory at the top level or under packaging/ holding these C helper programs and they having a Makefile using the build system of CUPS itself, making use of ./configure and Makedefs.

Or should we alternatively not move the packaging repos into CUPS so that they hold the C files by themselves. This would be ugly as we have 2 packaging methods sharing the C files, and so to not create said min repos for each of the C programs, having the 2 packaging methods in one repo which is ugly again.

"is-connected",
"--apparmor-label",
NULL,
- "cups-control",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a generic change that should always be applied? If so, apply it and don't patch around issues in the "upstream" code (now that this will be upstream).

If we need this to be configurable, make it configurable.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, there should not be any patches in a repo which patch anything in the same repo. Whatever gets patched here has to be done right in the first place, or be configurable if the patch is only applied for special cases.

This patch is always applied when we build the Snap and the code it patches is only relevant for the snapped CUPS, so, @rudra-iitm , here you should directly modify the file scheduler/auth.c to use cups-server instead of cups-control.

Please also check with other patches should you have moved some into the CUPS repo.

# We use "--with-tls=gnutls" here, as current CUPS defaults to SSL here
# and this is buggy, causing a segfault when serving out a HTTPS web
# interface page.
- --with-tls=gnutls
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please report this issue - we need to fix that and not work around bugs.

GNU TLS is an order of magnitude slower on most platforms than OpenSSL or LibreSSL.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rudra-iitm first, please re-check whether the problem is still there (build with this line commented out and see whether the web interface is working correctly).

If not, there is really a bug in the Linux version of whatever SSL CUPS is using by default.

As there are both OpenSSL and LibreSSL you could even include one of these alternatives in the Snap, the one where the bug does not occur ...

@@ -0,0 +1,141 @@
/* Copyright (C) 2014-2020 Daniel Dressler, Till Kamppeter, and contributors
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't exactly a script, and should probably be in a separate repo (you could probably create a cups-container repository or something to hold all these helper programs) rather than putting it under the packaging directory.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rudra-iitm See above with cups-proxyd.

@@ -0,0 +1,110 @@
#! /bin/sh
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There needs to be a way to disable cups-browsed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The best way is to move cups-browsed into its own Snap.

Generally it will go away with CUPS 3.x, but for the short remaining life time of CUPS 2.x we should do something about it.

cups-browsed in its own Snap would be the most elegant solution, do not install that Snap if all your print dialogs are nicely doing CPDB and so cope with temporary printers, install it if you still have to cope with broken print dialogs.

If we keep cups-browsed in the CUPS Snap, we need a way to make it easier than sudo snap disable cups.cups-browsed for the users of the CUPS Snap to turn off cups-browsed.

@@ -0,0 +1,68 @@
#!/bin/sh
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is confusing - I'm assuming this is for the OCI image and the "run-cupsd" is for the Snap? The snap and Rock-specific stuff needs to be separated.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rudra-iitm you need to use subdirectories and directory names to make clear what belongs to the Snap and what to the Rock ...

@tillkamppeter
Copy link
Member

@rudra-iitm the needed copyright/license header is as described in DEVELOPING.md, same text content as CUPS' own files. We want to have everything under the same license (Apache 2.0 with exceptions) so you overtake the content of the other file's license headers. The copyright of the snapping is by me and of the Rock is by you and me (as you have overtaken parts of the Snap). AFAIR I had issued the snapping under the same license as CUPS is, if not, you have my permission to change the license to be the same as CUPS.

craftctl default
# Settings:
# Patch to use snapctl with the slot name "cups-server" for Snap mediation
#patch -p1 < $CRAFT_PROJECT_DIR/patches/use-snapctl-with-slot-cups-server.patch
Copy link
Contributor Author

@rudra-iitm rudra-iitm Jan 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tillkamppeter Do we really need to apply this patch? The code that applies this patch is commented out in snapcraft.yaml. If the patch isn't necessary, we could simply remove the file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request platform issue Issue is specific to an OS or desktop priority-high
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants