Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

Commit

Permalink
Merge pull request #3 from sue445/support-ubuntu-16.04
Browse files Browse the repository at this point in the history
Support ubuntu 16.04
  • Loading branch information
masa-iwasaki authored Jan 1, 2020
2 parents 9e1d3b2 + aace7b3 commit 30cdc41
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
13 changes: 12 additions & 1 deletion lib/installer.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
};
Object.defineProperty(exports, "__esModule", { value: true });
const exec = __importStar(require("@actions/exec"));
const fs = __importStar(require("fs"));
function intallRbenv(options) {
return __awaiter(this, void 0, void 0, function* () {
yield exec.exec('sudo', ['git', 'clone', 'https://github.com/rbenv/rbenv.git', options.rbenvRoot]);
Expand All @@ -31,9 +32,19 @@ function installRubyBuild(options) {
"zlib1g-dev",
"libncurses5-dev",
"libffi-dev",
"libgdbm5",
"libgdbm-dev"
];
const osRelease = fs.readFileSync("/etc/os-release", { encoding: "utf-8" });
const matched = osRelease.match(/VERSION_ID="([0-9.]+)"/);
const ubuntuVersion = matched ? matched[1] : "0";
if (parseFloat(ubuntuVersion) >= 18.04) {
// Ubuntu 18.04+ (bionic)
packages.push("libgdbm5");
}
else {
// Ubuntu 16.04 (xenial)
packages.push("libgdbm3");
}
const rubyBuildInstallPath = `${options.rbenvRoot}/plugins/ruby-build`;
yield exec.exec('sudo', ['apt-get', 'update']);
yield exec.exec('sudo', ['apt-get', 'install', '-y', ...packages]);
Expand Down
14 changes: 13 additions & 1 deletion src/installer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as exec from '@actions/exec';
import * as fs from 'fs'

export async function intallRbenv(options: RbenvOptions) {
await exec.exec('sudo', ['git', 'clone', 'https://github.com/rbenv/rbenv.git', options.rbenvRoot]);
Expand All @@ -16,10 +17,21 @@ export async function installRubyBuild(options: RbenvOptions) {
"zlib1g-dev",
"libncurses5-dev",
"libffi-dev",
"libgdbm5",
"libgdbm-dev"
];

const osRelease = fs.readFileSync("/etc/os-release", {encoding: "utf-8"});
const matched = osRelease.match(/VERSION_ID="([0-9.]+)"/);
const ubuntuVersion = matched ? matched[1] : "0";

if (parseFloat(ubuntuVersion) >= 18.04 ){
// Ubuntu 18.04+ (bionic)
packages.push("libgdbm5");
} else {
// Ubuntu 16.04 (xenial)
packages.push("libgdbm3");
}

const rubyBuildInstallPath = `${options.rbenvRoot}/plugins/ruby-build`;

await exec.exec('sudo', ['apt-get', 'update']);
Expand Down

0 comments on commit 30cdc41

Please sign in to comment.