Project

General

Profile

« Previous | Next » 

Revision 75bb92c4

Added by Renato Botelho over 9 years ago

Set necessary env vars for pkg db and cache dir on nanobsd or when MFS partition is being used

View differences:

src/etc/inc/pkg-utils.inc
122 122
	return $rc;
123 123
}
124 124

  
125
/* return an array with necessary environment vars for pkg */
126
function pkg_env() {
127
	global $config, $g;
128

  
129
	$pkg_env_vars = array(
130
		"HTTP_USER_AGENT" => $user_agent,
131
		"ASSUME_ALWAYS_YES" => "true",
132
		"REPO_AUTOUPDATE" => "false"
133
	);
134

  
135
	if ($g['platform'] == "nanobsd" ||
136
	    isset($config['system']['use_mfs_tmpvar'])) {
137
		$pkg_env_vars['PKG_DBDIR'] = '/root/var/db/pkg';
138
		$pkg_env_vars['PKG_CACHEDIR'] = '/root/var/cache/pkg';
139
	}
140

  
141
	return $pkg_env_vars;
142
}
143

  
125 144
/* Execute a pkg call */
126 145
function pkg_call($params, $mute = false) {
127 146
	global $g, $config;
......
135 154
		$user_agent .= ' : ' . get_single_sysctl('kern.hostuuid');
136 155
	}
137 156

  
138
	$env = array(
139
		"HTTP_USER_AGENT" => $user_agent,
140
		"ASSUME_ALWAYS_YES" => "true",
141
		"REPO_AUTOUPDATE" => "false"
142
	);
143

  
144 157
	$descriptorspec = array(
145 158
		1 => array("pipe", "w"), /* stdout */
146 159
		2 => array("pipe", "w")	 /* stderr */
147 160
	);
148 161

  
149 162
	pkg_debug("pkg_call(): {$params}\n");
150
	$process = proc_open("/usr/sbin/pkg {$params}", $descriptorspec, $pipes, '/', $env);
163
	$process = proc_open("/usr/sbin/pkg {$params}", $descriptorspec, $pipes,
164
	    '/', pkg_env());
151 165

  
152 166
	if (!is_resource($process)) {
153 167
		return false;
......
233 247
		$user_agent .= ' : ' . get_single_sysctl('kern.hostuuid');
234 248
	}
235 249

  
236
	$env = array(
237
		"HTTP_USER_AGENT" => $user_agent,
238
		"ASSUME_ALWAYS_YES" => "true",
239
		"REPO_AUTOUPDATE" => "false"
240
	);
241

  
242 250
	$descriptorspec = array(
243 251
		1 => array("pipe", "w"), /* stdout */
244 252
		2 => array("pipe", "w")	 /* stderr */
245 253
	);
246 254

  
247 255
	pkg_debug("pkg_exec(): {$params}\n");
248
	$process = proc_open("/usr/sbin/pkg {$params}", $descriptorspec, $pipes, '/', $env);
256
	$process = proc_open("/usr/sbin/pkg {$params}", $descriptorspec, $pipes,
257
	    '/', pkg_env());
249 258

  
250 259
	if (!is_resource($process)) {
251 260
		return -1;

Also available in: Unified diff