Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* 'master' of https://github.com/roundcube/roundcubemail: (48 commits)
  Fix bug where external content in src attribute of input/video tags was not secured (roundcube#5583)
  Avoid closure compiler suspicious code warning (roundcube#5584)
  Add class attribute for preferences sections list
  Remove redundant code
  Fix bug where image data URIs in css style were treated as evil/remote in mail preview (roundcube#5580)
  Fix pdf object visibility
  Hide QR-Code button if PHP-GD is not installed
  Add 1.3-beta milestone + update copyright year
  Small code improvements in PDF capability checker
  Remove old jsdeps.sh script
  Add --delete argument to install-jsdeps.sh
  Fix function name
  Fix required OpenPGP version
  Make it working with wget when curl is not installed, mark --force argument as boolean
  Add --force option + update install insructions (roundcube#5535)
  Install script to fetch javascript dependencies defined in jsdeps.json (roundcube#5535)
  Fix so group/addressbook selection is retained on page refresh
  Fix some advanced search issues with multiple addressbooks (roundcube#5572)
  Fix unsetting template objects
  Nicely handle contact deletion on contact edit (roundcube#5522)
  ...
  • Loading branch information
ZiBiS committed Jan 9, 2017
2 parents ea09c68 + e08f22e commit a333912
Show file tree
Hide file tree
Showing 480 changed files with 4,977 additions and 29,906 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
CHANGELOG Roundcube Webmail
===========================

- Fix bug where image data URIs in css style were treated as evil/remote in mail preview (#5580)
- Fix bug where external content in src attribute of input/video tags was not secured (#5583)

RELEASE 1.3-beta
----------------
- Nicely handle contact deletion on contact edit (#5522)
- vcard_attachments: Add possibility to attach contact vCard to composed message (#4997)
- Preserve message internal/received date on import in mbox format (#5559)
- Zipdownload: Fix date format in mbox "From line"
- Possibility to display QR code for contacts data (#5030)
- Added identicon plugin
- Widescreen layout aka three column view (#5093)
- Unify automatic marking as \Seen in preview pane, full-page and extwin views (#5071)
Expand All @@ -17,6 +27,7 @@ CHANGELOG Roundcube Webmail
- Password: Added replacement variables support in password_pop_host (#5539)
- Password: Don't store passwords in temp files when using dovecotpw (#5531)
- Password: Added LDAP PPolicy driver (#5364)
- Password: Added cpanel_webmail driver (#5549)
- Password: Added possibility to nicely redirect from other plugins on password expiration (#5468)
- Implement separate action to mark all messages in a folder as \Seen (#5006)
- Implement marking as \Seen in all folders or in a folder and its subfolders (#5076)
Expand Down Expand Up @@ -73,6 +84,11 @@ CHANGELOG Roundcube Webmail
- Fix redundant keep-alive/refresh after session error on compose page (#5500)
- Managesieve: Fix handling of scripts with nested rules (#5540)
- Fix variable substitution in ldap host for some use-cases, e.g. new_user_identity (#5544)
- Enigma: Fix PHP fatal error when decrypting a message with invalid signature (#5555)
- Fix adding images to new identity signatures
- Fix rsync error handling in installto.sh script (#5562)
- Fix some advanced search issues with multiple addressbooks (#5572)
- Fix so group/addressbook selection is retained on page refresh

RELEASE 1.2.3
-------------
Expand Down
18 changes: 11 additions & 7 deletions INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ REQUIREMENTS
- Auth_SASL 1.0.6 or newer
- Net_Sieve 1.3.2 or newer (for managesieve plugin)
- Crypt_GPG 1.6.0 or newer (for enigma plugin)
- Endroid/QrCode 1.6.0 or newer (https://github.com/endroid/QrCode)
* php.ini options (see .htaccess file):
- error_reporting E_ALL & ~E_NOTICE & ~E_STRICT
- memory_limit > 16MB (increase as suitable to support large attachments)
Expand All @@ -40,13 +41,16 @@ INSTALLATION
============

1. Decompress and put this folder somewhere inside your document root
2. Install dependencies using composer:
- get composer from https://getcomposer.org/download/
- rename the composer.json-dist file into composer.json
- if you want to use LDAP address books, enable the LDAP libraries in your
composer.json file by moving the items from "suggest" to the "require"
section (remove the explanation texts after the version!).
- run `php composer.phar install --no-dev`
2. In case you don't use the so-called "complete" release package,
you have to install PHP and javascript dependencies.
2.1. Install PHP dependencies using composer:
- get composer from https://getcomposer.org/download/
- rename the composer.json-dist file into composer.json
- if you want to use LDAP address books, enable the LDAP libraries in your
composer.json file by moving the items from "suggest" to the "require"
section (remove the explanation texts after the version!).
- run `php composer.phar install --no-dev`
2.2. Install Javascript dependencies by executing `bin/install-jsdeps.sh` script.
3. Make sure that the following directories (and the files within)
are writable by the webserver
- /temp
Expand Down
308 changes: 308 additions & 0 deletions bin/install-jsdeps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,308 @@
#!/usr/bin/env php
<?php
/*
+-----------------------------------------------------------------------+
| bin/install-jsdeps.sh |
| |
| This file is part of the Roundcube Webmail client |
| Copyright (C) 2016, The Roundcube Dev Team |
| |
| Licensed under the GNU General Public License version 3 or |
| any later version with exceptions for skins & plugins. |
| See the README file for a full license statement. |
| |
| PURPOSE: |
| Utility script to fetch and install all 3rd party javascript |
| libraries unsed in Roundcube from source. |
+-----------------------------------------------------------------------+
| Author: Thomas Bruederli <[email protected]> |
+-----------------------------------------------------------------------+
*/

define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/' );

require_once INSTALL_PATH . 'program/include/clisetup.php';

$SOURCES = json_decode(file_get_contents(INSTALL_PATH . 'jsdeps.json'), true);

if (empty($SOURCES['dependencies'])) {
die("ERROR: Failed to read sources from " . INSTALL_PATH . "jsdeps.json\n");
}

$CURL = trim(`which curl`);
$WGET = trim(`which wget`);
$UNZIP = trim(`which unzip`);
$FILEINFO = trim(`which file`);

$CACHEDIR = sys_get_temp_dir();

if (is_writeable(INSTALL_PATH . 'temp/js_cache') || mkdir(INSTALL_PATH . 'temp/js_cache', 0774, true)) {
$CACHEDIR = INSTALL_PATH . 'temp/js_cache';
}


//////////////// License definitions

$LICENSES = array();
$LICENSES['MIT'] = <<<EOM
* Licensed under the MIT licenses
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
EOM;

$LICENSES['GPLv3'] = <<<EOG
* The JavaScript code in this page is free software: you can
* redistribute it and/or modify it under the terms of the GNU
* General Public License (GNU GPL) as published by the Free Software
* Foundation, either version 3 of the License, or (at your option)
* any later version. The code is distributed WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
*
* As additional permission under GNU GPL version 3 section 7, you
* may distribute non-source (e.g., minimized or compacted) forms of
* that code without the copy of the GNU GPL normally required by
* section 4, provided you include this license notice and a URL
* through which recipients can access the Corresponding Source.
EOG;

$LICENSES['LGPL'] = <<<EOL
* The JavaScript code in this page is free software: you can
* redistribute it and/or modify it under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option)
* any later version.
EOL;


//////////////// Functions

/**
* Fetch package file from source
*/
function fetch_from_source($package, $useCache = true, &$filetype = null)
{
global $CURL, $WGET, $FILEINFO, $CACHEDIR;

$filetype = pathinfo($package['url'], PATHINFO_EXTENSION) ?: 'tmp';
$cache_file = $CACHEDIR . '/' . $package['lib'] . '-' . $package['version'] . '.' . $filetype;

if (!is_readable($cache_file) || !$useCache) {
echo "Fetching $package[url]\n";

if ($CURL)
exec(sprintf('%s -s %s -o %s', $CURL, escapeshellarg($package['url']), $cache_file), $out, $retval);
else
exec(sprintf('%s -q %s -O %s', $WGET, escapeshellarg($package['url']), $cache_file), $out, $retval);

if ($retval !== 0) {
die("ERROR: Failed to download source file from " . $package['url'] . "\n");
}
}

if (!empty($package['sha1']) && ($sum = sha1_file($cache_file)) !== $package['sha1']) {
die("ERROR: Incorrect sha1 sum of $cache_file. Expected: $package[sha1], got: $sum\n");
}

// detect downloaded/cached file type
exec(sprintf('%s -b %s', $FILEINFO, $cache_file), $out);
if (stripos($out[0], 'zip') === 0) {
$filetype = 'zip';
}

return $cache_file;
}

/**
* Create a destination javascript file with copyright and license header
*/
function compose_destfile($package, $srcfile)
{
global $LICENSES;

$header = sprintf("/**\n * %s - v%s\n *\n", $package['name'], $package['version']);

if (!empty($package['source'])) {
$header .= " * @source " . $package['source'] . "\n";
$header .= " *\n";
}

if (!empty($package['license']) && isset($LICENSES[$package['license']])) {
$header .= " * @licstart The following is the entire license notice for the\n";
$header .= " * JavaScript code in this file.\n";
$header .= " *\n";
if (!empty($package['copyright'])) {
$header .= " * " . $package['copyright'] . "\n";
$header .= " *\n";
}

$header .= $LICENSES[$package['license']];
$header .= " *\n";
$header .= " * @licend The above is the entire license notice\n";
$header .= " * for the JavaScript code in this file.\n";
}

$header .= " */\n";

if (file_put_contents(INSTALL_PATH . $package['dest'], $header . file_get_contents($srcfile))) {
echo "Wrote file " . INSTALL_PATH . $package['dest'] . "\n";
}
else {
die("ERROR: Failed to write destination file " . INSTALL_PATH . $package['dest'] . "\n");
}
}

/**
* Extract a Zip archive into the destination specified by the package config
*/
function extract_zipfile($package, $srcfile)
{
global $UNZIP, $CACHEDIR;

$destdir = INSTALL_PATH . $package['dest'];
if (!is_dir($destdir)) {
mkdir($destdir, 0774, true);
}

if (!is_writeable($destdir)) {
die("ERROR: Cannot write to destination directory $destdir\n");
}

// pick files from zip archive
if (!empty($package['pick'])) {
foreach ($package['pick'] as $pattern) {
echo "Extracting files $pattern into $destdir\n";
exec(sprintf('%s -o %s %s -d %s', $UNZIP, escapeshellarg($srcfile), escapeshellarg($pattern), $destdir), $out, $retval);
if ($retval !== 0) {
echo "ERROR: Failed to unpack $pattern; " . join('; ' . $out) . "\n";
}
}
}
// unzip the archive and map source to dest files/directories
else if (!empty($package['map'])) {
$extract = $CACHEDIR . '/' . $package['lib'] . '-extract';
exec(sprintf('%s -o %s -d %s', $UNZIP, escapeshellarg($srcfile), $extract), $out, $retval);

foreach ($package['map'] as $src => $dest) {
echo "Installing files $extract/$src into $destdir/$dest\n";

// make sure the destination's parent directory exists
if (strpos($dest, '/') !== false) {
$parentdir = dirname($destdir . '/' . $dest);
if (!is_dir($parentdir)) {
mkdir($parentdir, 0774, true);
}
}

// avoid copying source directory as a child into destination
if (is_dir($extract . '/' . $src) && is_dir($destdir . '/' . $dest)) {
exec(sprintf('rm -rf %s/%s', $destdir, $dest));
}

exec(sprintf('mv -f %s/%s %s/%s', $extract, $src, $destdir, $dest), $out, $retval);
if ($retval !== 0) {
echo "ERROR: Failed to move $src into $destdir/$dest; " . join('; ' . $out) . "\n";
}
}

// remove temp extraction dir
exec('rm -rf ' . $extract);
}
// extract the archive into the destination directory
else {
echo "Extracting zip archive into $destdir\n";
exec(sprintf('%s -o %s -d %s', $UNZIP, escapeshellarg($srcfile), $destdir), $out, $retval);
if ($retval !== 0) {
echo "ERROR: Failed to unzip $srcfile; " . join('; ' . $out) . "\n";
}
}

// remove some files from the destination
if (!empty($package['omit'])) {
foreach ((array)$package['omit'] as $glob) {
exec(sprintf('rm -rf %s/%s', $destdir, escapeshellarg($glob)));
}
}

// prepend license header to extracted files
if (!empty($package['addlicense'])) {
foreach ((array)$package['addlicense'] as $filename) {
$pkg = $package;
$pkg['dest'] = $package['dest'] . '/' . $filename;
compose_destfile($pkg, $destdir . '/' . $filename);
}
}
}

/**
* Delete the package destination file/dir
*/
function delete_destfile($package)
{
$destdir = INSTALL_PATH . ($package['rm'] ?: $package['dest']);

if (file_exists($destdir)) {
if (PHP_OS === 'Windows') {
exec(sprintf("rd /s /q %s", escapeshellarg($destdir)));
}
else {
exec(sprintf("rm -rf %s", escapeshellarg($destdir)));
}
}
}


//////////////// Execution

$args = rcube_utils::get_opt(array('f' => 'force:bool', 'd' => 'delete:bool'))
+ array('force' => false, 'delete' => false);
$WHAT = $args[0];

foreach ($SOURCES['dependencies'] as $package) {
if (!isset($package['name'])) {
$package['name'] = $package['lib'];
}

if ($WHAT && $package['lib'] !== $WHAT) {
continue;
}

if ($args['delete']) {
delete_destfile($package);
continue;
}

echo "Installing $package[name]...\n";

$srcfile = fetch_from_source($package, !$args['force'], $filetype);

if ($filetype === 'zip') {
extract_zipfile($package, $srcfile);
}
else {
compose_destfile($package, $srcfile);
}

echo "Done.\n\n";
}

Loading

0 comments on commit a333912

Please sign in to comment.