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-opts$RESET: don't show/list options"
|
||||
echo_color " $BOLD--cores$RESET: how many cores to use for the build"
|
||||
echo_color " $BOLD--out$RESET: directory for the output archive"
|
||||
echo
|
||||
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_OPTS=0 # showing/listing options is ENABLED
|
||||
OPT_CORES=$(nproc) # use ALL CPU cores
|
||||
OPT_OUT="DEFAULT" # use the package dist directory for output
|
||||
|
||||
# parses all the options
|
||||
for arg in "$@"; do
|
||||
@ -166,7 +168,15 @@ for arg in "$@"; do
|
||||
"--no-opts")
|
||||
OPT_NO_OPTS=1 ;;
|
||||
"--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}"
|
||||
exit 1 ;;
|
||||
@ -206,7 +216,8 @@ if [ $OPT_NO_OPTS -eq 0 ]; then
|
||||
print " $BOLD NO_SDTOUT = $(itoyn $OPT_NO_STDOUT)"
|
||||
print " $BOLD NO_CACHE = $(itoyn $OPT_NO_CACHE)"
|
||||
print " $BOLD NO_OPTS = $(itoyn $OPT_NO_OPTS)"
|
||||
print " $BOLD CORES = $OPT_CORES"
|
||||
print " $BOLD CORES = ${OPT_CORES}"
|
||||
print " $BOLD OUT = ${OPT_OUT}"
|
||||
fi
|
||||
|
||||
cd "${TARGET}"
|
||||
@ -236,6 +247,11 @@ fi
|
||||
pkgpath="$(realpath .)"
|
||||
cachepath="$(realpath '.cache')"
|
||||
distpath="$(realpath 'dist')"
|
||||
if [ "${OPT_OUT}" == "DEFAULT" ]; then
|
||||
outpath="${distpath}"
|
||||
else
|
||||
outpath="${OPT_OUT}"
|
||||
fi
|
||||
rootpath="$(realpath 'root')"
|
||||
|
||||
mkdir -p "${rootpath}"
|
||||
@ -249,7 +265,7 @@ if [ $OPT_NO_CACHE -eq 0 ] && [ -f "${cachepath}/last" ]; then
|
||||
package_cache=$(sed -n '1p' "${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)"
|
||||
success "Build was successful"
|
||||
exit 0
|
||||
@ -431,6 +447,12 @@ clean_dist
|
||||
info "Cleaning the root directory"
|
||||
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
|
||||
unset_indent
|
||||
info "Updating the package cache"
|
||||
|
@ -95,6 +95,8 @@ for pkg in "${srcpath}/"*; do
|
||||
|
||||
files+=("${NAME}_${VERSION}.mpf")
|
||||
files+=("${NAME}_${VERSION}.mpf.sig")
|
||||
|
||||
clean_pkg_vars
|
||||
pi=$((pi+1))
|
||||
done
|
||||
|
||||
|
@ -72,7 +72,7 @@ list_to_str(){
|
||||
|
||||
# run mp-build with options
|
||||
mp_build_opts(){
|
||||
local opts=("${1}" "--no-opts")
|
||||
local opts=("${1}" "--no-opts" "--out='${2}'")
|
||||
|
||||
if [ $OPT_NO_DEPEND -eq 1 ]; then
|
||||
opts+=("--no-depend")
|
||||
@ -203,14 +203,14 @@ for pkg in "${srcpath}/"*; do
|
||||
info "(${pi}/${pc}) Building \"${package}\""
|
||||
|
||||
if [ $OPT_SKIP_FAIL -eq 1 ]; then
|
||||
mp_build_opts "${pkg}"
|
||||
mp_build_opts "${pkg}" "${distpath}"
|
||||
if [ $? -ne "0" ]; then
|
||||
error "(${pi}/${pc}) Build failed for \"${package}\", skipping"
|
||||
pi=$((pi+1))
|
||||
continue
|
||||
fi
|
||||
else
|
||||
mp_build_opts "${pkg}"
|
||||
mp_build_opts "${pkg}" "${distpath}"
|
||||
check_ret "(${pi}/${pc}) Build failed for \"${package}\""
|
||||
fi
|
||||
|
||||
|
@ -109,7 +109,15 @@ itoyn() {
|
||||
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() {
|
||||
if [ ! -n "$NAME" ]; then
|
||||
error "Failed to load the pool script"
|
||||
@ -155,7 +163,20 @@ check_pool_vars() {
|
||||
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() {
|
||||
if [ ! -n "$NAME" ]; then
|
||||
error "Failed to load the package script"
|
||||
|
Loading…
Reference in New Issue
Block a user