diff --git a/matter-base/main.sh b/matter-base/main.sh index ebca147..e35d853 100755 --- a/matter-base/main.sh +++ b/matter-base/main.sh @@ -115,7 +115,7 @@ EOF popd > /dev/null info "Syncing repositories" -matt sync --root "${target}" --yes +matt sync --root "${target}" check_ret "matt command failed" info "Installing base system packages" @@ -186,9 +186,11 @@ check_ret "Failed to run make-ca, install certs manually" rm -f "${target}/certdata.txt" info "Running install scripts" -matter-chroot "${target}" bash -c "bash /var/lib/matt/data/scripts/*" > /dev/null +echo 'bash /var/lib/matt/data/scripts/*' > "${target}/install_scripts" +matter-chroot "${target}" bash /install_scripts > /dev/null check_ret "Failed to run install scripts" rm -r "${target}/var/lib/matt/data/scripts" +rm "${target}/install_scripts" info "Setup complete, now creating the archive..." pushd "${target}" > /dev/null diff --git a/mp-pool/scripts/mp-pool.sh b/mp-pool/scripts/mp-pool.sh index f26b701..cecf2f5 100755 --- a/mp-pool/scripts/mp-pool.sh +++ b/mp-pool/scripts/mp-pool.sh @@ -36,7 +36,7 @@ fi # prints the help info help_cmd() { info "MatterLinux pool build script" - info "Usage: ${0} [pool directory]" + info "Usage: ${0} [pool directory] " info "Options:" echo_color " $BOLD--skip-fail$RESET: skip if a package build fails" echo_color " $BOLD--no-depend$RESET: don't check depends" @@ -100,6 +100,8 @@ OPT_NO_CACHE=0 # cache is ENABLED OPT_NO_OPTS=0 # showing/listing options is ENABLED OPT_NO_SIGN=0 # sign all the built packages OPT_CORES=$(nproc) # use ALL CPU cores +OPT_POOLDIR="" # target pool directory (no default) +OPT_PACKAGES=() # target packages (all by default) # parses all the options for arg in "$@"; do @@ -126,23 +128,22 @@ for arg in "$@"; do error "Unknown option: ${arg}" exit 1 ;; *) - if [ -z "${TARGET}" ]; then - TARGET="${arg}" + if [ -z "${OPT_POOLDIR}" ]; then + OPT_POOLDIR="${arg}" else - error "Unknown argument: ${arg}" - exit 1 + OPT_PACKAGES+=("${arg}") fi ;; esac done -if [ -z "${TARGET}" ]; then +if [ -z "${OPT_POOLDIR}" ]; then error "Pool directory is not specified, run with \"--help\" for more information" exit 1 fi -if [ ! -d "${TARGET}" ]; then - error "Pool directory \"${TARGET}\" does not exist" +if [ ! -d "${OPT_POOLDIR}" ]; then + error "Pool directory \"${OPT_POOLDIR}\" does not exist" exit 1 fi @@ -166,8 +167,8 @@ if [ $OPT_NO_OPTS -eq 0 ]; then print " $BOLD CORES = $OPT_CORES" fi -cd "${TARGET}" -check_ret "Failed to change directory into \"${TARGET}\"" +cd "${OPT_POOLDIR}" +check_ret "Failed to change directory into \"${OPT_POOLDIR}\"" if [ ! -f "pool.sh" ]; then error "Package directory does not contain a pool script (pool.sh)" @@ -194,24 +195,38 @@ if [ ! -d "${srcpath}" ]; then exit 1 fi +# obtain every package if no package is specified +if [ -z "${OPT_PACKAGES}" ]; then + for pkg in "${srcpath}/"*; do + pkg_name=$(basename "${pkg}") + OPT_PACKAGES+=("${pkg_name}") + done +fi + # build every package -pc="$(ls -1q "${srcpath}" | wc -l)" +pc=${#OPT_PACKAGES[@]} pi=1 -for pkg in "${srcpath}/"*; do - package=$(basename "${pkg}") - info "(${pi}/${pc}) Building \"${package}\"" +for pkg_name in "${OPT_PACKAGES[@]}"; do + pkg="${srcpath}/${pkg_name}" + + if [ ! -d "${pkg}" ]; then + error "Package not found: \"${pkg_name}\"" + exit 1 + fi + + info "(${pi}/${pc}) Building \"${pkg_name}\"" if [ $OPT_SKIP_FAIL -eq 1 ]; then mp_build_opts "${pkg}" "${distpath}" if [ $? -ne "0" ]; then - error "(${pi}/${pc}) Build failed for \"${package}\", skipping" + error "(${pi}/${pc}) Build failed for \"${pkg_name}\", skipping" pi=$((pi+1)) continue fi else mp_build_opts "${pkg}" "${distpath}" - check_ret "(${pi}/${pc}) Build failed for \"${package}\"" + check_ret "(${pi}/${pc}) Build failed for \"${pkg_name}\"" fi archive="$(find "${pkg}/dist" -name "*.mpf" | tail -n1)" @@ -220,10 +235,10 @@ for pkg in "${srcpath}/"*; do if [ ! -z "${archive}" ]; then rm -f "${distpath}/${name}_"* mv "${archive}" "${distpath}" - check_ret "(${pi}/${pc}) Moving package archive failed for \"${package}\"" + check_ret "(${pi}/${pc}) Moving package archive failed for \"${pkg_name}\"" fi - success "(${pi}/${pc}) Build was successful for \"${package}\"" + success "(${pi}/${pc}) Build was successful for \"${pkg_name}\"" pi=$((pi+1)) done