From b9f8fbc4756c9f90ecbf79f273cdbb8cdf140925 Mon Sep 17 00:00:00 2001 From: knuxify Date: Sun, 6 Oct 2019 18:55:58 +0200 Subject: [PATCH 01/14] FRONTEND: FIX: Fix dnf and yum support --- shoppe | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/shoppe b/shoppe index b44d400..4b6aafc 100755 --- a/shoppe +++ b/shoppe @@ -430,6 +430,14 @@ yay_query() { if [[ -z "$(cat $tmpdir/err)" ]]; then return 1; else return 0; fi } +dnf_query() { + # Workaround for buggy dnf/yum behavior (doesn't work with ^pkgname$ regex). + # Usage: dnf_query + dqinput="${1/\^/}" + dqinput="${dqinput/\$/}" + $pm info "$dqinput" +} + zypper_query() { # Workaround for buggy zypper behavior (yay will return 0 even if the search has failed, also doesn't work with ^pkgname$ regex). # Usage: zypper_query @@ -469,13 +477,22 @@ frontend_init() { frontend_listall="apt-cache pkgnames" # TODO: This only shows package names but not versions. Fix that, eventually. frontend_noconfirm="--yes --force-yes" ;; - dnf|yum) # dnf/yum (Fedora, CentOS, Red Hat and related) + dnf) # dnf (Fedora) frontend_install="$suauth $pm install" frontend_remove="$suauth $pm remove" - frontend_update="$suauth $pm update" + frontend_update="$suauth $pm check-update 1>/dev/null" frontend_upgrade="$suauth $pm upgrade" - frontend_query="$pm search" - frontend_listall="rpm -qa | sed -i 's/\:/\ 0\ /g'" + frontend_query="dnf_query" + frontend_listall="rpm -qa --qf '%{NAME}\n'" + frontend_noconfirm="-y" + ;; + yum) # yum (Fedora, CentOS, Red Hat and related) + frontend_install="$suauth $pm install" + frontend_remove="$suauth $pm remove" + frontend_update="$suauth $pm check-update 1>/dev/null" + frontend_upgrade="$suauth $pm update" + frontend_query="dnf_query" + frontend_listall="rpm -qa --qf '%{NAME}\n'" frontend_noconfirm="-y" ;; yay|yaourt|pacaur) # AUR helpers (Arch Linux) @@ -710,7 +727,7 @@ shoppe_remove() { # Update repository info. shoppe_update() { [[ "$pm" ]] && echo -e "$p_info Fetching installed package list from frontend..." && frontend_harvest - [[ "$pm" ]] && $frontend_update + [[ "$pm" ]] && echo -e "$p_info Updating frontend repositories..." && $frontend_update mv "$configdir/repodata" "$tmpdir/repodata-bak" mkdir -p "$configdir/repodata" # For each repository, check the repository type and fetch it accordingly. From a61ff5438333e805d59563828415db4bb17839e6 Mon Sep 17 00:00:00 2001 From: knuxify Date: Mon, 21 Oct 2019 21:24:21 +0200 Subject: [PATCH 02/14] SHOPPE: NEW: Add package groups --- docs/package-groups.md | 21 ++++++++++ docs/packages.md | 4 ++ shoppe | 88 +++++++++++++++++++++++------------------- 3 files changed, 73 insertions(+), 40 deletions(-) create mode 100644 docs/package-groups.md diff --git a/docs/package-groups.md b/docs/package-groups.md new file mode 100644 index 0000000..6fc2aea --- /dev/null +++ b/docs/package-groups.md @@ -0,0 +1,21 @@ +# Package groups + +Package groups allow for multiple packages to be installed in one small command quickly. + +## Creating a package group + +Creating a package group is simmilar to adding a package (see (Packages)[packages.md]). + +Package groups use shoppepkg files, just like regular packages. However, package groups +only have the following variables: + +- pkgname +- pkgdesc +- pkgrel +- pkgver +- **group** +- **optgroup** + +The group variable contains the packages in the group, separated by spaces. + +The optgroup variable contains the optional packages in the group. You can store optional dependency descriptions in the ``optdeps`` file, just like in regular packages. This process is described in the regular package documentation ((Packages)[packages.md]). diff --git a/docs/packages.md b/docs/packages.md index 24c9567..204e651 100644 --- a/docs/packages.md +++ b/docs/packages.md @@ -74,3 +74,7 @@ shoppepkg_build() { # You can also specify post- and pre-install hooks, by creating the shoppepkg_preinstall and shoppepkg_postinstall functions. ``` + +## Package groups + +See: (Package groups)[package-groups.md]. diff --git a/shoppe b/shoppe index 4b6aafc..e416577 100755 --- a/shoppe +++ b/shoppe @@ -2,7 +2,7 @@ # shellcheck disable=SC1090,SC2001,SC1091,SC2219 ## ## shoppe - a portable package manager that integrates with your current package manager -version="1.2.2" +version="1.3.0" ## ## Licensed under the MIT License @@ -316,6 +316,7 @@ pkg_cleanup() { # Usage: pkg_cleanup unset pkgname pkgdesc pkgarch pkgver revision license url depends optdepends makedepends provides conflicts archdependent source sourcetype tag commit unset -f shoppepkg_preinstall shoppepkg_build shoppepkg_postinstall + unset group optgroup [[ "$currentskipfrontend" == "true" ]] && [[ -z "$pm" ]] && pm="$oldpm" unset nobuild current_uptodate currentskipfrontend [[ "$forcebuild" == "true" ]] && nobuild="false" @@ -333,49 +334,51 @@ pkg_install() { [[ "$package" != "$pkgname" ]] && echo -e "$p_debug Package name and pkgname do not match (expected $package, got $pkgname). Please contact the package's maintainer." contentdir="$tmpdir/$package/content" sourcedir="$tmpdir/$package/source" - type -t shoppepkg_preinstall &>/dev/null && echo -e " - $p_info Running pre-install..." && shoppepkg_preinstall - if [[ "$nobuild" == "false" ]]; then - type -t shoppepkg_build &>/dev/null && echo -e " - $p_info Building..." && ! shoppepkg_build && fail "Failed to build $package." - cd "$tmpdir/$package" - else - contentchecksumvar="content_${arch}_checksum" - mkdir "$tmpdir/$package/content" - # shellcheck disable=SC2154 - if [[ "$(sha512sum content-$arch.tar.gz | sed 's/\*/\ /g')" == "${!contentchecksumvar}" ]]; then - ! tar -xzf content-$arch.tar.gz -C "$tmpdir/$package/content" && fail "Failed to extract $package." + if [[ ! "$group" ]]; then + type -t shoppepkg_preinstall &>/dev/null && echo -e " - $p_info Running pre-install..." && shoppepkg_preinstall + if [[ "$nobuild" == "false" ]]; then + type -t shoppepkg_build &>/dev/null && echo -e " - $p_info Building..." && ! shoppepkg_build && fail "Failed to build $package." + cd "$tmpdir/$package" else - echo -e "$p_warn Package checksum (${!contentchecksumvar}) does not match the content tarball's checksum ($(sha512sum content-$arch.tar.gz | sed 's/\*/\ /g'))." - yesnotxt="Install anyways (not reccomended)?" yesno n - if [[ "$choice" == "yes" ]]; then - if tar -xzf content-$arch.tar.gz -C "$tmpdir/$package/content"; then - echo -e "$p_info Successfully extracted package." + contentchecksumvar="content_${arch}_checksum" + mkdir "$tmpdir/$package/content" + # shellcheck disable=SC2154 + if [[ "$(sha512sum content-$arch.tar.gz | sed 's/\*/\ /g')" == "${!contentchecksumvar}" ]]; then + ! tar -xzf content-$arch.tar.gz -C "$tmpdir/$package/content" && fail "Failed to extract $package." + else + echo -e "$p_warn Package checksum (${!contentchecksumvar}) does not match the content tarball's checksum ($(sha512sum content-$arch.tar.gz | sed 's/\*/\ /g'))." + yesnotxt="Install anyways (not reccomended)?" yesno n + if [[ "$choice" == "yes" ]]; then + if tar -xzf content-$arch.tar.gz -C "$tmpdir/$package/content"; then + echo -e "$p_info Successfully extracted package." + else + fail "Failed to extract $package." + fi else - fail "Failed to extract $package." + fail "Failed to install $package." fi - else - fail "Failed to install $package." fi fi + ! cd content && fail "Failed to install $package." + if [[ -z "$custominstalldir" ]]; then + ! $suauth cp -rf . / && fail "Failed to install $package." + else + ! $suauth cp -rf . "$custominstalldir/" && fail "Failed to install $package." + fi + cd "$tmpdir/$package" + [[ -e "$pkginfo/$package" ]] && rm -rf "${pkginfo:?}/${package:?}" + mkdir "$pkginfo/$package" + shopt -s globstar + [[ -e "$pkginfo/$package/content" ]] && rm "$pkginfo/$package/content" + for file in "$tmpdir/$package/content"/**; do + [[ "$custominstalldir" ]] && $suauth ln -s "$file" "${file/$PWD\/content/}" + # This doesn't include directories that are made by the package, + # but that's still better than adding the entire / directory. + [[ -f "$file" ]] && echo "${file/$PWD\/content/}" >> "$pkginfo/$package/content" + done + shopt -u globstar + type -t shoppepkg_postinstall &>/dev/null && echo -e " - $p_info Running post-install..." && ! shoppepkg_postinstall && echo -e "$p_warn Post-install script failed, but package's files were already copied! It is reccomended to reinstall the package, and if that doesn't help, contact the package's maintainer." fi - ! cd content && fail "Failed to install $package." - if [[ -z "$custominstalldir" ]]; then - ! $suauth cp -rf . / && fail "Failed to install $package." - else - ! $suauth cp -rf . "$custominstalldir/" && fail "Failed to install $package." - fi - cd "$tmpdir/$package" - [[ -e "$pkginfo/$package" ]] && rm -rf "${pkginfo:?}/${package:?}" - mkdir "$pkginfo/$package" - shopt -s globstar - [[ -e "$pkginfo/$package/content" ]] && rm "$pkginfo/$package/content" - for file in "$tmpdir/$package/content"/**; do - [[ "$custominstalldir" ]] && $suauth ln -s "$file" "${file/$PWD\/content/}" - # This doesn't include directories that are made by the package, - # but that's still better than adding the entire / directory. - [[ -f "$file" ]] && echo "${file/$PWD\/content/}" >> "$pkginfo/$package/content" - done - shopt -u globstar - type -t shoppepkg_postinstall &>/dev/null && echo -e " - $p_info Running post-install..." && ! shoppepkg_postinstall && echo -e "$p_warn Post-install script failed, but package's files were already copied! It is reccomended to reinstall the package, and if that doesn't help, contact the package's maintainer." if grep "^$package " "$pkglist" &>/dev/null; then sed "/^$package\ /d" "$pkglist" > "${pkglist}-tmp" mv "${pkglist}-tmp" "$pkglist" @@ -584,6 +587,11 @@ shoppe_install() { [[ -z "$pm" ]] && command -v "$package" &>/dev/null && echo -e "$p_info Package $package is already installed, skipping..." && tocheck="${tocheck/$package/}" && continue pkg_fetch source "$tmpdir/$package/shoppepkg" &>/dev/null + if [[ "$group" ]]; then + [[ "$group" ]] && tocheck="$group $tocheck" + tocheck="${tocheck/$package/}" + continue + fi [[ "$package" == *"-git" ]] && [[ "$forcebuild" != "true" ]] && [[ "$nobuild" != "true" ]] && echo -e "$p_info $package will be built manually." && echo "nobuild='false'" >> "$tmpdir/$package/shoppepkg" && nobuild=false if [[ "$force" != "true" ]]; then for conflictpkg in $conflicts $provides; do @@ -633,10 +641,10 @@ shoppe_install() { echo -e "$p_info Installing $package..." let currentpkg++ ! pkg_install && fail "Failed to install $package." - if [[ "$optdepends" ]] && [[ -e "$tmpdir/$package/optdepends" ]]; then + if [[ "$optdepends" ]]; then echo -e "$p_info Optional dependencies:" for dep in $optdepends; do - if grep "^$dep " "$tmpdir/$package/optdepends" &>/dev/null; then + if [[ -e "$tmpdir/$package/optdepends" ]] && grep "^$dep " "$tmpdir/$package/optdepends" &>/dev/null; then if grep "^$dep$" "$pkglist" &>/dev/null || grep "^$dep$" "$pkglist.frontend" &>/dev/null; then echo "$(grep ^$dep $tmpdir/$package/optdepends) [Installed]" else From dd0ff49022bae6c486e76ee1309f456f1e8a088c Mon Sep 17 00:00:00 2001 From: knuxify Date: Mon, 21 Oct 2019 21:31:53 +0200 Subject: [PATCH 03/14] shoppe: NEW: Add --skip-frontend-query switch --- shoppe | 12 ++++++++++++ shoppe.8 | 10 +++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/shoppe b/shoppe index e416577..93e3702 100755 --- a/shoppe +++ b/shoppe @@ -130,6 +130,9 @@ Options: --skip-errors Do not exit when errors occur. Not reccomended. + + --skip-frontend-query + Automatically assume all packages are available from the frontend. " exit 0 } @@ -310,6 +313,10 @@ pkg_fetch_content() { # Package helper functions +donothing() { + return 0 +} + pkg_cleanup() { # This function cleans up after a shoppe package. # Use this when you're running a loop that sources multiple shoppepkgs. @@ -554,6 +561,10 @@ frontend_init() { frontend_upgrade="$frontend_upgrade $frontend_noconfirm" fi fi + if [[ "$skipfrontendquery" == "true" ]]; then + echo -e "$p_warn The --skip-frontend-query switch was passed. Shoppe will automatically assume that all packages are available in the frontend." + frontend_query="donothing" + fi } frontend_harvest() { @@ -898,6 +909,7 @@ for switch in $switches; do case $switch in '+skipfrontend'|'+sf'|'--skip-frontend'|'-s') skipfrontend="true";; '--skip-frontend-for-chosen-packages'|'-c') skipfrontendforchosenpkgs="true";; + '--skip-frontend-query') skipfrontendquery="true";; '+skiperrors'|'+se'|'--skip-errors') skiperrors="true";; '+noconfirm'|'+nc'|'--noconfirm'|'-y') noconfirm="true";; '+forcebuild'|'+fb'|'--forcebuild'|'-b') nobuild="false"; forcebuild="true";; diff --git a/shoppe.8 b/shoppe.8 index b74ffa4..ddc823c 100644 --- a/shoppe.8 +++ b/shoppe.8 @@ -1,7 +1,7 @@ -.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.10. -.TH SHOPPE "1" "September 2019" "shoppe 1.2.2" "User Commands" +.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.11. +.TH SHOPPE "1" "October 2019" "shoppe 1.3.0" "User Commands" .SH NAME -shoppe \- manual page for shoppe 1.2.2 +shoppe \- manual page for shoppe 1.3.0 .SH SYNOPSIS .B shoppe \fI\,function \/\fR[\fI\,options\/\fR] @@ -95,6 +95,10 @@ Creates a package. \fB\-\-skip\-errors\fR .IP Do not exit when errors occur. Not reccomended. +.HP +\fB\-\-skip\-frontend\-query\fR +.IP +Automatically assume all packages are available from the frontend. .SH "SEE ALSO" The full documentation for .B shoppe From 5b3a921ec79caadff0bd893bda25e4153d5239c2 Mon Sep 17 00:00:00 2001 From: knuxify Date: Sun, 27 Oct 2019 18:30:17 +0100 Subject: [PATCH 04/14] SHOPPE: FIX: Fix get_source function breaking with archives --- shoppe | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/shoppe b/shoppe index 93e3702..89f7b1d 100755 --- a/shoppe +++ b/shoppe @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/bash -x # shellcheck disable=SC1090,SC2001,SC1091,SC2219 ## ## shoppe - a portable package manager that integrates with your current package manager @@ -186,7 +186,7 @@ httpfetch_init() { fi } httpfetch() { - if [[ "$httpfetch" == "curl" ]]; then curlable="$(echo $* | sed 's/\ -O\ /\ -o\ /g')"; curl --progress-bar $curlable && return 0 || return 1; + if [[ "$httpfetch" == "curl" ]]; then curlable="$(echo $* | sed 's/\ -O\ /\ --output\ /g')"; curl -L --progress-bar $curlable && return 0 || return 1; elif [[ "$httpfetch" == "wget" ]]; then wget $* && return 0 || return 1; else return 1; fi @@ -209,11 +209,11 @@ get_source() { case $sourcetype in git) if [[ "$tag" ]]; then git clone --branch "$tag" "$source" "source"; else git clone "$source" "source"; fi if [[ "$commit" ]]; then cd source; git checkout "$commit"; cd ..; fi;; - tar) httpfetch "$source"; mkdir source; tar xvf ./* -C source;; - targz) httpfetch "$source"; mkdir source; tar xzf ./* -C source;; - #gz) httpfetch "$source"; gunzip ./*;; - tarxz) httpfetch "$source"; mkdir source; tar xJf ./* -C source;; - zip) httpfetch "$source"; mkdir source; unzip ./* -d source;; + tar) httpfetch "$source" -O "$(basename $source)"; mkdir source; tar xvf "$(basename $source)" -C source;; + targz) httpfetch "$source" -O "$(basename $source)"; mkdir source; tar xzf "$(basename $source)" -C source;; + #gz) httpfetch "$source" -O "$(basename $source)"; gunzip "$(basename $source)";; + tarxz) httpfetch "$source" -O "$(basename $source)"; mkdir source; tar xJf "$(basename $source)" -C source;; + zip) httpfetch "$source" -O "$(basename $source)"; mkdir source; unzip "$(basename $source)" -d source;; esac } From 177a436b6ae025dbf113f573db6a2ea9ffa27d81 Mon Sep 17 00:00:00 2001 From: knuxify Date: Sun, 27 Oct 2019 19:34:54 +0100 Subject: [PATCH 05/14] SHOPPE: FIX: Fix pkg_fetch function trying to fetch package that can't be found if pkg_fetch had been run before --- shoppe | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/shoppe b/shoppe index 89f7b1d..efeceea 100755 --- a/shoppe +++ b/shoppe @@ -53,6 +53,7 @@ skiperrors="false" if [[ "$*" != "install shoppe"* ]] && ! grep '^shoppe ' "$pkglist" &>/dev/null && ! grep '^shoppe-mc ' "$pkglist" &>/dev/null && ! grep '^shoppe-git ' "$pkglist" &>/dev/null; then echo "shoppe 0 $version" >> "$pkglist" fi +[[ ! -e "$deplist" ]] && touch "$deplist" ## Help (--help) shoppe_help() { echo "\ Usage: shoppe function [options] @@ -222,6 +223,7 @@ pkg_fetch() { # It is not meant to be called with multiple packages. # Usage: package="packagetofetch" pkg_fetch # Usage example: use in 'for' loops + unset reposwithpkg current_uptodate="false" success="0" repoID=0 @@ -239,7 +241,6 @@ pkg_fetch() { fi fi [[ "$command" != "shoppe_upgrade" ]] && [[ -f "$package" ]] && [[ "$package" != *".tar.gz" ]] && [[ "$package" != "shoppe" ]] && grep "pkgname=" "$package" && echo "nobuild='false'" >> "$package" && mkdir "$tmpdir/$package" && cp "$package" "$tmpdir/$package/shoppepkg" && package="$(basename $package)" && return 0 - [[ ! -e "$tmpdir/$package" ]] && mkdir "$tmpdir/$package" while IFS="" read -r repo || [[ -n "$repo" ]]; do let repoID++ if grep "^$package " "$configdir/repodata/$repoID" &>/dev/null; then @@ -248,6 +249,7 @@ pkg_fetch() { done < "$repolist" reposwithpkg=$(echo "$reposwithpkg" | sed -e 's/^[ \t]*//') [[ -z "$reposwithpkg" ]] && fail "Could not find package $package. Check if your spelling is correct or add a repository that contains this package." + [[ ! -e "$tmpdir/$package" ]] && mkdir "$tmpdir/$package" [[ "$command" != "shoppe_info" ]] && bestline=$(grep "^$package " "$pkglist") [[ -z "$bestline" ]] && bestline="$package 0 0" originalline="$bestline" @@ -287,6 +289,7 @@ pkg_fetch() { *) echo -e "$p_debug Repo data file for id $repo does not contain repository path! Have you been tampering with the file? Run shoppe update to fix this.";; esac fi + [[ ! -e "$tmpdir/$package/shoppepkg" ]] && [[ -z "$(cat $tmpdir/$package/shoppepkg)" ]] && success=0 if [[ "$success" == "1" ]]; then return 0; else return 1; fi } @@ -596,7 +599,7 @@ shoppe_install() { [[ "$skipfrontendforchosenpkgs" == "true" ]] && [[ "$packages" == *"$package"* ]] && currentskipfrontend="true" && unset pm [[ "$pm" ]] && $frontend_query ^$package$ &>/dev/null && tofrontend="$tofrontend $package" && tocheck="${tocheck/$package/}" && continue [[ -z "$pm" ]] && command -v "$package" &>/dev/null && echo -e "$p_info Package $package is already installed, skipping..." && tocheck="${tocheck/$package/}" && continue - pkg_fetch + pkg_fetch || fail "Package $package not found." source "$tmpdir/$package/shoppepkg" &>/dev/null if [[ "$group" ]]; then [[ "$group" ]] && tocheck="$group $tocheck" From b7d567492a5b2820587817912d66390a717a6bfa Mon Sep 17 00:00:00 2001 From: knuxify Date: Sun, 27 Oct 2019 19:35:39 +0100 Subject: [PATCH 06/14] META: fix shebang skip ci --- shoppe | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shoppe b/shoppe index efeceea..b8786e0 100755 --- a/shoppe +++ b/shoppe @@ -1,4 +1,4 @@ -#!/usr/bin/bash -x +#!/usr/bin/env bash # shellcheck disable=SC1090,SC2001,SC1091,SC2219 ## ## shoppe - a portable package manager that integrates with your current package manager From af4900664f0659497f8113508cddb4da7fbb8ccd Mon Sep 17 00:00:00 2001 From: knuxify Date: Sun, 27 Oct 2019 19:53:27 +0100 Subject: [PATCH 07/14] SHOPPE: Replace donothing() with true --- shoppe | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/shoppe b/shoppe index b8786e0..f15e648 100755 --- a/shoppe +++ b/shoppe @@ -316,10 +316,6 @@ pkg_fetch_content() { # Package helper functions -donothing() { - return 0 -} - pkg_cleanup() { # This function cleans up after a shoppe package. # Use this when you're running a loop that sources multiple shoppepkgs. @@ -566,7 +562,7 @@ frontend_init() { fi if [[ "$skipfrontendquery" == "true" ]]; then echo -e "$p_warn The --skip-frontend-query switch was passed. Shoppe will automatically assume that all packages are available in the frontend." - frontend_query="donothing" + frontend_query="true" fi } From 790f675f1fd0eb058642cfba76bdfb732284413f Mon Sep 17 00:00:00 2001 From: knuxify Date: Sun, 27 Oct 2019 20:55:52 +0100 Subject: [PATCH 08/14] SHOPPE: FIX: Fix archives not being created properly with packagemake --- shoppe | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/shoppe b/shoppe index f15e648..5dc5f11 100755 --- a/shoppe +++ b/shoppe @@ -670,15 +670,14 @@ shoppe_install() { done fi if [[ "$packagemake" == "true" ]]; then - cd "$tmpdir/$package/content" - tar -czf content-$arch.tar.gz . + mkdir "$tmpdir/$package/topackage" + cd "$tmpdir/$package/topackage" + tar -czf "content-$arch.tar.gz" -C "$tmpdir/$package/content" . sed "/content\_${arch}\_checksum/d" "$tmpdir/$package/shoppepkg" > "$tmpdir/$package/shoppepkg.tmp" [[ "$pkgrel" != "rolling" ]] && sed "/pkgrel/d" "$tmpdir/$package/shoppepkg" > "$tmpdir/$package/shoppepkg.tmp" mv "$tmpdir/$package/shoppepkg.tmp" "$tmpdir/$package/shoppepkg" echo "content_${arch}_checksum='$(sha512sum content-$arch.tar.gz)'" >> "$tmpdir/$package/shoppepkg" [[ "$pkgrel" != "rolling" ]] && echo "pkgrel='$pkgrel'" >> "$tmpdir/$package/shoppepkg" - mkdir "$tmpdir/$package/topackage" - mv content-$arch.tar.gz "$tmpdir/$package/topackage" mv "$tmpdir/$package/shoppepkg" "$tmpdir/$package/topackage" [[ -e "$tmpdir/$package/optdepends" ]] && mv "$tmpdir/$package/optdepends" "$tmpdir/$package/$topackage" tar -czf "$HOME/$package.tar.gz" -C "$tmpdir/$package/topackage" . From 0bea4dc8b1127a677ac62b0b0d4e2e07a9df115e Mon Sep 17 00:00:00 2001 From: knuxify Date: Sun, 27 Oct 2019 20:56:18 +0100 Subject: [PATCH 09/14] SHOPPE: Make tar extraction not verbose --- shoppe | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shoppe b/shoppe index 5dc5f11..cbbb6cb 100755 --- a/shoppe +++ b/shoppe @@ -210,7 +210,7 @@ get_source() { case $sourcetype in git) if [[ "$tag" ]]; then git clone --branch "$tag" "$source" "source"; else git clone "$source" "source"; fi if [[ "$commit" ]]; then cd source; git checkout "$commit"; cd ..; fi;; - tar) httpfetch "$source" -O "$(basename $source)"; mkdir source; tar xvf "$(basename $source)" -C source;; + tar) httpfetch "$source" -O "$(basename $source)"; mkdir source; tar xf "$(basename $source)" -C source;; targz) httpfetch "$source" -O "$(basename $source)"; mkdir source; tar xzf "$(basename $source)" -C source;; #gz) httpfetch "$source" -O "$(basename $source)"; gunzip "$(basename $source)";; tarxz) httpfetch "$source" -O "$(basename $source)"; mkdir source; tar xJf "$(basename $source)" -C source;; From c3da94d3de8c01dad449d1fcf5dcee2fa82c3d5e Mon Sep 17 00:00:00 2001 From: knuxify Date: Sun, 27 Oct 2019 21:15:48 +0100 Subject: [PATCH 10/14] SHOPPE: NEW: Package alternative lists --- docs/pkg-alternative-lists.md | 19 +++++++++++++++++++ shoppe | 11 +++++++++++ 2 files changed, 30 insertions(+) create mode 100644 docs/pkg-alternative-lists.md diff --git a/docs/pkg-alternative-lists.md b/docs/pkg-alternative-lists.md new file mode 100644 index 0000000..9458b9f --- /dev/null +++ b/docs/pkg-alternative-lists.md @@ -0,0 +1,19 @@ +# Package alternative lists + +Package alternative lists are files that contain alternative names for certain packages. + +When a package is named differently in one distro, and differently in another, a package alternative list that is specific to each package manager can solve this issue. + +## Creating a package alternative list + +Package manager specific lists use the commonpm variable (see [[Package manager support]](package-manager-support.md)) as their name, for example the alternative list for apt will be called ``apt.altlist``. + +The list follows the following format: + +``` +pkgname pkgalt +``` + +where each package alternative is separated by a newline. + +You can also place your own custom alternative rules in the ``custom.altlist`` file. diff --git a/shoppe b/shoppe index cbbb6cb..06bcd30 100755 --- a/shoppe +++ b/shoppe @@ -54,6 +54,7 @@ if [[ "$*" != "install shoppe"* ]] && ! grep '^shoppe ' "$pkglist" &>/dev/null & echo "shoppe 0 $version" >> "$pkglist" fi [[ ! -e "$deplist" ]] && touch "$deplist" + ## Help (--help) shoppe_help() { echo "\ Usage: shoppe function [options] @@ -593,6 +594,16 @@ shoppe_install() { pkg_cleanup success="0" [[ "$skipfrontendforchosenpkgs" == "true" ]] && [[ "$packages" == *"$package"* ]] && currentskipfrontend="true" && unset pm + if [[ -e "$configdir/$pm.altlist" ]]; then + unset alt + alt=$(grep "$package" "$configdir/$pm.altlist" 2>/dev/null) + [[ ! -z "$alt" ]] && package=$(echo "$alt" | awk '{print $2}') + fi + if [[ -e "$configdir/custom.altlist" ]]; then + unset alt + alt=$(grep "$package" "$configdir/custom.altlist" 2>/dev/null) + [[ ! -z "$alt" ]] && package=$(echo "$alt" | awk '{print $2}') + fi [[ "$pm" ]] && $frontend_query ^$package$ &>/dev/null && tofrontend="$tofrontend $package" && tocheck="${tocheck/$package/}" && continue [[ -z "$pm" ]] && command -v "$package" &>/dev/null && echo -e "$p_info Package $package is already installed, skipping..." && tocheck="${tocheck/$package/}" && continue pkg_fetch || fail "Package $package not found." From d59ac261f46d48524bbbb484ed5750fa76b530a9 Mon Sep 17 00:00:00 2001 From: knuxify Date: Sun, 27 Oct 2019 21:21:04 +0100 Subject: [PATCH 11/14] SHOPPE: NEW: Add commonpm variable --- docs/frontend-support.md | 16 ++++++++-------- docs/pkg-alternative-lists.md | 2 +- shoppe | 13 +++++++++++-- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/docs/frontend-support.md b/docs/frontend-support.md index 9794b7a..8ef05a1 100644 --- a/docs/frontend-support.md +++ b/docs/frontend-support.md @@ -1,10 +1,10 @@ # Package manager support -| Package manager | Install | Remove | Update | Upgrade | Query | List all | \-\-noconfirm switch | -| --- | --- | --- | --- | --- | --- | --- | --- | -| apt/apt-get/pkg (Debian-based) | [X] | [X] | [X] | [X] | [x] | [x] | [x] | -| yum/dnf (Fedora, CentOS, RedHat) | [X] | [X] | [X] | [X] | [x] | [x] | [x] | -| pacman (Arch Linux) | [X] | [X] | [X] | [X] | [X] | [X] | [x] | -| zypper (openSUSE and related) | [X] | [X] | [X] | [X] | [X] | [X] | [x] | -| apk (Alpine Linux, postmarketOS) | [X] | [X] | [X] | [X] | [X] | [X] | [ ] | -| eopkg (Solus) | [X] | [X] | [X] | [X] | [X] | [X] | [ ] | +| Package manager | commonpm | Install | Remove | Update | Upgrade | Query | List all | \-\-noconfirm switch | +| --- | --- | --- | --- | --- | --- | --- | --- | --- | +| apt/apt-get/pkg (Debian-based) | apt | [X] | [X] | [X] | [X] | [x] | [x] | [x] | +| yum/dnf (Fedora, CentOS, RedHat) | dnf | [X] | [X] | [X] | [X] | [x] | [x] | [x] | +| pacman/yay/pacaur (Arch Linux) | pacman | [X] | [X] | [X] | [X] | [X] | [X] | [x] | +| zypper (openSUSE and related) | zypper | [X] | [X] | [X] | [X] | [X] | [X] | [x] | +| apk (Alpine Linux, postmarketOS) | apk | [X] | [X] | [X] | [X] | [X] | [X] | [ ] | +| eopkg (Solus) | eopkg | [X] | [X] | [X] | [X] | [X] | [X] | [ ] | diff --git a/docs/pkg-alternative-lists.md b/docs/pkg-alternative-lists.md index 9458b9f..e386951 100644 --- a/docs/pkg-alternative-lists.md +++ b/docs/pkg-alternative-lists.md @@ -6,7 +6,7 @@ When a package is named differently in one distro, and differently in another, a ## Creating a package alternative list -Package manager specific lists use the commonpm variable (see [[Package manager support]](package-manager-support.md)) as their name, for example the alternative list for apt will be called ``apt.altlist``. +Package manager specific lists use the commonpm variable (see [[Package manager support]](frontend-support.md)) as their name, for example the alternative list for apt will be called ``apt.altlist``. The list follows the following format: diff --git a/shoppe b/shoppe index 06bcd30..ae9b94c 100755 --- a/shoppe +++ b/shoppe @@ -470,6 +470,7 @@ frontend_init() { nopmfound) # No package manager found pm="";; pkg) # pkg (Termux, Debian-based with custom frontend) + commonpm="apt" frontend_install="$pm install" frontend_remove="$pm remove" frontend_update="$pm update" @@ -479,6 +480,7 @@ frontend_init() { frontend_noconfirm="--yes --force-yes" ;; apt|apt-get) # apt/apt-get (Debian-based) + commonpm="apt" frontend_install="$suauth $pm install" frontend_remove="$suauth $pm remove" frontend_update="$suauth $pm update" @@ -488,6 +490,7 @@ frontend_init() { frontend_noconfirm="--yes --force-yes" ;; dnf) # dnf (Fedora) + commonpm="dnf" frontend_install="$suauth $pm install" frontend_remove="$suauth $pm remove" frontend_update="$suauth $pm check-update 1>/dev/null" @@ -497,6 +500,7 @@ frontend_init() { frontend_noconfirm="-y" ;; yum) # yum (Fedora, CentOS, Red Hat and related) + commonpm="dnf" frontend_install="$suauth $pm install" frontend_remove="$suauth $pm remove" frontend_update="$suauth $pm check-update 1>/dev/null" @@ -506,6 +510,7 @@ frontend_init() { frontend_noconfirm="-y" ;; yay|yaourt|pacaur) # AUR helpers (Arch Linux) + commonpm="pacman" frontend_install="$pm -Sy --needed" frontend_remove="$pm -R" frontend_update="$pm -Sy" @@ -515,6 +520,7 @@ frontend_init() { frontend_noconfirm="--noconfirm" ;; pacman) # pacman (Arch Linux) + commonpm="pacman" frontend_install="$suauth $pm -Sy --needed" frontend_remove="$suauth $pm -R" frontend_update="$suauth $pm -Sy" @@ -524,6 +530,7 @@ frontend_init() { frontend_noconfirm="--noconfirm" ;; zypper) # zypper (openSUSE-based) + commonpm="zypper" frontend_install="$suauth $pm install" frontend_remove="$suauth $pm remove" frontend_update="$suauth dnf clean expire-cache && $suauth dnf check-update" @@ -533,6 +540,7 @@ frontend_init() { frontend_noconfirm="--non-interactive" ;; apk) # apk (Alpine Linux, postmarketOS) + commonpm="apk" frontend_install="$suauth $pm add" frontend_remove="$suauth $pm del" frontend_update="$suauth $pm update" @@ -541,6 +549,7 @@ frontend_init() { frontend_listall="$pm info" # TODO: Fancy sed command that moves the version to the end and revision to the middle (use apk info -v for that) ;; eopkg) # eopkg (Solus) + commonpm="apk" frontend_install="$suauth $pm install" frontend_remove="$suauth $pm remove" frontend_update="$suauth $pm update-repo" @@ -594,9 +603,9 @@ shoppe_install() { pkg_cleanup success="0" [[ "$skipfrontendforchosenpkgs" == "true" ]] && [[ "$packages" == *"$package"* ]] && currentskipfrontend="true" && unset pm - if [[ -e "$configdir/$pm.altlist" ]]; then + if [[ -e "$configdir/$commonpm.altlist" ]]; then unset alt - alt=$(grep "$package" "$configdir/$pm.altlist" 2>/dev/null) + alt=$(grep "$package" "$configdir/$commonpm.altlist" 2>/dev/null) [[ ! -z "$alt" ]] && package=$(echo "$alt" | awk '{print $2}') fi if [[ -e "$configdir/custom.altlist" ]]; then From 3d97eac21dbdee9754d3cb0a5bd7491d312d522e Mon Sep 17 00:00:00 2001 From: knuxify Date: Sun, 27 Oct 2019 21:37:09 +0100 Subject: [PATCH 12/14] SHOPPE: FIX: fix endless loop on alt lists --- shoppe | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/shoppe b/shoppe index ae9b94c..ee2dd0c 100755 --- a/shoppe +++ b/shoppe @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/bash -x # shellcheck disable=SC1090,SC2001,SC1091,SC2219 ## ## shoppe - a portable package manager that integrates with your current package manager @@ -603,15 +603,16 @@ shoppe_install() { pkg_cleanup success="0" [[ "$skipfrontendforchosenpkgs" == "true" ]] && [[ "$packages" == *"$package"* ]] && currentskipfrontend="true" && unset pm + unset oldpackage if [[ -e "$configdir/$commonpm.altlist" ]]; then unset alt - alt=$(grep "$package" "$configdir/$commonpm.altlist" 2>/dev/null) - [[ ! -z "$alt" ]] && package=$(echo "$alt" | awk '{print $2}') + alt=$(grep "^$package " "$configdir/$commonpm.altlist") + [[ ! -z "$alt" ]] && oldpackage="$package" && package=$(echo "$alt" | awk '{print $2}') fi if [[ -e "$configdir/custom.altlist" ]]; then unset alt - alt=$(grep "$package" "$configdir/custom.altlist" 2>/dev/null) - [[ ! -z "$alt" ]] && package=$(echo "$alt" | awk '{print $2}') + alt=$(grep "^$package " "$configdir/custom.altlist") + [[ ! -z "$alt" ]] && oldpackage="$package" && package=$(echo "$alt" | awk '{print $2}') fi [[ "$pm" ]] && $frontend_query ^$package$ &>/dev/null && tofrontend="$tofrontend $package" && tocheck="${tocheck/$package/}" && continue [[ -z "$pm" ]] && command -v "$package" &>/dev/null && echo -e "$p_info Package $package is already installed, skipping..." && tocheck="${tocheck/$package/}" && continue @@ -635,24 +636,40 @@ shoppe_install() { else echo -e "$p_info Package $package is already installed, skipping..." fi - tocheck="${tocheck/$package/}" + if [[ "$oldpackage" ]]; then + tocheck="${tocheck/$oldpackage/}" + else + tocheck="${tocheck/$package/}" + fi continue fi if [[ "$pm" ]] && grep "^$package $pkgrel $pkgver" "$pkglist.frontend" &>/dev/null; then echo -e "$p_info Package $package is already installed via frontend, skipping..." - tocheck="${tocheck/$package/}" - continue + if [[ "$oldpackage" ]]; then + tocheck="${tocheck/$oldpackage/}" + else + tocheck="${tocheck/$package/}" + fi + continue fi if grep "$package" "$providedpkglist" &>/dev/null; then echo -e "$p_info Package $package was already provided by another package. Skipping..." - tocheck="${tocheck/$package/}" + if [[ "$oldpackage" ]]; then + tocheck="${tocheck/$oldpackage/}" + else + tocheck="${tocheck/$package/}" + fi continue fi fi toinstall="$toinstall $package" [[ "$depends" ]] && tocheck="$tocheck $depends" [[ "$nobuild" == "false" ]] && [[ "$makedepends" ]] && tocheck="$tocheck $makedepends" - tocheck="${tocheck/$package/}" + if [[ "$oldpackage" ]]; then + tocheck="${tocheck/$oldpackage/}" + else + tocheck="${tocheck/$package/}" + fi [[ "$currentskipfrontend" == "true" ]] && pm="$oldpm" done done From 9cc44ba22d04fa72ef7f71324428e78a2c9b67ee Mon Sep 17 00:00:00 2001 From: knuxify Date: Sun, 27 Oct 2019 22:30:01 +0100 Subject: [PATCH 13/14] SHOPPE: FIX: Fix loops with alt lists, for real. --- shoppe | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/shoppe b/shoppe index ee2dd0c..657f8f9 100755 --- a/shoppe +++ b/shoppe @@ -1,4 +1,4 @@ -#!/usr/bin/bash -x +#!/usr/bin/env bash # shellcheck disable=SC1090,SC2001,SC1091,SC2219 ## ## shoppe - a portable package manager that integrates with your current package manager @@ -607,15 +607,23 @@ shoppe_install() { if [[ -e "$configdir/$commonpm.altlist" ]]; then unset alt alt=$(grep "^$package " "$configdir/$commonpm.altlist") - [[ ! -z "$alt" ]] && oldpackage="$package" && package=$(echo "$alt" | awk '{print $2}') + [[ "$alt" ]] && oldpackage="$package" && package=$(echo "$alt" | awk '{print $2}') fi if [[ -e "$configdir/custom.altlist" ]]; then unset alt alt=$(grep "^$package " "$configdir/custom.altlist") - [[ ! -z "$alt" ]] && oldpackage="$package" && package=$(echo "$alt" | awk '{print $2}') + [[ "$alt" ]] && oldpackage="$package" && package=$(echo "$alt" | awk '{print $2}') fi - [[ "$pm" ]] && $frontend_query ^$package$ &>/dev/null && tofrontend="$tofrontend $package" && tocheck="${tocheck/$package/}" && continue - [[ -z "$pm" ]] && command -v "$package" &>/dev/null && echo -e "$p_info Package $package is already installed, skipping..." && tocheck="${tocheck/$package/}" && continue + if [[ "$pm" ]] && $frontend_query ^$package$ &>/dev/null; then + tofrontend="$tofrontend $package" + if [[ "$oldpackage" ]]; then + tocheck="${tocheck/$oldpackage/}" + else + tocheck="${tocheck/$package/}" + fi + continue + fi + [[ -z "$pm" ]] && command -v "$package" &>/dev/null && echo -e "$p_info Package $package is already installed, skipping..." && if [[ "$oldpackage" ]]; then tocheck="${tocheck/$oldpackage/}"; else tocheck="${tocheck/$package/}"; fi && continue pkg_fetch || fail "Package $package not found." source "$tmpdir/$package/shoppepkg" &>/dev/null if [[ "$group" ]]; then From c045c7ed3d61f78671c7c32d3a463189870fd0fb Mon Sep 17 00:00:00 2001 From: knuxify Date: Sun, 27 Oct 2019 22:38:41 +0100 Subject: [PATCH 14/14] SHOPPE: FIX: Fix empty strings returning no even when the default option is yes in yesno prompts --- shoppe | 1 + 1 file changed, 1 insertion(+) diff --git a/shoppe b/shoppe index 657f8f9..7f2441f 100755 --- a/shoppe +++ b/shoppe @@ -169,6 +169,7 @@ yesno() { choice="$1" else read -p "$yesnotxt $yesnochoice " -re choice + [[ -z "$choice" ]] && choice="$1" fi if [[ "$choice" == "Y" || "$choice" == "y" ]]; then choice="yes"; else choice="no"; fi }