aboutsummaryrefslogtreecommitdiff
path: root/src/cpt-lib.in
diff options
context:
space:
mode:
Diffstat (limited to 'src/cpt-lib.in')
-rw-r--r--src/cpt-lib.in27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/cpt-lib.in b/src/cpt-lib.in
index 58c9a0f..3a57d00 100644
--- a/src/cpt-lib.in
+++ b/src/cpt-lib.in
@@ -100,7 +100,7 @@ sepchar() (
str_tmp=${str_tmp%?}
done
set -- "$@" "$str_tmp"
- str=${str#$str_tmp}
+ str=${str#"$str_tmp"}
done
printf '%s\n' "$@"
)
@@ -801,7 +801,7 @@ pkg_extract() {
# VCS Repository
git+*|hg+*|fossil+*)
backend=${src%%+*}
- url=${src##${backend}+} com=${url##*[@#]} com=${com#${url%[@#]*}}
+ url=${src##"${backend}"+} com=${url##*[@#]} com=${com#"${url%[@#]*}"}
log "$1" "Cloning ${url%[#@]*}"
"pkg_vcs_clone_$backend" "${url%[#@]*}" "$com"
@@ -972,7 +972,7 @@ pkg_fix_deps() {
case ${elf_prog:-ldd} in
*readelf) "$elf_prog" -d "$file" 2>/dev/null ;;
- *) pirntf '%s\n' "$lddbuf" ;;
+ *) printf '%s\n' "$lddbuf" ;;
esac |
while read -r dep; do
# Skip lines containing 'ldd'.
@@ -1033,7 +1033,7 @@ pkg_manifest() (
# sed: Remove the first character in each line (./dir -> /dir) and
# remove all lines which only contain '.'.
find . -type d -exec printf '%s/\n' {} + -o -print |
- sort -r | sed '/^\.$/d;/^\.\/$/d;ss.ss' > "${2:-$pkg_dir}/$1/$pkg_db/$1/manifest"
+ sort -r | sed '/^\.\/*$/d;ss.ss' > "${2:-$pkg_dir}/$1/$pkg_db/$1/manifest"
)
pkg_etcsums() (
@@ -1063,7 +1063,7 @@ pkg_tar() {
log "$1" "Creating tarball"
# Read the version information to name the package.
- read -r version release < "$(pkg_find "$1")/version"
+ read -r version release < "$pkg_dir/$1/$pkg_db/$1/version"
# Create a tarball from the contents of the built package.
cd "$pkg_dir/$1"
@@ -1294,7 +1294,7 @@ pkg_checksums() {
pkg_verify() {
# Verify all package checksums. This is achieved by generating a new set of
# checksums and then comparing those with the old set.
- vcmd="NR==FNR{a[\$1];next}/^git .*/{next}!((\$1)in a){exit 1}"
+ vcmd="NR==FNR{a[\$1];next}/^git .*/{next}!((\$1)in a){exit 1}END{if(NR/2!=FNR)exit 1}"
for pkg; do
repo_dir=$(pkg_find "$pkg")
@@ -1340,7 +1340,7 @@ pkg_conflicts() {
# Combine the dirname and file values, and print them into the
# temporary manifest to be parsed.
- printf '%s/%s\n' "${dirname#$CPT_ROOT}" "${file##*/}"
+ printf '%s/%s\n' "${dirname#"$CPT_ROOT"}" "${file##*/}"
done < "$tar_dir/$1/$pkg_db/$1/manifest" > "$CPT_TMPDIR/$pid/manifest"
@@ -1462,15 +1462,22 @@ pkg_swap() {
# its manifest file to reflect this. We then resort this file
# so no issues arise when removing packages.
cp -Pf "$CPT_ROOT/$2" "$pkg_owns>${alt#*>}"
- sed "s#^$(regesc "$2")\$#${PWD#$CPT_ROOT}/$pkg_owns>${alt#*>}#" \
+ sed "s#^$(regesc "$2")\$#${PWD#"$CPT_ROOT"}/$pkg_owns>${alt#*>}#" \
"../installed/$pkg_owns/manifest" |
sort -r -o "../installed/$pkg_owns/manifest"
+ else
+ # If the file doesn't exist, we assume that there was a previous owner,
+ # but the package was then removed. We want the message to be short
+ # and clear, I thought of writing "Swapping [...] from 'null' to '$1'",
+ # but that would probably sound more like a package manager bug. Instead
+ # we are printing the message below which should be informative enough.
+ log "Installing '$2' from '$1'"
fi
# Convert the desired alternative to a real file and rewrite
# the manifest file to reflect this. The reverse of above.
mv -f "$alt" "$CPT_ROOT/$2"
- sed "s#^${PWD#$CPT_ROOT}/$(regesc "$alt")\$#$2#" "../installed/$1/manifest" |
+ sed "s#^${PWD#"$CPT_ROOT"}/$(regesc "$alt")\$#$2#" "../installed/$1/manifest" |
sort -r -o "../installed/$1/manifest"
}
@@ -1714,7 +1721,7 @@ pkg_repository_update() {
# Function to update the given package repository.
cd "$1"
repo_type=$(pkg_vcs_info)
- repo_root=${repo_type#$PWD:}
+ repo_root=${repo_type#"$PWD":}
repo_type=${repo_type##*:} repo_root=${repo_root%:*}
contains "$repos" "$repo_root" || {
repos="$repos $repo_root "