diff --git a/src/common/clib-package.c b/src/common/clib-package.c index f047c0e9..b74f4529 100755 --- a/src/common/clib-package.c +++ b/src/common/clib-package.c @@ -1096,8 +1096,11 @@ static void set_prefix(clib_package_t *pkg, long path_max) { } } -int clib_package_install_executable(clib_package_t *pkg, const char *dir, - int verbose) { +int clib_package_install_executable( + clib_package_t *pkg, + const char *dir, + int verbose +) { #ifdef PATH_MAX long path_max = PATH_MAX; #elif defined(_PC_PATH_MAX) @@ -1207,9 +1210,30 @@ int clib_package_install_executable(clib_package_t *pkg, const char *dir, goto cleanup; } - if (!opts.global && pkg->makefile) { - E_FORMAT(&command, "cp -fr %s/%s/%s %s", dir_path, pkg->name, - basename(pkg->makefile), unpack_dir); + if (!opts.global) { + if (pkg->makefile) { + E_FORMAT(&command, + "cp -fr %s/%s/%s %s", + dir_path, + pkg->name, + basename(pkg->makefile), + unpack_dir + ); + + rc = system(command); + if (0 != rc) { + goto cleanup; + } + + free(command); + } + + E_FORMAT(&command, + "cp -rf %s/* %s/%s", + unpack_dir, + dir_path, + pkg->name + ); rc = system(command); if (0 != rc) { diff --git a/test/cache/cache-test.c b/test/cache/cache-test.c index bb2a42aa..287aa634 100644 --- a/test/cache/cache-test.c +++ b/test/cache/cache-test.c @@ -23,7 +23,7 @@ static void assert_cached_file(char *pkg_dir, char *file) { static void assert_cached_files(char *pkg_dir) { assert_cached_file(pkg_dir, "copy.c"); assert_cached_file(pkg_dir, "copy.h"); - assert_cached_file(pkg_dir, "package.json"); + assert_cached_file(pkg_dir, "clib.json"); } int main() { diff --git a/test/data/test-save-package.json b/test/data/test-save-clib.json similarity index 100% rename from test/data/test-save-package.json rename to test/data/test-save-clib.json diff --git a/test/install-binary-dependencies.sh b/test/install-binary-dependencies.sh index 458e00b6..96056ca4 100755 --- a/test/install-binary-dependencies.sh +++ b/test/install-binary-dependencies.sh @@ -1,10 +1,15 @@ #!/bin/sh +mkdir -p tmp/bin + clib install -c stephenmathieson/tabs-to-spaces@1.0.0 -P tmp > /dev/null || { echo >&2 "Failed to install stephenmathieson/tabs-to-spaces" exit 1 } + command -v tmp/bin/t2s >/dev/null 2>&1 || { echo >&2 "Failed to put t2s on path" exit 1 } + +rm -rf deps/tabs-to-spaces diff --git a/test/install-deps-from-package-json.sh b/test/install-deps-from-clib-json.sh similarity index 93% rename from test/install-deps-from-package-json.sh rename to test/install-deps-from-clib-json.sh index e32e13e6..8da47da0 100755 --- a/test/install-deps-from-package-json.sh +++ b/test/install-deps-from-clib-json.sh @@ -10,7 +10,7 @@ mkdir -p tmp cd tmp || exit # see https://github.com/clibs/clib/issues/45 -cat > package.json << EOF +cat > clib.json << EOF { "dependencies": { "linenoise": "*", diff --git a/test/install-save.sh b/test/install-save.sh index 4534fe2e..213edfdc 100755 --- a/test/install-save.sh +++ b/test/install-save.sh @@ -1,30 +1,34 @@ #!/bin/sh +root="$(pwd)" mkdir -p tmp/test-save -cp test/data/test-save-package.json tmp/test-save/package.json +mkdir -p tmp/bin +cp test/data/test-save-clib.json tmp/test-save/clib.json cd tmp/test-save || exit -../../clib-install -c --save stephenmathieson/tabs-to-spaces@1.0.0 >/dev/null -../../clib-install -c -S darthtrevino/str-concat@0.0.2 >/dev/null -../../clib-install -c --save-dev jwerle/fs.c@0.1.1 >/dev/null -../../clib-install -c -D clibs/parson@1.0.2 >/dev/null -cd - || exit +../../clib-install --prefix "$root/tmp" -c --save stephenmathieson/tabs-to-spaces@1.0.0 >/dev/null +../../clib-install --prefix "$root/tmp" -c -S darthtrevino/str-concat@0.0.2 >/dev/null +../../clib-install --prefix "$root/tmp" -c --save-dev jwerle/fs.c@0.1.1 >/dev/null +../../clib-install --prefix "$root/tmp" -c -D clibs/parson@1.0.2 >/dev/null +cd - >/dev/null || exit -if ! grep --quiet "stephenmathieson/tabs-to-spaces" tmp/test-save/package.json; then - echo >&2 "Failed to find stephenmathieson/tabs-to-spaces saved in package.json" +if ! grep --quiet "stephenmathieson/tabs-to-spaces" tmp/test-save/clib.json; then + echo >&2 "Failed to find stephenmathieson/tabs-to-spaces saved in clib.json" exit 1 fi -if ! grep --quiet "darthtrevino/str-concat" tmp/test-save/package.json; then - echo >&2 "Failed to find darthtrevino/strconcat saved in package.json" +if ! grep --quiet "darthtrevino/str-concat" tmp/test-save/clib.json; then + echo >&2 "Failed to find darthtrevino/strconcat saved in clib.json" exit 1 fi -if ! grep --quiet "jwerle/fs.c" tmp/test-save/package.json; then - echo >&2 "Failed to find jwerle/fs.c saved in package.json" +if ! grep --quiet "jwerle/fs.c" tmp/test-save/clib.json; then + echo >&2 "Failed to find jwerle/fs.c saved in clib.json" exit 1 fi -if ! grep --quiet "clibs/parson" tmp/test-save/package.json; then - echo >&2 "Failed to find clibs/parson saved in package.json" +if ! grep --quiet "clibs/parson" tmp/test-save/clib.json; then + echo >&2 "Failed to find clibs/parson saved in clib.json" exit 1 fi + +rm -rf "$root/deps/tabs-to-spaces" diff --git a/test/uninstall.sh b/test/uninstall.sh index 8cc78d8e..c2f5ebe9 100755 --- a/test/uninstall.sh +++ b/test/uninstall.sh @@ -11,6 +11,7 @@ clib uninstall stephenmathieson/tabs-to-spaces -P tmp # ensure the un-installation worked command -v tmp/bin/t2s >/dev/null 2>&1 && { + rm -rf deps/tabs-to-spaces exit 0 }