aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormerakor <cem@ckyln.com>2021-06-26 12:59:37 +0000
committermerakor <cem@ckyln.com>2021-06-26 12:59:37 +0000
commit0eb001f470c8f162740eb86d17e46b490811e9f2 (patch)
tree8fff3ac912d2a8bb5fe469fd502b7c7bd799acf0 /src
parent0962927eb9a132f4323c8685a5ce3934a2f31c32 (diff)
downloadcpt-0eb001f470c8f162740eb86d17e46b490811e9f2.tar.gz
pkg_repository_update(): move package repository update calls
to this function for better scriptability FossilOrigin-Name: 368840cf577d21bca584d84f3421d0ce62bb30797fef08bfc49aaa98a5c7fddf
Diffstat (limited to 'src')
-rw-r--r--src/cpt-lib.in36
1 files 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
}