mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-11-10 11:40:53 +08:00
build: Add upx compression
This commit is contained in:
parent
a0dfbde0d3
commit
d6af9cd088
2 changed files with 75 additions and 26 deletions
|
|
@ -32,6 +32,9 @@ builds:
|
||||||
- arm
|
- arm
|
||||||
- ppc64le
|
- ppc64le
|
||||||
- s390x
|
- s390x
|
||||||
|
hooks:
|
||||||
|
post:
|
||||||
|
- ./ci/script.sh compress_binary {{ .Path }} {{ .Arch }}
|
||||||
|
|
||||||
- id: core
|
- id: core
|
||||||
dir: core
|
dir: core
|
||||||
|
|
@ -54,6 +57,9 @@ builds:
|
||||||
- arm
|
- arm
|
||||||
- ppc64le
|
- ppc64le
|
||||||
- s390x
|
- s390x
|
||||||
|
hooks:
|
||||||
|
post:
|
||||||
|
- ./ci/script.sh compress_binary {{ .Path }} {{ .Arch }}
|
||||||
|
|
||||||
archives:
|
archives:
|
||||||
- formats: [ 'tar.gz' ]
|
- formats: [ 'tar.gz' ]
|
||||||
|
|
|
||||||
95
ci/script.sh
95
ci/script.sh
|
|
@ -1,36 +1,79 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
command -v wget >/dev/null || {
|
set -e
|
||||||
echo "wget not found, please install it and try again ."
|
|
||||||
exit 1
|
download_resources() {
|
||||||
|
command -v wget >/dev/null || {
|
||||||
|
echo "wget not found, please install it and try again."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ ! -f "1pctl" ]; then
|
||||||
|
wget https://github.com/1Panel-dev/installer/raw/v2/1pctl
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f "install.sh" ]; then
|
||||||
|
wget https://github.com/1Panel-dev/installer/raw/v2/install.sh
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f "1panel-core.service" ]; then
|
||||||
|
wget https://github.com/1Panel-dev/installer/raw/v2/1panel-core.service
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f "1panel-agent.service" ]; then
|
||||||
|
wget https://github.com/1Panel-dev/installer/raw/v2/1panel-agent.service
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d "lang" ]; then
|
||||||
|
mkdir -p lang && cd lang
|
||||||
|
for lang in en fa pt-BR ru zh; do
|
||||||
|
wget -q https://github.com/1Panel-dev/installer/raw/v2/lang/$lang.sh
|
||||||
|
done
|
||||||
|
cd ..
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f "GeoIP.mmdb" ]; then
|
||||||
|
wget https://resource.fit2cloud.com/1panel/package/v2/geo/GeoIP.mmdb
|
||||||
|
fi
|
||||||
|
|
||||||
|
chmod 755 1pctl install.sh
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ ! -f "1pctl" ]; then
|
compress_binary() {
|
||||||
wget https://github.com/1Panel-dev/installer/raw/v2/1pctl
|
local binary_path="$1"
|
||||||
fi
|
local arch="$2"
|
||||||
|
|
||||||
if [ ! -f "install.sh" ]; then
|
echo "Attempting to compress: $binary_path for arch: $arch"
|
||||||
wget https://github.com/1Panel-dev/installer/raw/v2/install.sh
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -f "1panel-core.service" ]; then
|
if [ "$arch" = "s390x" ]; then
|
||||||
wget https://github.com/1Panel-dev/installer/raw/v2/1panel-core.service
|
echo "Skipping UPX compression for s390x"
|
||||||
fi
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
if [ ! -f "1panel-agent.service" ]; then
|
if ! command -v upx >/dev/null; then
|
||||||
wget https://github.com/1Panel-dev/installer/raw/v2/1panel-agent.service
|
echo "Installing upx..."
|
||||||
fi
|
if [ "$(uname -m)" = "s390x" ]; then
|
||||||
|
echo "UPX not supported on s390x"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
if [ ! -d "lang" ]; then
|
sudo apt-get update
|
||||||
mkdir -p lang && cd lang
|
sudo apt-get install -y upx-ucl || {
|
||||||
for lang in en fa pt-BR ru zh; do
|
echo "Failed to install upx via apt, trying source build"
|
||||||
wget -q https://github.com/1Panel-dev/installer/raw/v2/lang/$lang.sh
|
git clone https://github.com/upx/upx.git
|
||||||
done
|
cd upx
|
||||||
cd ..
|
git checkout v4.2.2
|
||||||
fi
|
make
|
||||||
|
sudo cp src/upx /usr/local/bin/
|
||||||
|
cd ..
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
|
||||||
if [ ! -f "GeoIP.mmdb" ]; then
|
upx --best --lzma "$binary_path" && echo "[ok] Compressed: $binary_path" || echo "[warn] Failed to compress: $binary_path"
|
||||||
wget https://resource.fit2cloud.com/1panel/package/v2/geo/GeoIP.mmdb
|
}
|
||||||
fi
|
|
||||||
|
|
||||||
chmod 755 1pctl install.sh
|
if [ "$1" = "compress_binary" ]; then
|
||||||
|
compress_binary "$2" "$3"
|
||||||
|
else
|
||||||
|
download_resources
|
||||||
|
fi
|
||||||
Loading…
Add table
Reference in a new issue