[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Solved: Aptitude with ISO and network repositories?



Hi all

I think I solved it...
I used some time to get it to work, so I'd better post what I have found:

I primarily used the following information:
http://www.debianhelp.org/node/10486
http://forum.linuxmce.org/index.php?topic=10408.0
http://www.debian.org/doc/manuals/repository-howto/repository-howto

And I came up with this script (partly copied from one of the references):

#!/bin/bash
#
# This script will scan local Debian repositories,
#   create the Package file and a signed Release file for each.
#
# Basic idea:
# Aptitude fetch packages from local repositories when package is present and up to date.
#   Aptitude fetch packages from network repositories in other cases.
#
# Solution:
# 1) Ensure you have added a gpg key to aptitude with apt-key (for signing the repository later).
#   2) Create a parent folder for local repositories.
#   3) Download Debian ISOs.
#   4) Mount ISOs and copy relevant repositories out to the created folder.
#   5) Repeat for all ISOs and repositories needed (e.g. main and contrib).
#   6) Run this script for each of the repositories.
# 7) Add each of the repositories at the beginning of /etc/apt/sources.list
#      "deb file::<path to parent-dir> <repository>/"
#
# Example:
#      APT_REP=/var/local/aptitude/repository
#
#      mkdir -p ${APT_REP}
#
#      mount -o loop debian-6.0.0-amd64-DVD-1.iso /mnt
#      cp -an /mnt/pool/main ${APT_REP}
#      cp -an /mnt/pool/contrib ${APT_REP}
#      umount /mnt
#
#      mount -o loop debian-6.0.0-amd64-DVD-2.iso /mnt
#      cp -an /mnt/pool/main ${APT_REP}
#      cp -an /mnt/pool/contrib ${APT_REP}
#      umount /mnt
#
#      ./generate_repository ${APT_REP}/main ${APT_REP}/contrib
#
#      sed -i "1i\
#              deb file::${APT_REP} contrib/" /etc/apt/sources.list
#      sed -i "1i\
#              deb file::${APT_REP} main/" /etc/apt/sources.list
#
#      aptitude update
#

for REPO_DIR; do
    REPOSITORY=`basename ${REPO_DIR}`
    pushd ${REPO_DIR} >/dev/null

    echo Processing ${REPOSITORY}

    rm -f Packages Packages.gz Release Release.gpg
    (cd .. && dpkg-scanpackages ${REPOSITORY} /dev/null) > Packages
    gzip -9c Packages > Packages.gz

    cat >Release <<EOF
Origin: Debian
Label: Debian
Suite: stable
Version: 6.0
Codename: ${REPOSITORY}
Date: Sat, 05 Feb 2011 12:29:37 UTC
Architectures: amd64
Description: Debian 6.0 Released 05 February 2011
EOF
printf 'MD5Sum: '$(md5sum Packages | cut --delimiter=' ' --fields=1)' %16d Packages\n' \
        $(wc --bytes Packages | cut --delimiter=' ' --fields=1) >> Release
printf ' '$(md5sum Packages.gz | cut --delimiter=' ' --fields=1)' %16d Packages.gz' \ $(wc --bytes Packages.gz | cut --delimiter=' ' --fields=1) >> Release

    gpg --yes --armor --detach-sign --output Release.gpg Release

    echo
    popd >/dev/null
done
#---

I hope it might be useful to someone.

~Per


Reply to: