From ede298ff50f70143f04abbf735aea3e0075b3819 Mon Sep 17 00:00:00 2001 From: Alex Branham Date: Wed, 25 Apr 2018 14:00:41 -0500 Subject: [PATCH] Add system-packages-ensure Also an alias for system-packages-package-installed-p to executable-find. This is somewhat related to bug #26, since you can now do something clever with if statments: if pack-man=apt, then ensure blah, else if pack-man=pacman, ensure blah-foo. Obviously, there's still work to be done here. --- system-packages.el | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/system-packages.el b/system-packages.el index d425198..6b3f426 100644 --- a/system-packages.el +++ b/system-packages.el @@ -353,6 +353,22 @@ manger." (interactive "sPackage to install: ") (system-packages--run-command 'install pack args)) +;;;###autoload +(defun system-packages-ensure (pack &optional args) + "Ensure PACK is installed on system. +Search for PACK with `system-packages-package-installed-p', and +install the package if not found. Use ARGS to pass options to +the package manager." + (if (system-packages-package-installed-p pack) + t + (system-packages-install pack args))) + +;;;###autoload +(defalias 'system-packages-package-installed-p #'executable-find + "Return t if PACK is installed. +Currently an alias for `executable-find', so it will give wrong +results if the package and executable names are different.") + ;;;###autoload (defun system-packages-search (pack &optional args) "Search for system packages.