Skip to content

Commit

Permalink
feat(package): add an instruction to install @snap apps
Browse files Browse the repository at this point in the history
  • Loading branch information
yunielrc committed Sep 15, 2023
1 parent 322b0ef commit d0eda52
Show file tree
Hide file tree
Showing 11 changed files with 89 additions and 8 deletions.
11 changes: 4 additions & 7 deletions Vedvfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@ FROM admin@manjaro/manjaro-gnome-22.1.3-x86_64

WORKDIR /home/vedv/ydf

RUN sudo pacman-mirrors --fasttrack && \
sudo pacman -Syu --noconfirm --needed make
RUN sudo pacman-mirrors --fasttrack

COPY packages.env .
# install gnome base system
RUN sudo -H flatpak install --assumeyes --noninteractive io.github.andreibachim.shortcut

RUN mkdir tools
COPY tools/install-run-manjaro tools
COPY tools/install-dev-manjaro.vedv tools
COPY packages.env .

RUN tools/install-run-manjaro && tools/install-dev-manjaro.vedv
# install gnome base system
RUN sudo -H flatpak install --assumeyes --noninteractive io.github.andreibachim.shortcut

COPY . .
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 @@ -29,7 +29,7 @@ fi
# readonly __YDF_PACKAGE_SERVICE_INSTRUCTIONS_UBUNTU="preinstall apt install postinstall ${__YDF_PACKAGE_SERVICE_INSTRUCTIONS_COMMON}"

readonly __YDF_PACKAGE_SERVICE_INSTRUCTIONS_COMMON=''
readonly __YDF_PACKAGE_SERVICE_INSTRUCTIONS_MANJARO="preinstall install @pacman @yay @flatpak postinstall ${__YDF_PACKAGE_SERVICE_INSTRUCTIONS_COMMON}"
readonly __YDF_PACKAGE_SERVICE_INSTRUCTIONS_MANJARO="preinstall install @pacman @yay @flatpak @snap postinstall ${__YDF_PACKAGE_SERVICE_INSTRUCTIONS_COMMON}"
# readonly __YDF_PACKAGE_SERVICE_INSTRUCTIONS_UBUNTU="preinstall install postinstall ${__YDF_PACKAGE_SERVICE_INSTRUCTIONS_COMMON}"

#
Expand Down Expand Up @@ -158,6 +158,23 @@ ydf::package_service::__instruction_@flatpak() {
sudo -H flatpak install --assumeyes --noninteractive flathub "${flatpak_pkg_name:-"$pkg_name"}"
}

#
# Execute @snap instruction
#
# Arguments:
# pkg_name string package name
#
# Returns:
# 0 on success, non-zero on error.
#
ydf::package_service::__instruction_@snap() {
local -r pkg_name="$1"
# select the first no empty line
local -r snap_pkg_name="$(ydf::utils::print_1line <@snap)"
# eval allows include options along with package name
eval sudo -H snap install "${snap_pkg_name:-"$pkg_name"}"
}

#
# Install a ydotfile package from a directory
#
Expand Down
1 change: 1 addition & 0 deletions tests/fixtures/packages/8go@snap/@snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--classic go
1 change: 1 addition & 0 deletions tests/fixtures/packages/8go@snap/install
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
echo '8go@snap: install succeed'
1 change: 1 addition & 0 deletions tests/fixtures/packages/8go@snap/postinstall
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
echo '8go@snap: postinstall succeed'
1 change: 1 addition & 0 deletions tests/fixtures/packages/8go@snap/preinstall
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
echo '8go@snap: preinstall succeed'
Empty file.
32 changes: 32 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 @@ -220,3 +220,35 @@ com.github.tchx84.Flatseal: postinstall succeed"
assert_success
assert_output --partial "com.github.tchx84.Flatseal"
}

# Tests for ydf package install ../8go@snap
@test "ydf package install ../8go@snap, Should succeed" {
local -r _package_dir="${TEST_FIXTURES_DIR}/packages/8go@snap"

run ydf package install "$_package_dir"

assert_success
assert_output --regexp "8go@snap: preinstall succeed
8go@snap: install succeed
.*
8go@snap: postinstall succeed"

run command -v go

assert_success
assert_output --partial "/bin/go"
}

@test "ydf package install ../multipass, Should succeed Without package name in @snap" {
local -r _package_dir="${TEST_FIXTURES_DIR}/packages/multipass"

run ydf package install "$_package_dir"

assert_success
assert_output --regexp "multipass .* installed"

run command -v multipass

assert_success
assert_output --partial "/bin/multipass"
}
Original file line number Diff line number Diff line change
Expand Up @@ -246,3 +246,20 @@ postinstall"
assert_success
assert_output --partial "io.missioncenter.MissionCenter/x86_64/stable"
}

# Tests for ydf::package_service::__instruction_@snap()
@test "ydf::package_service::__instruction_@snap() Should succeed" {

cd "${TEST_FIXTURES_DIR}/packages/8go@snap"

run ydf::package_service::__instruction_@snap '8go@snap'

assert_success
assert_output --partial "go"

run command -v go

assert_success

assert_output --partial 'bin/go'
}
1 change: 1 addition & 0 deletions tools/ct-clean-exec
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ if ! vedv container ls --all | grep -q "$VEDV_CONTAINER_NAME"; then
vedv container create --name "$VEDV_CONTAINER_NAME" "$VEDV_IMAGE_NAME"
echo ">> Container created"

echo
echo ">> Starting container"
vedv container start --wait "$VEDV_CONTAINER_NAME"
echo ">> Container started"
Expand Down
13 changes: 13 additions & 0 deletions tools/install-run-manjaro
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,16 @@ set -eu
sudo pacman -Syu --noconfirm --needed yay

yay -Sy --noconfirm --needed "${PKG_RUN_MANJARO_YAY[@]}"

# Install snap
sudo pacman -S --noconfirm --needed snapd

sudo systemctl enable apparmor --now
sudo systemctl enable snapd.apparmor --now
sudo systemctl enable snapd --now

sudo ln -vs /var/lib/snapd/snap /snap

echo ">>Attention: log out and back in again, or restart your system, to ensure snap’s paths are updated correctly"

# sudo snap install core

0 comments on commit d0eda52

Please sign in to comment.