Ajout d'un script permettant de récupérer les packages de Kopano

localement afin de procéder à son installation/mise à jour.
This commit is contained in:
root 2020-05-11 01:22:04 +02:00
parent bcd36b08d4
commit e41b4c264a

71
kopano/download_repo.sh Executable file
View File

@ -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}"