Answers:
在没有所有.svn文件夹的情况下,复制存储库最新版本的最简单方法是使用svn export
命令。
这是我制作存档的方法:
$ svn export URL PATH ; tar czf exported_copy.tgz PATH
其中URL是svn存储库的URL,而PATH是适合保存导出的存储库副本的本地路径。我不知道有比这更直接的方法。不幸的是,您最终还是将导出的副本挂了起来,因此,您可能只想将整个内容放在一个简短的bash脚本中,然后再删除临时文件。
编辑:虽然这是最简单的方法,也是我使用的方法,但我会小心。在我的研究中,我发现此 http://narfation.org/2009/01/08/creating-recreatable-tar-gz-from-svn 可以清楚地告诉我们保留组/用户所有权的问题,这会在部署到另一个用户时引起问题系统。我已经尝试过对该脚本进行自己的修改以适合我的目的,您也可能会从中受益。
这是根据我写的单线改编而成。假设您有一个〜/ tmp目录。您需要在前两个步骤中更改PROJ和URL变量。其余的应该工作。
为了方便复制:
PROJ='yourproj' && URL='http://svn.example.com/svn/repo/$PROJ' && REV=`svn info $URL | fgrep Revision | cut -d ' ' -f 2` && cd ~/tmp && svn export $URL $PROJ && tar czv -f $PROJ.r$REV.tar.gz $PROJ && rm -r $PROJ.r$REV
为了易于查看:
PROJ='yourproj' &&
URL='http://svn.example.com/svn/repo/$PROJ' &&
REV=`svn info $URL | fgrep Revision | cut -d ' ' -f 2` &&
cd ~/tmp &&
svn export $URL $PROJ &&
tar czv -f $PROJ.r$REV.tar.gz $PROJ &&
rm -r $PROJ.r$REV
这是我尝试从SVN存储库制作确定性tarball的工作。
需要GNU tar 1.27或更高版本。
特征:
pax
扩展报头,SVN的时间戳精度达到了微秒级git archive
这样做.tar.gz
和.tar.xz
压缩。gzip的,则可以通过使用进一步优化压缩advdef
从AdvanceCOMP(advdef
用途zopfli库)。举例来说,我使用Subversion Repo本身作为签出和创建tar包的源。请注意,这不是SVN打包其tarball的方式,并且与SVN开发无关。毕竟,这只是一个例子。
# URL of repository to export
url="https://svn.apache.org/repos/asf/subversion/tags/1.9.7/"
# Name of distribution sub-directory
dist_name=subversion-1.9.7-test
# ---------------------------------------------------------------------
info=$(svn info --xml "$url" | tr -- '\t\n' ' ')
revision=$(echo "$info" |
sed 's|.*<commit[^>]* revision="\{0,1\}\([^">]*\)"\{0,1\}>.*|\1|')
tar_name=${dist_name}-r${revision}
# Subversion's commit timestamps can be as precise as 0.000001 seconds,
# but sub-second precision is only available through --xml output
# format.
date=$(echo "$info" |
sed 's|.*<commit[^>]*>.*<date>\([^<]*\)</date>.*</commit>.*|\1|')
# Factors that would make tarball non-deterministic include:
# - umask
# - Ordering of file names
# - Timestamps of directories ("svn export" doesn't update them)
# - User and group names and IDs
# - Format of tar (gnu, ustar or pax)
# - For pax format, the name and contents of extended header blocks
umask u=rwx,go=rx
svn export -r "$revision" "$url" "$dist_name"
# "svn export" will update file modification time to latest time of
# commit that modifies the file, but won't do so on directories.
find . -type d | xargs touch -c -m -d "$date" --
trap 's=$?; rm -f "${tar_name}.tar" || : ; exit $s' 1 2 3 15
# pax extended header allows sub-second precision on modification time.
# The default extended header name pattern ("%d/PaxHeaders.%p/%f")
# would contain a process ID that makes tarball non-deterministic.
# "git archive" would store a commit ID in pax global header (named
# "pax_global_header"). We can do similar.
# GNU tar (<=1.30) has a bug that it rejects globexthdr.mtime that
# contains fraction of seconds.
pax_options=$(printf '%s%s%s%s%s%s' \
"globexthdr.name=pax_global_header," \
"globexthdr.mtime={$(echo ${date}|sed -e 's/\.[0-9]*Z/Z/g')}," \
"comment=${revision}," \
"exthdr.name=%d/PaxHeaders/%f," \
"delete=atime," \
"delete=ctime")
find "$dist_name" \
\( -type d -exec printf '%s/\n' '{}' \; \) -o -print |
LC_ALL=C sort |
tar -c --no-recursion --format=pax --owner=root:0 --group=root:0 \
--pax-option="$pax_options" -f "${tar_name}.tar" -T -
# Compression (gzip/xz) can add additional non-deterministic factors.
# xz format does not store file name or timestamp...
trap 's=$?; rm -f "${tar_name}.tar.xz" || : ; exit $s' 1 2 3 15
xz -9e -k "${tar_name}.tar"
# ...but for gzip, you need either --no-name option or feed the input
# from stdin. This example uses former, and also tries advdef to
# optimize compression if available.
trap 's=$?; rm -f "${tar_name}.tar.gz" || : ; exit $s' 1 2 3 15
gzip --no-name -9 -k "${tar_name}.tar" &&
{ advdef -4 -z "${tar_name}.tar.gz" || : ; }