aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile5
-rw-r--r--spec/01_lib_spec.sh8
-rwxr-xr-xsrc/cpt2
-rw-r--r--src/cpt-lib.in55
-rw-r--r--www/index.md4
5 files changed, 48 insertions, 26 deletions
diff --git a/Makefile b/Makefile
index eceb18d..042e261 100644
--- a/Makefile
+++ b/Makefile
@@ -23,7 +23,10 @@ test: all tests/etc/cpt-hook
tests/etc/cpt-hook:
ln -s ../hook-file $@
-dist: docs/cpt.info
+CHANGELOG.md:
+ fossil wiki export Changelog | sed '1cCHANGELOG\n=========' > CHANGELOG.md
+
+dist: docs/cpt.info CHANGELOG.md
./tools/mkdist.sh "${VERSION}"
install: all
diff --git a/spec/01_lib_spec.sh b/spec/01_lib_spec.sh
index 581ba70..0ff2752 100644
--- a/spec/01_lib_spec.sh
+++ b/spec/01_lib_spec.sh
@@ -186,16 +186,12 @@ Describe 'CPT Library'
The variable CPT_HOOK should eq "$PWD/tests/hook-file"
End
End
- Describe 'create_cache()'
+ Describe 'create_tmp()'
After pkg_clean
It 'creates cache directories'
- When call create_cache
+ When call create_tmp
The variable mak_dir should be a directory
End
- It "doesn't create build directories if an argument is passed"
- When call create_cache nobuild
- The variable mak_dir should be undefined
- End
End
Describe 'pkg_get_base()'
CPT_ROOT=$PWD/tests
diff --git a/src/cpt b/src/cpt
index 4ddb4df..50268ea 100755
--- a/src/cpt
+++ b/src/cpt
@@ -11,7 +11,7 @@ case "$arg" in
log "Carbs Packaging Tool"
set --
for path in $(SEARCH_PATH=$PATH pkg_find cpt-* all -x); do
- set -- "${path#*/cpt-}" "$@"
+ set -- "${path##*/cpt-}" "$@"
max=$((${#1} > max ? ${#1} : max))
done
diff --git a/src/cpt-lib.in b/src/cpt-lib.in
index 2e8c262..5d93f83 100644
--- a/src/cpt-lib.in
+++ b/src/cpt-lib.in
@@ -882,11 +882,19 @@ pkg_strip() {
done 2>/dev/null ||:
}
+pkg_fix_deps_fullpath() {
+ # Return the canonical path of libraries extracted by readelf.
+ while read -r dep _ rslv _; do
+ [ "$dep" = "$1" ] || continue
+ printf '%s\n' "$rslv"
+ done
+}
+
pkg_fix_deps() {
# Dynamically look for missing runtime dependencies by checking each binary
# and library with either 'ldd' or 'readelf'. This catches any extra
# libraries and or dependencies pulled in by the package's build suite.
- log "$1" "Checking for missing dependencies"
+ log "$1" "Checking for missing dependencies (using ${elf_prog##*/})"
# Go to the directory containing the built package to
# simplify path building.
@@ -911,9 +919,15 @@ pkg_fix_deps() {
find "$pkg_dir/$pkg_name/" -type f 2>/dev/null |
while read -r file; do
+ # We call ldd regardless here, because we also use it to retrieve the
+ # fullpath of a library when using readelf. Best use we have here is
+ # saving it in a buffer, so we don't use the dynamic loader everytime we
+ # need to reference it.
+ lddbuf=$(ldd -- "$file" 2>/dev/null) ||:
+
case ${elf_prog:-ldd} in
*readelf) "$elf_prog" -d "$file" 2>/dev/null ;;
- *) ldd "$file" 2>/dev/null ;;
+ *) pirntf '%s\n' "$lddbuf" ;;
esac |
while read -r dep; do
# Skip lines containing 'ldd'.
@@ -925,6 +939,12 @@ pkg_fix_deps() {
dep=${dep##*\[}
dep=${dep%%\]*}
+ # Retrieve the fullpath of the library from our ldd buffer.
+ case $elf_prog in
+ *readelf) line=$(printf '%s\n' "$lddbuf" |
+ pkg_fix_deps_fullpath "$line")
+ esac
+
# ldd output:
# libc.so => /lib/ld-musl-x86_64.so.1
dep=${dep#* => }
@@ -1993,23 +2013,19 @@ pkg_clean() {
rm -rf -- "${CPT_TMPDIR:=$cac_dir/proc}/$pid"
}
+create_tmp() {
+ # Create the required temporary directories and set the variables which
+ # point to them.
+ mkdir -p "${mak_dir:=$tmp_dir/build}" \
+ "${pkg_dir:=$tmp_dir/pkg}" \
+ "${tar_dir:=$tmp_dir/export}"
+}
+
create_cache() {
- # A temporary directory can be specified apart from the cache
- # directory in order to build in a user specified directory.
- # /tmp could be used in order to build on ram, useful on SSDs.
- # The user can specify CPT_TMPDIR for this.
+ # DEPRECATED, use create_tmp() instead.
#
- # Create the required temporary directories and set the variables
- # which point to them.
- mkdir -p "${tmp_dir:=${CPT_TMPDIR:=$cac_dir/proc}/$pid}"
-
# If an argument is given, skip the creation of other cache directories.
- # This here makes shellcheck extremely angry, so I am globally disabling
- # SC2119.
- [ "$1" ] || mkdir -p "${mak_dir:=$tmp_dir/build}" \
- "${pkg_dir:=$tmp_dir/pkg}" \
- "${tar_dir:=$tmp_dir/export}"
-
+ [ "$1" ] || create_tmp
}
# main()
@@ -2028,7 +2044,14 @@ create_cache() {
# to them. This is seperate from temporary directories created in
# create_cache(). That's because we need these variables set on most
# occasions.
+ #
+ # A temporary directory can be specified apart from the cache directory in
+ # order to build in a user specified directory. /tmp could be used in order
+ # to build on ram, useful on SSDs. The user can specify CPT_TMPDIR for this.
+ # We create the temporary directory here to avoid permission issues that can
+ # arise from functions that call as_root().
mkdir -p "${cac_dir:=${CPT_CACHE:=${XDG_CACHE_HOME:-$HOME/.cache}/cpt}}" \
+ "${tmp_dir:=${CPT_TMPDIR:=$cac_dir/proc}/$pid}" \
"${src_dir:=$cac_dir/sources}" \
"${log_dir:=$cac_dir/logs}" \
"${bin_dir:=$cac_dir/bin}"
diff --git a/www/index.md b/www/index.md
index 99a1f13..abc5953 100644
--- a/www/index.md
+++ b/www/index.md
@@ -27,8 +27,8 @@ complements the tools that come with it. It has the following features:
users with the `$PATH` variable.
- **Serve repositories with your method** - Package repositories can be served
- in a variety of formats, they can be either local, served with Git, or through
- the `rsync` method, with Fossil integration to be added soon.
+ in a variety of formats, they can be either local, served with Git, Mercurial,
+ or through the `rsync` method, with Fossil integration to be added soon.
<hr>