From e41b4c264ad26fce41f2b1c14074c324ecc3a5f8 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 11 May 2020 01:22:04 +0200 Subject: [PATCH] =?UTF-8?q?Ajout=20d'un=20script=20permettant=20de=20r?= =?UTF-8?q?=C3=A9cup=C3=A9rer=20les=20packages=20de=20Kopano=20localement?= =?UTF-8?q?=20afin=20de=20proc=C3=A9der=20=C3=A0=20son=20installation/mise?= =?UTF-8?q?=20=C3=A0=20jour.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kopano/download_repo.sh | 71 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100755 kopano/download_repo.sh diff --git a/kopano/download_repo.sh b/kopano/download_repo.sh new file mode 100755 index 0000000..8afccf9 --- /dev/null +++ b/kopano/download_repo.sh @@ -0,0 +1,71 @@ +#!/bin/sh +# Require curl, html2text + +URLs="https://download.kopano.io/community/core%3A/ https://download.kopano.io/community/meet%3A/ https://download.kopano.io/community/webapp%3A/" +HTML2TEXT_BIN="html2text" +HTML2TEXT_OPT="-width 2000" +DISTRI="Debian_10" +ARCH="amd64" +TMPDIR=$(mktemp -d) +LOCALREPODIR="/var/cache/apt-kopano" + +echo "Retrieving Source packages..." +for URL in ${URLs} ; do + TEMPBASH=$(mktemp) + cat > ${TEMPBASH} << EOF +#!/bin/sh +PACKAGE=\$(curl -s ${URL} | ${HTML2TEXT_BIN} ${HTML2TEXT_OPT} - | awk '\$2 ~ /Debian_10.*(${ARCH}|all)/ {print \$2}') +EOF + . ${TEMPBASH} + rm ${TEMPBASH} + echo "${PACKAGE}" + if [ -e "${LOCALREPODIR}/list_of_file" ] ; then + if grep ${PACKAGE} "${LOCALREPODIR}/list_of_file" > /dev/null 2>&1 ; then + echo "Package already integrated into ${LOCALREPODIR}/repo" + continue + fi + fi + curl -qo "${TMPDIR}/${PACKAGE}" ${URL}${PACKAGE} + echo ${PACKAGE} >> "${TMPDIR}/list_of_file" + if [ -e "${LOCALREPODIR}/list_of_file" ] ; then + PACKAGE_NAME=$(echo ${PACKAGE} | awk -F'-' '{ print $1 }') + TEMPBASH=$(mktemp) + cat > ${TEMPBASH} << EOF +#!/bin/sh +sed -i '/^${PACKAGE_NAME}/d' "${LOCALREPODIR}/list_of_file" +echo ${PACKAGE} >> "${LOCALREPODIR}/list_of_file" +EOF + sh ${TEMPBASH} + rm ${TEMPBASH} + else + echo "${PACKAGE}" >> "${LOCALREPODIR}/list_of_file" + fi +done + +echo "Uncompress Source Packages..." +cd "${TMPDIR}" +if [ -e "${TMPDIR}/list_of_file" ] ; then + cat "${TMPDIR}/list_of_file" | while read file ; do + tar xf "$file" + done +else + echo "Nothing to uncompress..." +fi + +echo "Mooving .deb files into ${LOCALREPODIR}..." +mkdir -p "${LOCALREPODIR}/repo/" +find "${TMPDIR}" -type f -name '*.deb' -exec mv {} "${LOCALREPODIR}/repo/" \; + +echo "Cleaning old packages..." +LANG="" dpkg-scanpackages /var/cache/apt-kopano/repo 2>&1 >/dev/null | grep -Po '((\/.*?deb)(?=.*?repeat;))|used that.*?\K(\/.*deb)' | xargs -r rm -v + +echo "Building Packages file..." +TEMPBASH=$(mktemp) +cat > ${TEMPBASH} << EOF +#!/bin/sh +dpkg-scanpackages "${LOCALREPODIR}/repo" | sed 's@^Filename:.*${LOCALREPODIR}/\(.*\)@Filename: \1@g' > "${LOCALREPODIR}/Packages" +EOF +sh ${TEMPBASH} +rm ${TEMPBASH} + +rm -r "${TMPDIR}"