From 6c0e636f3c8ffdf6e38d4d85bc1e9855c7a57935 Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Wed, 19 Mar 2025 20:55:53 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9Epkg=E6=89=93=E5=8C=85?= =?UTF-8?q?=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg.sh | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 pkg.sh diff --git a/pkg.sh b/pkg.sh new file mode 100644 index 0000000..c0f5222 --- /dev/null +++ b/pkg.sh @@ -0,0 +1,84 @@ +#!/bin/bash + +# front-end Catalog +WebDir=/root/omc.git/fe.ems.vue3 +BuildWeb="" +# back-end catalog +ApiDir=/root/omc.git/be.ems +BuildApi="" +# Package Catalog +BuildDir=/root/omc.git/build.ems +# Default Version Value +VERSION="2.2503.2" + +# usage +usage() { + echo "Usage: bash $0 [OPTION]" + echo + echo "Build Software Package OPTION:" + echo " -v Specify the version" + echo " --web Build Web ($WebDir)" + echo " --api Build Api ($ApiDir)" + echo " -h Display this help message" + echo + exit 1 +} +# Read command line arguments +while [[ $# -gt 0 ]]; do + case "$1" in + -v) VERSION="$2"; shift 2 ;; + --web) BuildWeb="build"; shift ;; + --api) BuildApi="build"; shift ;; + *) usage ;; + esac +done + +# =================== Web +echo +# Determine if --web is passed in +if [ -n "$BuildWeb" ]; then + cd $WebDir + git checkout . + git pull + git checkout lichang + git pull + + npm install --registry https://registry.npmmirror.com + npm run build + + output=$BuildDir/build/linux/usr/local/etc/omc/web + rm -rf $output + cp -rf dist/default/config.js dist/config.js + cp -rf dist $output + echo "===> web build dist copy to $output" +fi + +# =================== Api +echo +# Determine if --api is passed in +if [ -n "$BuildApi" ]; then + cd $ApiDir + git checkout . + git pull + git checkout lichang + git pull + + MOD_CONFIG="be.ems/src/framework/config" + go build -o omc -v -ldflags "-s -w -X '$MOD_CONFIG.Version=$VERSION' -X '$MOD_CONFIG.BuildTime=$(date)' -X '$MOD_CONFIG.GoVer=$(go version)'" + + output=$BuildDir/build/linux/usr/local/bin + cp -rf omc $output/omc + echo "===> go build omc copy to $output" + + # sshsvc + cd $ApiDir/sshsvc + make + cp -rf sshsvc $output/sshsvc + echo "===> go build sshsvc copy to $output" +fi + +# =================== deb/rpm +echo +bash $BuildDir/build/build.sh -v $VERSION + +# bash pkg.sh --web --api -v 2.2503.2