feat: psap init
This commit is contained in:
127
bin/makepkg.sh
Executable file
127
bin/makepkg.sh
Executable file
@@ -0,0 +1,127 @@
|
||||
#!/bin/bash
|
||||
|
||||
usage() {
|
||||
echo "Usage: $0 deb|rpm [option]..."
|
||||
echo
|
||||
echo "Make omc package, option as follow:"
|
||||
echo " deb|rpm, deb: ubuntu|debian package build by dpkg"
|
||||
echo " rpm: centos/redhat package, build by rpmbuild"
|
||||
echo " -r, =build root directory build root directory, default directory is $HOME/omc.git"
|
||||
echo " -d dump SQL from database"
|
||||
echo " -m, =be|fe|all be: only process back-end code, default if non input"
|
||||
echo " fe: only process front-end code"
|
||||
echo " all: process all include be and fe"
|
||||
echo " -c, =ba ba: customized for BA OMC"
|
||||
}
|
||||
|
||||
pkgtype=""
|
||||
new_args=()
|
||||
be_args=()
|
||||
# Traverse all parameters
|
||||
for arg in "$@"; do
|
||||
if [[ "$arg" == "deb" || "$arg" == "rpm" ]]; then
|
||||
pkgtype=$arg
|
||||
be_args+=("$arg")
|
||||
else
|
||||
new_args+=("$arg") # Add non pkgtype parameters to a new parameter list
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -z "$pkgtype" ]; then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Use a new parameter list
|
||||
set -- "${new_args[@]}"
|
||||
|
||||
rootdir=${HOME}/omc.git
|
||||
m_arg="*"
|
||||
while getopts "m:r:c:d" option; do
|
||||
case $option in
|
||||
m)
|
||||
m_arg=$(echo $OPTARG | tr '[:upper:]' '[:lower:]')
|
||||
;;
|
||||
r)
|
||||
rootdir=$OPTARG
|
||||
be_args+=("-r ${rootdir}")
|
||||
;;
|
||||
d)
|
||||
be_args+=("-d")
|
||||
;;
|
||||
c)
|
||||
c_arg=$(echo $OPTARG | tr '[:upper:]' '[:lower:]')
|
||||
if [ "${c_arg}" == "ba" ]; then
|
||||
pkgtype="badeb"
|
||||
be_args+=("${pkgtype}")
|
||||
fi
|
||||
;;
|
||||
\?)
|
||||
echo "Invalid option: -$OPTARG" >&2
|
||||
usage
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ ! -d ${rootdir} ]; then
|
||||
echo "Not exist directory: ${rootdir}"
|
||||
exit 3
|
||||
fi
|
||||
|
||||
bedir=${rootdir}/be.ems
|
||||
|
||||
builddir=${rootdir}/build.ems
|
||||
buildcustomized=${builddir}/customized
|
||||
customizeddir=${buildcustomized}/${c_arg}.d
|
||||
|
||||
fedir=${rootdir}/fe.ems.vue3
|
||||
feassetsdir=${fedir}/src/assets
|
||||
felocalesdir=${fedir}/src/i18n/locales
|
||||
feconstantsdir=${fedir}/src/constants
|
||||
fehooksdir=${fedir}/src/hooks
|
||||
|
||||
makefe() {
|
||||
cd ${fedir}
|
||||
git checkout ${feassetsdir}
|
||||
git checkout ${felocalesdir}
|
||||
git checkout ${feconstantsdir}
|
||||
git checkout ${fehooksdir}
|
||||
git pull
|
||||
if [ "${pkgtype}" == "badeb" ]; then
|
||||
cp -rf ${customizeddir}/images/* ${feassetsdir}
|
||||
cp -rf ${customizeddir}/locales/* ${felocalesdir}
|
||||
find "${feconstantsdir}" -type f -name '*.ts' -exec sed -i 's/[一-龥()“”,。?!]~·]//g' {} +
|
||||
find "${fehooksdir}" -type f -name '*.ts' -exec sed -i 's/[一-龥()“”,。?!]~·]//g' {} +
|
||||
fi
|
||||
npm install --force --registry https://registry.npmmirror.com
|
||||
echo -n "Building front-end vue ... "
|
||||
npm run build 1>/dev/null
|
||||
if [ $? = 0 ]; then
|
||||
echo "done"
|
||||
fi
|
||||
git checkout ${feassetsdir}
|
||||
git checkout ${felocalesdir}
|
||||
git checkout ${feconstantsdir}
|
||||
git checkout ${fehooksdir}
|
||||
}
|
||||
|
||||
makebe() {
|
||||
cd ${builddir}
|
||||
#chmod +x mkpkg.sh
|
||||
chmod +x build.sh
|
||||
./build.sh ${be_args[@]}
|
||||
}
|
||||
|
||||
case "${m_arg}" in
|
||||
fe)
|
||||
makefe
|
||||
;;
|
||||
all)
|
||||
makefe
|
||||
makebe
|
||||
;;
|
||||
be | *)
|
||||
makebe
|
||||
;;
|
||||
esac
|
||||
Reference in New Issue
Block a user