|
|
@ -36,7 +36,6 @@ if (empty($SOURCES['dependencies'])) {
|
|
|
|
$CURL = trim(`which curl`);
|
|
|
|
$CURL = trim(`which curl`);
|
|
|
|
$WGET = trim(`which wget`);
|
|
|
|
$WGET = trim(`which wget`);
|
|
|
|
$UNZIP = trim(`which unzip`);
|
|
|
|
$UNZIP = trim(`which unzip`);
|
|
|
|
$FILEINFO = trim(`which file`);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (($CACHEDIR = getenv("CACHEDIR")) && is_writeable($CACHEDIR)) {
|
|
|
|
if (($CACHEDIR = getenv("CACHEDIR")) && is_writeable($CACHEDIR)) {
|
|
|
|
// use $CACHEDIR
|
|
|
|
// use $CACHEDIR
|
|
|
@ -154,19 +153,17 @@ function fetch_from_source($package, $useCache = true, &$filetype = null)
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function extract_filetype($package, &$filetype = null)
|
|
|
|
function extract_filetype($package, &$filetype = null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
global $FILEINFO, $CACHEDIR;
|
|
|
|
global $CACHEDIR;
|
|
|
|
|
|
|
|
|
|
|
|
$filetype = pathinfo($package['url'], PATHINFO_EXTENSION) ?: 'tmp';
|
|
|
|
$filetype = pathinfo($package['url'], PATHINFO_EXTENSION) ?: 'tmp';
|
|
|
|
$cache_file = $CACHEDIR . '/' . $package['lib'] . '-' . $package['version'] . '.' . $filetype;
|
|
|
|
$cache_file = $CACHEDIR . '/' . $package['lib'] . '-' . $package['version'] . '.' . $filetype;
|
|
|
|
|
|
|
|
|
|
|
|
if (empty($FILEINFO)) {
|
|
|
|
// Make sure it is a zip file
|
|
|
|
rcube::raise_error("Required program 'file' not found.", false, true);
|
|
|
|
if (file_exists($cache_file)) {
|
|
|
|
}
|
|
|
|
$magic = file_get_contents($cache_file, false, null, 0, 4);
|
|
|
|
|
|
|
|
if ($magic === "PK\003\004") {
|
|
|
|
// detect downloaded/cached file type
|
|
|
|
$filetype = 'zip';
|
|
|
|
exec(sprintf('%s -b %s', $FILEINFO, $cache_file), $out);
|
|
|
|
}
|
|
|
|
if (stripos($out[0], 'zip') === 0) {
|
|
|
|
|
|
|
|
$filetype = 'zip';
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return $cache_file;
|
|
|
|
return $cache_file;
|
|
|
|