Skip to content

Commit

Permalink
feat(package): add instruction rootcps to copy to / with envar substi…
Browse files Browse the repository at this point in the history
…tution
  • Loading branch information
yunielrc committed Sep 17, 2023
1 parent 4f89db9 commit 8ee935a
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/usr/lib/ydf/components/package/ydf-package-service.bash
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fi
# readonly __YDF_PACKAGE_SERVICE_INSTRUCTIONS_MANJARO="preinstall pacman yay install postinstall ${__YDF_PACKAGE_SERVICE_INSTRUCTIONS_COMMON}"
# readonly __YDF_PACKAGE_SERVICE_INSTRUCTIONS_UBUNTU="preinstall apt install postinstall ${__YDF_PACKAGE_SERVICE_INSTRUCTIONS_COMMON}"
# shellcheck disable=SC2016
readonly __YDF_PACKAGE_SERVICE_INSTRUCTIONS_COMMON='install @flatpak @snap docker_compose:docker-compose.yml plugin_zsh:${pkg_name}.plugin.zsh homeln/ homelnr/ homecp/ rootcp/ homecat/ rootcat/ homecps/ postinstall'
readonly __YDF_PACKAGE_SERVICE_INSTRUCTIONS_COMMON='install @flatpak @snap docker_compose:docker-compose.yml plugin_zsh:${pkg_name}.plugin.zsh homeln/ homelnr/ homecp/ rootcp/ homecat/ rootcat/ homecps/ rootcps/ postinstall'

readonly __YDF_PACKAGE_SERVICE_INSTRUCTIONS_MANJARO="preinstall @pacman @yay ${__YDF_PACKAGE_SERVICE_INSTRUCTIONS_COMMON}"
# readonly __YDF_PACKAGE_SERVICE_INSTRUCTIONS_UBUNTU="preinstall install postinstall ${__YDF_PACKAGE_SERVICE_INSTRUCTIONS_COMMON}"
Expand Down Expand Up @@ -393,6 +393,23 @@ ydf::package_service::__instruction_homecps() {
"$1" homecps
}

#
# Execute rootcps instruction
#
# Globals:
# HOME
#
# Arguments:
# pkg_name string package name
#
# Returns:
# 0 on success, non-zero on error.
#
ydf::package_service::__instruction_rootcps() {
ydf::package_service::__recursive_copy_with_envsubst \
"$1" rootcps
}

#
# Install a ydotfile package from a directory
#
Expand Down
63 changes: 63 additions & 0 deletions tests/usr/lib/ydf/components/package/ydf-package-command.f.bats
Original file line number Diff line number Diff line change
Expand Up @@ -566,3 +566,66 @@ line 11'
.* vedv vedv .* /home/vedv/.my/dir1/file11
.* vedv vedv .* /home/vedv/.my/file1"
}

# Tests for ydf package install ./18rootcps
@test "ydf package install ./18rootcps Should succeed" {
local -r _package_dir="${TEST_FIXTURES_DIR}/packages/18rootcps"

run ydf package install "$_package_dir"

assert_success
assert_output ""

run cat /.my/file1

assert_success
assert_output "line 1
line 3"

run cat /.my/dir1/file11

assert_success
assert_output 'line 1
file11_1: "file11_1"
file11_2: file11 2
line 11'

run cat /.my-config.env

assert_success
assert_output 'line 1
my_config1: "my_config1"
my_config2: my config2
line 11'

run ls -la /.my

assert_success
assert_output --regexp ".* root root .* \.
.* root root .* \.\.
.* root root .* dir1
.* root root .* file1"

run ls -la /.my/file1 \
/.my/dir1/file11 /.my-config.env

assert_success
assert_output --regexp ".* root root .* /.my-config.env
.* root root .* /.my/dir1/file11
.* root root .* /.my/file1"
}
Original file line number Diff line number Diff line change
Expand Up @@ -811,3 +811,8 @@ line 11'
@test "ydf::package_service::__instruction_homecps() DUMMY" {
:
}

# Tests for ydf::package_service::__instruction_rootcps()
@test "ydf::package_service::__instruction_rootcps() DUMMY" {
:
}

0 comments on commit 8ee935a

Please sign in to comment.