From d08eff0fdffc423b033ed86b6ad1f070ece91a67 Mon Sep 17 00:00:00 2001 From: Rudra-IITM Date: Mon, 12 Aug 2024 17:53:11 +0530 Subject: [PATCH 01/10] Initial Repository Setup for Rockcrafting: - Added parts: - pappl - pappl-retrofit - qpdf - ghostscript - cups - libcupsfilters - libppd - cups-filters - pyppd - foomatic-db - hplip - c2050 - min12xxw - pnm2ppa - c2esp - dymo-cups-drivers - foo2zjs - fxlinuxprint - m2300w - printer-driver-oki - pxljr - rastertosag-gdi - splix - brlaser - ptouch-driver - ghostscript-printer-app - scripts - avahi-daemon - Added service to start dbus-daemon and start ghostscript-printer-app server - Included scripts: - Scripts to start dbus-daemon - Makefiles and scripts to build ghostscript-printer-app --- .gitignore | 2 + Makefile | 110 ++ ghostscript-printer-app.1 | 110 ++ ghostscript-printer-app.c | 258 +++ ghostscript-printer-app.service | 10 + patch-files/c2esp-libcupsfilters2-api.patch | 153 ++ .../cups-dnssd-backend-socket-only.patch | 36 + rockcraft.yaml | 1475 +++++++++++++++++ scripts/run-dbus.sh | 32 + testpage.ps | Bin 0 -> 17524 bytes 10 files changed, 2186 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 ghostscript-printer-app.1 create mode 100644 ghostscript-printer-app.c create mode 100644 ghostscript-printer-app.service create mode 100644 patch-files/c2esp-libcupsfilters2-api.patch create mode 100644 patch-files/cups-dnssd-backend-socket-only.patch create mode 100644 rockcraft.yaml create mode 100644 scripts/run-dbus.sh create mode 100644 testpage.ps diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fa9a08a --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.rock +.DS_Store \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..ba31b6d --- /dev/null +++ b/Makefile @@ -0,0 +1,110 @@ +# +# Makefile for the Ghostscript Printer Application +# +# Copyright © 2020-2021 by Till Kamppeter +# Copyright © 2020 by Michael R Sweet +# +# Licensed under Apache License v2.0. See the file "LICENSE" for more +# information. +# + +# Version and +VERSION = 1.0 +prefix = $(DESTDIR)/usr +localstatedir = $(DESTDIR)/var +includedir = $(prefix)/include +bindir = $(prefix)/bin +libdir = $(prefix)/lib +mandir = $(prefix)/share/man +ppddir = $(prefix)/share/ppd +statedir = $(localstatedir)/lib/ghostscript-printer-app +spooldir = $(localstatedir)/spool/ghostscript-printer-app +serverbin = $(prefix)/lib/ghostscript-printer-app +resourcedir = $(prefix)/share/ghostscript-printer-app +cupsserverbin = `cups-config --serverbin` +unitdir := $(DESTDIR)`pkg-config --variable=systemdsystemunitdir systemd` + + +# Compiler/linker options... +OPTIM = -Os -g +CFLAGS += `pkg-config --cflags pappl` `cups-config --cflags` `pkg-config --cflags libppd` `pkg-config --cflags libcupsfilters` `pkg-config --cflags libpappl-retrofit` $(OPTIM) +ifdef VERSION +CFLAGS += -DSYSTEM_VERSION_STR="\"$(VERSION)\"" +ifndef MAJOR +MAJOR = `echo $(VERSION) | perl -p -e 's/^(\d+).*$$/\1/'` +endif +ifndef MINOR +MINOR = `echo $(VERSION) | perl -p -e 's/^\d+\D+(\d+).*$$/\1/'` +endif +ifndef PATCH +PATCH = `echo $(VERSION) | perl -p -e 's/^\d+\D+\d+\D+(\d+).*$$/\1/'` +endif +ifndef PACKAGE +PACKAGE = `echo $(VERSION) | perl -p -e 's/^\d+\D+\d+\D+\d+\D+(\d+).*$$/\1/'` +endif +endif +ifdef MAJOR +CFLAGS += -DSYSTEM_VERSION_ARR_0=$(MAJOR) +endif +ifdef MINOR +CFLAGS += -DSYSTEM_VERSION_ARR_1=$(MINOR) +endif +ifdef PATCH +CFLAGS += -DSYSTEM_VERSION_ARR_2=$(PATCH) +endif +ifdef PACKAGE +CFLAGS += -DSYSTEM_VERSION_ARR_3=$(PACKAGE) +endif +ifdef SNAP +CFLAGS += -DSNAP=$(SNAP) +endif +LDFLAGS += $(OPTIM) `cups-config --ldflags` +LIBS += `pkg-config --libs pappl` `cups-config --image --libs` `pkg-config --libs libppd` `pkg-config --libs libcupsfilters` `pkg-config --libs libpappl-retrofit` + + +# Targets... +OBJS = ghostscript-printer-app.o +TARGETS = ghostscript-printer-app + + +# General build rules... +.SUFFIXES: .c .o +.c.o: + $(CC) $(CFLAGS) -c -o $@ $< + + +# Targets... +all: $(TARGETS) + +clean: + rm -f $(TARGETS) $(OBJS) + +install: $(TARGETS) + mkdir -p $(bindir) + cp $(TARGETS) $(bindir) + mkdir -p $(mandir)/man1 + cp ghostscript-printer-app.1 $(mandir)/man1 + mkdir -p $(ppddir) + mkdir -p $(statedir)/ppd + mkdir -p $(spooldir) + mkdir -p $(resourcedir) + cp testpage.ps $(resourcedir) + if test "x$(cupsserverbin)" != x; then \ + mkdir -p $(libdir); \ + touch $(serverbin) 2> /dev/null || :; \ + if rm $(serverbin) 2> /dev/null; then \ + ln -s $(cupsserverbin) $(serverbin); \ + fi; \ + else \ + mkdir -p $(serverbin)/filter; \ + mkdir -p $(serverbin)/backend; \ + fi + if test "x$(unitdir)" != x; then \ + mkdir -p $(unitdir); \ + cp ghostscript-printer-app.service $(unitdir); \ + fi + +ghostscript-printer-app: $(OBJS) + $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) + +$(OBJS): Makefile diff --git a/ghostscript-printer-app.1 b/ghostscript-printer-app.1 new file mode 100644 index 0000000..d96c6ea --- /dev/null +++ b/ghostscript-printer-app.1 @@ -0,0 +1,110 @@ +.\" +.\" Ghostscript Printer Application man page +.\" +.\" Copyright © 2020-2021 by Till Kamppeter +.\" Copyright © 2020 by Michael R Sweet +.\" +.\" Licensed under Apache License v2.0. See the file "LICENSE" for more +.\" information. +.\" +.TH ghostscript-printer-app 1 "ghostscript-printer-app" "2021-08-26" "OpenPrinting" +.SH NAME +ghostscript-printer-app \- Ghostscript Printer Application +.SH SYNOPSIS +.B ghostscript-printer-app +[ +.I SUB-COMMAND +] [ OPTIONS ] [ FILES ] +.SH DESCRIPTION +.B ghostscript-printer-app +is a Printer Application that can be run standalone or as a dedicated IPP Everywhere network service. +.B ghostscript-printer-app +supports printing PDF files, PostScript files, JPEG images, PNG images, and Apple/PWG raster files to USB and network printers supported by Ghostscript's built-in printer drivers and a few extra filters. For these printers info of the PPD (PostScript Printer Description) files of the Foomatic database on OpenPrinting is used, to give access to printer features as trays, duplex, supported paper sizes, resolutions, finishers, ... + +Under the extra filters is especially HPLIP's hpijs for non-HP PCL 5c/e printers (for HP printers pleasu use HPLIP for best support), but there is also c2050 for Lexmark 2050, cjet for older Canon LBP laser printers, min12xxw for Konica Minolta PagePro 1[234]xxW printers, and pnm2ppa for PPA-based HP DeskJet printers. + +.SH SUB-COMMANDS +If no sub-command is specified, "submit" is assumed. + +The following sub-commands are recognized by +.B ghostscript-printer-app: +.TP 5 +add +Add a printer queue. +.TP 5 +cancel +Cancel one or more print jobs. +.TP 5 +default +Get/Set the default printer queue. +.TP 5 +delete +Delete a printer queue. +.TP 5 +devices +List connected printers. +.TP 5 +drivers +List the supported drivers. +.TP 5 +jobs +List pending print jobs. +.TP 5 +modify +Modify a printer queue. +.TP 5 +options +List supported options. +.TP 5 +printers +List the printer queues. +.TP 5 +server +Start a server. +.TP 5 +shutdown +Shutdown a running server. +.TP 5 +status +Show the status of a printer or all printers. +.TP 5 +submit +Submit a file for printing. +.SH OPTIONS +The following options are recognized by +.B ghostscript-printer-app: +.TP 5 +-a +Cancel all jobs. +.TP 5 +-d PRINTER +Specify printer. +.TP 5 +-h HOST +Specify hostname. +.TP 5 +-j JOB-ID +Specify job ID. +.TP 5 +-m DRIVER-NAME +Specify driver. +.TP 5 +-n COPIES +Specify number of copies. +.TP 5 +-o NAME=VALUE +Specify option. +.TP 5 +-t TITLE +Specify job title. +.TP 5 +-u URI +Specify ipp: or ipps: printer/server. +.TP 5 +-v DEVICE-URI +Specify socket: or usb: device. +.SH SEE ALSO +https://github.com/OpenPrinting/ghostscript-printer-app +.SH COPYRIGHT +Copyright \[co] 2020-2021 by Till Kamppeter. +Copyright \[co] 2020 by Michael R Sweet. diff --git a/ghostscript-printer-app.c b/ghostscript-printer-app.c new file mode 100644 index 0000000..4aca074 --- /dev/null +++ b/ghostscript-printer-app.c @@ -0,0 +1,258 @@ +// +// Ghostscript (Foomatic) Printer Application based on PAPPL and +// libpappl-retrofit +// +// Copyright © 2020-2021 by Till Kamppeter. +// Copyright © 2020 by Michael R Sweet. +// +// Licensed under Apache License v2.0. See the file "LICENSE" for more +// information. +// + +// +// Include necessary headers... +// + +#include + + +// +// Constants... +// + +// Name and version + +#define SYSTEM_NAME "Ghostscript Printer Application" +#define SYSTEM_PACKAGE_NAME "ghostscript-printer-app" +#ifndef SYSTEM_VERSION_STR +# define SYSTEM_VERSION_STR "1.0" +#endif +#ifndef SYSTEM_VERSION_ARR_0 +# define SYSTEM_VERSION_ARR_0 1 +#endif +#ifndef SYSTEM_VERSION_ARR_1 +# define SYSTEM_VERSION_ARR_1 0 +#endif +#ifndef SYSTEM_VERSION_ARR_2 +# define SYSTEM_VERSION_ARR_2 0 +#endif +#ifndef SYSTEM_VERSION_ARR_3 +# define SYSTEM_VERSION_ARR_3 0 +#endif +#define SYSTEM_WEB_IF_FOOTER "Copyright © 2021 by Till Kamppeter. Provided under the terms of the Apache License 2.0." + +// Test page + +#define TESTPAGE "testpage.pdf" + + +// +// Spooling conversions +// + +// When using the fxlinuxprint driver for the non-IPP-driverless PDF +// printers from Fuji Xerox convert PDF with the driver's "pdftopdffx" +// filter + +// Raster input does not need extra conversion rules, here we make use +// of the PostScript input support of the driver + +static pr_spooling_conversion_t ghostscript_convert_pdf_to_fx_pdf = +{ + "application/pdf", + "application/vnd.cups-pdfprintfx", + 2, + { + { + cfFilterPDFToPDF, + NULL, + "pdftopdf" + }, + { + ppdFilterExternalCUPS, + &((cf_filter_external_t){ + "pdftopdffx", + 0, + 0, + NULL, + NULL + }), + "pdftopdffx" + } + } +}; + + +// +// 'ghostscript_autoadd()' - Auto-add printers. +// + +const char * // O - Driver name or `NULL` for none +ghostscript_autoadd(const char *device_info, // I - Device name (unused) + const char *device_uri, // I - Device URI (unused) + const char *device_id, // I - IEEE-1284 device ID + void *data) // I - Global data +{ + pr_printer_app_global_data_t *global_data = + (pr_printer_app_global_data_t *)data; + const char *ret = NULL; // Return value + + + (void)device_info; + (void)device_uri; + + if (device_id == NULL || global_data == NULL) + return (NULL); + + // + // Find the best-matching PPD file to expicitly support our printer model + if (!((ret = prBestMatchingPPD(device_id, global_data)) != 0 || + // No dedicated support for this model, look at the COMMAND + // SET (CMD) key in the device ID for the list of printer + // languages and select a generic driver if we find a + // supported language + (prSupportsPostScript(device_id) && + (ret = prBestMatchingPPD("MFG:Generic;MDL:PostScript Printer;", + global_data)) != 0) || + (prSupportsPCLXL(device_id) && + (ret = prBestMatchingPPD("MFG:Generic;MDL:PCL 6/PCL XL Printer;", + global_data)) != 0) || + (prSupportsPCL5c(device_id) && + (ret = prBestMatchingPPD("MFG:Generic;MDL:PCL 5c Printer;", + global_data)) != 0) || + (prSupportsPCL5(device_id) && + (ret = prBestMatchingPPD("MFG:Generic;MDL:PCL 5e Printer;", + global_data)) != 0))) + // Printer does not support our PDL, it is not supported by this + // Printer Application + ret = NULL; + + return (ret); +} + + +// +// 'main()' - Main entry for the ghostscript-printer-app. +// + +int +main(int argc, // I - Number of command-line arguments + char *argv[]) // I - Command-line arguments +{ + cups_array_t *spooling_conversions, + *stream_formats, + *driver_selection_regex_list; + + // Array of spooling conversions, most desirables first + // + // Here we prefer not converting into another format + // Keeping vector formats (like PS -> PDF) is usually more desirable + // but as many printers have buggy PS interpreters we prefer converting + // PDF to Raster and not to PS + spooling_conversions = cupsArrayNew(NULL, NULL); + + // Special conversion rule for fxlinuxprint driver (Fuji Xerox + // non-IPP-driverless PDF printers) + cupsArrayAdd(spooling_conversions, &ghostscript_convert_pdf_to_fx_pdf); + + // Standard conversion rules + cupsArrayAdd(spooling_conversions, (void *)&PR_CONVERT_PDF_TO_PDF); + cupsArrayAdd(spooling_conversions, (void *)&PR_CONVERT_PDF_TO_RASTER); + cupsArrayAdd(spooling_conversions, (void *)&PR_CONVERT_PDF_TO_PS); + cupsArrayAdd(spooling_conversions, (void *)&PR_CONVERT_PS_TO_PS); + cupsArrayAdd(spooling_conversions, (void *)&PR_CONVERT_PS_TO_PDF); + cupsArrayAdd(spooling_conversions, (void *)&PR_CONVERT_PS_TO_RASTER); + + // Array of stream formats, most desirables first + // + // PDF comes last because it is generally not streamable. + // PostScript comes second as it is Ghostscript's streamable + // input format. + stream_formats = cupsArrayNew(NULL, NULL); + cupsArrayAdd(stream_formats, (void *)&PR_STREAM_CUPS_RASTER); + cupsArrayAdd(stream_formats, (void *)&PR_STREAM_POSTSCRIPT); + cupsArrayAdd(stream_formats, (void *)&PR_STREAM_PDF); + + // Array of regular expressions for driver priorization + // For some printers the "(recommended)" is missing ... + driver_selection_regex_list = cupsArrayNew(NULL, NULL); + cupsArrayAdd(driver_selection_regex_list, "-recommended-"); + cupsArrayAdd(driver_selection_regex_list, "-pdf-"); + cupsArrayAdd(driver_selection_regex_list, "-postscript-"); + cupsArrayAdd(driver_selection_regex_list, "-pxlcolor-"); + cupsArrayAdd(driver_selection_regex_list, "-hpijs-pcl-5-c-"); + cupsArrayAdd(driver_selection_regex_list, "-cljet-5-"); + cupsArrayAdd(driver_selection_regex_list, "-pxl-"); + cupsArrayAdd(driver_selection_regex_list, "-pxlmono-"); + cupsArrayAdd(driver_selection_regex_list, "-lj-5-gray-"); + cupsArrayAdd(driver_selection_regex_list, "-lj-5-mono-"); + cupsArrayAdd(driver_selection_regex_list, "-hl-1250-"); + cupsArrayAdd(driver_selection_regex_list, "-hl-7-x-0-"); + cupsArrayAdd(driver_selection_regex_list, "-hpijs-pcl-5-e-"); + cupsArrayAdd(driver_selection_regex_list, "-pcl-5-"); + cupsArrayAdd(driver_selection_regex_list, "-ljet-4-d-"); + cupsArrayAdd(driver_selection_regex_list, "-ljet-4-"); + cupsArrayAdd(driver_selection_regex_list, "-lj-4-dith"); + cupsArrayAdd(driver_selection_regex_list, "-ljet-3-d-"); + cupsArrayAdd(driver_selection_regex_list, "-ljet-3-"); + cupsArrayAdd(driver_selection_regex_list, "-laserjet-"); + cupsArrayAdd(driver_selection_regex_list, "-ljet-2-p-"); + cupsArrayAdd(driver_selection_regex_list, "-ljetplus-"); + cupsArrayAdd(driver_selection_regex_list, "-pcl-3-"); + + // Configuration record of the Printer Application + pr_printer_app_config_t printer_app_config = + { + SYSTEM_NAME, // Display name for Printer Application + SYSTEM_PACKAGE_NAME, // Package/executable name + SYSTEM_VERSION_STR, // Version as a string + { + SYSTEM_VERSION_ARR_0, // Version 1st number + SYSTEM_VERSION_ARR_1, // 2nd + SYSTEM_VERSION_ARR_2, // 3rd + SYSTEM_VERSION_ARR_3 // 4th + }, + SYSTEM_WEB_IF_FOOTER, // Footer for web interface (in HTML) + PR_COPTIONS_QUERY_PS_DEFAULTS | // pappl-retrofit special features to be + PR_COPTIONS_NO_GENERIC_DRIVER | // used +#if !SNAP + PR_COPTIONS_USE_ONLY_MATCHING_NICKNAMES | +#endif // !SNAP + PR_COPTIONS_NO_PAPPL_BACKENDS | + PR_COPTIONS_CUPS_BACKENDS, + ghostscript_autoadd, // Auto-add (driver assignment) callback + prIdentify, // Printer identify callback + prTestPage, // Test page print callback + NULL, // No extra setup steps for the system + prSetupDeviceSettingsPage, // Set up "Device Settings" printer web + // interface page + spooling_conversions, // Array of data format conversion rules for + // printing in spooling mode + stream_formats, // Arrray for stream formats to be generated + // when printing in streaming mode + "", // CUPS backends to be ignored + "snmp,dnssd,usb", // CUPS backends to be used exclusively + // If empty all but the ignored backends are used + TESTPAGE, // Test page (printable file), used by the + // standard test print callback prTestPage() + " +Foomatic/(.+)$| +(PDF|PXL|PCL5)$", + // Regular expression to separate the + // extra information after make/model in + // the PPD's *NickName. Also extracts a + // contained driver name (by using + // parentheses) + driver_selection_regex_list + // Regular expression for the driver + // auto-selection to prioritize a driver + // when there is more than one for a + // given printer. If a regular + // expression matches on the driver + // name, the driver gets priority. If + // there is more than one matching + // driver, the driver name on which the + // earlier regular expression in the + // list matches, gets the priority. + }; + + return (prRetroFitPrinterApp(&printer_app_config, argc, argv)); +} diff --git a/ghostscript-printer-app.service b/ghostscript-printer-app.service new file mode 100644 index 0000000..0101050 --- /dev/null +++ b/ghostscript-printer-app.service @@ -0,0 +1,10 @@ +[Unit] +Description=Ghostscript Printer Application + +[Service] +ExecStart=ghostscript-printer-app server +ExecStop=ghostscript-printer-app shutdown +Type=simple + +[Install] +WantedBy=multi-user.target diff --git a/patch-files/c2esp-libcupsfilters2-api.patch b/patch-files/c2esp-libcupsfilters2-api.patch new file mode 100644 index 0000000..84aff45 --- /dev/null +++ b/patch-files/c2esp-libcupsfilters2-api.patch @@ -0,0 +1,153 @@ +--- a/src/c2esp.c ++++ b/src/c2esp.c +@@ -44,6 +44,7 @@ + + #if HAVE_CUPSFILTERS_DRIVER_H == 1 + #include //has the dither functions ++#include + #else + #include //has the dither functions + #endif +@@ -522,7 +523,7 @@ + } //end of stripe with print + } + +-void SetUpDither(cups_lut_t *Lut[], cups_dither_t *DitherState[], int LineWidth, int OutBits) ++void SetUpDither(cf_lut_t *Lut[], cf_dither_t *DitherState[], int LineWidth, int OutBits) + { + //Creates Luts and DitherStates for dithering + +@@ -530,14 +531,18 @@ + for(Col=0;Col<3;++Col) + { + //For CMY or RGB +- if(OutBits == 2) Lut[Col] = cupsLutNew(3, default_lut3); +- else Lut[Col] = cupsLutNew(2, default_lut2); +- DitherState[Col] = cupsDitherNew(LineWidth); ++ if(OutBits == 2) Lut[Col] = cfLutNew(3, default_lut3, ++ cfCUPSLogFunc, NULL); ++ else Lut[Col] = cfLutNew(2, default_lut2, ++ cfCUPSLogFunc, NULL); ++ DitherState[Col] = cfDitherNew(LineWidth); + } + //For Kk +- if(OutBits == 2) Lut[3] = cupsLutNew(5, default_lut5); +- else Lut[3] = cupsLutNew(3, default_lut3); +- DitherState[3] = cupsDitherNew(LineWidth); ++ if(OutBits == 2) Lut[3] = cfLutNew(5, default_lut5, ++ cfCUPSLogFunc, NULL); ++ else Lut[3] = cfLutNew(3, default_lut3, ++ cfCUPSLogFunc, NULL); ++ DitherState[3] = cfDitherNew(LineWidth); + } + + unsigned char Dithered8ToPrint(unsigned char *Buffer, int x, int Level) +@@ -672,7 +677,7 @@ + + + void +-Terminate(cups_raster_t *ras,int fd,cups_dither_t **DitherState,cups_lut_t **Lut) ++Terminate(cups_raster_t *ras,int fd,cf_dither_t **DitherState,cf_lut_t **Lut) + { + int CloseError, Col; + +@@ -691,8 +696,8 @@ + //free the dither states + for(Col = 0; Col < 4 ;++Col) + { +- cupsDitherDelete(DitherState[Col]); +- cupsLutDelete(Lut[Col]); ++ cfDitherDelete(DitherState[Col]); ++ cfLutDelete(Lut[Col]); + } + /* + * Termination, send an error message if required... +@@ -782,7 +787,7 @@ + } + } + +-void DitherProcess(cups_lut_t **Lut, cups_dither_t **DitherState, cups_page_header2_t *header, int Col, int *BlankColour) ++void DitherProcess(cf_lut_t **Lut, cf_dither_t **DitherState, cups_page_header2_t *header, int Col, int *BlankColour) + { + //convert the bits in CupsLineBuffer to short ints in DitherInputBuffer for the current colour + //checking if it's blank as we go +@@ -833,7 +838,7 @@ + //if(y == 0) DoLog("Dither stage colour %d line %d\n", Col, y); + if(*BlankColour==0) + { +- cupsDitherLine(DitherState[Col], Lut[Col], DitherInputBuffer, 1, DitherOutputBuffer); ++ cfDitherLine(DitherState[Col], Lut[Col], DitherInputBuffer, 1, DitherOutputBuffer); + // full scale input is 4095. output is the index in the lut. + } + if(Col == MonitorColour) //0=cyan 1=mag 2=yellow 3=black +@@ -944,8 +949,8 @@ + ppd_file_t *ppd; /* PPD file */ + cups_raster_t *ras; /* Raster stream from cups */ + cups_page_header2_t header; /* Page header from cups */ +- cups_cmyk_t *cmykTrans300; /* cmyk transform for cups 300dpi*/ +- cups_cmyk_t *cmykTrans600; /* cmyk transform for cups 600dpi*/ ++ cf_cmyk_t *cmykTrans300 = NULL; /* cmyk transform for cups 300dpi*/ ++ cf_cmyk_t *cmykTrans600 = NULL; /* cmyk transform for cups 600dpi*/ + int RemainingPixels; + int Stripe, y; + int StripeEnd; //index of last byte in current stripe +@@ -953,8 +958,8 @@ + int Col,i,x; + int BlankColour; //boolean to record if the line is blank to save time + int argi; +- cups_lut_t *Lut[4]; /* Dither lookup tables */ +- cups_dither_t *DitherState[4]; /* Dither states */ ++ cf_lut_t *Lut[4]; /* Dither lookup tables */ ++ cf_dither_t *DitherState[4]; /* Dither states */ + long RasForCompHeight; + + StartTime = time(NULL); +@@ -1042,8 +1047,10 @@ + if(ppd) + { + DoLog("Opened ppd OK. Reading from ppd\n",0,0); +- cmykTrans300 = cupsCMYKLoad(ppd, "RGB", "", "300x1200dpi"); +- cmykTrans600 = cupsCMYKLoad(ppd, "RGB", "", "600x1200dpi"); ++ cmykTrans300 = ppdCMYKLoad(ppd, "RGB", "", "300x1200dpi", ++ cfCUPSLogFunc, NULL); ++ cmykTrans600 = ppdCMYKLoad(ppd, "RGB", "", "600x1200dpi", ++ cfCUPSLogFunc, NULL); + ppdClose(ppd); + DoLog("InkChannels 300dpi=%d 600dpi=%d\n",cmykTrans300->num_channels,cmykTrans600->num_channels); + } +@@ -1233,8 +1240,8 @@ + if (header.cupsColorSpace == CUPS_CSPACE_RGB) + { + if(y == 0) DoLog("Doing transform & dither (CMYK) stripe %d line %d\n", Stripe, y); +- if(header.HWResolution[0] == 300) cupsCMYKDoRGB(cmykTrans300, CupsLineBuffer, TransformedBuffer, RemainingPixels); +- else cupsCMYKDoRGB(cmykTrans600, CupsLineBuffer, TransformedBuffer, RemainingPixels); ++ if(header.HWResolution[0] == 300) cfCMYKDoRGB(cmykTrans300, CupsLineBuffer, TransformedBuffer, RemainingPixels); ++ else cfCMYKDoRGB(cmykTrans600, CupsLineBuffer, TransformedBuffer, RemainingPixels); + // cupsDoRGB scales up to 4096 a short int from the unsigned char input 255 + for(Col = 0; Col<4; ++Col) + { +--- a/configure.ac ++++ b/configure.ac +@@ -19,14 +19,19 @@ + AC_CHECK_LIB(cups, ppdOpenFile) + + #-lcupsdriver for cups < ver 1.6 +-AC_SEARCH_LIBS(cupsDitherNew, cupsdriver cupsfilters) +-if test "$ac_cv_search_cupsDitherNew" = "-lcupsdriver"; then : ++AC_SEARCH_LIBS(cfDitherNew, cupsdriver cupsfilters) ++if test "$ac_cv_search_cfDitherNew" = "-lcupsdriver"; then : + HAVE_LIBCUPSDRIVER="1" + fi +-if test "$ac_cv_search_cupsDitherNew" = "-lcupsfilters"; then : ++if test "$ac_cv_search_cfDitherNew" = "-lcupsfilters"; then : + HAVE_LIBCUPSFILTERS="1" + fi + ++AC_SEARCH_LIBS(ppdCMYKLoad, ppd) ++if test "$ac_cv_search_ppdCMYKLoad" = "-lppd"; then : ++ HAVE_LIBPPD="1" ++fi ++ + AC_SEARCH_LIBS(cupsRasterOpen, cupsimage cupsfilters cups) + if test "$ac_cv_search_cupsRasterOpen" != "no"; then : + HAVE_LIBCUPSIMAGE="1" diff --git a/patch-files/cups-dnssd-backend-socket-only.patch b/patch-files/cups-dnssd-backend-socket-only.patch new file mode 100644 index 0000000..ccaa3a1 --- /dev/null +++ b/patch-files/cups-dnssd-backend-socket-only.patch @@ -0,0 +1,36 @@ +diff --git a/backend/dnssd.c b/backend/dnssd.c +index e57029178..77c7724b3 100644 +--- a/backend/dnssd.c ++++ b/backend/dnssd.c +@@ -297,8 +297,8 @@ main(int argc, /* I - Number of command-line args */ + return (0); + } + +- browsers = 6; +- avahi_service_browser_new(client, AVAHI_IF_UNSPEC, ++ browsers = /*6*/1; ++ /*avahi_service_browser_new(client, AVAHI_IF_UNSPEC, + AVAHI_PROTO_UNSPEC, + "_fax-ipp._tcp", NULL, 0, + browse_callback, devices); +@@ -313,17 +313,17 @@ main(int argc, /* I - Number of command-line args */ + avahi_service_browser_new(client, AVAHI_IF_UNSPEC, + AVAHI_PROTO_UNSPEC, + "_ipps._tcp", NULL, 0, +- browse_callback, devices); ++ browse_callback, devices);*/ + avahi_service_browser_new(client, AVAHI_IF_UNSPEC, + AVAHI_PROTO_UNSPEC, + "_pdl-datastream._tcp", + NULL, 0, + browse_callback, + devices); +- avahi_service_browser_new(client, AVAHI_IF_UNSPEC, ++ /*avahi_service_browser_new(client, AVAHI_IF_UNSPEC, + AVAHI_PROTO_UNSPEC, + "_printer._tcp", NULL, 0, +- browse_callback, devices); ++ browse_callback, devices);*/ + #endif /* HAVE_AVAHI */ + + /* diff --git a/rockcraft.yaml b/rockcraft.yaml new file mode 100644 index 0000000..2496feb --- /dev/null +++ b/rockcraft.yaml @@ -0,0 +1,1475 @@ +name: ghostscript-printer-app +base: ubuntu@22.04 +version: '10.03.0-9' +summary: Ghostscript Printer Application +description: | + The Ghostscript Printer Application is a PAPPL (Printer Application + Framework) based Printer Application to support printers using + Ghostscript's built-in printer drivers (and some extra filters). + +adopt-info: ghostscript + +# Only build on the architectures supported +platforms: + arm64: + amd64: + armhf: + +services: + dbus: + command: /scripts/run-dbus.sh + override: replace + on-failure: restart + startup: enabled + + ghostscript-printer-app: + command: ghostscript-printer-app -o log-file=/ghostscript-printer-app.log server + override: replace + on-failure: restart + startup: enabled + after: [dbus] + +parts: + pappl: + source: https://github.com/michaelrsweet/pappl + source-type: git + source-tag: 'v1.4.6' + source-depth: 1 +# ext:updatesnap +# version-format: +# lower-than: '2' +# no-9x-revisions: true + plugin: autotools + override-build: | + set -eux + # Raise the supported number of vendor-specific options/attributes in + # PAPPL to 256, as the original 32 can be too small for some busy PPD + # files + perl -p -i -e 's/(define\s+PAPPL_MAX_VENDOR\s+)32/\1 256/' pappl/printer.h + # De-activate log-rotating. It does not work with the forked processes + # of the filters + perl -p -i -e 's/(system->logmaxsize\s+=).*/\1 0;/' pappl/system.c + # As we do not use PAPPL's own backends but the CUPS backends using the + # "cups" device scheme of pappl-retrofit, we let the manual "Network + # Printer" device on the "Add Printer" page of the web interface use a + # "cups:socket://..." URI instead of simply "socket://..." + perl -p -i -e 's/(httpAssembleURI\(.*?)"socket"(.*?\))/\1"cups:socket"\2/' pappl/system-webif.c + # PAPPL's build system does not insert the LDFLAGS when linking. + # Patching Makedefs.in to fix this + perl -p -i -e 's/^(\s*DSOFLAGS\s*=\s*\S*\s+)/\1\$\(LDFLAGS\) /' Makedefs.in + craftctl default + autotools-configure-parameters: + - --prefix=/usr + - --enable-libjpeg + - --enable-libpng + - --enable-libusb + - --with-dnssd=avahi + build-packages: + - libavahi-client-dev + - libgnutls28-dev + - libjpeg-dev + - libpam0g-dev + - libpng-dev + - libusb-1.0-0-dev + - zlib1g-dev + - perl-base + stage-packages: + # We have libavahi-client3 already in this Snap via the "cups" part, + # so here we do not stage it again to avoid any file clashes. + #- libavahi-client3 + - libpng16-16 + - libusb-1.0-0 + prime: + - -etc/fonts + - -var + - lib/*/lib*.so* + - usr/lib/lib*.so* + - usr/lib/*/lib*.so* + - -usr/include + - -usr/lib/pkgconfig + - -usr/share/fonts + - -usr/share/man + - -usr/share/doc + - -usr/share/doc-base + - -usr/share/lintian + after: [cups] + + pappl-retrofit: + source: https://github.com/openprinting/pappl-retrofit + source-type: git + # source-tag: '1.0b2' + source-depth: 1 +# ext:updatesnap +# version-format: +# ignore: true +# format: '%V' + plugin: autotools + autotools-configure-parameters: + - --prefix=/usr + # To find the libraries built in this Snap + build-environment: + - LD_LIBRARY_PATH: "${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}$CRAFT_STAGE/usr/lib" + build-packages: + - autoconf + - automake + - libtool + - autotools-dev + - pkg-config + - perl-base + stage-packages: + - libusb-1.0-0 + organize: + usr/share/legacy-printer-app/testpage.pdf: usr/share/ghostscript-printer-app/testpage.pdf + prime: + - lib/*/lib*.so* + - usr/lib/lib*.so* + - usr/lib/*/lib*.so* + - usr/share/ghostscript-printer-app/testpage.pdf + - -var + - -usr/var + - -usr/bin/legacy-printer-app + - -usr/include + - -usr/lib/pkgconfig + - -usr/lib/legacy-printer-app + - -usr/share/legacy-printer-app + - -usr/share/fonts + - -usr/share/man + - -usr/share/doc + - -usr/share/doc-base + - -usr/share/lintian + after: [cups, pappl, libcupsfilters, libppd] + + qpdf: + source: https://github.com/qpdf/qpdf + source-type: git + source-tag: 'v11.9.1' + source-depth: 1 +# ext:updatesnap +# version-format: +# lower-than: '12' +# no-9x-revisions: true + plugin: cmake + cmake-parameters: + - -DCMAKE_INSTALL_PREFIX=/ + - -DCMAKE_BUILD_RPATH_USE_ORIGIN=1 + - -DUSE_IMPLICIT_CRYPTO=0 + - -DREQUIRE_CRYPTO_GNUTLS=1 + - -DSHOW_FAILED_TEST_OUTPUT=1 + - -DCMAKE_BUILD_TYPE=RelWithDebInfo + - -DQTEST_COLOR=0 + build-packages: + - cmake + - g++ + - libjpeg-dev + - zlib1g-dev + - libgnutls28-dev + stage-packages: + - libjpeg-turbo8 + stage: + # The *.la file which gets installed by "make install" contains a + # wrong prefix, breaking parts of this Snap which use this library + - -usr/lib/lib*.la + prime: + - lib/*/lib*.so* + - usr/lib/lib*.so* + - usr/lib/*/lib*.so* + - -etc/fonts + - -var + - -usr/include + - -share/man + - -share/doc + - -share/lintian + - -usr/share/fonts + - -usr/share/man + - -usr/share/doc + - -usr/share/doc-base + - -usr/share/lintian + - -usr/lib/libqpdf.a + - -usr/lib/libqpdf.la + - -usr/lib/pkgconfig + + ghostscript: + #source: https://git.ghostscript.com/ghostpdl.git + source: https://github.com/ArtifexSoftware/ghostpdl.git + source-type: git + source-tag: 'ghostpdl-10.03.0rc1_test' + source-depth: 1 +# ext:updatesnap +# version-format: +# format: "ghostpdl-%M.%m.%R" +# lower-than: '11' +# no-9x-revisions: true + plugin: autotools + # As this Printer Application supports Ghostscript's built-in drivers, + # we build them all. + autotools-configure-parameters: + - --prefix=/usr + - --without-x + - --disable-gtk + - --with-drivers=ALL + - --enable-freetype + - --without-tesseract + build-packages: + - curl + stage-packages: + - libpaper1 + - libfontconfig1 + - libfreetype6 + - libpng16-16 + prime: + - usr/bin/gs + - lib/*/lib*.so* + - usr/lib/*/lib*.so* + - usr/share/ghostscript + - -etc/fonts + - -var + - -usr/include + - -usr/lib/pkgconfig + - -usr/share/fonts + - -usr/share/man + - -usr/share/doc + - -usr/share/doc-base + - -usr/share/lintian + after: [cups] + + cups: + source: https://github.com/OpenPrinting/cups + source-type: git + source-tag: 'v2.4.10' + source-depth: 1 +# ext:updatesnap +# version-format: +# lower-than: '3' +# no-9x-revisions: true + plugin: autotools + # We only need libcups (with headers, ...), the rastertoepson, + # rastertohp, and rastertolabel filters (for the PCL-5 PPD files from + # Ricoh and OEM, and for sample.drv PPDs), the backends, and the + # sample.drv file + override-build: | + set -eux + patch -p1 < $CRAFT_PROJECT_DIR/patch-files/cups-dnssd-backend-socket-only.patch + # 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. + ./configure --with-tls=gnutls + cd cups + make + cd .. + cd filter + make rastertoepson + make rastertohp + make rastertolabel + cd .. + cd backend + # Have USB quirk files in user-modifiable space for debugging + perl -p -i -e 's/"CUPS_DATADIR"/"USB_QUIRK_DIR"/' usb-libusb.c + make snmp dnssd socket ipp ipps lpd usb + cd .. + mkdir -p $CRAFT_PART_INSTALL/usr/lib + cp cups/libcups*.a $CRAFT_PART_INSTALL/usr/lib/ + cp -P cups/libcups*.so* $CRAFT_PART_INSTALL/usr/lib/ + mkdir -p $CRAFT_PART_INSTALL/usr/include/cups + cp cups/*.h $CRAFT_PART_INSTALL/usr/include/cups/ + mkdir -p $CRAFT_PART_INSTALL/usr/bin + cp cups-config $CRAFT_PART_INSTALL/usr/bin/ + mkdir -p $CRAFT_PART_INSTALL/usr/lib/ghostscript-printer-app/filter + cp filter/rastertoepson $CRAFT_PART_INSTALL/usr/lib/ghostscript-printer-app/filter + cp filter/rastertohp $CRAFT_PART_INSTALL/usr/lib/ghostscript-printer-app/filter + cp filter/rastertolabel $CRAFT_PART_INSTALL/usr/lib/ghostscript-printer-app/filter + mkdir -p $CRAFT_PART_INSTALL/usr/lib/ghostscript-printer-app/backend/ + ( cd backend; \ + cp snmp dnssd socket ipp ipps lpd usb org.cups.usb-quirks $CRAFT_PART_INSTALL/usr/lib/ghostscript-printer-app/backend/ \ + ) + cp conf/snmp.conf $CRAFT_PART_INSTALL/usr/lib/ghostscript-printer-app/backend/ + mkdir -p $CRAFT_PART_INSTALL/usr/share/ppd + cp ppdc/sample.drv $CRAFT_PART_INSTALL/usr/share/ppd/cups.drv + build-packages: + - patch + - gettext + - autoconf + - automake + - libtool + - autotools-dev + - pkg-config + - libavahi-client-dev + - libavahi-common-dev + - libavahi-compat-libdnssd-dev + - libdbus-1-dev + - libfontconfig1-dev + - libfreetype6-dev + - libgnutls28-dev + - libjpeg-dev + - libldap2-dev + - libkrb5-dev + - libpam0g-dev + - libpaper-dev + - libpng-dev + - libusb-1.0-0-dev + - perl-base + stage-packages: + - libusb-1.0-0 + - libavahi-common3 + - libavahi-client3 + - libicu70 + prime: + - -etc/fonts + - -var + - -usr/include + - -usr/lib/pkgconfig + - -usr/share/fonts + - -usr/share/man + - -usr/share/doc + - -usr/share/doc-base + - -usr/share/lintian + - lib/*/lib*.so* + - usr/lib/lib*.so* + - usr/lib/*/lib*.so* + - usr/share/ppd/cups.drv + - usr/lib/ghostscript-printer-app/filter/* + - usr/lib/ghostscript-printer-app/backend/* + # Reported unused by snapcraft linter + - -usr/lib/*/libdconf.* + - -usr/lib/*/libicuio.* + - -usr/lib/*/libicutest.* + - -usr/lib/*/libicutu.* + - -usr/lib/*/libicuuc.* + - -usr/lib/*/libicui18n.* + + libcupsfilters: + source: https://github.com/OpenPrinting/libcupsfilters + source-type: git + source-tag: '2.0.0' + source-depth: 1 +# ext:updatesnap +# version-format: +# lower-than: '3' +# no-9x-revisions: true + plugin: autotools + # We only need libcupsfilters itself. so we simply do not prime the + # auxiliary files (/usr/share) + autotools-configure-parameters: + - --prefix=/usr + - --disable-avahi + - --disable-mutool + build-packages: + - gettext + - autoconf + - automake + - autotools-dev + - pkg-config + - g++ + - sharutils + - liblcms2-dev + - libpoppler-cpp-dev + - libpng-dev + - libjpeg-dev + - libtiff5-dev + - zlib1g-dev + - libfontconfig1-dev + - libdbus-1-dev + - libexif-dev + stage-packages: + - libpoppler-cpp0v5 + - libjbig0 + - liblcms2-2 + - libnspr4 + - libnss3 + - libopenjp2-7 + - libpoppler118 + - libtiff5 + - libwebp7 + - libexif12 + stage: + # The *.la file which gets installed by "make install" contains a + # wrong prefix, breaking parts of this Snap which use this library + - -usr/lib/lib*.la + prime: + - -etc + - -var + - -usr/include + - -usr/lib/pkgconfig + - usr/share/cups + - -usr/share/fonts + - -usr/share/man + - -usr/share/doc + - -usr/share/doc-base + - -usr/share/lintian + - lib/*/lib*.so* + - usr/lib/lib*.so* + - usr/lib/*/lib*.so* + - usr/lib/*/nss + # Reported unused by snapcraft linter + - -usr/lib/*/libssl3.* + after: [cups, qpdf, ghostscript] + + libppd: + source: https://github.com/OpenPrinting/libppd + source-type: git + source-tag: '2.0.0' + source-depth: 1 +# ext:updatesnap +# version-format: +# lower-than: '3' +# no-9x-revisions: true + plugin: autotools + # We need libppd itself, the PPD compiler ppdc and its auxiliary files + # (/usr/share/ppdc/) + autotools-configure-parameters: + - --prefix=/usr + - --disable-mutool + - --disable-pdftocairo + - --disable-acroread + - --enable-ppdc-utils + # To find the libraries built in this Snap + build-environment: + - LD_LIBRARY_PATH: "${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}$CRAFT_STAGE/usr/lib" + build-packages: + - gettext + - autoconf + - automake + - autotools-dev + - pkg-config + - g++ + - sharutils + - poppler-utils + prime: + - -etc + - -var + - -usr/bin/ppdc + - -usr/include + - -usr/lib/pkgconfig + - -usr/share/fonts + - -usr/share/man + - -usr/share/doc + - -usr/share/doc-base + - -usr/share/lintian + - lib/*/lib*.so* + - usr/lib/lib*.so* + - usr/lib/*/lib*.so* + - usr/lib/*/nss + - usr/share/ppdc/* + after: [cups, ghostscript, libcupsfilters] + + cups-filters: + source: https://github.com/OpenPrinting/cups-filters + source-type: git + source-tag: '2.0.0' + source-depth: 1 +# ext:updatesnap +# version-format: +# lower-than: '3' +# no-9x-revisions: true + plugin: autotools + # To find the libraries built in this Snap + build-environment: + - LD_LIBRARY_PATH: "${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}$CRAFT_STAGE/usr/lib" + # We need foomatic-rip (for the Foomatic PPDs for the Ghostscript drivers + # and also for the PCL-XL PPDs from Ricoh and OEM), gstoraster (for SpliX), + # the rastertoepson, rastertopclx (for the included PPD files), and also + # all PPD and *.drv files + override-build: | + set -eux + ./autogen.sh + ./configure --disable-mutool --enable-ppdc-utils + make foomatic-rip + make gstoraster + make pdftops + make rastertoescpx + make rastertopclx + mkdir -p $CRAFT_PART_INSTALL + cp foomatic-rip $CRAFT_PART_INSTALL + cp gstoraster $CRAFT_PART_INSTALL + cp pdftops $CRAFT_PART_INSTALL + cp rastertoescpx $CRAFT_PART_INSTALL + cp rastertopclx $CRAFT_PART_INSTALL + mkdir -p $CRAFT_PART_INSTALL/usr/share/ppdc + cp filter/escp.h filter/pcl.h $CRAFT_PART_INSTALL/usr/share/ppdc/ + # Compile cupsfilters.drv into PPD files + $CRAFT_STAGE/usr/bin/ppdc -I $CRAFT_PART_INSTALL/usr/share/ppdc -I $CRAFT_STAGE/usr/share/ppdc -d ppd drv/cupsfilters.drv + # Remove PPD files which are not useful in the Printer Application + rm -f ppd/test.ppd ppd/test2.ppd ppd/textonly.ppd + # Compress the included PPD files, both ready-made and compiled + cp ppdfiles/*.ppd ppd + pyppd -v -o cups-filters-ppds ppd + rm -rf ppd + mkdir -p $CRAFT_PART_INSTALL/usr/share/ppd + mv cups-filters-ppds $CRAFT_PART_INSTALL/usr/share/ppd + build-packages: + - gettext + - autoconf + - automake + - autotools-dev + - pkg-config + - g++ + - sharutils + - pyppd + stage-packages: + - poppler-utils + organize: + foomatic-rip: usr/lib/ghostscript-printer-app/filter/foomatic-rip + gstoraster: usr/lib/ghostscript-printer-app/filter/gstoraster + pdftops: usr/lib/ghostscript-printer-app/filter/pdftops + rastertoescpx: usr/lib/ghostscript-printer-app/filter/rastertoescpx + rastertopclx: usr/lib/ghostscript-printer-app/filter/rastertopclx + prime: + - -etc/fonts + - -var + - -usr/include + - -usr/lib/pkgconfig + - -usr/share/fonts + - -usr/share/man + - -usr/share/doc + - -usr/share/doc-base + - -usr/share/lintian + - lib/*/lib*.so* + - usr/lib/lib*.so* + - usr/lib/*/lib*.so* + - usr/lib/*/nss + - usr/bin/pdftops + - usr/lib/ghostscript-printer-app + - usr/share/ppd/cups-filters-ppds + - usr/share/ppdc/* + # Reported unused by snapcraft linter + - -usr/lib/*/libcairo.* + - -usr/lib/*/libssl3.* + - -usr/lib/*/libX11.* + - -usr/lib/*/libXau.* + - -usr/lib/*/libXdmcp.* + - -usr/lib/*/libXext.* + - -usr/lib/*/libXrender.* + - -usr/lib/*/libpixman-1.* + - -usr/lib/*/libxcb.* + - -usr/lib/*/libxcb-render.* + - -usr/lib/*/libxcb-shm.* + after: [cups, qpdf, ghostscript, pyppd, libcupsfilters, libppd] + + pyppd: + source: https://github.com/OpenPrinting/pyppd + source-type: git + source-tag: 'release-1-1-0' + source-depth: 1 +# ext:updatesnap +# version-format: +# format: 'release-%M-%m-%R' +# lower-than: '2' +# no-9x-revisions: true + plugin: python + build-packages: + - python3.10 + stage-packages: + - python3.10 + override-prime: "" + + foomatic-db: + source: https://github.com/OpenPrinting/foomatic-db + source-type: git + source-tag: '20240504' + source-depth: 1 +# ext:updatesnap +# version-format: +# format: '%V' + plugin: nil + override-build: | + set -eux + ./make_configure + ./configure --disable-ppds-to-cups --disable-gzip-ppds --prefix=/usr --with-drivers=NOOBSOLETES,NOEMPTYCMDLINE + make DESTDIR=`pwd`/../install install + cd ../install + # Remove all PostScript PPDs, these printers are supported by the + # PostScript Printer Application + rm usr/share/foomatic/db/source/PPD/*/*.ppd + rm -rf usr/share/foomatic/db/source/PPD/Kyocera + rm -rf usr/share/foomatic/db/source/PPD/Utax + rm -rf usr/share/foomatic/db/source/PPD/Oce + rm -rf usr/share/foomatic/db/source/PPD/*/PS + # Remove executable bits on the files + find usr/share/foomatic/db -executable -type f -print0 | xargs -0 chmod -x || : + # Remove non-PPD files from the PPD file directories + find usr/share/foomatic/db/source/PPD -type f \! -name '*.ppd' -print0 | xargs -0 rm || : + # Correct common errors in PPD files: "*CloseUI" without ':' and + # "*1284DeviceId" instead of "*1284DeviceID" + for f in `find usr/share/foomatic/db/source/PPD -name '*.ppd'`; do perl -p -i -e 's/^\*CloseUI(\s+)/*CloseUI:\1/' $f; perl -p -i -e 's/\*1284DeviceId/*1284DeviceID/' $f; done + # Remove drivers which need external filters we cannot get hold on + # Note that the "./configure; make install" process of foomatic-db + # already removed driver entries marked obsolete and entries without + # driver command line prototype. + ( cd usr/share/foomatic/db/source/driver; \ + rm bjc800j.xml; \ + rm c2070.xml; \ + rm drv_x125.xml; \ + rm lm1100.xml; \ + rm lpstyl.xml; \ + rm ml85p.xml; \ + rm pbm2l2030.xml; \ + rm pbm2l7k.xml; \ + rm pbm2lwxl.xml; \ + rm pentaxpj.xml; \ + rm ppmtomd.xml; \ + ) + # Pre-build all PPDs from the Foomatic XML data + FOOMATICDB=usr/share/foomatic foomatic-compiledb -j 4 -t ppd -d ppd `ls -1 usr/share/foomatic/db/source/driver/*.xml | perl -p -e 's:^.*db/source/driver/(\S*)\.xml\s*$:\1\n:'` + # Compress the Foomatic PPDs in a self-extracting archive + pyppd -v -o foomatic-ppds ppd + rm -rf ppd + # Compress the manufacturer PPDs in a self-extracting archive + mv usr/share/foomatic/db/source/PPD ppd + pyppd -v -o manufacturer-ppds ppd + build-packages: + - perl-base + - python3 + - xz-utils + - foomatic-db-engine + - python3.10 + - pyppd + stage-packages: + - python3 + - xz-utils + - python3.10 + organize: + foomatic-ppds: usr/share/ppd/foomatic-ppds + manufacturer-ppds: usr/share/ppd/manufacturer-ppds + stage: + - usr/bin + - usr/share/ppd + prime: + - usr/bin/xz + - -usr/bin/pdb3 + - -usr/bin/pydoc3 + - -usr/bin/pygettext3 + - usr/share/ppd + after: [pyppd] + + hplip: + # We need only the hpijs executable (for the Foomatic PPDs HPIJS is used + # here for non-HP PCL 5c/e printers, works better than Ghostscript's + # built-in drivers + # + # We use the Debian package source instead of the upstream source code + # of HPLIP as the Debian package has ~80 patches fixing bugs which are + # reported upstream but the patches not adopted upstream. + # This way we should have the same user experience in terms of reliability + # and quality as with the Debian package. + # Note that the repository has all patches already applied, so we do + # not need to apply them before building. + # Debian source + source: https://salsa.debian.org/printing-team/hplip.v2.git + source-type: git + source-tag: 'debian/3.22.10+dfsg0-5' +# ext:updatesnap +# version-format: +# format: 'debian/%V' + source-depth: 1 + # Upstream source + #source: https://sourceforge.net/projects/hplip/files/hplip/3.22.10/hplip-3.22.10.tar.gz + plugin: autotools + build-environment: + - PYTHON: python3 + - LD_LIBRARY_PATH: $CRAFT_STAGE/usr/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} + - CUPS_DATADIR: $CRAFT_STAGE/usr/share/cups + - on arm64: + - BUILDARCH: aarch64-unknown-linux-gnu + - else: + - BUILDARCH: $CRAFT_ARCH_TRIPLET + # Paremeter list here only needed for upstream source, but no need to + # comment out for Debian source + autotools-configure-parameters: + - --build=$BUILDARCH + - --prefix=/usr + - --disable-foomatic-rip-hplip-install + - --without-docdir + - --without-htmldir + - --without-hpppddir + - --without-drvdir + - --without-icondir + - --disable-hpcups-install + - --disable-cups-drv-install + - --disable-cups-ppd-install + - --enable-hpijs-install + - --disable-foomatic-drv-install + - --disable-foomatic-ppd-install + - --enable-network-build + - --disable-class-driver + - --disable-scan-build + - --disable-gui-build + - --disable-fax-build + - --disable-qt3 + - --disable-qt4 + - --disable-qt5 + - --disable-policykit + # We need only the hpijs executable + override-build: | + set -eux + # Correct hard-coded /etc/hp/ path in Makefile + perl -p -i -e 's:/etc/hp:/ghostscript-printer-app/current/etc/hp:' Makefile* + # Do the "./configure" (for Debian source) + sh debian/autogen.sh + ./configure \ + --build=$BUILDARCH \ + --prefix=/usr \ + --disable-foomatic-rip-hplip-install \ + --without-docdir \ + --without-htmldir \ + --without-hpppddir \ + --without-drvdir \ + --without-icondir \ + --disable-hpcups-install \ + --disable-cups-drv-install \ + --disable-cups-ppd-install \ + --enable-hpijs-install \ + --disable-foomatic-drv-install \ + --disable-foomatic-ppd-install \ + --enable-network-build \ + --disable-class-driver \ + --disable-scan-build \ + --disable-gui-build \ + --disable-fax-build \ + --disable-qt3 \ + --disable-qt4 \ + --disable-qt5 \ + --disable-policykit + # Following step needed because of the Debian patches (for Debian source) + # Compress various files before building, they are needed for the build, + # and were compressed in the non-repacked upstream tarballs + find . -name '*.ppd' | xargs gzip -f + find data/ -regextype posix-extended -regex '.*\.(ldl|pcl|ps|pdf)' | xargs gzip -f + # Following step needed because of the Debian patches (for Debian source) + # Rebuild the .drv.in files from drv.in.template + python3 ./dat2drv.py + # Correct hard-coded paths in C/C++ source code + # The /etc/... and /usr/... paths in these files do not need to get + # corrected, only the /var/... ones + perl -p -i -e 's:\"/var/lib/hp:\"/var/ghostscript-printer-app/common/var/:' common/utils.[ch] + # Do the "./configure; make; make install" (for upstream source) + # craftctl default + # Do the "make; make install" (for Debian source) + make + make DESTDIR=`pwd`/../install install + # Correct hard-coded paths in hplip.conf + ( cd ../install/ghostscript-printer-app/current/etc/hp; \ + perl -p -i -e 's:/var/:/var/ghostscript-printer-app/common/var/:' hplip.conf; \ + perl -p -i -e 's:/usr/share/:/ghostscript-printer-app/current/usr/share/:' hplip.conf; \ + perl -p -i -e 's:/usr/share/ppd/hplip:/usr/share/ppd:' hplip.conf; \ + perl -p -i -e 's:/usr/share/ppd/HP:/usr/share/ppd:' hplip.conf; \ + perl -p -i -e 's:/usr/lib/cups/:/ghostscript-printer-app/current/usr/lib/ghostscript-printer-app/:' hplip.conf; \ + ) + build-packages: + - ubuntu-dev-tools + - dpkg-dev + - fakeroot + - autoconf + - automake + - gawk + - python3-dev + - libpython3-dev + - fdupes + - libavahi-client-dev + - libavahi-core-dev + - libdbus-1-dev + - libjpeg-dev + - libsnmp-dev + - libssl-dev + - libtool + - libudev-dev + - libusb-1.0-0-dev + - perl-base + - python3 + - xz-utils + - pyppd + - python3-dev + stage-packages: + - libsnmp40 + - python3-dev + organize: + ghostscript-printer-app/current/etc/hp/hplip.conf: etc/hp/hplip.conf + prime: + - etc/hp/hplip.conf + - usr/bin/hpijs + - lib/*/lib*.so* + - usr/lib/lib*.so* + - usr/lib/*/lib*.so* + # Reported unused by snapcraft linter + - -usr/lib/libhpipp.* + - -usr/lib/*/libgdbm.* + - -usr/lib/*/libgdbm_compat.* + - -usr/lib/*/libnetsnmpagent.* + - -usr/lib/*/libnetsnmpmibs.* + - -usr/lib/*/libpci* + - -usr/lib/*/libperl.* + - -usr/lib/*/libsensors.* + - -usr/lib/*/libsnmp.* + after: [cups, cups-filters] + + # Unmaintained printer drivers which come as a filter to convert generic + # raster output of GhostScript into the printer's data format. The PPDs + # for these drivers come as part of Foomatic, so we build and install + # only the filters here. + + c2050: + # Upstream source is not available any more, using Debian packaging + # GIT instead + source: https://salsa.debian.org/printing-team/c2050.git + source-type: git + source-tag: 'debian/0.3-7' + source-depth: 1 +# ext:updatesnap +# version-format: +# format: 'debian/%V' + plugin: make + override-build: | + set -eux + make -j2 + mkdir -p $CRAFT_PART_INSTALL/usr/bin + cp c2050 $CRAFT_PART_INSTALL/usr/bin + stage-packages: + - libjbig0 + - libjpeg-turbo8 + - libpng16-16 + - libtiff5 + - libwebp7 + prime: + - usr/bin/c2050 + - lib/*/lib*.so* + - usr/lib/lib*.so* + - usr/lib/*/lib*.so* + + cjet: + # Upstream source is not available any more, using Debian packaging + # GIT instead + source: https://salsa.debian.org/printing-team/cjet.git + source-type: git + source-tag: 'debian/0.8.9-11' + source-depth: 1 +# ext:updatesnap +# version-format: +# format: 'debian/%V' + plugin: make + override-build: | + set -eux + make -j2 + mkdir -p $CRAFT_PART_INSTALL/usr/bin + cp cjet $CRAFT_PART_INSTALL/usr/bin + prime: + - usr/bin/cjet + + min12xxw: + # Upstream source is still available but to include Debian's patches, we + # are using Debian packaging GIT instead + # Original homepage: http://www.hinterbergen.de/mala/min12xxw/ + source: https://salsa.debian.org/printing-team/min12xxw.git + source-type: git + source-tag: debian/0.0.9-11 + source-depth: 1 +# ext:updatesnap +# version-format: +# format: 'debian/%V' + plugin: autotools + autotools-configure-parameters: + - --prefix=/usr + override-build: | + set -eux + # Refresh build system, because of the Debian patches + autoreconf --install + craftctl default + build-packages: + - autoconf + prime: + - usr/bin/min12xxw + + pnm2ppa: + # Upstream source is still available but to include Debian's patches, we + # are using Debian packaging GIT instead + # Original homepage: http://pnm2ppa.sourceforge.net/ + source: https://salsa.debian.org/printing-team/pnm2ppa.git + source-type: git + source-tag: debian/1.13-13 + source-depth: 1 +# ext:updatesnap +# version-format: +# format: 'debian/%M.%m-%R' +# lower-than: '2' +# no-9x-revisions: true + plugin: autotools + autotools-configure-parameters: + - --prefix=/usr + - --sysconfdir=/etc + override-build: | + set -eux + # "Unlock" config file + perl -p -i -e 's/^\s*version\s+0\s+/version 710 /' pnm2ppa.conf + # Set config file path (we copy the config file to an editable place + # on server startup) + perl -p -i -e 's:(\s+)SYSCONFDIR "(/pnm2ppa\.):\1"/var/ghostscript-printer-app/common/pnm2ppa\2:' pnm2ppa.h + # Update config.guess/config.sub, pnm2ppa seems to be of pre-arm64 era + cp /usr/share/misc/config.* . + craftctl default + build-packages: + - autotools-dev + prime: + - etc/pnm2ppa.conf + - usr/bin/calibrate_ppa + - usr/bin/pnm2ppa + + # Unmaintained printer drivers which come as complete package of either + # CUPS filter(s) or filters to use together with Ghostscript and + # foomatic-rip and of PPD files or PPD file generators (*.drv files for + # /usr/share/cups/drv or executables for /usr/lib/cups/driver) + + c2esp: + # Upstream source is still available but to include Debian's patches, we + # are using Debian packaging GIT instead + # Original homepage: https://sourceforge.net/projects/cupsdriverkodak/ + source: https://salsa.debian.org/printing-team/c2esp.git + source-type: git + source-tag: debian/27-11 + source-depth: 1 +# ext:updatesnap +# version-format: +# format: 'debian/%M-%m' +# lower-than: '8' +# no-9x-revisions: true + plugin: autotools + autotools-configure-parameters: + - --prefix=/usr + # To find the libraries built in this Snap + build-environment: + - LD_LIBRARY_PATH: "${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}$CRAFT_STAGE/usr/lib" + override-build: | + set -eux + # In libcupsfilter2 the API for driver-relevant functions has changed + # to introduce log functions. This patch does the needed adaptations + # on the code of c2esp. + patch -p1 < $CRAFT_PROJECT_DIR/patch-files/c2esp-libcupsfilters2-api.patch + autoreconf --install + craftctl default + perl -p -i -e 's:/usr/lib/cups/filter/::g' */*.drv + mkdir -p $CRAFT_PART_INSTALL/usr/share/ppd + cp */*.drv $CRAFT_PART_INSTALL/usr/share/ppd/ + build-packages: + - autoconf + - automake + organize: + usr/lib/cups/filter: usr/lib/ghostscript-printer-app/filter + prime: + - usr/lib/ghostscript-printer-app/filter/* + - usr/share/ppd/*.drv + after: [cups, libcupsfilters, libppd, cups-filters] + + dymo-cups-drivers: + # Upstream source is still available but to include Debian's patches, we + # are using Debian packaging GIT instead + # Original homepage: + #https://www.dymo-label-printers.co.uk/news/download-dymo-sdk-for-linux.html + source: https://salsa.debian.org/printing-team/dymo-cups-drivers.git + source-type: git + source-tag: debian/1.4.0-12 + source-depth: 1 +# ext:updatesnap +# version-format: +# format: 'debian/%V' + plugin: autotools + autotools-configure-parameters: + - --prefix=/usr + override-build: | + set -eux + autoreconf --install + craftctl default + # Compress the included PPD files + pyppd -v -o dymo-ppds ppd + mkdir -p $CRAFT_PART_INSTALL/usr/share/ppd + mv dymo-ppds $CRAFT_PART_INSTALL/usr/share/ppd + build-packages: + - autoconf + - automake + - pyppd + organize: + usr/lib/cups/filter: usr/lib/ghostscript-printer-app/filter + prime: + - usr/lib/ghostscript-printer-app/filter/* + - usr/share/ppd/dymo-ppds + after: [cups, pyppd] + + foo2zjs: + # Upstream source is not available any more, using Debian packaging + # GIT instead + # We do support color profiles in the sub-directories of + # /var/snap/ghostscript-printer-app/common/foo2zjs but we do not + # support automatic loading of firmware files. For those printers the + # HPLIP Printer Application (with plugin loaded in-app) should be used. + source: https://salsa.debian.org/printing-team/foo2zjs.git + source-type: git + source-tag: 'debian/20200505dfsg0-3' + source-depth: 1 +# ext:updatesnap +# version-format: +# format: 'debian/%V' + plugin: nil + override-build: | + set -eux + cp printer-profile.in printer-profile + # Adjust paths in Makefile + cp Makefile Makefile.orig + perl -p -i -e 's:\$\(PREFIX\)/share/foo2:/var/ghostscript-printer-app/common/foo2zjs/foo2:' Makefile + make all PREFIX=/ghostscript-printer-app/current/usr CUPS_SERVERBIN=$CRAFT_PART_INSTALL/usr/lib/ghostscript-printer-app CUPS_DEVEL=1 CUPS_GOODAPI=1 + cp Makefile.orig Makefile + make install PREFIX=$CRAFT_PART_INSTALL/usr CUPS_SERVERBIN=$CRAFT_PART_INSTALL/usr/lib/ghostscript-printer-app + # Install missing files + mkdir -p $CRAFT_PART_INSTALL/usr/bin/ + cp getweb $CRAFT_PART_INSTALL/usr/bin/ + mkdir -p $CRAFT_PART_INSTALL/usr/lib/ghostscript-printer-app/filter + rm -f $CRAFT_PART_INSTALL/usr/lib/ghostscript-printer-app/filter/command2foo2lava-pjl + cp command2foo2lava-pjl $CRAFT_PART_INSTALL/usr/lib/ghostscript-printer-app/filter + # Adjust the paths to the auxiliary files + perl -p -i -e 's:PREFIX=.*:PREFIX=/ghostscript-printer-app/current/usr:' $CRAFT_PART_INSTALL/usr/bin/*-wrapper + perl -p -i -e 's:\$PREFIX/share/foo2:/var/ghostscript-printer-app/common/foo2zjs/foo2:' $CRAFT_PART_INSTALL/usr/bin/*-wrapper + perl -p -i -e 's:/usr/share/":/var/ghostscript-printer-app/common/foo2zjs/":' $CRAFT_PART_INSTALL/usr/bin/getweb + perl -p -i -e 's:/usr/share/\$FOO:/var/ghostscript-printer-app/common/foo2zjs/\$FOO:' $CRAFT_PART_INSTALL/usr/bin/printer-profile* + # Use $TMPDIR for temporary directory + perl -p -i -e 's:/tmp:\$TMPDIR:' $CRAFT_PART_INSTALL/usr/bin/*-wrapper + # Add "-dNOINTERPOLATE" to the Ghostscript command lines to make + # Ghostscript rendering the pages significantly faster + perl -p -i -e 's/dNOPAUSE/dNOPAUSE -dNOINTERPOLATE/g' $CRAFT_PART_INSTALL/usr/bin/*-wrapper + # Set up the PPD file collection + cp -r PPD ppd + # Remove the PPDs of printers which need their firmware loaded whenever + # they are turned on. User should use the HPLIP Printer Application + # with them + for model in `cat Makefile | grep install-usermap | cut -d j -f 2 | cut -d ' ' -f 1`; do + rm ppd/HP-LaserJet_$model.ppd + done + # Compress the included PPD files + pyppd -v -o foo2zjs-ppds ppd + rm -rf ppd + mkdir -p $CRAFT_PART_INSTALL/usr/share/ppd + mv foo2zjs-ppds $CRAFT_PART_INSTALL/usr/share/ppd + build-packages: + - dc + - pyppd + stage-packages: + - psutils + - bsdutils + - dc + prime: + - usr/bin/* + - usr/lib/ghostscript-printer-app/filter/command2foo2lava-pjl + - usr/share/ppd/foo2zjs-ppds + - usr/share/foo2* + after: [cups, pyppd] + + fxlinuxprint: + # Upstream source is not available any more, using Debian packaging + # GIT instead + # Fuji Xerox probably stopped with this driver as this is a PDF driver + # and nowadays PDF printers use driverless IPP. The driver seems to be + # for the pre-driverless-IPP PDF printers. + source: https://salsa.debian.org/printing-team/fxlinuxprint + source-type: git + source-tag: debian/1.1.0+ds-4 + source-depth: 1 +# ext:updatesnap +# version-format: +# format: 'debian/%V' + plugin: autotools + autotools-configure-parameters: + - --prefix=/usr + override-build: | + set -eux + autoreconf --install + craftctl default + # Compress the included PPD file + pyppd -v -o fxlinuxprint-ppds . + mkdir -p $CRAFT_PART_INSTALL/usr/share/ppd + mv fxlinuxprint-ppds $CRAFT_PART_INSTALL/usr/share/ppd + build-packages: + - autoconf + - automake + - pyppd + organize: + usr/lib/cups/filter: usr/lib/ghostscript-printer-app/filter + prime: + - usr/lib/ghostscript-printer-app/filter/* + - usr/share/ppd/fxlinuxprint-ppds + after: [cups, pyppd] + + m2300w: + # Upstream source is still available but to include Debian's patches, we + # are using Debian packaging GIT instead + # Original homepage: https://sourceforge.net/projects/m2300w/ + # There is a successor (native CUPS!) on + # https://github.com/ondrej-zary/m2x00w-cups + # but as it is a very invasive change we stay with m2300w for the + # 2300w qnd 2400w printers. We have no printers for testing. + # Color profiles in the appropriate sub-directories of + # /var/snap/ghostscript-printer-app/common/m2300w are supported. + source: https://salsa.debian.org/printing-team/m2300w.git + source-type: git + source-tag: debian/0.51-15 + source-depth: 1 +# ext:updatesnap +# version-format: +# format: 'debian/%M.%m-%R' +# lower-than: '1' +# no-9x-revisions: true + plugin: autotools + autotools-configure-parameters: + - --prefix=/usr + override-build: | + set -eux + # Explicitly call "./configure; make; make install" as "make install" + # uses "INSTROOT" instead of "DESTDIR" (and in core20 the "autotools" + # plugin is hardwired to "DESTDIR") + autoreconf --install + ./configure --prefix=/usr + make -j2 + make INSTROOT=$CRAFT_PART_INSTALL install + # Adjust the paths to the auxiliary files + perl -p -i -e 's:PREFIX=.*:PREFIX=/ghostscript-printer-app/current/usr:' $CRAFT_PART_INSTALL/usr/bin/*-wrapper + perl -p -i -e 's:SHARE=.*:SHARE=/var/ghostscript-printer-app/common/m2300w:' $CRAFT_PART_INSTALL/usr/bin/*-wrapper + # Use $TMPDIR for temporary directory + perl -p -i -e 's:/tmp:\$TMPDIR:' $CRAFT_PART_INSTALL/usr/bin/*-wrapper + # Remove unneeded old foomatic-rip file + rm -rf $CRAFT_PART_INSTALL/usr/share/m2300w/0.51/foomatic + # Package the two PPDs and their second version counterpart. + mkdir -p $CRAFT_PART_INSTALL/ppd + for n in 2300 2400; do + mv $CRAFT_PART_INSTALL/usr/share/cups/model/Minolta/magicolor_${n}W-m${n}w.ppd $CRAFT_PART_INSTALL/ppd/Minolta-magicolor_${n}W-m2300w.ppd + # Create copies for "KONICA MINOLTA" manufacturer name + perl -p -e 's/Minolta/KONICA MINOLTA/g' $CRAFT_PART_INSTALL/ppd/Minolta-magicolor_${n}W-m2300w.ppd > $CRAFT_PART_INSTALL/ppd/KONICA_MINOLTA-magicolor_${n}W-m2300w.ppd + # Correct originals for "Minolta" manufacturer name + perl -p -i -e 's/KONICA MINOLTA/Minolta/g' $CRAFT_PART_INSTALL/ppd/Minolta-magicolor_${n}W-m2300w.ppd + done + rm -rf $CRAFT_PART_INSTALL/usr/share/cups + # Compress the PPD files + ( cd $CRAFT_PART_INSTALL + pyppd -v -o m2300w-ppds ppd + rm -rf ppd + mkdir -p $CRAFT_PART_INSTALL/usr/share/ppd + mv m2300w-ppds $CRAFT_PART_INSTALL/usr/share/ppd + ) + build-packages: + - autoconf + - automake + - pyppd + stage-packages: + - psutils + prime: + - usr/bin/* + - usr/share/ppd/m2300w-ppds + - usr/share/m2300w/* + after: [cups, pyppd] + + printer-driver-oki: + # There is no Debian packaging GIT, using "Upstream" GIT from + # Debian maintainer Balint Reczey: + # https://github.com/rbalint/printer-driver-oki + # Original download place at Okidata: + # ftp://ftp2.okidata.com/pub/drivers/linux/ + # Original Debian packaging GIT (server removed): + # git://anonscm.debian.org/collab-maint/printer-driver-oki.git + source: https://github.com/rbalint/printer-driver-oki + source-type: git + source-tag: '1.0.1' + source-depth: 1 +# ext:updatesnap +# version-format: +# lower-than: '2' +# no-9x-revisions: true + plugin: make + make-parameters: + - PREFIX=/usr + - DESTDIR=/ghostscript-printer-app/current + override-build: | + set -eux + # Correct path to CUPS filters + perl -p -i -e 's:/usr/lib/cups/filter:/ghostscript-printer-app/current/usr/lib/ghostscript-printer-app/filter:' filters/* + # Correct path for Ghostscript + perl -p -i -e 's:/usr/bin/gs:/ghostscript-printer-app/current/usr/bin/gs:' filters/* + # Do not overwrite $PATH environment variable + perl -p -i -e 's:^(\s*(export |)PATH):#\1:' filters/* + # Do not set $GSCRIPT_LIB environment variable + perl -p -i -e 's:^(\s*(export |)GSCRIPT_LIB):#\1:' filters/* + # Use $TMPDIR for temporary directory + perl -p -i -e 's:/tmp:\$TMPDIR:' filters/* + # Create filter installation directory + mkdir -p $CRAFT_PART_INSTALL/usr/lib/cups/filter/ + # Correct language in PPD file + perl -p -i -e 's/^(\*LanguageVersion:\s+).*/\1Portuguese/' MFP/OK4X1PSBR.ppd + # Install the files + craftctl default + # Compress the included PPD files + ( cd $CRAFT_PART_INSTALL/usr/share/ppd + ln -s okidata ppd + pyppd -v -o oki-ppds ppd + rm ppd + ) + organize: + usr/lib/cups/filter: usr/lib/ghostscript-printer-app/filter + prime: + - usr/lib/ghostscript-printer-app/filter/* + - usr/share/ppd/oki-ppds + after: [cups, pyppd] + + pxljr: + # Upstream source is still available but to include Debian's patches, we + # are using Debian packaging GIT instead + # Original homepage: http://hp-pxl-jetready.sourceforge.net/ + source: https://salsa.debian.org/printing-team/pxljr.git + source-type: git + source-tag: debian/1.4+repack0-6 + source-depth: 1 +# ext:updatesnap +# version-format: +# format: 'debian/%V' + plugin: autotools + autotools-configure-parameters: + - --prefix=/usr + override-build: | + set -eux + autoreconf --install + craftctl default + # Generate PPD files for the HP LaserJet 3500 and 3600 + mkdir ppd + cp HP-Color_LaserJet_3550-pxljr.ppd ppd + cd ppd + for n in 3500 3600; do + perl -p -e "s:3550(?!\"):${n}:g" HP-Color_LaserJet_3550-pxljr.ppd > HP-Color_LaserJet_${n}-pxljr.ppd + done + # Allow also PDF as input data format + perl -p -i -e 's,^\*cupsFilter:\s*\"application/vnd.cups-postscript\s+0\s+foomatic-rip\",*cupsFilter: "application/vnd.cups-postscript 100 foomatic-rip"\n*cupsFilter: "application/vnd.cups-pdf 0 foomatic-rip",' *.ppd + # Make the page rendering by Ghostscript faster + perl -p -i -e 's,(\-sDEVICE=ijs),-dNOINTERPOLATE \1,' *.ppd + # Compress the PPD files + cd .. + pyppd -v -o pxljr-ppds ppd + rm -rf ppd + mkdir -p $CRAFT_PART_INSTALL/usr/share/ppd + mv pxljr-ppds $CRAFT_PART_INSTALL/usr/share/ppd + build-packages: + - autoconf + - automake + - libijs-dev + - libjpeg-dev + - pyppd + stage-packages: + - libijs-0.35 + organize: + usr/lib/cups/filter: usr/lib/ghostscript-printer-app/filter + prime: + - usr/bin/ijs_pxljr + - usr/lib/*/libijs*.so* + - usr/share/ppd/pxljr-ppds + after: [cups, pyppd] + + rastertosag-gdi: + # Upstream source is still available but to include Debian's patches, we + # are using Debian packaging GIT instead + # Original homepage: https://www.openprinting.org/download/printing/rastertosag-gdi/ + source: https://salsa.debian.org/printing-team/rastertosag-gdi.git + source-type: git + source-tag: debian/0.1-8 + source-depth: 1 +# ext:updatesnap +# version-format: +# format: 'debian/%M.%m-%R' +# lower-than: '1' +# no-9x-revisions: true + plugin: nil + override-build: | + set -eux + # Copy the filter to the right place + mkdir -p $CRAFT_PART_INSTALL/usr/lib/ghostscript-printer-app/filter + cp rastertosag-gdi $CRAFT_PART_INSTALL/usr/lib/ghostscript-printer-app/filter + # Compress the PPD files + pyppd -v -o rastertosag-gdi-ppds ppd + mkdir -p $CRAFT_PART_INSTALL/usr/share/ppd + mv rastertosag-gdi-ppds $CRAFT_PART_INSTALL/usr/share/ppd + prime: + - usr/lib/ghostscript-printer-app/filter/rastertosag-gdi + - usr/share/ppd/rastertosag-gdi-ppds + after: [pyppd] + + splix: + # Upstream source is still available but to include Debian's patches, we + # are using Debian packaging GIT instead + # Original homepage: http://splix.ap2c.org/, + # https://sourceforge.net/projects/splix/ + source: https://salsa.debian.org/printing-team/splix.git + source-type: git + source-tag: debian/2.0.0+svn315-7 + source-depth: 1 +# ext:updatesnap +# version-format: +# format: 'debian/%V' + plugin: nil + override-build: | + set -eux + make V=1 rastertoqpdl_LIBS="-lcupsimage -lcups -lpthread -ljbig -L$CRAFT_STAGE/usr/lib/" pstoqpdl_LIBS="-lcupsimage -lcups -ljbig -L$CRAFT_STAGE/usr/lib/" CUPSFILTER="/ghostscript-printer-app/current/usr/lib/ghostscript-printer-app/filter" + # Copy the filters to the right place + mkdir -p $CRAFT_PART_INSTALL/usr/lib/ghostscript-printer-app/filter + cp optimized/*toqpdl $CRAFT_PART_INSTALL/usr/lib/ghostscript-printer-app/filter + # Compress the PPD files + cp *.ppd ppd + pyppd -v -o splix-ppds ppd + mkdir -p $CRAFT_PART_INSTALL/usr/share/ppd + mv splix-ppds $CRAFT_PART_INSTALL/usr/share/ppd + build-packages: + - libjbig-dev + - pyppd + stage-packages: + - libjbig0 + prime: + - usr/lib/ghostscript-printer-app/filter/pstoqpdl + - usr/lib/ghostscript-printer-app/filter/rastertoqpdl + - usr/lib/*/libjbig*.so* + - usr/share/ppd/splix-ppds + after: [cups, pyppd] + + # Maintained(?) printer drivers which come as complete package of either + # CUPS filter(s) or filters to use together with Ghostscript and + # foomatic-rip and of PPD files or PPD file generators (*.drv files for + # /usr/share/cups/drv or executables for /usr/lib/cups/driver) + + brlaser: + # Upstream source GIT is ahead of the release version 6 Debian uses + # and Debian does not apply any patch, so we use the current upstream + # GIT master here. + # Debian GIT: https://salsa.debian.org/printing-team/brlaser.git + source: https://github.com/pdewacht/brlaser.git + source-type: git + source-tag: 'v6' + source-depth: 1 +# ext:updatesnap +# version-format: +# format: 'v%V' + plugin: cmake + cmake-parameters: + - -DCMAKE_INSTALL_PREFIX=/usr + override-build: | + set -eux + craftctl default + mkdir -p $CRAFT_PART_INSTALL/usr/share/ppd + cp *.drv $CRAFT_PART_INSTALL/usr/share/ppd + organize: + usr/lib/cups/filter: usr/lib/ghostscript-printer-app/filter + prime: + - usr/lib/ghostscript-printer-app/filter/rastertobrlaser + - usr/share/ppd/*.drv + after: [cups, cups-filters] + + ptouch-driver: + # Github source: https://github.com/philpem/printer-driver-ptouch.git + source: https://salsa.debian.org/printing-team/ptouch-driver.git + source-type: git + source-tag: 'debian/1.7-1' + source-depth: 1 +# ext:updatesnap +# version-format: +# format: 'debian/%M.%m-%R' +# lower-than: '2' +# no-9x-revisions: true + plugin: autotools + autotools-configure-parameters: + - --prefix=/usr + override-build: | + set -eux + autoreconf --install + craftctl default + # Generate PPDs files from Foomatic data + mkdir foomatic-db + cp -r $CRAFT_PART_INSTALL/usr/share/foomatic/* foomatic-db/ + echo '#' > foomatic-db/db/oldprinterids + rm -rf $CRAFT_PART_INSTALL/usr/share/foomatic + FOOMATICDB=foomatic-db foomatic-compiledb -j 2 -t ppd -d ppd `ls -1 foomatic-db/db/source/driver/*ptouch*.xml | perl -p -e 's:^.*db/source/driver/(\S*)\.xml\s*$:\1\n:'` + rm -rf foomatic-db + pyppd -v -o ptouch-ppds ppd + rm -rf ppd + mkdir -p $CRAFT_PART_INSTALL/usr/share/ppd + mv ptouch-ppds $CRAFT_PART_INSTALL/usr/share/ppd + build-packages: + - autoconf + - automake + - foomatic-db-engine + - libxml-libxml-perl + - pyppd + organize: + usr/lib/cups/filter: usr/lib/ghostscript-printer-app/filter + prime: + - usr/lib/ghostscript-printer-app/filter/rastertoptch + - usr/share/ppd/ptouch-ppds + after: [cups, pyppd] + + ghostscript-printer-app: + plugin: make + source: . + make-parameters: + - LDFLAGS="$LDFLAGS -ljpeg" + - VERSION="$VERSION" + - SNAP=1 + # To find the libraries built in this Snap + build-environment: + - LD_LIBRARY_PATH: "${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}$CRAFT_STAGE/usr/lib" + # To improve convenience for developers (and everyone who wants to + # build from source), we do a "make clean" before "make" here, + # because if we had done "make" off-Snap, directly in the source + # tree and afterwards build the Snap with snapcraft, the build + # sucks in our local binary of ghostscript-printer-app instead of + # compiling its own one in the Snap harness with the appropriate + # libraries, ending up with the Snap containing an executable + # which does not work inside the Snap. The "make clean" removes + # any accidentally grabbed binary. + # + # We need to directly call the "make" and "make install" commands + # here as we cannot inject an environment variable into the default + # build process ("craftctl default") and we also cannot call + # "craftctl get version" in the lines of "make-parameters:" or + # "build-environment:". This way we get the version number of our + # Snap (which is extracted from the Ghostscript upstream source) + # inyo the ghostscript-printer-app executable. + override-build: | + set -eux + make clean + VERSION="`craftctl get version`" + make -j"8" LDFLAGS="$LDFLAGS -ljpeg" SNAP=1 VERSION="$VERSION" + make -j"8" install LDFLAGS="$LDFLAGS -ljpeg" SNAP=1 VERSION="$VERSION" DESTDIR="$CRAFT_PART_INSTALL" + #craftctl default + build-packages: + - libusb-1.0-0-dev + stage-packages: + - libusb-1.0-0 + - libjbig0 + - liblcms2-2 + - libtiff5 + - libwebp7 + stage: + - -usr/lib/ghostscript-printer-app + prime: + - usr/bin/ghostscript-printer-app + - lib/*/lib*.so* + - usr/lib/*/lib*.so* + - usr/share/ghostscript-printer-app + - -var + - -usr/share/man + after: [pappl-retrofit, pappl, ghostscript, libcupsfilters, libppd, cups-filters, foomatic-db] + + avahi-daemon: + plugin: nil + overlay-packages: + - avahi-daemon + - avahi-utils + - libnss-mdns + - mdns-scan + - dbus + - python3 + + scripts: + plugin: dump + source: scripts/ + organize: + run-dbus.sh: /scripts/run-dbus.sh + override-prime: | + set -eux + craftctl default + # Ensure the run-dbus.sh script has executable permissions + if [ -f "$CRAFT_PRIME/scripts/run-dbus.sh" ]; then + chmod +x "$CRAFT_PRIME/scripts/run-dbus.sh" + fi \ No newline at end of file diff --git a/scripts/run-dbus.sh b/scripts/run-dbus.sh new file mode 100644 index 0000000..23f91ea --- /dev/null +++ b/scripts/run-dbus.sh @@ -0,0 +1,32 @@ +#!/bin/sh +set -eux + +echo "Creating system users" + +# Create system users with system accounts and no home directories, using nologin shell +useradd --system --no-create-home --shell /usr/sbin/nologin systemd-resolve || true +useradd --system --no-create-home --shell /usr/sbin/nologin systemd-network || true + +echo "Creating directories" + +# Create the /run/dbus directory if it doesn't exist, set permissions, and ownership +mkdir -p /run/dbus +chmod 755 /run/dbus +chown root:root /run/dbus + +echo "Starting dbus" + +# Start the dbus daemon in the foreground +# dbus-daemon --system --nofork --nopidfile & + +# Check the status of the dbus service +service dbus start +service dbus status || true + +echo "Starting avahi-daemon" + +# Start the avahi-daemon in the background without dropping root privileges +avahi-daemon --daemonize --no-drop-root + +# Keep the script running to avoid container exit +tail -f /dev/null \ No newline at end of file diff --git a/testpage.ps b/testpage.ps new file mode 100644 index 0000000000000000000000000000000000000000..f6acbf28a0a3b6c161dca32af3c41361038ae713 GIT binary patch literal 17524 zcmds9YjfL1mi-)6?SJU;mbR$G6kmEou5wLTvg5cSJ1)_g%v8-6kc24AkN_6|_1KjE z`<`=eqtSSfl5BZucbv>v0&aKT_p_1RKYbi`U(J$9*d6Wncm8AdiT~)1=G~>aOV(x@ z#3l`cnaQuB>^UE$W|c;99;PPBOq}EX9KRhWh^3KZ`B+uISaS9!k5 zUi5l%aBw}@pC-%Rud6T?Hb(KhH@||6Gm&xE%D)?|R=p_8)?ucHl{@mMr~0$AyL+0f z;~B6xO>SS9KK?lx49)S$5U)N4^Duj12Kezji05nkdLCYf3w`uDnXZ>%oWBn8;DtF` zgh70K8sz{k-i+5&kZ^VpW>D=Z_gbaNlv2sVEEiIH!~K!BwSsZ^AHtZm6fBc^6Oj3m|AL(1t)? zzZmxW$Ni)J(Qt6k@ArS`ANKoz`V{30y#53<4cUN4Z{pcmvLwYBemf245hR!_l6mo4 zL1vRk10oH!-PtX7G|45bDKx$&n6uwLj-58YPNQphf{QRulS|m(c{E9b^bVVJW+C6r z%w?J^Wf#v&IGoL8lFE*Ia`IWSx=W+^Rc<=dJu~bN`(|XCAyAIYr z?hgBdL4}Dmpux$>2tfT~^Crmd%s9EsZ-O)gA<1k#CA+Zic{B~<3^+sGK-H^NFa`DY zskt8R_u(+cVJPHWMiAJu^LJ-&K8)Wy6GE0r3MrT<2354*B!)D1dgC{L{q*X?C-cX5 z-+i}hUZ=qgY<(C} zD4Pc9tUUO$Wfh723H&s9qN4C9jl;Pam|!+D2L=R`^mYcO%dPfs?7^3lT<(uEu=@|D z*m$`2#oT$orVnAHdi#-O`PNMz!Sm=cTx678W)mF`;4{OA1q{{I(?BXhI)J)ZYZE<`V;FBnPG=B%`X)%H02f2%=}{cR zTi~IJTMfZl9yP=}28YlnI`)(woQYChpfxQg;ygJq_K!@~Ou*cc(?ybnj^s1`CMM2D zvL&3=LfG*WeQ6}FMqY>wkob@ABtT#tDuX`Lp^+Zvuoh7q;zWjG-CKEXoelP(J<0#T zfMUms=jQEmbNbw56a%({iwg638r%ssr`CU1fyw*6Stf|2i2$4-l)>eTGi#T^t8`jm zl}zbH0bFIrDSQ-77`|Qi$`Gvn8Cvb&k0nDqsV;&^xKL&YK_qD$To?Wr$57CtKKy7V zE&%WU>MIbQcSe0$Yj``oB4maPl+FT>fAb;n+(LS!BV0xdAx03PDCQZC$KQr~rAdzL zK!~`IA1xeTTMaxc4*T`;5?m(_sIC%VWgEe(izwkB0|X-u_&P=EBkLKh{|uT_TrkAxW2fF-0{>1V2X#v4m*y@74b8w zB5TOG*mec#o#^9x7N64&>&J?5HWmWo0|pMpAhCJTO$osGH8gxqvRrg2LjWZ$-rfZ=;V(Rj z$44v`4*srA2E0_JkgI}bww}3-M8ocP-K`9xi zdbeAa`R{butt`VjC-Li&?@v!g! zJVdHE3~ao62o{9(@E9EJANrWEV^PDV${2`RQF4$TS_1kFaLeH77mAkGP4U@OLcFXr zTvVs5466Krh?`>aSu+sEShta`7h#H?+aiJEkcc}&3h6P9=H-!Q|0tq%7O55y@` z0U_h}@6OM?w}<=XTfT0ki0)emW`9J^wqcoOf=)+C3cTVa6_zXTVwE7SW-eQ#q2Y!4 zFnUTC0hBZH0yxv6`bM10Lek1zQ>1(1r9mwBWbkiy!!bJ^3+IRnzg4(DdxUfrtTa4K zG|xk>Cr8kYOIXm{(+m%o#nHtha$9d+anyi-Sy6 z1_&Ny(jW<&pyMhbO)T5VM^6@sx{X5M(vSSNjrc+Dz?VUt*1_S!X!VdfF((^N`f=My zM~^uOwFg|iWcA>QBt2HMY)tcn*%xf=b1U~!v7BB_Z0hhenx(PV*Da0A9yU$YvRc)r zUOh;wM$+aP9t&NCEBQjTVy^iFTGb@HMXwy8P^t$I+M-fz$26469dq>XQ#R|99+}Zq zu|h=e99cD;p8Bf_M!v&xdX;K6`*^kToOt=899$gE^vqW_s|$5J>o(nOabRu!O9jBg zP+2&WmS{rv?E6ls!Idkb;1*4uBo447fS%nEQH_SB3L`>DE?serO`rHx%FAx_q1k{~ zyQdsBRG`7y7Js>&wSD7-Ld?LR|U8*aNdQMNvO1B9Kxh4*ZylG;Wg6R|;2~2{JqAu7b>Y@h9ZMQ))V}g1qCL9r;RB{76 zb84>T+L&z%ba|v;lg^1Zsq*R}Kl5d-jGbKluW9cYXKZ-G&<0zhs2I_#Vy31GN8-hd`m?qESZ_ zOYZCv8*@-j`fDm2BpocW1tGz%K*rVIn#c(`$0L-aBwI$lozsJp>!o9Mn_Jan-<`R`Z5b}s%=p535{K~Oj?4- zuVEuwhv)PqZR2w>E;^{fM-*hL)xamY;gjV{4DxRh`yY#1*2x{Y&@ul6P zBpD+dDdAb_a|G2bU-itP1uwemTI`n)^e{S);;8<6LqWK=cCD{y?=hVt`KkE01}=TH zH?SqxXY&GVt|6*$i!Dnm_7;72IxY^>v3D|I_-`S_ZVn9~GdN}IkgV#UwT(pWFX*y+ zNCdl^G)kDOk?7AMflbR?)}VyTi9Prz!?n} zsFnLi;OdahBpXNM5N&P$-&^<#BNVj(D)qg%vc?ZJthYI&NxG56&l zAc=9#+{H|Ivx|%pU1Nw7JFw7ltw3Je+ZmcF*joj1OU**^f|b3VfNkylgaUbi@f?^% z7Jvn|_I8Y-8_RV|)B$&Ly^iFnY4ayzMEZh=2-wEhO%~!{{LI`F-xi5`@_xDmZGf?{ z2=qeL{hTdiXDOTQgl6)tGGZ=G-e!>~EQ{j7KEbH1I+muNDxJiEj**0+bv_JwgQFtr z^cXQZ^wu;~pT(~&Yl>@Snw&w@cc%N&T*-{Ig2b?_lEk<-S4#H&8PLUcZYMUGY!W8( zU3c+GR0MN>T#!TywsK}!Wj&PaGLijP5IySsSn#o(=mV6it2=myCgsdJ!XTA=6;}yZ zx67qYFu)bd!YCImt^dXCa$e3tM7u5SSGj9rO^dbs$F6=+RMoapL$&UGJlkc&EArmP z_9Db;;^bB8wkq1*Lg&==50l$zQhaDx(bsi;9d>)uPApO{ZKXct(kQO1jpAn%0;0SlXIW|9 z@?5)TQ44hBG1bP zn-iKxpvwO%$n59=tYWr{SL&RCe8`YU@YzQ4EAznGLai9MbdzvBy1$`xg{Td(*-D&{ zZ|j~7>q{Cp$yQ36u2e$h#P&&rt0zbqzFoQk;Wg=V>wqdm;aFbZQt5mZj&$=jgyR=;}YW0@?6^j(x5`u=wu%wde1lS`mY~EU&|H^I;-w^ zwkrJdJGM|)DW}!=iVFq3{r*R;czWV)&&s{U-p50=EY)6XmY7;kR8KY}68|3gIeJnX zCMTQdZYEGR0CU*lGN`AjO8);Q=rzS_r09?5{J$ng_we?t&HA7(Pt_0PZfUE94K|g) zO;y{Tt5;LCds6k{n^p`K@lh+h*aI@wPWho_dqC*O7qUp=d7%TuG85NFl8)m`4*if; z&U8_og`GaP$N-yN^B3IC!AB}pZ(b#_l5{_e0=sKF`uK=|M|#+oNOa8KI~BT2M`=oN z`Ce9eLF~dlV{rKUUS-){QCsNep-)Vn{phrvyp Date: Mon, 12 Aug 2024 18:41:04 +0530 Subject: [PATCH 02/10] Implemented the latest workflow from ubuntu/desktop-snaps, which incorporates an automated rock versioning system. - In the workflow file .github/workflows/auto-update.yml, we add the parameter "rock-version-schema: '^ghostpdl-(\d+\.\d+\.\d+)' to the call of the GitHub action. This instructs the action to perform versioning automation and specifies the format of the upstream release tags and the upstream version number in them. - We add "adopt-info: ghostscript" even with all metadata fields in rockcraft.yaml. This tells the GitHub action which part is the supplier of the upstream version number. Add GitHub Action to Push Image to Docker Registry - Added registry-actions.yml to automate pushing Docker images to the Docker registry. - Utilized craft-action/rockcraft-pack from Canonical to pack the rock. - Integrated docker/login-action for seamless authentication to Docker Hub within the GitHub Actions workflow. - Configured the workflow to pack rock as a Docker image using Skopeo. --- .github/workflows/auto-update.yml | 20 +++++ .github/workflows/registry-actions.yml | 117 +++++++++++++++++++++++++ 2 files changed, 137 insertions(+) create mode 100644 .github/workflows/auto-update.yml create mode 100644 .github/workflows/registry-actions.yml diff --git a/.github/workflows/auto-update.yml b/.github/workflows/auto-update.yml new file mode 100644 index 0000000..8d78077 --- /dev/null +++ b/.github/workflows/auto-update.yml @@ -0,0 +1,20 @@ +name: Push new tag update to stable branch + +on: + schedule: + # Daily for now + - cron: "9 7 * * *" + workflow_dispatch: + +jobs: + update-snapcraft-yaml: + runs-on: ubuntu-latest + steps: + - name: Checkout this repo + uses: actions/checkout@v3 + - name: Run desktop-snaps action + uses: ubuntu/desktop-snaps@stable + with: + token: ${{ secrets.GITHUB_TOKEN }} + repo: ${{ github.repository }} + rock-version-schema: '^ghostpdl-(\d+\.\d+\.\d+)' diff --git a/.github/workflows/registry-actions.yml b/.github/workflows/registry-actions.yml new file mode 100644 index 0000000..0467f15 --- /dev/null +++ b/.github/workflows/registry-actions.yml @@ -0,0 +1,117 @@ +name: Pack and Publish OCI Image to Docker Registry + +on: + push: + branches: + - main + workflow_dispatch: + inputs: + workflow_choice: + description: "Choose Release Channel" + required: true + default: "edge" + type: choice + options: + - edge + - stable + +jobs: + build-rock: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Pack with Rockcraft + uses: canonical/craft-actions/rockcraft-pack@main + id: rockcraft + + - name: Upload Rock Artifact + uses: actions/upload-artifact@v4 + with: + name: cups-rock + path: ${{ steps.rockcraft.outputs.rock }} + + publish-rock-edge: + needs: build-rock + if: github.ref_name == 'main' && (github.event.inputs.workflow_choice == 'edge' || github.event_name == 'push') + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Download Rock Artifact + uses: actions/download-artifact@v4 + with: + name: cups-rock + + - name: Install Dependencies + run: | + sudo snap install rockcraft --classic + sudo snap install docker + sudo snap install yq + + - name: Ensure Docker Daemon is Running + run: | + sudo systemctl start docker + sudo systemctl enable docker + sudo systemctl is-active --quiet docker || sudo systemctl start docker + + - name: Log in to Docker Hub + uses: docker/login-action@v3.2.0 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build and Push Docker Image + env: + USERNAME: ${{ secrets.DOCKER_USERNAME }} + run: | + IMAGE="$(yq '.name' rockcraft.yaml)" + VERSION="$(yq '.version' rockcraft.yaml)" + ROCK="$(ls *.rock | tail -n 1)" + sudo rockcraft.skopeo --insecure-policy copy oci-archive:"${ROCK}" docker-daemon:"${USERNAME}/${IMAGE}:${VERSION}-edge" + docker push ${USERNAME}/${IMAGE}:${VERSION}-edge + docker tag ${USERNAME}/${IMAGE}:${VERSION}-edge ${USERNAME}/${IMAGE}:latest + docker push ${USERNAME}/${IMAGE}:latest + + publish-rock-stable: + needs: build-rock + if: github.ref_name == 'main' && github.event.inputs.workflow_choice == 'stable' + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Download Rock Artifact + uses: actions/download-artifact@v4 + with: + name: cups-rock + + - name: Install Dependencies + run: | + sudo snap install rockcraft --classic + sudo snap install docker + sudo snap install yq + + - name: Ensure Docker Daemon is Running + run: | + sudo systemctl start docker + sudo systemctl enable docker + sudo systemctl is-active --quiet docker || sudo systemctl start docker + + - name: Log in to Docker Hub + uses: docker/login-action@v3.2.0 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build and Push Docker Image + env: + USERNAME: ${{ secrets.DOCKER_USERNAME }} + run: | + IMAGE="$(yq '.name' rockcraft.yaml)" + VERSION="$(yq '.version' rockcraft.yaml)" + ROCK="$(ls *.rock | tail -n 1)" + sudo rockcraft.skopeo --insecure-policy copy oci-archive:"${ROCK}" docker-daemon:"${USERNAME}/${IMAGE}:${VERSION}-stable" + docker push ${USERNAME}/${IMAGE}:${VERSION}-stable From 58716292b11e862a0656f1bb8dae0c3a784b1a80 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 15 Aug 2024 07:19:13 +0000 Subject: [PATCH 03/10] Update snap version/tag --- rockcraft.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rockcraft.yaml b/rockcraft.yaml index 2496feb..7a758eb 100644 --- a/rockcraft.yaml +++ b/rockcraft.yaml @@ -1,6 +1,6 @@ name: ghostscript-printer-app base: ubuntu@22.04 -version: '10.03.0-9' +version: '10.03.0-10' summary: Ghostscript Printer Application description: | The Ghostscript Printer Application is a PAPPL (Printer Application @@ -454,7 +454,7 @@ parts: cups-filters: source: https://github.com/OpenPrinting/cups-filters source-type: git - source-tag: '2.0.0' + source-tag: '2.0.1' source-depth: 1 # ext:updatesnap # version-format: @@ -1472,4 +1472,4 @@ parts: # Ensure the run-dbus.sh script has executable permissions if [ -f "$CRAFT_PRIME/scripts/run-dbus.sh" ]; then chmod +x "$CRAFT_PRIME/scripts/run-dbus.sh" - fi \ No newline at end of file + fi From 0a4f7c3366eb92a2b14beb5320a580b32fc94d22 Mon Sep 17 00:00:00 2001 From: Rudra-IITM Date: Thu, 15 Aug 2024 19:49:53 +0530 Subject: [PATCH 04/10] Updated documentation for ghostscript-printer-app --- README.md | 293 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 293 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..615d90e --- /dev/null +++ b/README.md @@ -0,0 +1,293 @@ +# Ghostscript Printer Application + +## INTRODUCTION + +This repository contains a Printer Application for printers supported +by Ghostscript's built-in printer drivers and some extra filters. + +It uses [PAPPL](https://www.msweet.org/pappl) to support IPP +printing from multiple operating systems. In addition, it uses the +resources of [cups-filters +2.x](https://github.com/OpenPrinting/cups-filters) (filter functions +in libcupsfilters, libppd) and +[pappl-retrofit](https://github.com/OpenPrinting/pappl-retrofit) +(encapsulating classic CUPS drivers in Printer Applications). This +work (or now the code of pappl-retrofit) is derived from the +[hp-printer-app](https://github.com/michaelrsweet/hp-printer-app). + +For printer capability and driver usage information the Foomatic +database of OpenPrinting (Online access [by +printer](http://www.openprinting.org/printers/), [by +driver](http://www.openprinting.org/drivers/), +[Downlod](http://github.com/OpenPrinting/foomatic-db)) is used. + +Your contributions are welcome. Please post [issues and pull +requests](https://github.com/OpenPrinting/ghostscript-printer-app). + + +### Contained Printer Drivers (in the Rock) + +- **Ghostscript built-in**: + ``` + ap3250, appledmp, bj10e, bj10vh, bj10v, bj10, bj200, bj8XXYYZ.upp, + bjc250gs, bjc600, bjc800, bjc880j, cdj500, cdj550, cdnj500, chp2200, + cljet5, cp50, declj250, deskjet, dj505j, djet500, dnj650c, + eplaser-jp, eplaser, eps9high, eps9mid, epsonc, epson, escpage, + fmlbp, fmpr, gdi, hl1250, hl7x0, ibmpro, imagen, iwhi, jetp3852, + jj100, la50, la70, la75plus, la75, laserjet, lbp310, lbp320, lbp8, + lex5700, lex7000, lips2p, lips3, lips4v, lips4, lj250, lj4dithp, + lj4dith, lj5gray, ljet2p, ljet3d, ljet3, ljet4d, ljet4, ljetplus, + ln03, lp2000, lp2563, lp8000, lq850, lxm3200-tweaked, lxm5700m, + m8510, md1xMono, md2k, md50Eco, md50Mono, md5k, mj700v2c, ml600, + necp2xX.upp, necp6, npdl, oce9050, oki182, oki4w, okiibm, paintjet, + pcl3, picty180, pjetxl, pjxl300, pjxl, pj, ps2write, pr150, pr201, + pxlcolor, pxldpl, pxlmono, r4081, rpdl, sharp.upp, sipixa6.upp, + sj48, stcolor, t4693dX, tek4696, xes + ``` + + This gives support for many old and ancient printers, but also for + PCL lasers (especially PCL 6/XL) and dot-matrix printers. + + The included Ghostscript can have more drivers but these are the + ones for which we have PPD support from Foomatic and which are not + considered deprecated by another driver. + +- **`hpijs` of HPLIP**: For non-HP PCL printers (use the [HPLIP + Printer Application](https://snapcraft.io/hplip-printer-app) for HP + printers). Better print quality than with Ghostscript's built-in + drivers. + +- **`pnm2ppa`**: Driver for some older HP printers with proprietary + protocol, probably the only HP printers **NOT supported by + HPLIP**. even not with HP's proprietary plugin. The configuration + file in the Rock is user-editable, see below. + +- **`pxljr`**: For HP Color LaserJet 3500/3550/3600, should give + better output quality than HPLIP. + +- **`foo2zjs`**: Driver for laser printers with proprietary languages, + from Dell, Epson, Fuji, HP, Kyocera, Lexmark, (Konica) Minolta, Oki, + Olivetti, Ricoh, Samsung, Xerox. Note that the firmware loading + facility for HP is not included in this Printer Application, use the + [HPLIP Printer Application](https://snapcraft.io/hplip-printer-app) + (download proprietary plugin in-app, via web interface) for these + printers, the firmware is proprietary anyway. In the Rock the user + can add color profiles, see below. + +- **`SpliX`**: Driver for laser printers with proprietary languages, + from Dell, Lexmark, Samsung, Toshiba, Xerox + +- **`brlaser`**: Driver for Brother HL, DCP, and MFC laser printers + which do not understand PostScript nor PCL. + +- **`fxlinuxprint`**: Driver from Fuji Xerox for their PDF printers + before the times of driverless IPP. + +- **`c2esp`**: Driver for Kodak EasyShare printers. + +- **`rastertosag-gdi`**: For the few Ricoh models which do not do + PostScript or PCL: Ricoh Aficio SP 1000S/1100S + +- **`dymo`**: Driver for Dymo's label printers + +- **`ptouch`**: Driver for Brother's P-Touch label printers + +- **`c2050`, `cjet`, `min12xxw`, `m2300w`**: Drivers for older + Lexmark, Canon, and Minolta printers. For `m2300w` in the Rock the + user can add color profiles, see below. + +- **`CUPS`, `cups-filters`**: Included drivers for PCL, dot-matrix + (Oki, Epson), label printers (Dymo, Intellitech, Zebra), and some + older HP DesignJet large-format printers. + +- **Manufacturer-supplied PPD files**: For PCL and PDF printers from + Ricoh and OEM (Gestetner, InfoPrint, Infotec, Lanier, NRG, Ricoh, + Savin) and from Samsung. + +### Not included + +- **PostScript**: For manufacturer-supplied PostScript support, use + the [PostScript Printer + Application](https://snapcraft.io/ps-printer-app). + +- **HPLIP**: For practically all HP printers use the [HPLIP Printer + Application](https://snapcraft.io/hplip-printer-app). It also + supports HP's proprietary plugin for printers which need to load + their firmware on startup or need a proprietary driver extension. + +- **Gutenprint**: High-quality output with inkjets from Epson, Canon, + and others, also PCL laser printers. A lot of adjustable + parameters. Use the [Gutenprint Printer + Application](https://snapcraft.io/gutenprint-printer-app). + +- **`epson-inkjet-printer-escpr`**: Epson's free-software printer + driver for ESC/P-R-based inkjet printers. It supports only 360 dpi + resolution and a very awkward user interface which cannot get easily + mapped to IPP. Therefore it is not included in this Printer + Application. Use the [Gutenprint Printer + Application](https://snapcraft.io/gutenprint-printer-app). + +- **Braille embosser drivers**: We plan a separate Printer Application + for that. + +- **Scanners in multi-function devices**: We plan a SANE retro-fit + Scanner Application. + +### Properties + +- A Printer Application providing Ghostscript-based printer + drivers. Input data is converted to PDF or PostScript (if not + already supplied in one of these formats) as these are the input + data formats of Ghostscript, fed into Ghostscript and by Ghostscript + converted into the printer's native language. In some cases + Ghostscript produces generic raster output which is converted to the + printer's language by an additional filter. + +- PWG Raster, Apple Raster or image input data is converted to + PostScript and not to PDF as PostScript is streamable, and this way + large jobs need less resources or one can theoretically even print + infinite jobs. + +- This Printer Application also includes some separate, old and now + unmaintained printer drivers which are too small projects for their + own Printer Application. These can also consist of a CUPS Raster + filter, not needing Ghostscript if the input is PWG Raster, Apple + Raster, or an image. + +- Note that most of the drivers (both inside Ghostscript and separate + filters) are old, unmaintained code, for old printers which we do + not have access to for testing. The packaging in the Rock (and also + in Debian where the Rock uses a Debian source) is minimum-invasive + to assure formerly working code stays working, but it is not assured + due to changes in GCC and the libraries or due to the Rock + environment. + +- This Printer Application supports thousands of (usually older) + printer models. The needed printer capability information and driver + usage information is mainly taken from OpenPrinting's Foomatic + database, but also from information which comes with individual + drivers. + +- From the Foomatic data CUPS PPD files are pre-built, compressed and + packaged with the Rock. Also the foomatic-rip filter of + cups-filters, Ghostscript, and the extra printer driver filters are + included. With this a CUPS driver retro-fit using the pappl-retrofit + library is done. This way we do not need to modify or adapt the now + mostly unmaintained printer driver code, nor the Foomatic data or + the PPD files. This is important as we do not have the printers for + testing. + +- We use the printer's IEEE-1284 device ID to identify manufacturer + and model of the printer and look for explicit driver support for + this model. If we do not find it, we check the CMD: field of the ID + to see whetrher the printer supports any common data format, + currently PostScript, PCL-6/XL, PCL 5c, and PCL 5e to select a + generic driver. + +- Available printer devices are discovered (and used) with CUPS' + backends and not with PAPPL's own backends. This way quirk + workarounds for USB printers with compatibility problems are used + (and are editable) and any driver's output can get sent to the + printer via IPP, IPPS (encrypted!), and LPD in addition to socket + (usually port 9100). The SNMP backend can get configured (community, + address scope). + +- If you have an unusual system configuration or a personal firewall + your printer will perhaps not get discovered. In this situation the + fully manual "Network Printer" entry in combination with the + hostname/IP field can be helpful. + +- Standard job IPP attributes are mapped to the driver's option + settings best fitting to them so that users can print from any type + of client (like for example a phone or IoT device) which only + supports standard IPP attributes and cannot retrive the PPD + options. Trays, media sizes, media types, and duplex can get mapped + easily, but when it comes to color and quality it gets more complex, + as relevant options differ a lot in the PPD files. Here we use an + algorithm which automatically (who wants hand-edit ~10000 PPD files + for the assignments) finds the right set of option settings for each + combination of `print-color-mode` (`color`/`monochrome`), + `print-quality` (`draft`/`normal`/`high`), and + `print-content-optimize` + (`auto`/`photo`/`graphics`/`text`/`text-and-graphics`) in the PPD of + the current printer. So you have easy access to the full quality or + speed of your printer without needing to deal with printer-specific + option settings (the original options are still accessible via web + admin interface). + +## Install from Docker Hub +### Prerequisites + +1. **Docker Installed**: Ensure Docker is installed on your system. You can download it from the [official Docker website](https://www.docker.com/get-started). + +### Step-by-Step Guide + +#### 1. Pull the ghostscript-printer-app docker image: + +The first step is to pull the ghostscript-printer-app Docker image from Docker Hub. +```sh +sudo docker pull openprinting/ghostscript-printer-app +``` + +#### 2. Start the ghostscript-printer-app Container + +##### Run the following Docker command to run the ghostscript-printer-app image: +```sh +sudo docker run --rm -d --name ghostscript-printer-app -p :8000 \ + openprinting/ghostscript-printer-app:latest +``` + +## Setting Up and Running ghostscript-printer-app locally + +### Prerequisites + +1. **Docker Installed**: Ensure Docker is installed on your system. You can download it from the [official Docker website](https://www.docker.com/get-started). + +2. **Rockcraft**: Rockcraft should be installed. You can install Rockcraft using the following command: +```sh +sudo snap install rockcraft --classic +``` + +3. **Skopeo**: Skopeo should be installed to compile `.rock` files into Docker images.
+**Note**: It comes bundled with Rockcraft. + +### Step-by-Step Guide + +#### 1. Build ghostscript-printer-app rock: + +The first step is to build the Rock from the `rockcraft.yaml`. This image will contain all the configurations and dependencies required to run ghostscript-printer-app. + +Open your terminal and navigate to the directory containing your `rockcraft.yaml`, then run the following command: + +```sh +rockcraft pack -v +``` + +#### 2. Compile to Docker Image: + +Once the rock is built, you need to compile docker image from it. + +```sh +sudo rockcraft.skopeo --insecure-policy copy oci-archive: docker-daemon:ghostscript-printer-app:latest +``` + +#### Run the ghostscript-printer-app Docker Container: + +```sh +sudo docker run --rm -d --name ghostscript-printer-app -p :8000 \ + ghostscript-printer-app:latest +``` + +### Setting up + +Enter the web interface + +```sh +http://localhost:/ +``` + +Use the web interface to add a printer. Supply a name, select the +discovered printer, then select make and model. Also set the installed +accessories, loaded media and the option defaults. Accessory +configuration and option defaults can also offen get polled from the +printer. \ No newline at end of file From be856d2cd8ab14eefb49ce7847746ab25a25c8c7 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 20 Sep 2024 07:22:56 +0000 Subject: [PATCH 05/10] Update snap version/tag --- rockcraft.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rockcraft.yaml b/rockcraft.yaml index 7a758eb..d62d440 100644 --- a/rockcraft.yaml +++ b/rockcraft.yaml @@ -1,6 +1,6 @@ name: ghostscript-printer-app base: ubuntu@22.04 -version: '10.03.0-10' +version: '10.03.0-11' summary: Ghostscript Printer Application description: | The Ghostscript Printer Application is a PAPPL (Printer Application @@ -1295,7 +1295,7 @@ parts: # https://sourceforge.net/projects/splix/ source: https://salsa.debian.org/printing-team/splix.git source-type: git - source-tag: debian/2.0.0+svn315-7 + source-tag: 'debian/2.0.1-1' source-depth: 1 # ext:updatesnap # version-format: From 6179d987484f6914b5ad1df1aec0f0b401a4c593 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 1 Oct 2024 07:23:16 +0000 Subject: [PATCH 06/10] Update snap version/tag --- rockcraft.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rockcraft.yaml b/rockcraft.yaml index d62d440..1f03eba 100644 --- a/rockcraft.yaml +++ b/rockcraft.yaml @@ -1,6 +1,6 @@ name: ghostscript-printer-app base: ubuntu@22.04 -version: '10.03.0-11' +version: '10.03.0-12' summary: Ghostscript Printer Application description: | The Ghostscript Printer Application is a PAPPL (Printer Application @@ -235,7 +235,7 @@ parts: cups: source: https://github.com/OpenPrinting/cups source-type: git - source-tag: 'v2.4.10' + source-tag: 'v2.4.11' source-depth: 1 # ext:updatesnap # version-format: From 53dca15f5dfdf30935698e194f44bcf7d2ad41b9 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 16 Oct 2024 07:22:19 +0000 Subject: [PATCH 07/10] Update snap version/tag --- rockcraft.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rockcraft.yaml b/rockcraft.yaml index 1f03eba..f09f78a 100644 --- a/rockcraft.yaml +++ b/rockcraft.yaml @@ -1,6 +1,6 @@ name: ghostscript-printer-app base: ubuntu@22.04 -version: '10.03.0-12' +version: '10.03.0-13' summary: Ghostscript Printer Application description: | The Ghostscript Printer Application is a PAPPL (Printer Application @@ -33,7 +33,7 @@ parts: pappl: source: https://github.com/michaelrsweet/pappl source-type: git - source-tag: 'v1.4.6' + source-tag: 'v1.4.7' source-depth: 1 # ext:updatesnap # version-format: From 937cbceef0c0d6b3734cec5ea3fc7056d4a192f8 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 18 Oct 2024 07:22:00 +0000 Subject: [PATCH 08/10] Update snap version/tag --- rockcraft.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rockcraft.yaml b/rockcraft.yaml index f09f78a..c39be0b 100644 --- a/rockcraft.yaml +++ b/rockcraft.yaml @@ -1,6 +1,6 @@ name: ghostscript-printer-app base: ubuntu@22.04 -version: '10.03.0-13' +version: '10.03.0-14' summary: Ghostscript Printer Application description: | The Ghostscript Printer Application is a PAPPL (Printer Application @@ -339,7 +339,7 @@ parts: libcupsfilters: source: https://github.com/OpenPrinting/libcupsfilters source-type: git - source-tag: '2.0.0' + source-tag: '2.1.0' source-depth: 1 # ext:updatesnap # version-format: @@ -406,7 +406,7 @@ parts: libppd: source: https://github.com/OpenPrinting/libppd source-type: git - source-tag: '2.0.0' + source-tag: '2.1.0' source-depth: 1 # ext:updatesnap # version-format: From fce8701f5fb4949440ecbdbca50d7182911649e2 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 1 Nov 2024 07:22:38 +0000 Subject: [PATCH 09/10] Update snap version/tag --- rockcraft.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rockcraft.yaml b/rockcraft.yaml index c39be0b..91ba435 100644 --- a/rockcraft.yaml +++ b/rockcraft.yaml @@ -1,6 +1,6 @@ name: ghostscript-printer-app base: ubuntu@22.04 -version: '10.03.0-14' +version: '10.05.0-1' summary: Ghostscript Printer Application description: | The Ghostscript Printer Application is a PAPPL (Printer Application @@ -192,7 +192,7 @@ parts: #source: https://git.ghostscript.com/ghostpdl.git source: https://github.com/ArtifexSoftware/ghostpdl.git source-type: git - source-tag: 'ghostpdl-10.03.0rc1_test' + source-tag: 'ghostpdl-10.05.0-test-base-001' source-depth: 1 # ext:updatesnap # version-format: From 99366f392959dbfb17c55dea53cb88e97c8e39af Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 15 Nov 2024 07:23:03 +0000 Subject: [PATCH 10/10] Update snap version/tag --- rockcraft.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rockcraft.yaml b/rockcraft.yaml index 91ba435..736468a 100644 --- a/rockcraft.yaml +++ b/rockcraft.yaml @@ -1,6 +1,6 @@ name: ghostscript-printer-app base: ubuntu@22.04 -version: '10.05.0-1' +version: '10.05.0-2' summary: Ghostscript Printer Application description: | The Ghostscript Printer Application is a PAPPL (Printer Application @@ -33,7 +33,7 @@ parts: pappl: source: https://github.com/michaelrsweet/pappl source-type: git - source-tag: 'v1.4.7' + source-tag: 'v1.4.8' source-depth: 1 # ext:updatesnap # version-format: