blob: 52a50382ce270533e9442709b197075f218fa8de (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
# Maintainer: Yakov Till <yakov.till@gmail.com>
pkgname=fileoptimizer-bin
_pkgname=fileoptimizer
# This is only the initial version
# The pkgver() function below will always fetch the latest version
pkgver=16.90.2829
# Always fetch the latest version
pkgver() {
curl -sL "https://sourceforge.net/projects/nikkhokkho/best_release.json" | \
jq -r '.release.filename' | \
sed -n 's|.*/\([0-9.]*\)/.*|\1|p'
}
pkgrel=1
pkgdesc="Lossless file size optimizer supporting multiple formats"
arch=('x86_64')
url="https://nikkhokkho.sourceforge.io/?page=FileOptimizer"
license=('AGPL-3.0-only or AGPL-3.0-or-later')
depends=('wine' 'wine-mono')
makedepends=('p7zip' 'jq' 'curl' 'icoutils' 'imagemagick') # Added icoutils and imagemagick
provides=("${_pkgname}")
conflicts=("${_pkgname}")
source=("$_pkgname-$pkgver.7z.exe::https://sourceforge.net/projects/nikkhokkho/files/FileOptimizer/${pkgver}/FileOptimizerFull.7z.exe/download"
"$_pkgname.desktop")
sha256sums=('SKIP'
'SKIP')
options=(!strip)
prepare() {
7z x "$_pkgname-$pkgver.7z.exe"
}
package() {
install -dm755 "$pkgdir/opt/$_pkgname"
install -Dm755 FileOptimizer64.exe "$pkgdir/opt/$_pkgname/FileOptimizer64.exe"
install -Dm755 WebView2Loader.dll "$pkgdir/opt/$_pkgname/WebView2Loader.dll"
cp -r Plugins64 "$pkgdir/opt/$_pkgname/"
install -Dm644 FileOptimizer.chm "$pkgdir/opt/$_pkgname/FileOptimizer.chm"
install -Dm644 *.po -t "$pkgdir/opt/$_pkgname/"
# Extract icon from executable
wrestool -x -t 14 FileOptimizer64.exe -o FileOptimizer.ico
# Convert ico to png files
magick FileOptimizer.ico fileoptimizer.png
# The above command creates files like fileoptimizer-0.png, fileoptimizer-1.png, etc.
# We need to identify which file corresponds to which size
# Create a directory to store the icon files
mkdir -p icons
# Move the generated PNG files to the icons directory
mv fileoptimizer-*.png icons/
# Install icons to appropriate directories based on their size
for icon in icons/fileoptimizer-*.png; do
size=$(identify -format "%wx%h" "$icon" | cut -d 'x' -f 1)
install -Dm644 "$icon" "$pkgdir/usr/share/icons/hicolor/${size}x${size}/apps/$_pkgname.png"
done
# Set the desktop file to use the installed icon
install -Dm644 "$_pkgname.desktop" "$pkgdir/usr/share/applications/$_pkgname.desktop"
# Create the wrapper script
install -Dm755 /dev/null "$pkgdir/usr/bin/$_pkgname"
cat << 'EOF' > "$pkgdir/usr/bin/$_pkgname"
#!/bin/bash
set -e
export WINEARCH=win64
export WINEDEBUG=-all
USER_CONFIG_DIR="$HOME/.config/fileoptimizer"
INSTALL_DIR="/opt/fileoptimizer"
# Create user config directory if it doesn't exist
mkdir -p "$USER_CONFIG_DIR"
# Create symlinks for program files if they don't exist
# This allows the app to be run from the user's config directory
# while the actual files remain in the system directory
create_symlink() {
local source="$1"
local target="$2"
if [ ! -e "$source" ]; then
echo "Warning: Source file $source does not exist" >&2
return 1
fi
if [ ! -e "$target" ]; then
ln -sf "$source" "$target"
fi
}
# Check if installation directory exists
if [ ! -d "$INSTALL_DIR" ]; then
echo "Error: Installation directory $INSTALL_DIR not found" >&2
exit 1
fi
# Create necessary symlinks
create_symlink "$INSTALL_DIR/FileOptimizer64.exe" "$USER_CONFIG_DIR/FileOptimizer64.exe" || exit 1
create_symlink "$INSTALL_DIR/WebView2Loader.dll" "$USER_CONFIG_DIR/WebView2Loader.dll" || exit 1
create_symlink "$INSTALL_DIR/Plugins64" "$USER_CONFIG_DIR/Plugins64" || exit 1
create_symlink "$INSTALL_DIR/FileOptimizer.chm" "$USER_CONFIG_DIR/FileOptimizer.chm" || exit 1
# Create empty config file if it doesn't exist
touch "$USER_CONFIG_DIR/FileOptimizer64.ini"
# Change to the config directory
cd "$USER_CONFIG_DIR" || { echo "Error: Cannot change to $USER_CONFIG_DIR" >&2; exit 1; }
# Run FileOptimizer with Wine, passing all arguments directly
wine "$USER_CONFIG_DIR/FileOptimizer64.exe" "$@"
EOF
}
|