Script "collect_new_packages.sh"
#!/bin/sh

# -----------------------------
# collect_new_packages.sh
# version 1.2.7.5
# -----------------------------

[ -z "${USERNAME}" ] && USERNAME=`logname`
# sed 's/^[ \t]*//;s/[ \t]*$//' is used to delete both leading and trailing whitespace
USERHOME=`finger -l "${USERNAME}" 2>/dev/null | grep "Directory:" | cut -f1 | cut -d':' -f2 | sed 's/^[ \t]*//;s/[ \t]*$//'`
[ -z "${USERHOME}" ] && USERHOME="/home/`logname`"
[ -z "${CHROOT_DIR}" ] && CHROOT_DIR="${HOME}/mx-chroot"
[ -z "${BUILDFARM_DIR}" ] && BUILDFARM_DIR="${USERHOME}/build-farm"

printf "User: %s  \tHome directory: %s\n" "${USERNAME}" "${USERHOME}"

src_packages_dir=`find "${CHROOT_DIR}"/root -type d -name PACKAGES`
dst_packages_dir=`find "${BUILDFARM_DIR}" -type d -name PACKAGES`
list_of_src_packages=`find "${src_packages_dir}" -name *.srcpkg.* -print`
list_of_bin_packages=`find "${src_packages_dir}" -name *.binpkg.* -print`
if [ ! -z "${list_of_src_packages}" ] || [ ! -z "${list_of_bin_packages}" ]; then
  printf "Moving from '%s' to '%s':\n" "${src_packages_dir}" "${dst_packages_dir}"
else
  echo "No packages to collect."
fi

if [ ! -z "${list_of_src_packages}" ]; then
  echo "${list_of_src_packages}" | while read the_pkg
  do
    mv "${the_pkg}" "${dst_packages_dir}"/
    printf "\t%s\n" "${the_pkg}"
  done
fi
if [ ! -z "${list_of_bin_packages}" ]; then
  echo "${list_of_bin_packages}" | while read the_pkg
  do
    mv "${the_pkg}" "${dst_packages_dir}"/
    printf "\t%s\n" "${the_pkg}"
  done
fi

cd "${dst_packages_dir}"
chown -R "${USERNAME}" ./* && chgrp -R "${USERNAME}" ./* && chmod -R ug+w ./*

# self-update
if [ -d "${BUILDFARM_DIR}"/SERVICE-SCRIPTS ]; then
  script_name=`basename "${0}"`
  rm -f "${HOME}"/"${script_name}".NEW
  cp "${BUILDFARM_DIR}"/SERVICE-SCRIPTS/"${script_name}" "${HOME}"/"${script_name}".NEW
  diff -u "${HOME}"/"${script_name}" "${HOME}"/"${script_name}".NEW 1>/dev/null 2>&1 && \
    rm -f "${HOME}"/"${script_name}".NEW
  [ -f "${HOME}"/"${script_name}".NEW ] && printf "found new version of this script, see '%s'\n" "${script_name}".NEW
fi

echo "-done-"
Unless otherwise stated, the content of this page is licensed under GNU Free Documentation License.