#!/usr/bin/perl -w use Getopt::Long; use File::Copy; use strict; # sigh: i need to fix this #$ENV{'LD_LIBRARY_PATH'} = '/home/kelnos/.local/gentoo/usr/lib/gcc/i686-pc-linux-gnu/4.2.3'; my ($startat,$onlyfailed); if(!GetOptions("start-at=s" => \$startat, "only-failed" => \$onlyfailed)) { die("Bad options passed"); } my $prefix = $ENV{'HOME'}.'/.local/xfce4-svn'; my $gtk_prefix = $ENV{'HOME'}.'/.local/gentoo'; my $checkout_dir = $ENV{'HOME'}.'/downloads/xfce4-snapshots'; my $snap_dir = '/var/www/xfce.org/downloads/svn-snapshots'; my $ac_cache = $checkout_dir.'/autoconf-cache'; my $fail_log = $ENV{'HOME'}.'/.local/var/log/xfce4-snapshots-errors.log'; my $repo_root_uri = 'file:///var/svn'; my @svn_repos = ( { 'name' => 'xfce', 'modules' => [ 'xfce4-dev-tools', 'libxfce4util', 'xfconf', 'libxfce4mcs', 'libxfcegui4', 'libxfce4menu', 'xfce-mcs-manager', 'xfce-mcs-plugins', 'xfce4-settings', 'xfce-utils', 'xfce4-icon-theme', 'xfce4-session', 'xfwm4', 'libexo', 'xfce4-panel', 'thunar', 'xfdesktop', 'gtk-xfce-engine-2', 'xfprint', 'xfcalendar', 'xfwm4-themes', 'xfce4-appfinder', # 'xfmedia', 'mousepad', 'terminal', 'squeeze', 'xarchiver', 'xfce4-mixer', # 'xfce4-perl', # 'pyxfce', # 'xfc', # 'installit', ], }, # ghal is needed for volstatus, so do this before goodies { 'name' => 'kelnos', 'modules' => [ 'ghal', 'airconfig', 'xfce-power-manager', ], }, { 'name' => 'goodies', 'modules' => [ 'gsynaptics-mcs-plugin', 'notification-daemon-xfce', 'ristretto', 'thunar-archive-plugin', 'thunar-media-tags-plugin', 'thunar-svn-plugin', 'thunar-thumbnailers', 'thunar-volman', 'verve-plugin', 'xfburn', 'xfce4-artwork', 'xfce4-battery-plugin', 'xfce4-bglist-editor', 'xfce4-cddrive-plugin', 'xfce4-cellmodem-plugin', 'xfce4-clipman-plugin', 'xfce4-cpufreq-plugin', 'xfce4-cpugraph-plugin', 'xfce4-datetime-plugin', 'xfce4-dict', 'xfce4-diskperf-plugin', 'xfce4-eyes-plugin', 'xfce4-fsguard-plugin', 'xfce4-genmon-plugin', 'xfce4-i8k-plugin', 'xfce4-lua-graph-plugin', 'xfce4-mailwatch-plugin', 'xfce4-megahertz-plugin', 'xfce4-modemlights-plugin', 'xfce4-mount-plugin', 'xfce4-mpc-plugin', 'xfce4-netload-plugin', 'xfce4-notes-plugin', 'xfce4-places-plugin', 'xfce4-quicklauncher-plugin', 'xfce4-radio-plugin', 'xfce4-rss-plugin', 'xfce4-sample-plugin', 'xfce4-screenshooter-plugin', 'xfce4-sensors-plugin', 'xfce4-showdesktop-plugin', 'xfce4-smartbookmark-plugin', 'xfce4-smartpm-plugin', 'xfce4-systemload-plugin', 'xfce4-taskbar-plugin', 'xfce4-taskmanager', 'xfce4-teatime-plugin', 'xfce4-time-out-plugin', 'xfce4-timer-plugin', 'xfce4-volstatus-icon', 'xfce4-wavelan-plugin', 'xfce4-weather-plugin', 'xfce4-websearch-plugin', 'xfce4-windowlist-plugin', 'xfce4-wmdock-plugin', 'xfce4-xfapplet-plugin', 'xfce4-xkb-plugin', 'xfce4-xmms-plugin', 'xfmedia-remote-plugin', ], }, ); # make a module list for the web view PHP script my $module_datadir = '/var/www/xfce.org/utils/svn-snaps-data'; system("rm -rf $module_datadir/*"); foreach my $repohashref (@svn_repos) { my %repohash = %{$repohashref}; my @modules = @{$repohash{'modules'}}; my $repo = $repohash{'name'}; mkdir("$module_datadir/$repo"); foreach my $module (@modules) { system("touch $module_datadir/$repo/$module"); } } # find the correct 'make' my $make; if(defined($ENV{'MAKE'})) { $make = $ENV{'MAKE'}; } elsif(-x '/usr/bin/gmake' || -x '/bin/gmake') { $make = 'gmake'; } elsif(-x '/usr/bin/make' || -x '/bin/make') { $make = 'make'; } else { die("Can't find 'make'"); } # set up the environment $ENV{'PATH'} = "$prefix/bin:$prefix/sbin:$gtk_prefix/usr/bin:$gtk_prefix/usr/sbin:$gtk_prefix/bin:$gtk_prefix/sbin:".$ENV{'PATH'}; $ENV{'LD_LIBRARY_PATH'} = "$prefix/lib:$gtk_prefix/lib:$gtk_prefix/usr/lib".(defined($ENV{'LD_LIBRARY_PATH'})?':'.$ENV{'LD_LIBRARY_PATH'}:''); $ENV{'PKG_CONFIG_PATH'} = "$prefix/lib/pkgconfig:$gtk_prefix/usr/lib/pkgconfig".(defined($ENV{'PKG_CONFIG_PATH'})?':'.$ENV{'PKG_CONFIG_PATH'}:''); #$ENV{'CC'} = "gcc -I$gtk_prefix/include -L$gtk_prefix/lib"; $ENV{'PLATFORM_CPPFLAGS'} = "-I$gtk_prefix/usr/include"; $ENV{'PLATFORM_LDFLAGS'} = "-L$gtk_prefix/lib -L$gtk_prefix/usr/lib"; $ENV{'ACLOCAL_FLAGS'} = "-I $gtk_prefix/usr/share/aclocal"; mkdir($checkout_dir) if(! -d $checkout_dir); die("Unable to create $checkout_dir") if(! -d $checkout_dir); if(!defined($startat) && !defined($onlyfailed)) { # clean up system("rm -rf $prefix"); } unlink($ac_cache); foreach my $repohashref (@svn_repos) { my %repohash = %{$repohashref}; my @modules = @{$repohash{'modules'}}; my $repo = $repohash{'name'}; mkdir("$snap_dir/$repo") if(! -d "$snap_dir/$repo"); foreach my $module (@modules) { if(defined($startat)) { next if($startat ne $module); undef $startat; } my $logfile = "$snap_dir/$repo/$module.log"; if(defined($onlyfailed) && ! -f $logfile) { faillog($repo, $module, "skipping"); next; } unlink($logfile); system("touch $snap_dir/$repo/$module.lock"); chdir("$checkout_dir"); if(! -d $module) { (system("svn co $repo_root_uri/$repo/$module/trunk $module >>$logfile 2>&1") == 0) || do { faillog($repo, $module, "svn co"); next }; chdir("$checkout_dir/$module"); } else { chdir("$checkout_dir/$module"); (system("(svn up || (svn cleanup && svn up)) >>$logfile 2>&1") == 0) || do{ faillog($repo, $module, "svn up"); next }; } my $svnrev; my $op = `env LC_ALL=C svn info`; if($op =~ /Revision:\s+(\d+)/) { $svnrev = $1; } my $my_config = "--cache-file=$ac_cache --prefix=$prefix"; $my_config .= " --enable-gtk-doc --enable-xsltproc"; $my_config .= " --with-xsession-prefix=$prefix" if($module eq 'xfce-utils'); (system("./autogen.sh ${my_config} >>$logfile 2>&1") == 0) || do { faillog($repo, $module, "autogen"); next }; (system("$make clean all >>$logfile 2>&1") == 0) || do { faillog($repo, $module, "make"); next }; (system("$make install >>$logfile 2>&1") == 0) || do { faillog($repo, $module, "make install"); next }; # grr, these packages need to be fixed if($repo eq "xfce" && ($module eq "libxfce4menu" || $module eq "thunar" || $module eq "xfconf")) { (system("$make dist >>$logfile 2>&1") == 0) || do { faillog($repo, $module, "make distcheck"); next }; } else { (system("$make distcheck >>$logfile 2>&1") == 0) || do { faillog($repo, $module, "make distcheck"); next }; } my ($package,$version) = get_pkginfo(); faillog($repo, $module, "failed to get package or version for $module") if(!defined($package) || !defined($version)); if(! -f "$package-$version.tar.bz2") { if(! -f "$package-$version.tar.gz") { faillog($repo, $module, "missing .tar.gz"); next; } (system("gunzip -c $package-$version.tar.gz | bzip2 -9 -c >$package-$version.tar.bz2 2>>$logfile") == 0) || do { faillog($repo, $module, "rezip"); next}; } # fixup tarball names my $newversion = $version; if($version !~ /svn-r\d+/) { if($version =~ /svn-(\d+)/) { $newversion =~ s/svn-(\d+)/svn-r$1/; } elsif($version =~ /svn$/) { $newversion = $version.'-r'.$svnrev; } else { $newversion = $version.'svn-r'.$svnrev; } } my @oldsnaps = find_old_snaps($repo, $package); unlink(@oldsnaps) if(@oldsnaps); copy("$package-$version.tar.bz2", "$snap_dir/$repo/$package-$newversion.tar.bz2") or do { faillog($repo, $module, "copy ($!)"); next}; unlink($logfile); unlink("$snap_dir/$repo/$module.lock"); # clean up svn checkout chdir($ENV{'HOME'}); system("rm -rf $checkout_dir/$module"); } } # final cleanup of failed stuff system("chmod -R u+w $checkout_dir"); system("rm -rf $checkout_dir"); exit(0); sub faillog { my ($repo,$module,$str) = @_; open(LOG, ">>$fail_log") or return; print LOG "$repo/$module: $str\n"; close(LOG); unlink("$snap_dir/$repo/$module.lock"); # exit(1); } sub get_pkginfo { my ($package,$version); if(-f 'config.h') { open(CONFIGH, ") { if(/#define\s+PACKAGE(_TARNAME)?\s+"(.*?)"/) { $package = $2; } elsif(/#define\s+(PACKAGE_)?VERSION\s+"(.*?)"/) { $version = $2; } last if(defined($package) && defined($version)); } close(CONFIGH); } else { open(CONFIGURE, ") { if(/^PACKAGE_NAME='(.*?)'/) { $package = $1; } elsif(/^PACKAGE_VERSION='(.*?)'/) { $version = $1; } last if(defined($package) && defined($version)); } close(CONFIGURE); } return ($package,$version); } sub find_old_snaps { my ($repo,$package) = @_; opendir(DIR, "$snap_dir/$repo") or return undef; my @files = grep { /^$package-\d/ } readdir(DIR); closedir(DIR); if(@files) { for(my $i = 0; $i < scalar(@files); $i++) { $files[$i] = "$snap_dir/$repo/".$files[$i]; } } return @files; }