-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmakefile
153 lines (120 loc) · 6 KB
/
makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# Generic makefile for DVCS conversions using reposurgeon
#
# Steps to using this:
# 0. Copy this into a scratch directory as Makefile
# 1. Make sure git, reposurgeon, and repopuller are on your $PATH.
# 2. Set PROJECT to the name of your project
# 3. Set SOURCE_VCS to svn or cvs
# 4. Set TARGET_VCS to git, hg, or bzr
# 5. For svn, set SVN_URL to point at the remote repository you want to convert.
# 6. For cvs, set CVS_HOST to the repo hostname and CVS_MODULE to the module.
# 7. Create a $(PROJECT).lift script for your custom commands, initially empty.
# 8. Run 'make stubmap' to create a stub author map.
# 9. (Optional) set REPOSURGEON to point at a faster cython build of the tool
# 10. Run 'make' to build a converted repository
#
# For a production-quality conversion you will need to edit the map
# file and the lift script. During the process you can set EXTRAS to
# name extra metadata such as a comments mailbox.
#
# After the conversion, you can perform a sanity check with 'make diff'.
# Note that CVS-checkout directories not matched in a conversion may be
# historical relics containing only CVSROOT directories.
PROJECT = fink
SOURCE_VCS = cvs
TARGET_VCS = git
EXTRAS =
SVN_URL = svn://svn.debian.org/$(PROJECT)
CVS_HOST = $(PROJECT).cvs.sourceforge.net
CVS_MODULE = dists
VERBOSITY = "verbose 1"
REPOSURGEON = reposurgeon
# Configuration ends here
.PHONY: local-clobber remote-clobber gitk gc compare clean dist stubmap diff
default: $(PROJECT)-$(TARGET_VCS)
# Build the converted repo from the second-stage fast-import stream
$(PROJECT)-$(TARGET_VCS): $(PROJECT).fi
rm -fr $(PROJECT)-$(TARGET_VCS); $(REPOSURGEON) "read <$(PROJECT).fi" "prefer $(TARGET_VCS)" "rebuild $(PROJECT)-$(TARGET_VCS)"
# Build the second-stage fast-import stream from the first-stage stream dump
$(PROJECT).fi: $(PROJECT).$(SOURCE_VCS) $(PROJECT).lift $(PROJECT).map $(EXTRAS)
$(REPOSURGEON) $(VERBOSITY) "read <$(PROJECT).$(SOURCE_VCS)" "authors read <$(PROJECT).map" "prefer git" "script $(PROJECT).lift" "legacy write >$(PROJECT).fo" "write >$(PROJECT).fi"
# Force rebuild of first-stage stream from the local mirror on the next make
local-clobber: clean
rm -fr $(PROJECT).fi $(PROJECT)-$(TARGET_VCS) *~ .rs* $(PROJECT)-conversion.tar.gz
# Force full rebuild from the remote repo on the next make.
remote-clobber: local-clobber
rm -fr $(PROJECT).$(SOURCE_VCS) $(PROJECT)-mirror $(PROJECT)-checkout
# Get the (empty) state of the author mapping from the first-stage stream
stubmap: $(PROJECT).$(SOURCE_VCS)
$(REPOSURGEON) "read <$(PROJECT).$(SOURCE_VCS)" "authors write >$(PROJECT).map"
# Compare the head revisions of the unconverted and converted repositories
EXCLUDE = -x CVS -x .$(SOURCE_VCS) -x .$(TARGET_VCS)
EXCLUDE += -x .$(SOURCE_VCS)ignore -x .$(TARGET_VCS)ignore
diff: $(PROJECT)-checkout $(PROJECT)-$(TARGET_VCS)
diff $(EXCLUDE) -r -u $(PROJECT)-checkout $(PROJECT)-$(TARGET_VCS)
# Source-VCS-specific productions to build the first-stage stream dump
ifeq ($(SOURCE_VCS),svn)
# Build the first-stage (Subversion) stream dump from the local mirror
$(PROJECT).svn: $(PROJECT)-mirror
repopuller $(PROJECT)-mirror
svnadmin dump $(PROJECT)-mirror/ >$(PROJECT).svn
# Build a local mirror of the remote Subversion repo
$(PROJECT)-mirror:
repopuller $(SVN_URL)
# Make a local checkout of the Subversion mirror for inspection
$(PROJECT)-checkout: $(PROJECT)-mirror
svn co file://${PWD}/$(PROJECT)-mirror $(PROJECT)-checkout
endif
ifeq ($(SOURCE_VCS),cvs)
# Mirror a CVS repo. Requires cvssync(1) from the cvs-fast-export
# distribution. You will need cvs-fast-export installed as well.
$(PROJECT)-mirror:
cvssync -c -o $(PROJECT)-mirror "$(CVS_HOST):/cvsroot/$(PROJECT)" $(CVS_MODULE)
# Build the first-stage CVS stream dump from the local mirror
$(PROJECT).cvs: $(PROJECT)-mirror
find $(PROJECT)-mirror -name '*,v' | cvs-fast-export -p --reposurgeon >$(PROJECT).cvs
# Make a local checkout of the CVS mirror for inspection
$(PROJECT)-checkout: $(PROJECT)-mirror
cvs -Q -d:local:${PWD}/$(PROJECT)-mirror co -kk $(CVS_MODULE)
mv $(CVS_MODULE) $(PROJECT)-checkout
endif
ifeq ($(TARGET_VCS),git)
#
# The following productions are git-specific
#
# Browse the generated git repository
gitk: $(PROJECT)-git
cd $(PROJECT)-git; gitk --all
# Run a garbage-collect on the generated git repository. Import doesn't.
# This repack call is the active part of gc --aggressive. This call is
# tuned for very large repositories.
gc: $(PROJECT)-git
cd $(PROJECT)-git; time git -c pack.threads=0 repack -AdF --window=1250 --depth=250
# Make a conversion using a competing tool
$(PROJECT)-git-svn:
git svn --stdlayout --no-metadata --authors-file=$(PROJECT).authormap clone file://${PWD}/$(PROJECT)-mirror $(PROJECT)-git-svn
# Compare file manifests on the master branch
compare: $(PROJECT)-git-svn $(PROJECT)-git
@echo; echo "Comparing the directory manifests..."
@rm -f GITSVN.MANIFEST PROJECTGIT.MANIFEST
@(cd $(PROJECT)-git-svn >/dev/null; find . -type f | sort | fgrep -v '.git') >GITSVN.MANIFEST
@(cd $(PROJECT)-git >/dev/null; find . -type f | sort | fgrep -v '.git') >PROJECTGIT.MANIFEST
@echo "Comparing file manifests..."
@diff -u GITSVN.MANIFEST PROJECTGIT.MANIFEST
@echo "No diff output is good news"
@echo; echo "Comparing file contents..."
@set -e; for file in `cd $(PROJECT)-git-svn >/dev/null; git ls-files`; do cmp $(PROJECT)-git-svn/$$file $(PROJECT)-git/$$file; done
@echo "No cmp output is good news"
# Compare all files in all revisions. Ignore .gitignores, as reposurgeon
# makes them but git-svn does not.
repodiffer: $(PROJECT)-git-svn $(PROJECT)-git
repodiffer --ignore="gitignore,comment" --fossil-map=$(PROJECT).fo $(PROJECT)-git $(PROJECT)-git-svn | tee REPODIFFER.LOG
endif
# General cleanup and utility
clean:
rm -fr *~ .rs* $(PROJECT)-conversion.tar.gz REPODIFFER.LOG
# Bundle up the conversion metadata for shipping
SOURCES = Makefile $(PROJECT).lift $(PROJECT).map $(EXTRAS)
$(PROJECT)-conversion.tar.gz: $(SOURCES)
tar --dereference --transform 's:^:$(PROJECT)-conversion/:' -czvf $(PROJECT)-conversion.tar.gz $(SOURCES)
dist: $(PROJECT)-conversion.tar.gz