From 72495b4b01b079ade0a6ecbc72a9a174c2851519 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=A4ckerlin?= Date: Sat, 14 Jul 2018 11:41:00 +0200 Subject: [PATCH] reverted PHP version thet works with MySQL 5.7 --- ax_check_qt.m4 | 21 ++++++- ax_init_standard_project.m4 | 2 +- bootstrap.sh | 15 +++-- build-in-docker.sh | 24 +++++--- configure.ac | 1 + docker/Dockerfile | 12 ++++ docker/README.md | 33 ++++++++++ html/checknewuser.php | 3 +- html/functions.php | 8 ++- html/index.html.in | 3 +- html/opendb.php | 10 +-- html/schema.sql | 34 ++++------- resolve-debbuilddeps.sh | 2 +- resolve-rpmbuilddeps.sh | 4 +- ...chat.desktop.in => safechat-php.desktop.in | 6 +- safechat-php.spec.in | 61 +++++++++++++++++++ safechat.spec.in | 60 ------------------ 17 files changed, 188 insertions(+), 111 deletions(-) create mode 100644 docker/Dockerfile create mode 100644 docker/README.md rename safechat.desktop.in => safechat-php.desktop.in (69%) create mode 100644 safechat-php.spec.in delete mode 100644 safechat.spec.in diff --git a/ax_check_qt.m4 b/ax_check_qt.m4 index e0eecf2..dfd8ac2 100644 --- a/ax_check_qt.m4 +++ b/ax_check_qt.m4 @@ -119,10 +119,25 @@ AC_DEFUN([AX_CHECK_QT], [ AC_DEFINE([HAVE_$1]) QTDIR=$(${PKG_CONFIG} --variable=prefix Qt5Core) qt_host_bins=$(${PKG_CONFIG} --variable=host_bins Qt5Core) - if test -d "${qt_host_bins}"; then - QT_PLUGIN_PATH=${qt_host_bins}/../plugins + qt_libdir=$(${PKG_CONFIG} --variable=libdir Qt5Core) + if test -d "${qt_libdir}" -a -d "${qt_libdir}/plugins"; then + QT_PLUGIN_PATH="${qt_libdir}/plugins" + elif test -d "${qt_libdir}/qt5" -a -d "${qt_libdir}/qt5/plugins"; then + QT_PLUGIN_PATH="${qt_libdir}/qt5/plugins" + elif test -d "${qt_host_bins}" -a -d "${qt_host_bins}/../plugins"; then + QT_PLUGIN_PATH="${qt_host_bins}/../plugins" + elif test -d "${QTDIR}/plugins; then + QT_PLUGIN_PATH="${QTDIR}/plugins" + elif test -d "${QTDIR}/share/qt5/plugins; then + QT_PLUGIN_PATH="${QTDIR}/share/qt5/plugins" else - QT_PLUGIN_PATH=${QTDIR}/share/qt5/plugins + AC_MSG_ERROR([QT_PLUGIN_PATH not found + - not in: ${qt_libdir}/plugins + - not in: ${qt_libdir}/qt5/plugins + - not in: ${qt_host_bins}/../plugins + - not in: ${QTDIR}/plugins + - not in: ${QTDIR}/share/qt5/plugins +]) fi MOC_FLAGS+=" -DHAVE_$1=1 ${[$1]5_CFLAGS}" [$1]_CPPFLAGS="${[$1]5_CFLAGS}" diff --git a/ax_init_standard_project.m4 b/ax_init_standard_project.m4 index 864c92e..629c66a 100644 --- a/ax_init_standard_project.m4 +++ b/ax_init_standard_project.m4 @@ -218,7 +218,7 @@ AC_DEFUN([AX_INIT_STANDARD_PROJECT], [ AX_SUBST(AUTHOR_URL) AX_SUBST(AUTHOR_MAIL) AX_SUBST(PACKAGER) - PROJECT_URL="${PROJECT_URL:-${AUTHOR_URL}/projects/${PACKAGE_NAME}}" + #PROJECT_URL="${PROJECT_URL:-${AUTHOR_URL}}" SOURCE_DOWNLOAD="${SOURCE_DOWNLOAD:-${AUTHOR_URL}/downloads/${PACKAGE_NAME}}" AX_SUBST(PROJECT_URL) AX_SUBST(SOURCE_DOWNLOAD) diff --git a/bootstrap.sh b/bootstrap.sh index 705fb76..ffcbfc9 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -1678,7 +1678,7 @@ fi) $(if testtag AX_RPM_DEPEND; then echo "Requires: @RPM_DEPEND@"; fi) Source0: %{name}-%{version}.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root -BuildRequires: which, pkgconfig, pandoc, gnupg, expect, ${VCSDEPENDS_RPM}make, automake, autoconf, rpm-build$( +BuildRequires: which, pkgconfig, gnupg, expect, ${VCSDEPENDS_RPM}make, automake, autoconf, rpm-build$( if testtag AX_USE_CXX; then echo -n ", binutils-devel, gcc-c++" fi @@ -1700,13 +1700,17 @@ BuildRequires: lsb-release$( echo -n ", libqt5-qtbase-devel, libqt5-qttools, libqt5-linguist-devel, libQt5WebKit5-devel libqt5-qtwebengine-devel libQt5WebKitWidgets-devel"; fi) %else +%if 0%{?mageia} +BuildRequires: rpm-sign, lsb-release $( if testtag AX_REQUIRE_QT || testtag AX_CHECK_QT; then - echo -n "BuildRequires: qt5-qtbase-devel, qt5-qttools-devel, qt5-qtwebkit-devel"; + echo -n "BuildRequires: qtbase5-common-devel, qttools5, lib64qt5webkit-devel, lib64qt5webkitwidgets-devel"; fi) -%if 0%{?mageia} -BuildRequires: rpm-sign, lsb-release %else +$( + if testtag AX_REQUIRE_QT || testtag AX_CHECK_QT; then + echo -n "BuildRequires: qt5-qtbase-devel, qt5-qttools-devel, qt5-qtwebkit-devel"; + fi) BuildRequires: rpm-sign, redhat-lsb %global debug_package %{nil} %endif @@ -1715,6 +1719,9 @@ $( if testtag AX_USE_DOXYGEN; then cat <> /etc/apt/preferences" + PREVENT='libpam-systemd policykit.* colord dconf-service' + for f in ${PREVENT}; do + docker exec ${DOCKER_ID} bash -c "echo 'Package: ${f}' >> /etc/apt/preferences" docker exec ${DOCKER_ID} bash -c "echo 'Pin-Priority: -100' >> /etc/apt/preferences" docker exec ${DOCKER_ID} bash -c "echo >> /etc/apt/preferences" done docker exec ${DOCKER_ID} apt-get update ${OPTIONS} + docker exec ${DOCKER_ID} apt-mark hold ${PREVENT} docker exec ${DOCKER_ID} apt-get upgrade ${OPTIONS} - docker exec ${DOCKER_ID} apt-get install ${OPTIONS} python-software-properties software-properties-common apt-transport-https dpkg-dev lsb-release wget || \ - docker exec ${DOCKER_ID} apt-get install ${OPTIONS} software-properties-common apt-transport-https dpkg-dev lsb-release wget || \ - docker exec ${DOCKER_ID} apt-get install ${OPTIONS} python-software-properties apt-transport-https dpkg-dev lsb-release wget; + docker exec ${DOCKER_ID} apt-get install ${OPTIONS} ${PREVENT// /- }- python-software-properties software-properties-common apt-transport-https dpkg-dev lsb-release wget || \ + docker exec ${DOCKER_ID} apt-get install ${OPTIONS} ${PREVENT// /- }- software-properties-common apt-transport-https dpkg-dev lsb-release wget || \ + docker exec ${DOCKER_ID} apt-get install ${OPTIONS} ${PREVENT// /- }- python-software-properties apt-transport-https dpkg-dev lsb-release wget; for key in "${keys[@]}"; do wget -O- "$key" \ | docker exec -i ${DOCKER_ID} apt-key add - @@ -265,9 +267,12 @@ case $mode in for repo in "${repos[@]}"; do ifthenelse "${repo}" "apt-add-repository 'ARG'" done + + + docker exec ${DOCKER_ID} apt-get update ${OPTIONS} for package in "${packages[@]}"; do - ifthenelse "${package}" "apt-get install ${OPTIONS} ARG" + ifthenelse "${package}" "apt-get install ${OPTIONS} ${PREVENT} ARG" done for command in "${commands[@]}"; do ifthenelse "${command}" "ARG" @@ -294,11 +299,14 @@ EOF LSB_RELEASE=/usr/bin/lsb_release fi docker exec ${DOCKER_ID} ${INSTALL_TOOL} rpm-build automake libtool subversion gcc-c++ pkgconfig wget $LSB_RELEASE + if docker exec ${DOCKER_ID} test -x /usr/bin/dnf; then + docker exec ${DOCKER_ID} dnf install -y 'dnf-command(config-manager)' + fi i=0 for key in "${keys[@]}"; do - wget -Orpm-key "$key" + docker exec -i ${DOCKER_ID} wget -Orpm-key "$key" docker exec -i ${DOCKER_ID} rpm --import rpm-key - rm rpm-key + docker exec -i ${DOCKER_ID} rm rpm-key done for repo in "${repos[@]}"; do INSTALL_REPO=$((docker exec ${DOCKER_ID} test -x /usr/bin/zypper && echo zypper ar) || (docker exec ${DOCKER_ID} test -x /usr/bin/dnf && echo dnf config-manager --add-repo) || (docker exec ${DOCKER_ID} test -x /usr/bin/yum && echo wget -O/etc/yum.repos.d/additional$i.repo) || (docker exec ${DOCKER_ID} test -x /usr/sbin/urpmi && echo false)) diff --git a/configure.ac b/configure.ac index 09f5faa..8063045 100644 --- a/configure.ac +++ b/configure.ac @@ -12,6 +12,7 @@ m4_define(x_minor, 3) # project's minor version m4_include(ax_init_standard_project.m4) AC_INIT(x_package_name, x_version, x_package_name) AM_INIT_AUTOMAKE([1.9 tar-pax]) +PROJECT_URL="https://mrw.sh/webservices/safechat" AX_INIT_STANDARD_PROJECT # requirements, uncomment, what you need: diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..c9ef58b --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,12 @@ +FROM mwaeckerlin/php-fpm +MAINTAINER mwaeckerlin + +ENV CONTAINERNAME safechat +ENV WEB_ROOT_PATH /usr/share/safechat-php/html/ +USER root +RUN apk add mysql-client gpgme gpgme-dev musl-dev gcc make && \ + pecl install gnupg && \ + echo extension=gnupg.so >> /etc/php7/php.ini && \ + apk del gpgme-dev musl-dev gcc make +ADD usr /usr +USER $WWWUSER diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 0000000..7f43d25 --- /dev/null +++ b/docker/README.md @@ -0,0 +1,33 @@ +Docker Image for SafeChat +========================= + +For a running example see: https://safechat.ch + + +Run SafeChat +------------ + +Safechat exposts port 8080 as it is based on [mwaeckerlin/php-fpm]. + +You need a [mysql] database (less than version 8). The hostname must be `mysql` and the root password must be set in `MYSQL_ENV_MYSQL_ROOT_PASSWORD`, e.g. + +```bash +docker run -d --name safechat-mysql -e MYSQL_ROOT_PASSWORD=$(pwgen 20 1) mysql:5 +docker run -d --name safechat -p 8005:8080 --link safechat-mysql:mysql mwaeckerlin/safechat +``` + + +Build Docker Image +------------------ + +Install safechat into path `docker/usr`, then build the image, e.g.: + +```bash +cd ~/git/safechat +./bootstrap.sh -t "all install" --prefix=$(pwd)/docker/usr +docker build --rm --force-rm -t mwaeckerlin/safechat docker +``` + + +[mwaeckerlin/php-fpm]: https://hub.docker.com/r/mwaeckerlin/php-fpm "image on docker hub" +[mysql]: https://hub.docker.com/_/mysql "image on docker hub" diff --git a/html/checknewuser.php b/html/checknewuser.php index 89b0d89..3e42a6e 100644 --- a/html/checknewuser.php +++ b/html/checknewuser.php @@ -21,6 +21,7 @@ function checknewuser($user) { require_once("opendb.php"); $dbuser = $db->real_escape_string($user); $q = $db->query("select * from user where name='$dbuser';"); + if (!$q) error("server database error: ".$db->error); if ($q->num_rows==0) { echo json_encode($user); } else { @@ -31,4 +32,4 @@ function checknewuser($user) { } } checknewuser($_REQUEST['user']); -?> \ No newline at end of file +?> diff --git a/html/functions.php b/html/functions.php index c4e424f..b504297 100644 --- a/html/functions.php +++ b/html/functions.php @@ -1,5 +1,7 @@ error); + } echo json_encode(array('success' => false, 'txt' => $txt)); exit; } @@ -83,4 +89,4 @@ EOT; } } -?> \ No newline at end of file +?> diff --git a/html/index.html.in b/html/index.html.in index a94ca06..aa93fd9 100644 --- a/html/index.html.in +++ b/html/index.html.in @@ -28,7 +28,8 @@
  • Edit Groups
  • Download Android-App
  • -
  • About Safe Chat
  • +
  • About the Project
  • +
  • About the Author