Add support for php.ini customization and fix bugs

This commit is contained in:
Shivam Mathur
2019-09-18 07:40:09 +05:30
parent a398f54da4
commit e4a37d0f16
9 changed files with 112 additions and 34 deletions

View File

@ -4,8 +4,11 @@ if [ "$version" != "$1" ]; then
brew unlink php;
brew install php@$1;
brew link --force --overwrite php@$1;
else
sudo cp /etc/php.ini.default /etc/php.ini
fi
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
sudo chmod 777 $ini_file
curl -sS https://getcomposer.org/installer | php
chmod +x composer.phar
mv composer.phar /usr/local/bin/composer

View File

@ -71,7 +71,7 @@ async function addExtension(extension_csv: string, version: string) {
// else add script to attempt to install the extension
if (os_version == 'linux') {
linux +=
'sudo apt install -y php' +
'sudo DEBIAN_FRONTEND=noninteractive apt install -y php' +
version +
'-' +
extension +
@ -113,7 +113,25 @@ async function addExtension(extension_csv: string, version: string) {
}
}
});
linux += 'sudo apt autoremove -y';
linux += 'sudo DEBIAN_FRONTEND=noninteractive apt autoremove -y';
}
/*
Add script to set custom ini values
*/
async function addINIValues(ini_values_csv: string) {
let ini_values: any = ini_values_csv
.split(',')
.map(function(ini_value: string) {
return ini_value.trim();
});
await asyncForEach(ini_values, async function(ini_value: string) {
// add script to set ini value
linux += '\necho "' + ini_value + '" >> $ini_file';
darwin += '\necho "' + ini_value + '" >> $ini_file';
windows +=
'\nAdd-Content C:\\tools\\php$version\\php.ini "' + ini_value + '"';
});
}
/*
@ -146,7 +164,7 @@ async function run() {
if (!version) {
version = core.getInput('php-version', {required: true});
}
console.log('Input: ' + version);
console.log('Version: ' + version);
if (version == '7.4') {
darwin = fs.readFileSync(path.join(__dirname, '../src/7.4.sh'), 'utf8');
@ -157,10 +175,19 @@ async function run() {
extension_csv = core.getInput('extension-csv');
}
if (extension_csv) {
console.log('Input: ' + extension_csv);
console.log('Extensions: ' + extension_csv);
await addExtension(extension_csv, version);
}
let ini_values_csv = process.env['ini-values-csv'];
if (!ini_values_csv) {
ini_values_csv = core.getInput('ini-values-csv');
}
if (ini_values_csv) {
console.log('INI Values: ' + ini_values_csv);
await addINIValues(ini_values_csv);
}
// check the os version and run the respective script
if (os_version == 'darwin') {
await createScript('darwin.sh', version);

View File

@ -1,26 +1,23 @@
ua()
{
for tool in php phar phar.phar php-cgi php-config phpize; do
if [ -e "/usr/bin/$tool$version" ]; then
sudo update-alternatives --set $tool /usr/bin/$tool$1;
fi
done
}
version=$(php-config --version | cut -c 1-3)
if [ "$version" != "$1" ]; then
if [ ! -e "/usr/bin/php$1" ]; then
sudo add-apt-repository ppa:ondrej/php -y
sudo apt update -y
sudo apt install -y php$1 curl;
sudo apt autoremove -y;
sudo DEBIAN_FRONTEND=noninteractive add-apt-repository ppa:ondrej/php -y
sudo DEBIAN_FRONTEND=noninteractive apt update -y
sudo DEBIAN_FRONTEND=noninteractive apt install -y php$1 curl;
sudo DEBIAN_FRONTEND=noninteractive apt autoremove -y;
fi
ua $1;
for tool in php phar phar.phar php-cgi php-config phpize; do
if [ -e "/usr/bin/$tool$1" ]; then
sudo update-alternatives --set $tool /usr/bin/$tool$1;
fi
done
fi
if [ ! -e "/usr/bin/composer" ]; then
sudo curl -s https://getcomposer.org/installer | php;
sudo mv composer.phar /usr/local/bin/composer;
fi
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
sudo chmod 777 $ini_file
php -v
composer -V