From 6c65f35cc84cd80125622e87c74d0c16a21c146b Mon Sep 17 00:00:00 2001 From: Mystery Man Date: Wed, 30 Jan 2002 13:16:47 +0000 Subject: New repository initialized by cvs2svn. --- ChangeLog | 398 ------------------------ Makefile | 75 ----- rpmbuildupdate | 671 ----------------------------------------- rpmbuildupdate.bash-completion | 49 --- rpmbuildupdate.spec | 50 --- 5 files changed, 1243 deletions(-) delete mode 100644 ChangeLog delete mode 100644 Makefile delete mode 100755 rpmbuildupdate delete mode 100644 rpmbuildupdate.bash-completion delete mode 100644 rpmbuildupdate.spec diff --git a/ChangeLog b/ChangeLog deleted file mode 100644 index 8d3c3dc..0000000 --- a/ChangeLog +++ /dev/null @@ -1,398 +0,0 @@ -2006-01-18 11:48 Michael Scherer - - * rpmbuildupdate.spec: version 0.6.1, I forgot to tag the spec - -2006-01-18 11:47 Michael Scherer - - * rpmbuildupdate.spec: version 0.6 - -2006-01-18 11:42 Michael Scherer - - * Makefile: Correct changelog generation - -2006-01-18 11:39 Michael Scherer - - * Makefile: Fix name of Makefile - -2006-01-17 11:56 Michael Scherer - - * rpmbuildupdate: - use a dedicated module instead of running the - file command, in order to fix gtkhtml downloading problem ( as - the regexp was also matching on the name ), problem spoted by - goetz. - -2006-01-09 11:05 Michael Scherer - - * rpmbuildupdate: - do not use hardcoded %packager tag in spec file - if present - -2006-01-09 11:04 Michael Scherer - - * rpmbuildupdate: - factorisation of packager email retrieval in a - function called get_email - -2005-12-16 17:43 Michael Scherer - - * rpmbuildupdate: - do not try to install '(none)' as - buildRequires, and do not run the script if nothing need to be - installed. - -2005-12-12 16:51 Michael Scherer - - * rpmbuildupdate: - use shell_quote for installbuildrequires and - execafterbuild - -2005-12-12 16:50 Michael Scherer - - * rpmbuildupdate: - fix bug when the source use a %{url} tag, like - udev.spec ( 1.136 ), thanks blino - -2005-12-09 15:15 Michael Scherer - - * rpmbuildupdate: - Do not stop when a file with the same name of - the package exist in current directory ( thanks blino ) - -2005-12-06 16:17 Michael Scherer - - * rpmbuildupdate: - add --nodownload ( oden request ) - remove some - tests on config{nobuild} that no one can explain - -2005-12-05 11:24 Michael Scherer - - * rpmbuildupdate: - if epoch is set in spec, add it to the - changelog too (oden request , bug #20007 ) - -2005-12-05 11:21 Michael Scherer - - * rpmbuildupdate: - use RPM4 instead of Hdlist - -2005-11-10 16:50 Michael Scherer - - * rpmbuildupdate: - remove obsolete, inflexible and surely unused - option --deps - -2005-11-10 11:57 Michael Scherer - - * rpmbuildupdate: - add installbuildrequires option, that will run - a command that install buildrequires before updating the rpm - -2005-10-20 11:00 Michael Scherer - - * rpmbuildupdate: - use rmtree instead of rm_rf ( to not depend on - Mdk::Common ) - -2005-10-10 23:05 Michael Scherer - - * rpmbuildupdate: - remove deps on Mdk::Common and use - File::Basename - -2005-10-10 23:00 Michael Scherer - - * rpmbuildupdate: - add return code - revert previous removal ( i - didn't test the good version ) - -2005-10-10 22:08 Michael Scherer - - * rpmbuildupdate: - remove use module import - -2005-10-06 17:53 Guillaume Rousse - - * rpmbuildupdate.spec: fix url, description and changelog - -2005-10-06 17:49 Guillaume Rousse - - * rpmbuildupdate.spec: fix sources and installation - -2005-10-06 17:45 Guillaume Rousse - - * Makefile: add ChangeLog.rpmbuildupdate - -2005-10-06 17:42 Guillaume Rousse - - * Makefile: fix changelog target - -2005-10-06 17:37 Guillaume Rousse - - * Makefile, rpmbuildupdate.spec: split rpmbuildupdate out - -2005-09-11 02:11 Frederic Lepied - - * rpmbuildupdate: Mandriva - -2005-09-01 15:40 Michael Scherer - - * rpmbuildupdate: - add .tar.Z to the list of extension to download - and test ( buchan request ) - -2005-08-27 21:32 Michael Scherer - - * rpmbuildupdate: - fix parsing of file with macro that contains a - tag ( like cyrus-imapd.spec, 1.29 , 2nd line of macro : - %{?!mdkversion: %define mdkversion %(perl -pe - '/(\\d+)\.(\\d)\.?(\\d)?/; $_="$1$2".($3||0)' - /etc/mandrake-release)} ). - -2005-04-19 10:17 Michael Scherer - - * rpmbuildupdate: - new sourceforge mirror, thanks to Götz Waschk - -2005-04-01 22:27 Michael Scherer - - * rpmbuildupdate: - fix %mkrel still being incremented when a new - version is build. - -2005-04-01 22:13 Michael Scherer - - * rpmbuildupdate: - fix cvs Id expansion - -2005-04-01 19:13 Michael Scherer - - * rpmbuildupdate: - use perl-hdlist - fix for %( macro - do not - mess with Tab - add a cvs id - -2005-02-24 09:51 Michael Scherer - - * rpmbuildupdate: - %mkrel integration - -2005-02-12 20:27 Michael Scherer - - * rpmbuildupdate: - use new bzme option in rpmbuildupdate to force - compression - -2005-02-10 16:42 Michael Scherer - - * rpmbuildupdate: - still try to download, even for rebuild ( in - case we only supply a spec file ) - -2005-02-07 17:51 Michael Scherer - - * rpmbuildupdate, rpmbuildupdate.bash-completion: - new option - execafterbuild, to run a script after build the rpm - add the - proper credit - version 0.5 - -2005-02-07 16:26 Michael Scherer - - * rpmbuildupdate: - do not hardcode path ( buchan idea ) - -2005-01-28 23:23 Guillaume Rousse - - * rpmbuildupdate.bash-completion: also complete on local files - -2005-01-09 19:33 Guillaume Rousse - - * rpmbuildupdate: cleanup usage - -2005-01-09 19:30 Guillaume Rousse - - * rpmbuildupdate: regexp cleanup - -2005-01-09 19:15 Guillaume Rousse - - * rpmbuildupdate: don't attempt to download files for simple - rebuilds - -2005-01-09 18:56 Guillaume Rousse - - * rpmbuildupdate.bash-completion: options sync - -2005-01-09 18:54 Guillaume Rousse - - * rpmbuildupdate: cleanup main function and removed useless options - -2005-01-09 16:54 Guillaume Rousse - - * rpmbuildupdate: sanitize indentation and args passing - -2004-12-29 23:28 Guillaume Rousse - - * rpmbuildupdate: --execute option - -2004-12-05 00:11 Michael Scherer - - * rpmbuildupdate: - fix bug when %%changelog is present in the spec - file - -2004-11-28 23:34 Guillaume Rousse - - * rpmbuildupdate.bash-completion: new options complete on rpm name - -2004-11-28 23:07 Guillaume Rousse - - * rpmbuildupdate: use .rpmbuildupdaterc as personal configuration - file - -2004-11-12 19:41 Michael Scherer - - * rpmbuildupdate: - fix the usage of spec file with a regular path - is given. - add more magic for project hosted on gna and other - sourceforgelike sites. - -2004-10-25 22:44 Guillaume Rousse - - * rpmbuildupdate.bash-completion: first import - -2004-10-25 06:07 Michael Scherer - - * rpmbuildupdate: - add --rpmoption, to provides options when - rebuilding - fix some escaping issue - remove old comment - -2004-10-24 19:31 Michael Scherer - - * rpmbuildupdate: - DWIM, ie autodetection of the argument ( if a - spec, build from spec, etc ) - -2004-10-24 19:08 Michael Scherer - - * rpmbuildupdate: - allow to build from a spec file - add noupdate, - to not modify the specfile - allow multiple SRPM dir for --srpms - - add berlios.de autodetection - remove some dead code - -2004-10-09 02:04 Michael Scherer - - * rpmbuildupdate: - allows to give a relative path to --src - -2004-10-09 01:52 Michael Scherer - - * rpmbuildupdate: - some perl_checker fix - allow to update php - code ( no tarball in the spec ) - -2004-09-05 04:53 Michael Scherer - - * rpmbuildupdate: - do not replace %{release} if it used in the - Release: tag. - -2004-09-05 02:04 Michael Scherer - - * rpmbuildupdate: - perl_checker fix, remove obsolete construct ( - &func ) - rebuild the package if no new version is given - add - two config file ( /etc/rpmbuildupdate.conf and - ~/.rpmbuildupdate.conf ) - add a new mirror to sourceforge ( ovh, - france ) - keep prefix (ie plfawarness ) - add a changelog option - to use another changelog message - check if options are valid and - show help if not - do not use %packager if not defined - -2004-08-30 17:17 Michael Scherer - - * rpmbuildupdate: - use rpm --eval , pterjan idea - -2004-08-17 13:35 Michael Scherer - - * rpmbuildupdate: - better autodetection of sourceforge url. - -2004-05-14 16:29 Michael Scherer - - * rpmbuildupdate: - add a test to not try to bzip2 error html pages - -2004-05-13 18:27 Michael Scherer - - * rpmbuildupdate: - replace ` and system with perl function. - - replace some regexp by basename. - remove useless wait ( system - already do 'wait', in perl ). - -2004-05-07 14:59 Michael Scherer - - * rpmbuildupdate: - do a chmod 644 on source tarball before - building ( Goetz Waschk idea ) - -2004-05-06 16:23 Frederic Lepied - - * rpmbuildupdate: add --log option - -2004-05-06 07:49 Frederic Lepied - - * rpmbuildupdate: really install depenencies - -2004-05-05 22:30 Frederic Lepied - - * rpmbuildupdate: fixed rpmmon - -2004-05-04 17:25 Michael Scherer - - * rpmbuildupdate: - try to detect sources url with Url tag if - Source not present - some code factorisation - -2004-05-04 15:50 Michael Scherer - - * rpmbuildupdate: fixed some regexp causing problems when a - whitespace is present at the end of the lines for spec files - variables - -2004-04-18 14:02 Frederic Lepied - - * rpmbuildupdate: use nodeps to avoid failure when a dependency - isn't present when building the src.rpm. - -2004-04-09 16:30 Michael Scherer - - * rpmbuildupdate: - added support to fetch and build tarballs - directly from subversion repository - added support for https - server - test the return values of system and die if any error - - workaround webserver using mod_spel and thus returning a webpage - instead of 404 - code cleanup - -2004-04-06 11:37 Frederic Lepied - - * rpmbuildupdate: create a date in the changelog entry that is - compatible with emacs rpm-spec mode. - -2004-04-06 10:57 Frederic Lepied - - * rpmbuildupdate: added GNOME magic - -2004-04-05 22:50 Frederic Lepied - - * rpmbuildupdate: correctly handle .gz in redhat package support - Release tag not in a macro - -2004-03-07 22:53 Frederic Lepied - - * rpmbuildupdate: added support for sourceforge mirrors - -2004-03-07 21:47 Frederic Lepied - - * rpmbuildupdate: allow to specify rpm top directory switch from - rawhide to fedora - -2004-02-28 13:25 Frederic Lepied - - * rpmbuildupdate: use getpwuid instead of directly parsing passwd - to support NIS - -2003-08-28 17:09 Julien Danjou - - * rpmbuildupdate: --deps now works - -2003-08-26 15:23 Julien Danjou - - * rpmbuildupdate: More comments :) - -2003-08-06 15:35 Julien Danjou - - * rpmbuildupdate: Add --nosource and --deps - -2003-08-05 17:35 Julien Danjou - - * rpmbuildupdate: fix some bugs - -2003-07-18 11:59 Julien Danjou - - * rpmbuildupdate: Adding Rawhide mode some fixes - -2003-07-15 10:26 Julien Danjou - - * rpmbuildupdate: Remove exit() - -2003-07-11 16:40 Julien Danjou - - * rpmbuildupdate: version 0.2 - -2003-07-11 08:55 Frederic Lepied - - * rpmbuildupdate: put the default mount point like on the - compilation cluster. use %_topdir to find the root of the rpm - tree. use bzme to transform .gz in .bz2. - -2003-07-08 16:54 uid634 - - * rpmbuildupdate: Script for auto building up to date RPMs - diff --git a/Makefile b/Makefile deleted file mode 100644 index a9fd280..0000000 --- a/Makefile +++ /dev/null @@ -1,75 +0,0 @@ -#--------------------------------------------------------------- -# Project : Linux-Mandrake -# Module : rpmbuildupdate -# File : Makefile -# Version : $Id$ -# Author : Guillaume Rousse -# Created On : Sun Oct 1 19:26:37 2000 -#--------------------------------------------------------------- - -BINFILES=rpmbuildupdate -OTHERFILES=Makefile rpmbuildupdate.spec rpmbuildupdate.bash-completion ChangeLog.rpmbuildupdate -FILES=$(BINFILES) $(OTHERFILES) - -PACKAGE=rpmbuildupdate -VERSION:=$(shell rpm -q --qf %{VERSION} --specfile $(PACKAGE).spec) -RELEASE:=$(shell rpm -q --qf %{RELEASE} --specfile $(PACKAGE).spec) -TAG := $(shell echo "V$(VERSION)_$(RELEASE)" | tr -- '-.' '__') - -all: - @echo "nothing to be done for $(PACKAGE)-$(VERSION)-$(RELEASE)" - -install: - mkdir -p $(RPM_BUILD_ROOT)/usr/bin - install -m 755 $(BINFILES) $(RPM_BUILD_ROOT)/usr/bin - mkdir -p $(RPM_BUILD_ROOT)/etc/bash_completion.d - install -m 644 rpmbuildupdate.bash-completion $(RPM_BUILD_ROOT)/etc/bash_completion.d/rpmbuildupdate - -clean: cleandist - rm -f *~ - -# rules to build a test rpm - -localrpm: localdist buildrpm - -localdist: cleandist dir localcopy tar - -cleandist: - rm -rf $(PACKAGE)-$(VERSION) $(PACKAGE)-$(VERSION).tar.bz2 - -dir: - mkdir $(PACKAGE)-$(VERSION) - -localcopy: - tar c $(FILES) | tar x -C $(PACKAGE)-$(VERSION) - -tar: - tar cvf $(PACKAGE)-$(VERSION).tar $(PACKAGE)-$(VERSION) - bzip2 -9vf $(PACKAGE)-$(VERSION).tar - rm -rf $(PACKAGE)-$(VERSION) - -buildrpm: - rpm -ta $(PACKAGE)-$(VERSION).tar.bz2 - -# rules to build a distributable rpm - -rpm: changelog cvstag dist buildrpm - -dist: cleandist dir export tar - -export: - cvs export -d $(PACKAGE)-$(VERSION) -r $(TAG) $(PACKAGE) - -cvstag: - cvs tag $(CVSTAGOPT) $(TAG) - -changelog: ../common/username - cvs2cl -U ../common/username -I ChangeLog - rm -f ChangeLog.bak - cvs commit -m "Generated by cvs2cl the `date '+%d_%b'`" ChangeLog - -# Local variables: -# mode: makefile -# End: -# -# Makefile ends here diff --git a/rpmbuildupdate b/rpmbuildupdate deleted file mode 100755 index 9d64ebc..0000000 --- a/rpmbuildupdate +++ /dev/null @@ -1,671 +0,0 @@ -#!/usr/bin/perl -w -# -# rpmbuildupdate by Julien Danjou -# -# Copyright (c) 2003-2005 by Mandriva -# -# Permission to use, copy, modify, and distribute this software and its -# documentation under the terms of the GNU General Public License is hereby -# granted. No representations are made about the suitability of this software -# for any purpose. It is provided "as is" without express or implied warranty. -# See the GNU General Public License for more details. -# -# $Id$ - -# TODO -# rework configuration option -# add debian url ( like gnome or rh ) => cannot be done i think -# use more Hdlist ( see Hdlist->build() ) -# see if use force ( for RPM4::Spec ) could help when we buld a spec file from scrath - -# list of the return code : -# 255 => usage -# 6 => cannot open the spec file -# 5 => random problem -# 4 => a external command failed -# 2 => invalid url -# 1 => only src is build -# 0 => no error - -use strict; -use AppConfig; -use File::Basename; -use File::Copy; -use Cwd; -use File::Spec; -use File::Path; -use RPM4; -use String::ShellQuote; -use File::MimeInfo::Magic; - -my %config; - -my ($log, $top, $rpm); - -sub system_die { - my ($command, $message) = @_; - $message ||= "$command failed"; - # in case we die - $! = 4; - # do not forget , return value of 1 means failure in unix - system($command) and die $message; -} - -sub file_not_found { - my ($basename) = @_; - ! -f $basename and return 1; - # sometimes, the webserver return a webpage when the file is not found, instead of letting wget fails - # see wget http://www.wesnoth.org/files/wesnoth-0.7.1.tar.bz2 - # So if the file is a html page, then it is a error and it should be removed. - is_html($basename) and do { rmtree($basename); return 1 }; - return 0; -} - -sub is_html { - my ($basename) = @_; - mimetype($basename) =~ /HTML/i and return 1; - return 0; -} - -sub download { - my $wget = "wget -N -q"; - my ($url)=@_; - my $temp = basename($url); - print "Trying to fetch $url...\n"; - system("$wget $url;"); - -f $temp && ! is_html($temp) && $temp !~ /.bz2$/ && system_die("bzme -F $temp", "Cannot convert $temp"); -} - -sub fetch { - my ($url) = @_; - # if you add a handler here, do not forget to add it to the body of build() - return fetch_http($url) if $url =~ m!^(ftp|https?)://!; - return fetch_svn($url) if $url =~ m!^svns?://!; -} - -sub fetch_svn { - my ($url) = @_; - my ($basename, $repos); - - $basename = basename($url); - ($repos = $url) =~ s|/$basename$||; - $repos =~ s/^svn/http/; - die "Cannot extract revision number from the name." if $basename !~ /^(.*)-([^-]*rev)(\d\d*).tar.bz2$/; - my ($name, $prefix, $release) = ($1, $2, $3); - my $dir="$ENV{TMP}/rpmbuildupdate-$$"; - my $current_dir = cwd(); - mkdir $dir or die "Cannot create dir $dir"; - chdir $dir or die "Cannot change dir to $dir"; - system_die("svn co -r $release $repos", "svn checkout failed on $repos"); - my $basedir = basename($repos); - - # FIXME quite inelegant, should use a dedicated cpan module. - my $complete_name = "$name-$prefix$release"; - move($basedir, $complete_name); - system_die("find $complete_name -name '.svn' | xargs rm -Rf"); - system_die("tar -cjf $complete_name.tar.bz2 $complete_name", "tar failed"); - system_die("mv -f $complete_name.tar.bz2 $current_dir"); - chdir $current_dir; -} - -sub fetch_http { - my ($url) = @_; - my $basename = basename($url); - my $turl; - - rmtree($basename); - - download($url); - foreach ('.tar.gz', '.tgz', '.tar.Z', '.zip') { - ($turl = $url) =~ s/\.tar\.bz2/$_/; - download($turl) if file_not_found($basename); - } - return ! file_not_found($basename); -} - - -sub fill_global_variable { - my ($pkgrpm) = @_; - $top = $config{top} || RPM4::expand('%_topdir'); - chomp($top); - if ($config{log}) { - my $basename = basename($pkgrpm); - mkdir_p("$top/log"); - my $logfile = "$top/log/${basename}.log"; - $log = " >> $logfile 2>&1"; - print "Logs are in $logfile\n"; - } else { - $log = ""; - } - #TODO replace with perl-hdlist - RPM4::add_macro("_topdir $top"); - $rpm = qq(rpm --define "_topdir $top"); - $config{sourcedir} = RPM4::expand('%_sourcedir'); - chomp( $config{sourcedir}); #"$top/SOURCES"; -} - - -sub build_from_spec { - my ($spec_path, $newversion) = @_; - #TODO replace with perl-hdlist binding - my $rpm_tag = (split(/\n/,`rpm -q $config{rpmoption} --queryformat '%{NAME} %{VERSION} %{RELEASE}\n' --specfile $spec_path`))[0]; - my ($pkg, $version, $release) = split(/ /, $rpm_tag); - fill_global_variable($pkg); - $spec_path = File::Spec->rel2abs($spec_path); - - chdir($config{sourcedir}) or die "Unable to chdir to $config{sourcedir}"; - build($spec_path,$pkg,$version,$release,$newversion); -} - -sub build_from_repository { - my ($pkg, $newversion) = @_; - my $pkgrpm; - - foreach my $srpm_dir (split(/,/, $config{srpms})) { - opendir(MP, $srpm_dir) or die "$srpm_dir is not a directory"; - my @rpms = readdir(MP); - foreach (@rpms) { - if (/^\Q$pkg\E-[^-]+-[^-]+\.\w+\.rpm/) { - $pkgrpm = "$srpm_dir/$_"; - last; - } - } - closedir(MP); - last if $pkgrpm; - } - unless ($pkgrpm) { - print "Package $pkg has no source, skipping.\n\n"; - return; - } - build_from_src($pkgrpm,$newversion); -} - -sub build_from_src { - my ($pkgrpm, $newversion) = @_; - - $pkgrpm = File::Spec->rel2abs($pkgrpm); - fill_global_variable($pkgrpm); - my $found = 0; - my ($name, $version, $release); - - chdir($config{sourcedir}) or die "Unable to chdir to $config{sourcedir}"; - - my $pkgrpm_basename = basename($pkgrpm); - if ($pkgrpm_basename =~ /^(.*)-([^-]+)-([^-]+)\.\w+\.rpm/) { - $name = $1; - $version = $2; - $release = $3; - } else { - die "Cannot parse the name of rpm $pkgrpm_basename"; - } - - # TODO log, check return - my ($spec_path) = RPM4::installsrpm($pkgrpm); - build($spec_path, $name, $version, $release, $newversion); -} - -sub get_email() { - my $packager = RPM4::expand('%packager'); - my @l = getpwuid($<); - chomp($packager); - # if macro is undefined - $packager =~ s/\%packager//g; - return ( $packager ? $packager : $l[6] . ($ENV{EMAIL} ? " <$ENV{EMAIL}>" : " <$l[0]\@mandriva.com>")); - -} - -sub build { - $! = 5; - my ($spec_path, $pkg, $version, $release, $newversion) = @_; - my ($message, $spec, @url, %specvars); - my ($newrelease, $release_prefix) = ($1,$2) if $release =~ /^(.*\d+)(\D*)$/g; - my $email = get_email(); - my $hdlist_spec = RPM4::specnew($spec_path,force => 1) or die "Unable to parse spec $spec_path\n"; - if ($newversion) { - print "===> Building $pkg $newversion\n"; - } else { - print "===> Rebuilding $pkg\n"; - } - - if ( $config{installbuildrequires} ) { - my @requires = split(/\s+/, $hdlist_spec->srcheader->queryformat("[%{requires} ]")); - @requires = grep { $_ ne '(none)' } @requires; - if (@requires) { - print "===> Installing BuildRequires : @requires\n"; - system("$config{installbuildrequires} " . shell_quote @requires); - } - }; - - if (! defined($newversion)) { - $newversion = $version; - my @tmp = split(/\./,$newrelease); - $tmp[-1]++; - $newrelease = join('.',@tmp) . $release_prefix; - $message = $config{message} || '- Rebuild'; - } else { - $message = $config{message} || '- New release %%VERSION'; - $newrelease = "1$release_prefix"; - } - $newrelease = $config{release} if $config{release}; - - - my $SPECFILE; - if (!open($SPECFILE, $spec_path)) { - print STDERR "Unable to open spec file $spec_path.\n"; - $! = 6; - return; - } - - my $tar_ball=''; - - while (<$SPECFILE>) { - # Doing a s/// version - s/(\%define\s+version\s+)$version/$1$newversion/; - s/(\%define\s+release\s+)$release/$1$newrelease/; - s/Version:(\s+)$version/Version:$1$newversion/i; - s/Release:(\s+)$release/Release:$1$newrelease/i; - # TODO factorisation - # case of %define release %mkrel 2 - if ( /^(.*\s\%mkrel\s+)(\d+)(.*)$/ ) - { - $_ = "$1" . ((( $version eq $newversion ) ? $2 : 0 ) + 1 ) . "$3\n"; - } - - # case of %define release %mkrel %rel - # and %define rel 2 - if ( /^(\%define\s+rel\s+)(\d+)(.*)$/ ) - { - $_ = "$1" . ((( $version eq $newversion ) ? $2 : 0 ) + 1 ) . "$3\n"; - } - - - eval $config{execute} if $config{execute}; - - $spec .= $_; - - - # For %vars ! - $specvars{$1} = $2 if /\%define\s+(\S+?)\s+(\S+)/g; - foreach my $i ('url', 'name', 'version', 'release', 'epoch') { - $specvars{$i} = $1 if !$specvars{$i} && /\b$i\s*:\s+(\S+)/gi; - } - - if (/^Source[0-9]*:\s+(\S+)/i) { - my $source = $1; - # TODO could it be done cleanly with RPM4::expand ? - $source =~ s/\%url/$specvars{'url'}/; - $source =~ s/\%{url}/$specvars{'url'}/; - if ($source =~ /(?:ftp|svns?|https?):\/\/\S+/) { - push(@url, $source); - } else { - $tar_ball= $source unless $tar_ball; - }; - } - - if (/^\%changelog/) { - $message =~ s/\%\%VERSION/$newversion/; - my $epoch = ( $specvars{'epoch'} ? "$specvars{'epoch'}:" : "" ); - $spec .= "* " . `LC_TIME=C date '+%a %b %d %Y'|tr -d '\n'` . " $email $epoch$newversion-$newrelease\n"; - $spec .= "$message\n\n"; - } - - } - close($SPECFILE); - - - if (!$url[0]) { - print "URL of sources was not found ! Trying to guess it with url tag ...\n"; - - my $url = $specvars{url}; - # add jabberstudio, collabnet, http://www.sourcefubar.net/, http://sarovar.org/ - my @sf_like = ( { - download => 'http://prdownloads.sourceforge.net/$1/$2' , - regexp => 'http://(.*)\.(?:sourceforge|sf)\.net/?(.*)' - }, - { # to test - download => 'http://download.gna.org/$1/$2', - regexp => 'https?://gna.org/projects/([^/]*)/(.*)' - }, - { - download => 'http://download.berlios.de/$1/$2' , - regexp => 'http://(.*)\.berlios.de/(.*)' - }, - { # to test , and to merge with regular savanah ? - download => 'http://savannah.nongnu.org/download//$1/$2', - regexp => 'https?://savannah.nongnu.org/projects/([^/]*)/(.*)' - }, - { # to test - download => 'http://savannah.gnu.org/download//$1/$2', - regexp => 'https?://savannah.gnu.org/projects/([^/]*)/(.*)' - } - ); - - # http://jabberstudio.org/files/ejogger/ - # http://jabberstudio.org/projects/ejogger/project/view.php - foreach my $sf (@sf_like) { - if ($url =~ m/$sf->{regexp}/) { - $sf->{download} =~ s/^/"/; - $sf->{download} =~ s/$/"/; - $url =~ s/$sf->{regexp}/"$sf->{download}"/eeg; - } - } - - push(@url, "$url/$tar_ball") - } - my $found = 0; - - unless ($config{nodownload}) { - foreach (@url) { - # Replace variable from spec (%blabla) - while (/\%[^(]?/) { - s/\%\{?(\w+)\}?/$specvars{$1}/g; - s/\%\{name\}/$pkg/g; - s/\%\{version\}/$newversion/g; - } - - my $basename = basename($_); - rmtree("$config{sourcedir}/$basename"); - - # GNOME: add the major version to the URL automatically - # for example: ftp://ftp://ftp.gnome.org/pub/GNOME/sources/ORbit2/ORbit2-2.10.0.tar.bz2 - # is rewritten in ftp://ftp.gnome.org/pub/GNOME/sources/ORbit2/2.10/ORbit2-2.10.0.tar.bz2 - if (m!ftp.gnome.org/pub/GNOME/sources/!) { - (my $major = $newversion) =~ s/([^.]+\.[^.]+).*/$1/; - s!(.*/)(.*)!$1$major/$2!; - } - - # download from Fedora rpms - if (/ftp\.redhat\.com/) { - opendir(MP, $config{fedora}) or die "$config{fedora} is not a directory"; - my @rpmsrh = readdir(MP); - - my $pkgrpmrh; - - foreach (@rpmsrh) { - if (/^\Q$pkg\E-[^-]+-[^-]+\.\w+\.rpm/) { - $pkgrpmrh = $_; - last; - } - } - - closedir(MP); - - print "Trying from fedora($basename): $config{fedora}/$pkgrpmrh\n"; - system_die("cd $config{sourcedir}; rpm2cpio $config{fedora}/$pkgrpmrh | cpio -id $basename", "Rpm extraction failed"); - if (! -f "$config{sourcedir}/$basename") { - (my $bname = $basename) =~ s/bz2/gz/; - print "Trying from fedora($bname): $config{fedora}/$pkgrpmrh\n"; - system("cd $config{sourcedir}; rpm2cpio $config{fedora}/$pkgrpmrh | cpio -id $bname; bzme -F $bname", "rpm recompression failed"); - } - } - # download from sourceforge mirrors - if (m!http://prdownloads.sourceforge.net!) { - foreach my $site ("http://ovh.dl.sourceforge.net/sourceforge/", - "http://mesh.dl.sourceforge.net/sourceforge/", - "http://switch.dl.sourceforge.net/sourceforge/", - "http://belnet.dl.sourceforge.net/sourceforge/", - "http://puzzle.dl.sourceforge.net/sourceforge/", - "http://heanet.dl.sourceforge.net/sourceforge/", - "http://kent.dl.sourceforge.net/sourceforge/", - "http://voxel.dl.sourceforge.net/sourceforge/", - "http://easynews.dl.sourceforge.net/sourceforge/", - "http://cogent.dl.sourceforge.net/sourceforge/", - "http://optusnet.dl.sourceforge.net/sourceforge/", - "http://jaist.dl.sourceforge.net/sourceforge/", - "http://nchc.dl.sourceforge.net/sourceforge/", - "http://citkit.dl.sourceforge.net/sourceforge/", - ) - { - (my $dest = $_) =~ s!http://prdownloads.sourceforge.net/!$site!; - last if fetch_http($dest); - } - } - # download specified url - if (! -f "$config{sourcedir}/$basename") { - fetch($_); - } - $found++ if -e $basename; - chmod(0644, "$config{sourcedir}/$basename"); - } - } - # some specs have no source ( php ) - $found++ if ! $tar_ball or $config{'nodownload'}; - - unless ($found) { - print "Unable to download file: URL is not valid ! :-(\n\n"; - $! = 2; - return; - } - - - - unless ($config{noupdate}) { - # TODO use output ? - open($SPECFILE, ">$spec_path") or die "Unable to open $pkg.spec"; - print $SPECFILE $spec; - close($SPECFILE); - } - - unless ($config{nobuild}) { - if (system("$rpm -ba $config{rpmoption} $spec_path $log")) { - print "Binary build fails: building source only\n"; - system("$rpm -bs $config{rpmoption} --nodeps $spec_path $log"); - $! = 1; - } else { - $! = 0; - } - } - if ($config{execafterbuild}) - { - my @rpms_upload; - push(@rpms_upload, $hdlist_spec->srcrpm); - foreach ($hdlist_spec->binrpm()) - { - -f $_ or next; - push(@rpms_upload, $_); - } - system("$config{execafterbuild} " . shell_quote @rpms_upload); - } -} - -sub wget_check { - my $wgetv = `wget --version`; - $wgetv =~ /Wget/ or die "You need `wget' binary for FTP/HTTP download\n"; -} - -sub parse_argv { - my $conf = AppConfig->new({ CASE => 1, ERROR => \&usage }); - - $conf->define("rpmmon", { - ARGS => "=s", - ALIAS => "r", - ARGCOUNT => AppConfig::ARGCOUNT_ONE - }); - - $conf->define("release", { - ARGS => "=s", - DEFAULT => "", - ARGCOUNT => AppConfig::ARGCOUNT_ONE - }); - - $conf->define("srpms", { - ARGS => "=s", - ALIAS => "m", - DEFAULT => "/mnt/BIG/distrib/cooker/SRPMS/", - ARGCOUNT => AppConfig::ARGCOUNT_ONE - }); - - $conf->define("rpmoption", { - ARGS => "=s", - DEFAULT => "", - ARGCOUNT => AppConfig::ARGCOUNT_ONE - }); - - $conf->define("fedora", { - ARGS => "=s", - ALIAS => "h", - DEFAULT => "/mnt/BIG/distrib/fedora/development/SRPMS/", - ARGCOUNT => AppConfig::ARGCOUNT_ONE - }); - - $conf->define("nosource", { - ALIAS => "n", - DEFAULT => 0, - ARGCOUNT => AppConfig::ARGCOUNT_NONE - }); - - $conf->define("noupdate", { - DEFAULT => 0, - ARGCOUNT => AppConfig::ARGCOUNT_NONE - }); - - $conf->define("top", { - ARGS => "=t", - ALIAS => "h", - DEFAULT => 0, - ARGCOUNT => AppConfig::ARGCOUNT_ONE - }); - - $conf->define("nobuild", { - ALIAS => "c", - DEFAULT => 0, - ARGCOUNT => AppConfig::ARGCOUNT_NONE - }); - - $conf->define("nodownload", { - DEFAULT => 0, - ARGCOUNT => AppConfig::ARGCOUNT_NONE - }); - - - $conf->define("log", { - ALIAS => "l", - DEFAULT => 0, - ARGCOUNT => AppConfig::ARGCOUNT_NONE - }); - - $conf->define("changelog", { - ARGS => "=s", - # default is defined at the beggining of build - # as it depend if this is a new version or a simple rebuild - DEFAULT => "", - ARGCOUNT => AppConfig::ARGCOUNT_ONE - }); - - $conf->define("execute", { - ARGS => "=s", - DEFAULT => "", - ARGCOUNT => AppConfig::ARGCOUNT_ONE - }); - - $conf->define("execafterbuild", { - ARGS => "=s", - DEFAULT => "", - ARGCOUNT => AppConfig::ARGCOUNT_ONE - }); - - $conf->define("installbuildrequires", { - ARGS => "=s", - DEFAULT => "", - ARGCOUNT => AppConfig::ARGCOUNT_ONE - }); - - - - foreach my $f ('/etc/rpmbuildupdate.conf', "$ENV{HOME}/.rpmbuildupdaterc") { - -f $f && $conf->file($f); - } - $conf->args; - # TODO remove this useless piece of code and use directly $conf->get - $config{rpmmon} = $conf->get("rpmmon"); - $config{srpms} = $conf->get("srpms"); - $config{release} = $conf->get("release"); - $config{noupdate} = $conf->get("noupdate"); - $config{nosource} = $conf->get("nosource"); - $config{fedora} = $conf->get("fedora"); - $config{top} = $conf->get("top"); - $config{nodownload} = $conf->get("nodownload"); - $config{nobuild} = $conf->get("nobuild"); - $config{message} = $conf->get("changelog"); - $config{rpmoption} = $conf->get("rpmoption"); - $config{log} = $conf->get("log"); - $config{execute} = $conf->get("execute"); - $config{execafterbuild} = $conf->get("execafterbuild"); - $config{installbuildrequires} = $conf->get("installbuildrequires"); -} - -sub usage { - my $id = '$Id$'; - print <: parse output of rpmmon from file - --srpms : specify SRPMS path, separate folder with a comma - --rpmoption : use this option when rebuilding ( --with , mainly ) - --release : release version of package (default: 1mdk) - --changelog : use a alternate message. \%\%VERSION is replace by version - --log: log builds - --nosource: do not install source from (urpmi x.src.rpm) - --noupdate: do not touch to the spec file - --top : specify rpm top dir (default: `rpm --eval \%_topdir`) - --nodownload: do not download any files. - --nobuild|-c: do not build the package. Only download files. - --execute : execute an arbitrary perl command for each line of the spec file - --execafterbuild : execute a shell command after the build, with the source and binary rpm as argument - --installbuildrequires : command executed with the list of BuildRequires to install -EOF - exit 255; -} - -sub parse_rpmmon { - my ($f) = @_; - -f $f or die "Error: $f is not a file.\n"; - - open(my $RPMMON, $f); - while (<$RPMMON>) { - build_from_repository($1, $3) if /^\s+(\S+)\s+(\S+)\s+(\S+)$/ && ! /Package/; - build_from_repository($2, $4) if /^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)$/ && ! /Package/; - } - close($RPMMON); -} - -sub check_dir { - my ($list) = @_; - foreach my $dir (split(/,/, $list)) { - -d $dir or die $dir . " is not a directory.\n"; - } -} - -sub main { - parse_argv; - wget_check; - if ($config{rpmmon}) { - print($config{srpms}); - parse_rpmmon($config{rpmmon}) - } else { - my ($name, $version); - if ($ARGV[0]) { - $name = $ARGV[0]; - $version = $ARGV[1]; - if (-f $name && $name =~ /(?:.spec|.(?:no)?src.rpm)$/) { - build_from_spec($name, $version) if $name =~ /.spec$/; - build_from_src($name, $version) if $name =~ /.(?:no)?src.rpm$/; - } else { - check_dir($config{srpms}); - build_from_repository($name, $version) - } - } else { - usage; - } - } -} - -main; -exit $!; diff --git a/rpmbuildupdate.bash-completion b/rpmbuildupdate.bash-completion deleted file mode 100644 index 6c88289..0000000 --- a/rpmbuildupdate.bash-completion +++ /dev/null @@ -1,49 +0,0 @@ -# bash completion for rpmbuildupdate -# $Id$ - -_rpmbuildupdate() -{ - local cur prev rpmpath file - - COMPREPLY=() - cur=${COMP_WORDS[COMP_CWORD]} - prev=${COMP_WORDS[COMP_CWORD-1]} - - case $prev in - --rpmmon) - _filedir - return 0 - ;; - --@(srpms|top)) - _filedir -d - return 0 - ;; - esac - - - if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '--rpmmon --srpms --rpmoption \ - --release --changelog --deps --log --nosource \ - --noupdate --top --nobuild --execute -c --execafterbuild' -- $cur ) ) - else - # get source rpm path - for file in /etc/rpmbuildupdate $HOME/.rpmbuildupdaterc; do - if [ -f $file ]; then - rpmpath=`awk -F" *= *" '/srpms/ {print $2}' $file` - fi - done - for (( i=1; i < COMP_CWORD; i++ )); do - if [[ "${COMP_WORDS[i]}" == --srpms ]]; then - rpmpath=${COMP_WORDS[i+1]} - break - fi - done - if [ -n "$rpmpath" ]; then - rpmpath=${rpmpath//,/ } - COMPREPLY=( $( eval command ls "$rpmpath" 2>/dev/null | \ - sed -ne 's|^\('$cur'.*\)-[0-9a-zA-Z._]\+-[0-9a-z.@]\+\.src\.rpm$|\1|p' ) ) - fi - _filedir - fi -} -complete -F _rpmbuildupdate $filenames rpmbuildupdate diff --git a/rpmbuildupdate.spec b/rpmbuildupdate.spec deleted file mode 100644 index bfa1a47..0000000 --- a/rpmbuildupdate.spec +++ /dev/null @@ -1,50 +0,0 @@ -%define name rpmbuildupdate -%define version 0.6.1 -%define release %mkrel 1 - -Name: %{name} -Version: %{version} -Release: %{release} -Summary: Helps you build up to date RPMs -License: GPL -Group: Development/Other -Source0: %{name}-%{version}.tar.bz2 -URL: http://qa.mandriva.com/twiki/bin/view/Main/RpmBuildUpdate -BuildArch: noarch -Requires: wget -Buildroot: %{_tmppath}/%{name}-%{version} -Conflicts: rpm-rebuilder <= 0.25-1mdk - -%description -rpmbuildupdate helps you build up to date RPMs. It download source tarball -and update the spec files. It can also be used to rebuild and apply scripted -change to a spec file. - -%prep -%setup - -%build - -%install -rm -rf %{buildroot} -make install - -%clean -rm -rf %{buildroot} - -%files -%defattr(-,root,root) -%{_bindir}/%{name} -%{_sysconfdir}/bash_completion.d/%{name} - -%changelog -* Wed Jan 18 2006 Michael Scherer 0.6.1-1mdk -- new release to please cvs - -* Wed Jan 18 2006 Michael Scherer 0.6-1mdk -- 0.6 -- enhance description -- add url - -* Thu Oct 06 2005 Guillaume Rousse 0.5-1mdk -- first individual release -- cgit v1.2.1