From a7f8b1b63a97c66aea6f39342313d7a5b919cfa7 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Fri, 21 Sep 2012 17:13:04 +0100 Subject: Fix up Lorry to expect repositories to be bare. This patch makes Lorry always create bare repositories where it can (Note that it cannot for CVS imports) and to create tarballs of bare repositories (if not disabled) which will be more efficient than bundles for creation and cloning. We may be able to disable bundles later. --- README | 14 +-- import-tars.perl | 189 ------------------------------------ lorry | 92 ++++++++++++------ lorry.tar-importer | 205 +++++++++++++++++++++++++++++++++++++++ setup.py | 5 +- test-lorry | 3 + tests/bzr-single-commit.script | 2 +- tests/cvs-single-commit.script | 2 +- tests/git-backup-on-error.script | 5 +- tests/git-backup-on-error.stdout | 38 +------- tests/git-single-commit.script | 2 +- tests/hg-single-commit.script | 2 +- tests/make-tarball.script | 32 ++++++ tests/make-tarball.setup | 59 +++++++++++ tests/no-pushspec-pushall.script | 2 +- tests/pushspecs-only.script | 2 +- tests/svn-single-commit.script | 2 +- tests/tar-single-commit.script | 6 +- tests/tar-single-commit.setup | 5 +- tests/tar-single-commit.stdout | 9 +- 20 files changed, 399 insertions(+), 277 deletions(-) delete mode 100644 import-tars.perl create mode 100755 lorry.tar-importer create mode 100755 test-lorry create mode 100755 tests/make-tarball.script create mode 100755 tests/make-tarball.setup diff --git a/README b/README index 45b803a..a1355a4 100644 --- a/README +++ b/README @@ -5,9 +5,9 @@ Lorry is a tool to take upstream source code (in various formats, though preferably in version control) and converts it into a git repository. -If you want to try this, use `--pull-only` and/or `--gitorious-base-url` +If you want to try this, use `--pull-only` and/or `--mirror-base-url-push` so that you do not accidentally overwrite important stuff for Baserock. -(If you don't have direct commit access to Baserock on Gitorious.org, +(If you don't have direct commit access to Baserock on git.baserock.org then you're not dangerous.) See the manual page for instructions on using. @@ -25,8 +25,8 @@ You can find a lot of lorries to crib ideas from at: Implementation -------------- -Lorry relies on git-svn, git-cvsimport, and bzr fast-export for the -conversions. You need to have them installed. +Lorry relies on git-svn, git-cvsimport, hg-fast-export, perl (for tarballs) and +bzr fast-export for the conversions. You need to have them installed. Lorry file specification ------------------------ @@ -193,12 +193,14 @@ often have the folder name as the first component. } } -NOTE: tarball imports are unlikely to give the same sha. +NOTE: tarball imports are unlikely to give the same commit SHA1 but the tree +SHA1 inside (which is what is used for artifact cache IDs) should remain +stable. Legal stuff ----------- -Copyright (C) 2011 Codethink Limited +Copyright (C) 2011, 2012 Codethink Limited 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 diff --git a/import-tars.perl b/import-tars.perl deleted file mode 100644 index 95438e1..0000000 --- a/import-tars.perl +++ /dev/null @@ -1,189 +0,0 @@ -#!/usr/bin/perl - -## tar archive frontend for git-fast-import -## -## For example: -## -## mkdir project; cd project; git init -## perl import-tars.perl *.tar.bz2 -## git whatchanged import-tars -## -## Use --metainfo to specify the extension for a meta data file, where -## import-tars can read the commit message and optionally author and -## committer information. -## -## echo 'This is the commit message' > myfile.tar.bz2.msg -## perl import-tars.perl --metainfo=msg myfile.tar.bz2 - -use strict; -use Getopt::Long; - -my $metaext = ''; - -die "usage: import-tars [--metainfo=extension] *.tar.{gz,bz2,lzma,xz,Z}\n" - unless GetOptions('metainfo=s' => \$metaext) && @ARGV; - -my $branch_name = 'import-tars'; -my $branch_ref = "refs/heads/$branch_name"; -my $author_name = $ENV{'GIT_AUTHOR_NAME'} || 'T Ar Creator'; -my $author_email = $ENV{'GIT_AUTHOR_EMAIL'} || 'tar@example.com'; -my $committer_name = $ENV{'GIT_COMMITTER_NAME'} || `git config --get user.name`; -my $committer_email = $ENV{'GIT_COMMITTER_EMAIL'} || `git config --get user.email`; - -chomp($committer_name, $committer_email); - -open(FI, '|-', 'git', 'fast-import', '--quiet') - or die "Unable to start git fast-import: $!\n"; -foreach my $tar_file (@ARGV) -{ - my $commit_time = time; - $tar_file =~ m,([^/]+)$,; - my $tar_name = $1; - - if ($tar_name =~ s/\.(tar\.gz|tgz)$//) { - open(I, '-|', 'gunzip', '-c', $tar_file) - or die "Unable to gunzip -c $tar_file: $!\n"; - } elsif ($tar_name =~ s/\.(tar\.bz2|tbz2)$//) { - open(I, '-|', 'bunzip2', '-c', $tar_file) - or die "Unable to bunzip2 -c $tar_file: $!\n"; - } elsif ($tar_name =~ s/\.tar\.Z$//) { - open(I, '-|', 'uncompress', '-c', $tar_file) - or die "Unable to uncompress -c $tar_file: $!\n"; - } elsif ($tar_name =~ s/\.(tar\.(lzma|xz)|(tlz|txz))$//) { - open(I, '-|', 'xz', '-dc', $tar_file) - or die "Unable to xz -dc $tar_file: $!\n"; - } elsif ($tar_name =~ s/\.tar$//) { - open(I, $tar_file) or die "Unable to open $tar_file: $!\n"; - } else { - die "Unrecognized compression format: $tar_file\n"; - } - - my $author_time = 0; - my $next_mark = 1; - my $have_top_dir = 1; - my ($top_dir, %files); - - while (read(I, $_, 512) == 512) { - my ($name, $mode, $uid, $gid, $size, $mtime, - $chksum, $typeflag, $linkname, $magic, - $version, $uname, $gname, $devmajor, $devminor, - $prefix) = unpack 'Z100 Z8 Z8 Z8 Z12 Z12 - Z8 Z1 Z100 Z6 - Z2 Z32 Z32 Z8 Z8 Z*', $_; - last unless length($name); - if ($name eq '././@LongLink') { - # GNU tar extension - if (read(I, $_, 512) != 512) { - die ('Short archive'); - } - $name = unpack 'Z257', $_; - next unless $name; - - my $dummy; - if (read(I, $_, 512) != 512) { - die ('Short archive'); - } - ($dummy, $mode, $uid, $gid, $size, $mtime, - $chksum, $typeflag, $linkname, $magic, - $version, $uname, $gname, $devmajor, $devminor, - $prefix) = unpack 'Z100 Z8 Z8 Z8 Z12 Z12 - Z8 Z1 Z100 Z6 - Z2 Z32 Z32 Z8 Z8 Z*', $_; - } - next if $name =~ m{/\z}; - $mode = oct $mode; - $size = oct $size; - $mtime = oct $mtime; - next if $typeflag == 5; # directory - - print FI "blob\n", "mark :$next_mark\n"; - if ($typeflag == 2) { # symbolic link - print FI "data ", length($linkname), "\n", $linkname; - $mode = 0120000; - } else { - print FI "data $size\n"; - while ($size > 0 && read(I, $_, 512) == 512) { - print FI substr($_, 0, $size); - $size -= 512; - } - } - print FI "\n"; - - my $path; - if ($prefix) { - $path = "$prefix/$name"; - } else { - $path = "$name"; - } - $files{$path} = [$next_mark++, $mode]; - - $author_time = $mtime if $mtime > $author_time; - $path =~ m,^([^/]+)/,; - $top_dir = $1 unless $top_dir; - $have_top_dir = 0 if $top_dir ne $1; - } - - my $commit_msg = "Imported from $tar_file."; - my $this_committer_name = $committer_name; - my $this_committer_email = $committer_email; - my $this_author_name = $author_name; - my $this_author_email = $author_email; - if ($metaext ne '') { - # Optionally read a commit message from .msg - # Add a line on the form "Committer: name " to override - # the committer and "Author: name " to override the - # author for this tar ball. - if (open MSG, '<', "${tar_file}.${metaext}") { - my $header_done = 0; - $commit_msg = ''; - while () { - if (!$header_done && /^Committer:\s+([^<>]*)\s+<(.*)>\s*$/i) { - $this_committer_name = $1; - $this_committer_email = $2; - } elsif (!$header_done && /^Author:\s+([^<>]*)\s+<(.*)>\s*$/i) { - $this_author_name = $1; - $this_author_email = $2; - } elsif (!$header_done && /^$/) { # empty line ends header. - $header_done = 1; - } else { - $commit_msg .= $_; - $header_done = 1; - } - } - close MSG; - } - } - - print FI < $author_time +0000 -committer $this_committer_name <$this_committer_email> $commit_time +0000 -data < $author_time +0000 -data < myfile.tar.bz2.msg +## perl import-tars.perl --metainfo=msg myfile.tar.bz2 + +use strict; +use Getopt::Long; + +my $metaext = ''; + +die "usage: import-tars [--metainfo=extension] *.tar.{gz,bz2,lzma,xz,Z}\n" + unless GetOptions('metainfo=s' => \$metaext) && @ARGV; + +my $branch_name = 'master'; +my $branch_ref = "refs/heads/$branch_name"; +my $old_sha = `git show-ref $branch_ref 2>/dev/null`; +my $author_name = $ENV{'GIT_AUTHOR_NAME'} || 'Lorry Tar Creator'; +my $author_email = $ENV{'GIT_AUTHOR_EMAIL'} || 'lorry-tar-importer@baserock.org'; +my $committer_name = $ENV{'GIT_COMMITTER_NAME'} || `git config --get user.name`; +my $committer_email = $ENV{'GIT_COMMITTER_EMAIL'} || `git config --get user.email`; + +chomp($committer_name, $committer_email, $old_sha); + +if ($old_sha ne '') { + $old_sha = ($old_sha =~ /^([a-f0-9]+)/)[0]; +} +open(FI, '|-', 'git', 'fast-import', '--quiet') + or die "Unable to start git fast-import: $!\n"; +foreach my $tar_file (@ARGV) +{ + my $commit_time = time; + $tar_file =~ m,([^/]+)$,; + my $tar_name = $1; + + if ($tar_name =~ s/\.(tar\.gz|tgz)$//) { + open(I, '-|', 'gunzip', '-c', $tar_file) + or die "Unable to gunzip -c $tar_file: $!\n"; + } elsif ($tar_name =~ s/\.(tar\.bz2|tbz2)$//) { + open(I, '-|', 'bunzip2', '-c', $tar_file) + or die "Unable to bunzip2 -c $tar_file: $!\n"; + } elsif ($tar_name =~ s/\.tar\.Z$//) { + open(I, '-|', 'uncompress', '-c', $tar_file) + or die "Unable to uncompress -c $tar_file: $!\n"; + } elsif ($tar_name =~ s/\.(tar\.(lzma|xz)|(tlz|txz))$//) { + open(I, '-|', 'xz', '-dc', $tar_file) + or die "Unable to xz -dc $tar_file: $!\n"; + } elsif ($tar_name =~ s/\.tar$//) { + open(I, $tar_file) or die "Unable to open $tar_file: $!\n"; + } else { + die "Unrecognized compression format: $tar_file\n"; + } + + my $author_time = 0; + my $next_mark = 1; + my $have_top_dir = 1; + my ($top_dir, %files); + + while (read(I, $_, 512) == 512) { + my ($name, $mode, $uid, $gid, $size, $mtime, + $chksum, $typeflag, $linkname, $magic, + $version, $uname, $gname, $devmajor, $devminor, + $prefix) = unpack 'Z100 Z8 Z8 Z8 Z12 Z12 + Z8 Z1 Z100 Z6 + Z2 Z32 Z32 Z8 Z8 Z*', $_; + last unless length($name); + if ($name eq '././@LongLink') { + # GNU tar extension + if (read(I, $_, 512) != 512) { + die ('Short archive'); + } + $name = unpack 'Z257', $_; + next unless $name; + + my $dummy; + if (read(I, $_, 512) != 512) { + die ('Short archive'); + } + ($dummy, $mode, $uid, $gid, $size, $mtime, + $chksum, $typeflag, $linkname, $magic, + $version, $uname, $gname, $devmajor, $devminor, + $prefix) = unpack 'Z100 Z8 Z8 Z8 Z12 Z12 + Z8 Z1 Z100 Z6 + Z2 Z32 Z32 Z8 Z8 Z*', $_; + } + next if $name =~ m{/\z}; + $mode = oct $mode; + $size = oct $size; + $mtime = oct $mtime; + next if $typeflag == 5; # directory + + print FI "blob\n", "mark :$next_mark\n"; + if ($typeflag == 2) { # symbolic link + print FI "data ", length($linkname), "\n", $linkname; + $mode = 0120000; + } else { + print FI "data $size\n"; + while ($size > 0 && read(I, $_, 512) == 512) { + print FI substr($_, 0, $size); + $size -= 512; + } + } + print FI "\n"; + + my $path; + if ($prefix) { + $path = "$prefix/$name"; + } else { + $path = "$name"; + } + $files{$path} = [$next_mark++, $mode]; + + $author_time = $mtime if $mtime > $author_time; + $path =~ m,^([^/]+)/,; + $top_dir = $1 unless $top_dir; + $have_top_dir = 0 if $top_dir ne $1; + } + + my $commit_msg = "Imported from $tar_file."; + my $this_committer_name = $committer_name; + my $this_committer_email = $committer_email; + my $this_author_name = $author_name; + my $this_author_email = $author_email; + if ($metaext ne '') { + # Optionally read a commit message from .msg + # Add a line on the form "Committer: name " to override + # the committer and "Author: name " to override the + # author for this tar ball. + if (open MSG, '<', "${tar_file}.${metaext}") { + my $header_done = 0; + $commit_msg = ''; + while () { + if (!$header_done && /^Committer:\s+([^<>]*)\s+<(.*)>\s*$/i) { + $this_committer_name = $1; + $this_committer_email = $2; + } elsif (!$header_done && /^Author:\s+([^<>]*)\s+<(.*)>\s*$/i) { + $this_author_name = $1; + $this_author_email = $2; + } elsif (!$header_done && /^$/) { # empty line ends header. + $header_done = 1; + } else { + $commit_msg .= $_; + $header_done = 1; + } + } + close MSG; + } + } + + print FI < $author_time +0000 +committer $this_committer_name <$this_committer_email> $commit_time +0000 +data < $author_time +0000 +data < /dev/null 2> /dev/null # verify that the git repository was set up correctly diff --git a/tests/cvs-single-commit.script b/tests/cvs-single-commit.script index ad4eca8..e133fae 100755 --- a/tests/cvs-single-commit.script +++ b/tests/cvs-single-commit.script @@ -28,7 +28,7 @@ export USER=root export LOGNAME=$USER export USERNAME=$USER -./lorry --pull-only --log="$logfile" --working-area="$workdir" \ +${SRCDIR}/test-lorry --pull-only --log="$logfile" --working-area="$workdir" \ "$DATADIR/cvs-test-repo.lorry" > /dev/null 2> /dev/null # verify that the git repository was created successfully diff --git a/tests/git-backup-on-error.script b/tests/git-backup-on-error.script index 134367c..8be1a83 100755 --- a/tests/git-backup-on-error.script +++ b/tests/git-backup-on-error.script @@ -30,16 +30,17 @@ normalize() { DATETIMESPEC='[0-9]*-[0-9]*-[0-9]*-[0-9]*:[0-9]*:[0-9]*' sed -r -e "s|git-pre-update-$DATETIMESPEC|git-pre-update-DATETIME|g" \ -e "s|git-post-fail-$DATETIMESPEC|git-post-fail-DATETIME|g" \ + -e '/hooks\/.*\.sample/d' \ -e "s|$DATADIR|DATADIR|g" "$@" } # mirror some history -./lorry --pull-only --log="$logfile" --working-area="$workdir" --bundle=never \ +${SRCDIR}/test-lorry --pull-only --log="$logfile" --working-area="$workdir" --bundle=never \ "$DATADIR/git-backup-test-repo.lorry" | normalize # make upstream disappear to cause errors rm -rf "$repo" -if ./lorry --pull-only --log="$logfile" --working-area="$workdir" \ +if ${SRCDIR}/test-lorry --pull-only --log="$logfile" --working-area="$workdir" \ "$DATADIR/git-backup-test-repo.lorry" --bundle=never 2>/dev/null | \ normalize then diff --git a/tests/git-backup-on-error.stdout b/tests/git-backup-on-error.stdout index 195970e..7e18431 100644 --- a/tests/git-backup-on-error.stdout +++ b/tests/git-backup-on-error.stdout @@ -8,68 +8,40 @@ DATADIR/work-dir/git-backup-test-repo/git-post-fail-DATETIME/branches DATADIR/work-dir/git-backup-test-repo/git-post-fail-DATETIME/config DATADIR/work-dir/git-backup-test-repo/git-post-fail-DATETIME/description DATADIR/work-dir/git-backup-test-repo/git-post-fail-DATETIME/hooks -DATADIR/work-dir/git-backup-test-repo/git-post-fail-DATETIME/hooks/applypatch-msg.sample -DATADIR/work-dir/git-backup-test-repo/git-post-fail-DATETIME/hooks/commit-msg.sample -DATADIR/work-dir/git-backup-test-repo/git-post-fail-DATETIME/hooks/post-commit.sample -DATADIR/work-dir/git-backup-test-repo/git-post-fail-DATETIME/hooks/post-receive.sample -DATADIR/work-dir/git-backup-test-repo/git-post-fail-DATETIME/hooks/post-update.sample -DATADIR/work-dir/git-backup-test-repo/git-post-fail-DATETIME/hooks/pre-applypatch.sample -DATADIR/work-dir/git-backup-test-repo/git-post-fail-DATETIME/hooks/pre-commit.sample -DATADIR/work-dir/git-backup-test-repo/git-post-fail-DATETIME/hooks/pre-rebase.sample -DATADIR/work-dir/git-backup-test-repo/git-post-fail-DATETIME/hooks/prepare-commit-msg.sample -DATADIR/work-dir/git-backup-test-repo/git-post-fail-DATETIME/hooks/update.sample DATADIR/work-dir/git-backup-test-repo/git-post-fail-DATETIME/info DATADIR/work-dir/git-backup-test-repo/git-post-fail-DATETIME/info/exclude DATADIR/work-dir/git-backup-test-repo/git-post-fail-DATETIME/info/refs DATADIR/work-dir/git-backup-test-repo/git-post-fail-DATETIME/objects -DATADIR/work-dir/git-backup-test-repo/git-post-fail-DATETIME/packed-refs DATADIR/work-dir/git-backup-test-repo/git-post-fail-DATETIME/refs DATADIR/work-dir/git-backup-test-repo/git-post-fail-DATETIME/refs/heads +DATADIR/work-dir/git-backup-test-repo/git-post-fail-DATETIME/refs/heads/master DATADIR/work-dir/git-backup-test-repo/git-post-fail-DATETIME/refs/tags DATADIR/work-dir/git-backup-test-repo/git-pre-update-DATETIME +DATADIR/work-dir/git-backup-test-repo/git-pre-update-DATETIME/FETCH_HEAD DATADIR/work-dir/git-backup-test-repo/git-pre-update-DATETIME/HEAD DATADIR/work-dir/git-backup-test-repo/git-pre-update-DATETIME/branches DATADIR/work-dir/git-backup-test-repo/git-pre-update-DATETIME/config DATADIR/work-dir/git-backup-test-repo/git-pre-update-DATETIME/description DATADIR/work-dir/git-backup-test-repo/git-pre-update-DATETIME/hooks -DATADIR/work-dir/git-backup-test-repo/git-pre-update-DATETIME/hooks/applypatch-msg.sample -DATADIR/work-dir/git-backup-test-repo/git-pre-update-DATETIME/hooks/commit-msg.sample -DATADIR/work-dir/git-backup-test-repo/git-pre-update-DATETIME/hooks/post-commit.sample -DATADIR/work-dir/git-backup-test-repo/git-pre-update-DATETIME/hooks/post-receive.sample -DATADIR/work-dir/git-backup-test-repo/git-pre-update-DATETIME/hooks/post-update.sample -DATADIR/work-dir/git-backup-test-repo/git-pre-update-DATETIME/hooks/pre-applypatch.sample -DATADIR/work-dir/git-backup-test-repo/git-pre-update-DATETIME/hooks/pre-commit.sample -DATADIR/work-dir/git-backup-test-repo/git-pre-update-DATETIME/hooks/pre-rebase.sample -DATADIR/work-dir/git-backup-test-repo/git-pre-update-DATETIME/hooks/prepare-commit-msg.sample -DATADIR/work-dir/git-backup-test-repo/git-pre-update-DATETIME/hooks/update.sample DATADIR/work-dir/git-backup-test-repo/git-pre-update-DATETIME/info DATADIR/work-dir/git-backup-test-repo/git-pre-update-DATETIME/info/exclude DATADIR/work-dir/git-backup-test-repo/git-pre-update-DATETIME/info/refs DATADIR/work-dir/git-backup-test-repo/git-pre-update-DATETIME/objects -DATADIR/work-dir/git-backup-test-repo/git-pre-update-DATETIME/packed-refs DATADIR/work-dir/git-backup-test-repo/git-pre-update-DATETIME/refs DATADIR/work-dir/git-backup-test-repo/git-pre-update-DATETIME/refs/heads +DATADIR/work-dir/git-backup-test-repo/git-pre-update-DATETIME/refs/heads/master DATADIR/work-dir/git-backup-test-repo/git-pre-update-DATETIME/refs/tags +DATADIR/work-dir/git-backup-test-repo/git/FETCH_HEAD DATADIR/work-dir/git-backup-test-repo/git/HEAD DATADIR/work-dir/git-backup-test-repo/git/branches DATADIR/work-dir/git-backup-test-repo/git/config DATADIR/work-dir/git-backup-test-repo/git/description DATADIR/work-dir/git-backup-test-repo/git/hooks -DATADIR/work-dir/git-backup-test-repo/git/hooks/applypatch-msg.sample -DATADIR/work-dir/git-backup-test-repo/git/hooks/commit-msg.sample -DATADIR/work-dir/git-backup-test-repo/git/hooks/post-commit.sample -DATADIR/work-dir/git-backup-test-repo/git/hooks/post-receive.sample -DATADIR/work-dir/git-backup-test-repo/git/hooks/post-update.sample -DATADIR/work-dir/git-backup-test-repo/git/hooks/pre-applypatch.sample -DATADIR/work-dir/git-backup-test-repo/git/hooks/pre-commit.sample -DATADIR/work-dir/git-backup-test-repo/git/hooks/pre-rebase.sample -DATADIR/work-dir/git-backup-test-repo/git/hooks/prepare-commit-msg.sample -DATADIR/work-dir/git-backup-test-repo/git/hooks/update.sample DATADIR/work-dir/git-backup-test-repo/git/info DATADIR/work-dir/git-backup-test-repo/git/info/exclude DATADIR/work-dir/git-backup-test-repo/git/info/refs DATADIR/work-dir/git-backup-test-repo/git/objects -DATADIR/work-dir/git-backup-test-repo/git/packed-refs DATADIR/work-dir/git-backup-test-repo/git/refs DATADIR/work-dir/git-backup-test-repo/git/refs/heads +DATADIR/work-dir/git-backup-test-repo/git/refs/heads/master DATADIR/work-dir/git-backup-test-repo/git/refs/tags diff --git a/tests/git-single-commit.script b/tests/git-single-commit.script index 4a6e8b3..b3d8e43 100755 --- a/tests/git-single-commit.script +++ b/tests/git-single-commit.script @@ -24,7 +24,7 @@ set -e logfile="$DATADIR/git-test-repo.log" workdir="$DATADIR/work-dir" -./lorry --pull-only --log="$logfile" --working-area="$workdir" \ +${SRCDIR}/test-lorry --pull-only --log="$logfile" --working-area="$workdir" \ "$DATADIR/git-test-repo.lorry" > /dev/null 2> /dev/null # verify that the git repository was set up correctly diff --git a/tests/hg-single-commit.script b/tests/hg-single-commit.script index c370190..585fd33 100755 --- a/tests/hg-single-commit.script +++ b/tests/hg-single-commit.script @@ -24,7 +24,7 @@ set -e logfile="$DATADIR/hg-test-repo.log" workdir="$DATADIR/work-dir" -./lorry --verbose --pull-only --log="$logfile" --working-area="$workdir" \ +${SRCDIR}/test-lorry --verbose --pull-only --log="$logfile" --working-area="$workdir" \ "$DATADIR/hg-test-repo.lorry" > /dev/null 2> /dev/null # verify that the git repository was created correctly diff --git a/tests/make-tarball.script b/tests/make-tarball.script new file mode 100755 index 0000000..8be7b77 --- /dev/null +++ b/tests/make-tarball.script @@ -0,0 +1,32 @@ +#!/bin/sh +# +# Test that we can create a tarball of the git trees. +# +# Copyright (C) 2012 Codethink Limited +# +# 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; version 2 of the License. +# +# 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., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + + +set -e + +logfile="$DATADIR/make-tarball.log" +workdir="$DATADIR/work-dir" + +${SRCDIR}/test-lorry --pull-only --log="$logfile" --working-area="$workdir" \ + --tarball=first \ + "$DATADIR/make-tarball-repo.lorry" > /dev/null 2> /dev/null + +# verify that we can see the tarball generated of the git tree + +test -r "${workdir}/make-tarball-repo-bzip2/git/"*"make_tarball_repo_bzip2.tar" diff --git a/tests/make-tarball.setup b/tests/make-tarball.setup new file mode 100755 index 0000000..2032610 --- /dev/null +++ b/tests/make-tarball.setup @@ -0,0 +1,59 @@ +#!/bin/sh +# +# Creates gzip/bzip2/lzma tarballs, each with a single file. +# +# Copyright (C) 2012 Codethink Limited +# +# 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; version 2 of the License. +# +# 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., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + + +set -e + +# create the original "repository" +repo="$DATADIR/make-tarball-repo" +mkdir "$repo" +echo "first line" > "$repo/test.txt" + +# create the tarballs +cd "$DATADIR" +tar -czf make-tarball-repo.tar.gz "`basename $repo`" +tar -cjf make-tarball-repo.tar.bz2 "`basename $repo`" +tar -cf make-tarball-repo.tar.lzma "`basename $repo`" --lzma + +# create the .lorry file for the tarball "repositories" +cat < $DATADIR/make-tarball-repo.lorry +{ + "make-tarball-repo-gzip": { + "type": "tarball", + "compression": "gzip", + "strip": 1, + "url": "file://$DATADIR/make-tarball-repo.tar.gz" + }, + "make-tarball-repo-bzip2": { + "type": "tarball", + "compression": "bzip2", + "strip": 1, + "url": "file://$DATADIR/make-tarball-repo.tar.bz2" + }, + "make-tarball-repo-lzma": { + "type": "tarball", + "compression": "lzma", + "strip": 1, + "url": "file://$DATADIR/make-tarball-repo.tar.lzma" + } +} +EOF + +# create the working directory +test -d "$DATADIR/work-dir" || mkdir "$DATADIR/work-dir" diff --git a/tests/no-pushspec-pushall.script b/tests/no-pushspec-pushall.script index cc56d8a..7de3a58 100755 --- a/tests/no-pushspec-pushall.script +++ b/tests/no-pushspec-pushall.script @@ -37,7 +37,7 @@ mirror_path="$DATADIR"/git-mirror mkdir -p "$mirror_path" git init --quiet --bare "$mirror_path"/no-pushspec.git -./lorry --log="$logfile" --working-area="$workdir" \ +${SRCDIR}/test-lorry --log="$logfile" --working-area="$workdir" \ --mirror-base-url-push=file://"$mirror_path" \ --mirror-base-url-fetch=file://"$mirror_path" \ "$lorryfile" diff --git a/tests/pushspecs-only.script b/tests/pushspecs-only.script index 787cc38..d7f4c2f 100755 --- a/tests/pushspecs-only.script +++ b/tests/pushspecs-only.script @@ -41,7 +41,7 @@ mirror_path="$DATADIR"/git-mirror mkdir -p "$mirror_path" git init --quiet --bare "$mirror_path"/pushspecs.git -./lorry --log="$logfile" --working-area="$workdir" \ +${SRCDIR}/test-lorry --log="$logfile" --working-area="$workdir" \ --mirror-base-url-push=file://"$mirror_path" \ --mirror-base-url-fetch=file://"$mirror_path" \ "$lorryfile" diff --git a/tests/svn-single-commit.script b/tests/svn-single-commit.script index f1c769c..cff91b0 100755 --- a/tests/svn-single-commit.script +++ b/tests/svn-single-commit.script @@ -23,7 +23,7 @@ set -e logfile="$DATADIR/svn-test-repo.log" workdir="$DATADIR/work-dir" -./lorry --pull-only --log="$logfile" --working-area="$workdir" \ +${SRCDIR}/test-lorry --pull-only --log="$logfile" --working-area="$workdir" \ "$DATADIR/svn-test-repo.lorry" > /dev/null 2> /dev/null # verify that the git repository was created successfully diff --git a/tests/tar-single-commit.script b/tests/tar-single-commit.script index 623adee..f1d92c5 100755 --- a/tests/tar-single-commit.script +++ b/tests/tar-single-commit.script @@ -20,10 +20,10 @@ set -e -logfile="$DATADIR/svn-test-repo.log" +logfile="$DATADIR/tar-single-commit.log" workdir="$DATADIR/work-dir" -./lorry --pull-only --log="$logfile" --working-area="$workdir" \ +${SRCDIR}/test-lorry --pull-only --log="$logfile" --working-area="$workdir" \ "$DATADIR/tar-test-repo.lorry" > /dev/null 2> /dev/null # verify that the git repositories were created successfully @@ -39,5 +39,5 @@ for FORMAT in "gzip" "bzip2" "lzma"; do git cat-file blob master:test.txt # list the commit messages - git log --pretty='%s' master + git log --pretty='%s' master | sed -e"s,${DATADIR},DATADIR," done diff --git a/tests/tar-single-commit.setup b/tests/tar-single-commit.setup index c99450f..bfc99f8 100755 --- a/tests/tar-single-commit.setup +++ b/tests/tar-single-commit.setup @@ -29,7 +29,8 @@ echo "first line" > "$repo/test.txt" cd "$DATADIR" tar -czf tar-test-repo.tar.gz "`basename $repo`" tar -cjf tar-test-repo.tar.bz2 "`basename $repo`" -tar -cf tar-test-repo.tar.lzma "`basename $repo`" --lzma +tar -cf tar-test-repo.tar "`basename $repo`" +xz -z tar-test-repo.tar # create the .lorry file for the tarball "repositories" cat < $DATADIR/tar-test-repo.lorry @@ -50,7 +51,7 @@ cat < $DATADIR/tar-test-repo.lorry "type": "tarball", "compression": "lzma", "strip": 1, - "url": "file://$DATADIR/tar-test-repo.tar.lzma" + "url": "file://$DATADIR/tar-test-repo.tar.xz" } } EOF diff --git a/tests/tar-single-commit.stdout b/tests/tar-single-commit.stdout index 04cec41..32fcdd5 100644 --- a/tests/tar-single-commit.stdout +++ b/tests/tar-single-commit.stdout @@ -1,12 +1,15 @@ gzip refs/heads/master +refs/tags/tar-test-repo first line -Tarball conversion +Imported from DATADIR/work-dir/tar-test-repo-gzip/tar-test-repo.tar.gz. bzip2 refs/heads/master +refs/tags/tar-test-repo first line -Tarball conversion +Imported from DATADIR/work-dir/tar-test-repo-bzip2/tar-test-repo.tar.bz2. lzma refs/heads/master +refs/tags/tar-test-repo first line -Tarball conversion +Imported from DATADIR/work-dir/tar-test-repo-lzma/tar-test-repo.tar.xz. -- cgit v1.2.1