Package: approx
Version: 1.15
Severity: normal
Tags: patch

I'm using "secure" apt 0.6, which AFAICS prefers Packages.bz2 files to
the usual Packages.gz files. gc_approx doesn't know about .bz2 files and
thus might completely purge the repository.

This is somewhat related to #310399 -- I think it would indeed be a good
idea to use only the latest Packages(|.gz|.bz2) found in a directory.

Also, while looking at this, I found that approx doesn't know about
Release.gpg files; instead, it looked for Release.gz files which AFAIK
never existed.

A crude patch is attached.


-- System Information:
Debian Release: 3.1
[I'm not writing this from the system I'm running approx on, so I
removed the dependency information. In case it matters, that system is
running sarge plus apt 0.6.]
--- ./approx.ml 2005/06/12 10:31:36     1.1
+++ ./approx.ml 2005/06/12 10:35:09
@@ -91,6 +91,9 @@
   if Filename.check_suffix file_name ".gz" then
     [ "Content-Type", "application/x-gzip";
       "Content-Encoding", "x-gzip" ]
+  else if Filename.check_suffix file_name ".bz2" then
+    [ "Content-Type", "application/x-bzip2";
+      "Content-Encoding", "x-bzip2" ]
   else
     [ "Content-Type", "text/plain" ]
 
--- ./debian/changelog  2005/06/12 10:40:39     1.1
+++ ./debian/changelog  2005/06/12 11:12:09
@@ -1,3 +1,10 @@
+approx (1.15.1) unstable; urgency=low
+
+  * Add support for bzip2'd Packages/Release/Sources files.
+  * gc_approx: Keep "Release.gpg", not "Release.gz" which doesn't exist.
+
+ -- Flavio Stanchina <[EMAIL PROTECTED]>  Sun, 12 Jun 2005 13:01:47 +0200
+
 approx (1.15) unstable; urgency=low
 
   * Build byte-code version on architectures with no ocamlopt
--- ./debian/control    2005/06/12 10:43:02     1.1
+++ ./debian/control    2005/06/12 10:43:42
@@ -9,6 +9,7 @@
 Package: approx
 Architecture: any
 Depends: ${shlibs:Depends}, wget
+Recommends: bzip2
 Description: caching proxy server for Debian archive files
  Approx is an HTTP-based Debian archive server.
  It fetches packages from remote repositories on demand,
--- ./gc_approx.ml      2005/06/12 10:31:36     1.1
+++ ./gc_approx.ml      2005/06/12 11:01:19
@@ -55,7 +55,7 @@
 let find_roots () =
   let find file =
     match Filename.basename file with
-    | "Packages" | "Packages.gz" -> roots := file :: !roots
+    | "Packages" | "Packages.gz" | "Packages.bz2" -> roots := file :: !roots
     | _ -> ()
   in
   Config.iter (fun dir _ -> treewalk find (cache_dir ^/ dir))
@@ -90,9 +90,9 @@
 
 let is_candidate file =
   match Filename.basename file with
-    | "Packages" | "Packages.gz"
-    | "Release" | "Release.gz"
-    | "Sources" | "Sources.gz" ->
+    | "Release"  | "Release.gpg"
+    | "Packages" | "Packages.gz" | "Packages.bz2"
+    | "Sources"  | "Sources.gz"  | "Sources.bz2" ->
        let dist, _ = split_cache_pathname file in
        (try ignore (Config.get dist); false
         with Not_found -> true (* not part of a known distribution *))
--- ./package.ml        2005/06/12 10:31:36     1.1
+++ ./package.ml        2005/06/12 10:38:52
@@ -63,10 +63,24 @@
   Sys.remove tmp;
   chan
 
+let decompress2 file =
+  let tmp = tmp_file () in
+  let cmd = Printf.sprintf "/usr/bin/bunzip2 --stdout %s > %s" file tmp in
+  if Sys.command cmd <> 0 then
+    begin
+      Sys.remove tmp;
+      failwith "decompress2"
+    end;
+  let chan = open_in tmp in
+  Sys.remove tmp;
+  chan
+
 let with_open_file file proc =
   let chan =
     if Filename.check_suffix file ".gz" then
       decompress file
+    else if Filename.check_suffix file ".bz2" then
+      decompress2 file
     else
       open_in file
   in

Reply via email to