Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
core.debug(error);
throw `Failed to install R: ${error}`;
}
//
// Add symlinks to the installed R to the path
//
//
try {
await exec.exec("sudo ln", [
"-s",
path.join("/opt", "R", version, "bin", "R"),
"/usr/local/bin/R"
]);
await exec.exec("sudo ln", [
"-s",
path.join("/opt", "R", version, "bin", "Rscript"),
"/usr/local/bin/Rscript"
]);
} catch (error) {
core.debug(error);
throw `Failed to setup symlinks to R: ${error}`;
}
return "/usr/local/bin";
}
} catch (error) {
core.debug(error);
throw `Failed to download version ${version}: ${error}`;
}
//
// Install
//
let extPath: string = tempDirectory;
if (!extPath) {
throw new Error("Temp directory not set");
}
try {
await exec.exec(path.join(tempDirectory, fileName), [
"/VERYSILENT",
"/SUPPRESSMSGBOXES",
"/DIR=C:\\R"
]);
} catch (error) {
core.debug(error);
throw `Failed to install R: ${error}`;
}
core.addPath(`C:\\R\\bin`);
return "";
}
}
}
const fileName = "install-unx.sh";
const downloadUrl = "https://yihui.name/gh/tinytex/tools/install-unx.sh";
let downloadPath: string | null = null;
try {
downloadPath = await tc.downloadTool(downloadUrl);
} catch (error) {
throw `Failed to download TinyTex: ${error}`;
}
await io.mv(downloadPath, path.join(tempDirectory, fileName));
await exec.exec("sh", [path.join(tempDirectory, fileName)]);
let binPath: string;
// The binaries are in TinyTeX/bin/*/, where the wildcard is the
// architecture, but we should always take the first one.
if (IS_MAC) {
binPath = path.join(process.env["HOME"] || "/", "Library/TinyTeX/bin");
} else {
binPath = path.join(process.env["HOME"] || "/", ".TinyTeX/bin");
}
const arch = fs.readdirSync(binPath)[0];
core.addPath(path.join(binPath, arch));
}
async function downgradeMySQL() {
core.startGroup(`Downgrade MySQL`)
const pkgDir = `${process.env.HOME}/packages`
const pkgOption = `--directory-prefix=${pkgDir}/`
const mirrorUrl = 'https://mirrors.mediatemple.net/debian-security/pool/updates/main/m/mysql-5.5'
const ubuntuUrl = 'http://archive.ubuntu.com/ubuntu/pool/main'
// executes the following all in parallel
const promise1 = exec.exec('sudo', ['apt-get', 'remove', 'mysql-client'])
const promise2 = exec.exec('wget', [pkgOption, `${mirrorUrl}/libmysqlclient18_5.5.62-0%2Bdeb8u1_amd64.deb`])
const promise3 = exec.exec('wget', [pkgOption, `${mirrorUrl}/libmysqlclient-dev_5.5.62-0%2Bdeb8u1_amd64.deb`])
const promise4 = exec.exec('wget', [pkgOption, `${ubuntuUrl}/g/glibc/multiarch-support_2.27-3ubuntu1.2_amd64.deb`])
// wait for the parallel processes to finish
await Promise.all([promise1, promise2, promise3, promise4])
// executes serially
await exec.exec('sudo', ['dpkg', '-i', `${pkgDir}/multiarch-support_2.27-3ubuntu1.2_amd64.deb`])
await exec.exec('sudo', ['dpkg', '-i', `${pkgDir}/libmysqlclient18_5.5.62-0+deb8u1_amd64.deb`])
await exec.exec('sudo', ['dpkg', '-i', `${pkgDir}/libmysqlclient-dev_5.5.62-0+deb8u1_amd64.deb`])
core.endGroup()
}
return __awaiter(this, void 0, void 0, function* () {
// Install Xcode for Mac OS
if (process.platform == 'darwin') {
let runner_ = new toolrunner.ToolRunner('xcode-select', ['--install']);
runner_.exec();
} else {
let runner0 = new toolrunner.ToolRunner('sudo',
['apt-get', 'update']);
runner0.exec();
let runner_ = new toolrunner.ToolRunner('sudo',
['apt-get', 'install', 'ruby-full', 'build-essential', 'postgresql', 'libpq-dev']);
yield runner_.exec();
}
// WORKAROUND, TODO: Parse version from Gemfile
let runner = null;
if (process.platform == 'darwin') {
runner = new toolrunner.ToolRunner('gem',
['install', 'bundler:1.17.2']);
} else {
runner = new toolrunner.ToolRunner('sudo',
['gem', 'install', 'bundler:1.17.2']);
}
return __awaiter(this, void 0, void 0, function* () {
// Create directory if not exists
yield io.mkdirP('config');
let runner0 = new toolrunner.ToolRunner('openssl', ['version']);
yield runner0.exec();
// TODO: also check that the key is valid after decryption
let runner = new toolrunner.ToolRunner('openssl',
['enc', '-d', '-aes-256-cbc', '-md', 'sha512', '-salt', '-in',
enc_rsa_key_pth, '-out', 'config/deploy_id_rsa', '-k', deploy_key, '-a']);
yield runner.exec();
});
}
if (process.platform == 'darwin') {
let runner_ = new toolrunner.ToolRunner('xcode-select', ['--install']);
runner_.exec();
} else {
let runner0 = new toolrunner.ToolRunner('sudo',
['apt-get', 'update']);
runner0.exec();
let runner_ = new toolrunner.ToolRunner('sudo',
['apt-get', 'install', 'ruby-full', 'build-essential', 'postgresql', 'libpq-dev']);
yield runner_.exec();
}
// WORKAROUND, TODO: Parse version from Gemfile
let runner = null;
if (process.platform == 'darwin') {
runner = new toolrunner.ToolRunner('gem',
['install', 'bundler:1.17.2']);
} else {
runner = new toolrunner.ToolRunner('sudo',
['gem', 'install', 'bundler:1.17.2']);
}
yield runner.exec();
//let runner0 = new toolrunner.ToolRunner('gem', ['install', 'capistrano', 'capistrano-rails']);
//yield runner0.exec();
//let runner1 = new toolrunner.ToolRunner('bundle', ['update', '--bundler']);
//yield runner1.exec();
let runner2 = null;
if (process.platform == 'darwin') {
runner2 = new toolrunner.ToolRunner('bundle', ['install', '--deployment']);
dest = dest || (yield _createExtractFolder(dest));
const originalCwd = process.cwd();
process.chdir(dest);
if (_7zPath) {
try {
const args = [
'x',
'-bb1',
'-bd',
'-sccUTF-8',
file
];
const options = {
silent: true
};
yield exec_1.exec(`"${_7zPath}"`, args, options);
}
finally {
process.chdir(originalCwd);
}
}
else {
const escapedScript = path
.join(__dirname, '..', 'scripts', 'Invoke-7zdec.ps1')
.replace(/'/g, "''")
.replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines
const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, '');
const escapedTarget = dest.replace(/'/g, "''").replace(/"|\n|\r/g, '');
const command = `& '${escapedScript}' -Source '${escapedFile}' -Target '${escapedTarget}'`;
const args = [
'-NoLogo',
'-Sta',
dest = dest || (yield _createExtractFolder(dest));
const originalCwd = process.cwd();
process.chdir(dest);
if (_7zPath) {
try {
const args = [
'x',
'-bb1',
'-bd',
'-sccUTF-8',
file
];
const options = {
silent: true
};
yield exec_1.exec(`"${_7zPath}"`, args, options);
}
finally {
process.chdir(originalCwd);
}
}
else {
const escapedScript = path
.join(__dirname, '..', 'scripts', 'Invoke-7zdec.ps1')
.replace(/'/g, "''")
.replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines
const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, '');
const escapedTarget = dest.replace(/'/g, "''").replace(/"|\n|\r/g, '');
const command = `& '${escapedScript}' -Source '${escapedFile}' -Target '${escapedTarget}'`;
const args = [
'-NoLogo',
'-Sta',
// check the os version and run the respective script
let script_path = '';
switch (os_version) {
case 'darwin':
script_path = await build(os_version + '.sh', version, os_version);
await exec('sh ' + script_path + ' ' + version + ' ' + __dirname);
break;
case 'linux': {
const pecl: string = await utils.getInput('pecl', false);
script_path = await build(os_version + '.sh', version, os_version);
await exec('sh ' + script_path + ' ' + version + ' ' + pecl);
break;
}
case 'win32':
script_path = await build('win32.ps1', version, os_version);
await exec(
'pwsh ' + script_path + ' -version ' + version + ' -dir ' + __dirname
);
break;
}
await matchers.addMatchers();
} catch (error) {
core.setFailed(error.message);
}
}