1 .First.lib <- function(libname, pkgname) {
2 global <- function(name,value) assign(name,value,envir=.GlobalEnv)
3 global("which_system", Sys.getenv('CRAN2DEB_SYS','debian-amd64'))
4 if (!length(grep('^[a-z]+-[a-z0-9]+$',which_system))) {
5 stop('Invalid system specification: must be of the form name-arch')
7 global("host_arch", gsub('^[a-z]+-','',which_system))
8 global("maintainer", 'cran2deb autobuild <cran2deb@gmail.com>')
9 global("root", system.file(package='cran2deb'))
10 global("cache_root", Sys.getenv('CRAN2DEB_CACHE','/var/cache/cran2deb'))
11 global("config_dir", Sys.getenv('CRAN2DEB_CONFDIR','/etc/cran2deb'))
12 global("pbuilder_results", file.path(cache_root,which_system))
13 global("pbuilder_config", file.path(config_dir,'sys',which_system,'pbuilderrc'))
14 global("dput_config", file.path(config_dir,'sys',which_system,'dput.cf'))
15 global("dinstall_config", file.path(config_dir,'sys',which_system,'mini-dinstall.conf'))
16 global("dinstall_archive", file.path(config_dir,'archive',which_system))
17 global("r_depend_fields", c('Depends','Imports')) # Suggests, Enhances
18 global("scm_revision", paste("svn:", svnversion()))
19 global("patch_dir", file.path(config_dir,'patches'))
20 global("lintian_dir", file.path(config_dir,'lintian'))
21 global("changesfile", function(srcname,version='*') {
22 return(file.path(pbuilder_results
23 ,paste(srcname,'_',version,'_'
24 ,host_arch,'.changes',sep='')))
26 global("version_suffix","~debianr+")
27 # perhaps db_cur_version() should be used instead?
28 global("version_suffix_step",1)
30 cache <- file.path(cache_root,'cache.rda')
31 if (file.exists(cache)) {
32 load(cache,envir=.GlobalEnv)
34 message(paste('I: cran2deb',scm_revision,'building for',which_system,'at',Sys.time()))