Diranged;250685 Wrote: 
> That probably does occur... and should be fixed. Though its not a big
> issue, since that was a use-case that never existed before. When you
> ran --snapshot, your version was always overwritten ... no matter what.
> Now I'm just allowing the ability to force the version-name for the
> purpose of building the RPM in a yum-ified way.

OK, so then you can't build both the RPM and the tarball in the same
run of makerelease.pl, right?

Anyway, here's a pretty simple patch that does the following:
- Restore the previous $version behavior for non-RPMs.  Running with
"--snapshot --version 7.0.0" will now build the RPM and both tarballs.
- Don't build a third, different tarball for the RPM.  Use the one we
just made instead.
- Pass information into the RPM with the macros and eliminate the
patching of the specfile.


Code:
--------------------
    Index: platforms/redhat/squeezecenter.spec
  ===================================================================
  --- platforms/redhat/squeezecenter.spec (revision 15548)
  +++ platforms/redhat/squeezecenter.spec (working copy)
  @@ -18,26 +18,29 @@
  %define build_release %{?_with_release:1}0
  
  %if %{build_trunk}
  +%define src_basename SqueezeCenter_trunk_v%{_src_date}
  %define rpm_release 0.%{increment}.%{_rpm_date}
  %endif
  %if %{build_branch}
  +%define src_basename SqueezeCenter_%{_branch}_v%{_src_date}
  %define rpm_release 0.%{increment}.%{_rpm_date}
  %endif
  %if %{build_release}
  +%define src_basename SqueezeCenter_v%{_version}
  %define rpm_release 1
  %endif
  
  
  Name:          squeezecenter           
  Packager:      Slim Devices/Logitech <[EMAIL PROTECTED]>
  -Version:       _VERSION_
  +Version:       %{_version}
  Release:       %{rpm_release}
  Summary:        SqueezeCenter Music Server
  
  Group:         System Environment/Daemons          
  License:       GPL and proprietary        
  URL:           http://www.slimdevices.com            
  -Source0:       _SOURCE_
  +Source0:       %{src_basename}.tar.gz
  Source1:       squeezecenter.config
  Source2:       squeezecenter.init
  Source3:       squeezecenter.logrotate
  @@ -58,7 +61,7 @@
  
  
  %prep
  -%setup -q -n _SOURCEFILE_
  +%setup -q -n %{src_basename}
  
  
  %build
  Index: makerelease.pl
  ===================================================================
  --- makerelease.pl      (revision 15548)
  +++ makerelease.pl      (working copy)
  @@ -38,7 +38,7 @@
  'linux'   => \&buildLinux,
  );
  
  -my ($snapshot, $version, $title, $buildDir, $destDir, $sourceDir, 
$sourceCopy, $humanTitle);
  +my ($rpmVersion, $snapshot, $version, $title, $buildDir, $destDir, 
$sourceDir, $sourceCopy, $humanTitle);
  
  sub main {
  
  @@ -74,11 +74,8 @@
  
  if ($snapshot) {
  
  -               ## If we're doing a snapshot, but a version has been 
explicitly 
  -               ## configured, always use the explicitly configured data.
  -               if (!$version) { 
  -                       $version = strftime('%Y-%m-%d', localtime());
  -               }
  +               $rpmVersion = $version;
  +               $version = strftime('%Y-%m-%d', localtime());
  
  if ($branch) {
  $title      = "${prefix}_${branch}_v$version";
  @@ -464,8 +461,6 @@
  
  # this must be a unix system
  # make the RPM if appropriate
  -       my $rpmVersion = $version;
  -          $rpmVersion =~ s/-/_/g;
  
  if (!File::Which::which('rpmbuild')) {
  
  @@ -473,12 +468,6 @@
  return;
  }
  
  -       # remove bits that don't need to be in the RPM
  -       my $match = qr/(?:darwin|MSWin32|powerpc-hardhat-linux)/i;
  -
  -       removeDirectoriesMatching("$sourceCopy/server/Bin", $match);
  -       removeDirectoriesMatching("$sourceCopy/server/CPAN/arch/5.8", $match);
  -
  print "Making version $rpmVersion RPM in $buildDir..\n";
  
  # make a destination dir for the RPM
  @@ -487,35 +476,18 @@
  mkpath("$buildDir/rpm/$path");
  }
  
  +       # Use the tarball we just made
  +       copy("$destDir/$title.tar.gz", "$buildDir/rpm/SOURCES");
  +
  copy("$sourceDir/platforms/redhat/squeezecenter.config", 
"$buildDir/rpm/SOURCES");
  copy("$sourceDir/platforms/redhat/squeezecenter.init", 
"$buildDir/rpm/SOURCES");
  copy("$sourceDir/platforms/redhat/squeezecenter.logrotate", 
"$buildDir/rpm/SOURCES");
  -
  -       open (READ, "$sourceDir/platforms/redhat/squeezecenter.spec") || die 
"Can't open spec file to read: $!\n";
  -       open (WRITE, ">$buildDir/rpm/SPECS/squeezecenter.spec") ||  die 
"Can't open spec file to write: $!\n";
  -
  -       while (<READ>) {
  -               s/_VERSION_/$rpmVersion/;
  -               s/_SOURCE_/build.tar/;
  -               s/_TOPDIR_/$buildDir\/rpm/;
  -               s/_SOURCEFILE_/server/;
  -               print WRITE $_;
  -       }
  -
  -       close WRITE;
  -       close READ;
  -
  -       print "Making Linux tarball...";
  -
  -       print "executing: cd $buildDir/$title; tar cf 
$buildDir/rpm/SOURCES/build.tar server\n";
  -       system "cd $buildDir/$title; tar cf $buildDir/rpm/SOURCES/build.tar 
server";
  -
  -       print "  done.\n";
  +       copy("$sourceDir/platforms/redhat/squeezecenter.spec", 
"$buildDir/rpm/SPECS");
  
  # Do it
  my $date = strftime('%Y-%m-%d', localtime());
  my $shortdate = strftime('%Y%m%d', localtime());
  -       `rpmbuild -bb --with trunk --define="_src_date $date" 
--define="_rpm_date $shortdate" --define='_topdir $buildDir/rpm' 
$buildDir/rpm/SPECS/squeezecenter.spec`;
  +       `rpmbuild -bb --with trunk --define="_version $rpmVersion" 
--define="_src_date $date" --define="_rpm_date $shortdate" --define='_topdir 
$buildDir/rpm' $buildDir/rpm/SPECS/squeezecenter.spec`;
  
  ## We used to rename the file here... instead, just move it to the right 
location.
  ## We leave the file un-renamed for the Yum repository to continue to be 
valid.
  
--------------------


Tested, but not checked in yet.


-- 
Fletch
------------------------------------------------------------------------
Fletch's Profile: http://forums.slimdevices.com/member.php?userid=529
View this thread: http://forums.slimdevices.com/showthread.php?t=41217

_______________________________________________
beta mailing list
[email protected]
http://lists.slimdevices.com/lists/listinfo/beta

Reply via email to