tcache - libdevuansdk - common library for devuan's simple distro kits
 (HTM) git clone https://git.parazyd.org/libdevuansdk
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Submodules
 (DIR) README
 (DIR) LICENSE
       ---
       tcache (2551B)
       ---
            1 #!/usr/bin/env zsh
            2 # Copyright (c) 2017 Dyne.org Foundation
            3 # libdevuansdk is maintained by Ivan J. <parazyd@dyne.org>
            4 #
            5 # This file is part of libdevuansdk
            6 #
            7 # This source code is free software: you can redistribute it and/or modify
            8 # it under the terms of the GNU General Public License as published by
            9 # the Free Software Foundation, either version 3 of the License, or
           10 # (at your option) any later version.
           11 #
           12 # This software is distributed in the hope that it will be useful,
           13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
           14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
           15 # GNU General Public License for more details.
           16 #
           17 # You should have received a copy of the GNU General Public License
           18 # along with this source code. If not, see <http://www.gnu.org/licenses/>.
           19 
           20 aptcache() {
           21     fn aptcache "$*"
           22     req=(aptcachedir watdo werdo APT_CACHE)
           23     local watdo="$1"
           24     local werdo="$2"
           25     ckreq || return 1
           26 
           27     [[ $APT_CACHE = 1 ]] || return 0
           28 
           29     case "$watdo" in
           30         on)
           31             act "mounting local apt cache"
           32             sudo mount -o bind "$aptcachedir" "$werdo" || zerr
           33             ;;
           34         off)
           35             act "umounting local apt cache"
           36             sudo umount "$werdo" || zerr
           37             ;;
           38     esac
           39 }
           40 
           41 fill_apt_cache() {
           42     fn fill_apt_cache
           43     req=(strapdir APT_CACHE aptcachedir)
           44     ckreq || return 1
           45 
           46     [[ $APT_CACHE = 1 ]] || return 0
           47 
           48     notice "filling local apt cache"
           49 
           50         cp -fv $strapdir/var/cache/apt/archives/*.deb $aptcachedir
           51 
           52         pushd "$aptcachedir"
           53                 dpkg-scanpackages . /dev/null > Packages
           54                 gzip -c Packages > Packages.gz
           55                 cat <<EOF > Release
           56 Origin: ${os}
           57 Suite: ${release}
           58 Version: ${version}
           59 Architectures: alpha amd64 arm64 armel armhf hppa i386 ia64 mips mipsel powerpc ppc64el s390x sparc
           60 MD5sum:
           61  $(md5sum Packages    | cut -d' ' -f1)    $(du -b Packages)
           62  $(md5sum Packages.gz | cut -d' ' -f1)    $(du -b Packages.gz)
           63 SHA1:
           64  $(sha1sum Packages    | cut -d' ' -f1)    $(du -b Packages)
           65  $(sha1sum Packages.gz | cut -d' ' -f1)    $(du -b Packages.gz)
           66 SHA256:
           67  $(sha256sum Packages    | cut -d' ' -f1)    $(du -b Packages)
           68  $(sha256sum Packages.gz | cut -d' ' -f1)    $(du -b Packages.gz)
           69 EOF
           70                 rm -f Packages
           71                 gpg --sign --detach-sign -a --sign-with $aptcachegpg Release || zerr
           72                 mv Release.asc Release.gpg
           73         popd
           74 
           75 
           76         sudo sed -i '/deb file:\/mnt/d' "$strapdir/etc/apt/sources.list"
           77         notice "removing apt cache gpg pubkey"
           78         cat <<EOF | sudo tee ${strapdir}/delcachepubkey >/dev/null
           79 #!/bin/sh
           80 apt-key del ${aptcachegpg}
           81 EOF
           82         chroot-script delcachepubkey || zerr
           83 }