Skip to content

Commit

Permalink
fix: Acount for .pkg or .dmg under Darwin
Browse files Browse the repository at this point in the history
  • Loading branch information
gcarreno committed Jan 6, 2022
1 parent e01b9f9 commit 4dbbd0d
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 17 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Unfortunately there are some restrictions:
```yaml
steps:
- uses: actions/checkout@v2
- uses: gcarreno/[email protected].5
- uses: gcarreno/[email protected].6
with:
lazarus-version: "dist"
include-packages: "Synapse 40.1"
Expand Down Expand Up @@ -110,7 +110,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Install Lazarus
uses: gcarreno/[email protected].5
uses: gcarreno/[email protected].6
with:
lazarus-version: ${{ matrix.lazarus-versions }}
include-packages: "Synapse 40.1"
Expand Down
42 changes: 35 additions & 7 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -603,11 +603,25 @@ class Lazarus {
let downloadFPCSRCURLDAR = this._getPackageURL('fpcsrc');
console.log(`_downloadLazarus - Downloading ${downloadFPCSRCURLDAR}`);
try {
// Decide what the local download filename should be
var downloadName = downloadFPCSRCURLDAR.endsWith('.dmg') ? 'fpcsrc.dmg' : 'fpcsrc.pkg';
// Perform the download
downloadPath_DAR = yield tc.downloadTool(downloadFPCSRCURLDAR, path.join(this._getTempDirectory(), 'fpcsrc.pkg'));
downloadPath_DAR = yield tc.downloadTool(downloadFPCSRCURLDAR, path.join(this._getTempDirectory(), downloadName));
console.log(`_downloadLazarus - Downloaded into ${downloadPath_DAR}`);
// Install the package
yield exec_1.exec(`sudo installer -pkg ${downloadPath_DAR} -target /`);
// Download could be a pkg or dmg, handle either case
if (downloadName == 'fpcsrc.dmg') {
// Mount DMG and intall package
yield exec_1.exec(`sudo hdiutil attach ${downloadPath_DAR}`);
// There MUST be a better way to do this
var fpcsrc = fs.readdirSync('/Volumes').filter(fn => fn.startsWith('fpcsrc'));
var loc = fs.readdirSync('/Volumes/' + fpcsrc[0]).filter(fn => fn.endsWith('.pkg'));
var full_path = '/Volumes/' + fpcsrc[0] + '/' + loc[0];
yield exec_1.exec(`sudo installer -package ${full_path} -target /`);
}
else {
// Install the package
yield exec_1.exec(`sudo installer -package ${downloadPath_DAR} -target /`);
}
}
catch (err) {
throw err;
Expand Down Expand Up @@ -643,11 +657,25 @@ class Lazarus {
let downloadLazURLDAR = this._getPackageURL('laz');
console.log(`_downloadLazarus - Downloading ${downloadLazURLDAR}`);
try {
// Decide what the local download filename should be
var downloadName = downloadLazURLDAR.endsWith('.dmg') ? 'lazarus.dmg' : 'lazarus.pkg';
// Perform the download
downloadPath_DAR = yield tc.downloadTool(downloadLazURLDAR, path.join(this._getTempDirectory(), 'lazarus.pkg'));
downloadPath_DAR = yield tc.downloadTool(downloadLazURLDAR, path.join(this._getTempDirectory(), downloadName));
console.log(`_downloadLazarus - Downloaded into ${downloadPath_DAR}`);
// Install the package
yield exec_1.exec(`sudo installer -pkg ${downloadPath_DAR} -target /`);
// Download could be a pkg or dmg, handle either case
if (downloadName == 'lazarus.dmg') {
// Mount DMG and intall package
yield exec_1.exec(`sudo hdiutil attach ${downloadPath_DAR}`);
// There MUST be a better way to do this
var laz = fs.readdirSync('/Volumes').filter(fn => fn.startsWith('lazarus'));
var loc = fs.readdirSync('/Volumes/' + laz[0]).filter(fn => fn.endsWith('.pkg'));
var full_path = '/Volumes/' + laz[0] + '/' + loc[0];
yield exec_1.exec(`sudo installer -package ${full_path} -target /`);
}
else {
// Install the package
yield exec_1.exec(`sudo installer -package ${downloadPath_DAR} -target /`);
}
}
catch (err) {
throw err;
Expand Down Expand Up @@ -982,7 +1010,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
Object.defineProperty(exports, "__esModule", ({ value: true }));
const core = __importStar(__webpack_require__(186));
const inst = __importStar(__webpack_require__(981));
const _version = '3.0.5';
const _version = '3.0.6';
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "setup-lazarus",
"version": "3.0.5",
"version": "3.0.6",
"description": "Set up your GitHub Actions workflow with a specific version of Lazarus",
"main": "lib/setup-lazarus.js",
"scripts": {
Expand Down
44 changes: 38 additions & 6 deletions src/Lazarus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -488,11 +488,27 @@ export class Lazarus{
let downloadFPCSRCURLDAR: string = this._getPackageURL('fpcsrc');
console.log(`_downloadLazarus - Downloading ${downloadFPCSRCURLDAR}`);
try {
// Decide what the local download filename should be
var downloadName = downloadFPCSRCURLDAR.endsWith('.dmg') ? 'fpcsrc.dmg' : 'fpcsrc.pkg';

// Perform the download
downloadPath_DAR = await tc.downloadTool(downloadFPCSRCURLDAR, path.join(this._getTempDirectory(), 'fpcsrc.pkg'));
downloadPath_DAR = await tc.downloadTool(downloadFPCSRCURLDAR, path.join(this._getTempDirectory(), downloadName));
console.log(`_downloadLazarus - Downloaded into ${downloadPath_DAR}`);
// Install the package
await exec(`sudo installer -pkg ${downloadPath_DAR} -target /`);

// Download could be a pkg or dmg, handle either case
if (downloadName == 'fpcsrc.dmg') {
// Mount DMG and intall package
await exec(`sudo hdiutil attach ${downloadPath_DAR}`);

// There MUST be a better way to do this
var fpcsrc = fs.readdirSync('/Volumes').filter(fn => fn.startsWith('fpcsrc'));
var loc = fs.readdirSync('/Volumes/'+fpcsrc[0]).filter(fn => fn.endsWith('.pkg'));
var full_path = '/Volumes/'+fpcsrc[0]+'/'+loc[0]
await exec(`sudo installer -package ${full_path} -target /`);
} else {
// Install the package
await exec(`sudo installer -package ${downloadPath_DAR} -target /`);
}
} catch(err) {
throw err;
}
Expand Down Expand Up @@ -531,11 +547,27 @@ export class Lazarus{
let downloadLazURLDAR: string = this._getPackageURL('laz');
console.log(`_downloadLazarus - Downloading ${downloadLazURLDAR}`);
try {
// Decide what the local download filename should be
var downloadName = downloadLazURLDAR.endsWith('.dmg') ? 'lazarus.dmg' : 'lazarus.pkg';

// Perform the download
downloadPath_DAR = await tc.downloadTool(downloadLazURLDAR, path.join(this._getTempDirectory(), 'lazarus.pkg'));
downloadPath_DAR = await tc.downloadTool(downloadLazURLDAR, path.join(this._getTempDirectory(), downloadName));
console.log(`_downloadLazarus - Downloaded into ${downloadPath_DAR}`);
// Install the package
await exec(`sudo installer -pkg ${downloadPath_DAR} -target /`);

// Download could be a pkg or dmg, handle either case
if (downloadName == 'lazarus.dmg') {
// Mount DMG and intall package
await exec(`sudo hdiutil attach ${downloadPath_DAR}`);

// There MUST be a better way to do this
var laz = fs.readdirSync('/Volumes').filter(fn => fn.startsWith('lazarus'));
var loc = fs.readdirSync('/Volumes/'+laz[0]).filter(fn => fn.endsWith('.pkg'));
var full_path = '/Volumes/'+laz[0]+'/'+loc[0]
await exec(`sudo installer -package ${full_path} -target /`);
} else {
// Install the package
await exec(`sudo installer -package ${downloadPath_DAR} -target /`);
}
} catch(err) {
throw err;
}
Expand Down
2 changes: 1 addition & 1 deletion src/setup-lazarus.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as core from '@actions/core';
import * as inst from './Installer';

const _version = '3.0.5';
const _version = '3.0.6';

async function run(): Promise<void> {
try {
Expand Down

0 comments on commit 4dbbd0d

Please sign in to comment.