From 55112eb54a1c4cfaec5dd2592a39cea72f78ed56 Mon Sep 17 00:00:00 2001 From: Ulysses1337 <2980728+Ulysses1337@users.noreply.github.com> Date: Wed, 24 Aug 2022 17:08:34 +0100 Subject: [PATCH] [mchehab-zbar] Add new port (#16113) * Add mchehab/zbar * Quote all paths Co-authored-by: Cheney Wang <38240633+Cheney-W@users.noreply.github.com> * Update to 0.23.90 * Flip name * Update version registry Co-authored-by: Cheney Wang <38240633+Cheney-W@users.noreply.github.com> --- ports/mchehab-zbar/c99.patch | 89 ++++++++++++++++++++ ports/mchehab-zbar/issue219.patch | 13 +++ ports/mchehab-zbar/portfile.cmake | 48 +++++++++++ ports/mchehab-zbar/vcpkg.json | 11 +++ ports/mchehab-zbar/windows.patch | 68 +++++++++++++++ ports/mchehab-zbar/x64.patch | 21 +++++ scripts/buildsystems/make_wrapper/windres-rc | 48 +++++------ versions/baseline.json | 4 + versions/m-/mchehab-zbar.json | 9 ++ 9 files changed, 284 insertions(+), 27 deletions(-) create mode 100644 ports/mchehab-zbar/c99.patch create mode 100644 ports/mchehab-zbar/issue219.patch create mode 100644 ports/mchehab-zbar/portfile.cmake create mode 100644 ports/mchehab-zbar/vcpkg.json create mode 100644 ports/mchehab-zbar/windows.patch create mode 100644 ports/mchehab-zbar/x64.patch create mode 100644 versions/m-/mchehab-zbar.json diff --git a/ports/mchehab-zbar/c99.patch b/ports/mchehab-zbar/c99.patch new file mode 100644 index 0000000000..8b906fcaa9 --- /dev/null +++ b/ports/mchehab-zbar/c99.patch @@ -0,0 +1,89 @@ +diff --git a/zbar/symbol.c b/zbar/symbol.c +index 27dbc87..1059a72 100644 +--- a/zbar/symbol.c ++++ b/zbar/symbol.c +@@ -100,40 +100,29 @@ const char *zbar_get_orientation_name (zbar_orientation_t orient) + + int _zbar_get_symbol_hash (zbar_symbol_type_t sym) + { +- static const signed char hash[ZBAR_CODE128 + 1] = { +- [0 ... ZBAR_CODE128] = -1, +- +- /* [ZBAR_FOO] = 0, is empty */ +- [ZBAR_SQCODE] = 1, +- [ZBAR_CODE128] = 2, +- [ZBAR_EAN13] = 3, +- [ZBAR_UPCA] = 4, +- [ZBAR_EAN8] = 5, +- [ZBAR_UPCE] = 6, +- [ZBAR_ISBN13] = 7, +- [ZBAR_ISBN10] = 8, +- [ZBAR_CODE39] = 9, +- [ZBAR_I25] = 10, +- [ZBAR_PDF417] = 11, +- [ZBAR_QRCODE] = 12, +- [ZBAR_DATABAR] = 13, +- [ZBAR_DATABAR_EXP] = 14, +- [ZBAR_CODE93] = 15, +- [ZBAR_EAN2] = 16, +- [ZBAR_EAN5] = 17, +- [ZBAR_COMPOSITE] = 18, +- [ZBAR_CODABAR] = 19, +- +- /* Please update NUM_SYMS accordingly */ +- }; +- int h; +- +- assert (sym >= ZBAR_PARTIAL && sym <= ZBAR_CODE128); +- +- h = hash[sym]; +- assert (h >= 0 && h < NUM_SYMS); +- +- return h; ++ switch(sym) ++ { ++ default: return -1; ++ case ZBAR_SQCODE: return 1; ++ case ZBAR_CODE128: return 2; ++ case ZBAR_EAN13: return 3; ++ case ZBAR_UPCA: return 4; ++ case ZBAR_EAN8: return 5; ++ case ZBAR_UPCE: return 6; ++ case ZBAR_ISBN13: return 7; ++ case ZBAR_ISBN10: return 8; ++ case ZBAR_CODE39: return 9; ++ case ZBAR_I25: return 10; ++ case ZBAR_PDF417: return 11; ++ case ZBAR_QRCODE: return 12; ++ case ZBAR_DATABAR: return 13; ++ case ZBAR_DATABAR_EXP: return 14; ++ case ZBAR_CODE93: return 15; ++ case ZBAR_EAN2: return 16; ++ case ZBAR_EAN5: return 17; ++ case ZBAR_COMPOSITE: return 18; ++ case ZBAR_CODABAR: return 19; ++ } + } + + void _zbar_symbol_free (zbar_symbol_t *sym) +diff --git a/zbar/window/win.c b/zbar/window/win.c +index b949f65..7edcfa2 100644 +--- a/zbar/window/win.c ++++ b/zbar/window/win.c +@@ -194,7 +194,7 @@ int _zbar_window_draw_polygon (zbar_window_t *w, + win_set_rgb(hdc, rgb); + + point_t org = w->scaled_offset; +- POINT gdipts[npts + 1]; ++ POINT* gdipts = malloc((npts + 1) * sizeof(POINT)); + int i; + for(i = 0; i < npts; i++) { + point_t p = window_scale_pt(w, pts[i]); +@@ -204,6 +204,7 @@ int _zbar_window_draw_polygon (zbar_window_t *w, + gdipts[npts] = gdipts[0]; + + Polyline(hdc, gdipts, npts + 1); ++ free(gdipts); + return(0); + } + diff --git a/ports/mchehab-zbar/issue219.patch b/ports/mchehab-zbar/issue219.patch new file mode 100644 index 0000000000..2f86a7c3aa --- /dev/null +++ b/ports/mchehab-zbar/issue219.patch @@ -0,0 +1,13 @@ +diff --git a/zbar/decoder/databar.c b/zbar/decoder/databar.c +index 8cfa848..ffb972e 100644 +--- a/zbar/decoder/databar.c ++++ b/zbar/decoder/databar.c +@@ -695,7 +695,7 @@ lookup_sequence (databar_segment_t *seg, + seq[i++] = s; + } + dbprintf(2, "}"); +- seq[n] = -1; ++ if (n<22) {seq[n]=-1;} /* https://github.com/mchehab/zbar/issues/219 */ + return(fixed < 1); + } + diff --git a/ports/mchehab-zbar/portfile.cmake b/ports/mchehab-zbar/portfile.cmake new file mode 100644 index 0000000000..57d5da97a7 --- /dev/null +++ b/ports/mchehab-zbar/portfile.cmake @@ -0,0 +1,48 @@ +if(EXISTS ${CURRENT_INSTALLED_DIR}/share/zbar/copyright) + message(FATAL_ERROR "${PORT} conflicts with zbar. Please remove zbar before installing ${PORT}.") +endif() + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO mchehab/zbar + REF 0.23.90 + SHA512 d73d71873bec68ee021997512a9edbd223f5f5fe43c66c4dd3502224ba6009be2e5e1714766cb8e1056244673e87e0939ed0319116f61d7371b5ab79fb5e04eb + HEAD_REF master + PATCHES + c99.patch + issue219.patch + windows.patch + x64.patch +) + +vcpkg_configure_make( + SOURCE_PATH "${SOURCE_PATH}" + NO_ADDITIONAL_PATHS + ADD_BIN_TO_PATH + ADDITIONAL_MSYS_PACKAGES findutils gettext gettext-devel liblzma tar xz + OPTIONS + --disable-video + --without-gtk + --without-imagemagick + --without-java + --without-python + --without-qt +) + +vcpkg_install_make() +vcpkg_copy_pdbs() +vcpkg_fixup_pkgconfig() + +if(VCPKG_LIBRARY_LINKAGE STREQUAL static) + file(REMOVE_RECURSE + "${CURRENT_PACKAGES_DIR}/bin" + "${CURRENT_PACKAGES_DIR}/debug/bin") +endif() + +file(REMOVE_RECURSE + "${CURRENT_PACKAGES_DIR}/debug/include" + "${CURRENT_PACKAGES_DIR}/debug/share" + "${CURRENT_PACKAGES_DIR}/share/doc") + +file(RENAME "${CURRENT_PACKAGES_DIR}/share/zbar" "${CURRENT_PACKAGES_DIR}/share/${PORT}") +configure_file("${SOURCE_PATH}/COPYING" "${CURRENT_PACKAGES_DIR}/share/${PORT}/copyright" COPYONLY) diff --git a/ports/mchehab-zbar/vcpkg.json b/ports/mchehab-zbar/vcpkg.json new file mode 100644 index 0000000000..8a2be0ce1a --- /dev/null +++ b/ports/mchehab-zbar/vcpkg.json @@ -0,0 +1,11 @@ +{ + "name": "mchehab-zbar", + "version": "0.23.90", + "description": "ZBar is an open source software suite for reading bar codes from various sources, including webcams. This fork is actively maintained.", + "homepage": "https://github.com/mchehab/zbar", + "license": "LGPL-2.1-or-later", + "supports": "windows & !uwp", + "dependencies": [ + "libiconv" + ] +} diff --git a/ports/mchehab-zbar/windows.patch b/ports/mchehab-zbar/windows.patch new file mode 100644 index 0000000000..3e950ec146 --- /dev/null +++ b/ports/mchehab-zbar/windows.patch @@ -0,0 +1,68 @@ +diff --git a/configure.ac b/configure.ac +index c8fea14..eb0a097 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -55,7 +55,7 @@ AC_DEFINE_UNQUOTED([LIB_VERSION_REVISION], + [Library revision]) + + AM_CPPFLAGS="-I\$(top_srcdir)/include" +-AM_CFLAGS="-Wall -Wno-parentheses" ++AM_CFLAGS="-Wall" + AM_CXXFLAGS="$AM_CFLAGS" + AC_SUBST([AM_CPPFLAGS]) + AC_SUBST([AM_CFLAGS]) +diff --git a/zbar/Makefile.am b/zbar/Makefile.am +index ca54d01..6c0cd83 100644 +--- a/zbar/Makefile.am ++++ b/zbar/Makefile.am +@@ -68,7 +68,7 @@ if WIN32 + + libzbar_la_SOURCES += processor/win.c libzbar.rc + libzbar_la_CPPFLAGS += -mthreads +-libzbar_la_LDFLAGS += -mthreads ++libzbar_la_LDFLAGS += -mthreads -Xcompiler -Wl,-DEBUG + # FIXME broken + libzbar_la_LIBADD += libzbar-rc.lo + else +diff --git a/zbar/libzbar.rc b/zbar/libzbar.rc +index 413635b..c241f82 100644 +--- a/zbar/libzbar.rc ++++ b/zbar/libzbar.rc +@@ -17,8 +17,7 @@ VS_VERSION_INFO VERSIONINFO + VALUE "InternalName", "libzbar" + VALUE "OriginalFilename", "libzbar-" XSTR(LIB_VERSION_MAJOR) ".dll" + +- VALUE "FileVersion", XSTR(LIB_VERSION_MAJOR) "." \ +- XSTR(LIB_VERSION_MINOR) "." XSTR(LIB_VERSION_REVISION) ++ VALUE "FileVersion", XSTR(LIB_VERSION_MAJOR) "." XSTR(LIB_VERSION_MINOR) "." XSTR(LIB_VERSION_REVISION) + VALUE "ProductVersion", PACKAGE_VERSION + + VALUE "FileDescription", "Bar code reader library" +diff --git a/zbar/processor.h b/zbar/processor.h +index d5e9fef..54d6584 100644 +--- a/zbar/processor.h ++++ b/zbar/processor.h +@@ -27,7 +27,9 @@ + #ifdef HAVE_INTTYPES_H + # include + #endif +-#include ++#ifndef WIN32 ++# include ++#endif + #include + #include + +diff --git a/zbar/thread.h b/zbar/thread.h +index 96d6415..252d3f2 100644 +--- a/zbar/thread.h ++++ b/zbar/thread.h +@@ -35,7 +35,7 @@ + # define HAVE_THREADS + # define ZTHREAD DWORD WINAPI + +-typedef ZTHREAD (zbar_thread_proc_t)(void*); ++typedef ZTHREAD zbar_thread_proc_t(void*); + + typedef DWORD zbar_thread_id_t; + diff --git a/ports/mchehab-zbar/x64.patch b/ports/mchehab-zbar/x64.patch new file mode 100644 index 0000000000..c8eefac8ed --- /dev/null +++ b/ports/mchehab-zbar/x64.patch @@ -0,0 +1,21 @@ +diff --git a/zbar/decoder.c b/zbar/decoder.c +index 7f7336f..e9ffc45 100644 +--- a/zbar/decoder.c ++++ b/zbar/decoder.c +@@ -25,6 +25,7 @@ + #include /* malloc, calloc, free */ + #include /* snprintf */ + #include /* memset, strlen */ ++#include /* offsetof */ + + #include + +@@ -113,7 +114,7 @@ void zbar_decoder_destroy (zbar_decoder_t *dcode) + + void zbar_decoder_reset (zbar_decoder_t *dcode) + { +- memset(dcode, 0, (long)&dcode->buf_alloc - (long)dcode); ++ memset(dcode, 0, offsetof(zbar_decoder_t, buf_alloc)); + #if ENABLE_EAN == 1 + ean_reset(&dcode->ean); + #endif diff --git a/scripts/buildsystems/make_wrapper/windres-rc b/scripts/buildsystems/make_wrapper/windres-rc index b695744fcc..9d20158f1f 100755 --- a/scripts/buildsystems/make_wrapper/windres-rc +++ b/scripts/buildsystems/make_wrapper/windres-rc @@ -1,7 +1,7 @@ #! /bin/sh # Wrapper for windres to rc which do not understand '-i -o --output-format'. # cvtres is invoked by the linker -scriptversion=2021-04-02.18; # UTC +scriptversion=2022-08-24.12; # UTC nl=' @@ -59,67 +59,61 @@ func_file_conv () func_windres_wrapper () { # Assume a capable shell + bin= in= out= for arg do - if test -n "$eat"; then + if test -z "$bin"; then + bin=$1 + elif test -n "$eat"; then eat= else case $1 in + --output-format=*) + ;; --define*) - eat=1 - set x "$@" "-d $2" - shift - ;; + eat=1 + set -- "$@" "-d $2" + ;; --include-dir*) - eat=1 - func_file_conv "$2" - set x "$@" "-I $file" - shift - ;; + eat=1 + func_file_conv "$2" + set -- "$@" "-I $file" + ;; -o) eat=1 func_file_conv "$2" out="$file" echo "OUTPUT:$file" - set x "$@" - shift ;; *.obj) func_file_conv "$1" out="$file" echo "OUTPUT:$file" - set x "$@" - shift - ;; - --output-format=*) - set x "$@" - shift ;; -i) eat=1 func_file_conv "$2" mingw in="$file" echo "INPUT:$file" - set x "$@" - shift ;; -*) - set x "$@" "${1//\\\"/\"}" - shift + set -- "$@" "${1//\\\"/\"}" ;; *) - set x "$@" "$1" - shift + # libtool reorders arguments; save unqualified one as input + func_file_conv "$1" + in="$file" + echo "INPUT:$file" ;; esac fi shift done - echo "$@" -fo "$out" "$in" - exec "$@" -fo "$out" "$in" + echo "$bin" "$@" -fo "$out" "$in" + exec "$bin" "$@" -fo "$out" "$in" exit 1 } diff --git a/versions/baseline.json b/versions/baseline.json index 3765579927..8904762f74 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -4552,6 +4552,10 @@ "baseline": "2.28.1", "port-version": 0 }, + "mchehab-zbar": { + "baseline": "0.23.90", + "port-version": 0 + }, "mcpp": { "baseline": "2.7.2.14", "port-version": 3 diff --git a/versions/m-/mchehab-zbar.json b/versions/m-/mchehab-zbar.json new file mode 100644 index 0000000000..8b4e71c46c --- /dev/null +++ b/versions/m-/mchehab-zbar.json @@ -0,0 +1,9 @@ +{ + "versions": [ + { + "git-tree": "7c066057a5c24bbea65e26e9e7519db938a2932e", + "version": "0.23.90", + "port-version": 0 + } + ] +}