+ close IN;
+ die "Unable to determine protocol_version for $lastversion.\n" unless defined $last_protocol_version;
+
+ my($protocol_version,$subprotocol_version);
+ open(IN, '<', 'rsync.h') or die "Unable to open rsync.h: $!\n";
+ while (<IN>) {
+ if (/^#define\s+PROTOCOL_VERSION\s+(\d+)/) {
+ $protocol_version = $1;
+ } elsif (/^#define\s+SUBPROTOCOL_VERSION\s+(\d+)/) {
+ $subprotocol_version = $1;
+ }
+ }
+ close IN;
+ die "Unable to determine the current PROTOCOL_VERSION.\n" unless defined $protocol_version;
+ die "Unable to determine the current SUBPROTOCOL_VERSION.\n" unless defined $subprotocol_version;
+
+ if ($confversion =~ /dev|pre/) {
+ if ($last_protocol_version ne $protocol_version) {
+ if ($subprotocol_version == 0) {
+ die "SUBPROTOCOL_VERSION must not be 0 for a non-final release with a changed PROTOCOL_VERSION.\n";
+ }
+ } else {
+ if ($subprotocol_version != 0) {
+ die "SUBPROTOCOL_VERSION must be 0 when the PROTOCOL_VERSION hasn't changed from the last release.\n";
+ }
+ }
+ } else {
+ if ($subprotocol_version != 0) {
+ die "SUBPROTOCOL_VERSION must be 0 for a final release.\n";
+ }
+ }
+
+ print "Creating $name.tar.gz\n";
+ system "rsync -a @extra_files $name/";
+ system "git archive --format=tar --prefix=$name/ HEAD | tar xf -";
+ system "support/git-set-file-times --prefix=$name/";
+ system "fakeroot tar czf $dest/$name.tar.gz $name; rm -rf $name";
+