new: implement the --insecure option for mp-build and mp-pool

This commit is contained in:
ngn 2024-08-22 11:24:39 +03:00
parent 9fc56f5dc8
commit 57c898c8d4
2 changed files with 19 additions and 12 deletions

View File

@ -42,7 +42,11 @@ get_fn_url() {
get_file() { get_file() {
if [[ "${1}" == "https://"* || "${1}" == "http://"* || "${1}" == "ftp://"* ]] if [[ "${1}" == "https://"* || "${1}" == "http://"* || "${1}" == "ftp://"* ]]
then then
curl "${1}" --progress-bar -OL if [ $OPT_INSECURE -eq 1 ]; then
curl "${1}" --insecure --progress-bar -OL
else
curl "${1}" --progress-bar -OL
fi
return $? return $?
elif [ -f "${pkgpath}/${1}" ]; then elif [ -f "${pkgpath}/${1}" ]; then
cp "${pkgpath}/${1}" . cp "${pkgpath}/${1}" .
@ -89,6 +93,7 @@ help_cmd() {
echo_color " $BOLD--no-depend$RESET: don't check depends" echo_color " $BOLD--no-depend$RESET: don't check depends"
echo_color " $BOLD--no-stdout$RESET: disable stdout for PACKAGE() function" echo_color " $BOLD--no-stdout$RESET: disable stdout for PACKAGE() function"
echo_color " $BOLD--no-cache$RESET: don't check cache" echo_color " $BOLD--no-cache$RESET: don't check cache"
echo_color " $BOLD--insecure$RESET: allow insecure curl downloads"
echo_color " $BOLD--no-opts$RESET: don't show/list options" echo_color " $BOLD--no-opts$RESET: don't show/list options"
echo_color " $BOLD--cores$RESET: how many cores to use for the build" echo_color " $BOLD--cores$RESET: how many cores to use for the build"
echo_color " $BOLD--out$RESET: directory for the output archive" echo_color " $BOLD--out$RESET: directory for the output archive"
@ -154,6 +159,7 @@ check_depends() {
OPT_NO_DEPEND=0 # checking depends is ENABLED OPT_NO_DEPEND=0 # checking depends is ENABLED
OPT_NO_STDOUT=0 # PACKAGE() function output is ENABLED OPT_NO_STDOUT=0 # PACKAGE() function output is ENABLED
OPT_NO_CACHE=0 # cache is ENABLED OPT_NO_CACHE=0 # cache is ENABLED
OPT_INSECURE=0 # insecure curl downloads are DISABLED
OPT_NO_OPTS=0 # showing/listing options is ENABLED OPT_NO_OPTS=0 # showing/listing options is ENABLED
OPT_CORES=$(nproc) # use ALL CPU cores OPT_CORES=$(nproc) # use ALL CPU cores
OPT_OUT="DEFAULT" # use the package dist directory for output OPT_OUT="DEFAULT" # use the package dist directory for output
@ -171,6 +177,8 @@ for arg in "$@"; do
OPT_NO_STDOUT=1 ;; OPT_NO_STDOUT=1 ;;
"--no-cache") "--no-cache")
OPT_NO_CACHE=1 ;; OPT_NO_CACHE=1 ;;
"--insecure")
OPT_INSECURE=1 ;;
"--no-opts") "--no-opts")
OPT_NO_OPTS=1 ;; OPT_NO_OPTS=1 ;;
"--cores"*) "--cores"*)
@ -223,6 +231,7 @@ if [ $OPT_NO_OPTS -eq 0 ]; then
print " $BOLD NO_DEPEND = $(itoyn $OPT_NO_DEPEND)" print " $BOLD NO_DEPEND = $(itoyn $OPT_NO_DEPEND)"
print " $BOLD NO_SDTOUT = $(itoyn $OPT_NO_STDOUT)" print " $BOLD NO_SDTOUT = $(itoyn $OPT_NO_STDOUT)"
print " $BOLD NO_CACHE = $(itoyn $OPT_NO_CACHE)" print " $BOLD NO_CACHE = $(itoyn $OPT_NO_CACHE)"
print " $BOLD INSECURE = $(itoyn $OPT_INSECURE)"
print " $BOLD NO_OPTS = $(itoyn $OPT_NO_OPTS)" print " $BOLD NO_OPTS = $(itoyn $OPT_NO_OPTS)"
print " $BOLD CORES = ${OPT_CORES}" print " $BOLD CORES = ${OPT_CORES}"
print " $BOLD OUT = ${OPT_OUT}" print " $BOLD OUT = ${OPT_OUT}"

View File

@ -42,6 +42,7 @@ help_cmd() {
echo_color " $BOLD--no-depend$RESET: don't check depends" echo_color " $BOLD--no-depend$RESET: don't check depends"
echo_color " $BOLD--no-stdout$RESET: disable stdout for build() function" echo_color " $BOLD--no-stdout$RESET: disable stdout for build() function"
echo_color " $BOLD--no-cache$RESET: don't use cache" echo_color " $BOLD--no-cache$RESET: don't use cache"
echo_color " $BOLD--insecure$RESET: allow insecure curl downloads"
echo_color " $BOLD--no-opts$RESET: don't show/list options" echo_color " $BOLD--no-opts$RESET: don't show/list options"
echo_color " $BOLD--no-sign$RESET: don't sign build packages" echo_color " $BOLD--no-sign$RESET: don't sign build packages"
echo_color " $BOLD--cores$RESET: how many cores to use for the build" echo_color " $BOLD--cores$RESET: how many cores to use for the build"
@ -74,17 +75,10 @@ list_to_str(){
mp_build_opts(){ mp_build_opts(){
local opts=("${1}" "--no-opts" "--out='${2}'") local opts=("${1}" "--no-opts" "--out='${2}'")
if [ $OPT_NO_DEPEND -eq 1 ]; then [ $OPT_NO_DEPEND -eq 1 ] && opts+=("--no-depend")
opts+=("--no-depend") [ $OPT_NO_STDOUT -eq 1 ] && opts+=("--no-stdout")
fi [ $OPT_INSECURE -eq 1 ] && opts+=("--insecure")
[ $OPT_NO_CACHE -eq 1 ] && opts+=("--no-cache")
if [ $OPT_NO_STDOUT -eq 1 ]; then
opts+=("--no-stdout")
fi
if [ $OPT_NO_CACHE -eq 1 ]; then
opts+=("--no-cache")
fi
mp-build ${opts[@]} mp-build ${opts[@]}
return "$?" return "$?"
@ -97,6 +91,7 @@ OPT_SKIP_FAIL=0 # stop build when a package build fails
OPT_NO_DEPEND=0 # checking depends is ENABLED OPT_NO_DEPEND=0 # checking depends is ENABLED
OPT_NO_STDOUT=0 # build() function output is ENABLED OPT_NO_STDOUT=0 # build() function output is ENABLED
OPT_NO_CACHE=0 # cache is ENABLED OPT_NO_CACHE=0 # cache is ENABLED
OPT_INSECURE=0 # insecure curl downloads are DISABLED
OPT_NO_OPTS=0 # showing/listing options is ENABLED OPT_NO_OPTS=0 # showing/listing options is ENABLED
OPT_NO_SIGN=0 # sign all the built packages OPT_NO_SIGN=0 # sign all the built packages
OPT_CORES=$(nproc) # use ALL CPU cores OPT_CORES=$(nproc) # use ALL CPU cores
@ -118,6 +113,8 @@ for arg in "$@"; do
OPT_NO_STDOUT=1 ;; OPT_NO_STDOUT=1 ;;
"--no-cache") "--no-cache")
OPT_NO_CACHE=1 ;; OPT_NO_CACHE=1 ;;
"--insecure")
OPT_INSECURE=1 ;;
"--no-opts") "--no-opts")
OPT_NO_OPTS=1 ;; OPT_NO_OPTS=1 ;;
"--no-sign") "--no-sign")
@ -162,6 +159,7 @@ if [ $OPT_NO_OPTS -eq 0 ]; then
print " $BOLD NO_DEPEND = $(itoyn $OPT_NO_DEPEND)" print " $BOLD NO_DEPEND = $(itoyn $OPT_NO_DEPEND)"
print " $BOLD NO_SDTOUT = $(itoyn $OPT_NO_STDOUT)" print " $BOLD NO_SDTOUT = $(itoyn $OPT_NO_STDOUT)"
print " $BOLD NO_CACHE = $(itoyn $OPT_NO_CACHE)" print " $BOLD NO_CACHE = $(itoyn $OPT_NO_CACHE)"
print " $BOLD INSECURE = $(itoyn $OPT_INSECURE)"
print " $BOLD NO_OPTS = $(itoyn $OPT_NO_OPTS)" print " $BOLD NO_OPTS = $(itoyn $OPT_NO_OPTS)"
print " $BOLD NO_SIGN = $(itoyn $OPT_NO_SIGN)" print " $BOLD NO_SIGN = $(itoyn $OPT_NO_SIGN)"
print " $BOLD CORES = $OPT_CORES" print " $BOLD CORES = $OPT_CORES"