~rbn/buildslack

7460e0e5202135992e7a7a5ff9076b47d8ae929f — Ruben Schuller 3 months ago 4c8b5b7 master v0.1.10
git log mtime, switch to turn off mtime checking

check mtime using git log if available
add switch to disable mtime checking
3 files changed, 28 insertions(+), 12 deletions(-)

M buildslack
M pkgIndex.tcl
M queue.tcl
M buildslack => buildslack +3 -2
@@ 20,7 20,7 @@ package require cmdline
# try loading package, if that fails, try sourcing the scripts from
# the directory of the current script
try { 
	package require buildslack 0.1.9
	package require buildslack 0.1.10
} on error {} {
	source [file join [file dirname [info script]] index.tcl ]
	source [file join [file dirname [info script]] repository.tcl ]


@@ 119,7 119,7 @@ proc upgrade { opts } {

	::buildslack::repository::index db [ dict get $opts packages ]

	::buildslack::queue::upgrade $environment db [ dict get $opts custom ] $sources [ dict get $opts packages ] [ dict get $opts force ] [ dict get $opts keep ] [ dict get $opts backup ] [ dict get $opts cont ] [ lindex $argv 0 ] 
	::buildslack::queue::upgrade $environment db [ dict get $opts custom ] $sources [ dict get $opts packages ] [ dict get $opts force ] [ dict get $opts keep ] [ dict get $opts backup ] [ dict get $opts cont ] [ dict get $opts nomtime ] [ lindex $argv 0 ] 
	exit 0
}



@@ 189,6 189,7 @@ set options {
		{ backup								"keep backup of previous build" }
		{ keep									"keep environments of broken builds" }
		{ cont									"continue upgrade after failed builds" }
		{ nomtime								"don't use git log time or mtime to test for changed slackbuilds" }
		{ debug									"print debug output" }
		{ force									"force redownload and rebuild" }


M pkgIndex.tcl => pkgIndex.tcl +2 -2
@@ 1,6 1,6 @@
package ifneeded buildslack 0.1.9 [ subst {
package ifneeded buildslack 0.1.10 [ subst {
	foreach f {build.tcl database.tcl environment.tcl index.tcl queue.tcl repository.tcl slackbuild.tcl sources.tcl} { 
		source [file join $dir \$f] 
	}
	package provide buildslack 0.1.9
	package provide buildslack 0.1.10
} ]

M queue.tcl => queue.tcl +23 -8
@@ 122,7 122,7 @@ namespace eval ::buildslack::queue {
		return $out
	}

	proc upgrade { environment db croot sources packages force keep backup cont prgnam } {
	proc upgrade { environment db croot sources packages force keep backup cont nomtime prgnam } {
		# upgrade packages
		#  environment - environment as returned by [::buildslack::environment::new]
		#  db - opened database


@@ 132,6 132,7 @@ namespace eval ::buildslack::queue {
		#  keep - keep environments of broken builds
		#  backup - keep backup of the last package instead of replacing it
		#  cont - continue with next package after build fails
		#  nomtime - don't use git log time or mtime to test for changed slackbuilds
		#  prgnam - either name of slackbuild OR empty string "" to upgrade all outdated slackbuilds
		lappend pkgs [ ::buildslack::repository::sb $db $prgnam ]



@@ 155,19 156,33 @@ namespace eval ::buildslack::queue {
				continue
			}

			set pkgMtime [ file mtime [ ::buildslack::repository::path $db [ dict get $pkg PRGNAM ] ] ]
			set sbMtime [ file mtime [ lindex [ glob -directory [ dict get $sb PATH ] "*.SlackBuild" ] 0 ] ]
			if { !$nomtime } {
				set pkgMtime [ file mtime [ ::buildslack::repository::path $db [ dict get $pkg PRGNAM ] ] ]
				set sbFile [ lindex [ glob -directory [ dict get $sb PATH ] "*.SlackBuild" ] 0 ]
				set sbMtime -1

				try {
					set sbMtime [ exec >&@stdout git -C [ file dirname $sbFile ] log -1 --format=%ct [ file tail $sbFile ] ]
					log::log debug "[dict get $pkg PRGNAM ] SlackBuild mtime from git $sbMtime"
				} trap CHILDSTATUS {} {
					set sbMtime [ file mtime $sbFile ]
					log::log debug "[dict get $pkg PRGNAM ] SlackBuild mtime from file $sbMtime"
				}

			if { $pkgMtime < $sbMtime } {
				log::log info "[dict get $pkg PRGNAM]: slackbuild mtime ($sbMtime) younger than package mtime ($pkgMtime), upgrading."
				lappend changed [ dict get $pkg PRGNAM ]
				continue
				if { $sbMtime == -1 } {
					error "couldn't determine slackbuild mtime"
				}

				if { $pkgMtime < $sbMtime } {
					log::log info "[dict get $pkg PRGNAM]: slackbuild mtime ($sbMtime) younger than package mtime ($pkgMtime), upgrading."
					lappend changed [ dict get $pkg PRGNAM ]
					continue
				}
			}

			log::log info "[ dict get $pkg PRGNAM ]: [ dict get $pkg VERSION ] (package) == [ dict get $sb VERSION ] (slackbuild), not upgrading"
		}


		log::log info "collecting reverse dependencies of changed slackbuilds..."
		lappend q
		foreach prgnam $changed {