summaryrefslogtreecommitdiff
path: root/src/toru/toru-path
diff options
context:
space:
mode:
Diffstat (limited to 'src/toru/toru-path')
-rwxr-xr-xsrc/toru/toru-path125
1 files changed, 65 insertions, 60 deletions
diff --git a/src/toru/toru-path b/src/toru/toru-path
index 56bea42..fac4e5a 100755
--- a/src/toru/toru-path
+++ b/src/toru/toru-path
@@ -21,71 +21,76 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
. "$(librelib messages)"
-setup_traps
+. "$(librelib conf)"
-# TODO: better option parsing
-TORUPATH=${T:-${TORUPATH}}
-VERBOSE=${V:-false}
-FORCE=${F:-false}
+main() {
+ setup_traps
-. "$(librelib conf)"
-load_files libretools
-check_vars libretools TORUPATH REPOS || exit 1
-load_files abs
-check_vars abs ABSROOT || exit 1
-
-if [ ! -w "$TORUPATH" ]; then
- error "Toru's path isn't writable. Please check $TORUPATH"
- exit 1
-fi
-
-lastsyncfile=${TORUPATH}/lastsync.paths
-pathfile=${TORUPATH}/paths.tch
-
-if [ ! -e "${pathfile}" ]; then
- tcamgr create "${pathfile}"
-fi
-
-# TODO: ability to use flags to pass in other directories to fullrepos
-
-# This loops over ${REPOS[@]} backward. This is because early entries
-# in REPOS have higher precidence, but the way this is implemented,
-# the later entries have precedence, so we need to flip the order.
-fullrepos=()
-for (( i = ${#REPOS[@]}-1 ; i >= 0 ; i-- )); do
- $VERBOSE && msg "Processing [%s]" "${REPOS[$i]}"
-
- if [ -d "${ABSROOT}/${REPOS[$i]}" ]; then
- fullrepos+=("${ABSROOT}/${REPOS[$i]}")
+ # TODO: better option parsing
+ TORUPATH=${T:-${TORUPATH}}
+ VERBOSE=${V:-false}
+ FORCE=${F:-false}
+
+ load_files libretools
+ check_vars libretools TORUPATH REPOS || exit 1
+ load_files abs
+ check_vars abs ABSROOT || exit 1
+
+ if [ ! -w "$TORUPATH" ]; then
+ error "Toru's path isn't writable. Please check $TORUPATH"
+ exit 1
+ fi
+
+ lastsyncfile=${TORUPATH}/lastsync.paths
+ pathfile=${TORUPATH}/paths.tch
+
+ if [ ! -e "${pathfile}" ]; then
+ tcamgr create "${pathfile}"
fi
-done
-
-# Find PKGBUILDs in ${fullrepos[@]}
-find_args=("${fullrepos[@]}" -mindepth 2 -maxdepth 3 -type f -name PKGBUILD)
-if ! $FORCE && [[ -e $lastsyncfile ]]; then
- # if lastfilesync exists, only look at things that have
- # changed since then (unless $FORCE is on)
- find_args+=(-newer "${lastsyncfile}")
-fi
-IFS=$'\n'
-pkgbuilds=($(find "${find_args[@]}"))
-
-# Add information from each of the PKGBUILDs to the toru cache.
-msg "Updating path cache"
-msg2 "%d PKGBUILDs to update" ${#pkgbuilds[@]}
-for _pkgbuild in "${pkgbuilds[@]}"; do
- # plain "$_pkgbuild"
- if ! load_PKGBUILD "${_pkgbuild}" >/dev/null 2>&1; then
- error "%q contains errors, skipping" "${_pkgbuild}"
- continue
+
+ # TODO: ability to use flags to pass in other directories to fullrepos
+
+ # This loops over ${REPOS[@]} backward. This is because early entries
+ # in REPOS have higher precidence, but the way this is implemented,
+ # the later entries have precedence, so we need to flip the order.
+ fullrepos=()
+ for (( i = ${#REPOS[@]}-1 ; i >= 0 ; i-- )); do
+ $VERBOSE && msg "Processing [%s]" "${REPOS[$i]}"
+
+ if [ -d "${ABSROOT}/${REPOS[$i]}" ]; then
+ fullrepos+=("${ABSROOT}/${REPOS[$i]}")
+ fi
+ done
+
+ # Find PKGBUILDs in ${fullrepos[@]}
+ find_args=("${fullrepos[@]}" -mindepth 2 -maxdepth 3 -type f -name PKGBUILD)
+ if ! $FORCE && [[ -e $lastsyncfile ]]; then
+ # if lastfilesync exists, only look at things that have
+ # changed since then (unless $FORCE is on)
+ find_args+=(-newer "${lastsyncfile}")
fi
+ IFS=$'\n'
+ pkgbuilds=($(find "${find_args[@]}"))
+
+ # Add information from each of the PKGBUILDs to the toru cache.
+ msg "Updating path cache"
+ msg2 "%d PKGBUILDs to update" ${#pkgbuilds[@]}
+ for _pkgbuild in "${pkgbuilds[@]}"; do
+ # plain "$_pkgbuild"
+ if ! load_PKGBUILD "${_pkgbuild}" >/dev/null 2>&1; then
+ error "%q contains errors, skipping" "${_pkgbuild}"
+ continue
+ fi
- fullpath="$(dirname -- "${_pkgbuild}")"
+ fullpath="$(dirname -- "${_pkgbuild}")"
- for _pkg in "${pkgbase}" "${pkgname[@]}" "${provides[@]}"; do
- $VERBOSE && msg2 '%s -> %s' "${_pkg}" "${fullpath}"
- tcamgr put "${pathfile}" "${_pkg%%[<>=]*}" "${fullpath}"
+ for _pkg in "${pkgbase}" "${pkgname[@]}" "${provides[@]}"; do
+ $VERBOSE && msg2 '%s -> %s' "${_pkg}" "${fullpath}"
+ tcamgr put "${pathfile}" "${_pkg%%[<>=]*}" "${fullpath}"
+ done
done
-done
-date +%s > "${lastsyncfile}"
+ date +%s > "${lastsyncfile}"
+}
+
+main "$@"