From 6628625fc8d3954866760eda60ab8b732667740b Mon Sep 17 00:00:00 2001
From: Akira Ohgaki <akiraohgaki@gmail.com>
Date: Thu, 8 Feb 2018 02:08:33 +0900
Subject: [PATCH] Code cleanup

---
 pkg/archlinux/PKGBUILD    |  2 +-
 pkg/fedora/ocs-url.spec   |  4 ++--
 pkg/opensuse/ocs-url.spec |  4 ++--
 pkg/ubuntu/debian/control |  2 +-
 pkg/ubuntu/debian/rules   |  2 +-
 scripts/build-docker.sh   | 39 +++++++++++++++++----------------------
 scripts/build.sh          |  2 +-
 7 files changed, 25 insertions(+), 30 deletions(-)

diff --git a/pkg/archlinux/PKGBUILD b/pkg/archlinux/PKGBUILD
index 0a2537f..17e387e 100644
--- a/pkg/archlinux/PKGBUILD
+++ b/pkg/archlinux/PKGBUILD
@@ -22,7 +22,7 @@ prepare() {
 build() {
     #cd "${pkgname}-release-${pkgver}"
     cd "${pkgname}"
-    qmake PREFIX="/usr"
+    qmake PREFIX=/usr
     make
 }
 
diff --git a/pkg/fedora/ocs-url.spec b/pkg/fedora/ocs-url.spec
index a7f1a3d..1dd527a 100644
--- a/pkg/fedora/ocs-url.spec
+++ b/pkg/fedora/ocs-url.spec
@@ -10,7 +10,7 @@ URL: https://github.com/opendesktop/ocs-url
 Source0: %{name}.tar.gz
 
 Requires: qt5-qtbase >= 5.2.0, qt5-qtbase-gui >= 5.2.0, qt5-qtsvg >= 5.2.0, qt5-qtdeclarative >= 5.2.0, qt5-qtquickcontrols >= 5.2.0
-BuildRequires: make, automake, gcc, gcc-c++, libtool, qt5-qtbase-devel >= 5.2.0, qt5-qtsvg-devel >= 5.2.0, qt5-qtdeclarative-devel >= 5.2.0, git, rpm-build
+BuildRequires: git, make, automake, gcc, gcc-c++, libtool, qt5-qtbase-devel >= 5.2.0, qt5-qtsvg-devel >= 5.2.0, qt5-qtdeclarative-devel >= 5.2.0, rpm-build
 
 %description
 An install helper program for items served on OpenCollaborationServices (OCS).
@@ -22,7 +22,7 @@ sh scripts/prepare.sh
 
 %build
 %define debug_package %{nil}
-qmake-qt5 PREFIX="/usr"
+qmake-qt5 PREFIX=/usr
 make
 
 %install
diff --git a/pkg/opensuse/ocs-url.spec b/pkg/opensuse/ocs-url.spec
index 32bfcd5..cdb9fa5 100644
--- a/pkg/opensuse/ocs-url.spec
+++ b/pkg/opensuse/ocs-url.spec
@@ -10,7 +10,7 @@ URL: https://github.com/opendesktop/ocs-url
 Source0: %{name}.tar.gz
 
 Requires: libQt5Svg5 >= 5.2.0, libqt5-qtquickcontrols >= 5.2.0
-BuildRequires: make, automake, gcc, gcc-c++, libtool, libqt5-qtbase-devel >= 5.2.0, libqt5-qtsvg-devel >= 5.2.0, libqt5-qtdeclarative-devel >= 5.2.0, git, rpm-build
+BuildRequires: git, make, automake, gcc, gcc-c++, libtool, libqt5-qtbase-devel >= 5.2.0, libqt5-qtsvg-devel >= 5.2.0, libqt5-qtdeclarative-devel >= 5.2.0, rpm-build
 
 %description
 An install helper program for items served on OpenCollaborationServices (OCS).
@@ -22,7 +22,7 @@ sh scripts/prepare.sh
 
 %build
 %define debug_package %{nil}
-qmake-qt5 PREFIX="/usr"
+qmake-qt5 PREFIX=/usr
 make
 
 %install
diff --git a/pkg/ubuntu/debian/control b/pkg/ubuntu/debian/control
index de4998e..52f4b84 100644
--- a/pkg/ubuntu/debian/control
+++ b/pkg/ubuntu/debian/control
@@ -2,7 +2,7 @@ Source: ocs-url
 Section: web
 Priority: optional
 Maintainer: Akira Ohgaki <akiraohgaki@gmail.com>
-Build-Depends: build-essential, qt5-default (>= 5.2.0), libqt5svg5-dev (>= 5.2.0), qtdeclarative5-dev (>= 5.2.0), git, devscripts, debhelper, fakeroot
+Build-Depends: git, build-essential, qt5-default (>= 5.2.0), libqt5svg5-dev (>= 5.2.0), qtdeclarative5-dev (>= 5.2.0), devscripts, debhelper, fakeroot
 Standards-Version: 3.9.4
 
 Package: ocs-url
diff --git a/pkg/ubuntu/debian/rules b/pkg/ubuntu/debian/rules
index 1443dc9..2506194 100755
--- a/pkg/ubuntu/debian/rules
+++ b/pkg/ubuntu/debian/rules
@@ -5,7 +5,7 @@
 
 override_dh_auto_configure:
 	sh scripts/prepare.sh
-	qmake PREFIX="/usr"
+	qmake PREFIX=/usr
 
 override_dh_auto_install:
 	make INSTALL_ROOT="$(CURDIR)/debian/tmp" install
diff --git a/scripts/build-docker.sh b/scripts/build-docker.sh
index 7d5c89b..6059549 100644
--- a/scripts/build-docker.sh
+++ b/scripts/build-docker.sh
@@ -20,74 +20,69 @@ transfer_file() {
     if [ -f "${filepath}" ]; then
         filename="$(basename "${filepath}")"
         echo "Uploading ${filename}" >> "${TRANSFERLOG}"
-        curl -T "${filepath}" "https://transfer.sh/${filename}" >> "${TRANSFERLOG}"
-        echo "" >> "${TRANSFERLOG}"
+        curl -fsSL -T "${filepath}" "https://transfer.sh/${filename}" >> "${TRANSFERLOG}"
+        echo '' >> "${TRANSFERLOG}"
     fi
 }
 
 build_ubuntu() {
     # docker-image: ubuntu:14.04
+
     apt update -qq
+    apt -y install curl git
     apt -y install build-essential qt5-default libqt5svg5-dev qtdeclarative5-dev
-    apt -y install git devscripts debhelper fakeroot
-    apt -y install curl
+    apt -y install devscripts debhelper fakeroot
 
     useradd -m ${PKGUSER}
-    export HOME="/home/${PKGUSER}"
     chown -R ${PKGUSER}:${PKGUSER} "${PROJDIR}"
 
-    su -c "sh "${BUILDSCRIPT}" ${BUILDTYPE}" ${PKGUSER}
+    su -c "export HOME=/home/${PKGUSER} && sh "${BUILDSCRIPT}" ${BUILDTYPE}" ${PKGUSER}
 
     transfer_file "$(find "${PROJDIR}/build_"*${BUILDTYPE} -type f -name "${PKGNAME}*.deb")"
 }
 
 build_fedora() {
     # docker-image: fedora:20
+
+    yum -y install curl git
     yum -y install make automake gcc gcc-c++ libtool qt5-qtbase-devel qt5-qtsvg-devel qt5-qtdeclarative-devel
-    yum -y install git rpm-build
-    yum -y install curl
-    # docker-image: fedora:22
-    #dnf -y install make automake gcc gcc-c++ libtool qt5-qtbase-devel qt5-qtsvg-devel qt5-qtdeclarative-devel
-    #dnf -y install git rpm-build
-    #dnf -y install curl
+    yum -y install rpm-build
 
     useradd -m ${PKGUSER}
-    export HOME="/home/${PKGUSER}"
     chown -R ${PKGUSER}:${PKGUSER} "${PROJDIR}"
 
-    su -c "sh "${BUILDSCRIPT}" ${BUILDTYPE}" ${PKGUSER}
+    su -c "export HOME=/home/${PKGUSER} && sh "${BUILDSCRIPT}" ${BUILDTYPE}" ${PKGUSER}
 
     transfer_file "$(find "${PROJDIR}/build_"*${BUILDTYPE} -type f -name "${PKGNAME}*.rpm")"
 }
 
 build_opensuse() {
     # docker-image: opensuse:42.1
+
     zypper --non-interactive refresh
+    zypper --non-interactive install curl git
     zypper --non-interactive install make automake gcc gcc-c++ libtool libqt5-qtbase-devel libqt5-qtsvg-devel libqt5-qtdeclarative-devel
-    zypper --non-interactive install git rpm-build
-    zypper --non-interactive install curl
+    zypper --non-interactive install rpm-build
 
     useradd -m ${PKGUSER}
-    export HOME="/home/${PKGUSER}"
     chown -R ${PKGUSER}:${PKGUSER} "${PROJDIR}"
 
-    su -c "sh "${BUILDSCRIPT}" ${BUILDTYPE}" ${PKGUSER}
+    su -c "export HOME=/home/${PKGUSER} && sh "${BUILDSCRIPT}" ${BUILDTYPE}" ${PKGUSER}
 
     transfer_file "$(find "${PROJDIR}/build_"*${BUILDTYPE} -type f -name "${PKGNAME}*.rpm")"
 }
 
 build_archlinux() {
     # docker-image: base/archlinux:latest
+
     pacman -Syu --noconfirm
+    pacman -S --noconfirm curl git
     pacman -S --noconfirm base-devel qt5-base qt5-svg qt5-declarative qt5-quickcontrols
-    pacman -S --noconfirm git
-    pacman -S --noconfirm curl
 
     useradd -m ${PKGUSER}
-    export HOME="/home/${PKGUSER}"
     chown -R ${PKGUSER}:${PKGUSER} "${PROJDIR}"
 
-    su -c "sh "${BUILDSCRIPT}" ${BUILDTYPE}" ${PKGUSER}
+    su -c "export HOME=/home/${PKGUSER} && sh "${BUILDSCRIPT}" ${BUILDTYPE}" ${PKGUSER}
 
     transfer_file "$(find "${PROJDIR}/build_"*${BUILDTYPE} -type f -name "${PKGNAME}*.pkg.tar.xz")"
 }
diff --git a/scripts/build.sh b/scripts/build.sh
index 09a56d8..3eed0a2 100644
--- a/scripts/build.sh
+++ b/scripts/build.sh
@@ -25,7 +25,7 @@ build_ubuntu() {
     mkdir -p "${BUILDDIR}"
     export_srcarchive "${SRCARCHIVE}"
 
-    tar -xzvf "${SRCARCHIVE}" -C "${BUILDDIR}"
+    tar -xzf "${SRCARCHIVE}" -C "${BUILDDIR}"
     cp -r "${PROJDIR}/pkg/ubuntu/debian" "${BUILDDIR}/${PKGNAME}"
     cd "${BUILDDIR}/${PKGNAME}"
     debuild -uc -us -b
-- 
GitLab