[Apt-zip-devel] Re: apt-zip
Giacomo Catenazzi
cate at cateee.net
Thu Feb 1 08:46:18 CET 2007
Some comments:
* You should add also the list address, so the patches and
discussions are archived:
Apt-zip Development Team <apt-zip-devel at lists.alioth.debian.org>
* Why do you decompress Packages file in the fetch script?
I think it is better to raw copy the file. Then in the host
machine you could decompress. In this mannes it doesn't
requires bzip2 or gunzip on the remote machine, and it
requires less space in medium.
* I think you should export only the name "Packages" to
the list of files to download.
The fetch script then should test it it exits the
.bz2 or the .gz files.
(so you remove also the "sed" requirement).
BTW I think apt-get cannot use raw (non compressed) Package,
but we can use as failover. Ev. in install script we can
compress it (but now I don't remember the requirement
of repositories, I should recheck the dpkg doc)
As secundary note: We should always download the Packages
files and not the eventual diff files (as in etch and sid).
I'm not sure if diff now are the default or if it requires
addisional parameter. To check.
* BTW: we could add an option to download Packages also
during normal apt-zip-list operation.
So for frequent usage, user don't need double trip.
* - ${CHECK} \$2 \$4 \$?
+ ${CHECK} "\$2" "\$4" "\$?"
Such quotation are useless, they are removed bye
first shell run (in home host).
Better is:
+ ${CHECK} \"\$2\" \"\$4\" \"\$?\"
which on first run convert in
check "$1" "$4" "$?"
on the fetch script (ready for the second run).
But it is not very readable. Anyway it could improve
security.
General comment.
In a long term maybe we should avoid the double run of
method scripts: they are not very readable, and it is
difficult to understand what code is run on target and
what code on home machine.
(maybe with %VAR% notation and some sed script that
substitute/insert variables and blocks)
But you, Fran,cois, ignore this for now. It should be
a long term change, during a eventual new rewrite.
ciao
cate
François Févotte wrote:
> Hi,
>
> attached is the diff of my version against the svn trunk. I updated
> the sgml manpage.
>
> Index: apt-zip-inst
> ===================================================================
> --- apt-zip-inst (revision 73)
> +++ apt-zip-inst (working copy)
> @@ -12,15 +12,7 @@
> check_medium
> az_mount
>
> -if [ -r "${MEDIUM}/${APTZIPTARFILE}" ]
> -then
> - echo >&2 "Unpacking tarball..."
> - ( cd /var/cache/apt/archive ; tar xf ${MEDIUM}/${APTZIPTARFILE} )
> - APTZIPINSFILE="${MEDIUM}/${APTZIPINSFILE}"
> -else
> - APTGETCACHE="-o dir::cache::archives=${MEDIUM}"
> - APTZIPINSFILE="${MEDIUM}/${APTZIPINSFILE}"
> -fi
> +APTZIPINSFILE="${MEDIUM}/${APTZIPINSFILE}"
>
> if [ -r "${APTZIPINSFILE}" ] ; then
> . "${APTZIPINSFILE}"
> @@ -33,6 +25,20 @@
> [ -z "$APTGETACTION" ] && APTGETACTION=${DEF_APTGETACTION}
> [ -z "$APTGETEXTRAOPTS" ] && APTGETEXTRAOPTS=${DEF_APTGETEXTRAOPTS}
>
> +if [ -r "${MEDIUM}/${APTZIPTARFILE}" ]
> +then
> + EXTRACTDIR=/var/cache/apt/archive
> + [ "$APTGETACTION" = "update" ] && EXTRACTDIR=/var/lib/apt/lists
> + echo >&2 "Unpacking tarball..."
> + ( cd $EXTRACTDIR ; tar xf ${MEDIUM}/${APTZIPTARFILE} )
> +else
> + [ "$APTGETACTION" = "update" ] \
> + && echo "Error: the \`tar' option should be set when using" \
> + "\`--aptgetaction update'" \
> + && exit 1
> + APTGETCACHE="-o dir::cache::archives=${MEDIUM}"
> +fi
> +
> APTGETEXTRAOPTS="${APTGETEXTRAOPTS} ${APTGETCACHE}"
>
> [ -n "$PACKAGES" ] && apt-get ${APTGETEXTRAOPTS} install $PACKAGES
> Index: methods/wget
> ===================================================================
> --- methods/wget (revision 73)
> +++ methods/wget (working copy)
> @@ -31,6 +31,8 @@
> [ ! "${USEMD5SUMS}" = 'no' ] && cat <<-EOF
> check(){
> [ ! -r "\$1" ] && return 1
> + [ "\$2" = "0" ] && return \$3
> + [ "\$2" = "" ] && return \$3
> [ "\`type md5sum\`" ] &&
> if [ "\`md5sum \$1 | cut -d' ' -f1\`" = \$2 ]
> then return 0
> @@ -77,7 +79,7 @@
>
> do_wget() {
> wget -t3 -nv -O \$2 \$1
> - ${CHECK} \$2 \$4 \$?
> + ${CHECK} "\$2" "\$4" "\$?"
> ${SLEEPCMD}
> return \$?
> }
> @@ -100,10 +102,10 @@
> if [ -r "$OLDTARFILE" ] && "$TAR" "$TARTEST" "$OLDTARFILE" \$2 >/dev/null 2>&1
> then
> "$TAR" "$TAREXTRACT" "$OLDTARFILE" \$2
> - if [ -r \$2 ] && ${CHECK} \$2 \$4 \$? ; then echo "Already got \$2"; return 0; fi
> + if [ -r \$2 ] && ${CHECK} "\$2" "\$4" "\$?" ; then echo "Already got \$2"; return 0; fi
> fi
> wget -nc -t3 -nv -O \$2 \$1
> - ${CHECK} \$2 \$4 \$?
> + ${CHECK} "\$2" "\$4" "\$?"
> ${SLEEPCMD}
> return \$?
> }
> @@ -112,9 +114,9 @@
> elif [ "$OPTION_TAR" = 0 ] ; then
> cat <<-EOF
> do_wget() {
> - if [ -r ../\$2 ] && ${CHECK} ../\$2 \$4 \$? ; then echo "Already got \$2"; return 1; fi
> + if [ -r ../\$2 ] && ${CHECK} ../\$2 "\$4" "\$?" ; then echo "Already got \$2"; return 1; fi
> wget -t3 -nv -O \$2 \$1
> - ${CHECK} \$2 \$4 \$?
> + ${CHECK} "\$2" "\$4" "\$?"
> ${SLEEPCMD}
> return \$?
> }
> @@ -125,6 +127,51 @@
> fi
> fi
>
> +
> +
> +#################
> +# Specific function for packages index
> +#
> +
> +DO_WGET=do_wget
> +if [ "$APTGETACTION" = "update" ] ; then
> + DO_WGET=getindexfile
> + cat <<-EOF
> + getindexfile(){
> + FILE=\$1
> +
> + # If the file is a bzip2 archive
> + # download and uncompress it
> + BASENAME=\`echo \$FILE | sed -e 's/.bz2$//'\`
> + if [ ! \$BASENAME = \$FILE ] ; then
> + do_wget \$FILE \$2.bz2 \$3 \$4 \\
> + && bunzip2 \$2.bz2 \\
> + && return 0
> + rm -f \$2.bz2 \$2
> +
> + # Try to find a gzip version
> + FILE=\${BASENAME}.gz
> + fi
> +
> + # If the file is a gzip archive
> + # download and uncompress it
> + BASENAME=\`echo \$FILE | sed -e 's/.gz$//'\`
> + if [ ! \$BASENAME = \$FILE ] ; then
> + do_wget \$FILE \$2.gz \$3 \$4 \\
> + && gunzip \$2.gz \\
> + && return 0
> + rm -f \$2.gz \$2
> + fi
> +
> + # Nothing special if the file is not a compressed archive
> + do_wget \$1 \$2 \$3 \$4 && return 0
> + rm -f \$2
> + return 1
> + }
> +EOF
> +fi
> +
> +
> ###############
> # Stuff dependant on TAR option
> #
> @@ -134,8 +181,8 @@
> cat <<-EOF
>
> getfile(){
> - ( [ -r ../\$2 ] && ${CHECK} ../\$2 \$4 \$? && echo \$2 already downloaded.) ||
> - (do_wget \$1 \$2 \$3 \$4 && mv \$2 ../)
> + ( [ -r ../\$2 ] && ${CHECK} ../\$2 "\$4" "\$?" && echo \$2 already downloaded.) ||
> + ($DO_WGET \$1 \$2 \$3 \$4 && mv \$2 ../)
> }
>
> mkdir -p partial && cd partial || echo >&2 "Cannot change to directory ./partial"
> @@ -144,7 +191,7 @@
> cat <<-EOF
>
> getfile(){
> - do_wget \$1 \$2 \$3 \$4 &&
> + $DO_WGET \$1 \$2 \$3 \$4 &&
> $TAR $TARADD $APTZIPTARFILE \$2 &&
> rm \$2
> }
> Index: apt-zip.sgml
> ===================================================================
> --- apt-zip.sgml (revision 73)
> +++ apt-zip.sgml (working copy)
> @@ -134,11 +134,14 @@
> <term>--aptgetaction, -a</term>
> <listitem>
> <simpara>Select the action done by apt-get. Possible actions are
> - <option>dselect-upgrade</option>,<option>upgrade</option> and
> - <option>dist-upgrade</option>.</simpara>
> + <option>dselect-upgrade</option>, <option>upgrade</option>,
> + <option>dist-upgrade</option> and <option>update</option>.
> + </simpara>
> <simpara>If <option>--packages</option> is not set the default is
> <option>dselect-upgrade</option> (See also
> <filename>apt-zip.conf</filename>), if it is set none is selected.
> + <simpara>The <option>update</option> action must always be used
> + in conjunction with the <option>tar</option> (see below).</simpara>
> </listitem>
> </varlistentry>
>
> Index: common.sh.in
> ===================================================================
> --- common.sh.in (revision 73)
> +++ common.sh.in (working copy)
> @@ -8,7 +8,7 @@
> SKIPMOUNT=no
> APTGETEXTRAOPTS=""
>
> -KNOWNAPTGETACTIONS=" dselect-upgrade upgrade dist-upgrade "
> +KNOWNAPTGETACTIONS=" dselect-upgrade upgrade dist-upgrade update "
> KNOWNOPTIONS="TAR GNUTAR SOLARISTAR RESTART"
>
> DEFAULT_TAR=tar
> Index: apt-zip-list
> ===================================================================
> --- apt-zip-list (revision 73)
> +++ apt-zip-list (working copy)
> @@ -70,10 +70,16 @@
> export SLEEPTIME
> export SLEEPCMD=`eval "$SLEEPEVALCMD"`
> export CHECK=`eval "$CHECKEVALCMD"`
> +export APTGETACTION
>
> # Write the script
> SCRIPT="${MEDIUM}"/fetch-script-$METHOD-$(uname -n)
>
> +[ "$OPTION_TAR" = "0" -a "$APTGETACTION" = "update" ] \
> + && echo "Error: the \`tar' option should be set when using" \
> + "\`--aptgetaction update'" \
> + && exit 1
> +
> # --print-uris shows: URI filename size-in-bytes md5
> $FILTER < "$TEMP" >"$SCRIPT"
> if [ $? != 0 ]
More information about the apt-zip-devel
mailing list