Skip to content

Commit e54c184

Browse files
committed
losslesscut: optimize the packaging process
1 parent a7b6ad0 commit e54c184

4 files changed

Lines changed: 165 additions & 39 deletions

File tree

archlinuxcn/losslesscut/LICENSE

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Copyright Arch Linux Contributors
2+
3+
Permission to use, copy, modify, and/or distribute this software for
4+
any purpose with or without fee is hereby granted.
5+
6+
THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL
7+
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
8+
OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE
9+
FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
10+
DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
11+
AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
12+
OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

archlinuxcn/losslesscut/PKGBUILD

Lines changed: 114 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -8,86 +8,161 @@ pkgver=3.68.0
88
_electronversion=38
99
_nodeversion=22
1010
pkgrel=4
11-
pkgdesc="The swiss army knife of lossless video/audio editing.Using system-wide ffmpeg.(Use system-wide electron)"
11+
pkgdesc="The swiss army knife of lossless video/audio editing"
1212
arch=('x86_64')
1313
url="https://github.com/mifi/${_reponame}"
1414
license=('GPL-2.0-only')
15-
conflicts=(
16-
"${pkgname}-git"
17-
"${pkgname}-bin"
18-
)
19-
provides=(
20-
"${pkgname}"
21-
)
22-
depends=(
23-
"electron${_electronversion}"
24-
'ffmpeg'
25-
)
26-
makedepends=(
27-
'nvm'
28-
'npm'
29-
'yarn'
30-
'jq'
31-
)
15+
conflicts=("${pkgname}-git" "${pkgname}-bin")
16+
depends=("electron${_electronversion}" 'ffmpeg' 'bash' 'hicolor-icon-theme')
17+
makedepends=('nodejs-lts-jod' 'npm' 'yarn' 'node-gyp' 'imagemagick' 'librsvg')
3218
source=(
3319
"${pkgname}-${pkgver}.tar.gz::${url}/archive/refs/tags/v${pkgver}.tar.gz"
20+
"fix-wayland-wmclass.patch"
3421
"${pkgname}.sh"
3522
)
3623
sha256sums=('b4b2e0d4ba06de0243dfa3be5ec964b28f6c694c412487143b9c68d54b94fbb0'
24+
'5854853fb487b8c5e659b943b317f7670c2d038839075182ac8db988ddb7ba61'
3725
'31ad33b633744f5361abd964be306cea53ae1050e760c787115f7eca60045ae6')
38-
_ensure_local_nvm() {
39-
local NVM_DIR="${srcdir}/.nvm"
40-
source /usr/share/nvm/init-nvm.sh || [[ $? != 1 ]]
41-
nvm install "${_nodeversion}"
42-
nvm use "${_nodeversion}"
43-
}
44-
_get_electron_version() {
45-
_elec_ver=$(jq -r '.devDependencies["electron"] // .dependencies["electron"]' "package.json" | tr -d '^')
46-
_main_ver=$(echo "${_elec_ver}" | cut -d. -f1)
47-
echo -e "The electron version is: \033[1;31m${_main_ver}\033[0m"
48-
}
26+
4927
prepare() {
50-
cd "${srcdir}/${_reponame}-${pkgver}"
51-
_get_electron_version
5228
sed -i -e "
5329
s/@electronversion@/${_electronversion}/g
5430
s/@appname@/${pkgname}/g
5531
s/@runname@/app.asar/g
5632
s/@cfgdirname@/${_pkgname}/g
5733
s/@options@//g
5834
" "${srcdir}/${pkgname}.sh"
35+
36+
cd "${srcdir}/${_reponame}-${pkgver}"
37+
38+
# Fix the window title bar icon
39+
patch -Np1 -i "${srcdir}/fix-wayland-wmclass.patch"
40+
41+
export npm_config_cache="$srcdir/npm_cache"
5942
export ELECTRON_SKIP_BINARY_DOWNLOAD=1
6043
export SYSTEM_ELECTRON_VERSION="$(electron${_electronversion} -v | sed 's/v//g')"
6144
HOME="${srcdir}/.electron-gyp"
6245
mkdir -p "${srcdir}/.electron-gyp"
63-
_ensure_local_nvm
46+
6447
find src -type f -exec sed -i "s/process.resourcesPath/\'\/usr\/lib\/${pkgname}\'/g" {} +
6548
sed -e "
6649
s/\/app\/bin\/run.sh/${pkgname}/g;
6750
s/${_appname}/${pkgname}/g
6851
" -i "${_appname}.desktop"
6952
sed -i "s/${_appname}/${pkgname}/g" "${_appname}.appdata.xml"
7053
sed -i "s/\"electron\": \"[^\"]*\"/\"electron\": \"${SYSTEM_ELECTRON_VERSION}\"/g" package.json
54+
7155
yarn config set --home enableTelemetry 0
72-
NODE_ENV=development yarn add node-gyp
7356
NODE_ENV=development yarn install
7457
}
58+
7559
build() {
7660
cd "${srcdir}/${_reponame}-${pkgver}"
77-
_ensure_local_nvm
61+
62+
export npm_config_cache="$srcdir/npm_cache"
7863
export ELECTRON_SKIP_BINARY_DOWNLOAD=1
7964
export HOME="${srcdir}/.electron-gyp"
8065
local electronDist="/usr/lib/electron${_electronversion}"
66+
8167
NODE_ENV=production yarn run build
68+
69+
find -name '*.map' -type f -print -delete
70+
71+
pushd node_modules
72+
73+
# Compilation toolchains, type definitions, and browser compatibility data
74+
rm -rf @babel
75+
rm -rf @types
76+
rm -rf browserslist
77+
rm -rf caniuse-lite
78+
rm -rf node-gyp
79+
rm -rf typescript
80+
81+
# Linting, AST parsers, code analysis, and their underlying utilities
82+
rm -rf @aashutoshrathi
83+
rm -rf @eslint
84+
rm -rf @humanwhocodes
85+
rm -rf acorn
86+
rm -rf acorn-jsx
87+
rm -rf doctrine
88+
rm -rf eslint*
89+
rm -rf espree
90+
rm -rf esquery
91+
rm -rf estraverse
92+
rm -rf esutils
93+
rm -rf file-entry-cache
94+
rm -rf flat-cache
95+
rm -rf globals
96+
rm -rf graphemer
97+
rm -rf hermes-estree
98+
rm -rf hermes-parser
99+
rm -rf ignore
100+
rm -rf jsx-ast-utils
101+
rm -rf levn
102+
rm -rf optionator
103+
rm -rf prelude-ls
104+
rm -rf regexp-tree
105+
rm -rf text-table
106+
rm -rf type-check
107+
108+
# Testing frameworks and accessibility (A11y) automation testing tools
109+
rm -rf aria-query
110+
rm -rf axe-core
111+
rm -rf axobject-query
112+
rm -rf jest*
113+
rm -rf mocha*
114+
115+
# Polyfills and old syntax shims
116+
rm -rf es-abstract
117+
rm -rf es-iterator-helpers
118+
rm -rf *.prototype.*
119+
120+
find -name '*.gypi' -type f -print -delete
121+
find -name '*.ts' -type f -print -delete
122+
find -name '*.js.flow' -type f -print -delete
123+
find -name '*.cts' -type f -print -delete
124+
find -name '*.yml' ! -name '.yarn-state.yml' -type f -print -delete
125+
find -name '*.md' -type f -print -delete
126+
find -name '*.markdown' -type f -print -delete
127+
find -name .editorconfig -type f -print -delete
128+
find -name .nycrc -type f -print -delete
129+
find -name test.js -type f -print -delete
130+
find -name tsconfig.json -type f -print -delete
131+
find -name Makefile -type f -print -delete
132+
133+
find -type d -name 'doc' -prune -exec rm -rf {} +
134+
find -type d -name 'docs' -prune -exec rm -rf {} +
135+
find -type d -name 'benchmarks' -prune -exec rm -rf {} +
136+
find -type d -name 'tests' -prune -exec rm -rf {} +
137+
find -type d -name '__tests__' -prune -exec rm -rf {} +
138+
139+
popd
140+
82141
NODE_ENV=production yarn electron-builder --linux dir -c.electronDist="${electronDist}"
142+
143+
for res in 16 32 48 64 128 256 512 1024; do
144+
mkdir -p "icons-build/${res}x${res}"
145+
magick -background none "src/renderer/src/icon.svg" -resize "${res}x${res}" "icons-build/${res}x${res}/${pkgname}.png"
146+
done
83147
}
148+
84149
package() {
150+
cd "${srcdir}/${_reponame}-${pkgver}"
151+
85152
install -Dm755 "${srcdir}/${pkgname}.sh" "${pkgdir}/usr/bin/${pkgname}"
86-
install -Dm644 "${_reponame}-${pkgver}/dist/linux-unpacked/resources/app.asar" -t "${pkgdir}/usr/lib/${pkgname}"
87-
cp -r "${_reponame}-${pkgver}/dist/linux-unpacked/resources/locales" "${pkgdir}/usr/lib/${pkgname}/"
153+
154+
install -Dm644 "dist/linux-unpacked/resources/app.asar" -t "${pkgdir}/usr/lib/${pkgname}"
155+
cp -r "dist/linux-unpacked/resources/locales" "${pkgdir}/usr/lib/${pkgname}/"
156+
88157
ln -sf "/usr/bin/ffmpeg" "${pkgdir}/usr/lib/${pkgname}/ffmpeg"
89158
ln -sf "/usr/bin/ffprobe" "${pkgdir}/usr/lib/${pkgname}/ffprobe"
90-
install -Dm644 "${_reponame}-${pkgver}/icon-build/app-512.png" "${pkgdir}/usr/share/pixmaps/${pkgname}.png"
91-
install -Dm644 "${_reponame}-${pkgver}/${_appname}.desktop" "${pkgdir}/usr/share/applications/${pkgname}.desktop"
92-
install -Dm644 "${_reponame}-${pkgver}/${_appname}.appdata.xml" "${pkgdir}/usr/share/metainfo/${pkgname}.appdata.xml"
159+
160+
install -vDm644 "src/renderer/src/icon.svg" "${pkgdir}/usr/share/icons/hicolor/scalable/apps/${pkgname}.svg"
161+
for res in 16 32 48 64 128 256 512 1024; do
162+
install -Dm644 "icons-build/${res}x${res}/${pkgname}.png" \
163+
"${pkgdir}/usr/share/icons/hicolor/${res}x${res}/apps/${pkgname}.png"
164+
done
165+
166+
install -Dm644 "${_appname}.desktop" "${pkgdir}/usr/share/applications/${pkgname}.desktop"
167+
install -Dm644 "${_appname}.appdata.xml" "${pkgdir}/usr/share/metainfo/${pkgname}.appdata.xml"
93168
}

archlinuxcn/losslesscut/REUSE.toml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[[annotations]]
2+
path = [
3+
"PKGBUILD",
4+
"README.md",
5+
"keys/**",
6+
".SRCINFO",
7+
".nvchecker.toml",
8+
"*.install",
9+
"*.sysusers",
10+
"*.tmpfiles",
11+
"*.logrotate",
12+
"*.pam",
13+
"*.service",
14+
"*.socket",
15+
"*.timer",
16+
"*.desktop",
17+
"*.hook",
18+
]
19+
SPDX-FileCopyrightText = "Arch Linux contributors"
20+
SPDX-License-Identifier = "0BSD"
21+
22+
[[annotations]]
23+
path = [
24+
"fix-wayland-wmclass.patch",
25+
]
26+
SPDX-FileCopyrightText = "LosslessCut contributors"
27+
SPDX-License-Identifier = "MIT"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff --git a/src/main/index.ts b/src/main/index.ts
2+
index 9144dda..916330d 100644
3+
--- a/src/main/index.ts
4+
+++ b/src/main/index.ts
5+
@@ -50,6 +50,7 @@ remote.initialize();
6+
7+
8+
app.name = appName;
9+
+app.setDesktopName("losslesscut.desktop");
10+
11+
if (isWindows) {
12+
// in order to set the title on OS notifications on Windows, this needs to be set to app.name

0 commit comments

Comments
 (0)