Skip to content
This repository has been archived by the owner on Dec 10, 2021. It is now read-only.

[#TODO] Support more package manager #5

Closed
24 tasks done
NNBnh opened this issue Mar 3, 2021 · 16 comments · Fixed by #11 or #12
Closed
24 tasks done

[#TODO] Support more package manager #5

NNBnh opened this issue Mar 3, 2021 · 16 comments · Fixed by #11 or #12
Labels
help wanted Extra attention is needed
Milestone

Comments

@NNBnh
Copy link
Owner

NNBnh commented Mar 3, 2021

Current state:

superb-bootstrap/sbb

Lines 47 to 77 in ef20588

APK_MARK='APK'; APK_PM='apk' ; APK_COMMAND="$PERMISSION_COMMAND $APT_PM add"
APT_MARK='APT'; APT_PM='apt' ; APT_COMMAND="$PERMISSION_COMMAND $APT_PM install --assume-yes"
DNF_MARK='DNF'; DNF_PM='dnf' ; DNF_COMMAND="$PERMISSION_COMMAND $DNF_PM install --assumeyes"
EOPKG_MARK='EOP'; EOPKG_PM='eopkg' ; EOPKG_COMMAND="$PERMISSION_COMMAND $EOPKG_PM install --yes-all"
Mports_MARK='MPT'; Mports_PM='mports' ; Mports_COMMAND="$PERMISSION_COMMAND $Mports_PM install"
OpenBSD_MARK='OBP'; OpenBSD_PM='pkg_add' ; OpenBSD_COMMAND="$PERMISSION_COMMAND $OpenBSD_PM -I"
Pacman_MARK='PAC'; Pacman_PM='pacman' ; Pacman_COMMAND="$PERMISSION_COMMAND $Pacman_PM --sync --noconfirm --needed"
Portage_MARK='PTG'; Portage_PM='emerge' ; Portage_COMMAND="$PERMISSION_COMMAND $Portage_PM"
PKGIN_MARK='PIN'; PKGIN_PM='pkgin' ; PKGIN_COMMAND="$PERMISSION_COMMAND $PKGIN_PM install -y"
PKGNG_MARK='PNG'; PKGNG_PM='pkg' ; PKGNG_COMMAND="$PERMISSION_COMMAND $PKGNG_PM install -y"
Slackpkg_MARK='SLK'; Slackpkg_PM='slackpkg' ; Slackpkg_COMMAND="$PERMISSION_COMMAND $Slackpkg_PM install"
Termux_MARK='TMP'; Termux_PM='pkg' ; Termux_COMMAND="$Termux_PM install --assume-yes"
URPMI_MARK='URP'; URPMI_PM='urpmi' ; URPMI_COMMAND="$PERMISSION_COMMAND $URPMI_PM --force"
XBPS_MARK='XBP'; XBPS_PM='xbps-install'; XBPS_COMMAND="$PERMISSION_COMMAND $XBPS_PM --yes"
YUM_MARK='YUM'; YUM_PM='yum' ; YUM_COMMAND="$PERMISSION_COMMAND $YUM_PM install --assumeyes"
Zypper_MARK='ZPR'; Zypper_PM='zypper' ; Zypper_COMMAND="$PERMISSION_COMMAND $Zypper_PM --non-interactive install"
AUR_MARK='AUR'; AUR_PM='paru' ; AUR_COMMAND="$AUR_PM --sync --skipreview --useask --noconfirm --needed"
Flatpak_MARK='FLA'; Flatpak_PM='flatpak' ; Flatpak_COMMAND="$PERMISSION_COMMAND $Flatpak_PM install"
Homebrew_MARK='HBR'; Homebrew_PM='brew' ; Homebrew_COMMAND="$Homebrew_PM install"
MacPorts_MARK='MCP'; MacPorts_PM='port' ; MacPorts_COMMAND="$PERMISSION_COMMAND $MacPorts_PM install"
MAS_MARK='MAS'; MAS_PM='mas' ; MAS_COMMAND="$MAS_PM install"
Nix_MARK='NIX'; Nix_PM='nix-env' ; Nix_COMMAND="NIXPKGS_ALLOW_UNFREE='1' $Nix_PM --install --attr"
SBO_MARK='SBO'; SBO_PM='sbopkg' ; SBO_COMMAND="$PERMISSION_COMMAND $SBO_PM -ifq"
Snap_MARK='SNA'; Snap_PM='snap' ; Snap_COMMAND="$PERMISSION_COMMAND $Snap_PM install"
Basher_MARK='BSR'; Basher_PM='sbb_basher' ; Basher_COMMAND="$Basher_PM"
BPKG_MARK='BPK'; BPKG_PM='sbb_bpkg' ; BPKG_COMMAND="$BPKG_PM"
NPM_MARK='NPM'; NPM_PM='npm' ; NPM_COMMAND="$PERMISSION_COMMAND $NPM_PM install --global"
PIP_MARK='PIP'; PIP_PM='pip' ; PIP_COMMAND="$PIP_PM install --user"
Yarn_MARK='YRN'; Yarn_PM='yarn' ; Yarn_COMMAND="$Yarn_PM global add"

#TODO

You can help us by summit:

  • A mark (3 letter)
  • A package manager tool
  • A full command with flags to install packages
  • A setup function
  • NOTE:
    • The less user input needed the better, you should add no-confirm flag like --noconfirm, --non-interactive, --assume-yes, ... to the commands
    • For more Clarity, use full flag instead of short flag (E.g: use --sync over -S)

Example:

Pacman_MARK='PAC'

Pacman_PM='pacman'

Pacman_COMMAND="$PERMISSION_COMMAND $Pacman_PM --sync --noconfirm --needed"

superbbootstrap_Pacman() {
	sudo pacman --sync --sysupgrade --refresh --noconfirm --needed
}

NOTE: $PERMISSION_COMMAND is default to sudo on Linux and doas on BSD

@NNBnh NNBnh added the help wanted Extra attention is needed label Mar 3, 2021
@NNBnh NNBnh added this to the 1.6.0 milestone Mar 3, 2021
@xfzv
Copy link

xfzv commented Mar 3, 2021

I'm not a Gentoo expert by any means but here's my attempt for Emerge (Gentoo)

Emerge_MARK='EMG';      Emerge_COMMAND='sudo emerge --sync && sudo emerge -v'

superbbootstrap_Emerge() {
    sudo emerge --sync
    sudo emerge -vuND --with-bdeps=y @world
}

@xfzv
Copy link

xfzv commented Mar 3, 2021

Zypper (openSUSE)

Zypper_MARK='ZPR';        Zypper_COMMAND='sudo zypper refresh && sudo zypper -n install'

superbbootstrap_Zypper() {
    sudo zypper -n update       # or dist-upgrade instead? maybe overkill
}

@xfzv
Copy link

xfzv commented Mar 3, 2021

Just curious, why do:

  • Pacman_COMMAND
  • XBPS_COMMAND
  • AUR_COMMAND

include a sync/refresh option (respectively --refresh ; --sync and -Sy) whereas the others just perform install without any sync/refresh operation?

superb-bootstrap/setup

Lines 101 to 107 in 5b8a7f2

APT_MARK='APT'; APT_COMMAND='sudo apt install --assume-yes'
Pacman_MARK='PAC'; Pacman_COMMAND='sudo pacman --sync --refresh --noconfirm --needed'
XBPS_MARK='XBP'; XBPS_COMMAND='sudo xbps-install --sync --yes'
AUR_MARK='AUR'; AUR_COMMAND='paru -Sy --nodiffmenu --save --noconfirm'
Flatpak_MARK='FLA'; Flatpak_COMMAND='sudo flatpak install'
Snap_MARK='SNA'; Snap_COMMAND='sudo snap install'
Homebrew_MARK='HBR'; Homebrew_COMMAND='brew install'


The superbbootstrap_$package_manager functions, which are run before, all perform a sync/refresh too. Isn't it redundant to sync/refresh a second time?

superb-bootstrap/setup

Lines 159 to 160 in 5b8a7f2

superbbootstrap_APT() {
sudo apt update --assume-yes

superb-bootstrap/setup

Lines 164 to 165 in 5b8a7f2

superbbootstrap_Pacman() {
sudo pacman --sync --sysupgrade --refresh --noconfirm --needed

superb-bootstrap/setup

Lines 168 to 169 in 5b8a7f2

superbbootstrap_XBPS() {
sudo xbps-install --sync --yes --update

superb-bootstrap/setup

Lines 174 to 175 in 5b8a7f2

superbbootstrap_AUR() {
sudo pacman --sync --refresh --noconfirm --needed git base-devel

superb-bootstrap/setup

Lines 182 to 186 in 5b8a7f2

superbbootstrap_Flatpak() {
case "$packagemanager_main" in
'Pacman') sudo pacman --sync --refresh --noconfirm --needed flatpak ;;
'APT') sudo apt install --assume-yes flatpak gnome-software-plugin-flatpak ;;
'XBPS') sudo xbps-install --sync --yes flatpak ;;

superb-bootstrap/setup

Lines 192 to 194 in 5b8a7f2

superbbootstrap_Snap() {
if [ $packagemanager_main = 'Pacman' ]; then
sudo pacman --sync --refresh --noconfirm --needed git

If so, maybe this should now be:

Value Old New
Pacman_COMMAND sudo pacman --sync --refresh --noconfirm --needed sudo pacman --sync --noconfirm --needed
XBPS_COMMAND sudo xbps-install --sync --yes sudo xbps-install --yes
AUR_COMMAND paru -Sy --nodiffmenu --save --noconfirm paru --sync --nodiffmenu --save --noconfirm
Emerge_COMMAND sudo emerge --sync && sudo emerge -v sudo emerge -v
Zypper_COMMAND sudo zypper refresh && sudo zypper -n install sudo zypper -n install

@NNBnh NNBnh pinned this issue Mar 4, 2021
@NNBnh
Copy link
Owner Author

NNBnh commented Mar 4, 2021

Zypper (openSUSE)

Zypper_MARK='ZPR';        Zypper_COMMAND='sudo zypper refresh && sudo zypper -n install'

superbbootstrap_Zypper() {
    sudo zypper -n update       # or dist-upgrade instead? maybe overkill
}

I'm not a Gentoo expert by any means but here's my attempt for Emerge (Gentoo)

Emerge_MARK='EMG';      Emerge_COMMAND='sudo emerge --sync && sudo emerge -v'

superbbootstrap_Emerge() {
    sudo emerge --sync
    sudo emerge -vuND --with-bdeps=y @world
}

Thanks, this will be add to SBB 1.5.4 but i will change Gentoo package manager's mark EMG to PTG because "Portage" is the package manager real name, emerge is just a command that come with Portage

https://wiki.gentoo.org/wiki/Portage

@NNBnh
Copy link
Owner Author

NNBnh commented Mar 4, 2021

Just curious, why do:
* Pacman_COMMAND
* XBPS_COMMAND
* AUR_COMMAND

include a sync/refresh option (respectively --refresh ; --sync and -Sy) whereas the others just perform install without any sync/refresh operation?

The superbbootstrap_$package_manager functions, which are run before, all perform a sync/refresh too. Isn't it redundant to sync/refresh a second time?

Yeah... this is kinda redundant, here is the fix taking from your suggestion:

Name Mark PM Command
APT APT apt $PERMISSION_COMMAND $APT_PM install --assume-yes
Pacman PAC pacman $PERMISSION_COMMAND $Pacman_PM --sync --noconfirm --needed
Portage PTG emerge $PERMISSION_COMMAND $Emerge_PM
XBPS XBP xbps-install $PERMISSION_COMMAND $XBPS_PM --yes
Zypper ZPR zypper $PERMISSION_COMMAND $Zypper_PM --non-interactive install
AUR AUR paru $AUR_PM --sync --nodiffmenu --save --noconfirm
Flatpak FLA flatpak $PERMISSION_COMMAND $Flatpak_PM install
Homebrew HBR brew $Homebrew_PM install
Snap SNA snap $PERMISSION_COMMAND $Snap_PM install

btw, do you mind if i add you name to the credits section?

@xfzv
Copy link

xfzv commented Mar 4, 2021

Zypper (openSUSE)

Zypper_MARK='ZPR';        Zypper_COMMAND='sudo zypper refresh && sudo zypper -n install'

superbbootstrap_Zypper() {
    sudo zypper -n update       # or dist-upgrade instead? maybe overkill
}

I'm not a Gentoo expert by any means but here's my attempt for Emerge (Gentoo)

Emerge_MARK='EMG';      Emerge_COMMAND='sudo emerge --sync && sudo emerge -v'

superbbootstrap_Emerge() {
    sudo emerge --sync
    sudo emerge -vuND --with-bdeps=y @world
}

Thanks, this will be add to SBB 1.5.4 but i will change Gentoo package manager's mark EMG to PTG because "Portage" is the package manager real name, emerge is just a command that come with Portage

https://wiki.gentoo.org/wiki/Portage

Indeed, PTG makes more sense.

btw, do you mind if i add you name to the credits section?

No problem!

@arcadellama
Copy link

Slackware has an 'official' package manager and many unofficial third-party managers for Slackbuilds.org, which is similar to the AUR. I went with sbopkg here for the latter as it does dependency resolution with minimal user interaction, as per the gist of this script.

slackpkg_MARK='SLK'; slackpkg_PM='slackpkg' ; slackpkg_COMMAND="$PERMISSION_COMMAND $slackpkg_PM install" sbopkg_MARK='SBO'; sbopkg_PM='sbopkg' ; sbopkg_COMMAND="$PERMISSION_COMMAND $sbopkg_PM -ifq"

superbbootstrap_slackpkg() { $PERMISSION_COMMAND slackpkg update gpg $PERMISSION_COMMAND slackpkg update }

superbbootstrap_sbopkg() { if ! command -v 'sbopkg' >/dev/null; then SLACKWARE_VERSION=$(awk '{print $2}' /etc/slackware-version) SBO_VERSION=$(curl -s https://api.github.com/repos/sbopkg/sbopkg/releases/latest | grep tag_name | awk -F':' '{print substr($2,3,length($2)-4)}') cd $TEMPORARY || exit 1 $PERMISSION_COMMAND wget https://github.com/sbopkg/sbopkg/releases/download/$SBO_VERSION/sbopkg-$SBO_VERSION-noarch-1_wsr.tgz upgradepkg --install-new $TEMPORARY/sbopkg-$SBO_VERSION-noarch-1_wsr.tgz cd $WD || exit 1 $PERMISSION_COMMAND mkdir -p /var/lib/sbopkg/SBo/$SLACKWARE_VERSION /var/lib/sbopkg/queues /var/log/sbopkg /var/cache/sbopkg $PERMISSION_COMMAND sbopkg -rq $PERMISSION_COMMAND sqg -a else printf '%s\n' "sbopkg has been installed" fi }
Add this to subperbbootstrap_Flatpak():
'SBO') $sbopkg_COMMAND flatpak ;;

Also, to my knowledge, there isn't a SlackBuild for snapd (likely due to philosophy and the systemd work-arounds). I would suggest that testing for package manager isn't a fool-proof way to determin if Snap should be in the PACKAGEMANAGER_LIST. I would suggest doing a search by the distro instead, perhaps checking in '/etc/os-release' or similar. This is more important when you get to DNF, which could be Fedora or CentOS 8, etc., etc. Happy to work on that if desired.

@NNBnh NNBnh removed this from the 2.0.0 milestone Mar 8, 2021
@NNBnh
Copy link
Owner Author

NNBnh commented Mar 8, 2021

@arcadellama Awesome, thank you for your contribution, This will be added to SBB 1.6.0.

Do you mind if i add you name to the credits section?

@arcadellama
Copy link

Of course, no problem.

@a4vg
Copy link

a4vg commented Mar 9, 2021

Hello again! I managed to do something for...

I couldn't find a way to install MacPorts entirely through the CLI. It has to be installed through a .pkg installer and I don't know how to get the information to get the name of the .pkg file.

MacPorts_MARK='MCP'
MacPorts_PM='port'
MacPorts_COMMAND="$PERMISSION_COMMAND $MacPorts_PM install"

superbbootstrap_MacPorts() {
  # Install Apple's Command Line Developer Tools (will open a pop-up to confirm)
  xcode-select --install
  
  # Get MACPORT_VERSION (ex.: 2.6.4), OS_VERSION_NUMBER (ex.: 10.15) and OS_VERSION_NAME (ex.: Catalina) somehow
  macports_pkg_filename=MacPorts-$MACPORT_VERSION-$OS_VERSION_NUMBER-$OS_VERSION_NAME.pkg
  curl -O https://github.com/macports/macports-base/releases/latest/download/$macports_pkg_filename
  sudo installer -pkg $macports_pkg_filename -target /
}

MAS can be installed with Homebrew or MacPorts, one of them should be the PACKAGEMANAGER_MAIN on MacOS. The script checks which was installed and uses it. MAS also requires to be signed into the AppStore, but on MacOS 10.13+ you have to sign in manually. I'm not sure on how to proceed if this is the case.

MAS_MARK='MAS'
MAS_PM='mas'
MAS_COMMAND="$MAS_PM install"

superbbootstrap_MAS() {
  if [ ! -x "$(command -v "$MAS_PM")" ]; then

    if [ -x "$(command -v "$Homebrew_PM")" ]; then
      $Homebrew_COMMAND mas
    elif [ -x "$(command -v "$MCP_PM")" ]; then
      $MacPorts_COMMAND mas
    else
      superbbootstrap_Homebrew
      $Homebrew_COMMAND mas
    fi

  else
    printf '%s\n' "MAS has been installed"
  fi

  # Sign in to the AppStore
  if ! (
        mas account &> /dev/null && # verify if user is already signed in
        mas signin --dialog $APPLE_ID # if not, try to sign in with a pop-up
       ) ; then

    # signin command failed. It is disabled on 10.13+, user has to sign in
    # directly from the AppStore
    # (stop execution, skip packages with MAS Mark, wait till the user signs in or something)

  else
    printf '%s\n' "Successfully signed in to the AppStore"
  fi

I dug a little more about brew cask and it seems you can install apps with brew install app-name. The Homebrew website uses the --cask flag (like on these app), but the Homebrew Cask github uses it without the flag. I tried on my Macbook and indeed, it works without the flag. However, it's a good practice to use the flag in case there's a package and a cask app with the same name (like wireshark).

Soo.. here's the script with the flag. I didn't include a HomebrewCask_PM because it's the same as Homebrew and I don't know if it's necessary.

HomebrewCask_MARK='HBC'
HomebrewCask_COMMAND="$Homebrew_PM --cask install"

superbbootstrap_HomebrewCask() {
  if [ ! -x "$(command -v "$Homebrew_PM")" ]; then
    superbbootstrap_Homebrew
  fi
}

There's also an easier way that doesn't need any code change. This brew install --cask app-name is just another way to write brew install homebrew/cask/app-name. So just writing HBR:homebrew/cask/app-name should work I guess.

Finally, Brew bundle just installs the first time you run brew bundle and looks for a Brewfile in the directory. No need to implement that.

Feel free to change the code or rewrite all of it, I'm not very good at bash and it may not be the best code. If you don't own a device with MacOS I'm happy to test it if necessary (as long as I don't have to remove important stuff to reinstall them and set them up again).

@NNBnh
Copy link
Owner Author

NNBnh commented Mar 10, 2021

Thank you @a4vg, your contribution has been added in SBB 1.7.0:

Add supported for:

@weiss-d
Copy link
Contributor

weiss-d commented Apr 1, 2021

pipx is a wonderful tool that installs Python packages just like regular PIP, but does it in isolated Python environment. That way packages and their dependencies don't interfere with system Python and with each other.
Default commands requires no sudo and no user interaction.
It's convenient way to install youtube-dl for example.

pipx_MARK='PIX'

pipx_PM='pipx'

pipx_COMMAND="$pipx_PM install"

superbbootstrap_pipx() {
        python3 -m ensurepip
	python3 -m pip install --user pipx
	python3 -m pipx ensurepath
}

Their repo: https://github.com/pipxproject/pipx

@LoricAndre
Copy link
Contributor

LoricAndre commented Apr 8, 2021

Are pip and npm still open ? I could work on them if that's the case !
EDIT: I added them locally, I could git that and start a PR with another change I made to handle this kind of "auxiliary" package manager better

@NNBnh
Copy link
Owner Author

NNBnh commented Apr 8, 2021

@LoricAndre Yes it is still open and i love to see your work on them ^^

@LoricAndre
Copy link
Contributor

Done with #18

@NNBnh NNBnh added this to the Version 2.0.0 milestone Apr 11, 2021
@weiss-d
Copy link
Contributor

weiss-d commented Apr 25, 2021

Done with #18

Hi, @LoricAndre! There is some problem I mentioned here: #28

This was linked to pull requests May 25, 2021
@NNBnh NNBnh closed this as completed May 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants