From 0eb001f470c8f162740eb86d17e46b490811e9f2 Mon Sep 17 00:00:00 2001 From: merakor Date: Sat, 26 Jun 2021 12:59:37 +0000 Subject: pkg_repository_update(): move package repository update calls to this function for better scriptability FossilOrigin-Name: 368840cf577d21bca584d84f3421d0ce62bb30797fef08bfc49aaa98a5c7fddf --- src/cpt-lib.in | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/cpt-lib.in b/src/cpt-lib.in index 4e687c4..569008d 100644 --- a/src/cpt-lib.in +++ b/src/cpt-lib.in @@ -1659,6 +1659,24 @@ pkg_install() { log "$pkg_name" "Installed successfully" } +pkg_repository_update() { + # Function to update the given package repository. + cd "$1" + repo_type=$(pkg_vcs_info) + repo_root=${repo_type#$PWD:} + repo_type=${repo_type##*:} repo_root=${repo_root%:*} + contains "$repos" "$repo_root" || { + repos="$repos $repo_root " + cd "$repo_root" + + "pkg_vcs_pull_$repo_type" + + # Repositories can contain a "Message of the Day" file in order to + # relay important information to their users. + ! [ -r "$repo_root/motd" ] || cat "$repo_root/motd" + } +} + pkg_vcs_clone_git() { # $1: Clone URL # $2: Branch or Commit Object @@ -1844,23 +1862,7 @@ pkg_fetch() { # Update each repository in '$CPT_PATH'. It is assumed that # each repository is 'git' tracked. - for repo; do - # Go to the root of the repository. - cd "$repo" - repo_type=$(pkg_vcs_info) - repo_root=${repo_type#$PWD:} - repo_type=${repo_type##*:} repo_root=${repo_root%:*} - contains "$repos" "$repo_root" || { - repos="$repos $repo_root " - cd "$repo_root" - - "pkg_vcs_pull_$repo_type" - - # Repositories can contain a "Message of the Day" file in order to - # relay important information to their users. - ! [ -r "$repo_root/motd" ] || cat "$repo_root/motd" - } - done + for repo; do pkg_repository_update "$repo"; done run_hook post-fetch } -- cgit v1.2.3