[Cdd-commits] r408 - projects/simple-cdd/trunk

CDD Subversion Commit noreply at alioth.debian.org
Fri Aug 4 16:56:11 UTC 2006


Author: otavio
Date: Fri Aug  4 16:56:10 2006
New Revision: 408

Added:
   projects/simple-cdd/trunk/CONF.sh
   projects/simple-cdd/trunk/build-simple-cdd   (contents, props changed)
   projects/simple-cdd/trunk/debpartial-mirror.conf
   projects/simple-cdd/trunk/patched-debpartial-mirror   (contents, props changed)
   projects/simple-cdd/trunk/simple-cdd-packages.list
Modified:
   projects/simple-cdd/trunk/   (props changed)
Log:
work on simple-cdd in my own playpen...



Added: projects/simple-cdd/trunk/CONF.sh
==============================================================================
--- (empty file)
+++ projects/simple-cdd/trunk/CONF.sh	Fri Aug  4 16:56:10 2006
@@ -0,0 +1,300 @@
+#
+# This file will have to be sourced where needed
+#
+
+# Unset all optional variables first to start from a clean state
+unset TASK              || true
+unset SIZELIMIT         || true
+unset NONUS             || true
+unset FORCENONUSONCD1   || true
+unset NONFREE           || true
+unset CONTRIB           || true
+unset EXTRANONFREE      || true
+unset LOCAL             || true
+unset LOCALDEBS         || true
+unset SECURED           || true
+unset SECURITY          || true
+unset BOOTDIR           || true
+unset BOOTDISKS         || true
+unset SYMLINK           || true
+unset COPYLINK          || true
+unset MKISOFS           || true
+unset MKISOFS_OPTS      || true
+unset ISOLINUX          || true
+unset EXCLUDE           || true
+unset SRCEXCLUDE        || true
+unset NORECOMMENDS      || true
+unset NOSUGGESTS        || true
+unset DOJIGDO           || true
+unset JIGDOCMD          || true
+unset JIGDOTEMPLATEURL  || true
+unset JIGDOFALLBACKURLS || true
+unset JIGDOINCLUDEURLS  || true
+unset JIGDOSCRIPT       || true
+unset DEFBINSIZE        || true
+unset DEFSRCSIZE        || true
+unset FASTSUMS          || true
+unset PUBLISH_URL       || true
+unset PUBLISH_NONUS_URL || true
+unset PUBLISH_PATH      || true
+unset UDEB_INCLUDE      || true
+unset UDEB_EXCLUDE      || true
+unset BASE_INCLUDE      || true
+unset BASE_EXCLUDE      || true
+unset INSTALLER_CD      || true
+unset DI_CODENAME       || true
+unset MAXCDS            || true
+unset SPLASHPNG         || true
+
+# The debian-cd dir
+# Where I am (hoping I'm in the debian-cd dir)
+export BASEDIR=/usr/share/debian-cd
+
+# Building sarge cd set ...
+export CODENAME=sarge
+
+# By default use Debian installer packages from $CODENAME
+if [ ! "$DI_CODENAME" ]
+then
+  export DI_CODENAME=$CODENAME
+fi
+
+# If set, controls where the d-i components are downloaded from.
+# This may be an url, or "default", which will make it use the default url
+# for the daily d-i builds. If not set, uses the official d-i images from
+# the Debian mirror.
+#export DI_WWW_HOME=default
+
+# Version number, "2.2 r0", "2.2 r1" etc.
+export DEBVERSION="3.1"
+
+# Official or non-official set.
+# NOTE: THE "OFFICIAL" DESIGNATION IS ONLY ALLOWED FOR IMAGES AVAILABLE
+# ON THE OFFICIAL DEBIAN CD WEBSITE http://cdimage.debian.org
+export OFFICIAL="Unofficial"
+#export OFFICIAL="Official"
+#export OFFICIAL="Official Beta"
+
+# ... for arch  
+export ARCH=`dpkg --print-installation-architecture`
+
+# IMPORTANT : The 4 following paths must be on the same partition/device.
+#	      If they aren't then you must set COPYLINK below to 1. This
+#	      takes a lot of extra room to create the sandbox for the ISO
+#	      images, however. Also, if you are using an NFS partition for
+#	      some part of this, you must use this option.
+# Paths to the mirrors
+export MIRROR=/ftp/debian
+
+# Comment the following line if you don't have/want non-US
+#export NONUS=/ftp/debian-non-US
+
+# And this option will make you 2 copies of CD1 - one with all the
+# non-US packages on it, one with none. Useful if you're likely to
+# need both.
+#export FORCENONUSONCD1=1
+
+# Path of the temporary directory
+export TDIR=/ftp/tmp
+
+# Path where the images will be written
+export OUT=/rack/debian-cd
+
+# Where we keep the temporary apt stuff.
+# This cannot reside on an NFS mount.
+export APTTMP=/ftp/tmp/apt
+
+# Do I want to have NONFREE merged in the CD set
+# export NONFREE=1
+
+# Do I want to have CONTRIB merged in the CD set
+export CONTRIB=1
+
+# Do I want to have NONFREE on a separate CD (the last CD of the CD set)
+# WARNING: Don't use NONFREE and EXTRANONFREE at the same time !
+# export EXTRANONFREE=1
+
+# If you have a $MIRROR/dists/$CODENAME/local/binary-$ARCH dir with 
+# local packages that you want to put on the CD set then
+# uncomment the following line 
+# export LOCAL=1
+
+# If your local packages are not under $MIRROR, but somewhere else, 
+# you can uncomment this line and edit to to point to a directory
+# containing dists/$CODENAME/local/binary-$ARCH
+# export LOCALDEBS=/home/joey/debian/va/debian
+
+# If you want a <codename>-secured tree with a copy of the signed
+# Release.gpg and files listed by this Release file, then
+# uncomment this line
+# export SECURED=1
+
+# Where to find the security patches.  This directory should be the
+# top directory of a security.debian.org mirror.
+#export SECURITY="$TOPDIR"/debian/debian-security
+
+# Sparc only : bootdir (location of cd.b and second.b)
+# export BOOTDIR=/boot
+
+# Symlink farmers should uncomment this line :
+# export SYMLINK=1
+
+# Use this to force copying the files instead of symlinking or hardlinking
+# them. This is useful if your destination directories are on a different
+# partition than your source files.
+# export COPYLINK=1
+
+# Options
+# export MKISOFS=/usr/bin/mkisofs
+# export MKISOFS_OPTS="-r"		#For normal users
+# export MKISOFS_OPTS="-r -F ."	#For symlink farmers
+
+# ISOLinux support for multiboot on CD1 for i386
+export ISOLINUX=1
+
+# uncomment this to if you want to see more of what the Makefile is doing
+#export VERBOSE_MAKE=1
+
+# uncoment this to make build_all.sh try to build a simple CD image if
+# the proper official CD run does not work
+#ATTEMPT_FALLBACK=yes
+
+# Set your disk size here in MB. Used in calculating package and
+# source file layouts in build.sh and build_all.sh. Defaults are for
+# CD-R, try ~4600 for DVD-R.
+export DEFBINSIZE=630
+export DEFSRCSIZE=635
+
+# We don't want certain packages to take up space on CD1...
+#export EXCLUDE="$BASEDIR"/tasks/exclude-sarge
+# ...but they are okay for other CDs (UNEXCLUDEx == may be included on CD >= x)
+#export UNEXCLUDE2="$BASEDIR"/tasks/unexclude-CD2-sarge
+# Any packages listed in EXCLUDE but not in any UNEXCLUDE will be
+# excluded completely.
+
+# We also exclude some source packages
+#export SRCEXCLUDE="$BASEDIR"/tasks/exclude-src-potato
+
+# Set this if the recommended packages should be skipped when adding 
+# package on the CD.  The default is 'false'.
+export NORECOMMENDS=1
+
+# Set this if the suggested packages should be skipped when adding 
+# package on the CD.  The default is 'true'.
+#export NOSUGGESTS=1
+
+# Produce jigdo files:
+# 0/unset = Don't do jigdo at all, produce only the full iso image.
+# 1 = Produce both the iso image and jigdo stuff.
+# 2 = Produce ONLY jigdo stuff by piping mkisofs directly into jigdo-file,
+#     no temporary iso image is created (saves lots of disk space).
+#     NOTE: The no-temp-iso will not work for (at least) alpha and powerpc
+#     since they need the actual .iso to make it bootable. For these archs,
+#     the temp-iso will be generated, but deleted again immediately after the
+#     jigdo stuff is made; needs temporary space as big as the biggest image.
+#export DOJIGDO=2
+#
+# jigdo-file command & options
+# Note: building the cache takes hours, so keep it around for the next run
+#export JIGDOCMD="/usr/local/bin/jigdo-file --cache=$HOME/jigdo-cache.db"
+#
+# HTTP/FTP URL for directory where you intend to make the templates
+# available. You should not need to change this; the default value ""
+# means "template in same dir as the .jigdo file", which is usually
+# correct. If it is non-empty, it needs a trailing slash. "%ARCH%"
+# will be substituted by the current architecture.
+#export JIGDOTEMPLATEURL=""
+#
+# Name of a directory on disc to create data for a fallback server in. 
+# Should later be made available by you at the URL given in
+# JIGDOFALLBACKURLS. In the directory, two subdirs named "Debian" and
+# "Non-US" will be created, and filled with hard links to the actual
+# files in your FTP archive. Because of the hard links, the dir must
+# be on the same partition as the FTP archive! If unset, no fallback
+# data is created, which may cause problems - see README.
+#export JIGDOFALLBACKPATH="$(OUT)/snapshot/"
+#
+# Space-separated list of label->URL mappings for "jigdo fallback
+# server(s)" to add to .jigdo file. If unset, no fallback URL is
+# added, which may cause problems - see README.
+#export JIGDOFALLBACKURLS="Debian=http://myserver/snapshot/Debian/ Non-US=http://myserver/snapshot/Non-US/"
+#
+# Space-separated list of "include URLs" to add to the .jigdo file. 
+# The included files are used to provide an up-to-date list of Debian
+# mirrors to the jigdo _GUI_application_ (_jigdo-lite_ doesn't support
+# "[Include ...]").
+export JIGDOINCLUDEURLS="http://cdimage.debian.org/debian-cd/debian-servers.jigdo"
+#
+# $JIGDOTEMPLATEURL and $JIGDOINCLUDEURLS are passed to
+# "tools/jigdo_header", which is used by default to generate the
+# [Image] and [Servers] sections of the .jigdo file. You can provide
+# your own script if you need the .jigdo file to contain different
+# data.
+#export JIGDOSCRIPT="myscript"
+
+# If set, use the md5sums from the main archive, rather than calculating
+# them locally
+#export FASTSUMS=1
+
+# A couple of things used only by publish_cds, so it can tweak the
+# jigdo files, and knows where to put the results.
+# You need to run publish_cds manually, it is not run by the Makefile.
+export PUBLISH_URL="http://cdimage.debian.org/jigdo-area"
+export PUBLISH_NONUS_URL="http://non-US.cdimage.debian.org/jigdo-area"
+export PUBLISH_PATH="/home/jigdo-area/"
+
+# Where to find the boot disks
+#export BOOTDISKS=$TOPDIR/ftp/skolelinux/boot-floppies
+
+# File with list of packages to include when fetching modules for the
+# first stage installer (debian-installer). One package per line.
+# Lines starting with '#' are comments.  The package order is
+# important, as the packages will be installed in the given order.
+#export UDEB_INCLUDE="$BASEDIR"/data/$CODENAME/udeb_include
+
+# File with list of packages to exclude as above.
+#export UDEB_EXCLUDE="$BASEDIR"/data/$CODENAME/udeb_exclude
+
+# File with list of packages to include when running debootstrap from
+# the first stage installer (currently only supported in
+# debian-installer). One package per line.  Lines starting with '#'
+# are comments.  The package order is important, as the packages will
+# be installed in the given order.
+#export BASE_INCLUDE="$BASEDIR"/data/$CODENAME/base_include
+
+# File with list of packages to exclude as above.
+#export BASE_EXCLUDE="$BASEDIR"/data/$CODENAME/base_exclude
+
+# Only put the installer onto the cd (set NORECOMMENDS,... as well).
+# INSTALLER_CD=0: nothing special (default)
+# INSTALLER_CD=1: just add debian-installer (use TASK=tasks/debian-installer)
+# INSTALLER_CD=2: add d-i and base (use TASK=tasks/debian-installer+kernel)
+#export INSTALLER_CD=0
+
+# Parameters to pass to kernel when the CD boots. Not currently supported
+# for all architectures.
+#export KERNEL_PARAMS="DEBCONF_PRIORITY=critical"
+
+# If set, limits the number of binary CDs to produce.
+#export MAXCDS=1
+
+# If set, overrides the boot picture used.
+#export SPLASHPNG="$BASEDIR/data/$CODENAME/splash-img.png"
+
+# Used by build.sh to determine what to build, this is the name of a target
+# in the Makefile. Use bin-official_images to build only binary CDs. The
+# default, official_images, builds everything.
+#IMAGETARGET=official_images
+
+export MIRROR=$simple_cdd_path/mirror
+export TDIR=$simple_cdd_path/tmp
+export OUT=$simple_cdd_path/images
+export APTTMP=$simple_cdd_path/tmp/apt
+export CONTRIB=0
+export MAXCDS=1
+# TASK should point to same file as include-task in debpartial-mirror.conf
+export TASK=$simple_cdd_path/simple-cdd-packages.list
+export INSTALLER_CD=2
+# increase the size limit if debian-cd tries to make more CDs than you
+# want, and the generated CDs are smaller than 650MB.
+export SIZELIMIT=739631360

Added: projects/simple-cdd/trunk/build-simple-cdd
==============================================================================
--- (empty file)
+++ projects/simple-cdd/trunk/build-simple-cdd	Fri Aug  4 16:56:10 2006
@@ -0,0 +1,44 @@
+#!/bin/sh
+
+# TODO add packages from commandline
+# TODO add packages from file given
+
+simple_cdd_path="~/nobackup/simple-cdd"
+
+mkdir -p "$simple_cdd_path"
+
+if [ ! -d "$simple_cdd_path" ] ; then
+  echo "ERROR: directory not found: $simple_cdd_path"
+  exit 1
+fi
+
+. CONF.sh
+
+for p in $(/usr/sbin/debootstrap --print-debs sarge) ; do
+  # FIXME make idempotent
+  echo $p >> $TASK
+done
+
+# generate the mirror
+# patched debpartial-mirror for cleaner output...
+http_proxy=http://localhost:3128 ./patched-debpartial-mirror -c debpartial-mirror.conf
+
+cd /usr/share/debian-cd
+
+echo simple-cdd: distclean
+make distclean
+
+echo simple-cdd: status
+make status
+
+echo simple-cdd: bin-list
+make bin-list
+
+echo simple-cdd: bootable
+make bootable
+
+echo simple-cdd: packages
+make packages
+
+echo simple-cdd: bin-image
+make bin-image CD=1

Added: projects/simple-cdd/trunk/debpartial-mirror.conf
==============================================================================
--- (empty file)
+++ projects/simple-cdd/trunk/debpartial-mirror.conf	Fri Aug  4 16:56:10 2006
@@ -0,0 +1,46 @@
+#
+# debpartial-mirror configuration file.
+#
+# Author: Otavio Salvador <otavio at debian.org>
+# $Id: debpartial-mirror.conf 88 2004-06-16 15:34:56Z otavio $
+
+[mirror]
+# mirror origin server
+server=http://ftp.us.debian.org/debian/
+
+# mirror destiny directory
+local_directory=/home/music/simple-cdd/mirror/
+
+# extra files list to be downloaded (this accepts regular expressions)
+#files=doc/(.*.txt)
+files=README doc/ tools/ indices/ dists/sarge/main/installer-i386/current/
+
+# should I get the suggeted packages?
+get_suggests=false
+
+# should I get the recomended packages?
+get_recomends=false
+
+# should I get the provided packages?
+get_provides=false
+
+# witch archs should I download?
+archs=i386
+
+[sarge]
+# If using debian-cd tasks, you need filter without any packages. See bellow
+#filter=main:-:-
+#include-task=/usr/share/debian-cd/tasks/debian-installer
+#exclude-task=/usr/share/debian-cd/tasks/exclude
+
+# Another filter example
+#filter=main:base:* main:*:required main:*:important main/debian-installer:*:*
+
+filter=main:*:standard main:*:required main:*:important main/debian-installer:*:*
+include-task=simple-cdd-packages.list
+
+#[unstable]
+#packages=main:apt-utils
+#exclude=main:lilo
+#filter=main/debian-installer:*:*
+

Added: projects/simple-cdd/trunk/patched-debpartial-mirror
==============================================================================
--- (empty file)
+++ projects/simple-cdd/trunk/patched-debpartial-mirror	Fri Aug  4 16:56:10 2006
@@ -0,0 +1,351 @@
+#!/usr/bin/env python
+
+# debpartial-mirror - partial debian mirror package tool
+# (c) 2004 Otavio Salvador <otavio at debian.org>, Henrique Vilela <jacare at ucpel.tche.br>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+# $Id$
+
+import getopt
+import gzip
+import os
+import re
+import sys
+import time
+import urllib
+
+sys.path.append("/usr/share/debpartial-mirror")
+
+import Config
+import LocalPackages
+import Package
+import RemotePackages
+
+class Mirror:
+    def __init__(self, cfg_file, getFiles, getPackages, Simulate = False):
+        try:
+            self.__cfg = Config.Config(cfg_file)
+
+            if not Simulate:
+                self.__getPackagesIndex()
+        except Exception, msg:
+            print msg
+            sys.exit(1)
+
+        if getFiles:
+            for filename in self.__cfg.getFiles():
+                self.__getFile(self.__cfg.getServer() + filename, self.__cfg.getLocalDirectory() + filename, True, Simulate)
+
+        if getPackages:
+            rules = {}
+            excludes = {}
+            for d in self.__cfg.getDists():
+                for s in self.__cfg.getSections(d):
+                    for f in self.__getPackagesURI(d, s, self.__cfg.getLocalDirectory()):
+                        rules[f] = self.__cfg.getFilters(d, s)
+                        excludes[f] = self.__cfg.getExcludes(d)
+
+                        if self.__cfg.getIncludeTask(d):
+                            for a in self.__cfg.getArchs():
+                                try:
+                                    for i in os.popen('cpp -I ' + os.path.dirname(self.__cfg.getIncludeTask(d)) + ' -DARCH_' + a + ' ' + self.__cfg.getIncludeTask(d) + '| grep -v \'^$\|^#.*\'', 'r').readlines():
+                                        rules[f].append({'section':'*', 'priority':'*', 'package':i[:-1]})
+                                except Exception, msg:
+                                    print msg
+                                    sys.exit(1)
+
+                        if self.__cfg.getExcludeTask(d):
+                            for a in self.__cfg.getArchs():
+                                try:
+                                    for i in os.popen('cpp -I ' + os.path.dirname(self.__cfg.getExcludeTask(d)) + ' -DARCH_' + a + ' ' + self.__cfg.getExcludeTask(d) + '| grep -v \'^$\|^#.*\'', 'r').readlines():
+                                        excludes[f].append(i[:-1])
+                                except Exception, msg:
+                                    print msg
+                                    sys.exit(1)
+
+            self.__selected = RemotePackages.RemotePackages(rules,
+                                                            excludes,
+                                                            self.__cfg.getSuggests(),
+                                                            self.__cfg.getRecomends(),
+                                                            self.__cfg.getProvides()).getSelectedPackages()
+            self.__local = LocalPackages.LocalPackages(self.__cfg.getLocalDirectory() + 'pool/').getLocalPackages()
+
+
+            remove = []
+            for local_pkg in self.__local.itervalues():
+                for local_version in local_pkg:
+                    if not self.__checkRemotePackage(local_version):
+                        remove.append(local_version)
+
+            c = 0
+            for i in remove:
+                c=c+1
+                print "\n", c, " of ", len(remove)
+                self.__removePath(i.getFilename(), Simulate);
+
+            get = []
+            for filename in self.__selected:
+                for selected_version in self.__selected[filename].itervalues():
+                    if not self.__checkLocalPackage(selected_version):
+                        get.append(selected_version)
+            c = 0
+            for i in get:
+                c=c+1
+                print c, " of ", len(get)
+                self.__getFile(self.__cfg.getServer() + i.getFilename(), self.__cfg.getLocalDirectory() + i.getFilename(), Simulate)
+
+    def __checkRemotePackage(self, local):
+        for filename in self.__selected:
+            if self.__selected[filename].has_key(local.getName()):
+                if self.__selected[filename][local.getName()].getMD5Sum() == local.getMD5Sum():
+                    return True
+        return False
+
+    def __checkLocalPackage(self, remote):
+        for local_pkg in self.__local.itervalues():
+            if self.__local.has_key(remote.getName()):
+                for local_version in local_pkg:
+                    if local_version.getMD5Sum() == remote.getMD5Sum():
+                        return True
+        return False
+
+    def __getPackagesURI(self, dist, section, where, append=""):
+        files = []
+
+        for arch in self.__cfg.getArchs():
+            files.append(where + 'dists/' + dist + '/' + section + '/binary-' + arch + '/Packages' + append)
+
+        return files
+    
+    def __getPackagesIndex(self):
+        for dist in self.__cfg.getDists().keys():
+            self.__getFile(self.__cfg.getServer() + "dists/" + dist + "/Release",
+                           self.__cfg.getLocalDirectory() + "dists/" + dist + "/Release",
+                           True);
+            
+            self.__getFile(self.__cfg.getServer() + "dists/" + dist + "/Release.gpg",
+                           self.__cfg.getLocalDirectory() + "dists/" + dist + "/Release.gpg",
+                           True);
+            
+            for section in self.__cfg.getSections(dist).keys():
+                for arch in self.__cfg.getArchs():
+                    self.__getFile(self.__cfg.getServer() + "dists/" + dist + "/" + section + "/binary-" + arch + "/Release",
+                                   self.__cfg.getLocalDirectory() + "dists/" + dist + "/" + section + "/binary-" + arch + "/Release",
+                                   True);
+
+                    self.__getFile(self.__cfg.getServer() + "dists/" + dist + "/Contents-" + arch + ".gz",
+                                   self.__cfg.getLocalDirectory() + "dists/" + dist + "/Contents-" + arch + ".gz",
+                                   True);
+
+                for package in self.__getPackagesURI(dist, section, '', '.gz'):
+                    origin =  self.__cfg.getServer() + package
+                    destiny = self.__cfg.getLocalDirectory() + package
+                    if self.__getFile(origin, destiny, True):
+                        self.__uncompressFile(destiny)
+
+    def __removePath(self, filename, Simulate=False):
+        if os.path.isdir(filename):
+            files = os.listdir(filename)
+            if not len(files):
+                print "Removing " + filename
+                if not Simulate:
+                    os.rmdir(filename)
+                    matches = re.compile('(.*)/.*').findall(filename);
+                    if matches:
+                        self.__removePath(matches[0])
+        else:
+            print "Removing " + filename
+            if not Simulate:
+                os.unlink(filename)
+                self.__removePath(os.path.dirname(filename))
+
+    def __getFile(self, origin, destiny, checkNew = False, Simulate = False):
+        matches = re.compile('(.*)\((.*)\)', re.IGNORECASE | re.MULTILINE ).findall(origin)
+        if matches:
+            origin=matches[0][0]
+
+        expression=""
+        matches = re.compile('(.*)\((.*)\)', re.IGNORECASE | re.MULTILINE ).findall(destiny)
+        if matches:
+            destiny=matches[0][0]
+            expression=matches[0][1]
+        
+        self.__createPath(destiny)
+
+        existSize = -1
+        if os.path.isfile(destiny):
+            existSize = os.path.getsize(destiny)
+
+        webPage = urllib.urlopen(origin)
+
+        #If the file exists, but we already have the whole thing, don't download again
+        if checkNew and webPage.headers.has_key('content-length') and int(webPage.headers['content-length']) == existSize:
+            if webPage.headers.has_key('Last-Modified') and int(time.mktime(time.strptime(webPage.headers['Last-Modified'], "%a, %d %b %Y %H:%M:%S %Z"))) < (os.path.getmtime(destiny) + time.altzone):
+                print 'Match:', destiny
+                webPage.close()
+                return False
+
+        if not Simulate:
+            # Get the file
+            content = ""
+            if origin[-1] == '/':
+                directory = True
+            else:
+                directory = False
+
+            if not directory and webPage.headers.has_key('Content-Length'):
+                content_length = int(webPage.headers['content-length'])
+
+                numBytes = 0
+                theline = "Getting " + origin + "\n"
+                sys.stdout.write(theline)
+                while numBytes < content_length:
+                    line = "... %d%%" % (numBytes * 100 / content_length)
+                    sys.stdout.write(line + '\r')
+
+                    data = webPage.read(8 * 1024)
+                    if not data:
+                        break
+                    content += data
+                    numBytes = numBytes + len(data)
+
+                sys.stdout.write("Done " + theline)
+            else:
+                if directory:
+                    content = webPage.read()
+                else:
+                    print "Error: " + origin + " not exists."
+                    webPage.close()
+                    return False;
+
+            webPage.close()
+
+            if directory:
+                matches = re.compile('<a href="([a-zA-Z0-9_][a-zA-Z0-9\-\./_]+)">', re.IGNORECASE | re.MULTILINE ).findall(content)
+                if matches:
+                    for filename in matches:
+                        if re.match(expression, filename):
+                            self.__getFile(origin + filename, destiny + filename, True, Simulate)
+                        else:
+                            print "Filed ", filename
+            else:
+                try:
+                    outputFile = open(destiny, "wb")
+                    outputFile.write(content)
+                    outputFile.close()
+                except IOError, msg:
+                    print msg
+                    sys.exit(1)
+
+        return True
+
+    def __uncompressFile(self, filename):
+        print 'Uncompressing', filename
+        # uncompress the file
+        compressedFile = gzip.GzipFile(filename, 'rb')
+        try:
+            outputFile = open(filename.split('.gz')[0], "wb")
+        except IOError, msg:
+            print msg
+            sys.exit(1)
+
+        numBytes = 0
+        while True:
+            data = compressedFile.read(64 * 1024)
+            if not data:
+                break
+            outputFile.write(data)
+            numBytes = numBytes + len(data)
+
+        compressedFile.close()
+        outputFile.close()
+        return True
+        
+    def __createPath(self, path):
+        dir_name = os.path.dirname(path)
+        if not os.path.exists(dir_name):
+            print "Making directory " + dir_name + "..."
+            os.makedirs(dir_name)
+
+# Main function, no further comment needed. :)
+def main():
+    try:
+        opts, args = getopt.getopt(sys.argv[1:], 'hvs:c:', ["help",
+                                                            "version",
+                                                            "skip-packages",
+                                                            "skip-files",
+                                                            "simulate",
+                                                            "configfile="])
+    except getopt.GetoptError:
+        print "ERROR"
+        usage()
+
+    configurefile = '/etc/debpartial-mirror.conf'
+
+    getFiles = True
+    getPackages = True
+    Simulate = False
+
+    for o, a in opts:
+        if o in ("-h", "--help"):
+            usage()
+            sys.exit()
+            
+        if o in ("-v", "--version"):
+            version()
+            sys.exit()
+            
+        if o in ("-c", "--configfile"):
+            if a == '':
+                usage()
+            configurefile = a
+
+        if o == "-s" or o in ("--skip-files",
+                              "--skip-packages",
+                              "--simulate"):
+            if o == "--skip-files" or a == "f":
+                getFiles = False
+
+            if o == "--skip-packages" or a == "p":
+                getPackages = False
+                
+            if o == "--simulate" or a == "":
+                Simulate = True
+
+    version()
+    mirror = Mirror(configurefile, getFiles, getPackages, Simulate)
+
+def version():
+    print "debpartial-mirror 0.2.8 - Partial mirroring tool for Debian - Fri,  2 Jul 2004 10:31:10 -0300"
+    print "(c) 2004 Otavio Salvador <otavio at debian.org>, Henrique Vilela <jacare at ucpel.tche.br>"
+    print "This program is free software and was released under the terms of the GNU General Public License"
+    print
+
+def usage():
+    print "Usage: debpartial-mirros [OPTION]"
+    print
+    print "-h --help\t\t\tDisplay this help end exit"
+    print "-c<file> --configfile=<file>\tSelect a config file"
+    print "-v --version\t\t\tShow the version"
+    print
+    sys.exit(2)
+
+    
+# Main
+if __name__ == '__main__':
+    try:
+        main()
+    except KeyboardInterrupt:
+        print "exiting due to user interrupt."

Added: projects/simple-cdd/trunk/simple-cdd-packages.list
==============================================================================
--- (empty file)
+++ projects/simple-cdd/trunk/simple-cdd-packages.list	Fri Aug  4 16:56:10 2006
@@ -0,0 +1,4 @@
+#include </usr/share/debian-cd/tasks/debian-installer+kernel>
+#include </usr/share/debian-cd/tasks/debian-installer>
+#include </usr/share/debian-cd/tasks/base-sarge>
+lessdisks



More information about the Cdd-commits mailing list