Skip to content
Snippets Groups Projects
Commit f6a1ba46 authored by akiraohgaki's avatar akiraohgaki
Browse files

Rewrite packaging script

parent 6628625f
No related branches found
No related tags found
No related merge requests found
......@@ -10,8 +10,8 @@ branches:
script:
- mntdir='/mnt/ocs-url'
- docker run --rm -v $(pwd):${mntdir} ubuntu:14.04 /bin/bash -c "sh ${mntdir}/scripts/build-docker.sh ubuntu"
- docker run --rm -v $(pwd):${mntdir} fedora:20 /bin/bash -c "sh ${mntdir}/scripts/build-docker.sh fedora"
- docker run --rm -v $(pwd):${mntdir} opensuse:42.1 /bin/bash -c "sh ${mntdir}/scripts/build-docker.sh opensuse"
- docker run --rm -v $(pwd):${mntdir} base/archlinux:latest /bin/bash -c "sh ${mntdir}/scripts/build-docker.sh archlinux"
- docker run --rm -v $(pwd):${mntdir} ubuntu:14.04 /bin/bash -c "sh ${mntdir}/scripts/package.sh ci_ubuntu_deb"
- docker run --rm -v $(pwd):${mntdir} fedora:20 /bin/bash -c "sh ${mntdir}/scripts/package.sh ci_fedora_rpm"
- docker run --rm -v $(pwd):${mntdir} opensuse:42.1 /bin/bash -c "sh ${mntdir}/scripts/package.sh ci_opensuse_rpm"
- docker run --rm -v $(pwd):${mntdir} base/archlinux:latest /bin/bash -c "sh ${mntdir}/scripts/package.sh ci_archlinux_pkg"
- cat transfer.log
#!/bin/bash
PKGNAME='ocs-url'
PKGUSER='pkgbuilder'
BUILDTYPE=''
if [ "${1}" ]; then
BUILDTYPE="${1}"
fi
PROJDIR="$(cd "$(dirname "${0}")/../" && pwd)"
BUILDSCRIPT="${PROJDIR}/scripts/build.sh"
TRANSFERLOG="${PROJDIR}/transfer.log"
transfer_file() {
filepath="${1}"
if [ -f "${filepath}" ]; then
filename="$(basename "${filepath}")"
echo "Uploading ${filename}" >> "${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 devscripts debhelper fakeroot
useradd -m ${PKGUSER}
chown -R ${PKGUSER}:${PKGUSER} "${PROJDIR}"
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 rpm-build
useradd -m ${PKGUSER}
chown -R ${PKGUSER}:${PKGUSER} "${PROJDIR}"
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 rpm-build
useradd -m ${PKGUSER}
chown -R ${PKGUSER}:${PKGUSER} "${PROJDIR}"
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
useradd -m ${PKGUSER}
chown -R ${PKGUSER}:${PKGUSER} "${PROJDIR}"
su -c "export HOME=/home/${PKGUSER} && sh "${BUILDSCRIPT}" ${BUILDTYPE}" ${PKGUSER}
transfer_file "$(find "${PROJDIR}/build_"*${BUILDTYPE} -type f -name "${PKGNAME}*.pkg.tar.xz")"
}
build_appimage() {
echo 'Not implemented yet'
}
build_snap() {
echo 'Not implemented yet'
}
build_flatpak() {
echo 'Not implemented yet'
}
if [ "${BUILDTYPE}" = 'ubuntu' ]; then
build_ubuntu
elif [ "${BUILDTYPE}" = 'fedora' ]; then
build_fedora
elif [ "${BUILDTYPE}" = 'opensuse' ]; then
build_opensuse
elif [ "${BUILDTYPE}" = 'archlinux' ]; then
build_archlinux
elif [ "${BUILDTYPE}" = 'appimage' ]; then
build_appimage
elif [ "${BUILDTYPE}" = 'snap' ]; then
build_snap
elif [ "${BUILDTYPE}" = 'flatpak' ]; then
build_flatpak
else
echo "sh $(basename "${0}") [ubuntu|fedora|archlinux|appimage|snap|flatpak]"
exit 1
fi
#!/bin/bash
PKGNAME='ocs-url'
BUILDTYPE=''
if [ "${1}" ]; then
BUILDTYPE="${1}"
fi
PROJDIR="$(cd "$(dirname "${0}")/../" && pwd)"
BUILDVER="$(cd "${PROJDIR}" && git describe --always)"
BUILDDIR="${PROJDIR}/build_${PKGNAME}_${BUILDVER}_${BUILDTYPE}"
SRCARCHIVE="${BUILDDIR}/${PKGNAME}.tar.gz"
export_srcarchive() {
filepath="${1}"
$(cd "${PROJDIR}" && git archive --prefix="${PKGNAME}/" --output="${filepath}" HEAD)
}
build_ubuntu() {
cd "${PROJDIR}"
mkdir -p "${BUILDDIR}"
export_srcarchive "${SRCARCHIVE}"
tar -xzf "${SRCARCHIVE}" -C "${BUILDDIR}"
cp -r "${PROJDIR}/pkg/ubuntu/debian" "${BUILDDIR}/${PKGNAME}"
cd "${BUILDDIR}/${PKGNAME}"
debuild -uc -us -b
}
build_fedora() {
cd "${PROJDIR}"
mkdir -p "${BUILDDIR}"
export_srcarchive "${SRCARCHIVE}"
mkdir "${BUILDDIR}/SOURCES"
mkdir "${BUILDDIR}/SPECS"
mv "${SRCARCHIVE}" "${BUILDDIR}/SOURCES"
cp "${PROJDIR}/pkg/fedora/${PKGNAME}.spec" "${BUILDDIR}/SPECS"
rpmbuild --define "_topdir ${BUILDDIR}" -bb "${BUILDDIR}/SPECS/${PKGNAME}.spec"
}
build_opensuse() {
cd "${PROJDIR}"
mkdir -p "${BUILDDIR}"
export_srcarchive "${SRCARCHIVE}"
mkdir "${BUILDDIR}/SOURCES"
mkdir "${BUILDDIR}/SPECS"
mv "${SRCARCHIVE}" "${BUILDDIR}/SOURCES"
cp "${PROJDIR}/pkg/opensuse/${PKGNAME}.spec" "${BUILDDIR}/SPECS"
rpmbuild --define "_topdir ${BUILDDIR}" -bb "${BUILDDIR}/SPECS/${PKGNAME}.spec"
}
build_archlinux() {
cd "${PROJDIR}"
mkdir -p "${BUILDDIR}"
export_srcarchive "${SRCARCHIVE}"
cp "${PROJDIR}/pkg/archlinux/PKGBUILD" "${BUILDDIR}"
cd "${BUILDDIR}"
updpkgsums
makepkg -s
}
build_appimage() {
echo 'Not implemented yet'
}
build_snap() {
echo 'Not implemented yet'
}
build_flatpak() {
echo 'Not implemented yet'
}
if [ "${BUILDTYPE}" = 'ubuntu' ]; then
build_ubuntu
elif [ "${BUILDTYPE}" = 'fedora' ]; then
build_fedora
elif [ "${BUILDTYPE}" = 'opensuse' ]; then
build_opensuse
elif [ "${BUILDTYPE}" = 'archlinux' ]; then
build_archlinux
elif [ "${BUILDTYPE}" = 'appimage' ]; then
build_appimage
elif [ "${BUILDTYPE}" = 'snap' ]; then
build_snap
elif [ "${BUILDTYPE}" = 'flatpak' ]; then
build_flatpak
else
echo "sh $(basename "${0}") [ubuntu|fedora|archlinux|appimage|snap|flatpak]"
exit 1
fi
#!/bin/bash
PKGNAME='ocs-url'
USER='pkgbuilder'
SCRIPT="${0}"
FUNCTION=''
if [ "${1}" ]; then
FUNCTION="${1}"
fi
PROJDIR="$(cd "$(dirname "${0}")/../" && pwd)"
BUILDDIR="${PROJDIR}/build_${PKGNAME}_${FUNCTION}"
export_srcarchive() {
filepath="${1}"
$(cd "${PROJDIR}" && git archive --prefix="${PKGNAME}/" --output="${filepath}" HEAD)
}
transfer_file() {
filepath="${1}"
if [ -f "${filepath}" ]; then
filename="$(basename "${filepath}")"
logfilepath="${PROJDIR}/transfer.log"
echo "Uploading ${filename}" >> "${logfilepath}"
curl -fsSL -T "${filepath}" "https://transfer.sh/${filename}" >> "${logfilepath}"
echo '' >> "${logfilepath}"
fi
}
build_ubuntu_deb() {
cd "${PROJDIR}"
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
}
build_fedora_rpm() {
cd "${PROJDIR}"
mkdir -p "${BUILDDIR}"
export_srcarchive "${BUILDDIR}/${PKGNAME}.tar.gz"
mkdir "${BUILDDIR}/SOURCES"
mkdir "${BUILDDIR}/SPECS"
mv "${BUILDDIR}/${PKGNAME}.tar.gz" "${BUILDDIR}/SOURCES"
cp "${PROJDIR}/pkg/fedora/${PKGNAME}.spec" "${BUILDDIR}/SPECS"
rpmbuild --define "_topdir ${BUILDDIR}" -bb "${BUILDDIR}/SPECS/${PKGNAME}.spec"
}
build_opensuse_rpm() {
cd "${PROJDIR}"
mkdir -p "${BUILDDIR}"
export_srcarchive "${BUILDDIR}/${PKGNAME}.tar.gz"
mkdir "${BUILDDIR}/SOURCES"
mkdir "${BUILDDIR}/SPECS"
mv "${BUILDDIR}/${PKGNAME}.tar.gz" "${BUILDDIR}/SOURCES"
cp "${PROJDIR}/pkg/opensuse/${PKGNAME}.spec" "${BUILDDIR}/SPECS"
rpmbuild --define "_topdir ${BUILDDIR}" -bb "${BUILDDIR}/SPECS/${PKGNAME}.spec"
}
build_archlinux_pkg() {
cd "${PROJDIR}"
mkdir -p "${BUILDDIR}"
export_srcarchive "${BUILDDIR}/${PKGNAME}.tar.gz"
cp "${PROJDIR}/pkg/archlinux/PKGBUILD" "${BUILDDIR}"
cd "${BUILDDIR}"
updpkgsums
makepkg -s
}
ci_ubuntu_deb() { # 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 devscripts debhelper fakeroot
useradd -m ${USER}
chown -R ${USER}:${USER} "${PROJDIR}"
su -c "export HOME=/home/${USER} && sh "${SCRIPT}" build_ubuntu_deb" ${USER}
transfer_file "$(find "${BUILDDIR}" -type f -name "${PKGNAME}*.deb")"
}
ci_fedora_rpm() { # 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 rpm-build
useradd -m ${USER}
chown -R ${USER}:${USER} "${PROJDIR}"
su -c "export HOME=/home/${USER} && sh "${SCRIPT}" build_fedora_rpm" ${USER}
transfer_file "$(find "${PROJDIR}/build_"*${FUNCTION} -type f -name "${PKGNAME}*.rpm")"
}
ci_opensuse_rpm() { # 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 rpm-build
useradd -m ${USER}
chown -R ${USER}:${USER} "${PROJDIR}"
su -c "export HOME=/home/${USER} && sh "${SCRIPT}" build_opensuse_rpm" ${USER}
transfer_file "$(find "${PROJDIR}/build_"*${FUNCTION} -type f -name "${PKGNAME}*.rpm")"
}
ci_archlinux_pkg() { # 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
useradd -m ${USER}
chown -R ${USER}:${USER} "${PROJDIR}"
su -c "export HOME=/home/${USER} && sh "${SCRIPT}" build_archlinux_pkg" ${USER}
transfer_file "$(find "${PROJDIR}/build_"*${FUNCTION} -type f -name "${PKGNAME}*.pkg.tar.xz")"
}
${FUNCTION}
DISTFILES += \
$${PWD}/build-docker.sh \
$${PWD}/build.sh \
$${PWD}/package.sh \
$${PWD}/prepare.sh
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment