create cache repo outside of the chroot

This commit is contained in:
parazyd 2017-05-22 00:02:25 +02:00
parent 9989685971
commit 5152c1fafa
No known key found for this signature in database
GPG Key ID: F0CB28FCF78637DE
3 changed files with 77 additions and 51 deletions

View File

@ -22,6 +22,7 @@ LIBPATH=${LIBPATH:-$(dirname $0)}
source $LIBPATH/config
source $LIBPATH/zlibs/bootstrap
source $LIBPATH/zlibs/cache
source $LIBPATH/zlibs/helpers
source $LIBPATH/zlibs/imaging
source $LIBPATH/zlibs/iso

76
zlibs/cache Normal file
View File

@ -0,0 +1,76 @@
#!/usr/bin/env zsh
# Copyright (c) 2017 Dyne.org Foundation
# libdevuansdk is maintained by Ivan J. <parazyd@dyne.org>
#
# This file is part of libdevuansdk
#
# This source code is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this source code. If not, see <http://www.gnu.org/licenses/>.
aptcache() {
fn aptcache "$*"
req=(aptcachedir watdo werdo APT_CACHE)
local watdo="$1"
local werdo="$2"
ckreq || return 1
[[ $APT_CACHE = 1 ]] || return 0
case "$watdo" in
on)
act "mounting local apt cache"
sudo mount -o bind "$aptcachedir" "$werdo" || zerr
;;
off)
act "umounting local apt cache"
sudo umount "$werdo" || zerr
;;
esac
}
fill_apt_cache() {
fn fill_apt_cache
req=(strapdir APT_CACHE aptcachedir)
ckreq || return 1
[[ $APT_CACHE = 1 ]] || return 0
notice "filling local apt cache"
cp -fv "$strapdir/var/cache/archives/*.deb" "$aptcachedir"
pushd "$aptcachedir"
dpkg-scanpackages . /dev/null > Packages
gzip -c Packages > Packages.gz
cat <<EOF > Release
Origin: ${os}
Suite: ${release}
Version: ${version}
Architectures: alpha amd64 arm64 armel armhf hppa i386 ia64 mips mipsel powerpc ppc64el s390x sparc
MD5sum:
$(md5sum Packages | cut -d' ' -f1) $(du -b Packages)
$(md5sum Packages.gz | cut -d' ' -f1) $(du -b Packages.gz)
SHA1:
$(sha1sum Packages | cut -d' ' -f1) $(du -b Packages)
$(sha1sum Packages.gz | cut -d' ' -f1) $(du -b Packages.gz)
SHA256:
$(sha256sum Packages | cut -d' ' -f1) $(du -b Packages)
$(sha256sum Packages.gz | cut -d' ' -f1) $(du -b Packages.gz)
EOF
rm -f Packages
## TODO: XXX: gpg sign Release
popd
sudo sed -i -e '@deb file:/mnt@d' "$strapdir/etc/apt/sources.list"
}

View File

@ -357,57 +357,6 @@ blend_postinst() {
return 0
}
aptcache() {
fn aptcache "$*"
req=(aptcachedir watdo werdo APT_CACHE)
local watdo="$1"
local werdo="$2"
ckreq || return 1
[[ $APT_CACHE = 1 ]] || return 0
case "$watdo" in
on)
act "mounting local apt cache"
sudo mount -o bind "$aptcachedir" "$werdo" || zerr
;;
off)
act "umounting local apt cache"
sudo umount "$werdo" || zerr
;;
esac
}
fill_apt_cache() {
fn fill_apt_cache
req=(strapdir APT_CACHE)
ckreq || return 1
[[ $APT_CACHE = 1 ]] || return 0
notice "filling local apt cache"
cat <<EOF | sudo tee ${strapdir}/fill-apt-cache >/dev/null
#!/bin/sh
# NOTE: do we need apt update or does it read the remote(s)?
apt-get update
apt-get --yes --force-yes --no-install-recommends install dpkg-dev
cp -afv /var/cache/apt/archives/*.deb /mnt
cd /mnt
dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz
cd -
apt-get --yes --force-yes purge dpkg-dev
sed -i -e "@deb file:/mnt@d" /etc/apt/sources.list
apt-get update
EOF
chroot-script fill-apt-cache || zerr
}
silly() {
fn silly "$@"
local arg1="$1"