update: add --out option to mp-build
This commit is contained in:
parent
aa5fbb82d6
commit
ff3245979e
@ -91,6 +91,7 @@ help_cmd() {
|
|||||||
echo_color " $BOLD--no-cache$RESET: don't check cache"
|
echo_color " $BOLD--no-cache$RESET: don't check cache"
|
||||||
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
|
echo
|
||||||
info "Licensed under GPLv3, see <https://www.gnu.org/licenses/> for more information"
|
info "Licensed under GPLv3, see <https://www.gnu.org/licenses/> for more information"
|
||||||
}
|
}
|
||||||
@ -149,6 +150,7 @@ OPT_NO_STDOUT=0 # PACKAGE() function output is ENABLED
|
|||||||
OPT_NO_CACHE=0 # cache is ENABLED
|
OPT_NO_CACHE=0 # cache is ENABLED
|
||||||
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
|
||||||
|
|
||||||
# parses all the options
|
# parses all the options
|
||||||
for arg in "$@"; do
|
for arg in "$@"; do
|
||||||
@ -166,7 +168,15 @@ for arg in "$@"; do
|
|||||||
"--no-opts")
|
"--no-opts")
|
||||||
OPT_NO_OPTS=1 ;;
|
OPT_NO_OPTS=1 ;;
|
||||||
"--cores"*)
|
"--cores"*)
|
||||||
OPT_CORES=$(echo "${arg}" | cut -d "=" -f2) ;;
|
OPT_CORES="$(echo "${arg}" | cut -d '=' -f2)" ;;
|
||||||
|
"--out"*)
|
||||||
|
OPT_OUT="$(echo "${arg}" | cut -d '=' -f2)"
|
||||||
|
OPT_OUT="$(echo "${OPT_OUT}" | sed "s/'//g")"
|
||||||
|
OPT_OUT="$(echo "${OPT_OUT}" | sed 's/"//g')"
|
||||||
|
if [ ! -d "${OPT_OUT}" ]; then
|
||||||
|
error "Failed to access to the output directory (${OPT_OUT})"
|
||||||
|
exit 1
|
||||||
|
fi ;;
|
||||||
--*)
|
--*)
|
||||||
error "Unknown option: ${arg}"
|
error "Unknown option: ${arg}"
|
||||||
exit 1 ;;
|
exit 1 ;;
|
||||||
@ -206,7 +216,8 @@ if [ $OPT_NO_OPTS -eq 0 ]; then
|
|||||||
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 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}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd "${TARGET}"
|
cd "${TARGET}"
|
||||||
@ -236,6 +247,11 @@ fi
|
|||||||
pkgpath="$(realpath .)"
|
pkgpath="$(realpath .)"
|
||||||
cachepath="$(realpath '.cache')"
|
cachepath="$(realpath '.cache')"
|
||||||
distpath="$(realpath 'dist')"
|
distpath="$(realpath 'dist')"
|
||||||
|
if [ "${OPT_OUT}" == "DEFAULT" ]; then
|
||||||
|
outpath="${distpath}"
|
||||||
|
else
|
||||||
|
outpath="${OPT_OUT}"
|
||||||
|
fi
|
||||||
rootpath="$(realpath 'root')"
|
rootpath="$(realpath 'root')"
|
||||||
|
|
||||||
mkdir -p "${rootpath}"
|
mkdir -p "${rootpath}"
|
||||||
@ -249,7 +265,7 @@ if [ $OPT_NO_CACHE -eq 0 ] && [ -f "${cachepath}/last" ]; then
|
|||||||
package_cache=$(sed -n '1p' "${cachepath}/last")
|
package_cache=$(sed -n '1p' "${cachepath}/last")
|
||||||
changes_cache=$(sed -n '2p' "${cachepath}/last")
|
changes_cache=$(sed -n '2p' "${cachepath}/last")
|
||||||
|
|
||||||
if [[ "${package_cache}" == "${package_hash}" ]] && [[ "${changes_cache}" == "${changes_hash}" ]]; then
|
if [ -f "${outpath}/${NAME}_${VERSION}.mpf" ] && [[ "${package_cache}" == "${package_hash}" ]] && [[ "${changes_cache}" == "${changes_hash}" ]]; then
|
||||||
info "Found build in the cache (add --no-cache if you want to rebuild anyway)"
|
info "Found build in the cache (add --no-cache if you want to rebuild anyway)"
|
||||||
success "Build was successful"
|
success "Build was successful"
|
||||||
exit 0
|
exit 0
|
||||||
@ -431,6 +447,12 @@ clean_dist
|
|||||||
info "Cleaning the root directory"
|
info "Cleaning the root directory"
|
||||||
rm -rf "${rootpath}"
|
rm -rf "${rootpath}"
|
||||||
|
|
||||||
|
# move archive to out directory
|
||||||
|
if [ "$(realpath "${distpath}/${archive}")" != "$(realpath "${outpath}")" ]; then
|
||||||
|
mv "${distpath}/${archive}" "${outpath}" 2> /dev/null
|
||||||
|
check_ret "Failed to move the archive to the output directory"
|
||||||
|
fi
|
||||||
|
|
||||||
# update the cache
|
# update the cache
|
||||||
unset_indent
|
unset_indent
|
||||||
info "Updating the package cache"
|
info "Updating the package cache"
|
||||||
|
@ -95,6 +95,8 @@ for pkg in "${srcpath}/"*; do
|
|||||||
|
|
||||||
files+=("${NAME}_${VERSION}.mpf")
|
files+=("${NAME}_${VERSION}.mpf")
|
||||||
files+=("${NAME}_${VERSION}.mpf.sig")
|
files+=("${NAME}_${VERSION}.mpf.sig")
|
||||||
|
|
||||||
|
clean_pkg_vars
|
||||||
pi=$((pi+1))
|
pi=$((pi+1))
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ list_to_str(){
|
|||||||
for el in "${list[@]}"; do
|
for el in "${list[@]}"; do
|
||||||
if [ -z "${str}" ]; then
|
if [ -z "${str}" ]; then
|
||||||
str="${el}"
|
str="${el}"
|
||||||
else
|
else
|
||||||
printf -v str "${str}\n ${el}"
|
printf -v str "${str}\n ${el}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@ -72,20 +72,20 @@ list_to_str(){
|
|||||||
|
|
||||||
# run mp-build with options
|
# run mp-build with options
|
||||||
mp_build_opts(){
|
mp_build_opts(){
|
||||||
local opts=("${1}" "--no-opts")
|
local opts=("${1}" "--no-opts" "--out='${2}'")
|
||||||
|
|
||||||
if [ $OPT_NO_DEPEND -eq 1 ]; then
|
if [ $OPT_NO_DEPEND -eq 1 ]; then
|
||||||
opts+=("--no-depend")
|
opts+=("--no-depend")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $OPT_NO_STDOUT -eq 1 ]; then
|
if [ $OPT_NO_STDOUT -eq 1 ]; then
|
||||||
opts+=("--no-stdout")
|
opts+=("--no-stdout")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $OPT_NO_CACHE -eq 1 ]; then
|
if [ $OPT_NO_CACHE -eq 1 ]; then
|
||||||
opts+=("--no-cache")
|
opts+=("--no-cache")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mp-build ${opts[@]}
|
mp-build ${opts[@]}
|
||||||
return "$?"
|
return "$?"
|
||||||
}
|
}
|
||||||
@ -94,16 +94,16 @@ mp_build_opts(){
|
|||||||
## main script ##
|
## main script ##
|
||||||
#################
|
#################
|
||||||
OPT_SKIP_FAIL=0 # stop build when a package build fails
|
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_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
|
||||||
|
|
||||||
# parses all the options
|
# parses all the options
|
||||||
for arg in "$@"; do
|
for arg in "$@"; do
|
||||||
case $arg in
|
case $arg in
|
||||||
"--help")
|
"--help")
|
||||||
help_cmd
|
help_cmd
|
||||||
exit 0
|
exit 0
|
||||||
@ -114,26 +114,26 @@ for arg in "$@"; do
|
|||||||
OPT_NO_DEPEND=1 ;;
|
OPT_NO_DEPEND=1 ;;
|
||||||
"--no-stdout")
|
"--no-stdout")
|
||||||
OPT_NO_STDOUT=1 ;;
|
OPT_NO_STDOUT=1 ;;
|
||||||
"--no-cache")
|
"--no-cache")
|
||||||
OPT_NO_CACHE=1 ;;
|
OPT_NO_CACHE=1 ;;
|
||||||
"--no-opts")
|
"--no-opts")
|
||||||
OPT_NO_OPTS=1 ;;
|
OPT_NO_OPTS=1 ;;
|
||||||
"--no-sign")
|
"--no-sign")
|
||||||
OPT_NO_SIGN=1 ;;
|
OPT_NO_SIGN=1 ;;
|
||||||
"--cores"*)
|
"--cores"*)
|
||||||
OPT_CORES=$(echo "${arg}" | cut -d "=" -f2) ;;
|
OPT_CORES=$(echo "${arg}" | cut -d "=" -f2) ;;
|
||||||
--*)
|
--*)
|
||||||
error "Unknown option: ${arg}"
|
error "Unknown option: ${arg}"
|
||||||
exit 1 ;;
|
exit 1 ;;
|
||||||
*)
|
*)
|
||||||
if [ -z "${TARGET}" ]; then
|
if [ -z "${TARGET}" ]; then
|
||||||
TARGET="${arg}"
|
TARGET="${arg}"
|
||||||
else
|
else
|
||||||
error "Unknown argument: ${arg}"
|
error "Unknown argument: ${arg}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -z "${TARGET}" ]; then
|
if [ -z "${TARGET}" ]; then
|
||||||
@ -156,7 +156,7 @@ fi
|
|||||||
|
|
||||||
# print the options
|
# print the options
|
||||||
if [ $OPT_NO_OPTS -eq 0 ]; then
|
if [ $OPT_NO_OPTS -eq 0 ]; then
|
||||||
info "Running mp-pool with the options:"
|
info "Running mp-pool with the options:"
|
||||||
print " $BOLD SKIP_FAIL = $(itoyn $OPT_SKIP_FAIL)"
|
print " $BOLD SKIP_FAIL = $(itoyn $OPT_SKIP_FAIL)"
|
||||||
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)"
|
||||||
@ -203,14 +203,14 @@ for pkg in "${srcpath}/"*; do
|
|||||||
info "(${pi}/${pc}) Building \"${package}\""
|
info "(${pi}/${pc}) Building \"${package}\""
|
||||||
|
|
||||||
if [ $OPT_SKIP_FAIL -eq 1 ]; then
|
if [ $OPT_SKIP_FAIL -eq 1 ]; then
|
||||||
mp_build_opts "${pkg}"
|
mp_build_opts "${pkg}" "${distpath}"
|
||||||
if [ $? -ne "0" ]; then
|
if [ $? -ne "0" ]; then
|
||||||
error "(${pi}/${pc}) Build failed for \"${package}\", skipping"
|
error "(${pi}/${pc}) Build failed for \"${package}\", skipping"
|
||||||
pi=$((pi+1))
|
pi=$((pi+1))
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
mp_build_opts "${pkg}"
|
mp_build_opts "${pkg}" "${distpath}"
|
||||||
check_ret "(${pi}/${pc}) Build failed for \"${package}\""
|
check_ret "(${pi}/${pc}) Build failed for \"${package}\""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -222,7 +222,7 @@ for pkg in "${srcpath}/"*; do
|
|||||||
mv "${archive}" "${distpath}"
|
mv "${archive}" "${distpath}"
|
||||||
check_ret "(${pi}/${pc}) Moving package archive failed for \"${package}\""
|
check_ret "(${pi}/${pc}) Moving package archive failed for \"${package}\""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
success "(${pi}/${pc}) Build was successful for \"${package}\""
|
success "(${pi}/${pc}) Build was successful for \"${package}\""
|
||||||
pi=$((pi+1))
|
pi=$((pi+1))
|
||||||
done
|
done
|
||||||
@ -242,8 +242,8 @@ if [ "$OPT_NO_SIGN" -eq 0 ]; then
|
|||||||
check_ret "Failed to sign package archive: \"$(basename "${pkg}")\""
|
check_ret "Failed to sign package archive: \"$(basename "${pkg}")\""
|
||||||
success "Signed archive: $(basename "${pkg}")"
|
success "Signed archive: $(basename "${pkg}")"
|
||||||
done
|
done
|
||||||
|
|
||||||
success "Signing process was completed"
|
success "Signing process was completed"
|
||||||
unset_indent
|
unset_indent
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -281,7 +281,7 @@ for pkg in "${distpath}/"*".mpf"; do
|
|||||||
done
|
done
|
||||||
|
|
||||||
pushd "${distpath}/list" > /dev/null
|
pushd "${distpath}/list" > /dev/null
|
||||||
tar czf "${distpath}/LIST" *
|
tar czf "${distpath}/LIST" *
|
||||||
check_ret "(2/2) Failed to create list archive (LIST)"
|
check_ret "(2/2) Failed to create list archive (LIST)"
|
||||||
popd > /dev/null
|
popd > /dev/null
|
||||||
|
|
||||||
|
@ -109,12 +109,20 @@ itoyn() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# checks if all the required package vars/functions are set
|
# unsets all the pool script vars/functions
|
||||||
|
clean_pool_vars() {
|
||||||
|
unset NAME
|
||||||
|
unset MAINTAINER
|
||||||
|
unset PUBKEY
|
||||||
|
unset SRCDIR
|
||||||
|
}
|
||||||
|
|
||||||
|
# checks if all the required pool script vars/functions are set
|
||||||
check_pool_vars() {
|
check_pool_vars() {
|
||||||
if [ ! -n "$NAME" ]; then
|
if [ ! -n "$NAME" ]; then
|
||||||
error "Failed to load the pool script"
|
error "Failed to load the pool script"
|
||||||
set_indent
|
set_indent
|
||||||
|
|
||||||
error "Required pool variable is not set: \"\$NAME\""
|
error "Required pool variable is not set: \"\$NAME\""
|
||||||
unset_indent
|
unset_indent
|
||||||
|
|
||||||
@ -126,9 +134,9 @@ check_pool_vars() {
|
|||||||
error "Required pool variable is not set: \"\$MAINTAINER\""
|
error "Required pool variable is not set: \"\$MAINTAINER\""
|
||||||
unset_indent
|
unset_indent
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
elif [ ! -n "$PUBKEY" ]; then
|
elif [ ! -n "$PUBKEY" ]; then
|
||||||
error "Failed to load the pool script"
|
error "Failed to load the pool script"
|
||||||
set_indent
|
set_indent
|
||||||
|
|
||||||
error "Required pool variable is not set: \"\$PUBKEY\""
|
error "Required pool variable is not set: \"\$PUBKEY\""
|
||||||
@ -136,7 +144,7 @@ check_pool_vars() {
|
|||||||
|
|
||||||
return 1
|
return 1
|
||||||
elif [ ! -n "$SRCDIR" ]; then
|
elif [ ! -n "$SRCDIR" ]; then
|
||||||
error "Failed to load the pool script"
|
error "Failed to load the pool script"
|
||||||
set_indent
|
set_indent
|
||||||
|
|
||||||
error "Required pool variable is not set: \"\$SRCDIR\""
|
error "Required pool variable is not set: \"\$SRCDIR\""
|
||||||
@ -144,7 +152,7 @@ check_pool_vars() {
|
|||||||
|
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case "${NAME}" in
|
case "${NAME}" in
|
||||||
*" "*)
|
*" "*)
|
||||||
error "Pool name contains an invalid character: \" \""
|
error "Pool name contains an invalid character: \" \""
|
||||||
@ -155,7 +163,20 @@ check_pool_vars() {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# checks if all the required package vars/functions are set
|
# unsets all the package script vars/functions
|
||||||
|
clean_pkg_vars() {
|
||||||
|
unset NAME
|
||||||
|
unset DESC
|
||||||
|
unset VERSION
|
||||||
|
unset FILES
|
||||||
|
unset HASHES
|
||||||
|
unset DEPENDS
|
||||||
|
unset BUILD
|
||||||
|
unset PACKAGE
|
||||||
|
unset INSTALL
|
||||||
|
}
|
||||||
|
|
||||||
|
# checks if all the required package script vars/functions are set
|
||||||
check_pkg_vars() {
|
check_pkg_vars() {
|
||||||
if [ ! -n "$NAME" ]; then
|
if [ ! -n "$NAME" ]; then
|
||||||
error "Failed to load the package script"
|
error "Failed to load the package script"
|
||||||
|
Loading…
Reference in New Issue
Block a user