Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
emulab
emulab-devel
Commits
863602d5
Commit
863602d5
authored
Nov 30, 2005
by
Leigh B. Stoller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Checkpoint the switch to using subversion instead of CVS. Wow, this is
going to be a lot easier!
parent
ea28187f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
113 additions
and
171 deletions
+113
-171
tbsetup/libArchive.pm.in
tbsetup/libArchive.pm.in
+113
-171
No files found.
tbsetup/libArchive.pm.in
View file @
863602d5
...
...
@@ -38,10 +38,14 @@ my $CHMOD = "/bin/chmod";
my
$
TAR
=
"/usr/bin/tar"
;
my
$
RM
=
"/bin/rm"
;
my
$
CVSBIN
=
"/usr/bin/cvs"
;
my
$
SVN
=
"/usr/local/bin/svn"
;
my
$
SVNADMIN
=
"/usr/local/bin/svnadmin"
;
my
$
IMPORTER
=
"$TB/sbin/svn_load_dirs.pl"
;
my
$
inittag
=
'root'
;
my
$
defaultview
=
'head'
;
my
$
debug
=
1
;
my
$
cvsopt
=
($
debug
?
""
:
"-q"
);
my
$
svnopt
=
($
debug
?
""
:
"-q"
);
#
Little
helper
and
debug
function
.
sub
mysystem
($)
...
...
@@ -103,16 +107,16 @@ sub ArchiveCreate(;$$)
#
to
hold
currently
checked
out
versions
of
the
tree
.
Lastly
,
we
#
need
a
place
to
copyin
files
before
they
are
added
to
the
repo
.
#
my
$
cvs
dir
=
"$dir/repo"
;
my
$
repo
dir
=
"$dir/repo"
;
my
$
checkouts
=
"$dir/checkouts"
;
my
$
checkins
=
"$dir/checkins"
;
if
(
! mkdir("$
cvs
dir", 0777)) {
print
STDERR
"ArchiveCreate: Could not mkdir $
cvs
dir: $!
\n
"
;
if
(
! mkdir("$
repo
dir", 0777)) {
print
STDERR
"ArchiveCreate: Could not mkdir $
repo
dir: $!
\n
"
;
goto
bad
;
}
if
(
! chmod(0777, "$
cvs
dir")) {
print
STDERR
"ArchiveCreate: Could not chmod $
cvs
dir: $!
\n
"
;
if
(
! chmod(0777, "$
repo
dir")) {
print
STDERR
"ArchiveCreate: Could not chmod $
repo
dir: $!
\n
"
;
goto
bad
;
}
if
(
! mkdir("$checkouts", 0777)) {
...
...
@@ -139,18 +143,25 @@ sub ArchiveCreate(;$$)
print
STDERR
"ArchiveCreate: Could not chmod $checkins/$view: $!
\n
"
;
goto
bad
;
}
#
Init
the
CVS
control
files
.
mysystem
(
"$
CVSBIN $cvsopt -d $cvsdir init
"
)
==
0
#
Init
ialize
the
repo
.
mysystem
(
"$
SVNADMIN create $repodir
"
)
==
0
or
goto
bad
;
#
Create
an
stub
directory
and
import
it
as
"root"
mysystem
(
"cd $dir; mkdir ignore; cd ignore; "
.
"$CVSBIN $cvsopt -d $cvsdir import "
.
"-m 'Initialize' root $tag ${tag}_init"
)
#
Create
an
stub
directory
tree
and
import
it
as
"root"
mysystem
(
"cd $dir; mkdir ignore; cd ignore; mkdir $view; "
.
" mkdir $view/trunk $view/savepoint $view/tags; "
.
"$SVN import -m 'ArchiveCreate' $view file://$repodir/$view"
)
==
0
or
goto
bad
;
#
Create
a
branch
tag
in
the
tags
directory
to
base
differences
against
.
mysystem
(
"$SVN copy -m 'ArchiveCreate Branch' "
.
" file://$repodir/$view/trunk "
.
" file://$repodir/$view/tags/${tag}-branch"
)
==
0
or
goto
bad
;
#
Now
check
it
out
.
This
creates
the
$
checkouts
/$
view
directory
.
mysystem
(
"cd $checkouts; "
.
"$CVSBIN $cvsopt -d $cvsdir checkout root; "
.
"/bin/mv root ${view}"
)
"$SVN checkout $svnopt file://$repodir/$view"
)
==
0
or
goto
bad
;
#
Now
enter
the
default
view
(
okay
,
branch
)
of
this
archive
.
...
...
@@ -160,7 +171,7 @@ sub ArchiveCreate(;$$)
#
Now
enter
an
initial
tag
for
the
tree
.
Nothing
actually
gets
tagged
.
DBQueryWarn
(
"insert into archive_tags set idx=NULL, "
.
" tag='$tag', archive_idx='$idx',
revision='1.1',
"
.
" tag='$tag', archive_idx='$idx', "
.
" date_created=UNIX_TIMESTAMP(now())"
)
or
goto
bad
;
return
$
idx
;
...
...
@@ -243,7 +254,7 @@ sub ArchiveAdd($$;$)
print
STDERR
"ArchiveFile: $directory cannot be written!
\n
"
;
return
-
1
;
}
my
$
cvs
dir
=
"$directory/repo"
;
my
$
repo
dir
=
"$directory/repo"
;
my
$
checkout
=
"$directory/checkouts/$view"
;
my
$
checkin
=
"$directory/checkins/$view"
;
...
...
@@ -305,7 +316,7 @@ sub ArchiveSavePoint($;$$)
print
STDERR
"ArchiveSavePoint: $directory cannot be written!
\n
"
;
goto
bad
;
}
my
$
cvs
dir
=
"$directory/repo"
;
my
$
repo
dir
=
"$directory/repo"
;
my
$
checkout
=
"$directory/checkouts/$view"
;
my
$
checkin
=
"$directory/checkins/$view"
;
...
...
@@ -321,9 +332,8 @@ sub ArchiveSavePoint($;$$)
}
#
Get
the
current
tag
for
the
archive
.
my
($
archive_tag
,
$
archive_revision
);
if
(
GetArchiveCurrentTags
($
archive_idx
,
$
view
,
\$
archive_tag
,
\$
archive_revision
)
<
0
)
{
my
($
archive_tag
);
if
(
GetArchiveCurrentTags
($
archive_idx
,
$
view
,
\$
archive_tag
)
<
0
)
{
print
STDERR
"ArchiveSavePoint: "
.
"Archive '$archive_idx' does not have a current tag!
\n
"
;
goto
bad
;
...
...
@@ -344,60 +354,35 @@ sub ArchiveSavePoint($;$$)
}
#
#
Use
cvs
import
command
.
This
is
nice
cause
it
handles
all
the
#
Use
svn
import
command
.
This
is
nice
cause
it
handles
all
the
#
subdirs
and
stuff
in
one
shot
,
instead
of
trying
to
deal
with
#
each
file
and
directory
individually
.
#
#
NOTE
:
Need
to
specify
the
current
"vendor"
branch
to
import
on
,
#
or
else
cvs
always
uses
1.1.1
.
After
each
commit
to
the
head
,
we
#
bump
this
so
that
the
savepoints
are
logically
distinct
and
clearly
#
associated
with
its
head
branch
.
#
my
$
rev
=
"${archive_revision}.1"
;
my
$
bopt
=
"-b $rev"
;
if
(
! chdir("$checkout")) {
print
STDERR
"ArchiveSavePoint: Cannot chdir to $checkout!
\n
"
;
goto
bad
;
}
#
#
Ack
! We need to set the default branch to match the head revision.
#
I
think
CVS
is
totally
screwed
up
on
this
!
#
#
mysystem
(
"rcs -b${rev} "
.
#
"`$CVSBIN $cvsopt -d $cvsdir -q log -R`"
);
#
Now
do
the
import
.
if
(
! chdir("$checkin")) {
print
STDERR
"ArchiveSavePoint: Cannot chdir to $checkin!
\n
"
;
goto
bad
;
}
mysystem
(
"$CVSBIN $cvsopt -d $cvsdir import $bopt "
.
"-m 'SavePoint' root $archive_tag $savetag"
);
if
($?)
{
print
STDERR
"ArchiveCommit: Could not import from $checkin!
\n
"
;
goto
bad
;
}
mysystem
(
"$IMPORTER -no_user_input file://$repodir "
.
" $view/savepoint . > /dev/null"
)
==
0
or
goto
bad
;
#
#
Create
the
tag
for
this
savepoint
.
#
mysystem
(
"$SVN copy -m 'ArchiveCreate Branch' "
.
" file://$repodir/$view/savepoint "
.
" file://$repodir/$view/tags/${savetag}"
)
==
0
or
goto
bad
;
#
#
And
record
the
new
tag
.
#
DBQueryWarn
(
"insert into archive_tags set idx=NULL, "
.
" tag='$savetag',
revision='${archive_revision}',
"
.
" tag='$savetag', "
.
" archive_idx='$archive_idx', "
.
" date_created=UNIX_TIMESTAMP(now())"
)
or
goto
bad
;
#
And
now
into
the
checkout
dir
to
checkout
a
current
copy
.
if
(
! chdir("$checkout")) {
print
STDERR
"ArchiveSavePoint: Cannot chdir to $checkout!
\n
"
;
goto
bad
;
}
mysystem
(
"$CVSBIN $cvsopt -d $cvsdir update -dP -r $rev"
);
if
($?)
{
print
STDERR
"ArchiveSavePoint: Could not checkout revision!
\n
"
;
goto
bad
;
}
okay
:
TBScriptUnlock
();
chdir
($
cwd
)
...
...
@@ -418,6 +403,7 @@ sub ArchiveSavePoint($;$$)
sub
ArchiveCommit
($;$$$)
{
my
($
archive_idx
,
$
newtag
,
$
view
,
$
altdir
)
=
@
_
;
my
$
noactivity
=
0
;
my
$
cwd
;
$
view
=
$
defaultview
...
...
@@ -440,7 +426,7 @@ sub ArchiveCommit($;$$$)
print
STDERR
"ArchiveCommit: $directory cannot be written!
\n
"
;
goto
bad
;
}
my
$
cvs
dir
=
"$directory/repo"
;
my
$
repo
dir
=
"$directory/repo"
;
my
$
checkout
=
"$directory/checkouts/$view"
;
my
$
checkin
=
(
defined
($
altdir
)
?
$
altdir
:
"$directory/checkins/$view"
);
...
...
@@ -461,30 +447,17 @@ sub ArchiveCommit($;$$$)
}
#
Get
the
current
tags
for
the
archive
.
my
($
archive_tag
,
$
archive_revision
,
$
previous_tag
);
my
($
archive_tag
,
$
previous_tag
);
if
(
GetArchiveCurrentTags
($
archive_idx
,
$
view
,
\$
archive_tag
,
\$
archive_revision
,
\$
previous_tag
)
<
0
)
{
\$
previous_tag
)
<
0
)
{
print
STDERR
"ArchiveCommit: "
.
"Archive '$archive_idx' does not have a current tag!
\n
"
;
goto
bad
;
}
#
#
Lets
see
if
there
has
been
any
action
since
the
last
commit
.
#
Check
for
new
tags
.
#
my
$
query_result
=
DBQueryWarn
(
"select tag from archive_tags "
.
"where archive_idx='$archive_idx' "
.
"order by idx desc limit 1"
);
goto
bad
if
(
!$query_result || !$query_result->numrows);
my
($
tmptag
)
=
$
query_result
->
fetchrow_array
();
if
($
tmptag
eq
$
archive_tag
)
{
print
"ArchiveCommit: Archive is clean; no need to commit.
\n
"
;
goto
okay
;
}
#
Form
new
tag
.
#
my
($
seconds
,
$
microseconds
)
=
gettimeofday
();
my
$
import_tag
=
POSIX
::
strftime
(
"T20%y%m%d-%H%M%S-"
,
localtime
());
$
import_tag
.=
$
microseconds
;
...
...
@@ -498,6 +471,24 @@ sub ArchiveCommit($;$$$)
$
newtag
=
"T"
.
$
newtag
;
}
#
#
Lets
see
if
there
has
been
any
action
since
the
last
commit
.
#
Check
for
new
tags
,
and
if
nothing
has
happened
,
just
drop
a
#
new
set
of
tags
in
and
return
.
#
my
$
query_result
=
DBQueryWarn
(
"select tag from archive_tags "
.
"where archive_idx='$archive_idx' "
.
"order by idx desc limit 1"
);
goto
bad
if
(
!$query_result || !$query_result->numrows);
my
($
tmptag
)
=
$
query_result
->
fetchrow_array
();
if
($
tmptag
eq
$
archive_tag
)
{
print
"ArchiveCommit: Archive is clean; no need to commit.
\n
"
;
$
noactivity
=
1
;
}
#
Clean
the
temp
dir
for
next
phase
.
mysystem
(
"/bin/rm -rf $checkin/*"
);
if
($?)
{
...
...
@@ -506,95 +497,55 @@ sub ArchiveCommit($;$$$)
}
#
#
Form
a
new
head
revision
and
branch
tag
.
#
my
$
next_revision
;
if
($
archive_revision
=~
/^(\
d
*)\.(\
d
*)$/)
{
$
next_revision
=
$
1
.
"."
.
($
2
+
1
);
}
else
{
print
STDERR
"ArchiveCommit: "
.
"Could not parse revision $archive_revision!
\n
"
;
goto
bad
;
}
#
#
If
this
is
the
first
commit
of
the
archive
,
then
just
checkout
#
and
commit
to
a
new
head
revision
.
#
if
($
archive_revision
eq
"1.1"
)
{
mysystem
(
"$CVSBIN $cvsopt -d $cvsdir checkout root"
);
if
($?)
{
print
STDERR
"ArchiveCommit: "
.
"Could not checkout $archive_tag!
\n
"
;
goto
bad
;
}
}
else
{
#
Okay
,
do
the
commit
to
the
trunk
for
this
view
.
#
if
(
! $noactivity) {
#
#
Need
to
merge
.
Do
a
fresh
checkout
,
merging
the
current
import
branch
#
into
the
head
revsion
.
#
Check
out
the
current
trunk
.
#
#
Yuck
.
Need
to
clear
the
-
b
(
default
branch
)
or
else
the
merge
#
commit
fails
for
some
reason
that
makes
no
sense
to
me
,
but
#
must
make
sense
to
someone
at
CVS
headquarters
.
mysystem
(
"$SVN checkout $svnopt file://$repodir/$view/trunk"
)
==
0
or
goto
bad
;
#
mysystem
(
"$CVSBIN $cvsopt -d $cvsdir "
.
"checkout -r $archive_revision root"
);
if
($?)
{
print
STDERR
"ArchiveCommit: "
.
"Could not checkout revision $archive_revision!
\n
"
;
goto
bad
;
}
mysystem
(
"$CVSBIN $cvsopt -d $cvsdir admin -b root"
);
if
($?)
{
print
STDERR
"ArchiveCommit: "
.
"Could not clear the default branch!
\n
"
;
goto
bad
;
}
mysystem
(
"$CVSBIN $cvsopt -d $cvsdir update -A "
.
"-j $previous_tag -j $archive_tag root"
);
if
($?)
{
print
STDERR
"ArchiveCommit: "
.
"Could not checkout and merge $archive_tag into head.!
\n
"
;
goto
bad
;
}
}
#
Do
a
merge
from
the
branch
off
the
previous
commit
tag
,
with
#
the
savepoint
.
This
is
merged
into
the
working
directory
we
#
just
checked
out
above
.
This
will
do
the
work
of
scheduling
#
additions
and
deletions
.
#
mysystem
(
"$SVN merge $svnopt "
.
" file://$repodir/$view/tags/${archive_tag}-branch "
.
" file://$repodir/$view/savepoint "
.
" trunk"
)
==
0
or
goto
bad
;
#
#
And
then
commit
it
back
to
the
head
revision
,
using
bumped
rev
number
.
#
mysystem
(
"$CVSBIN $cvsopt -d $cvsdir commit -f -R -r $next_revision "
.
"-m 'Commit merge of ${archive_tag} with head'"
);
if
($?)
{
print
STDERR
"ArchiveCommit: "
.
"Could not commit merge back to the repository!
\n
"
;
goto
bad
;
#
#
Now
commit
to
the
trunk
!
#
mysystem
(
"$SVN commit $svnopt "
.
" -m 'Commit merge of ${archive_tag} to trunk' trunk"
)
==
0
or
goto
bad
;
}
#
#
Ack
! We need to advance the default branch to match the head revision.
#
I
think
CVS
is
totally
screwed
up
on
this
!
#
mysystem
(
"rcs -b${next_revision}.1 "
.
"`$CVSBIN $cvsopt -d $cvsdir -q log -R`"
);
DBQueryWarn
(
"insert into archive_tags set idx=NULL, "
.
" tag='$import_tag', revision='${next_revision}', "
.
" archive_idx='$archive_idx', "
.
" date_created=UNIX_TIMESTAMP(now())"
)
or
goto
bad
;
#
Create
a
tag
in
the
tags
directory
for
the
commit
.
mysystem
(
"$SVN copy -m 'ArchiveCommit' "
.
" file://$repodir/$view/trunk "
.
" file://$repodir/$view/tags/${newtag}"
)
==
0
or
goto
bad
;
#
Create
a
branch
tag
in
the
tags
directory
to
base
differences
against
.
mysystem
(
"$SVN copy -m 'ArchiveCommit Branch' "
.
" file://$repodir/$view/trunk "
.
" file://$repodir/$view/tags/${newtag}-branch"
)
==
0
or
goto
bad
;
DBQueryWarn
(
"insert into archive_tags set idx=NULL, "
.
" tag='$newtag',
revision='${next_revision}',
"
.
" tag='$newtag', "
.
" archive_idx='$archive_idx', "
.
" date_created=UNIX_TIMESTAMP(now())"
)
or
goto
bad
;
DBQueryWarn
(
"update archive_views set "
.
" current_tag='$
import_
tag', "
.
" current_tag='$
new
tag', "
.
" previous_tag='$archive_tag' "
.
"where archive_idx='$archive_idx' and view='$view'"
)
or
goto
bad
;
...
...
@@ -606,21 +557,14 @@ sub ArchiveCommit($;$$$)
goto
bad
;
}
#
And
lets
tag
the
tree
for
good
measure
with
a
commit
tag
.
mysystem
(
"$CVSBIN $cvsopt -d $cvsdir rtag -r $next_revision $newtag root"
);
if
($?)
{
print
STDERR
"ArchiveCommit: Could not rtag with $newtag!
\n
"
;
goto
bad
;
}
#
And
now
into
the
checkout
dir
to
checkout
a
current
copy
.
if
(
! chdir("$checkout")) {
print
STDERR
"ArchiveCommit: Cannot chdir to $checkout!
\n
"
;
goto
bad
;
}
mysystem
(
"$
CVSBIN $cvsopt -d $cvsdir update -dP -r $next_revision
"
);
mysystem
(
"$
SVN $svnopt update trunk
"
);
if
($?)
{
print
STDERR
"ArchiveCommit: Could not
checkout
head revision!
\n
"
;
print
STDERR
"ArchiveCommit: Could not
update
head revision!
\n
"
;
goto
bad
;
}
okay
:
...
...
@@ -685,9 +629,9 @@ sub ArchiveFork($$;$)
}
#
Get
the
current
tags
for
the
archive
.
my
($
archive_tag
,
$
archive_revision
,
$
previous_tag
);
my
($
archive_tag
,
$
previous_tag
);
if
(
GetArchiveCurrentTags
($
archive_idx
,
$
view
,
\$
archive_tag
,
\$
archive_revision
,
\$
previous_tag
)
<
0
)
{
\$
previous_tag
)
<
0
)
{
print
STDERR
"ArchiveCommit: "
.
"Archive '$archive_idx' does not have a current tag!
\n
"
;
goto
bad
;
...
...
@@ -704,7 +648,7 @@ sub ArchiveFork($$;$)
}
#
Now
checkout
new
view
;
this
creates
the
$
checkouts
/$
newview
directory
.
mysystem
(
"cd $checkouts; "
.
"$CVSBIN $cvsopt -d $cvsdir checkout
-r $archive_revision
root; "
.
"$CVSBIN $cvsopt -d $cvsdir checkout root; "
.
"/bin/mv root ${newview}"
)
==
0
or
goto
bad
;
...
...
@@ -834,12 +778,12 @@ sub GetArchiveDirectory($$)
#
Get
the
current
tag
for
an
archive
,
given
its
index
.
Returns
-
1
on
error
,
#
zero
otherwise
.
Place
tag
in
the
return
pointer
.
#
sub
GetArchiveCurrentTags
($$$;$
$
)
sub
GetArchiveCurrentTags
($$$;$)
{
my
($
archive_idx
,
$
view
,
$
tagp
,
$
revnump
,
$
prevp
)
=
@
_
;
my
($
archive_idx
,
$
view
,
$
tagp
,
$
prevp
)
=
@
_
;
my
$
query_result
=
DBQueryWarn
(
"select v.current_tag,
t.revision,
v.previous_tag "
.
DBQueryWarn
(
"select v.current_tag,v.previous_tag "
.
" from archive_views as v "
.
"left join archive_tags as t on "
.
" t.archive_idx=v.archive_idx and "
.
...
...
@@ -849,12 +793,10 @@ sub GetArchiveCurrentTags($$$;$$)
return
-
1
if
(
!$query_result);
my
($
tag
,$
revision
,$
previous
)
=
$
query_result
->
fetchrow_array
();
my
($
tag
,$
previous
)
=
$
query_result
->
fetchrow_array
();
$$
tagp
=
$
tag
if
(
defined
($
tagp
));
$$
revnump
=
$
revision
if
(
defined
($
revnump
));
$$
prevp
=
$
previous
if
(
defined
($
prevp
));
return
0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment