diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml new file mode 100644 index 00000000..665d0fa5 --- /dev/null +++ b/.github/workflows/macos.yml @@ -0,0 +1,41 @@ +name: check-macos +on: + push: + branches: [ "macos" ] + pull_request: + branches: [ "master" ] + +jobs: + macos-build: + runs-on: macos-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Install Pre reqs + run: | + brew remove azure-cli + find /usr/local/bin -lname '*/Library/Frameworks/Python.framework/*' -delete + find /usr/local/bin -lname '*/Library/Frameworks/Python.framework/*' -delete + rm -rf /usr/local/bin/2to3* + rm -rf /usr/local/bin/idle3* + rm -rf /usr/local/bin/pydoc3* + rm -rf /usr/local/bin/python3 + rm -rf /usr/local/bin/python3-config + rm -rf /usr/local/bin/python3* + rm -rf /usr/local/bin/python3*-config + find /usr/local/lib/node_modules/npm -delete + brew update + brew install xz automake libtool binutils coreutils curl gettext libtool openssl pkgconfig gtk+3 + - uses: robinraju/release-downloader@v1.7 + with: + repository: "PerryWerneck/lib3270" + latest: true + fileName: "macos-lib3270.tar.xz" + - uses: robinraju/release-downloader@v1.7 + with: + repository: "PerryWerneck/libv3270" + latest: true + fileName: "macos-libv3270.tar.xz" + - name: build + run: ./mac/ci-build.sh + diff --git a/.github/workflows/msys2.yml b/.github/workflows/msys2.yml index ed92a25c..a56d1e87 100644 --- a/.github/workflows/msys2.yml +++ b/.github/workflows/msys2.yml @@ -1,25 +1,18 @@ -name: MSYS2 +name: check-msys2 on: - pull_request: - branches: - - master push: - branches: - - develop + branches: [ "win" ] + pull_request: + branches: [ "master" ] + jobs: - msys2-mingw: - name: Publish Windows 64 + msys2-build: runs-on: windows-latest defaults: run: shell: msys2 {0} steps: - uses: actions/checkout@v3 - - uses: oprypin/find-latest-tag@v1 - id: gettag - with: - repository: PerryWerneck/pw3270 - releases-only: true - uses: msys2/setup-msys2@v2 with: msystem: mingw64 @@ -36,6 +29,9 @@ jobs: latest: true fileName: "mingw-w64-x86_64-libv3270-5.4-0-x86_64.pkg.tar.zst" - name: CI-Build - run: ./win/ci-build.sh + run: | + pacman -U --noconfirm *.pkg.tar.zst + dos2unix PKGBUILD.mingw + makepkg BUILDDIR=/tmp/pkg -p PKGBUILD.mingw diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..091631e3 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,140 @@ +name: Publish +on: + push: + branches: [ "publish" ] + tags: [ "*" ] + +jobs: + msys2-publish: + runs-on: windows-latest + defaults: + run: + shell: msys2 {0} + steps: + - uses: actions/checkout@v3 + - uses: msys2/setup-msys2@v2 + with: + msystem: mingw64 + update: true + install: dos2unix mingw-w64-x86_64-gcc automake autoconf make git zip pkgconf mingw-w64-x86_64-gettext gettext-devel mingw-w64-x86_64-openssl libtool mingw-w64-x86_64-gtk3 mingw-w64-x86_64-imagemagick mingw-w64-x86_64-optipng mingw-w64-x86_64-inkscape mingw-w64-x86_64-nsis + - uses: robinraju/release-downloader@v1.7 + with: + repository: "PerryWerneck/lib3270" + latest: true + fileName: "mingw-w64-x86_64-lib3270-5.4-0-x86_64.pkg.tar.zst" + - uses: robinraju/release-downloader@v1.7 + with: + repository: "PerryWerneck/libv3270" + latest: true + fileName: "mingw-w64-x86_64-libv3270-5.4-0-x86_64.pkg.tar.zst" + - uses: robinraju/release-downloader@v1.7 + with: + repository: PerryWerneck/libipc3270 + latest: true + fileName: mingw-w64-x86_64-libipc3270-5.5-0-x86_64.pkg.tar.zst + - uses: robinraju/release-downloader@v1.7 + with: + repository: PerryWerneck/libhllapi + latest: true + fileName: mingw-w64-x86_64-libhllapi-5.5-0-x86_64.pkg.tar.zst + - uses: robinraju/release-downloader@v1.7 + with: + repository: PerryWerneck/pw3270-plugin-ipc + latest: true + fileName: mingw-w64-x86_64-pw3270-plugin-ipc-5.5-0-x86_64.pkg.tar.zst + - name: MakePackage + run: | + pacman -U --noconfirm *.pkg.tar.zst + dos2unix PKGBUILD.mingw + makepkg BUILDDIR=/tmp/pkg -p PKGBUILD.mingw + - uses: oprypin/find-latest-tag@v1 + id: gettag + with: + repository: PerryWerneck/pw3270 + sort-tags: true + releases-only: true + - uses: ncipollo/release-action@v1 + with: + tag: ${{ steps.gettag.outputs.tag }} + artifacts: "*-pw3270-5*.pkg.tar.zst" + allowUpdates: true + draft: true + makeLatest: true + omitBody: true + omitPrereleaseDuringUpdate: true + replacesArtifacts: true + - name: Make bundle + run: | + ./autogen.sh + ./win/bundle.msys --nsi --zip + find . -iname '*.exe' + find . -iname '*.zip' + - uses: ncipollo/release-action@v1 + with: + tag: ${{ steps.gettag.outputs.tag }} + artifacts: "*.zip" + allowUpdates: true + draft: true + makeLatest: true + omitBody: true + omitPrereleaseDuringUpdate: true + replacesArtifacts: true + - uses: ncipollo/release-action@v1 + with: + tag: ${{ steps.gettag.outputs.tag }} + artifacts: "pw3270-5*.exe" + allowUpdates: true + draft: true + makeLatest: true + omitBody: true + omitPrereleaseDuringUpdate: true + replacesArtifacts: true + macos-publish: + runs-on: macos-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Install Pre reqs + run: | + brew remove azure-cli + find /usr/local/bin -lname '*/Library/Frameworks/Python.framework/*' -delete + find /usr/local/bin -lname '*/Library/Frameworks/Python.framework/*' -delete + rm -rf /usr/local/bin/2to3* + rm -rf /usr/local/bin/idle3* + rm -rf /usr/local/bin/pydoc3* + rm -rf /usr/local/bin/python3 + rm -rf /usr/local/bin/python3-config + rm -rf /usr/local/bin/python3* + rm -rf /usr/local/bin/python3*-config + find /usr/local/lib/node_modules/npm -delete + brew update + brew install xz automake libtool binutils coreutils curl gettext libtool openssl pkgconfig gtk+3 + - uses: robinraju/release-downloader@v1.7 + with: + repository: "PerryWerneck/lib3270" + latest: true + fileName: "macos-lib3270.tar.xz" + - uses: robinraju/release-downloader@v1.7 + with: + repository: "PerryWerneck/libv3270" + latest: true + fileName: "macos-libv3270.tar.xz" + - name: build + run: ./mac/ci-build.sh + - uses: oprypin/find-latest-tag@v1 + id: gettag + with: + repository: PerryWerneck/pw3270 + sort-tags: true + releases-only: true + - uses: ncipollo/release-action@v1 + with: + tag: ${{ steps.gettag.outputs.tag }} + artifacts: "macos-pw3270.tar.xz" + allowUpdates: true + draft: false + makeLatest: true + omitBody: true + omitPrereleaseDuringUpdate: true + replacesArtifacts: true + diff --git a/.github/workflows/winpkg.yml b/.github/workflows/winpkg.yml deleted file mode 100644 index 8bd392ac..00000000 --- a/.github/workflows/winpkg.yml +++ /dev/null @@ -1,84 +0,0 @@ ---- -name: WinPKG -on: - pull_request: - branches: - - master - push: - branches: - - winpkg -jobs: - msys2-mingw64: - name: Publish for Windows 64 - runs-on: windows-latest - defaults: - run: - shell: msys2 {0} - steps: - - uses: actions/checkout@v3 - - uses: oprypin/find-latest-tag@v1 - id: gettag - with: - repository: PerryWerneck/pw3270 - sort-tags: true - releases-only: true - - uses: msys2/setup-msys2@v2 - with: - msystem: mingw64 - update: true - install: xz dos2unix mingw-w64-x86_64-gcc automake autoconf make git pkgconf - mingw-w64-x86_64-gettext gettext-devel mingw-w64-x86_64-openssl - libtool mingw-w64-x86_64-gtk3 mingw-w64-x86_64-librsvg mingw-w64-x86_64-gdk-pixbuf2 - mingw-w64-x86_64-optipng mingw-w64-x86_64-nsis - - uses: robinraju/release-downloader@v1.7 - with: - repository: "PerryWerneck/lib3270" - latest: true - fileName: "mingw-w64-x86_64-lib3270-5.4-0-x86_64.pkg.tar.zst" - - uses: robinraju/release-downloader@v1.7 - with: - repository: "PerryWerneck/libv3270" - latest: true - fileName: "mingw-w64-x86_64-libv3270-5.4-0-x86_64.pkg.tar.zst" - - name: BuildApp - run: ./win/ci-build.sh - - uses: ncipollo/release-action@v1 - with: - tag: ${{ steps.gettag.outputs.tag }} - artifacts: "*-pw3270-*.pkg.tar.zst" - allowUpdates: true - draft: true - makeLatest: true - omitBody: true - omitPrereleaseDuringUpdate: true - replacesArtifacts: true - - uses: robinraju/release-downloader@v1.7 - with: - repository: PerryWerneck/libipc3270 - latest: true - fileName: mingw-w64-x86_64-libipc3270-5.5-0-x86_64.pkg.tar.zst - - uses: robinraju/release-downloader@v1.7 - with: - repository: PerryWerneck/libhllapi - latest: true - fileName: mingw-w64-x86_64-libhllapi-5.5-0-x86_64.pkg.tar.zst - - uses: robinraju/release-downloader@v1.7 - with: - repository: PerryWerneck/pw3270-plugin-ipc - latest: true - fileName: mingw-w64-x86_64-pw3270-plugin-ipc-5.5-0-x86_64.pkg.tar.zst - - name: Make bundle - run: ./win/bundle.msys - - name: Make Package - run: tar -C ./.bin/bundle -Jcf mingw-w64-x86_64-pw3270-bundle-x86_64.tar.xz . - - uses: ncipollo/release-action@v1 - with: - tag: ${{ steps.gettag.outputs.tag }} - artifacts: "*-pw3270-*.tar.xz" - allowUpdates: true - draft: true - makeLatest: true - omitBody: true - omitPrereleaseDuringUpdate: true - replacesArtifacts: true - diff --git a/PKGBUILD.mingw b/PKGBUILD.mingw index 0e5ff500..6feb4782 100644 --- a/PKGBUILD.mingw +++ b/PKGBUILD.mingw @@ -25,7 +25,7 @@ source=() pkgver=$(grep AC_INIT "${startdir}/configure.ac" | cut -d[ -f3 | cut -d] -f1) pkgrel=0 -pkgdesc="TN3270 Access library" +pkgdesc="IBM 3270 Terminal emulator for GTK" url="https://github.com/PerryWerneck/${_realname}" arch=(i686 x86_64) license=(LGPL-3.0-or-later) @@ -38,12 +38,12 @@ conflicts=($pkgname) prepare() { rm -fr "$srcdir/$pkgname" - ln -snf "$startdir" "$srcdir/$pkgname" + mkdir -p "$srcdir/$pkgname" } build() { - cd $pkgname - ./autogen.sh \ + cd "$srcdir/$pkgname" + ${startdir}/autogen.sh \ --prefix=${MINGW_PREFIX} \ --build=${MINGW_CHOST} \ --host=${MINGW_CHOST} \ @@ -53,10 +53,11 @@ build() { } package() { - cd $pkgname + cd "$srcdir/$pkgname" make DESTDIR="${pkgdir}" install install \ -Dm644 \ - "LICENSE" \ + "${startdir}/LICENSE" \ "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE" } + diff --git a/autogen.sh b/autogen.sh index f25ca55a..d09d6769 100755 --- a/autogen.sh +++ b/autogen.sh @@ -10,10 +10,19 @@ cd ${srcdir} mkdir -p ./scripts mkdir -p m4 -libtoolize --force +LIBTOOLIZE=$(which libtoolize) +if [ -z ${LIBTOOLIZE} ]; then + LIBTOOLIZE=$(which glibtoolize) +fi +if [ -z ${LIBTOOLIZE} ]; then + echo "Can't find libtoolize" + exit -1 +fi + +${LIBTOOLIZE} --force if test $? != 0 ; then - echo "libtoolize failed." - exit -1 + echo "libtoolize failed." + exit -1 fi aclocal @@ -40,7 +49,7 @@ autopoint cd ${builddir} -test -n "$NOCONFIGURE" || "./configure" "$@" +test -n "$NOCONFIGURE" || "$srcdir/configure" --srcdir=${srcdir} $@ diff --git a/macos/Info.plist b/mac/Info.plist similarity index 100% rename from macos/Info.plist rename to mac/Info.plist diff --git a/macos/bundle b/mac/bundle similarity index 100% rename from macos/bundle rename to mac/bundle diff --git a/mac/ci-build.sh b/mac/ci-build.sh new file mode 100755 index 00000000..b6b256cc --- /dev/null +++ b/mac/ci-build.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +PROJECT_NAME=$(grep AC_INIT configure.ac | cut -d[ -f2 | cut -d] -f1) +VERSION=$(grep AC_INIT configure.ac | cut -d[ -f3 | cut -d] -f1) + +unpack() { + + echo "Unpacking ${1}" + + tar -C $(brew --cellar) -Jxf macos-${1}.tar.xz + if [ "$?" != "0" ]; then + exit -1 + fi + + brew link ${1} + if [ "$?" != "0" ]; then + exit -1 + fi + + rm -f macos-${1}.tar.xz + +} + +unpack lib3270 +unpack libv3270 + +./autogen.sh --prefix="/${PROJECT_NAME}/${VERSION}" +if [ "$?" != "0" ]; then + exit -1 +fi + +make all +if [ "$?" != "0" ]; then + exit -1 +fi + +make DESTDIR=.bin/package install +tar --create --xz --file=macos-${PROJECT_NAME}.tar.xz --directory=.bin/package --verbose . + +find . -iname *.tar.xz + + diff --git a/macos/launcher.sh b/mac/launcher.sh similarity index 100% rename from macos/launcher.sh rename to mac/launcher.sh diff --git a/pw3270.cbp b/pw3270.cbp index 17da4bc1..efde15de 100644 --- a/pw3270.cbp +++ b/pw3270.cbp @@ -61,6 +61,9 @@ + + diff --git a/src/include/config.h.in b/src/include/config.h.in index 955a7178..6234a289 100644 --- a/src/include/config.h.in +++ b/src/include/config.h.in @@ -24,12 +24,12 @@ /* do we have malloc.h? */ #undef HAVE_MALLOC_H +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H -/* Define to 1 if you have the header file. */ -#undef HAVE_STDIO_H - /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H @@ -105,9 +105,7 @@ /* The schema path */ #undef PRODUCT_PATH -/* Define to 1 if all of the C90 standard headers exist (not just the ones - required in a freestanding environment). This macro is provided for - backward compatibility; new code need not use it. */ +/* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Version number of package */ diff --git a/src/main/macos/tools.c b/src/main/macos/tools.c new file mode 100644 index 00000000..a9668060 --- /dev/null +++ b/src/main/macos/tools.c @@ -0,0 +1,83 @@ +/* SPDX-License-Identifier: LGPL-3.0-or-later */ + +/* + * Copyright (C) <2008> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + + #include + #include + #include + #include + #include + + static gchar * get_path_from_bundle(const char *name, GFileTest test) { + + size_t szBuffer = PATH_MAX; + char buffer[PATH_MAX+1]; + memset(buffer,0,PATH_MAX+1); + + CFBundleRef mainBundle = CFBundleGetMainBundle(); + + if (mainBundle) { + + CFURLRef url = CFBundleCopyBundleURL(mainBundle); + + if (url) { + + CFURLGetFileSystemRepresentation(url, true, (UInt8 *) buffer, szBuffer); + CFRelease(url); + + gchar * path = g_build_filename(buffer,name,NULL); + + if(g_file_test(path,test)) { + return path; + } + + g_free(path); + + } + + } + + return NULL; + + } + + gchar * pw3270_build_data_path(const char *name) { + + gchar * path = get_path_from_bundle(name,G_FILE_TEST_IS_DIR); + + if(path) { + return path; + } + + g_message("Cant find path for '%s'",path); + return NULL; + + } + + gchar * pw3270_build_data_filename(const char *filename) { + + gchar * path = get_path_from_bundle(filename,G_FILE_TEST_IS_REGULAR); + + if(path) { + return path; + } + + g_error("Cant find '%s'",filename); + return NULL; + } + diff --git a/win/bundle.common b/win/bundle.common index 074264ca..627b11db 100644 --- a/win/bundle.common +++ b/win/bundle.common @@ -389,24 +389,48 @@ build_package() { make_packages() { + echo "----------------------------------" + find . -iname *.nsi + echo "----------------------------------" + find ${srcdir} -iname *.nsi + echo "----------------------------------" + find ${buildroot} -iname *.nsi + echo "----------------------------------" + if [ -e "${srcdir}/win/${PACKAGE_NAME}.nsi" ]; then mkdir -p "${buildroot}${MINGW_PREFIX}/nsi" cp "${srcdir}/win/${PACKAGE_NAME}.nsi" "${buildroot}${MINGW_PREFIX}/${PACKAGE_NAME}.nsi" - if [ "$?" != "0" ]; then - echo "Cant copy nsis script" + if [ "$?" == "0" ]; then + echo "Nsis script installed" + else + echo "Error installing nsis" fi + else + echo "Cant find ${srcdir}/win/${PACKAGE_NAME}.nsi" fi - argument "zip" > /dev/null - if [ "$?" == "0" ]; then - make_zip - fi + if [ -e "${srcdir}/LICENSE" ]; then + mkdir -p "${buildroot}${MINGW_PREFIX}/share/pw3270" + cp "${srcdir}/LICENSE" "${buildroot}${MINGW_PREFIX}/share/pw3270" + if [ "$?" == "0" ]; then + echo "License installed" + else + echo "Error installing license" + fi + else + echo "Cant find ${srcdir}/LICENSE" + fi argument "nsi" > /dev/null if [ "$?" == "0" ]; then make_nsis fi + argument "zip" > /dev/null + if [ "$?" == "0" ]; then + make_zip + fi + } diff --git a/win/bundle.msys b/win/bundle.msys index bca621ad..13130235 100755 --- a/win/bundle.msys +++ b/win/bundle.msys @@ -33,6 +33,31 @@ do fi done +argument "build" > /dev/null +if [ "$?" == "0" ]; then + + NOCONFIGURE=1 ./autogen.sh + if [ "$?" != "0" ]; then + echo "Configure failed" + exit -1 + fi + + ./configure + if [ "$?" != "0" ]; then + echo "Configure failed" + exit -1 + fi + + build_package + +else + + packages="${packages} pw3270" + +fi + + install_gtk3_runtime +make_packages diff --git a/win/ci-build.sh b/win/ci-build.sh deleted file mode 100644 index ca9aeefb..00000000 --- a/win/ci-build.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash -# -# SPDX-License-Identifier: LGPL-3.0-or-later -# -# Copyright (C) 2008 Banco do Brasil S.A. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, see . - -# -# References: -# -# * https://www.msys2.org/docs/ci/ -# - -echo "Running ${0}" - -LOGFILE=build.log -rm -f ${LOGFILE} - -die ( ) { - [ -s $LOGFILE ] && tail $LOGFILE - [ "$1" ] && echo "$*" - exit -1 -} - -cd $(dirname $(dirname $(readlink -f ${0}))) - -# -# Install pre-reqs -# -echo "Installing pre-reqs..." -pacman -U --noconfirm *.pkg.tar.zst || die "pre-reqs failure" - -# -# Build -# -echo "Building package..." -dos2unix PKGBUILD.mingw || die "dos2unix failure" -makepkg BUILDDIR=/tmp/pkg -p PKGBUILD.mingw || die "makepkg failure" - -echo "Build complete" -