[clbuild-devel] [PATCH RFC] get_tarball: store contents in a darcs repository (Was: Simplify test...)

Daniel White daniel at whitehouse.id.au
Sat Oct 25 13:56:19 UTC 2008


On Fri, 24 Oct 2008 11:29:19 -0700
Albert Krewinkel <krewinkel at gmx.net> wrote:
> 
> On Oct 24, 2008, at 10:12 AM, Daniel White wrote:
> > There is an odd test in the method below:
> > [...]
> > I can't seem to find any sane reason that we'd want to get a list of
> > all possible directories that happen to start with $name rather than
> > just test for a directory $name.
> 
> Image a package distributed by tarballs.  More often than not, folder  
> names created from those tarballs contain a version number (like hello- 
> world-8.12.23 or foo-20081023).  Therefore, checking for directories  
> which start with $name does make sense.  However, a specific test for  
> version numbers after the name would be a better solution (who's up to  
> writing one?)
> [...]

This isn't quite with any of the tarballs at the moment, but it is
certainly a possibility.  I think I might be able to do one better than
just testing for version numbers.

The following patch probably has some stupid corner cases at the
moment, so I'll put it up for review.  Basically it establishes a darcs
repository for tarballs and each time the contents changes adds the
changes as a darcs patch.

I've included the methods below just so you can rip it to shreds here
if you so need, but the patch is also attached.

darcs_record_import() {
    local name="$1"
    local url="$2"

    IMPORT_MESSAGE="Imported $name from $url on $(date)"

    darcs record -a -l -A clbuild -m "$IMPORT_MESSAGE"
}

get_tarball() {
    local name="$1"
    local url="$2"
    local flags="${3:-z}"

    if [ -d $name ]; then
	dry_run_ok $name
    else
	dry_run_missing $name
    fi
    if [ -n "$dry_run" ]; then
	exit 0
    fi

    # if repository does not exist, then create empty one
    if [ ! -d $name ]; then
	(
	    mkdir $name
	    cd $name
	    darcs init
	    darcs_record_import $name $url
	    )
    fi

    # pull repository into temporary directory
    dribble_get "wget" $name
    (
	local tmp="${name}.tar.gz"

	cd $TMPDIR

	# clone the original directory
	darcs get "${source_dir}/${name}"

	wget \
	    --no-check-certificate \
	    --progress=dot \
	    -O "$tmp" \
	    $url \
	    2>&1 | tail_last
	tar v${flags}xf "$tmp" | tail_last
	rm $tmp

	# if directory names differ, copy into main directory
	local other_dir=$(echo ${name}?*/ | awk '{print $1}')
	if [ -d $other_dir ]; then
	    cp -R $other_dir $name
	fi
	)

    # record any changes and pull back into original directory
    (
	cd $TMPDIR/$name
	darcs_record_import $name $url
	darcs push -a -p "$IMPORT_MESSAGE" "$source_dir/$name"
	)
}

-- 
Daniel White
-------------- next part --------------
A non-text attachment was scrubbed...
Name: get_tarball_-store-contents-in-a-darcs-repository.dpatch
Type: application/octet-stream
Size: 25211 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/clbuild-devel/attachments/20081025/d2431ac0/attachment.obj>


More information about the clbuild-devel mailing list