Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:cardmaster
elekmon
updatesrc
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File updatesrc of Package elekmon
#!/usr/bin/perl -w #This script is use to update source code for empim. #run ./updatesrc in your osc working directory. use strict; use File::Copy qw/move/; use File::Path qw/rmtree/; #Subroutines sub HELP_MESSAGE; sub VERSION_MESSAGE; sub readspec; sub exec_cmd { my ($cmd, @args) = @_; my $realcmd = join (" ", $cmd, @args); print '+ ', $realcmd, "\n"; system $realcmd; return $?; } #Grab options my $args = scalar @ARGV; my %opts; use Getopt::Std; $Getopt::Std::STANDARD_HELP_VERSION = 1; Getopt::Std::getopts( 'r:t:o:c:k', \%opts ); my $addr='git://fiouas72.ebgroup.elektrobit.com/juti/elekmon.git'; my $spec='elekmon.spec'; $addr = $opts{r} if exists $opts{r}; $spec = $opts{c} if exists $opts{c}; print "Analyze package name & version\n"; my $attr = readspec $spec; sub showattr { my ($attr) = @_; while (my ($key, $val) = each (%$attr)) { if ($key =~ /^\@\$/){ print $key, ' : ', join (', ', @$val), "\n"; } else { print $key, ' : ', $val, "\n"; } } } #clone source print "Get source code from git, (may require source code)\n"; my $dirname = $attr->{Name}.'-'.$attr->{Version}; print "Checkout $addr to $dirname\n"; my $options = ' '; $options = $opts{o} if exists $opts{o}; my $cmd1 = join ' ', 'git', 'clone', $addr, $options, $dirname; exec_cmd $cmd1; exec_cmd "pwd"; exec_cmd "ls"; #my $cmd2 = join ' ', 'cd', $dirname; #print $cmd2, "\n"; #system $cmd2; #cd $dirname; chdir "$dirname"; exec_cmd "pwd"; my $cmd3 = join ' ', 'git', 'pull'; print '+ ', $cmd3, "\n"; exec_cmd $cmd3; my $usebranch = 'origin/develop'; $usebranch = '0.1.0'; my $cmd4 = join ' ', 'git', 'checkout', $usebranch; exec_cmd $cmd4; chdir ".."; exec_cmd "pwd"; #Checkout tag if (exists $opts{t}) { return; #don't use this feature now my $tag = $opts{t}; print "Switch to tag $tag\n"; chdir $dirname; exec_cmd 'git', 'checkout', $tag; chdir '..'; } my $tarball = $dirname.'.tar.bz2'; print "Create source tar ball\n"; exec_cmd 'tar', 'cjf', $tarball, $dirname, '--exclude=.git'; print "add tarball to osc manage\n"; exec_cmd 'osc', 'add', $tarball; print "Clean up..\n"; rmtree $dirname if not $opts{k}; print "Tarball is ready, use command oscl ci to comit it\n"; #Analyze a spec file, return a hash of these info #name, version sub readspec { my ($spec) = @_; open my $fd, '<', $spec or die "Can not open $spec:$!\n"; my $pat = eval { qr/^\s*(\S+)\s*:\s*(\S+.*)$/ }; my %attrmap; while (my $line = <$fd>) { if ($line =~ /$pat/) { # print $1, ' : ', $2, "\n"; #When attribute has multiple values, it'll be store into an array, where its key will be @$attrname if (exists $attrmap{$1}) { my $var = $attrmap{$1}; my $arykey = '@$'.$1; $attrmap{$arykey} = [$var] if (not exists $attrmap{$arykey}); $attrmap{$1} = $arykey; my $ref = $attrmap{'@$'.$1}; push (@$ref, $2); } else { $attrmap{$1} = $2; } } last if ($line =~ /^\s*%\w+/); } close $fd; return \%attrmap; } sub HELP_MESSAGE { my ($ofd) = @_; open $ofd, '>&STDOUT' if not $ofd; my $string = ' USAGE: updatesrc [--help] [-r gitrepo] [-c spec file] [-t gittag] [-o gitoption] -r repo, specify a git repository -t tagname, specify git tag name -o gitoption, additional options that pass to git -c spec, specify the spec file of current package. -k keep git workdir(skip clean); '; print $ofd $string; } sub VERSION_MESSAGE { my ($ofd) = @_; print $ofd "updatesrc, version 0.1", "\n"; }
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor