mirror of
https://github.com/webmin/webmin.git
synced 2025-07-23 00:30:33 +00:00
Add reworked CI/CD 1/2
[build]
This commit is contained in:
11
.github/build/bootstrap.bash
vendored
Executable file
11
.github/build/bootstrap.bash
vendored
Executable file
@ -0,0 +1,11 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# shellcheck disable=SC1091
|
||||||
|
# bootstrap.bash
|
||||||
|
# Copyright Ilia Ross <ilia@webmin.dev>
|
||||||
|
# Bootstrap the build process
|
||||||
|
|
||||||
|
# Source general build functions
|
||||||
|
source "./functions.bash" || exit 1
|
||||||
|
|
||||||
|
# Source build variables
|
||||||
|
source ./environment.bash || exit 1
|
77
.github/build/deb-mod.sh → .github/build/build-deb-module.bash
vendored
Normal file → Executable file
77
.github/build/deb-mod.sh → .github/build/build-deb-module.bash
vendored
Normal file → Executable file
@ -1,36 +1,31 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
# build-deb-module.bash
|
||||||
|
# Copyright Ilia Ross <ilia@webmin.dev>
|
||||||
#
|
#
|
||||||
# Automatically builds and updates repo metadata for Webmin modules.
|
# Automatically builds DEB Webmin module pulls changes from GitHub, creates
|
||||||
# Pulls latest changes from GitHub, detects release version based
|
# testing builds from the latest code with English-only support, production
|
||||||
# on what's available in the repo.
|
# builds from the latest tag, uploads them to the pre-configured repository,
|
||||||
#
|
# updates the repository metadata, and interacts with the environment using
|
||||||
# (DEB)
|
# bootstrap
|
||||||
#
|
#
|
||||||
# Usage:
|
# Usage:
|
||||||
# # Build all modules with production versions
|
|
||||||
# ./deb-mod.sh
|
|
||||||
#
|
#
|
||||||
# # Build all modules with development versions and debug
|
# Build testing module with in verbose mode
|
||||||
# ./deb-mod.sh --testing --debug
|
# ./build-deb-module.bash virtualmin-nginx --testing --verbose
|
||||||
#
|
#
|
||||||
# # Build specific module with version and release
|
# Build specific module with version and release
|
||||||
# ./deb-mod.sh virtualmin-nginx 2.36 2
|
# ./build-deb-module.bash virtualmin-nginx 2.36 2
|
||||||
#
|
#
|
||||||
|
|
||||||
# shellcheck disable=SC1091
|
# shellcheck disable=SC1091
|
||||||
# Source build variables
|
# Bootstrap build environment
|
||||||
source ./vars.sh || exit 1
|
source ./bootstrap.bash || exit 1
|
||||||
|
|
||||||
# Source build init
|
|
||||||
source ./init.sh || exit 1
|
|
||||||
|
|
||||||
# Source general build functions
|
|
||||||
source ./funcs.sh || exit 1
|
|
||||||
|
|
||||||
# Build module func
|
# Build module func
|
||||||
build_module() {
|
build_module() {
|
||||||
# Always return back to root directory
|
# Always return back to root directory
|
||||||
cd "$root" || exit 1
|
cd "$ROOT_DIR" || exit 1
|
||||||
|
|
||||||
# Define variables
|
# Define variables
|
||||||
local last_commit_date
|
local last_commit_date
|
||||||
@ -38,9 +33,8 @@ build_module() {
|
|||||||
local verorig=""
|
local verorig=""
|
||||||
local module=$1
|
local module=$1
|
||||||
local rel
|
local rel
|
||||||
local relval
|
|
||||||
local devel=0
|
local devel=0
|
||||||
local root_module="$root/$module"
|
local root_module="$ROOT_DIR/$module"
|
||||||
|
|
||||||
# Print build actual date
|
# Print build actual date
|
||||||
date=$(get_current_date)
|
date=$(get_current_date)
|
||||||
@ -53,7 +47,7 @@ build_module() {
|
|||||||
|
|
||||||
# Pull or clone module repository
|
# Pull or clone module repository
|
||||||
remove_dir "$root_module"
|
remove_dir "$root_module"
|
||||||
cmd=$(make_module_repo_cmd "$module")
|
cmd=$(make_module_repo_cmd "$module" "$MODULES_REPO_URL")
|
||||||
eval "$cmd"
|
eval "$cmd"
|
||||||
rs=$?
|
rs=$?
|
||||||
|
|
||||||
@ -67,10 +61,8 @@ build_module() {
|
|||||||
fi
|
fi
|
||||||
if [[ "'$3'" != *"--"* ]] && [[ -n "$3" ]]; then
|
if [[ "'$3'" != *"--"* ]] && [[ -n "$3" ]]; then
|
||||||
rel=$3
|
rel=$3
|
||||||
relval="-$3"
|
|
||||||
else
|
else
|
||||||
rel=1
|
rel=1
|
||||||
relval=""
|
|
||||||
fi
|
fi
|
||||||
if [ -z "$ver" ]; then
|
if [ -z "$ver" ]; then
|
||||||
ver=$(get_module_version)
|
ver=$(get_module_version)
|
||||||
@ -92,12 +84,12 @@ build_module() {
|
|||||||
echo "Pre-clean up .."
|
echo "Pre-clean up .."
|
||||||
# Make sure directories exist
|
# Make sure directories exist
|
||||||
make_dir "$root_module/tmp"
|
make_dir "$root_module/tmp"
|
||||||
make_dir "$root_repos"
|
make_dir "$ROOT_REPOS"
|
||||||
|
|
||||||
# Purge old files
|
# Purge old files
|
||||||
purge_dir "$root_module/tmp"
|
purge_dir "$root_module/tmp"
|
||||||
if [ "$module" != "" ]; then
|
if [ "$module" != "" ]; then
|
||||||
rm -f "$root_repos/$module-latest"*
|
rm -f "$ROOT_REPOS/$module-latest"*
|
||||||
fi
|
fi
|
||||||
postcmd $?
|
postcmd $?
|
||||||
echo
|
echo
|
||||||
@ -109,8 +101,10 @@ build_module() {
|
|||||||
echo "Building packages .."
|
echo "Building packages .."
|
||||||
(
|
(
|
||||||
# XXXX Update actual module testing version dynamically
|
# XXXX Update actual module testing version dynamically
|
||||||
cd "$root" || exit 1
|
cd "$ROOT_DIR" || exit 1
|
||||||
cmd="$root/build-deps/makemoduledeb.pl --release $rel --deb-depends --licence 'GPLv3' --email 'ilia@virtualmin.dev' --allow-overwrite --target-dir $root_module/tmp $module $verbosity_level"
|
cmd="$ROOT_DIR/build-deps/makemoduledeb.pl --release $rel --deb-depends \
|
||||||
|
--licence 'GPLv3' --email '$BUILDER_MODULE_EMAIL' --allow-overwrite \
|
||||||
|
--target-dir $root_module/tmp $module $VERBOSITY_LEVEL"
|
||||||
eval "$cmd"
|
eval "$cmd"
|
||||||
postcmd $?
|
postcmd $?
|
||||||
)
|
)
|
||||||
@ -118,10 +112,12 @@ build_module() {
|
|||||||
echo
|
echo
|
||||||
echo "Preparing built files for upload .."
|
echo "Preparing built files for upload .."
|
||||||
# Move DEB to repos
|
# Move DEB to repos
|
||||||
cmd="find $root_module/tmp -name webmin-${module}*$verorig*\.deb -exec mv '{}' $root_repos \; $verbosity_level"
|
cmd="find $root_module/tmp -name webmin-${module}*$verorig*\.deb -exec mv '{}' \
|
||||||
|
$ROOT_REPOS \; $VERBOSITY_LEVEL"
|
||||||
eval "$cmd"
|
eval "$cmd"
|
||||||
if [ "$devel" -eq 1 ]; then
|
if [ "$devel" -eq 1 ]; then
|
||||||
cmd="mv -f $root_repos/*${module}*$verorig*\.deb $root_repos/${module}_${ver}-${rel}_all.deb $verbosity_level"
|
cmd="mv -f $ROOT_REPOS/*${module}*$verorig*\.deb \
|
||||||
|
$ROOT_REPOS/${module}_${ver}-${rel}_all.deb $VERBOSITY_LEVEL"
|
||||||
eval "$cmd"
|
eval "$cmd"
|
||||||
fi
|
fi
|
||||||
postcmd $?
|
postcmd $?
|
||||||
@ -129,7 +125,7 @@ build_module() {
|
|||||||
|
|
||||||
# Adjust module filename
|
# Adjust module filename
|
||||||
echo "Adjusting module filename .."
|
echo "Adjusting module filename .."
|
||||||
adjust_module_filename "$root_repos" "deb"
|
adjust_module_filename "$ROOT_REPOS" "deb"
|
||||||
postcmd $?
|
postcmd $?
|
||||||
echo
|
echo
|
||||||
|
|
||||||
@ -140,14 +136,13 @@ build_module() {
|
|||||||
|
|
||||||
# Main
|
# Main
|
||||||
if [ -n "$1" ] && [[ "'$1'" != *"--"* ]]; then
|
if [ -n "$1" ] && [[ "'$1'" != *"--"* ]]; then
|
||||||
build_module $@
|
MODULES_REPO_URL="$VIRTUALMIN_ORG_AUTH_URL"
|
||||||
cloud_upload_list_upload=("$root_repos/*$1*")
|
build_module "$@"
|
||||||
|
cloud_upload_list_upload=("$ROOT_REPOS/*$1*")
|
||||||
|
cloud_upload cloud_upload_list_upload
|
||||||
|
cloud_repo_sign_and_update
|
||||||
else
|
else
|
||||||
for module in "${webmin_modules[@]}"; do
|
# Error otherwise
|
||||||
build_module $module $@
|
echo "Error: No module specified"
|
||||||
done
|
exit 1
|
||||||
cloud_upload_list_upload=("$root_repos/*")
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cloud_upload cloud_upload_list_upload
|
|
||||||
cloud_repo_sign_and_update
|
|
@ -1,41 +1,34 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
# build-deb-package.bash
|
||||||
|
# Copyright Ilia Ross <ilia@webmin.dev>
|
||||||
#
|
#
|
||||||
# Copyright @iliajie <ilia@webmin.dev>
|
# Automatically builds DEB packages of Webmin and Usermin with the latest
|
||||||
#
|
# Authentic Theme, pulls changes from GitHub, creates testing builds from the
|
||||||
# Automatically builds and updates a repo metadata.
|
# latest code with English-only support, production builds from the latest tag,
|
||||||
# Pulls latest changes from GitHub, detects release
|
# uploads them to the pre-configured repository, updates the repository
|
||||||
# version based on what's available in the repo
|
# metadata, and interacts with the environment using bootstrap
|
||||||
#
|
|
||||||
# (Debian)
|
|
||||||
#
|
#
|
||||||
# Usage:
|
# Usage:
|
||||||
#
|
#
|
||||||
# # Pull and build production versions
|
# Pull and build production versions of both Webmin and Usermin
|
||||||
# # of both Webmin and Usermin
|
# ./build-deb-package.bash
|
||||||
# ./deb.sh
|
|
||||||
#
|
#
|
||||||
# # Pull and build devel versions
|
# Pull and build testing versions of both Webmin and Usermin
|
||||||
# # of both Webmin and Usermin
|
# ./build-deb-package.bash --testing
|
||||||
# ./deb.sh --testing
|
|
||||||
#
|
#
|
||||||
# # Pull and build production Webmin version 2.101, forcing
|
# Pull and build production Webmin version 2.101, forcing
|
||||||
# # release version 3, displaying detailed output
|
# release version 3, displaying verbose output
|
||||||
# ./deb.sh webmin 2.101 3 --debug
|
# ./build-deb-package.bash webmin 2.101 3 --testing
|
||||||
#
|
#
|
||||||
# # Pull and build production Usermin version 2.000,
|
# Pull and build production Usermin version 2.000,
|
||||||
# # automatically setting release version to minimal
|
# automatically setting release version
|
||||||
# ./deb.sh usermin 2.000
|
# ./build-deb-package.bash usermin 2.000
|
||||||
#
|
#
|
||||||
|
|
||||||
# shellcheck disable=SC1091
|
# shellcheck disable=SC1091
|
||||||
# Source build variables
|
# Bootstrap build environment
|
||||||
source ./vars.sh || exit 1
|
source ./bootstrap.bash || exit 1
|
||||||
|
|
||||||
# Source build init
|
|
||||||
source ./init.sh || exit 1
|
|
||||||
|
|
||||||
# Source general build functions
|
|
||||||
source ./funcs.sh || exit 1
|
|
||||||
|
|
||||||
# Build product func
|
# Build product func
|
||||||
build_prod() {
|
build_prod() {
|
||||||
@ -47,14 +40,14 @@ build_prod() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Always return back to root directory
|
# Always return back to root directory
|
||||||
cd "$root" || exit 1
|
cd "$ROOT_DIR" || exit 1
|
||||||
|
|
||||||
# Define root
|
# Define root
|
||||||
local ver=""
|
|
||||||
local prod=$1
|
local prod=$1
|
||||||
|
ROOT_PROD="$ROOT_DIR/$prod"
|
||||||
|
local root_apt="$ROOT_PROD/deb"
|
||||||
|
local ver=""
|
||||||
local devel=0
|
local devel=0
|
||||||
root_prod="$root/$prod"
|
|
||||||
root_apt="$root_prod/deb"
|
|
||||||
|
|
||||||
# Print build actual date
|
# Print build actual date
|
||||||
date=$(get_current_date)
|
date=$(get_current_date)
|
||||||
@ -64,29 +57,33 @@ build_prod() {
|
|||||||
echo " build start date: $date "
|
echo " build start date: $date "
|
||||||
echo " package format: DEB "
|
echo " package format: DEB "
|
||||||
echo " product: $prod "
|
echo " product: $prod "
|
||||||
(make_prod_repos "$root_prod") &
|
(make_prod_repos "$ROOT_PROD" "$prod") &
|
||||||
spinner " package output version:"
|
spinner " package output version:"
|
||||||
|
|
||||||
# Pull main project first to get the latest tag
|
# Pull main project first to get the latest tag
|
||||||
cd "$root_prod" || exit 1
|
cd "$ROOT_PROD" || exit 1
|
||||||
cmd="git pull $verbosity_level"
|
cmd="git pull $VERBOSITY_LEVEL"
|
||||||
eval "$cmd"
|
eval "$cmd"
|
||||||
rs1=$?
|
rs1=$?
|
||||||
# Clean and try again
|
# Clean and try again
|
||||||
if [ "$rs1" != "0" ]; then
|
if [ "$rs1" != "0" ]; then
|
||||||
cmd="git checkout \"*\" $verbosity_level && git clean -f -d $verbosity_level && git pull $verbosity_level"
|
cmd="git checkout \"*\" $VERBOSITY_LEVEL && \
|
||||||
|
git clean -f -d $VERBOSITY_LEVEL && \
|
||||||
|
git pull $VERBOSITY_LEVEL"
|
||||||
eval "$cmd"
|
eval "$cmd"
|
||||||
rs1=$?
|
rs1=$?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Descend to theme dir
|
# Descend to theme dir
|
||||||
cd "authentic-theme" || exit 1
|
cd "authentic-theme" || exit 1
|
||||||
cmd="git pull $verbosity_level"
|
cmd="git pull $VERBOSITY_LEVEL"
|
||||||
eval "$cmd"
|
eval "$cmd"
|
||||||
rs2=$?
|
rs2=$?
|
||||||
# Clean and try again
|
# Clean and try again
|
||||||
if [ "$rs2" != "0" ]; then
|
if [ "$rs2" != "0" ]; then
|
||||||
cmd="git checkout \"*\" $verbosity_level && git clean -f -d $verbosity_level && git pull $verbosity_level"
|
cmd="git checkout \"*\" $VERBOSITY_LEVEL && \
|
||||||
|
git clean -f -d $VERBOSITY_LEVEL && \
|
||||||
|
git pull $VERBOSITY_LEVEL"
|
||||||
eval "$cmd"
|
eval "$cmd"
|
||||||
rs2=$?
|
rs2=$?
|
||||||
fi
|
fi
|
||||||
@ -100,7 +97,7 @@ build_prod() {
|
|||||||
date_version=$(get_latest_commit_date_version)
|
date_version=$(get_latest_commit_date_version)
|
||||||
|
|
||||||
# Handle other params
|
# Handle other params
|
||||||
cd "$root_prod" || exit 1
|
cd "$ROOT_PROD" || exit 1
|
||||||
if [[ "'$2'" != *"--"* ]]; then
|
if [[ "'$2'" != *"--"* ]]; then
|
||||||
ver=$2
|
ver=$2
|
||||||
fi
|
fi
|
||||||
@ -120,7 +117,7 @@ build_prod() {
|
|||||||
# Set actual product version
|
# Set actual product version
|
||||||
echo "${ver}" >"version"
|
echo "${ver}" >"version"
|
||||||
fi
|
fi
|
||||||
printf "$ver-$rel\n"
|
printf "%s-%s\n" "$ver" "$rel"
|
||||||
echo "************************************************************************"
|
echo "************************************************************************"
|
||||||
|
|
||||||
echo "Pulling latest changes.."
|
echo "Pulling latest changes.."
|
||||||
@ -131,35 +128,35 @@ build_prod() {
|
|||||||
|
|
||||||
echo "Pre-clean up .."
|
echo "Pre-clean up .."
|
||||||
# Make sure directories exist
|
# Make sure directories exist
|
||||||
make_dir "$root_repos/"
|
make_dir "$ROOT_REPOS/"
|
||||||
make_dir "$root_apt/"
|
make_dir "$root_apt/"
|
||||||
make_dir "$root_prod/newkey/deb/"
|
make_dir "$ROOT_PROD/newkey/deb/"
|
||||||
make_dir "$root_prod/umodules/"
|
make_dir "$ROOT_PROD/umodules/"
|
||||||
make_dir "$root_prod/minimal/"
|
make_dir "$ROOT_PROD/minimal/"
|
||||||
make_dir "$root_prod/tarballs/"
|
make_dir "$ROOT_PROD/tarballs/"
|
||||||
|
|
||||||
# Re-create legacy link
|
# Re-create legacy link
|
||||||
remove_dir "$root/webadmin"
|
remove_dir "$ROOT_DIR/webadmin"
|
||||||
ln -s "$root/webmin" "$root/webadmin"
|
ln -s "$ROOT_DIR/webmin" "$ROOT_DIR/webadmin"
|
||||||
|
|
||||||
# Purge old files
|
# Purge old files
|
||||||
purge_dir "$root_prod/newkey/deb"
|
purge_dir "$ROOT_PROD/newkey/deb"
|
||||||
purge_dir "$root_prod/umodules"
|
purge_dir "$ROOT_PROD/umodules"
|
||||||
purge_dir "$root_prod/minimal"
|
purge_dir "$ROOT_PROD/minimal"
|
||||||
purge_dir "$root_prod/tarballs"
|
purge_dir "$ROOT_PROD/tarballs"
|
||||||
if [ "$prod" != "" ]; then
|
if [ "$prod" != "" ]; then
|
||||||
rm -f "$root_repos/$prod-"*
|
rm -f "$ROOT_REPOS/$prod-"*
|
||||||
rm -f "$root_repos/${prod}_"*
|
rm -f "$ROOT_REPOS/${prod}_"*
|
||||||
fi
|
fi
|
||||||
postcmd $?
|
postcmd $?
|
||||||
echo
|
echo
|
||||||
|
|
||||||
# Descend to project dir
|
# Descend to project dir
|
||||||
cd "$root_prod" || exit 1
|
cd "$ROOT_PROD" || exit 1
|
||||||
|
|
||||||
if [ "$english_only" = "1" ]; then
|
if [ "$english_only" = "1" ]; then
|
||||||
echo "Cleaning languages .."
|
echo "Cleaning languages .."
|
||||||
cmd="./bin/language-manager --mode=clean --yes $verbosity_level_with_input"
|
cmd="./bin/language-manager --mode=clean --yes $VERBOSITY_LEVEL_WITH_INPUT"
|
||||||
eval "$cmd"
|
eval "$cmd"
|
||||||
postcmd $?
|
postcmd $?
|
||||||
echo
|
echo
|
||||||
@ -167,7 +164,8 @@ build_prod() {
|
|||||||
# Force restore build directory
|
# Force restore build directory
|
||||||
if [ ! -f "lang/ja" ]; then
|
if [ ! -f "lang/ja" ]; then
|
||||||
echo "Restoring languages .."
|
echo "Restoring languages .."
|
||||||
cmd="git checkout \"*\" $verbosity_level && git clean -f -d $verbosity_level && git pull $verbosity_level"
|
cmd="git checkout \"*\" $VERBOSITY_LEVEL && git clean -f -d \
|
||||||
|
$VERBOSITY_LEVEL && git pull $VERBOSITY_LEVEL"
|
||||||
eval "$cmd"
|
eval "$cmd"
|
||||||
postcmd $?
|
postcmd $?
|
||||||
echo
|
echo
|
||||||
@ -176,40 +174,43 @@ build_prod() {
|
|||||||
|
|
||||||
echo "Pre-building package .."
|
echo "Pre-building package .."
|
||||||
eval "$cmd"
|
eval "$cmd"
|
||||||
cmd="./makedist.pl \"${ver}${relval}\" $verbosity_level"
|
cmd="./makedist.pl \"${ver}${relval}\" $VERBOSITY_LEVEL"
|
||||||
eval "$cmd"
|
eval "$cmd"
|
||||||
postcmd $?
|
postcmd $?
|
||||||
echo
|
echo
|
||||||
|
|
||||||
echo "Building package .."
|
echo "Building package .."
|
||||||
if [ "$relval" == "" ]; then
|
if [ "$relval" == "" ]; then
|
||||||
cmd="./makedebian.pl \"$ver\" $verbosity_level"
|
cmd="./makedebian.pl \"$ver\" $VERBOSITY_LEVEL"
|
||||||
else
|
else
|
||||||
cmd="./makedebian.pl \"$ver\" \"$rel\" $verbosity_level"
|
cmd="./makedebian.pl \"$ver\" \"$rel\" $VERBOSITY_LEVEL"
|
||||||
fi
|
fi
|
||||||
eval "$cmd"
|
eval "$cmd"
|
||||||
postcmd $?
|
postcmd $?
|
||||||
echo
|
echo
|
||||||
|
|
||||||
cd "$root" || exit 1
|
cd "$ROOT_DIR" || exit 1
|
||||||
echo "Preparing built files for upload .."
|
echo "Preparing built files for upload .."
|
||||||
cmd="cp -f $root_prod/tarballs/${prod}-${ver}*\.tar.gz $root_repos/${prod}-$ver.tar.gz $verbosity_level"
|
cmd="cp -f $ROOT_PROD/tarballs/${prod}-${ver}*\.tar.gz \
|
||||||
|
$ROOT_REPOS/${prod}-$ver.tar.gz $VERBOSITY_LEVEL"
|
||||||
eval "$cmd"
|
eval "$cmd"
|
||||||
cmd="find $root_apt -name ${prod}_${ver}${relval}*\.deb -exec mv '{}' $root_repos \; $verbosity_level"
|
cmd="find $root_apt -name ${prod}_${ver}${relval}*\.deb -exec mv '{}' \
|
||||||
|
$ROOT_REPOS \; $VERBOSITY_LEVEL"
|
||||||
eval "$cmd"
|
eval "$cmd"
|
||||||
cmd="mv -f $root_repos/${prod}_${ver}${relval}*\.deb $root_repos/${prod}_${ver}-${rel}_all.deb $verbosity_level"
|
cmd="mv -f $ROOT_REPOS/${prod}_${ver}${relval}*\.deb \
|
||||||
|
$ROOT_REPOS/${prod}_${ver}-${rel}_all.deb $VERBOSITY_LEVEL"
|
||||||
eval "$cmd"
|
eval "$cmd"
|
||||||
postcmd $?
|
postcmd $?
|
||||||
}
|
}
|
||||||
|
|
||||||
# Main
|
# Main
|
||||||
if [ -n "$1" ] && [[ "'$1'" != *"--"* ]]; then
|
if [ -n "$1" ] && [[ "$1" != --* ]]; then
|
||||||
build_prod $@
|
build_prod "$@"
|
||||||
cloud_upload_list_upload=("$root_repos/$1*")
|
cloud_upload_list_upload=("$ROOT_REPOS/$1*")
|
||||||
else
|
else
|
||||||
build_prod webmin $@
|
build_prod webmin "$@"
|
||||||
build_prod usermin $@
|
build_prod usermin "$@"
|
||||||
cloud_upload_list_upload=("$root_repos/*")
|
cloud_upload_list_upload=("$ROOT_REPOS/"*)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cloud_upload cloud_upload_list_upload
|
cloud_upload cloud_upload_list_upload
|
114
.github/build/rpm-mod.sh → .github/build/build-rpm-module.bash
vendored
Normal file → Executable file
114
.github/build/rpm-mod.sh → .github/build/build-rpm-module.bash
vendored
Normal file → Executable file
@ -1,36 +1,31 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
# build-rpm-module.bash
|
||||||
|
# Copyright Ilia Ross <ilia@webmin.dev>
|
||||||
#
|
#
|
||||||
# Automatically builds and updates repo metadata for Webmin modules.
|
# Automatically builds DEB Webmin module pulls changes from GitHub, creates
|
||||||
# Pulls latest changes from GitHub, detects release version based
|
# testing builds from the latest code with English-only support, production
|
||||||
# on what's available in the repo.
|
# builds from the latest tag, uploads them to the pre-configured repository,
|
||||||
#
|
# updates the repository metadata, and interacts with the environment using
|
||||||
# (RPM)
|
# bootstrap
|
||||||
#
|
#
|
||||||
# Usage:
|
# Usage:
|
||||||
# # Build all modules with production versions
|
|
||||||
# ./rpm-mod.sh
|
|
||||||
#
|
#
|
||||||
# # Build all modules with development versions and debug
|
# Build testing module with in verbose mode
|
||||||
# ./rpm-mod.sh --testing --debug
|
# ./build-rpm-module.bash virtualmin-nginx --testing --verbose
|
||||||
#
|
#
|
||||||
# # Build specific module with version and release
|
# Build specific module with version and release
|
||||||
# ./rpm-mod.sh virtualmin-nginx 2.36 3
|
# ./build-rpm-module.bash virtualmin-nginx 2.36 2
|
||||||
#
|
#
|
||||||
|
|
||||||
# shellcheck disable=SC1091
|
# shellcheck disable=SC1091
|
||||||
# Source build variables
|
# Bootstrap build environment
|
||||||
source ./vars.sh || exit 1
|
source ./bootstrap.bash || exit 1
|
||||||
|
|
||||||
# Source build init
|
|
||||||
source ./init.sh || exit 1
|
|
||||||
|
|
||||||
# Source general build functions
|
|
||||||
source ./funcs.sh || exit 1
|
|
||||||
|
|
||||||
# Build module func
|
# Build module func
|
||||||
build_module() {
|
build_module() {
|
||||||
# Always return back to root directory
|
# Always return back to root directory
|
||||||
cd "$root" || exit 1
|
cd "$ROOT_DIR" || exit 1
|
||||||
|
|
||||||
# Define variables
|
# Define variables
|
||||||
local last_commit_date
|
local last_commit_date
|
||||||
@ -40,7 +35,7 @@ build_module() {
|
|||||||
local rel
|
local rel
|
||||||
local epoch
|
local epoch
|
||||||
local devel=0
|
local devel=0
|
||||||
local root_module="$root/$module"
|
local root_module="$ROOT_DIR/$module"
|
||||||
|
|
||||||
# Print build actual date
|
# Print build actual date
|
||||||
date=$(get_current_date)
|
date=$(get_current_date)
|
||||||
@ -53,7 +48,7 @@ build_module() {
|
|||||||
|
|
||||||
# Pull or clone module repository
|
# Pull or clone module repository
|
||||||
remove_dir "$root_module"
|
remove_dir "$root_module"
|
||||||
cmd=$(make_module_repo_cmd "$module")
|
cmd=$(make_module_repo_cmd "$module" "$MODULES_REPO_URL")
|
||||||
eval "$cmd"
|
eval "$cmd"
|
||||||
rs=$?
|
rs=$?
|
||||||
|
|
||||||
@ -93,23 +88,23 @@ build_module() {
|
|||||||
echo "Pre-clean up .."
|
echo "Pre-clean up .."
|
||||||
# Make sure directories exist
|
# Make sure directories exist
|
||||||
make_dir "$root_module/tmp"
|
make_dir "$root_module/tmp"
|
||||||
make_dir "$root/newkey/rpm/"
|
make_dir "$ROOT_DIR/newkey/rpm/"
|
||||||
make_dir "$root/umodules/"
|
make_dir "$ROOT_DIR/umodules/"
|
||||||
make_dir "$root/minimal/"
|
make_dir "$ROOT_DIR/minimal/"
|
||||||
make_dir "$root/tarballs/"
|
make_dir "$ROOT_DIR/tarballs/"
|
||||||
make_dir "$root_build/BUILD/"
|
make_dir "$ROOT_BUILD/BUILD/"
|
||||||
make_dir "$root_build/BUILDROOT/"
|
make_dir "$ROOT_BUILD/BUILDROOT/"
|
||||||
make_dir "$root_build/RPMS/"
|
make_dir "$ROOT_BUILD/RPMS/"
|
||||||
make_dir "$root_rpms"
|
make_dir "$ROOT_RPMS"
|
||||||
make_dir "$root_build/SOURCES/"
|
make_dir "$ROOT_BUILD/SOURCES/"
|
||||||
make_dir "$root_build/SPECS/"
|
make_dir "$ROOT_BUILD/SPECS/"
|
||||||
make_dir "$root_build/SRPMS/"
|
make_dir "$ROOT_BUILD/SRPMS/"
|
||||||
make_dir "$root_repos"
|
make_dir "$ROOT_REPOS"
|
||||||
|
|
||||||
# Purge old files
|
# Purge old files
|
||||||
purge_dir "$root_module/tmp"
|
purge_dir "$root_module/tmp"
|
||||||
if [ "$module" != "" ]; then
|
if [ "$module" != "" ]; then
|
||||||
rm -f "$root_repos/$module-latest"*
|
rm -f "$ROOT_REPOS/$module-latest"*
|
||||||
fi
|
fi
|
||||||
postcmd $?
|
postcmd $?
|
||||||
echo
|
echo
|
||||||
@ -121,8 +116,10 @@ build_module() {
|
|||||||
echo "Building packages.."
|
echo "Building packages.."
|
||||||
(
|
(
|
||||||
# XXXX Update actual module testing version dynamically
|
# XXXX Update actual module testing version dynamically
|
||||||
cd "$root" || exit 1
|
cd "$ROOT_DIR" || exit 1
|
||||||
cmd="$root/build-deps/makemodulerpm.pl $epoch--release $rel --rpm-depends --licence 'GPLv3' --allow-overwrite --rpm-dir $root_build --target-dir $root_module/tmp $module $verbosity_level"
|
cmd="$ROOT_DIR/build-deps/makemodulerpm.pl $epoch--release \
|
||||||
|
$rel --rpm-depends --licence 'GPLv3' --allow-overwrite --rpm-dir \
|
||||||
|
$ROOT_BUILD --target-dir $root_module/tmp $module $VERBOSITY_LEVEL"
|
||||||
eval "$cmd"
|
eval "$cmd"
|
||||||
postcmd $?
|
postcmd $?
|
||||||
)
|
)
|
||||||
@ -130,10 +127,12 @@ build_module() {
|
|||||||
echo
|
echo
|
||||||
echo "Preparing built files for upload .."
|
echo "Preparing built files for upload .."
|
||||||
# Move RPM to repos
|
# Move RPM to repos
|
||||||
cmd="find $root_rpms -name wbm-$module*$verorig*\.rpm -exec mv '{}' $root_repos \; $verbosity_level"
|
cmd="find $ROOT_RPMS -name wbm-$module*$verorig*\.rpm -exec mv '{}' \
|
||||||
|
$ROOT_REPOS \; $VERBOSITY_LEVEL"
|
||||||
eval "$cmd"
|
eval "$cmd"
|
||||||
if [ "$devel" -eq 1 ]; then
|
if [ "$devel" -eq 1 ]; then
|
||||||
cmd="mv -f $root_repos/wbm-$module*$verorig*\.rpm $root_repos/${module}-$ver-$rel.noarch.rpm $verbosity_level"
|
cmd="mv -f $ROOT_REPOS/wbm-$module*$verorig*\.rpm \
|
||||||
|
$ROOT_REPOS/${module}-$ver-$rel.noarch.rpm $VERBOSITY_LEVEL"
|
||||||
eval "$cmd"
|
eval "$cmd"
|
||||||
fi
|
fi
|
||||||
postcmd $?
|
postcmd $?
|
||||||
@ -141,37 +140,32 @@ build_module() {
|
|||||||
|
|
||||||
# Adjust module filename
|
# Adjust module filename
|
||||||
echo "Adjusting module filename .."
|
echo "Adjusting module filename .."
|
||||||
adjust_module_filename "$root_repos" "rpm"
|
adjust_module_filename "$ROOT_REPOS" "rpm"
|
||||||
postcmd $?
|
postcmd $?
|
||||||
echo
|
echo
|
||||||
|
|
||||||
echo "Post-clean up .."
|
echo "Post-clean up .."
|
||||||
remove_dir "$root_module"
|
remove_dir "$root_module"
|
||||||
# Purge old files
|
# Purge old files
|
||||||
purge_dir "$root_prod/newkey/rpm"
|
purge_dir "$ROOT_BUILD/BUILD"
|
||||||
purge_dir "$root_prod/umodules"
|
purge_dir "$ROOT_BUILD/BUILDROOT"
|
||||||
purge_dir "$root_prod/minimal"
|
purge_dir "$ROOT_BUILD/RPMS"
|
||||||
purge_dir "$root_prod/tarballs"
|
purge_dir "$ROOT_BUILD/SOURCES"
|
||||||
purge_dir "$root_build/BUILD"
|
purge_dir "$ROOT_BUILD/SPECS"
|
||||||
purge_dir "$root_build/BUILDROOT"
|
purge_dir "$ROOT_BUILD/SRPMS"
|
||||||
purge_dir "$root_build/RPMS"
|
remove_dir "$ROOT_REPOS/repodata"
|
||||||
purge_dir "$root_build/SOURCES"
|
|
||||||
purge_dir "$root_build/SPECS"
|
|
||||||
purge_dir "$root_build/SRPMS"
|
|
||||||
remove_dir "$root_repos/repodata"
|
|
||||||
postcmd $?
|
postcmd $?
|
||||||
}
|
}
|
||||||
|
|
||||||
# Main
|
# Main
|
||||||
if [ -n "$1" ] && [[ "'$1'" != *"--"* ]]; then
|
if [ -n "$1" ] && [[ "'$1'" != *"--"* ]]; then
|
||||||
build_module $@
|
MODULES_REPO_URL="$VIRTUALMIN_ORG_AUTH_URL"
|
||||||
cloud_upload_list_upload=("$root_repos/*$1*")
|
build_module "$@"
|
||||||
|
cloud_upload_list_upload=("$ROOT_REPOS/*$1*")
|
||||||
|
cloud_upload cloud_upload_list_upload
|
||||||
|
cloud_repo_sign_and_update
|
||||||
else
|
else
|
||||||
for module in "${webmin_modules[@]}"; do
|
# Error otherwise
|
||||||
build_module $module $@
|
echo "Error: No module specified"
|
||||||
done
|
exit 1
|
||||||
cloud_upload_list_upload=("$root_repos/*")
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cloud_upload cloud_upload_list_upload
|
|
||||||
cloud_repo_sign_and_update
|
|
237
.github/build/build-rpm-package.bash
vendored
Executable file
237
.github/build/build-rpm-package.bash
vendored
Executable file
@ -0,0 +1,237 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
# build-rpm-package.bash
|
||||||
|
# Copyright Ilia Ross <ilia@webmin.dev>
|
||||||
|
#
|
||||||
|
# Automatically builds RPM packages of Webmin and Usermin with the latest
|
||||||
|
# Authentic Theme, pulls changes from GitHub, creates testing builds from the
|
||||||
|
# latest code with English-only support, production builds from the latest tag,
|
||||||
|
# uploads them to the pre-configured repository, updates the repository
|
||||||
|
# metadata, and interacts with the environment using bootstrap
|
||||||
|
#
|
||||||
|
# Usage:
|
||||||
|
#
|
||||||
|
# Pull and build production versions of both Webmin and Usermin
|
||||||
|
# ./build-rpm-package.bash
|
||||||
|
#
|
||||||
|
# Pull and build testing versions of both Webmin and Usermin
|
||||||
|
# ./build-rpm-package.bash --testing
|
||||||
|
#
|
||||||
|
# Pull and build production Webmin version 2.101, forcing
|
||||||
|
# release version 3, displaying verbose output
|
||||||
|
# ./build-rpm-package.bash webmin 2.101 3 --testing
|
||||||
|
#
|
||||||
|
# Pull and build production Usermin version 2.000,
|
||||||
|
# automatically setting release version
|
||||||
|
# ./build-rpm-package.bash usermin 2.000
|
||||||
|
#
|
||||||
|
|
||||||
|
# shellcheck disable=SC1091
|
||||||
|
# Bootstrap build environment
|
||||||
|
source ./bootstrap.bash || exit 1
|
||||||
|
|
||||||
|
# Build product func
|
||||||
|
build_prod() {
|
||||||
|
|
||||||
|
# Pack with English only in devel builds
|
||||||
|
local english_only=0
|
||||||
|
if [[ "'$*'" == *"--testing"* ]]; then
|
||||||
|
english_only=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Always return back to root directory
|
||||||
|
cd "$ROOT_DIR" || exit 1
|
||||||
|
|
||||||
|
# Define root
|
||||||
|
local ver=""
|
||||||
|
local prod=$1
|
||||||
|
local devel=0
|
||||||
|
ROOT_PROD="$ROOT_DIR/$prod"
|
||||||
|
|
||||||
|
# Print build actual date
|
||||||
|
date=$(get_current_date)
|
||||||
|
|
||||||
|
# Print opening header
|
||||||
|
echo "************************************************************************"
|
||||||
|
echo " build start date: $date "
|
||||||
|
echo " package format: RPM "
|
||||||
|
echo " product: $prod "
|
||||||
|
(make_prod_repos "$ROOT_PROD" "$prod") &
|
||||||
|
spinner " package output version:"
|
||||||
|
|
||||||
|
# Pull main project first to get the latest tag
|
||||||
|
cd "$ROOT_PROD" || exit 1
|
||||||
|
cmd="git pull $VERBOSITY_LEVEL"
|
||||||
|
eval "$cmd"
|
||||||
|
rs1=$?
|
||||||
|
# Clean and try again
|
||||||
|
if [ "$rs1" != "0" ]; then
|
||||||
|
cmd="git checkout \"*\" $VERBOSITY_LEVEL && git clean -f -d \
|
||||||
|
$VERBOSITY_LEVEL && git pull $VERBOSITY_LEVEL"
|
||||||
|
eval "$cmd"
|
||||||
|
rs1=$?
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Pull theme to theme dir
|
||||||
|
cd "authentic-theme" || exit 1
|
||||||
|
cmd="git pull $VERBOSITY_LEVEL"
|
||||||
|
eval "$cmd"
|
||||||
|
rs2=$?
|
||||||
|
# Clean and try again
|
||||||
|
if [ "$rs2" != "0" ]; then
|
||||||
|
cmd="git checkout \"*\" $VERBOSITY_LEVEL && git clean -f -d \
|
||||||
|
$VERBOSITY_LEVEL && git pull $VERBOSITY_LEVEL"
|
||||||
|
eval "$cmd"
|
||||||
|
rs2=$?
|
||||||
|
fi
|
||||||
|
if [ "$rs1" != "0" ] || [ "$rs2" != "0" ]; then
|
||||||
|
rs=1
|
||||||
|
else
|
||||||
|
rs=0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Build number
|
||||||
|
date_version=$(get_latest_commit_date_version)
|
||||||
|
|
||||||
|
# Handle other params
|
||||||
|
cd "$ROOT_PROD" || exit 1
|
||||||
|
if [[ "'$2'" != *"--"* ]]; then
|
||||||
|
ver=$2
|
||||||
|
fi
|
||||||
|
if [[ "'$3'" != *"--"* ]] && [[ -n "$3" ]]; then
|
||||||
|
rel=$3
|
||||||
|
else
|
||||||
|
rel=1
|
||||||
|
fi
|
||||||
|
if [ -z "$ver" ]; then
|
||||||
|
ver=$(get_current_repo_tag)
|
||||||
|
fi
|
||||||
|
if [[ "'$*'" == *"--testing"* ]]; then
|
||||||
|
devel=1
|
||||||
|
ver="$ver.$date_version"
|
||||||
|
# Set actual product version
|
||||||
|
echo "${ver}" >"version"
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf "%s-%s\n" "$ver" "$rel"
|
||||||
|
echo "************************************************************************"
|
||||||
|
|
||||||
|
echo "Pulling latest changes.."
|
||||||
|
# We need to pull first to get the latest tag,
|
||||||
|
# so here we only report an error if any
|
||||||
|
postcmd $rs
|
||||||
|
echo
|
||||||
|
|
||||||
|
echo "Pre-clean up .."
|
||||||
|
# Make sure directories exist
|
||||||
|
make_dir "$ROOT_PROD/newkey/rpm/"
|
||||||
|
make_dir "$ROOT_PROD/umodules/"
|
||||||
|
make_dir "$ROOT_PROD/minimal/"
|
||||||
|
make_dir "$ROOT_PROD/tarballs/"
|
||||||
|
make_dir "$ROOT_BUILD/BUILD/"
|
||||||
|
make_dir "$ROOT_BUILD/BUILDROOT/"
|
||||||
|
make_dir "$ROOT_BUILD/RPMS/"
|
||||||
|
make_dir "$ROOT_BUILD/SOURCES/"
|
||||||
|
make_dir "$ROOT_BUILD/SPECS/"
|
||||||
|
make_dir "$ROOT_BUILD/SRPMS/"
|
||||||
|
make_dir "$ROOT_REPOS/"
|
||||||
|
|
||||||
|
# Re-create legacy link
|
||||||
|
remove_dir "$ROOT_DIR/webadmin"
|
||||||
|
ln -s "$ROOT_DIR/webmin" "$ROOT_DIR/webadmin"
|
||||||
|
|
||||||
|
# Purge old files
|
||||||
|
purge_dir "$ROOT_PROD/newkey/rpm"
|
||||||
|
purge_dir "$ROOT_PROD/umodules"
|
||||||
|
purge_dir "$ROOT_PROD/minimal"
|
||||||
|
purge_dir "$ROOT_PROD/tarballs"
|
||||||
|
purge_dir "$ROOT_BUILD/BUILD"
|
||||||
|
purge_dir "$ROOT_BUILD/BUILDROOT"
|
||||||
|
purge_dir "$ROOT_BUILD/RPMS"
|
||||||
|
purge_dir "$ROOT_BUILD/SOURCES"
|
||||||
|
purge_dir "$ROOT_BUILD/SPECS"
|
||||||
|
purge_dir "$ROOT_BUILD/SRPMS"
|
||||||
|
remove_dir "$ROOT_REPOS/repodata"
|
||||||
|
if [ "$prod" != "" ]; then
|
||||||
|
rm -f "$ROOT_REPOS/$prod-"*
|
||||||
|
rm -f "$ROOT_REPOS/${prod}_"*
|
||||||
|
fi
|
||||||
|
postcmd $?
|
||||||
|
make_dir "$ROOT_BUILD/RPMS/noarch"
|
||||||
|
echo
|
||||||
|
|
||||||
|
# Descend to project dir
|
||||||
|
cd "$ROOT_PROD" || exit 1
|
||||||
|
|
||||||
|
if [ "$english_only" = "1" ]; then
|
||||||
|
echo "Cleaning languages .."
|
||||||
|
cmd="./bin/language-manager --mode=clean --yes \
|
||||||
|
$VERBOSITY_LEVEL_WITH_INPUT"
|
||||||
|
eval "$cmd"
|
||||||
|
postcmd $?
|
||||||
|
echo
|
||||||
|
else
|
||||||
|
# Force restore build directory
|
||||||
|
if [ ! -f "lang/ja" ]; then
|
||||||
|
echo "Restoring languages .."
|
||||||
|
cmd="git checkout \"*\" $VERBOSITY_LEVEL && git clean -f -d \
|
||||||
|
$VERBOSITY_LEVEL && git pull $VERBOSITY_LEVEL"
|
||||||
|
eval "$cmd"
|
||||||
|
postcmd $?
|
||||||
|
echo
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
echo "Pre-building package .."
|
||||||
|
eval "$cmd"
|
||||||
|
if [ "$rel" = "1" ]; then
|
||||||
|
args="$ver"
|
||||||
|
else
|
||||||
|
args="$ver-$rel"
|
||||||
|
fi
|
||||||
|
|
||||||
|
cmd="./makedist.pl \"$args\" $VERBOSITY_LEVEL"
|
||||||
|
eval "$cmd"
|
||||||
|
postcmd $?
|
||||||
|
echo
|
||||||
|
|
||||||
|
echo "Building package .."
|
||||||
|
cmd="./makerpm.pl \"$ver\" \"$rel\" $VERBOSITY_LEVEL"
|
||||||
|
eval "$cmd"
|
||||||
|
postcmd $?
|
||||||
|
echo
|
||||||
|
|
||||||
|
cd "$ROOT_DIR" || exit 1
|
||||||
|
echo "Preparing built files for upload .."
|
||||||
|
cmd="cp -f $ROOT_PROD/tarballs/$prod-$ver*\.tar.gz \
|
||||||
|
$ROOT_REPOS/${prod}-$ver.tar.gz $VERBOSITY_LEVEL"
|
||||||
|
eval "$cmd"
|
||||||
|
cmd="find $ROOT_RPMS -name $prod-$ver-$rel*\.rpm -exec mv '{}' \
|
||||||
|
$ROOT_REPOS \; $VERBOSITY_LEVEL"
|
||||||
|
eval "$cmd"
|
||||||
|
# cmd="mv -f $ROOT_REPOS/$prod-$ver-$rel*\.rpm \
|
||||||
|
# $ROOT_REPOS/${prod}-$ver-$rel.noarch.rpm $VERBOSITY_LEVEL" # file name is already always the same
|
||||||
|
# eval "$cmd"
|
||||||
|
postcmd $?
|
||||||
|
echo
|
||||||
|
|
||||||
|
echo "Post-clean up .."
|
||||||
|
cd "$ROOT_BUILD" || exit 1
|
||||||
|
for dir in *; do
|
||||||
|
cmd="rm -rf \"$dir/*\" $VERBOSITY_LEVEL"
|
||||||
|
eval "$cmd"
|
||||||
|
done
|
||||||
|
postcmd $?
|
||||||
|
}
|
||||||
|
|
||||||
|
# Main
|
||||||
|
if [ -n "$1" ] && [[ "$1" != --* ]]; then
|
||||||
|
build_prod "$@"
|
||||||
|
cloud_upload_list_upload=("$ROOT_REPOS/$1*")
|
||||||
|
else
|
||||||
|
build_prod webmin "$@"
|
||||||
|
build_prod usermin "$@"
|
||||||
|
cloud_upload_list_upload=("$ROOT_REPOS/"*)
|
||||||
|
fi
|
||||||
|
|
||||||
|
cloud_upload cloud_upload_list_upload
|
||||||
|
cloud_repo_sign_and_update
|
44
.github/build/environment.bash
vendored
Executable file
44
.github/build/environment.bash
vendored
Executable file
@ -0,0 +1,44 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
# environment.bash
|
||||||
|
# Copyright Ilia Ross <ilia@webmin.dev>
|
||||||
|
# Configures environment variables for the build process
|
||||||
|
|
||||||
|
# Builder email
|
||||||
|
BUILDER_PACKAGE_EMAIL="${ENV_BUILD__BUILDER_EMAIL:-ilia@webmin.dev}"
|
||||||
|
BUILDER_MODULE_EMAIL="${ENV_BUILD__BUILDER_EMAIL:-ilia@virtualmin.dev}"
|
||||||
|
|
||||||
|
# Set defaults
|
||||||
|
ROOT_DIR="${ENV_BUILD__ROOT:-$HOME}"
|
||||||
|
ROOT_REPOS="${ENV_BUILD__ROOT_REPOS:-$ROOT_DIR/repo}"
|
||||||
|
ROOT_BUILD="${ENV_BUILD__ROOT_BUILD:-$ROOT_DIR/rpmbuild}"
|
||||||
|
ROOT_RPMS="${ENV_BUILD__ROOT_RPMS:-$ROOT_BUILD/RPMS/noarch}"
|
||||||
|
|
||||||
|
# Create symlinks for Perl
|
||||||
|
PERL_SOURCE="/usr/bin/perl"
|
||||||
|
PERL_TARGET="/usr/local/bin/perl"
|
||||||
|
ln -fs "$PERL_SOURCE" "$PERL_TARGET"
|
||||||
|
|
||||||
|
# GitHub private repos access token
|
||||||
|
GITHUB_TOKEN="${ENV_BUILD__GITHUB_TOKEN}"
|
||||||
|
|
||||||
|
# Cloud upload config
|
||||||
|
CLOUD_UPLOAD_SSH_USER="${ENV_BUILD__CLOUD_UPLOAD_SSH_USER:-webmin.dev}"
|
||||||
|
CLOUD_UPLOAD_SSH_HOST="${ENV_BUILD__CLOUD_UPLOAD_SSH_HOST:-webmin.dev}"
|
||||||
|
CLOUD_UPLOAD_SSH_DIR="${ENV_BUILD__CLOUD_UPLOAD_SSH_DIR:-~/domains/download.webmin.dev/public_html}"
|
||||||
|
CLOUD_UPLOAD_GPG_PASSPHRASE="${WEBMIN_DEV__GPG_PH}"
|
||||||
|
|
||||||
|
# Define verbosity level
|
||||||
|
VERBOSITY_LEVEL=' >/dev/null 2>&1 </dev/null'
|
||||||
|
VERBOSITY_LEVEL_TO_FILE='2> /dev/null'
|
||||||
|
VERBOSITY_LEVEL_WITH_INPUT=' >/dev/null 2>&1'
|
||||||
|
if [[ "'$*'" == *"--verbose"* ]]; then
|
||||||
|
unset VERBOSITY_LEVEL VERBOSITY_LEVEL_TO_FILE VERBOSITY_LEVEL_WITH_INPUT
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Project links
|
||||||
|
GIT_BASE_URL="https://github.com"
|
||||||
|
GIT_AUTH_URL="https://${GITHUB_TOKEN}@github.com"
|
||||||
|
WEBMIN_ORG_URL="$GIT_BASE_URL/webmin"
|
||||||
|
WEBMIN_REPO="$WEBMIN_ORG_URL/webmin"
|
||||||
|
VIRTUALMIN_ORG_AUTH_URL="$GIT_AUTH_URL/virtualmin"
|
@ -1,31 +1,76 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#
|
# functions.bash
|
||||||
# Copyright @iliajie <ilia@webmin.dev>
|
# Copyright Ilia Ross <ilia@webmin.dev>
|
||||||
#
|
# Build functions for the build process
|
||||||
# General build functions
|
|
||||||
#
|
# Set up SSH keys on the build machine
|
||||||
#
|
setup_ssh() {
|
||||||
|
|
||||||
|
# If SSH keys are already set up, skip this step
|
||||||
|
if [ -f "$HOME/.ssh/id_rsa" ] && [ -f "$HOME/.ssh/id_rsa.pub" ]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create and set permissions on SSH directory
|
||||||
|
mkdir -p "$HOME/.ssh"
|
||||||
|
chmod 700 "$HOME/.ssh"
|
||||||
|
|
||||||
|
if [[ -n "${WEBMIN_DEV__SSH_PRV_KEY:-}" ]] &&
|
||||||
|
[[ -n "${WEBMIN_DEV__SSH_PUB_KEY:-}" ]]; then
|
||||||
|
echo "Setting up development SSH keys .."
|
||||||
|
|
||||||
|
# Generate new pair with right permissions
|
||||||
|
cmd="ssh-keygen -t rsa -q -f \"$HOME/.ssh/id_rsa\" -N \"\"$VERBOSITY_LEVEL"
|
||||||
|
eval "$cmd"
|
||||||
|
postcmd $?
|
||||||
|
echo
|
||||||
|
|
||||||
|
# Import SSH keys from secrets to be able to connect to the remote host
|
||||||
|
echo "$WEBMIN_DEV__SSH_PRV_KEY" > "$HOME/.ssh/id_rsa"
|
||||||
|
echo "$WEBMIN_DEV__SSH_PUB_KEY" > "$HOME/.ssh/id_rsa.pub"
|
||||||
|
|
||||||
|
elif [[ -n "${WEBMIN_PROD__SSH_PRV_KEY:-}" ]] &&
|
||||||
|
[[ -n "${WEBMIN_PROD__SSH_PUB_KEY:-}" ]]; then
|
||||||
|
echo "Setting up production SSH keys .."
|
||||||
|
|
||||||
|
# Generate new pair with right permissions
|
||||||
|
cmd="ssh-keygen -t rsa -q -f \"$HOME/.ssh/id_rsa\" -N \"\"$VERBOSITY_LEVEL"
|
||||||
|
eval "$cmd"
|
||||||
|
postcmd $?
|
||||||
|
|
||||||
|
# Import SSH keys from secrets to be able to connect to the remote host
|
||||||
|
echo "$WEBMIN_PROD__SSH_PRV_KEY" > "$HOME/.ssh/id_rsa"
|
||||||
|
echo "$WEBMIN_PROD__SSH_PUB_KEY" > "$HOME/.ssh/id_rsa.pub"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Upload to cloud
|
# Upload to cloud
|
||||||
# Usage:
|
# Usage:
|
||||||
# cloud_upload_list_delete=("$cloud_upload_ssh_dir/repodata")
|
# cloud_upload_list_delete=("$CLOUD_UPLOAD_SSH_DIR/repodata")
|
||||||
# cloud_upload_list_upload=("$root_repos/*" "$root_repos/repodata")
|
# cloud_upload_list_upload=("$ROOT_REPOS/*" "$ROOT_REPOS/repodata")
|
||||||
# cloud_upload cloud_upload_list_upload cloud_upload_list_delete
|
# cloud_upload cloud_upload_list_upload cloud_upload_list_delete
|
||||||
cloud_upload() {
|
cloud_upload() {
|
||||||
# Print new block only if definded
|
# Print new block only if defined
|
||||||
local ssh_args="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
|
local ssh_args="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
|
||||||
if [ -n "$1" ]; then
|
if [ -n "$1" ]; then
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Setup SSH keys on the build machine
|
||||||
|
setup_ssh
|
||||||
|
|
||||||
# Delete files on remote if needed
|
# Delete files on remote if needed
|
||||||
if [ -n "$2" ]; then
|
if [ -n "$2" ]; then
|
||||||
echo "Deleting given files in $cloud_upload_ssh_host .."
|
echo "Deleting given files in $CLOUD_UPLOAD_SSH_HOST .."
|
||||||
local -n arr_del=$2
|
local -n arr_del=$2
|
||||||
local err=0
|
local err=0
|
||||||
for d in "${arr_del[@]}"; do
|
for d in "${arr_del[@]}"; do
|
||||||
if [ -n "$d" ]; then
|
if [ -n "$d" ]; then
|
||||||
local cmd1="ssh $ssh_args $cloud_upload_ssh_user@$cloud_upload_ssh_host \"rm -rf $d\" $verbosity_level"
|
local cmd1="ssh $ssh_args $CLOUD_UPLOAD_SSH_USER@\
|
||||||
|
$CLOUD_UPLOAD_SSH_HOST \"rm -rf $d\" $VERBOSITY_LEVEL"
|
||||||
eval "$cmd1"
|
eval "$cmd1"
|
||||||
|
# shellcheck disable=SC2181
|
||||||
if [ "$?" != "0" ]; then
|
if [ "$?" != "0" ]; then
|
||||||
err=1
|
err=1
|
||||||
fi
|
fi
|
||||||
@ -37,13 +82,15 @@ cloud_upload() {
|
|||||||
|
|
||||||
# Upload files to remote
|
# Upload files to remote
|
||||||
if [ -n "$1" ]; then
|
if [ -n "$1" ]; then
|
||||||
echo "Uploading built files to $cloud_upload_ssh_host .."
|
echo "Uploading built files to $CLOUD_UPLOAD_SSH_HOST .."
|
||||||
local -n arr_upl=$1
|
local -n arr_upl=$1
|
||||||
local err=0
|
local err=0
|
||||||
for u in "${arr_upl[@]}"; do
|
for u in "${arr_upl[@]}"; do
|
||||||
if [ -n "$u" ]; then
|
if [ -n "$u" ]; then
|
||||||
local cmd2="scp $ssh_args -r $u $cloud_upload_ssh_user@$cloud_upload_ssh_host:$cloud_upload_ssh_dir/ $verbosity_level"
|
local cmd2="scp $ssh_args -r $u $CLOUD_UPLOAD_SSH_USER@\
|
||||||
|
$CLOUD_UPLOAD_SSH_HOST:$CLOUD_UPLOAD_SSH_DIR/ $VERBOSITY_LEVEL"
|
||||||
eval "$cmd2"
|
eval "$cmd2"
|
||||||
|
# shellcheck disable=SC2181
|
||||||
if [ "$?" != "0" ]; then
|
if [ "$?" != "0" ]; then
|
||||||
err=1
|
err=1
|
||||||
fi
|
fi
|
||||||
@ -56,10 +103,15 @@ cloud_upload() {
|
|||||||
|
|
||||||
# Sign and update repos metadata in remote
|
# Sign and update repos metadata in remote
|
||||||
cloud_repo_sign_and_update() {
|
cloud_repo_sign_and_update() {
|
||||||
echo "Signing and updating repos metadata in $cloud_upload_ssh_host .."
|
# Setup SSH keys on the build machine
|
||||||
|
setup_ssh
|
||||||
|
# Sign and update repos metadata in remote
|
||||||
|
echo "Signing and updating repos metadata in $CLOUD_UPLOAD_SSH_HOST .."
|
||||||
local ssh_args="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
|
local ssh_args="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
|
||||||
local remote_cmd="cd ~/.scripts && ./update-repo-packages-signature.bash $cloud_upload_gpg_passphrase"
|
local remote_cmd="cd ~/.scripts && ./update-repo-packages-signature.bash \
|
||||||
local cmd1="ssh $ssh_args $cloud_upload_ssh_user@$cloud_upload_ssh_host \"$remote_cmd\" $verbosity_level"
|
$CLOUD_UPLOAD_GPG_PASSPHRASE"
|
||||||
|
local cmd1="ssh $ssh_args $CLOUD_UPLOAD_SSH_USER@\
|
||||||
|
$CLOUD_UPLOAD_SSH_HOST \"$remote_cmd\" $VERBOSITY_LEVEL"
|
||||||
eval "$cmd1"
|
eval "$cmd1"
|
||||||
postcmd $?
|
postcmd $?
|
||||||
echo
|
echo
|
||||||
@ -77,9 +129,14 @@ postcmd() {
|
|||||||
|
|
||||||
# Get max number from array
|
# Get max number from array
|
||||||
max() {
|
max() {
|
||||||
local -n arr_nums=$1
|
local max="$1"
|
||||||
IFS=$'\n'
|
shift
|
||||||
echo "${arr_nums[*]}" | sort -nr | head -n1
|
for value in "$@"; do
|
||||||
|
if [[ "$value" -gt "$max" ]]; then
|
||||||
|
max="$value"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "$max"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Mkdir and children dirs
|
# Mkdir and children dirs
|
||||||
@ -105,19 +162,21 @@ remove_dir() {
|
|||||||
|
|
||||||
# Get latest tag version
|
# Get latest tag version
|
||||||
get_current_repo_tag() {
|
get_current_repo_tag() {
|
||||||
cd "$root_prod" || exit 1
|
# shellcheck disable=SC2153
|
||||||
|
cd "$ROOT_PROD" || exit 1
|
||||||
tg=$(git rev-list --tags --max-count=1)
|
tg=$(git rev-list --tags --max-count=1)
|
||||||
ds=$(git describe --tags "$tg")
|
ds=$(git describe --tags "$tg")
|
||||||
echo "$ds" | sed 's/v//'
|
ds="${ds/v/}"
|
||||||
|
echo "$ds"
|
||||||
}
|
}
|
||||||
|
|
||||||
get_module_version() {
|
get_module_version() {
|
||||||
local root_prod="$1"
|
|
||||||
local version=""
|
local version=""
|
||||||
|
|
||||||
# Check if module.info exists and extract version
|
# Check if module.info exists and extract version
|
||||||
if [ -f "module.info" ]; then
|
if [ -f "module.info" ]; then
|
||||||
version=$(grep -E '^version=[0-9]+(\.[0-9]+)*' module.info | head -n 1 | cut -d'=' -f2)
|
version=$(grep -E '^version=[0-9]+(\.[0-9]+)*' module.info | \
|
||||||
|
head -n 1 | cut -d'=' -f2)
|
||||||
version=$(echo "$version" | sed -E 's/^([0-9]+\.[0-9]+(\.[0-9]+)?).*/\1/')
|
version=$(echo "$version" | sed -E 's/^([0-9]+\.[0-9]+(\.[0-9]+)?).*/\1/')
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -132,7 +191,7 @@ get_module_version() {
|
|||||||
|
|
||||||
# Get latest commit date
|
# Get latest commit date
|
||||||
get_current_date() {
|
get_current_date() {
|
||||||
echo $(date +'%Y-%m-%d %H:%M:%S %z')
|
date +'%Y-%m-%d %H:%M:%S %z'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get latest commit date version
|
# Get latest commit date version
|
||||||
@ -143,31 +202,35 @@ get_latest_commit_date_version() {
|
|||||||
local highest_version
|
local highest_version
|
||||||
|
|
||||||
theme_version=$(git log -n1 --pretty='format:%cd' --date=format:'%Y%m%d%H%M')
|
theme_version=$(git log -n1 --pretty='format:%cd' --date=format:'%Y%m%d%H%M')
|
||||||
cd "$root_prod" || exit 1
|
cd "$ROOT_PROD" || exit 1
|
||||||
prod_version=$(git log -n1 --pretty='format:%cd' --date=format:'%Y%m%d%H%M')
|
prod_version=$(git log -n1 --pretty='format:%cd' --date=format:'%Y%m%d%H%M')
|
||||||
max_prod=("$theme_version" "$prod_version")
|
max_prod=("$theme_version" "$prod_version")
|
||||||
highest_version=$(max max_prod)
|
highest_version=$(max "${max_prod[@]}")
|
||||||
echo "$highest_version"
|
echo "$highest_version"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Pull project repo and theme
|
# Pull project repo and theme
|
||||||
make_prod_repos() {
|
make_prod_repos() {
|
||||||
|
local root_prod="$1"
|
||||||
|
local prod="$2"
|
||||||
|
local cmd;
|
||||||
# Webmin or Usermin
|
# Webmin or Usermin
|
||||||
if [ ! -d "$1" ]; then
|
if [ ! -d "$root_prod" ]; then
|
||||||
local repo="webmin/$prod.git"
|
local repo="webmin/$prod.git"
|
||||||
cmd="git clone https://github.com/$repo $verbosity_level"
|
cmd="git clone $GIT_BASE_URL/$repo $VERBOSITY_LEVEL"
|
||||||
eval "$cmd"
|
eval "$cmd"
|
||||||
if [ ! -d "webmin" ]; then
|
if [ ! -d "webmin" ]; then
|
||||||
cmd="git clone --depth 1 https://github.com/webmin/webmin $verbosity_level"
|
cmd="git clone --depth 1 $WEBMIN_REPO \
|
||||||
|
$VERBOSITY_LEVEL"
|
||||||
eval "$cmd"
|
eval "$cmd"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
# Theme
|
# Theme
|
||||||
theme="authentic-theme"
|
local theme="authentic-theme"
|
||||||
if [ ! -d "$1/$theme" ]; then
|
if [ ! -d "$root_prod/$theme" ]; then
|
||||||
cd "$1" || exit 1
|
cd "$root_prod" || exit 1
|
||||||
local repo="webmin/$theme.git"
|
local repo="webmin/$theme.git"
|
||||||
cmd="git clone --depth 1 https://github.com/$repo $verbosity_level"
|
cmd="git clone --depth 1 $GIT_BASE_URL/$repo $VERBOSITY_LEVEL"
|
||||||
eval "$cmd"
|
eval "$cmd"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -175,8 +238,9 @@ make_prod_repos() {
|
|||||||
# Make module repo
|
# Make module repo
|
||||||
make_module_repo_cmd() {
|
make_module_repo_cmd() {
|
||||||
local module="$1"
|
local module="$1"
|
||||||
printf "git clone --depth 1 https://%s@github.com/virtualmin/%s.git %s" \
|
local target="$2"
|
||||||
"$github_token" "$module" "$verbosity_level"
|
printf "git clone --depth 1 $target/%s.git %s" \
|
||||||
|
"$module" "$VERBOSITY_LEVEL"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get last commit date from repo
|
# Get last commit date from repo
|
||||||
@ -191,22 +255,24 @@ get_last_commit_date() {
|
|||||||
# Get required build scripts from Webmin repo
|
# Get required build scripts from Webmin repo
|
||||||
make_module_build_deps() {
|
make_module_build_deps() {
|
||||||
# Create directory for build dependencies if it doesn't exist
|
# Create directory for build dependencies if it doesn't exist
|
||||||
if [ ! -d "$root/build-deps" ]; then
|
if [ ! -d "$ROOT_DIR/build-deps" ]; then
|
||||||
mkdir -p "$root/build-deps"
|
mkdir -p "$ROOT_DIR/build-deps"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Download required scripts from Webmin repo if they don't exist
|
# Download required scripts from Webmin repo if they don't exist
|
||||||
if [ ! -f "$root/build-deps/makemoduledeb.pl" ] || \
|
if [ ! -f "$ROOT_DIR/build-deps/makemoduledeb.pl" ] || \
|
||||||
[ ! -f "$root/build-deps/makemodulerpm.pl" ] || \
|
[ ! -f "$ROOT_DIR/build-deps/makemodulerpm.pl" ] || \
|
||||||
[ ! -f "$root/build-deps/create-module.pl" ]; then
|
[ ! -f "$ROOT_DIR/build-deps/create-module.pl" ]; then
|
||||||
echo "Downloading build dependencies .."
|
echo "Downloading build dependencies .."
|
||||||
|
|
||||||
# Create temporary directory
|
# Create temporary directory
|
||||||
local temp_dir=$(mktemp -d)
|
local temp_dir
|
||||||
|
temp_dir=$(mktemp -d)
|
||||||
cd "$temp_dir" || exit 1
|
cd "$temp_dir" || exit 1
|
||||||
|
|
||||||
# Clone Webmin repository (minimal depth)
|
# Clone Webmin repository (minimal depth)
|
||||||
cmd="git clone --depth 1 --filter=blob:none --sparse https://github.com/webmin/webmin.git $verbosity_level"
|
cmd="git clone --depth 1 --filter=blob:none --sparse \
|
||||||
|
$WEBMIN_REPO.git $VERBOSITY_LEVEL"
|
||||||
eval "$cmd"
|
eval "$cmd"
|
||||||
postcmd $?
|
postcmd $?
|
||||||
echo
|
echo
|
||||||
@ -214,13 +280,14 @@ make_module_build_deps() {
|
|||||||
cd webmin || exit 1
|
cd webmin || exit 1
|
||||||
|
|
||||||
# Copy required files to build-deps directory
|
# Copy required files to build-deps directory
|
||||||
cp makemoduledeb.pl makemodulerpm.pl create-module.pl "$root/build-deps/"
|
cp makemoduledeb.pl makemodulerpm.pl create-module.pl \
|
||||||
|
"$ROOT_DIR/build-deps/"
|
||||||
|
|
||||||
# Make scripts executable
|
# Make scripts executable
|
||||||
chmod +x "$root/build-deps/"*.pl
|
chmod +x "$ROOT_DIR/build-deps/"*.pl
|
||||||
|
|
||||||
# Clean up
|
# Clean up
|
||||||
cd "$root" || exit 1
|
cd "$ROOT_DIR" || exit 1
|
||||||
remove_dir "$temp_dir"
|
remove_dir "$temp_dir"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -230,6 +297,7 @@ adjust_module_filename() {
|
|||||||
local repo_dir="$1"
|
local repo_dir="$1"
|
||||||
local package_type="$2"
|
local package_type="$2"
|
||||||
local failed=0
|
local failed=0
|
||||||
|
local temp_file
|
||||||
|
|
||||||
# Create a secure temporary file
|
# Create a secure temporary file
|
||||||
temp_file=$(mktemp) || { echo "Failed to create temporary file"; return 1; }
|
temp_file=$(mktemp) || { echo "Failed to create temporary file"; return 1; }
|
||||||
@ -271,7 +339,8 @@ adjust_module_filename() {
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
# Perform rename and check for failure
|
# Perform rename and check for failure
|
||||||
if ! eval "mv \"$file\" \"$dir_name/$new_name\" $verbosity_level_with_input"; then
|
if ! eval "mv \"$file\" \"$dir_name/$new_name\" \
|
||||||
|
$VERBOSITY_LEVEL_WITH_INPUT"; then
|
||||||
failed=1
|
failed=1
|
||||||
fi
|
fi
|
||||||
done < "$temp_file"
|
done < "$temp_file"
|
||||||
@ -288,7 +357,7 @@ spinner() {
|
|||||||
local pid=$!
|
local pid=$!
|
||||||
local spin='-\|/'
|
local spin='-\|/'
|
||||||
local i=0
|
local i=0
|
||||||
printf "$msg "
|
printf "%s " "$msg"
|
||||||
while kill -0 $pid 2>/dev/null; do
|
while kill -0 $pid 2>/dev/null; do
|
||||||
(( i = (i + 1) % 4 ))
|
(( i = (i + 1) % 4 ))
|
||||||
# No spinner if not an interactive shell
|
# No spinner if not an interactive shell
|
29
.github/build/init.sh
vendored
29
.github/build/init.sh
vendored
@ -1,29 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
#
|
|
||||||
# Copyright @iliajie <ilia@webmin.dev>
|
|
||||||
#
|
|
||||||
# Build init
|
|
||||||
#
|
|
||||||
#
|
|
||||||
|
|
||||||
# Set up SSH dev keys
|
|
||||||
if [ -n "$WEBMIN_DEV__SSH_PRV_KEY" ] && [ -n "$WEBMIN_DEV__SSH_PUB_KEY" ]; then
|
|
||||||
# Generate new pair with right permissions
|
|
||||||
cmd="ssh-keygen -t rsa -q -f \"$HOME/.ssh/id_rsa\" -N \"\"$verbosity_level"
|
|
||||||
eval "$cmd"
|
|
||||||
# Import SSH keys from secrets to be able to connect to the remote host
|
|
||||||
echo "$WEBMIN_DEV__SSH_PRV_KEY" > "$HOME/.ssh/id_rsa"
|
|
||||||
echo "$WEBMIN_DEV__SSH_PUB_KEY" > "$HOME/.ssh/id_rsa.pub"
|
|
||||||
|
|
||||||
# Set up SSH production keys
|
|
||||||
elif [ -n "$WEBMIN_PROD__SSH_PRV_KEY" ] && [ -n "$WEBMIN_PROD__SSH_PUB_KEY" ]; then
|
|
||||||
# Generate new pair with right permissions
|
|
||||||
cmd="ssh-keygen -t rsa -q -f \"$HOME/.ssh/id_rsa\" -N \"\"$verbosity_level"
|
|
||||||
eval "$cmd"
|
|
||||||
# Import SSH keys from secrets to be able to connect to the remote host
|
|
||||||
echo "$WEBMIN_PROD__SSH_PRV_KEY" > "$HOME/.ssh/id_rsa"
|
|
||||||
echo "$WEBMIN_PROD__SSH_PUB_KEY" > "$HOME/.ssh/id_rsa.pub"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Create symlink to Perl
|
|
||||||
ln -fs /usr/bin/perl /usr/local/bin/perl
|
|
237
.github/build/rpm.sh
vendored
237
.github/build/rpm.sh
vendored
@ -1,237 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
#
|
|
||||||
# Copyright @iliajie <ilia@webmin.dev>
|
|
||||||
#
|
|
||||||
# Automatically builds and updates a repo metadata.
|
|
||||||
# Pulls latest changes from GitHub, detects release
|
|
||||||
# version based on what's available in the repo
|
|
||||||
#
|
|
||||||
# (RHEL)
|
|
||||||
#
|
|
||||||
# Usage:
|
|
||||||
#
|
|
||||||
# # Pull and build production versions
|
|
||||||
# # of both Webmin and Usermin
|
|
||||||
# ./rpm.sh
|
|
||||||
#
|
|
||||||
# # Pull and build devel versions
|
|
||||||
# # of both Webmin and Usermin
|
|
||||||
# ./rpm.sh --testing
|
|
||||||
#
|
|
||||||
# # Pull and build production Webmin version 2.101, forcing
|
|
||||||
# # release version 3, displaying detailed output
|
|
||||||
# ./rpm.sh webmin 2.101 3 --debug
|
|
||||||
#
|
|
||||||
# # Pull and build production Usermin version 2.000,
|
|
||||||
# # automatically setting release version to minimal
|
|
||||||
# ./rpm.sh usermin 2.000
|
|
||||||
#
|
|
||||||
|
|
||||||
# shellcheck disable=SC1091
|
|
||||||
# Source build variables
|
|
||||||
source ./vars.sh || exit 1
|
|
||||||
|
|
||||||
# Source build init
|
|
||||||
source ./init.sh || exit 1
|
|
||||||
|
|
||||||
# Source general build functions
|
|
||||||
source ./funcs.sh || exit 1
|
|
||||||
|
|
||||||
# Build product func
|
|
||||||
build_prod() {
|
|
||||||
|
|
||||||
# Pack with English only in devel builds
|
|
||||||
local english_only=0
|
|
||||||
if [[ "'$*'" == *"--testing"* ]]; then
|
|
||||||
english_only=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Always return back to root directory
|
|
||||||
cd "$root" || exit 1
|
|
||||||
|
|
||||||
# Define root
|
|
||||||
local ver=""
|
|
||||||
local prod=$1
|
|
||||||
local devel=0
|
|
||||||
root_prod="$root/$prod"
|
|
||||||
|
|
||||||
# Print build actual date
|
|
||||||
date=$(get_current_date)
|
|
||||||
|
|
||||||
# Print opening header
|
|
||||||
echo "************************************************************************"
|
|
||||||
echo " build start date: $date "
|
|
||||||
echo " package format: RPM "
|
|
||||||
echo " product: $prod "
|
|
||||||
(make_prod_repos "$root_prod") &
|
|
||||||
spinner " package output version:"
|
|
||||||
|
|
||||||
# Pull main project first to get the latest tag
|
|
||||||
cd "$root_prod" || exit 1
|
|
||||||
cmd="git pull $verbosity_level"
|
|
||||||
eval "$cmd"
|
|
||||||
rs1=$?
|
|
||||||
# Clean and try again
|
|
||||||
if [ "$rs1" != "0" ]; then
|
|
||||||
cmd="git checkout \"*\" $verbosity_level && git clean -f -d $verbosity_level && git pull $verbosity_level"
|
|
||||||
eval "$cmd"
|
|
||||||
rs1=$?
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Pull theme to theme dir
|
|
||||||
cd "authentic-theme" || exit 1
|
|
||||||
cmd="git pull $verbosity_level"
|
|
||||||
eval "$cmd"
|
|
||||||
rs2=$?
|
|
||||||
# Clean and try again
|
|
||||||
if [ "$rs2" != "0" ]; then
|
|
||||||
cmd="git checkout \"*\" $verbosity_level && git clean -f -d $verbosity_level && git pull $verbosity_level"
|
|
||||||
eval "$cmd"
|
|
||||||
rs2=$?
|
|
||||||
fi
|
|
||||||
if [ "$rs1" != "0" ] || [ "$rs2" != "0" ]; then
|
|
||||||
rs=1
|
|
||||||
else
|
|
||||||
rs=0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Build number
|
|
||||||
date_version=$(get_latest_commit_date_version)
|
|
||||||
|
|
||||||
# Handle other params
|
|
||||||
cd "$root_prod" || exit 1
|
|
||||||
if [[ "'$2'" != *"--"* ]]; then
|
|
||||||
ver=$2
|
|
||||||
fi
|
|
||||||
if [[ "'$3'" != *"--"* ]] && [[ -n "$3" ]]; then
|
|
||||||
rel=$3
|
|
||||||
else
|
|
||||||
rel=1
|
|
||||||
fi
|
|
||||||
if [ -z "$ver" ]; then
|
|
||||||
ver=$(get_current_repo_tag)
|
|
||||||
fi
|
|
||||||
if [[ "'$*'" == *"--testing"* ]]; then
|
|
||||||
devel=1
|
|
||||||
ver="$ver.$date_version"
|
|
||||||
# Set actual product version
|
|
||||||
echo "${ver}" >"version"
|
|
||||||
fi
|
|
||||||
|
|
||||||
printf "$ver-$rel\n"
|
|
||||||
echo "************************************************************************"
|
|
||||||
|
|
||||||
echo "Pulling latest changes.."
|
|
||||||
# We need to pull first to get the latest tag,
|
|
||||||
# so here we only report an error if any
|
|
||||||
postcmd $rs
|
|
||||||
echo
|
|
||||||
|
|
||||||
echo "Pre-clean up .."
|
|
||||||
# Make sure directories exist
|
|
||||||
make_dir "$root_prod/newkey/rpm/"
|
|
||||||
make_dir "$root_prod/umodules/"
|
|
||||||
make_dir "$root_prod/minimal/"
|
|
||||||
make_dir "$root_prod/tarballs/"
|
|
||||||
make_dir "$root_build/BUILD/"
|
|
||||||
make_dir "$root_build/BUILDROOT/"
|
|
||||||
make_dir "$root_build/RPMS/"
|
|
||||||
make_dir "$root_build/SOURCES/"
|
|
||||||
make_dir "$root_build/SPECS/"
|
|
||||||
make_dir "$root_build/SRPMS/"
|
|
||||||
make_dir "$root_repos/"
|
|
||||||
|
|
||||||
# Re-create legacy link
|
|
||||||
remove_dir "$root/webadmin"
|
|
||||||
ln -s "$root/webmin" "$root/webadmin"
|
|
||||||
|
|
||||||
# Purge old files
|
|
||||||
purge_dir "$root_prod/newkey/rpm"
|
|
||||||
purge_dir "$root_prod/umodules"
|
|
||||||
purge_dir "$root_prod/minimal"
|
|
||||||
purge_dir "$root_prod/tarballs"
|
|
||||||
purge_dir "$root_build/BUILD"
|
|
||||||
purge_dir "$root_build/BUILDROOT"
|
|
||||||
purge_dir "$root_build/RPMS"
|
|
||||||
purge_dir "$root_build/SOURCES"
|
|
||||||
purge_dir "$root_build/SPECS"
|
|
||||||
purge_dir "$root_build/SRPMS"
|
|
||||||
remove_dir "$root_repos/repodata"
|
|
||||||
if [ "$prod" != "" ]; then
|
|
||||||
rm -f "$root_repos/$prod-"*
|
|
||||||
rm -f "$root_repos/${prod}_"*
|
|
||||||
fi
|
|
||||||
postcmd $?
|
|
||||||
make_dir "$root_build/RPMS/noarch"
|
|
||||||
echo
|
|
||||||
|
|
||||||
# Descend to project dir
|
|
||||||
cd "$root_prod" || exit 1
|
|
||||||
|
|
||||||
if [ "$english_only" = "1" ]; then
|
|
||||||
echo "Cleaning languages .."
|
|
||||||
cmd="./bin/language-manager --mode=clean --yes $verbosity_level_with_input"
|
|
||||||
eval "$cmd"
|
|
||||||
postcmd $?
|
|
||||||
echo
|
|
||||||
else
|
|
||||||
# Force restore build directory
|
|
||||||
if [ ! -f "lang/ja" ]; then
|
|
||||||
echo "Restoring languages .."
|
|
||||||
cmd="git checkout \"*\" $verbosity_level && git clean -f -d $verbosity_level && git pull $verbosity_level"
|
|
||||||
eval "$cmd"
|
|
||||||
postcmd $?
|
|
||||||
echo
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
echo "Pre-building package .."
|
|
||||||
eval "$cmd"
|
|
||||||
if [ "$rel" = "1" ]; then
|
|
||||||
args="$ver"
|
|
||||||
else
|
|
||||||
args="$ver-$rel"
|
|
||||||
fi
|
|
||||||
|
|
||||||
cmd="./makedist.pl \"$args\" $verbosity_level"
|
|
||||||
eval "$cmd"
|
|
||||||
postcmd $?
|
|
||||||
echo
|
|
||||||
|
|
||||||
echo "Building package .."
|
|
||||||
cmd="./makerpm.pl \"$ver\" \"$rel\" $verbosity_level"
|
|
||||||
eval "$cmd"
|
|
||||||
postcmd $?
|
|
||||||
echo
|
|
||||||
|
|
||||||
cd "$root" || exit 1
|
|
||||||
echo "Preparing built files for upload .."
|
|
||||||
cmd="cp -f $root_prod/tarballs/$prod-$ver*\.tar.gz $root_repos/${prod}-$ver.tar.gz $verbosity_level"
|
|
||||||
eval "$cmd"
|
|
||||||
cmd="find $root_rpms -name $prod-$ver-$rel*\.rpm -exec mv '{}' $root_repos \; $verbosity_level"
|
|
||||||
eval "$cmd"
|
|
||||||
# cmd="mv -f $root_repos/$prod-$ver-$rel*\.rpm $root_repos/${prod}-$ver-$rel.noarch.rpm $verbosity_level" # file name is the same
|
|
||||||
# eval "$cmd"
|
|
||||||
postcmd $?
|
|
||||||
echo
|
|
||||||
|
|
||||||
echo "Post-clean up .."
|
|
||||||
cd "$root_build" || exit 1
|
|
||||||
for dir in *; do
|
|
||||||
cmd="rm -rf \"$dir/*\" $verbosity_level"
|
|
||||||
eval "$cmd"
|
|
||||||
done
|
|
||||||
postcmd $?
|
|
||||||
}
|
|
||||||
|
|
||||||
# Main
|
|
||||||
if [ -n "$1" ] && [[ "'$1'" != *"--"* ]]; then
|
|
||||||
build_prod $@
|
|
||||||
cloud_upload_list_upload=("$root_repos/$1*")
|
|
||||||
else
|
|
||||||
build_prod webmin $@
|
|
||||||
build_prod usermin $@
|
|
||||||
cloud_upload_list_upload=("$root_repos/*")
|
|
||||||
fi
|
|
||||||
|
|
||||||
cloud_upload cloud_upload_list_upload
|
|
||||||
cloud_repo_sign_and_update
|
|
43
.github/build/vars.sh
vendored
43
.github/build/vars.sh
vendored
@ -1,43 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
#
|
|
||||||
# Copyright @iliajie <ilia@webmin.dev>
|
|
||||||
#
|
|
||||||
# Build variables
|
|
||||||
#
|
|
||||||
#
|
|
||||||
|
|
||||||
# Set defaults
|
|
||||||
root="${ENV_BUILD__ROOT:-$HOME}"
|
|
||||||
root_repos="${ENV_BUILD__ROOT_REPOS:-$root/repo}"
|
|
||||||
root_build="${ENV_BUILD__ROOT_BUILD:-$root/rpmbuild}"
|
|
||||||
root_rpms="${ENV_BUILD__ROOT_RPMS:-$root_build/RPMS/noarch}"
|
|
||||||
|
|
||||||
# GitHub private repos access token
|
|
||||||
github_token="${ENV_BUILD__GITHUB_TOKEN}"
|
|
||||||
|
|
||||||
# Cloud upload config
|
|
||||||
cloud_upload_ssh_user="${ENV_BUILD__CLOUD_UPLOAD_SSH_USER:-webmin.dev}"
|
|
||||||
cloud_upload_ssh_host="${ENV_BUILD__CLOUD_UPLOAD_SSH_HOST:-webmin.dev}"
|
|
||||||
cloud_upload_ssh_dir="${ENV_BUILD__CLOUD_UPLOAD_SSH_DIR:-~/domains/download.webmin.dev/public_html}"
|
|
||||||
cloud_upload_gpg_passphrase="${WEBMIN_DEV__GPG_PH}"
|
|
||||||
|
|
||||||
# Define verbosity level
|
|
||||||
verbosity_level=' >/dev/null 2>&1 </dev/null'
|
|
||||||
verbosity_level_to_file='2> /dev/null'
|
|
||||||
verbosity_level_with_input=' >/dev/null 2>&1'
|
|
||||||
if [[ "'$*'" == *"--debug"* ]]; then
|
|
||||||
unset verbosity_level verbosity_level_to_file verbosity_level_with_input
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Webmin modules
|
|
||||||
webmin_modules=(
|
|
||||||
'ruby-gems'
|
|
||||||
'virtualmin-awstats'
|
|
||||||
'virtualmin-htpasswd'
|
|
||||||
'virtualmin-mailman'
|
|
||||||
'virtualmin-nginx-ssl'
|
|
||||||
'virtualmin-nginx'
|
|
||||||
'virtualmin-registrar'
|
|
||||||
'virtualmin-support'
|
|
||||||
'webmin-jailkit'
|
|
||||||
)
|
|
@ -1,4 +1,4 @@
|
|||||||
name: "webmin.dev: Deploy Webmin package"
|
name: "webmin.dev: Webmin package"
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@ -26,5 +26,5 @@ jobs:
|
|||||||
ENV_BUILD__CLOUD_UPLOAD_SSH_HOST: ${{ secrets.WEBMIN_DEV__IP_ADDR }}
|
ENV_BUILD__CLOUD_UPLOAD_SSH_HOST: ${{ secrets.WEBMIN_DEV__IP_ADDR }}
|
||||||
working-directory: ./.github/build
|
working-directory: ./.github/build
|
||||||
run: |-
|
run: |-
|
||||||
./deb.sh webmin --testing
|
./build-deb-package.bash webmin --testing --verbose
|
||||||
./rpm.sh webmin --testing
|
./build-rpm-package.bash webmin --testing --verbose
|
||||||
|
Reference in New Issue
Block a user