Changeset 18320 for trunk/base


Ignore:
Timestamp:
Jun 10, 2006, 8:07:40 AM (14 years ago)
Author:
pguyot (Paul Guyot)
Message:

Save the list of mirrored files in a database.
(this can be used to no longer mirror old files).

Location:
trunk/base/src/port1.0
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/base/src/port1.0/portfetch.tcl

    r18084 r18320  
    11# et:ts=4
    22# portfetch.tcl
    3 # $Id: portfetch.tcl,v 1.110 2006/05/24 00:42:56 pguyot Exp $
     3# $Id: portfetch.tcl,v 1.111 2006/06/10 08:07:40 pguyot Exp $
    44#
    55# Copyright (c) 2002 - 2003 Apple Computer, Inc.
     
    431431}
    432432
     433# Utility function to add files to a list of fetched files.
     434proc fetch_addfilestomap {filemapname} {
     435        global distpath fetch_urls $filemapname
     436        foreach {url_var distfile} $fetch_urls {
     437                if {[file isfile $distpath/$distfile]} {
     438                        filemap set $filemapname $distpath/$distfile 1
     439                }
     440        }
     441}
     442
    433443# Initialize fetch target, calling checkfiles if neccesary
    434444proc fetch_init {args} {
  • trunk/base/src/port1.0/portmirror.tcl

    r18084 r18320  
    22# portmirror.tcl
    33#
    4 # $Id: portmirror.tcl,v 1.1 2006/05/24 00:42:56 pguyot Exp $
     4# $Id: portmirror.tcl,v 1.2 2006/06/10 08:07:40 pguyot Exp $
    55#
    66# Copyright (c) 2006 Paul Guyot <pguyot@kallisys.net>,
     
    3535package provide portmirror 1.0
    3636package require portutil 1.0
     37package require Pextlib 1.0
    3738package require portfetch 1.0
    3839package require portchecksum 1.0
     
    4748# Mirror is a target that fetches & checksums files and delete them
    4849# if the checksum isn't correct.
     50# It also records the path in a database.
    4951
    5052proc mirror_main {args} {
    51         global fetch.type portname
     53        global fetch.type portname mirror_filemap ports_mirror_new portdbpath
    5254       
     55        set mirror_filemap_path [file join $portdbpath distfiles_mirror.db]
     56        if {![info exists mirror_filemap]
     57                && [info exists ports_mirror_new]
     58                && $ports_mirror_new == "yes"
     59                && [file exists $mirror_filemap_path]} {
     60                # Trash the map file if it existed.
     61                file delete -force $mirror_filemap_path
     62        }
     63       
     64        filemap open mirror_filemap $mirror_filemap_path
     65
    5366        # Check the distfiles if it's a regular fetch phase.
    5467        if {"${fetch.type}" == "standard"} {
    5568                # fetch the files.
    5669                fetch_init $args
    57                 #fetch_start $args
     70                #fetch_start
    5871                fetch_main $args
    5972
    6073                # checksum the files.
    61                 #checksum_start $args
     74                #checksum_start
    6275                if {[catch {checksum_main $args}]} {
    6376                        # delete the files.
    6477                        fetch_deletefiles $args
     78                } else {
     79                        # add the list of files.
     80                        fetch_addfilestomap mirror_filemap
    6581                }
    6682        }
     83
     84        # close the filemap.
     85        filemap close mirror_filemap
    6786}
Note: See TracChangeset for help on using the changeset viewer.