From c5fca92a08a8a63ad4d746b4d3a44a9cf724ea61 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Tue, 7 Sep 2021 02:46:07 +0200 Subject: Change buildsystem to use a ./configure script This is done to support webkit2gtk-4.1 (libsoup3) vs. webkit2gtk-4.0 (libsoup2). It will also be useful once WebKitGTK with support for GTK4 lands in badwolf. --- configure | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100755 configure (limited to 'configure') diff --git a/configure b/configure new file mode 100755 index 0000000..17510a0 --- /dev/null +++ b/configure @@ -0,0 +1,110 @@ +#!/bin/sh +VERSION=1.1.0 +VERSION_FULL=${VERSION}$(./version.sh) +PREFIX="${PREFIX:-/usr/local}" +BINDIR="${BINDIR:-${PREFIX}/bin}" +MANDIR="${MANDIR:-${PREFIX}/share/man}" +DOCDIR="${DOCDIR:-${PREFIX}/share/doc/badwolf-${VERSION}}" +DATADIR="${DATADIR:-${PREFIX}/share/badwolf}" +APPSDIR="${APPSDIR:-${PREFIX}/share/applications}" + +PKGCONFIG="${PKGCONFIG:-pkg-config}" +MSGFMT="${MSGFMT:-msgfmt}" +INKSCAPE="${INKSCAPE:-inkscape}" +CC="${CC:-cc}" +CFLAGS="${CFLAGS:--g -O2 -pie -fPIE} -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wall -Wextra -Wconversion -Wsign-conversion -Werror=implicit-function-declaration -Werror=implicit-int -Werror=vla ${EXTRA_CFLAGS}" + +DEPS="gtk+-3.0 libxml-2.0" + +is_ok() { + status="$?" + + if test "$status" == 0; then + printf " OK\n" + else + printf " FAIL\n" + fi + + return $status +} + +required() { + is_ok || exit 1 +} + +pkg_config_check() { + printf 'Checking: %s %s ...' "${PKGCONFIG}" "$*" + "${PKGCONFIG}" "$@" + is_ok +} + +printf 'Checking %s command existance ...' "${PKGCONFIG}" +command -v "${PKGCONFIG}" >/dev/null ; required + +printf 'Checking %s command existance ...' "${CC}" +command -v "${CC}" >/dev/null ; required + +for dep in ${DEPS} +do + pkg_config_check --exists "$dep" || exit 1 +done + +case "${WITH_WEBKITGTK}n" in + 4.1n) + pkg_config_check --atleast-version=2.32.0 webkit2gtk-4.1 || exit 1 + DEPS="${DEPS} webkit2gtk-4.1 libsoup-3.0" + ;; + 4.0n) + pkg_config_check --atleast-version=2.32.0 webkit2gtk-4.0 || exit 1 + DEPS="${DEPS} webkit2gtk-4.0 libsoup-2.4" + ;; + n) + echo "warning: Packagers should specify the ABI version (4.0 or 4.1) in WITH_WEBKITGTK" >&2 + if pkg_config_check --atleast-version=2.32.0 webkit2gtk-4.1 + then + DEPS="${DEPS} webkit2gtk-4.1 libsoup-3.0" + else + pkg_config_check --atleast-version=2.32.0 webkit2gtk-4.0 || exit 1 + DEPS="${DEPS} webkit2gtk-4.0 libsoup-2.4" + fi + ;; + *) + echo "error: invalid webkit2gtk version in WITH_WEBKITGTK environment variable, must be 4.0 or 4.1" >&2 + exit 1 + ;; +esac + +get_cflags() { "${PKGCONFIG}" --cflags "${DEPS}"; } +DEPS_cflags="$(get_cflags)" +get_libs() { "${PKGCONFIG}" --libs "${DEPS}"; } +DEPS_libs="$(get_libs)" + +ICON_SIZES="$(for i in 24 32 48 64 128 256; do printf 'icons/hicolor/%sx%s/apps/badwolf.png ' $i $i ; done)" + +printf 'Writing to config.mk ...' +cat >config.mk < Date: Sun, 19 Sep 2021 07:44:54 +0200 Subject: Switch from libsoup-2.4 to glib's GUri - SoupURI is gone in libsoup-3.0 - GUri got added in glib-2.66 - WebKitGTK 2.32.0 depends on >=glib-2.67 --- badwolf.c | 11 ++++++++--- badwolf.h | 2 +- configure | 8 ++++---- 3 files changed, 13 insertions(+), 8 deletions(-) (limited to 'configure') diff --git a/badwolf.c b/badwolf.c index 6ef4cf3..a0a7d09 100644 --- a/badwolf.c +++ b/badwolf.c @@ -439,7 +439,8 @@ WebViewCb_load_failed_with_tls_errors(WebKitWebView *web_view, struct Client *browser = (struct Client *)user_data; gchar *error_details = detail_tls_certificate_flags(errors); gint dialog_response; - SoupURI *failing_uri = soup_uri_new(failing_text); + + GUri *failing_uri = g_uri_parse(failing_text, G_URI_FLAGS_NONE, NULL); GtkWidget *dialog = gtk_message_dialog_new(GTK_WINDOW(browser->window->main_window), GTK_DIALOG_MODAL & GTK_DIALOG_DESTROY_WITH_PARENT, @@ -449,6 +450,10 @@ WebViewCb_load_failed_with_tls_errors(WebKitWebView *web_view, failing_text); gtk_dialog_add_buttons( GTK_DIALOG(dialog), _("Temporarily Add Exception"), 1, _("Continue"), 0, NULL); + if(!failing_uri) + { + gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), 1, FALSE); + } gtk_dialog_set_default_response(GTK_DIALOG(dialog), 0); gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog), "%s\n", error_details); @@ -457,11 +462,11 @@ WebViewCb_load_failed_with_tls_errors(WebKitWebView *web_view, if(dialog_response == 1) { webkit_web_context_allow_tls_certificate_for_host( - webkit_web_view_get_context(browser->webView), certificate, failing_uri->host); + webkit_web_view_get_context(browser->webView), certificate, g_uri_get_host(failing_uri)); webkit_web_view_reload(browser->webView); } - soup_uri_free(failing_uri); + g_free(failing_uri); g_free(error_details); gtk_widget_destroy(dialog); diff --git a/badwolf.h b/badwolf.h index 2b2882a..f751842 100644 --- a/badwolf.h +++ b/badwolf.h @@ -5,7 +5,7 @@ #include /* uint64_t */ #include -#if ! WEBKIT_CHECK_VERSION(2,32,0) +#if !WEBKIT_CHECK_VERSION(2, 32, 0) #error WebkitGTK 2.32.0 is the latest supported version for badwolf. #endif diff --git a/configure b/configure index 17510a0..c5fe4a8 100755 --- a/configure +++ b/configure @@ -52,20 +52,20 @@ done case "${WITH_WEBKITGTK}n" in 4.1n) pkg_config_check --atleast-version=2.32.0 webkit2gtk-4.1 || exit 1 - DEPS="${DEPS} webkit2gtk-4.1 libsoup-3.0" + DEPS="${DEPS} webkit2gtk-4.1" ;; 4.0n) pkg_config_check --atleast-version=2.32.0 webkit2gtk-4.0 || exit 1 - DEPS="${DEPS} webkit2gtk-4.0 libsoup-2.4" + DEPS="${DEPS} webkit2gtk-4.0" ;; n) echo "warning: Packagers should specify the ABI version (4.0 or 4.1) in WITH_WEBKITGTK" >&2 if pkg_config_check --atleast-version=2.32.0 webkit2gtk-4.1 then - DEPS="${DEPS} webkit2gtk-4.1 libsoup-3.0" + DEPS="${DEPS} webkit2gtk-4.1" else pkg_config_check --atleast-version=2.32.0 webkit2gtk-4.0 || exit 1 - DEPS="${DEPS} webkit2gtk-4.0 libsoup-2.4" + DEPS="${DEPS} webkit2gtk-4.0" fi ;; *) -- cgit v1.3.1-23-gd82d From dd3e46487b980fd0f2b9aa017b27e1af2f2bd07a Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Fri, 1 Oct 2021 21:19:58 +0200 Subject: Make: Add manpage linting mandb / GNU groff seems to have less tolerance than mandoc for rendering slightly broken manpages, which is rather annoying in my case. --- Makefile | 1 + README.md | 4 +++- configure | 11 +++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) (limited to 'configure') diff --git a/Makefile b/Makefile index 328da17..0ff8b3d 100644 --- a/Makefile +++ b/Makefile @@ -54,6 +54,7 @@ uri_test: uri.o uri_test.o .PHONY: test test: $(EXE_test) + $(MANDOC) -Tlint -Wunsupp,error,warning ./badwolf.1 .PHONY: install install: all diff --git a/README.md b/README.md index 5f61b0a..e5205e1 100644 --- a/README.md +++ b/README.md @@ -53,12 +53,14 @@ You need to have gettext installed. If you want a GUI, poedit exists and Weblate ## Manual Installation Dependencies are: +- POSIX-compatible Shell (ie. mrsh, dash, lksh) - C11 Compiler (such as clang or gcc) - [WebKitGTK](https://webkitgtk.org/), only the latest stable(2.32.0+) is supported - [libxml-2.0](http://www.xmlsoft.org/), no known version limitation - POSIX make with extension for shell in variables (works with GNU, {Net,Free,Open}BSD) - A pkg-config implementation (pkgconf is recommended) -- (optionnal) gettext implementation (such as GNU Gettext) +- (optional) gettext implementation (such as GNU Gettext) +- (optional, test) [mandoc](https://mdocml.bsd.lv/) (the command) for linting the manpage Compilation is done with `./configure && make`, install with `make install` (`DESTDIR` and `PREFIX` environment variables are supported, amongs other common ones). An example AppArmor profile is provided at `usr.bin.badwolf`, please do some long runtime checks before shipping it or a modified version, help can be provided but with no support. diff --git a/configure b/configure index c5fe4a8..b3e179a 100755 --- a/configure +++ b/configure @@ -13,6 +13,7 @@ MSGFMT="${MSGFMT:-msgfmt}" INKSCAPE="${INKSCAPE:-inkscape}" CC="${CC:-cc}" CFLAGS="${CFLAGS:--g -O2 -pie -fPIE} -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wall -Wextra -Wconversion -Wsign-conversion -Werror=implicit-function-declaration -Werror=implicit-int -Werror=vla ${EXTRA_CFLAGS}" +MANDOC="mandoc" DEPS="gtk+-3.0 libxml-2.0" @@ -44,6 +45,15 @@ command -v "${PKGCONFIG}" >/dev/null ; required printf 'Checking %s command existance ...' "${CC}" command -v "${CC}" >/dev/null ; required +printf 'Checking %s command existance ...' "${MANDOC}" +if command -v "${CC}" >/dev/null ; is_ok +then + : +else + MANDOC="true" +fi + + for dep in ${DEPS} do pkg_config_check --exists "$dep" || exit 1 @@ -100,6 +110,7 @@ CC = ${CC} INKSCAPE = ${INKSCAPE} MSGFMT = ${MSGFMT} DBG = ${DBG} +MANDOC = ${MANDOC} CFLAGS = ${CFLAGS} -DDATADIR=\"\${DATADIR}\" -DPACKAGE=\"\${PACKAGE}\" -D_XOPEN_SOURCE=700 -D_POSIX_C_SOURCE=200809L -DVERSION=\"\${VERSION_FULL}\" ${DEPS_cflags} LIBS = ${DEPS_libs} -- cgit v1.3.1-23-gd82d From 03503fcd1fcfe05a212dbf40083f5593ee2d9b52 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Sat, 2 Oct 2021 18:43:36 +0200 Subject: configure: Fix test case in is_ok For some reason this only broke in NetBSD while it's entirely out of POSIX. --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'configure') diff --git a/configure b/configure index b3e179a..9646723 100755 --- a/configure +++ b/configure @@ -20,7 +20,7 @@ DEPS="gtk+-3.0 libxml-2.0" is_ok() { status="$?" - if test "$status" == 0; then + if test $status -eq 0; then printf " OK\n" else printf " FAIL\n" -- cgit v1.3.1-23-gd82d From f539edf6f68be78e7be36a94f5020a6193f58867 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Sat, 2 Oct 2021 19:04:42 +0200 Subject: Bump to 1.2.0 --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'configure') diff --git a/configure b/configure index 9646723..3776bfa 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #!/bin/sh -VERSION=1.1.0 +VERSION=1.2.0 VERSION_FULL=${VERSION}$(./version.sh) PREFIX="${PREFIX:-/usr/local}" BINDIR="${BINDIR:-${PREFIX}/bin}" -- cgit v1.3.1-23-gd82d