Skip to content

Commit c6f3af3

Browse files
authored
Merge pull request #228047 from nibon7/master
gnome-papers 48.5 (new formula)
2 parents f64f9a5 + 40bd890 commit c6f3af3

File tree

1 file changed

+148
-0
lines changed

1 file changed

+148
-0
lines changed

Formula/g/gnome-papers.rb

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
class GnomePapers < Formula
2+
desc "Document viewer for PDF and other document formats aimed at the GNOME desktop"
3+
homepage "https://apps.gnome.org/Papers/"
4+
url "https://download.gnome.org/sources/papers/48/papers-48.5.tar.xz"
5+
sha256 "0cc8d72c71d3d8aab1be10ae1941a4cd92cd1e2a7e830ab7680e2c82dfb19c0b"
6+
license "GPL-2.0-or-later"
7+
8+
bottle do
9+
sha256 arm64_sequoia: "d9708f3c4d341496455119f0cbf14e9feb94bcfa3a6742f1ba1ac2b8a330d2d1"
10+
sha256 arm64_sonoma: "8a46f67637a9c9126948caa7b93048ee24aa314f9cc6a8f0b1ac664bf2bc0771"
11+
sha256 arm64_ventura: "95f5d01e5cc470b223e26df75f92d968554e07856150f8b61e66c1a369d5f7a7"
12+
sha256 sonoma: "977966489988c8819b3b5b53bdbb5e584edc9618a7c6a6d256dae5a1cdd1ef8e"
13+
sha256 ventura: "6594e4cb62781155b467d0db3928f2288586774537f3ce1a9c003740003564f6"
14+
sha256 x86_64_linux: "719b56150089db56278c1493c45dcfdfc75d25f0cc921a59e6e557e601ea6ea0"
15+
end
16+
17+
depends_on "desktop-file-utils" => :build
18+
depends_on "gobject-introspection" => :build
19+
depends_on "itstool" => :build
20+
depends_on "meson" => :build
21+
depends_on "ninja" => :build
22+
depends_on "pkgconf" => [:build, :test]
23+
depends_on "rust" => :build
24+
25+
depends_on "adwaita-icon-theme"
26+
depends_on "cairo"
27+
depends_on "djvulibre"
28+
depends_on "exempi"
29+
depends_on "gdk-pixbuf"
30+
depends_on "glib"
31+
depends_on "gtk4"
32+
depends_on "hicolor-icon-theme"
33+
depends_on "libadwaita"
34+
depends_on "libarchive"
35+
depends_on "libspelling"
36+
depends_on "libtiff"
37+
depends_on "poppler"
38+
39+
uses_from_macos "zlib"
40+
41+
on_macos do
42+
depends_on "gettext"
43+
end
44+
45+
on_linux do
46+
depends_on "gettext" => :build # for msgfmt
47+
end
48+
49+
def install
50+
ENV["DESTDIR"] = "/"
51+
52+
if OS.mac?
53+
# https://github.com/gettext-rs/gettext-rs/tree/master/gettext-sys#environment-variables
54+
ENV["GETTEXT_DIR"] = Formula["gettext"].prefix.to_s
55+
56+
ENV.append "RUSTFLAGS", "--codegen link-args=-Wl,-rpath,#{rpath}"
57+
end
58+
59+
# Export pps_job_run for testing. Remove this workaround in 49.x.
60+
inreplace "libview/pps-job.h", /^(gboolean pps_job_run)/, "PPS_PUBLIC \\1"
61+
62+
args = %w[
63+
-Dviewer=true
64+
-Dpreviewer=true
65+
-Dthumbnailer=true
66+
-Dnautilus=false
67+
-Dcomics=enabled
68+
-Ddjvu=enabled
69+
-Dpdf=enabled
70+
-Dtiff=enabled
71+
-Dtests=false
72+
-Ddocumentation=false
73+
-Duser_doc=false
74+
-Dintrospection=enabled
75+
-Dsysprof=disabled
76+
-Dkeyring=enabled
77+
-Dgtk_unix_print=enabled
78+
-Dspell_check=enabled
79+
]
80+
81+
system "meson", "setup", "build", *args, *std_meson_args
82+
system "meson", "compile", "-C", "build", "--verbose"
83+
system "meson", "install", "-C", "build"
84+
end
85+
86+
def post_install
87+
system Formula["glib"].opt_bin/"glib-compile-schemas", HOMEBREW_PREFIX/"share/glib-2.0/schemas"
88+
system Formula["gtk4"].opt_bin/"gtk4-update-icon-cache", "-f", "-t", HOMEBREW_PREFIX/"share/icons/hicolor"
89+
end
90+
91+
test do
92+
resource "test-pdf" do
93+
url "https://gitlab.freedesktop.org/poppler/test/-/raw/1aca8a13eeaa37403f9330febcb4745affcfd139/tests/text.pdf"
94+
sha256 "9fac4cf9ac688f067ee38ddddcf9f237d4f6adf29601672e4ef1765c63997880"
95+
end
96+
97+
resource("test-pdf").stage testpath
98+
(testpath/"test.c").write <<~C
99+
#include <glib.h>
100+
#define I_KNOW_THE_PAPERS_LIBS_ARE_UNSTABLE_AND_HAVE_TALKED_WITH_THE_AUTHORS
101+
#include <papers-document.h>
102+
#include <papers-view.h>
103+
104+
int main(void) {
105+
g_autoptr(GFile) file = NULL;
106+
g_autoptr(PpsJob) job = NULL;
107+
g_autoptr(PpsDocument) document = NULL;
108+
g_autoptr(PpsPage) page = NULL;
109+
g_autofree gchar *uri = NULL;
110+
const gchar *file_path = "text.pdf";
111+
gint n_pages;
112+
gboolean has_backend;
113+
114+
has_backend = pps_init();
115+
g_assert_true(has_backend);
116+
117+
file = g_file_new_for_path(file_path);
118+
g_assert_nonnull(file);
119+
120+
uri = g_file_get_uri(file);
121+
g_assert_nonnull(uri);
122+
123+
job = pps_job_load_new();
124+
g_assert_nonnull(job);
125+
126+
pps_job_load_set_uri(PPS_JOB_LOAD(job), uri);
127+
pps_job_run(job);
128+
129+
document = pps_job_load_get_loaded_document(PPS_JOB_LOAD(job));
130+
g_assert_nonnull(document);
131+
132+
n_pages = pps_document_get_n_pages(document);
133+
g_assert(n_pages == 1);
134+
135+
page = pps_document_get_page(document, 0);
136+
g_assert_nonnull(page);
137+
138+
pps_shutdown();
139+
140+
return 0;
141+
}
142+
C
143+
pkg_config_flags = shell_output("pkg-config --cflags --libs papers-document-4.0 papers-view-4.0").chomp.split
144+
system ENV.cc, "test.c", *pkg_config_flags
145+
system "./a.out"
146+
assert_match version.to_s, shell_output("#{bin}/papers --version")
147+
end
148+
end

0 commit comments

Comments
 (0)