3990b5fb65
1. PyCharm inspection: ignore no member for magic places (six.moves, mixin for system_test, unicode<->string on python2) 2. Fix docstrings 3. Fix reraise of SkipTest (use raise instead of raising again the same exception, but no args) 4. Bash simple variable usage Closes-bug: #1578998 Change-Id: Ifac2dcb68b323ce48c6c80598abfd18ed9bf2caf
93 lines
2.7 KiB
Bash
93 lines
2.7 KiB
Bash
#!/bin/bash
|
|
# Based on the method described here:
|
|
# http://troubleshootingrange.blogspot.com/2012/09/hosting-simple-apt-repository-on-centos.html
|
|
# Please install 'dpkg' and 'dpkg-devel' packages before use.
|
|
|
|
set -e
|
|
|
|
ARCH=amd64
|
|
REPO_PATH=$1
|
|
SUITE=$2
|
|
SECTION=main
|
|
|
|
BINDIR=${REPO_PATH}/dists/${SUITE}/${SECTION}
|
|
|
|
# Validate structure of the repo
|
|
mkdir -p "${BINDIR}/binary-${ARCH}/"
|
|
mkdir -p "${REPO_PATH}/pool/${SECTION}"
|
|
RELEASE="${REPO_PATH}/dists/${SUITE}/Release"
|
|
touch ${RELEASE}
|
|
|
|
release_header=`sed '/MD5Sum:/,$d' ${RELEASE}`
|
|
|
|
override_main="indices/override.${SUITE}.${SECTION}"
|
|
override_udeb="indices/override.${SUITE}.${SECTION}.debian-installer"
|
|
override_extra="indices/override.${SUITE}.extra.${SECTION}"
|
|
|
|
if [ -f "${REPO_PATH}/${override_main}" ]; then
|
|
binoverride="${override_main}"
|
|
else
|
|
binoverride=""
|
|
fi
|
|
if [ -f "${REPO_PATH}/${override_udeb}" ]; then
|
|
binoverride_udeb="${override_udeb}"
|
|
else
|
|
binoverride_udeb=""
|
|
fi
|
|
if [ -f "${REPO_PATH}/${override_extra}" ]; then
|
|
extraoverride="--extra-override ${override_extra}"
|
|
else
|
|
extraoverride=""
|
|
fi
|
|
|
|
package_deb=${BINDIR}/binary-${ARCH}/Packages
|
|
package_udeb=${BINDIR}/debian-installer/binary-${ARCH}/Packages
|
|
|
|
cd ${REPO_PATH}
|
|
|
|
# Scan *.deb packages
|
|
dpkg-scanpackages -m ${extraoverride} -a ${ARCH} pool/${SECTION} ${binoverride} > ${package_deb}.tmp 2>/dev/null
|
|
|
|
gzip -9c ${package_deb}.tmp > ${package_deb}.gz.tmp
|
|
bzip2 -ckz ${package_deb}.tmp > ${package_deb}.bz2.tmp
|
|
|
|
# Replace original files with new ones
|
|
mv --backup -f ${package_deb}.tmp ${package_deb}
|
|
mv --backup -f ${package_deb}.gz.tmp ${package_deb}.gz
|
|
mv --backup -f ${package_deb}.bz2.tmp ${package_deb}.bz2
|
|
|
|
# Scan *.udeb packages
|
|
if [ -d "${BINDIR}/debian-installer/binary-${ARCH}/" ]; then
|
|
dpkg-scanpackages --udeb -m -a ${ARCH} pool/debian-installer ${binoverride_udeb} > ${package_udeb}.tmp 2>/dev/null
|
|
|
|
gzip -9c ${package_udeb}.tmp > ${package_udeb}.gz.tmp
|
|
bzip2 -ckz ${package_udeb}.tmp > ${package_udeb}.bz2.tmp
|
|
|
|
# Replace original files with new ones
|
|
mv --backup -f ${package_udeb}.tmp ${package_udeb}
|
|
mv --backup -f ${package_udeb}.gz.tmp ${package_udeb}.gz
|
|
mv --backup -f ${package_udeb}.bz2.tmp ${package_udeb}.bz2
|
|
fi
|
|
|
|
# Generate release file
|
|
cd ${REPO_PATH}/dists/${SUITE}
|
|
echo "$release_header" > Release.tmp
|
|
|
|
# Generate hashes
|
|
c1=(MD5Sum: SHA1: SHA256: SHA512:)
|
|
c2=(md5 sha1 sha256 sha512)
|
|
|
|
i=0
|
|
while [ ${i} -lt ${#c1[*]} ]; do
|
|
echo ${c1[i]}
|
|
for hashme in `find ${SECTION} -type f \( -not -name "*~" -name "Package*" -o -name "Release*" \)`; do
|
|
ohash=`openssl dgst -${c2[$i]} ${hashme}`
|
|
chash="${ohash##* }"
|
|
size=`stat -c %s ${hashme}`
|
|
echo " ${chash} ${size} ${hashme}"
|
|
done
|
|
i=$(( $i + 1));
|
|
done >> Release.tmp
|
|
|
|
mv --backup -f Release.tmp Release
|