Package: svn-buildpackage Version: 0.6.23 Followup-For: Bug #501379 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA224
Hey, I was wondering about the same and tried to implement such a feature. Well, it's not that easy and the attached diff is *definitely* not really usable yet but it changes a bit and seems to work for a few things at least: * "svn-inject -b branch" would import the source to the specified branch instead of trunk and checkout the same directory * "svn-upgrade -b branch" would upgrade the specified branch instead of trunk * svn-buildpackage should be usable in a checkout of branches/foo Again: this is *not* ready but maybe it's a start for a new great feature. Hauke -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iFYEARELAAYFAkkm33kACgkQGOp6XeD8cQ2g+ADbBCi5DXVwGOoumFKqTWR5Z0yK rZHJnWuFsq6rCQDeMgum1Fj67D44wrt9F2+XERdnvR6LrX2X+gQ/1g== =pWIO -----END PGP SIGNATURE-----
diff -Naur svn-buildpackage-0.6.23~/SDCommon.pm svn-buildpackage-0.6.23/SDCommon.pm --- svn-buildpackage-0.6.23~/SDCommon.pm 2008-11-20 18:19:57.806536457 +0100 +++ svn-buildpackage-0.6.23/SDCommon.pm 2008-11-21 13:55:13.331035157 +0100 @@ -314,7 +314,7 @@ open(INFOC, "env LC_ALL=C svn info debian/changelog |"); @junk=<INFOC>; if(!close(INFOC)) { - exwerror "Not started from the Trunk directory or not a valid SVN repository. Aborting.\n"; + exwerror "Not started from the a valid directory (trunk or branches/something) or not a valid SVN repository. Aborting.\n"; } # `head -n1 debian/changelog` =~ /^(\S+)\s*\((.+)\)/; @@ -347,7 +347,7 @@ debian/changelog.\n" if $SDCommon::opt_verbose; } else { - exwerror "E: Not started from the trunk/PACKAGE directory (debian/changelog garbled?).\n"; + exwerror "E: Not started from the trunk/branches/PACKAGE directory (debian/changelog garbled?).\n"; } print " Package name: $SDCommon::package @@ -439,12 +439,12 @@ # always redetect them; keep them in the same config base just for the # record - $SDCommon::c{"trunkUrl"}=url("."); - if($SDCommon::c{"trunkUrl"}) { - $SDCommon::c{"trunkDir"}=getcwd; + $SDCommon::c{"workingUrl"}=url("."); + if($SDCommon::c{"workingUrl"}) { + $SDCommon::c{"workingDir"}=getcwd; } else { - exwerror "We are not in a working copy of SVN trunk directory"; + exwerror "We are not in a working copy of SVN trunk or branches/something directory"; } foreach(values(%SDCommon::c)) { @@ -534,7 +534,10 @@ # yourself with appropriate message. sub load_dirs { my $url=shift; - my $tmpdir=Cwd::abs_path(shift); + $url .= "/trunk" unless ($url =~ /(trunk|branches\/\w+)/); + my $tmpdir=shift; + # XXX: doesn't work with new branches; don't know why, yet +# my $tmpdir=Cwd::abs_path($td); my @src; while(@_) { push(@src, Cwd::abs_path(shift)); } @@ -543,7 +546,8 @@ if( ! withechoNoPrompt("svn", "co", $url, $tmpdir) ) { # svn sucks here, import does create subdirs, but mkdir has no -p switch withecho "mkdir", "-p", $tmpdir; - withecho("svn", "-m", "Creating trunk directory", "import", $tmpdir, $url); + #withecho("svn", "-m", "Creating trunk directory", "import", $tmpdir, $url); + withecho("svn", "-m", "Importing data to repository", "import", $tmpdir, $url); unlink $tmpdir; withecho("svn", "co", $url, $tmpdir); } diff -Naur svn-buildpackage-0.6.23~/svn-buildpackage svn-buildpackage-0.6.23/svn-buildpackage --- svn-buildpackage-0.6.23~/svn-buildpackage 2008-11-20 18:19:57.830536837 +0100 +++ svn-buildpackage-0.6.23/svn-buildpackage 2008-11-20 21:09:26.172359320 +0100 @@ -19,7 +19,7 @@ Usage: svn-buildpackage [ OPTIONS... ] [ OPTIONS for dpkg-buildpackage ] Builds Debian package within the SVN repository. The source code repository must be in the format created by svn-inject, and this script -must be executed from the work directory (trunk/package). +must be executed from the work directory (trunk or branches/something). Building and working directory management: --svn-builder CMD Use CMD as build command instead of dpkg-buildpackage @@ -37,7 +37,7 @@ Tagging and post-tagging: --svn-tag Final build: Export && build && tag && dch -i --svn-retag Replace an existing tag directory if found while tagging - --svn-only-tag Tags the current trunk directory without building + --svn-only-tag Tags the current working directory without building --svn-noautodch Don't add a new Debian changelog entry when done Post-build processing: --svn-lintian Run lintian after the build @@ -302,9 +302,9 @@ if($opt_only_tag) { checktag; - chdir $$c{"trunkDir"}; + chdir $$c{"workingDir"}; system "$opt_pretag" if($opt_pretag); - withecho ("svn", "-m", "$scriptname Tagging $package ($tagVersion)", "cp", $$c{"trunkUrl"}, $$c{"tagsUrl"}."/$tagVersion"); + withecho ("svn", "-m", "$scriptname Tagging $package ($tagVersion)", "cp", $$c{"workingUrl"}, $$c{"tagsUrl"}."/$tagVersion"); system "$opt_posttag" if($opt_posttag); dchIfNeeded; SDCommon::sd_exit 0; @@ -475,21 +475,21 @@ } } if($opt_nolinks || $opt_ignnew) { - withecho ("svn", "--force", "export", $$c{"trunkDir"},"$bdir"); + withecho ("svn", "--force", "export", $$c{"workingDir"},"$bdir"); } else { mkdir $bdir; #fixme maybe rewrite to withecho if( !withechoNoPrompt("mkdir","-p", map { "$bdir/$_" } @dirs) || !withechoNoPrompt("cp", "--parents", "-laf", @files, $bdir)) { # cp failed... - withecho "svn", "--force", "export", $$c{"trunkDir"},"$bdir"; + withecho "svn", "--force", "export", $$c{"workingDir"},"$bdir"; } } withecho "rm", "-rf", "$ba/tmp-$mod"; } else { if($opt_nolinks) { - withecho "svn","--force", "export",$$c{"trunkDir"},"$bdir"; + withecho "svn","--force", "export",$$c{"workingDir"},"$bdir"; } else { mkdir $bdir; @@ -502,7 +502,7 @@ #if(system ("cp", "--parents", "-laf", @files, $bdir)) { # cp failed... system "rm", "-rf", $bdir; - withecho "svn", "--force", "export",$$c{"trunkDir"},$bdir; + withecho "svn", "--force", "export",$$c{"workingDir"},$bdir; } } } @@ -515,18 +515,18 @@ my $dirname="$package-$upVersion"; needs_upsCurrentUrl; - if(`env LC_ALL=C svn status $$c{"trunkDir"}` =~ /(^|\n)(A|M|D)/m) { + if(`env LC_ALL=C svn status $$c{"workingDir"}` =~ /(^|\n)(A|M|D)/m) { print STDERR "Warning, uncommited changes found, using combinediff to merge them...\n"; chomp($afile=`mktemp`); chomp($bfile=`mktemp`); chomp($cfile=`mktemp`); - withecho "svn diff ".$$c{"upsCurrentUrl"}." ".$$c{"trunkUrl"}." > $afile"; - withecho "cd ".$$c{"trunkDir"}." ; svn diff > $bfile"; + withecho "svn diff ".$$c{"upsCurrentUrl"}." ".$$c{"workingUrl"}." > $afile"; + withecho "cd ".$$c{"workingDir"}." ; svn diff > $bfile"; withecho "combinediff $afile $bfile > $cfile"; open(DIFFIN, "cat $cfile |"); } else { - open(DIFFIN, "svn diff ".$$c{"upsCurrentUrl"}." ".$$c{"trunkUrl"}." |"); + open(DIFFIN, "svn diff ".$$c{"upsCurrentUrl"}." ".$$c{"workingUrl"}." |"); } open(DIFFOUT,">$tmpfile"); # fix some diff junk @@ -621,9 +621,9 @@ if($opt_tag) { system "$opt_pretag" if($opt_pretag); checktag; - withecho ("svn", "-m", "$scriptname Tagging $package ($tagVersion)", "cp", $$c{"trunkUrl"}, $$c{"tagsUrl"}."/$tagVersion"); + withecho ("svn", "-m", "$scriptname Tagging $package ($tagVersion)", "cp", $$c{"workingUrl"}, $$c{"tagsUrl"}."/$tagVersion"); system "$opt_posttag" if($opt_posttag); - chdir $$c{"trunkDir"}; + chdir $$c{"workingDir"}; dchIfNeeded; } diff -Naur svn-buildpackage-0.6.23~/svn-inject svn-buildpackage-0.6.23/svn-inject --- svn-buildpackage-0.6.23~/svn-inject 2008-11-20 18:19:57.726538301 +0100 +++ svn-buildpackage-0.6.23/svn-inject 2008-11-21 16:34:49.239245116 +0100 @@ -32,6 +32,7 @@ --no-branches Like -o but never tracking upstream branch -s Save the detected layout configuration (has effect only if a checkout is done after the inject) + -b <branch> Don't inject to trunk but the given branch If the base repository URL is omited, svn-inject tries to get it from the current directory. In this case, -c becomes ineffective. @@ -61,6 +62,7 @@ my $opt_nobranches; my $opt_savecfg; my $opt_dbgsdcommon; +my $opt_branch; #my $opt_trackmode; # parse Command line @@ -77,7 +79,8 @@ "c=i" => \$opt_checkout, "O|no-branches" => \$opt_nobranches, "s" => \$opt_savecfg, - "dbgsdcommon" => \$opt_dbgsdcommon + "dbgsdcommon" => \$opt_dbgsdcommon, + "b=s" => \$opt_branch, ); if (!defined $opt_dbgsdcommon) { @@ -105,7 +108,7 @@ my $testfile=`mktemp`; chomp $testfile; open (O, ">$testfile"); - print O '#!/bin/sh\necho ok\n'; + print O "#!/bin/sh\necho ok\n"; close O; print "Checking if the default \$TMPDIR allows execution...\n" ; if (system ("chmod", "+x", "$testfile") and (`$testfile`) =~ /ok/ ) { @@ -122,6 +125,7 @@ die "-c 2 only works with -t 1\n" if($opt_checkout==2 && $opt_layout!=1); +# I'll leave the trunk stuff here for the moment if($opt_dolike) { if (!$opt_svnurl) { $opt_svnurl=url($opt_dolike); @@ -161,6 +165,8 @@ die "Dsc file $opt_dsc not readable!\n" if (! -r $opt_dsc); +die "A new branch must not be in \"branches/upstream\"!" if ($opt_branch =~ /upstream/); + chomp(my $tempdir=`mktemp -d`); $opt_dsc = long_path($opt_dsc); @@ -225,14 +231,17 @@ die "$basedir/$package already exists, aborting...\n"; } +#XXX undefined if deb-native $dscDiff=long_path($dscDiff); +#XXX undefined if deb-native if($dscOrig) { $opt_tardir=long_path($opt_tardir ? $opt_tardir : "$basedir/tarballs"); mkdir $opt_tardir if(!-d $opt_tardir); withechoNoPrompt("cp", "-l", $dscOrig, $opt_tardir) || withecho("cp", $dscOrig, $opt_tardir); } +#XXX undefined if deb-native $SDCommon::c{"origDir"}=long_path($opt_tardir); my %ourfiles; @@ -253,23 +262,25 @@ chdir $tempdir; -my ($subupsCurrent, $subtrunk, $subupsVersion, $subtags, $subupsTags); +my ($subupsCurrent, $subworking, $subupsVersion, $subtags, $subupsTags); if ($opt_layout == 1) { $subupsCurrent="$package/branches/upstream/current"; $subupsVersion="$package/branches/upstream/$upsVersion"; $subupsTags="$package/branches/upstream"; - $subtrunk="$package/trunk"; + $subworking="$package/trunk"; + $subworking="$package/branches/$opt_branch" if ($opt_branch); $subtags="$package/tags"; } else { $subupsCurrent="branches/upstream/$package/current"; $subupsVersion="branches/upstream/$package/$upsVersion"; $subupsTags="branches/upstream/$package"; - $subtrunk="trunk/$package"; + $subworking="$package/trunk"; + $subworking="$package/branches/$opt_branch" if ($opt_branch); $subtags="tags/$package"; } -$SDCommon::c{"trunkUrl"} = "$opt_svnurl/$subtrunk"; +$SDCommon::c{"workingUrl"} = "$opt_svnurl/$subworking"; $SDCommon::c{"tagsUrl"} = "$opt_svnurl/$subtags"; $SDCommon::c{"upsCurrentUrl"}="$opt_svnurl/$subupsCurrent"; $SDCommon::c{"upsTagUrl"}="$opt_svnurl/$subupsTags"; @@ -289,21 +300,21 @@ if($#filesInside > 0) { # my favorite cruft, orig tarballs without the single top level # directory. Create an extra directory for them rather then renaming - # the dir into "current" - mkdir "current"; + # the dir into $upsVersion + mkdir "$upsVersion"; } - withecho("mv",@filesInside, "current"); + withecho("mv",@filesInside, "$upsVersion"); if($opt_onlychanged) { - chdir "current" || die "Internal operation error, unable to create local import directory\n"; # code 42, stop before unlinking anything + chdir "$upsVersion" || die "Internal operation error, unable to create local import directory\n"; # code 42, stop before unlinking anything del_unreferenced(".", %ourfiles); } } else { # native packages are easier - my $dir = dirname ("$subtrunk") ; - my $base = basename("$subtrunk") ; + my $dir = dirname ("$subworking") ; + my $base = basename("$subworking") ; withecho "mkdir", "-p", $dir; chdir $dir; withecho "dpkg-source -x $opt_dsc"; @@ -320,14 +331,14 @@ &printImportDetails; - # for non-native packages the source is in uptream/current + # for non-native packages the source is in uptream/upsVersion if ($dscOrig) { withecho ("svn", $opt_svnquiet, "import", "-m", "$scriptname Installing original source of $package", "$subupsTags", $SDCommon::c{"upsTagUrl"} ); } else { withecho ("svn", $opt_svnquiet, "import", "-m", "$scriptname Installing original source of $package", - "$subtrunk", "$opt_svnurl/$subtrunk" ); + "$subworking", "$opt_svnurl/$subworking" ); } ; } @@ -335,21 +346,24 @@ # make sure all directories up to that level are created SDCommon::svnMkdirP ( $SDCommon::c{"tagsUrl"} ) ; -# for non-native: create the trunk copy from the source and modify it +my $tempwork; + +# for non-native: create the working copy from the source and modify it if($dscOrig) { if($changed_non_debian>0 || !$opt_onlychanged) { + # ONLY if not for a new branch withecho("svn", "-m", "$scriptname Tagging upstream source version of $package", "copy", - "$opt_svnurl/$subupsCurrent", - "$opt_svnurl/$subupsVersion", $opt_svnquiet); + "$opt_svnurl/$subupsVersion", + "$opt_svnurl/$subupsCurrent", $opt_svnquiet) unless($opt_branch); # the destination directory must not exist, but all up to the last level must be there - SDCommon::svnMkdirP ( dirname("$opt_svnurl/$subtrunk") ) ; - withecho("svn", "-m", "$scriptname Forking $package source to Trunk", "copy", - "$opt_svnurl/$subupsCurrent", - "$opt_svnurl/$subtrunk", $opt_svnquiet); + SDCommon::svnMkdirP ( dirname("$opt_svnurl/$subworking") ) ; + withecho("svn", "-m", "$scriptname Forking $package source to working directory (trunk/branches)", "copy", + "$opt_svnurl/$subupsVersion", + "$opt_svnurl/$subworking", $opt_svnquiet); } mkdir "unpdir"; @@ -362,30 +376,34 @@ chdir $dirname; withecho "fakeroot debian/rules clean || debian/rules clean"; del_unreferenced(".", %ourfiles) if $opt_onlychanged; - load_dirs( "$opt_svnurl/$subtrunk", "$tempdir/trunk", "$tempdir/unpdir/$dirname"); + $tempwork="$tempdir/trunk"; + $tempwork="$tempdir/branches/$opt_branch" if ($opt_branch); + load_dirs( "$opt_svnurl/$subworking", "$tempwork", "$tempdir/unpdir/$dirname"); if ($opt_onlychanged) { - withecho "svn", "propset", "mergeWithUpstream", 1, "$tempdir/trunk/debian"; + withecho "svn", "propset", "mergeWithUpstream", 1, "$tempwork/debian"; } &printImportDetails; - withecho("svn", "commit", "-m", "$scriptname Applying Debian modifications to trunk", "$tempdir/trunk"); + withecho("svn", "commit", "-m", "$scriptname Applying Debian modifications to working directory", "$tempwork"); } chdir $basedir; -my $trunkdir; +my $workingdir; if($use_this_repo) { # FIXME: this doesn't take layout into account, does it? - $trunkdir = "$package/trunk"; + # NB: no :) + $workingdir="$package/trunk"; + $workingdir="$package/branches/$opt_branch" if ($opt_branch); withecho "svn up"; -} -else { +} else { if($opt_checkout==2) { # checkout everything if ($opt_layout==1) { - $trunkdir = "$basedir/$package/trunk"; + $workingdir="$basedir/$package/trunk"; + $workingdir="$basedir/$package/branches/$opt_branch" if ($opt_branch); print "Storing copy of your repository tree in $basedir/$package.\n"; withecho "svn", "checkout", "$opt_svnurl/$package", "$basedir/$package", $opt_svnquiet; } @@ -396,19 +414,19 @@ }; if ($opt_checkout==1) { - my $svnloc = $SDCommon::c{"trunkUrl"}; - $trunkdir = "$basedir/$package"; - print "Storing trunk copy in $basedir/$package.\n"; - #withecho("cp", "-a", "$tempdir/trunk", $trunkdir); + my $svnloc = $SDCommon::c{"workingUrl"}; + $workingdir = "$basedir/$package"; + print "Storing working copy in $basedir/$package.\n"; + #withecho("cp", "-a", "$tempwork", $workingdir); withecho "svn", "checkout", "$svnloc", "$basedir/$package", $opt_svnquiet ; }; } -chdir $trunkdir if($trunkdir); +chdir $workingdir if($workingdir); SDCommon::writeCfg ".svn/deb-layout" if($opt_checkout>0); print "Done!\n"; -print ("Your working directory is $trunkdir - have fun!\n") if($trunkdir); +print ("Your working directory is $workingdir - have fun!\n") if($workingdir); sub END { if ($tempdir && -e $tempdir) { diff -Naur svn-buildpackage-0.6.23~/svn-upgrade svn-buildpackage-0.6.23/svn-upgrade --- svn-buildpackage-0.6.23~/svn-upgrade 2008-11-20 18:19:58.358537760 +0100 +++ svn-buildpackage-0.6.23/svn-upgrade 2008-11-21 16:24:55.891378253 +0100 @@ -19,6 +19,8 @@ repository must be in the format created by svn-inject. -V, --upstreamversion STRING Forces a different upstream version string + -b, --branch STRING Use the given branch as the target instead + of trunk -c, --clean generic cleanup of upstream source - remove debian directory and object files -f, --force Force execution of certain operations @@ -50,6 +52,7 @@ my $opt_noninteractive; my $opt_ignoreerrors; my $opt_dbgsdcommon; +my $opt_branch; my %options = ( "h|help" => \$opt_help, @@ -62,7 +65,8 @@ "N|noautodch" => \$opt_noautodch, "noninteractive" => \$opt_noninteractive, "ignoreerrors" => \$opt_ignoreerrors, - "dbgsdcommon" => \&opt_dbgsdcommon + "dbgsdcommon" => \&opt_dbgsdcommon, + "b|branch=s" => \$branch ); my $retval = 0; @@ -240,7 +244,7 @@ Could not find the unmodified upstream version in $upsOldVersUrl! If you think that $$c{upsCurrentUrl} is the upstream source - which $$c{trunkUrl} is based on, run: + which $$c{workingDir} is based on, run: svn copy $$c{upsCurrentUrl} $upsOldVersUrl @@ -318,7 +322,7 @@ load_dirs($$c{"upsCurrentUrl"}, "$tmpdir/upsCurDir", "$tmpdir/$srcdir"); withecho("svn", "commit", "-m", "$scriptname Integrating new upstream version, $package ($upsVersion)", "$tmpdir/upsCurDir"); withecho("svn", "copy", "-m", "$scriptname Tagging new upstream version, $package ($upsVersion)", $$c{"upsCurrentUrl"}, $$c{"upsTagUrl"}."/$upsVersion"); - chdir $$c{"trunkDir"}; + chdir $$c{"workingDir"}; if($mergemode) { # allow to fail, eg. if upstream dir is there but empty withechoNoPrompt("svn","merge", $upsOldVersUrl, $$c{"upsCurrentUrl"}, "."); @@ -329,7 +333,7 @@ withechoNoPrompt "svn up"; } else { - chdir $$c{"trunkDir"}; + chdir $$c{"workingDir"}; } open(SVN, "env LC_ALL=C svn status|") or die ("Failed tu run `svn status`: $!");