package 3.92 KB
Newer Older
akiraohgaki's avatar
akiraohgaki committed
1
#!/bin/bash
akiraohgaki's avatar
akiraohgaki committed
2
3
4

PKGNAME='ocs-url'

akiraohgaki's avatar
akiraohgaki committed
5
PKGUSER='pkgbuilder'
akiraohgaki's avatar
akiraohgaki committed
6

akiraohgaki's avatar
akiraohgaki committed
7
PKGSCRIPT="${0}"
akiraohgaki's avatar
akiraohgaki committed
8
9
10

PROJDIR="$(cd "$(dirname "${0}")/../" && pwd)"

akiraohgaki's avatar
akiraohgaki committed
11
BUILDDIR="${PROJDIR}/build_${PKGNAME}"
akiraohgaki's avatar
akiraohgaki committed
12

akiraohgaki's avatar
akiraohgaki committed
13
ubuntu_deb() { # docker-image: ubuntu:14.04
akiraohgaki's avatar
akiraohgaki committed
14
15
16
17
18
19
20
    install_build_deps_ubuntu_deb
    add_pkguser
    su -c "export HOME=/home/${PKGUSER} && "${PKGSCRIPT}" build_ubuntu_deb" ${PKGUSER}
    transfer_file "$(find "${BUILDDIR}" -type f -name "${PKGNAME}*.deb")"
}

install_build_deps_ubuntu_deb() {
akiraohgaki's avatar
akiraohgaki committed
21
22
23
24
25
26
    apt update -qq
    apt -y install curl git
    apt -y install build-essential qt5-default libqt5svg5-dev qtdeclarative5-dev
    apt -y install devscripts debhelper fakeroot
}

akiraohgaki's avatar
akiraohgaki committed
27
build_ubuntu_deb() {
akiraohgaki's avatar
akiraohgaki committed
28
    rm -rf "${BUILDDIR}"
akiraohgaki's avatar
akiraohgaki committed
29
30
31
32
33
34
35
36
    mkdir -p "${BUILDDIR}"
    export_srcarchive "${BUILDDIR}/${PKGNAME}.tar.gz"
    tar -xzf "${BUILDDIR}/${PKGNAME}.tar.gz" -C "${BUILDDIR}"
    cp -r "${PROJDIR}/pkg/ubuntu/debian" "${BUILDDIR}/${PKGNAME}"
    cd "${BUILDDIR}/${PKGNAME}"
    debuild -uc -us -b
}

akiraohgaki's avatar
akiraohgaki committed
37
fedora_rpm() { # docker-image: fedora:20
akiraohgaki's avatar
akiraohgaki committed
38
39
40
41
42
43
44
    install_build_deps_fedora_rpm
    add_pkguser
    su -c "export HOME=/home/${PKGUSER} && "${PKGSCRIPT}" build_fedora_rpm" ${PKGUSER}
    transfer_file "$(find "${BUILDDIR}" -type f -name "${PKGNAME}*.rpm")"
}

install_build_deps_fedora_rpm() {
akiraohgaki's avatar
akiraohgaki committed
45
46
47
48
49
    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 rpm-build
}

akiraohgaki's avatar
akiraohgaki committed
50
build_fedora_rpm() {
akiraohgaki's avatar
akiraohgaki committed
51
    rm -rf "${BUILDDIR}"
akiraohgaki's avatar
akiraohgaki committed
52
53
54
55
56
57
58
    mkdir -p "${BUILDDIR}"
    mkdir "${BUILDDIR}/SOURCES"
    mkdir "${BUILDDIR}/SPECS"
    export_srcarchive "${BUILDDIR}/SOURCES/${PKGNAME}.tar.gz"
    cp "${PROJDIR}/pkg/fedora/${PKGNAME}.spec" "${BUILDDIR}/SPECS"
    rpmbuild --define "_topdir ${BUILDDIR}" -bb "${BUILDDIR}/SPECS/${PKGNAME}.spec"
}
akiraohgaki's avatar
akiraohgaki committed
59

akiraohgaki's avatar
akiraohgaki committed
60
opensuse_rpm() { # docker-image: opensuse:42.1
akiraohgaki's avatar
akiraohgaki committed
61
62
63
64
65
66
67
    install_build_deps_opensuse_rpm
    add_pkguser
    su -c "export HOME=/home/${PKGUSER} && "${PKGSCRIPT}" build_opensuse_rpm" ${PKGUSER}
    transfer_file "$(find "${BUILDDIR}" -type f -name "${PKGNAME}*.rpm")"
}

install_build_deps_opensuse_rpm() {
akiraohgaki's avatar
akiraohgaki committed
68
69
70
71
    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 rpm-build
akiraohgaki's avatar
akiraohgaki committed
72
73
74
}

build_opensuse_rpm() {
akiraohgaki's avatar
akiraohgaki committed
75
    rm -rf "${BUILDDIR}"
akiraohgaki's avatar
akiraohgaki committed
76
77
78
79
80
81
    mkdir -p "${BUILDDIR}"
    mkdir "${BUILDDIR}/SOURCES"
    mkdir "${BUILDDIR}/SPECS"
    export_srcarchive "${BUILDDIR}/SOURCES/${PKGNAME}.tar.gz"
    cp "${PROJDIR}/pkg/opensuse/${PKGNAME}.spec" "${BUILDDIR}/SPECS"
    rpmbuild --define "_topdir ${BUILDDIR}" -bb "${BUILDDIR}/SPECS/${PKGNAME}.spec"
akiraohgaki's avatar
akiraohgaki committed
82
83
}

akiraohgaki's avatar
akiraohgaki committed
84
archlinux_pkg() { # docker-image: base/archlinux:latest
akiraohgaki's avatar
akiraohgaki committed
85
86
87
88
89
90
91
    install_build_deps_archlinux_pkg
    add_pkguser
    su -c "export HOME=/home/${PKGUSER} && "${PKGSCRIPT}" build_archlinux_pkg" ${PKGUSER}
    transfer_file "$(find "${BUILDDIR}" -type f -name "${PKGNAME}*.pkg.tar.xz")"
}

install_build_deps_archlinux_pkg() {
akiraohgaki's avatar
akiraohgaki committed
92
93
94
    pacman -Syu --noconfirm
    pacman -S --noconfirm curl git
    pacman -S --noconfirm base-devel qt5-base qt5-svg qt5-declarative qt5-quickcontrols
akiraohgaki's avatar
akiraohgaki committed
95
    pacman -S --noconfirm pacman-contrib
akiraohgaki's avatar
akiraohgaki committed
96
97
}

akiraohgaki's avatar
akiraohgaki committed
98
build_archlinux_pkg() {
akiraohgaki's avatar
akiraohgaki committed
99
    rm -rf "${BUILDDIR}"
akiraohgaki's avatar
akiraohgaki committed
100
101
102
103
104
105
106
107
    mkdir -p "${BUILDDIR}"
    export_srcarchive "${BUILDDIR}/${PKGNAME}.tar.gz"
    cp "${PROJDIR}/pkg/archlinux/PKGBUILD" "${BUILDDIR}"
    cd "${BUILDDIR}"
    updpkgsums
    makepkg -s
}

akiraohgaki's avatar
akiraohgaki committed
108
109
110
111
112
add_pkguser() {
    useradd -m ${PKGUSER}
    chown -R ${PKGUSER} "${PROJDIR}"
}

akiraohgaki's avatar
akiraohgaki committed
113
export_srcarchive() {
akiraohgaki's avatar
akiraohgaki committed
114
    if [ "${1}" ]; then
akiraohgaki's avatar
Fix    
akiraohgaki committed
115
        log="$(cd "${PROJDIR}" && git archive --prefix="${PKGNAME}/" --output="${1}" HEAD)"
akiraohgaki's avatar
akiraohgaki committed
116
117
118
119
    fi
}

transfer_file() {
akiraohgaki's avatar
akiraohgaki committed
120
    if [ -f "${1}" ]; then
akiraohgaki's avatar
akiraohgaki committed
121
122
123
124
125
126
127
128
        filename="$(basename "${1}")"
        transferlog="${PROJDIR}/transfer.log"
        echo "Uploading ${filename}" >> "${transferlog}"
        curl -fsSL -T "${1}" "https://transfer.sh/${filename}" >> "${transferlog}"
        echo '' >> "${transferlog}"
    fi
}

akiraohgaki's avatar
akiraohgaki committed
129
if [ "${1}" ]; then
akiraohgaki's avatar
akiraohgaki committed
130
131
    ${1}
fi