[Apt-zip-devel] Re: apt-zip

Giacomo A. Catenazzi cate at debian.org
Wed Apr 11 07:02:21 UTC 2007


François Févotte wrote:
> Could you please review it and let me know of your comments / remarks ?

Hello François,

thanks for the patch, below I put some comments.

ciao
	cate


> 
> Thanks,
>   François
> 
> 
> ------------------------------------------------------------------------
> 
> 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,36 @@
>  [ -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} )

I don't like it ;-) To write fewer line, you complicate the scripts.
I think that you should mode the "EXTRACTDIR=/var/lib/apt/lists"
in after the next "if" statment, change the option of tar in
the if statment with "xvf" ( I don't know if "xtf" works),
and put this unpacking in a new "if action not update".

> +
> +    if [ "$APTGETACTION" = "update" ]
> +    then
> +        echo >&2 "Uncompressing index archives..."
> +        (
> +            cd $EXTRACTDIR
> +            tar tf ${MEDIUM}/${APTZIPTARFILE} |
> +            while read FILE
> +            do
> +              [ `basename $FILE .bz2` != "$FILE" ] && bunzip2 -f $FILE
> +              [ `basename $FILE .gz`  != "$FILE" ] && gunzip -f $FILE

I don't understand this.
if $FILE ends with ".gz", the first condition is true and it will try
to extract as bzip2 the .gz file.
I think you should do:
	[ `basename $FILE .bz2`.bz2 = "$FILE" ] && bunzip2 -f $FILE
or probably a grep is simpler:
	echo "$FILE" | grep -sqe '.bz2$' -  &&  bunzip2 -f "$FILE"
BTW I will quote the "$FILE".

> +            done
> +            rm -f foo-stamp

? who create this file?

> +        )
> +    fi
> +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: debian/changelog
> ===================================================================
> --- debian/changelog	(revision 73)
> +++ debian/changelog	(working copy)
> @@ -1,8 +1,10 @@
>  apt-zip (0.16) UNRELEASED; urgency=low
>  
>    * more indenting improvement in common.sh.in file
> +  * add possibility to run update, too, thanks to François Févotte for the
> +    patch
>  
> - -- Eddy Petrișor <eddy.petrisor at gmail.com>  Mon,  5 Jun 2006 22:44:21 +0300
> + -- Eddy Petrișor <eddy.petrisor at gmail.com>  Fri,  9 Feb 2007 22:44:52 +0200


Now that etch is released, we can upload a new testing version!


>  
>  apt-zip (0.15) unstable; urgency=low
>  
> 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
> @@ -125,6 +127,7 @@
>  	fi
>  fi
>  
> +
>  ###############
>  # Stuff dependant on TAR option
>  #
> @@ -144,9 +147,34 @@
>  	cat <<-EOF
>  
>  	getfile(){
> -	    do_wget \$1 \$2 \$3 \$4 &&
> -	    $TAR $TARADD $APTZIPTARFILE \$2 &&
> -	    rm \$2
> +EOF
> +
> +	#################
> +	# Stuff dependent on the update action
> +	#
> +
> +	if [ "$APTGETACTION" = "update" ] ; then
> +	    cat <<-EOF
> +	    FILE=""
> +	    for EXT in ".bz2" ".gz" ""
> +	    do
> +	      do_wget \$1\$EXT \$2\$EXT \$3 \$4 &&
> +	      FILE=\$2\$EXT &&
> +	      break
> +	      rm -f \$2\$EXT
> +	    done
> +	    [ "\$FILE" = "" ] && return 1
> +EOF
> +	else
> +	    cat <<-EOF
> +	    do_wget \$1 \$2 \$3 \$4 || return 1
> +	    FILE=\$2
> +EOF
> +	fi
> +
> +	cat <<-EOF
> +	    $TAR $TARADD $APTZIPTARFILE \$FILE &&
> +	    rm \$FILE
>  	}
>  
>  	touch foo-stamp && "$OPTION_TAR" cf "$APTZIPTARFILE" foo-stamp && rm foo-stamp
> 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)
> @@ -56,6 +56,7 @@
>      echo $_SZ
>      }
>  )
> +[ "$DWLSIZE" -eq "0" ] && DWLSIZE=unknown
>  export DWLSIZE
>  PACKCOUNT=`cat "$TMP" | wc -l`
>  export PACKCOUNT
> @@ -70,10 +71,28 @@
>  export SLEEPTIME
>  export SLEEPCMD=`eval "$SLEEPEVALCMD"`
>  export CHECK=`eval "$CHECKEVALCMD"`
> +export APTGETACTION
>  
>  # Write the script
>  SCRIPT="${MEDIUM}"/fetch-script-$METHOD-$(uname -n)
>  
> +if [ "$APTGETACTION" = "update" ]
> +then
> +    [ "$OPTION_TAR" = "0" ]                                     \
> +    && echo "Error: the \`tar' option should be set when using" \
> +            "\`--aptgetaction update'"                          \
> +    && exit 1
> +
> +    # Remove .bz2 and .gz extension from the `Packages' and
> +    # `Sources' index files
> +    perl -pn -i.bak                        \
> +        -e 's/Packages\.bz2\s/Packages /;' \
> +        -e 's/Packages\.gz\s/Packages /;'  \
> +        -e 's/Sources\.bz2\s/Sources /;'   \
> +        -e 's/Sources\.gz\s/Sources /;'    \
> +        $TEMP

perl? ;-)

I prefer sed:
sed -nre "s/\.(bz2|gz)$/ /pg" -
but ok if you like perl. But maybe you should add "$" at the end
of match expression.

> +fi
> +
>  # --print-uris shows: URI filename size-in-bytes md5
>  $FILTER < "$TEMP" >"$SCRIPT"
>  if [ $? != 0 ]
> 




More information about the apt-zip-devel mailing list