Mercurial > hg > xemacs-beta
comparison lisp/package-get.el @ 442:abe6d1db359e r21-2-36
Import from CVS: tag r21-2-36
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:35:02 +0200 |
parents | 8de8e3f6228a |
children | 576fb035e263 |
comparison
equal
deleted
inserted
replaced
441:72a7cfa4a488 | 442:abe6d1db359e |
---|---|
66 ;; version: 2.0 | 66 ;; version: 2.0 |
67 ;; | 67 ;; |
68 ;; vm - a mail reader | 68 ;; vm - a mail reader |
69 ;; [] Always install | 69 ;; [] Always install |
70 ;; [] Needs updating | 70 ;; [] Needs updating |
71 ;; [] Required by other [packages] | 71 ;; [] Required by other [packages] |
72 ;; | 72 ;; |
73 ;; Where `[]' indicates a toggle box | 73 ;; Where `[]' indicates a toggle box |
74 ;; | 74 ;; |
75 ;; - Clicking on "Always install" puts this into | 75 ;; - Clicking on "Always install" puts this into |
76 ;; `package-get-here' list. "Needs updating" indicates a new | 76 ;; `package-get-here' list. "Needs updating" indicates a new |
77 ;; version is available. Anything already in | 77 ;; version is available. Anything already in |
78 ;; `package-get-here' has this enabled. | 78 ;; `package-get-here' has this enabled. |
79 ;; - "Required by other" means some other packages are going to force | 79 ;; - "Required by other" means some other packages are going to force |
80 ;; this to be installed. Clicking on [packages] gives a list | 80 ;; this to be installed. Clicking on [packages] gives a list |
81 ;; of packages that require this. | 81 ;; of packages that require this. |
82 ;; | 82 ;; |
83 ;; The `package-get-base' should be installed in a file in | 83 ;; The `package-get-base' should be installed in a file in |
84 ;; `data-directory'. The `package-get-here' should be installed in | 84 ;; `data-directory'. The `package-get-here' should be installed in |
85 ;; site-lisp. Both are then read at run time. | 85 ;; site-lisp. Both are then read at run time. |
86 ;; | 86 ;; |
87 ;; TODO: | 87 ;; TODO: |
111 (defgroup package-get nil | 111 (defgroup package-get nil |
112 "Automatic Package Fetcher and Installer." | 112 "Automatic Package Fetcher and Installer." |
113 :prefix "package-get" | 113 :prefix "package-get" |
114 :group 'package-tools) | 114 :group 'package-tools) |
115 | 115 |
116 ;;;###autoload | 116 ;;;###autoload |
117 (defvar package-get-base nil | 117 (defvar package-get-base nil |
118 "List of packages that are installed at this site. | 118 "List of packages that are installed at this site. |
119 For each element in the alist, car is the package name and the cdr is | 119 For each element in the alist, car is the package name and the cdr is |
120 a plist containing information about the package. Typical fields | 120 a plist containing information about the package. Typical fields |
121 kept in the plist are: | 121 kept in the plist are: |
237 is the internet address of the download site. DIRECTORY-ON-SITE | 237 is the internet address of the download site. DIRECTORY-ON-SITE |
238 is the directory on the site in which packages may be found. | 238 is the directory on the site in which packages may be found. |
239 This variable is used to initialize `package-get-remote', the | 239 This variable is used to initialize `package-get-remote', the |
240 variable actually used to specify package download sites." | 240 variable actually used to specify package download sites." |
241 :tag "Package download sites" | 241 :tag "Package download sites" |
242 :type '(repeat (list hostname directory)) | 242 :type '(repeat (list (string :tag "Name") host-name directory)) |
243 :group 'package-get) | 243 :group 'package-get) |
244 | 244 |
245 (defcustom package-get-remove-copy t | 245 (defcustom package-get-remove-copy t |
246 "*After copying and installing a package, if this is t, then remove the | 246 "*After copying and installing a package, if this is t, then remove the |
247 copy. Otherwise, keep it around." | 247 copy. Otherwise, keep it around." |
286 (mapcar (lambda (site) | 286 (mapcar (lambda (site) |
287 (vector (car site) | 287 (vector (car site) |
288 `(if (member (quote ,(cdr site)) | 288 `(if (member (quote ,(cdr site)) |
289 package-get-remote) | 289 package-get-remote) |
290 (setq package-get-remote | 290 (setq package-get-remote |
291 (delete (quote ,(cdr site)) package-get-remote)) | 291 (delete (quote ,(cdr site)) |
292 package-get-remote)) | |
292 (package-ui-add-site (quote ,(cdr site)))) | 293 (package-ui-add-site (quote ,(cdr site)))) |
293 :style 'toggle | 294 :style 'toggle |
294 :selected `(member (quote ,(cdr site)) | 295 :selected `(member (quote ,(cdr site)) |
295 package-get-remote))) | 296 package-get-remote))) |
296 package-get-download-sites)) | 297 package-get-download-sites)) |
370 (insert-file-contents-literally location) | 371 (insert-file-contents-literally location) |
371 (md5 (current-buffer))))) | 372 (md5 (current-buffer))))) |
372 (unless (and location (file-writable-p location)) | 373 (unless (and location (file-writable-p location)) |
373 (setq location package-get-user-index-filename)) | 374 (setq location package-get-user-index-filename)) |
374 (when (y-or-n-p (concat "Update package index in " location "? ")) | 375 (when (y-or-n-p (concat "Update package index in " location "? ")) |
375 (write-file location)))))) | 376 (let ((coding-system-for-write 'binary)) |
376 | 377 (write-file location))))))) |
378 | |
377 | 379 |
378 ;;;###autoload | 380 ;;;###autoload |
379 (defun package-get-update-base (&optional db-file force-current) | 381 (defun package-get-update-base (&optional db-file force-current) |
380 "Update the package-get database file with entries from DB-FILE. | 382 "Update the package-get database file with entries from DB-FILE. |
381 Unless FORCE-CURRENT is non-nil never try to update the database." | 383 Unless FORCE-CURRENT is non-nil never try to update the database." |
396 (let ((buf (get-buffer-create "*package database*"))) | 398 (let ((buf (get-buffer-create "*package database*"))) |
397 (unwind-protect | 399 (unwind-protect |
398 (save-excursion | 400 (save-excursion |
399 (set-buffer buf) | 401 (set-buffer buf) |
400 (erase-buffer buf) | 402 (erase-buffer buf) |
401 (insert-file-contents-internal db-file) | 403 (insert-file-contents-literally db-file) |
402 (package-get-update-base-from-buffer buf) | 404 (package-get-update-base-from-buffer buf) |
403 (if (file-remote-p db-file) | 405 (if (file-remote-p db-file) |
404 (package-get-maybe-save-index db-file))) | 406 (package-get-maybe-save-index db-file))) |
405 (kill-buffer buf)))) | 407 (kill-buffer buf)))) |
406 | 408 |
513 "Perform interactive querying for package and optional version. | 515 "Perform interactive querying for package and optional version. |
514 Query for a version if GET-VERSION is non-nil. Return package name as | 516 Query for a version if GET-VERSION is non-nil. Return package name as |
515 a symbol instead of a string if PACKAGE-SYMBOL is non-nil. | 517 a symbol instead of a string if PACKAGE-SYMBOL is non-nil. |
516 The return value is suitable for direct passing to `interactive'." | 518 The return value is suitable for direct passing to `interactive'." |
517 (package-get-require-base t) | 519 (package-get-require-base t) |
518 (let ( (table (mapcar '(lambda (item) | 520 (let ((table (mapcar #'(lambda (item) |
519 (let ( (name (symbol-name (car item))) ) | 521 (let ((name (symbol-name (car item)))) |
520 (cons name name) | 522 (cons name name))) |
521 )) | 523 package-get-base)) |
522 package-get-base)) | 524 package package-symbol default-version version) |
523 package package-symbol default-version version) | |
524 (save-window-excursion | 525 (save-window-excursion |
525 (setq package (completing-read "Package: " table nil t)) | 526 (setq package (completing-read "Package: " table nil t)) |
526 (setq package-symbol (intern package)) | 527 (setq package-symbol (intern package)) |
527 (if get-version | 528 (if get-version |
528 (progn | 529 (progn |
529 (setq default-version | 530 (setq default-version |
530 (package-get-info-prop | 531 (package-get-info-prop |
531 (package-get-info-version | 532 (package-get-info-version |
532 (package-get-info-find-package package-get-base | 533 (package-get-info-find-package package-get-base |
533 package-symbol) nil) | 534 package-symbol) nil) |
534 'version)) | 535 'version)) |
535 (while (string= | 536 (while (string= |
540 (list package-symbol version) | 541 (list package-symbol version) |
541 (list package version)) | 542 (list package version)) |
542 ) | 543 ) |
543 (if package-symbol | 544 (if package-symbol |
544 (list package-symbol) | 545 (list package-symbol) |
545 (list package))) | 546 (list package)))))) |
546 ))) | |
547 | 547 |
548 ;;;###autoload | 548 ;;;###autoload |
549 (defun package-get-delete-package (package &optional pkg-topdir) | 549 (defun package-get-delete-package (package &optional pkg-topdir) |
550 "Delete an installation of PACKAGE below directory PKG-TOPDIR. | 550 "Delete an installation of PACKAGE below directory PKG-TOPDIR. |
551 PACKAGE is a symbol, not a string. | 551 PACKAGE is a symbol, not a string. |
637 (this-requires (package-get-info-prop this-package 'requires)) | 637 (this-requires (package-get-info-prop this-package 'requires)) |
638 (new-depends (set-difference | 638 (new-depends (set-difference |
639 (mapcar | 639 (mapcar |
640 #'(lambda (reqd) | 640 #'(lambda (reqd) |
641 (let* ((reqd-package (package-get-package-provider reqd)) | 641 (let* ((reqd-package (package-get-package-provider reqd)) |
642 (reqd-version (cadr reqd-package)) | |
643 (reqd-name (car reqd-package))) | 642 (reqd-name (car reqd-package))) |
644 (if (null reqd-name) | 643 (if (null reqd-name) |
645 (error "Unable to find a provider for %s" reqd)) | 644 (error "Unable to find a provider for %s" reqd)) |
646 reqd-name)) | 645 reqd-name)) |
647 this-requires) | 646 this-requires) |
704 'always always retrieve the package even if it is already installed | 703 'always always retrieve the package even if it is already installed |
705 'never do not retrieve the package if it is installed. | 704 'never do not retrieve the package if it is installed. |
706 INSTALL-DIR, if non-nil, specifies the package directory where | 705 INSTALL-DIR, if non-nil, specifies the package directory where |
707 fetched packages should be installed. | 706 fetched packages should be installed. |
708 | 707 |
709 The value of `package-get-base' is used to determine what files should | 708 The value of `package-get-base' is used to determine what files should |
710 be retrieved. The value of `package-get-remote' is used to determine | 709 be retrieved. The value of `package-get-remote' is used to determine |
711 where a package should be retrieved from. The sites are tried in | 710 where a package should be retrieved from. The sites are tried in |
712 order so one is better off listing easily reached sites first. | 711 order so one is better off listing easily reached sites first. |
713 | 712 |
714 Once the package is retrieved, its md5 checksum is computed. If that | 713 Once the package is retrieved, its md5 checksum is computed. If that |
812 ;; If the file exists on the remote system ... | 811 ;; If the file exists on the remote system ... |
813 ( (file-exists-p (package-get-remote-filename | 812 ( (file-exists-p (package-get-remote-filename |
814 current-dir-entry current-filename)) | 813 current-dir-entry current-filename)) |
815 ;; Get it | 814 ;; Get it |
816 (setq full-package-filename dest-filename) | 815 (setq full-package-filename dest-filename) |
817 (message "Retrieving package `%s' ..." | 816 (message "Retrieving package `%s' ..." |
818 current-filename) | 817 current-filename) |
819 (sit-for 0) | 818 (sit-for 0) |
820 (copy-file (package-get-remote-filename current-dir-entry | 819 (copy-file (package-get-remote-filename current-dir-entry |
821 current-filename) | 820 current-filename) |
822 full-package-filename t) | 821 full-package-filename t) |
843 "No download sites or local package locations specified."))) | 842 "No download sites or local package locations specified."))) |
844 ;; Validate the md5 checksum | 843 ;; Validate the md5 checksum |
845 ;; Doing it with XEmacs removes the need for an external md5 program | 844 ;; Doing it with XEmacs removes the need for an external md5 program |
846 (message "Validating checksum for `%s'..." package) (sit-for 0) | 845 (message "Validating checksum for `%s'..." package) (sit-for 0) |
847 (with-temp-buffer | 846 (with-temp-buffer |
848 ;; What ever happened to i-f-c-literally | 847 (insert-file-contents-literally full-package-filename) |
849 (let (file-name-handler-alist) | |
850 (insert-file-contents-internal full-package-filename)) | |
851 (if (not (string= (md5 (current-buffer)) | 848 (if (not (string= (md5 (current-buffer)) |
852 (package-get-info-prop this-package | 849 (package-get-info-prop this-package |
853 'md5sum))) | 850 'md5sum))) |
854 (error "Package %s does not match md5 checksum" base-filename))) | 851 (error "Package %s does not match md5 checksum" base-filename))) |
855 | 852 |
898 associated with it. See `package-get-base' for info on the format | 895 associated with it. See `package-get-base' for info on the format |
899 returned. | 896 returned. |
900 | 897 |
901 To access fields returned from this, use | 898 To access fields returned from this, use |
902 `package-get-info-version' to return information about particular a | 899 `package-get-info-version' to return information about particular a |
903 version. Use `package-get-info-find-prop' to find particular property | 900 version. Use `package-get-info-find-prop' to find particular property |
904 from a version returned by `package-get-info-version'." | 901 from a version returned by `package-get-info-version'." |
905 (interactive "xPackage list: \nsPackage Name: ") | 902 (interactive "xPackage list: \nsPackage Name: ") |
906 (if which | 903 (if which |
907 (if (eq (caar which) name) | 904 (if (eq (caar which) name) |
908 (cdar which) | 905 (cdar which) |
910 (package-get-info-find-package (cdr which) name))))) | 907 (package-get-info-find-package (cdr which) name))))) |
911 | 908 |
912 (defun package-get-info-version (package version) | 909 (defun package-get-info-version (package version) |
913 "In PACKAGE, return the plist associated with a particular VERSION of the | 910 "In PACKAGE, return the plist associated with a particular VERSION of the |
914 package. PACKAGE is typically as returned by | 911 package. PACKAGE is typically as returned by |
915 `package-get-info-find-package'. If VERSION is nil, then return the | 912 `package-get-info-find-package'. If VERSION is nil, then return the |
916 first (aka most recent) version. Use `package-get-info-find-prop' | 913 first (aka most recent) version. Use `package-get-info-find-prop' |
917 to retrieve a particular property from the value returned by this." | 914 to retrieve a particular property from the value returned by this." |
918 (interactive (package-get-interactive-package-query t t)) | 915 (interactive (package-get-interactive-package-query t t)) |
919 (while (and version package (not (string= (plist-get (car package) 'version) version))) | 916 (while (and version package (not (string= (plist-get (car package) 'version) version))) |
920 (setq package (cdr package))) | 917 (setq package (cdr package))) |
987 filename)))) | 984 filename)))) |
988 | 985 |
989 | 986 |
990 (defun package-get-installedp (package version) | 987 (defun package-get-installedp (package version) |
991 "Determine if PACKAGE with VERSION has already been installed. | 988 "Determine if PACKAGE with VERSION has already been installed. |
992 I'm not sure if I want to do this by searching directories or checking | 989 I'm not sure if I want to do this by searching directories or checking |
993 some built in variables. For now, use packages-package-list." | 990 some built in variables. For now, use packages-package-list." |
994 ;; Use packages-package-list which contains name and version | 991 ;; Use packages-package-list which contains name and version |
995 (equal (plist-get | 992 (equal (plist-get |
996 (package-get-info-find-package packages-package-list | 993 (package-get-info-find-package packages-package-list |
997 package) ':version) | 994 package) ':version) |
999 | 996 |
1000 ;;;###autoload | 997 ;;;###autoload |
1001 (defun package-get-package-provider (sym &optional force-current) | 998 (defun package-get-package-provider (sym &optional force-current) |
1002 "Search for a package that provides SYM and return the name and | 999 "Search for a package that provides SYM and return the name and |
1003 version. Searches in `package-get-base' for SYM. If SYM is a | 1000 version. Searches in `package-get-base' for SYM. If SYM is a |
1004 consp, then it must match a corresponding (provide (SYM VERSION)) from | 1001 consp, then it must match a corresponding (provide (SYM VERSION)) from |
1005 the package. | 1002 the package. |
1006 | 1003 |
1007 If FORCE-CURRENT is non-nil make sure the database is up to date. This might | 1004 If FORCE-CURRENT is non-nil make sure the database is up to date. This might |
1008 lead to Emacs accessing remote sites." | 1005 lead to Emacs accessing remote sites." |
1009 (interactive "SSymbol: ") | 1006 (interactive "SSymbol: ") |
1052 t) | 1049 t) |
1053 package-get-base)) | 1050 package-get-base)) |
1054 | 1051 |
1055 (defun package-get-ever-installed-p (pkg &optional notused) | 1052 (defun package-get-ever-installed-p (pkg &optional notused) |
1056 (string-match "-package$" (symbol-name pkg)) | 1053 (string-match "-package$" (symbol-name pkg)) |
1057 (custom-initialize-set | 1054 (custom-initialize-set |
1058 pkg | 1055 pkg |
1059 (if (package-get-info-find-package | 1056 (if (package-get-info-find-package |
1060 packages-package-list | 1057 packages-package-list |
1061 (intern (substring (symbol-name pkg) 0 (match-beginning 0)))) | 1058 (intern (substring (symbol-name pkg) 0 (match-beginning 0)))) |
1062 t))) | 1059 t))) |
1063 | 1060 |
1064 (defvar package-get-custom-groups nil | 1061 (defvar package-get-custom-groups nil |
1065 "List of package-get-custom groups") | 1062 "List of package-get-custom groups") |