Skip to content

copy unpacked files from 'local' install #286

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 29 additions & 5 deletions src/common/clib-package.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion test/cache/cache-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
File renamed without changes.
5 changes: 5 additions & 0 deletions test/install-binary-dependencies.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
#!/bin/sh

mkdir -p tmp/bin

clib install -c stephenmathieson/[email protected] -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
Original file line number Diff line number Diff line change
Expand Up @@ -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": "*",
Expand Down
32 changes: 18 additions & 14 deletions test/install-save.sh
Original file line number Diff line number Diff line change
@@ -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/[email protected] >/dev/null
../../clib-install -c -S darthtrevino/[email protected] >/dev/null
../../clib-install -c --save-dev jwerle/[email protected] >/dev/null
../../clib-install -c -D clibs/[email protected] >/dev/null
cd - || exit
../../clib-install --prefix "$root/tmp" -c --save stephenmathieson/[email protected] >/dev/null
../../clib-install --prefix "$root/tmp" -c -S darthtrevino/[email protected] >/dev/null
../../clib-install --prefix "$root/tmp" -c --save-dev jwerle/[email protected] >/dev/null
../../clib-install --prefix "$root/tmp" -c -D clibs/[email protected] >/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"
1 change: 1 addition & 0 deletions test/uninstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down