#!/bin/bash -e COMMENT="# this script is part of apt-get-interim, a tool for updating a debian system # without fast local net connection. # there are three stages. # first read in a list of needed packages. # second download them on any debian system with fast internet connection. # third install them on the origin debian system # a bunch of scripts will be generated by apt-get-interim, # so you simply have to start four scripts at all and everything will be fine :) ## send comments to age-at-systemausfall-dot-org" USAGEHINT="apt-get-interim-update - APT for lousy connected boxes\n usage: $0 DIR [ACTION]\n \tDIR should be the path to your removeable media\n \tACTION can be \"upgrade\", \"dist-upgrade\", \"install PACKAGELIST\"\n \t\tdefault action is dist-upgrade" VERSION="0.2" # what apt-get action should be performed (e.g. upgrade, install package foo, ..) ACTION="dist-upgrade" #ACTION="install $2" ##where $2 is a file with packagenames or a package or ia list of packages in quotes # which sources list should be used SRCLIST="/etc/apt/sources.list" [ -z "$1" ] && echo -e $USAGEHINT && exit 1 MEDIUM="$1" echo "your media: $MEDIUM" [ ! -d $MEDIUM -o ! -w $MEDIUM -o ! -x $MEDIUM ] && echo -e "\tis not writeable!" && exit 1 [ ! -z "$2" ] && ACTION="$2" echo "apt-get action: $ACTION" SCRIPT1=${MEDIUM}/apt-get-interim_1_$(uname -n) SCRIPT2=${MEDIUM}/apt-get-interim_2_$(uname -n) SCRIPT3=${MEDIUM}/apt-get-interim_3_$(uname -n) REMOTE_APT_CONF=${MEDIUM}/apt.conf ## generate stage 1 script for local update cat > $SCRIPT1 <<EOF #!/bin/sh # This file was auto-generated by apt-get-interim ${VERSION} $COMMENT # stage 1: # start this script on your debianbox with a slow internet connection, # to update your package lists. apt-get update || exit 1 cd $MEDIUM || exit 1 mkdir -p archives/partial mkdir -p lists/partial cp /var/lib/dpkg/status status cp $SRCLIST sources.list chmod 644 $SCRIPT1 chmod 744 $SCRIPT2 mv \$0 \${0}.done echo "start the stage 2 script on a debian machine with fast access to your apt sources!" EOF chmod 744 $SCRIPT1 ## generate remote apt.conf cat > $REMOTE_APT_CONF <<EOF APT { Architecture "i386"; Get::Download-Only "true"; } Dir { State "${MEDIUM}"; State::status "status"; Cache::archives "${MEDIUM}/archives"; } EOF ## generate stage 2 script to run on the remote machine cat > $SCRIPT2 <<EOF #!/bin/sh # This file was auto-generated by apt-get-interim ${VERSION} $COMMENT # stage 2: # start this script on a machine with fast access to the apt sources" cd $MEDIUM export APT_CONFIG="${REMOTE_APT_CONF}" apt-get update apt-get $ACTION chmod 644 $SCRIPT2 chmod 744 $SCRIPT3 mv \$0 \${0}.done echo "now get back home and install the fetched packages with the third script!" EOF ## generate stage 3 script that back on local machine installs the fetched packages cat > $SCRIPT3 <<EOF #!/bin/sh # This file was auto-generated by apt-get-interim ${VERSION} $COMMENT # stage 3: # start this script fully deb loaded and back on your slow connected machine cd $MEDIUM export APT_CONFIG="$MEDIUM/apt.conf" apt-get check apt-get --no-d -o dir::etc::status=/var/lib/dpkg/status $ACTION chmod 644 $SCRIPT3 mv \$0 \${0}.done echo "that's it, see you next time.." EOF echo "three scripts were generated." echo -e "ypu can start now the script for the first stage:\n\t$SCRIPT1"