#!/bin/sh
+
+# Note: Use "export CR_PAT=ghp_...." to make the github token available to this script
+# Use "export GH_USER=..." to set your github user
+# See https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry
+
cd docker
-docker build --progress=plain -f sigrok-mxe.Dockerfile .
+docker build --progress=plain -f sigrok-mxe.Dockerfile -t sigrok-mxe . && \
+ echo $CR_PAT | docker login ghcr.io -u $GH_USER --password-stdin && \
+ docker push ghcr.io/$GH_USER/sigrok-mxe:latest
cd ..
--- /dev/null
+From a69d26c8a1291ecd4febbec7ccc0b0d43410b09d Mon Sep 17 00:00:00 2001
+From: Thomas Hebb <tommyhebb@gmail.com>
+Date: Fri, 16 Jul 2021 22:31:49 -0700
+Subject: [PATCH] hidapi: Switch source to new GitHub repo and update
+
+The README at https://github.com/libusb/hidapi says "HIDAPI library was
+originally developed by Alan Ott (signal11). It was moved to
+libusb/hidapi on June 4th, 2019, in order to merge important bugfixes
+and continue development of the library." As such, the libusb version is
+now the official repository and we should use it.
+
+Also update to the latest master. Among other things, this fixes a
+[bug][autoconf-fix] that broke the build on new versions of autoconf
+(2.70 and later).
+
+[autoconf-fix]: https://github.com/libusb/hidapi/pull/226
+---
+ src/hidapi.mk | 8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/src/hidapi.mk b/src/hidapi.mk
+index c92e359f7c..5814db2e01 100644
+--- a/src/hidapi.mk
++++ b/src/hidapi.mk
+@@ -1,12 +1,12 @@
+ # This file is part of MXE. See LICENSE.md for licensing information.
+
+ PKG := hidapi
+-$(PKG)_WEBSITE := https://github.com/signal11/hidapi/
++$(PKG)_WEBSITE := https://github.com/libusb/hidapi/
+ $(PKG)_DESCR := HIDAPI
+ $(PKG)_IGNORE :=
+-$(PKG)_VERSION := a6a622f
+-$(PKG)_CHECKSUM := 32ea444bdd6c6a8a940bfa3287a2dc8c291a141fdc78cd638b37b546b44d95be
+-$(PKG)_GH_CONF := signal11/hidapi/branches/master
++$(PKG)_VERSION := 2a24bf9
++$(PKG)_CHECKSUM := fcf650c10ccd39c47cc86ffd676befc71dd74bd8367f6716418974830f218d1f
++$(PKG)_GH_CONF := libusb/hidapi/branches/master
+ $(PKG)_DEPS := cc
+
+ define $(PKG)_BUILD
&& git reset --hard b48b3cc7085548e896fe967dc6371ff9951390a4 \
&& patch -p1 < $BASE_DIR/mxe_fixes.patch
-make -j$(nproc) MXE_USE_CCACHE= DONT_CHECK_REQUIREMENTS=1 MXE_TARGETS="$MXE_TARGETS" MXE_PLUGIN_DIRS="$MXE_PLUGIN_DIRS" gcc
-make -j$(nproc) MXE_USE_CCACHE= DONT_CHECK_REQUIREMENTS=1 MXE_TARGETS="$MXE_TARGETS" MXE_PLUGIN_DIRS="$MXE_PLUGIN_DIRS" glib
-make -j$(nproc) MXE_USE_CCACHE= DONT_CHECK_REQUIREMENTS=1 MXE_TARGETS="$MXE_TARGETS" MXE_PLUGIN_DIRS="$MXE_PLUGIN_DIRS" \
+RUN cd $MXE_DIR && make -j$(nproc) MXE_USE_CCACHE= DONT_CHECK_REQUIREMENTS=1 MXE_TARGETS="$MXE_TARGETS" MXE_PLUGIN_DIRS="$MXE_PLUGIN_DIRS" gcc
+RUN cd $MXE_DIR && make -j$(nproc) MXE_USE_CCACHE= DONT_CHECK_REQUIREMENTS=1 MXE_TARGETS="$MXE_TARGETS" MXE_PLUGIN_DIRS="$MXE_PLUGIN_DIRS" glib
+RUN cd $MXE_DIR && make -j$(nproc) MXE_USE_CCACHE= DONT_CHECK_REQUIREMENTS=1 MXE_TARGETS="$MXE_TARGETS" MXE_PLUGIN_DIRS="$MXE_PLUGIN_DIRS" \
libzip \
libusb1 \
- libftdi1 \
- hidapi \
-make -j$(nproc) MXE_USE_CCACHE= DONT_CHECK_REQUIREMENTS=1 MXE_TARGETS="$MXE_TARGETS" MXE_PLUGIN_DIRS="$MXE_PLUGIN_DIRS" \
+ libftdi1
+
+COPY hidapi_fixes.patch $BASE_DIR
+RUN cd $MXE_DIR && patch -p1 < $BASE_DIR/hidapi_fixes.patch
+RUN cd $MXE_DIR && make -j$(nproc) MXE_USE_CCACHE= DONT_CHECK_REQUIREMENTS=1 MXE_TARGETS="$MXE_TARGETS" MXE_PLUGIN_DIRS="$MXE_PLUGIN_DIRS" hidapi
+
+RUN cd $MXE_DIR && make -j$(nproc) MXE_USE_CCACHE= DONT_CHECK_REQUIREMENTS=1 MXE_TARGETS="$MXE_TARGETS" MXE_PLUGIN_DIRS="$MXE_PLUGIN_DIRS" \
glibmm \
qtbase \
qtimageformats
-make -j$(nproc) MXE_USE_CCACHE= DONT_CHECK_REQUIREMENTS=1 MXE_TARGETS="$MXE_TARGETS" MXE_PLUGIN_DIRS="$MXE_PLUGIN_DIRS" \
+RUN cd $MXE_DIR && make -j$(nproc) MXE_USE_CCACHE= DONT_CHECK_REQUIREMENTS=1 MXE_TARGETS="$MXE_TARGETS" MXE_PLUGIN_DIRS="$MXE_PLUGIN_DIRS" \
qtsvg \
qttools \
- qttranslations \
-make -j$(nproc) MXE_USE_CCACHE= DONT_CHECK_REQUIREMENTS=1 MXE_TARGETS="$MXE_TARGETS" MXE_PLUGIN_DIRS="$MXE_PLUGIN_DIRS" \
- boost \
-make -j$(nproc) MXE_USE_CCACHE= DONT_CHECK_REQUIREMENTS=1 MXE_TARGETS="$MXE_TARGETS" MXE_PLUGIN_DIRS="$MXE_PLUGIN_DIRS" \
+ qttranslations
+RUN cd $MXE_DIR && make -j$(nproc) MXE_USE_CCACHE= DONT_CHECK_REQUIREMENTS=1 MXE_TARGETS="$MXE_TARGETS" MXE_PLUGIN_DIRS="$MXE_PLUGIN_DIRS" boost
+RUN cd $MXE_DIR && make -j$(nproc) MXE_USE_CCACHE= DONT_CHECK_REQUIREMENTS=1 MXE_TARGETS="$MXE_TARGETS" MXE_PLUGIN_DIRS="$MXE_PLUGIN_DIRS" \
check \
gendef \
libieee1284 \
nettle \
qwt \
qtbase_CONFIGURE_OPTS='-no-sql-mysql'
-rm -rf $MXE_DIR/.log \
+
+RUN rm -rf $MXE_DIR/.log \
&& rm -rf $MXE_DIR/mxe/pkg