From 36532345df0cc802f30a4ad2e424cff297cc026b Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Sun, 19 Apr 2020 10:59:47 +0200 Subject: [PATCH] Make install-jsdeps.sh script working without the 'file' program installed (#7325) --- CHANGELOG | 1 + bin/install-jsdeps.sh | 17 +++++++---------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 204c4fc19..371602282 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -38,6 +38,7 @@ CHANGELOG Roundcube Webmail - Mailvelope: Fix bug where recipients with name were not handled properly in mail compose (#7312) - Fix characters encoding in group rename input after group creation/rename (#7330) - Fix bug where some message/rfc822 parts could not be attached on forward (#7323) +- Make install-jsdeps.sh script working without the 'file' program installed (#7325) RELEASE 1.4.3 ------------- diff --git a/bin/install-jsdeps.sh b/bin/install-jsdeps.sh index c09051816..5094e46e8 100755 --- a/bin/install-jsdeps.sh +++ b/bin/install-jsdeps.sh @@ -36,7 +36,6 @@ if (empty($SOURCES['dependencies'])) { $CURL = trim(`which curl`); $WGET = trim(`which wget`); $UNZIP = trim(`which unzip`); -$FILEINFO = trim(`which file`); if (($CACHEDIR = getenv("CACHEDIR")) && is_writeable($CACHEDIR)) { // use $CACHEDIR @@ -154,19 +153,17 @@ function fetch_from_source($package, $useCache = true, &$filetype = null) */ function extract_filetype($package, &$filetype = null) { - global $FILEINFO, $CACHEDIR; + global $CACHEDIR; $filetype = pathinfo($package['url'], PATHINFO_EXTENSION) ?: 'tmp'; $cache_file = $CACHEDIR . '/' . $package['lib'] . '-' . $package['version'] . '.' . $filetype; - if (empty($FILEINFO)) { - rcube::raise_error("Required program 'file' not found.", false, true); - } - - // detect downloaded/cached file type - exec(sprintf('%s -b %s', $FILEINFO, $cache_file), $out); - if (stripos($out[0], 'zip') === 0) { - $filetype = 'zip'; + // Make sure it is a zip file + if (file_exists($cache_file)) { + $magic = file_get_contents($cache_file, false, null, 0, 4); + if ($magic === "PK\003\004") { + $filetype = 'zip'; + } } return $cache_file;