-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6e99373
commit 56d1ab9
Showing
14 changed files
with
83 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,6 +100,74 @@ function zipApp (p: string) { | |
return zip(p, p + '.zip') | ||
} | ||
|
||
function createDebInstaller (appPath: string) { | ||
ilog(`[${new Date().toLocaleString()}] Create .deb installer...`) | ||
const distRoot = path.dirname(appPath) | ||
const icon: { [size: string]: string } = { | ||
'16x16': path.join(__dirname, '../src/res/icon', '16x16.png'), | ||
'24x24': path.join(__dirname, '../src/res/icon', '24x24.png'), | ||
'32x32': path.join(__dirname, '../src/res/icon', '32x32.png'), | ||
'48x48': path.join(__dirname, '../src/res/icon', '48x48.png'), | ||
'64x64': path.join(__dirname, '../src/res/icon', '64x64.png'), | ||
'128x128': path.join(__dirname, '../src/res/icon', '128x128.png'), | ||
'256x256': path.join(__dirname, '../src/res/icon', '256x256.png'), | ||
'512x512': path.join(__dirname, '../src/res/icon', '512x512.png'), | ||
'1024x1024': path.join(__dirname, '../src/res/icon', '1024x1024.png') | ||
} | ||
fs.mkdirsSync(path.join(distRoot, '.tmp/DEBIAN')) | ||
fs.writeFileSync( | ||
path.join(distRoot, '.tmp/DEBIAN/control'), | ||
`Package: ${pkg.name} | ||
Version: ${pkg.version}-${Math.round(new Date().getTime() / 1000)} | ||
Section: games | ||
Priority: optional | ||
Architecture: ${arch === 'x64' ? 'amd64' : 'i386'} | ||
Depends: kde-cli-tools | kde-runtime | trash-cli | libglib2.0-bin | gvfs-bin, libgconf-2-4, libgtk-3-0 (>= 3.10.0), libnotify4, libnss3 (>= 2:3.26), libxtst6, xdg-utils | ||
Installed-Size: ${getDirectorySizeSync(appPath)} | ||
Maintainer: ${pkg.author.name} <[email protected]> | ||
Homepage: https://github.com/${pkg.author.name}/${pkg.name} | ||
Description: CGSS Desktop Application | ||
`) | ||
|
||
fs.mkdirsSync(path.join(distRoot, '.tmp/usr/share/applications')) | ||
fs.writeFileSync( | ||
path.join(distRoot, `.tmp/usr/share/applications/${pkg.name}.desktop`), | ||
`[Desktop Entry] | ||
Name=${pkg.name} | ||
Comment=CGSS Desktop Application | ||
GenericName=Game Utility | ||
Exec=/usr/share/${pkg.name}/${pkg.name} | ||
Icon=${pkg.name} | ||
Type=Application | ||
StartupNotify=true | ||
Categories=Utility;Game; | ||
`) | ||
|
||
for (const size in icon) { | ||
fs.mkdirsSync(path.join(distRoot, `.tmp/usr/share/icons/hicolor/${size}/apps`)) | ||
fs.copySync(icon[size], path.join(distRoot, `.tmp/usr/share/icons/hicolor/${size}/apps/${pkg.name}.png`)) | ||
} | ||
fs.copySync(appPath, path.join(distRoot, `.tmp/usr/share/${pkg.name}`)) | ||
|
||
execSync(`dpkg -b ./.tmp ./${pkg.name}-v${pkg.version}-linux-${arch}.deb`, { cwd: distRoot, stdio: 'inherit' }) | ||
fs.removeSync(path.join(distRoot, '.tmp')) | ||
} | ||
|
||
function getDirectorySizeSync (dir: string) { | ||
const ls = fs.readdirSync(dir) | ||
let size = 0 | ||
for (let i = 0; i < ls.length; i++) { | ||
const item = path.join(dir, ls[i]) | ||
const stat = fs.statSync(item) | ||
if (stat.isDirectory()) { | ||
size += getDirectorySizeSync(item) | ||
} else { | ||
size += stat.size | ||
} | ||
} | ||
return size | ||
} | ||
|
||
async function main () { | ||
const start = new Date().getTime() | ||
// await reInstall() | ||
|
@@ -115,6 +183,7 @@ async function main () { | |
await copyExtra(root) | ||
const newPath = await rename(appPath) | ||
const size = await zipApp(newPath) | ||
if (process.platform === 'linux') createDebInstaller(newPath) | ||
ilog(`[${new Date().toLocaleString()}] Size: ${size} Bytes`) | ||
return (new Date().getTime() - start) / 1000 | ||
} | ||
|
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters