@@ -152,6 +152,12 @@ will return `lint/checkdoc' with a dash between two subcommands."
152152 (list script-file))
153153 " /" ))))
154154
155+ (defun eask-command-check (version )
156+ " Report error if the current command requires minimum VERSION."
157+ (when (version< emacs-version version)
158+ (eask-error " The command `%s' requires Emacs %s and above!"
159+ (eask-command) version)))
160+
155161(defun eask-command-p (commands )
156162 " Return t if COMMANDS is the current command."
157163 (member (eask-command) (eask-listify commands)))
@@ -542,10 +548,25 @@ For arguments FUNC and DEPS, see function `mapc' for more information."
542548 (len (length deps))
543549 (fmt (eask--action-format len))
544550 (count 0 ))
545- (dolist (pkg deps)
551+ (dolist (dep deps)
546552 (cl-incf count)
547553 (setq eask--action-prefix (format fmt count))
548- (funcall func pkg))))
554+ (funcall func dep))))
555+
556+ (defun eask--install-dep (dep )
557+ " Custom install DEP."
558+ (let ((name (car dep)))
559+ (cond
560+ ; ; Install through the function `package-install-file' .
561+ ((memq :file dep)
562+ (let ((file (nth 2 dep)))
563+ (eask-package-install-file name file)))
564+ ; ; Install through the function `package-vc-install' .
565+ ((memq :vc dep)
566+ (let ((spec (cdr (memq :vc dep))))
567+ (eask-package-vc-install name spec)))
568+ ; ; Fallback to archive install.
569+ (t (eask-package-install name)))))
549570
550571(defun eask--install-deps (dependencies msg )
551572 " Install DEPENDENCIES.
@@ -557,10 +578,11 @@ scope of the dependencies (it's either `production' or `development')."
557578 (len (length dependencies))
558579 (ies (eask--sinr len " y" " ies" ))
559580 (pkg-installed (cl-remove-if #'package-installed-p names))
560- (installed (length pkg-installed)) (skipped (- len installed)))
581+ (installed (length pkg-installed))
582+ (skipped (- len installed)))
561583 (eask-log " Installing %s %s dependenc%s..." len msg ies)
562584 (eask-msg " " )
563- (eask--package-mapc #'eask-package -install names )
585+ (eask--package-mapc #'eask--install-dep dependencies )
564586 (eask-msg " " )
565587 (eask-info " (Total of %s dependenc%s installed, %s skipped)"
566588 installed ies skipped)))
@@ -669,6 +691,38 @@ Argument BODY are forms for execution."
669691 " Return non-nil if package (PKG) is installable."
670692 (assq (eask-intern pkg) package-archive-contents))
671693
694+ (defun eask-package-vc-install (pkg spec )
695+ " To vc install the package (PKG) by argument SPEC."
696+ (eask-defvc< 27 (eask-pkg-init)) ; XXX: remove this after we drop 26.x
697+ (eask--pkg-process pkg
698+ (cond
699+ ((package-installed-p pkg)
700+ (eask-msg " - %sSkipping %s (%s)... already installed ✗"
701+ eask--action-prefix
702+ name version))
703+ (t
704+ (eask-with-progress
705+ (format " - %s Installing %s (%s )... " eask--action-prefix name version)
706+ (eask-with-verbosity 'debug
707+ (apply #'package-vc-install spec))
708+ " done ✓" )))))
709+
710+ (defun eask-package-install-file (pkg file )
711+ " To FILE install the package (PKG)."
712+ (eask-defvc< 27 (eask-pkg-init)) ; XXX: remove this after we drop 26.x
713+ (eask--pkg-process pkg
714+ (cond
715+ ((package-installed-p pkg)
716+ (eask-msg " - %sSkipping %s (%s)... already installed ✗"
717+ eask--action-prefix
718+ name version))
719+ (t
720+ (eask-with-progress
721+ (format " - %s Installing %s (%s )... " eask--action-prefix name version)
722+ (eask-with-verbosity 'debug
723+ (package-install-file (expand-file-name file)))
724+ " done ✓" )))))
725+
672726(defun eask-package-install (pkg )
673727 " Install the package (PKG)."
674728 (eask-defvc< 27 (eask-pkg-init)) ; XXX: remove this after we drop 26.x
@@ -683,18 +737,17 @@ Argument BODY are forms for execution."
683737 (unless (eask-package-installable-p pkg)
684738 (eask-error " Package not installable `%s' ; make sure the package archive (source) is included" pkg))))
685739 (t
686- (eask--pkg-process pkg
687- (eask-with-progress
688- (format " - %s Installing %s (%s )... " eask--action-prefix name version)
689- (eask-with-verbosity 'debug
690- ; ; XXX: Without ignore-errors guard, it will trigger error
691- ; ;
692- ; ; Can't find library xxxxxxx.el
693- ; ;
694- ; ; But we can remove this after Emacs 28, since function `find-library-name'
695- ; ; has replaced the function `signal' instead of the `error' .
696- (eask-ignore-errors (package-install pkg)))
697- " done ✓" ))))))
740+ (eask-with-progress
741+ (format " - %s Installing %s (%s )... " eask--action-prefix name version)
742+ (eask-with-verbosity 'debug
743+ ; ; XXX: Without ignore-errors guard, it will trigger error
744+ ; ;
745+ ; ; Can't find library xxxxxxx.el
746+ ; ;
747+ ; ; But we can remove this after Emacs 28, since function `find-library-name'
748+ ; ; has replaced the function `signal' instead of the `error' .
749+ (eask-ignore-errors (package-install pkg)))
750+ " done ✓" )))))
698751
699752(defun eask-package-delete (pkg )
700753 " Delete the package (PKG)."
@@ -720,13 +773,12 @@ Argument BODY are forms for execution."
720773 (eask-msg " - %sSkipping %s (%s)... not installed ✗" eask--action-prefix name version))
721774 (t
722775 (eask-pkg-init)
723- (eask--pkg-process pkg
724- (eask-with-progress
725- (format " - %s Reinstalling %s (%s )... " eask--action-prefix name version)
726- (eask-with-verbosity 'debug
727- (package-delete (eask-package-desc pkg t ) t )
728- (eask-ignore-errors (package-install pkg)))
729- " done ✓" ))))))
776+ (eask-with-progress
777+ (format " - %s Reinstalling %s (%s )... " eask--action-prefix name version)
778+ (eask-with-verbosity 'debug
779+ (package-delete (eask-package-desc pkg t ) t )
780+ (eask-ignore-errors (package-install pkg)))
781+ " done ✓" )))))
730782
731783(defun eask-package-desc (name &optional current )
732784 " Build package description by its NAME.
@@ -1276,6 +1328,7 @@ This uses function `locate-dominating-file' to look up directory tree."
12761328(defvar eask-depends-on-emacs nil )
12771329(defvar eask-depends-on nil )
12781330(defvar eask-depends-on-dev nil )
1331+ (defvar eask-depends-on nil )
12791332
12801333(defmacro eask--save-eask-file-state (&rest body )
12811334 " Execute BODY without touching the Eask-file global variables."
@@ -1487,6 +1540,17 @@ argument COMMAND."
14871540
14881541(add-hook 'eask-file-loaded-hook #'eask--setup-dependencies )
14891542
1543+ (defun eask--check-depends-on (recipe )
1544+ " Return non-nil if RECIPE is invalid."
1545+ (let ((pkg (car recipe))
1546+ (minimum-version (cdr recipe)))
1547+ (cond ((member recipe eask-depends-on)
1548+ (eask-error " Define dependencies with the same name `%s' " pkg))
1549+ ((cl-some (lambda (rcp )
1550+ (string= (car rcp) pkg))
1551+ eask-depends-on)
1552+ (eask-error " Define dependencies with the same name `%s' with different version" pkg)))))
1553+
14901554(defun eask-f-depends-on (pkg &rest args )
14911555 " Specify a dependency (PKG) of this package.
14921556
@@ -1505,17 +1569,27 @@ ELPA)."
15051569 recipe)))
15061570 ; ; No argument specify
15071571 ((<= (length args) 1 )
1508- (let* ((minimum-version (or ( car args) " 0 " ))
1572+ (let* ((minimum-version (car args))
15091573 (recipe (list pkg minimum-version)))
1510- (if (member recipe eask-depends-on)
1511- (eask-error " Define dependencies with the same name `%s' " pkg)
1574+ (unless (eask--check-depends-on recipe)
1575+ (push recipe eask-depends-on))
1576+ recipe))
1577+ ; ; Local packages
1578+ ((memq :file args)
1579+ (let* ((recipe (append (list (intern pkg)) args)))
1580+ (unless (eask--check-depends-on recipe)
1581+ (push recipe eask-depends-on))
1582+ recipe))
1583+ ; ; VC packages
1584+ ((memq :vc args)
1585+ (let* ((recipe (append (list (intern pkg)) args)))
1586+ (unless (eask--check-depends-on recipe)
15121587 (push recipe eask-depends-on))
15131588 recipe))
15141589 ; ; recipe are entered
15151590 (t
15161591 (let ((recipe (append (list (intern pkg)) args)))
1517- (if (member recipe eask-depends-on)
1518- (eask-error " Define dependencies with the same name `%s' " pkg)
1592+ (unless (eask--check-depends-on recipe)
15191593 (push recipe eask-depends-on)
15201594 (eask-load " extern/github-elpa" )
15211595 (eask-with-verbosity 'debug
0 commit comments