all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* upgrading packages via script
@ 2017-09-26 14:55 Seb
  2017-09-27 13:21 ` Michael Heerdegen
  2017-09-27 14:21 ` Bastian Beischer
  0 siblings, 2 replies; 6+ messages in thread
From: Seb @ 2017-09-26 14:55 UTC (permalink / raw)
  To: help-gnu-emacs

Hello,

I'm trying to set up a script to upgrade packages using a cron job,
rather than interactively, as the latter has become a burden.  I'm using
Emacs 25.2.2 from Debian testing, and something is working inherently
different in the script compared to the interactive session.  At any
given time, the interactive session may display a number of packages
that can be upgraded, whereas the script fails to find any, even though
both are run with the same `package-archives' setting.

This is the script I wrote:

╭───── [ upgrade_packages.el ]
│ (setq package-archives
│       (quote
│        (("gnu" . "http://elpa.gnu.org/packages/")
│ 	("melpa" . "http://melpa.org/packages/")
│ 	("marmalade" . "https://marmalade-repo.org/packages/")
│ 	("org" . "http://orgmode.org/elpa/"))))
│ (package-initialize)
│ (list-packages)
│ (package-menu-mark-upgrades)
│ (package-menu-execute t)
╰─────

and this is how I run it:

---<--------------------cut here---------------start------------------->---
$ emacs -q --script upgrade_packages.el 
Loading 00debian-vars...
Loading /etc/emacs/site-start.d/20apel.el (source)...
Loading /etc/emacs/site-start.d/50asymptote.el (source)...
Loading /etc/emacs/site-start.d/50auctex.el (source)...
Loading /usr/share/emacs/site-lisp/auctex.el (source)...
Loading /usr/share/emacs/site-lisp/preview-latex.el (source)...
Loading /etc/emacs/site-start.d/50autoconf.el (source)...
Loading /etc/emacs/site-start.d/50bbdb3.el (source)...
Loading /etc/emacs/site-start.d/50cmake-data.el (source)...
Loading /etc/emacs/site-start.d/50devscripts-el.el (source)...
Loading /etc/emacs/site-start.d/50dictionaries-common.el (source)...
Loading debian-ispell...
Loading /var/cache/dictionaries-common/emacsen-ispell-default.el (source)...
Loading /var/cache/dictionaries-common/emacsen-ispell-dicts.el (source)...
Loading /etc/emacs/site-start.d/50dictionary-el.el (source)...
Loading dictionary-init...
Loading /etc/emacs/site-start.d/50dpkg-dev-el.el (source)...
Loading /etc/emacs/site-start.d/50el-get.el (source)...
Loading /etc/emacs/site-start.d/50emacs-goodies-el.el (source)...
Loading /etc/emacs/site-start.d/50festival.el (source)...
Loading /etc/emacs/site-start.d/50flim.el (source)...
Loading /etc/emacs/site-start.d/50gnugo.el (source)...
Loading /etc/emacs/site-start.d/50mailutils-mh.el (source)...
Loading /etc/emacs/site-start.d/50mh-e.el (source)...
Loading /etc/emacs/site-start.d/50mu4e.el (source)...
Loading /etc/emacs/site-start.d/50psvn.el (source)...
Loading /etc/emacs/site-start.d/50pylint.el (source)...
Loading /etc/emacs/site-start.d/50python-docutils.el (source)...
Loading /etc/emacs/site-start.d/50texlive-lang-english.el (source)...
Loading /etc/emacs/site-start.d/50w3m-el-snapshot.el (source)...
Loading /etc/emacs/site-start.d/51debian-el.el (source)...
Loading /etc/emacs/site-start.d/51semi.el (source)...
Loading /etc/emacs/site-start.d/65wl.el (source)...
Setting ‘package-selected-packages’ temporarily since "emacs -q" would overwrite customizations
Waiting for refresh to finish...
No operations specified
---<--------------------cut here---------------end--------------------->---

Remove the -q option doesn't make a difference.  If I do the same in an
interactive session, there are a number of packages available for
upgrade.  Any idea why the script fails to work?

-- 
Seb




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: upgrading packages via script
  2017-09-26 14:55 upgrading packages via script Seb
@ 2017-09-27 13:21 ` Michael Heerdegen
  2017-09-27 15:33   ` Seb
  2017-09-27 14:21 ` Bastian Beischer
  1 sibling, 1 reply; 6+ messages in thread
From: Michael Heerdegen @ 2017-09-27 13:21 UTC (permalink / raw)
  To: Seb; +Cc: help-gnu-emacs

Seb <spluque@gmail.com> writes:

> ╭───── [ upgrade_packages.el ]
> │ (setq package-archives
> │       (quote
> │        (("gnu" . "http://elpa.gnu.org/packages/")
> │ 	("melpa" . "http://melpa.org/packages/")
> │ 	("marmalade" . "https://marmalade-repo.org/packages/")
> │ 	("org" . "http://orgmode.org/elpa/"))))
> │ (package-initialize)
> │ (list-packages)
> │ (package-menu-mark-upgrades)
> │ (package-menu-execute t)
> ╰─────

My first guess would be that in nature, one has to wait until the
package manager has refreshed the view before one can select packages to
upgrade.  Your script finishes before that because updating the package
list happens asynchronously.


Michael.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: upgrading packages via script
  2017-09-26 14:55 upgrading packages via script Seb
  2017-09-27 13:21 ` Michael Heerdegen
@ 2017-09-27 14:21 ` Bastian Beischer
  2017-09-27 15:31   ` Sebastian P. Luque
  1 sibling, 1 reply; 6+ messages in thread
From: Bastian Beischer @ 2017-09-27 14:21 UTC (permalink / raw)
  To: Seb; +Cc: Help-Gnu-Emacs

Hi Seb,

On Tue, Sep 26, 2017 at 4:55 PM, Seb <spluque@gmail.com> wrote:
>
> Hello,
>
> I'm trying to set up a script to upgrade packages using a cron job,
> rather than interactively, as the latter has become a burden.  I'm using
> Emacs 25.2.2 from Debian testing, and something is working inherently
> different in the script compared to the interactive session.  At any
> given time, the interactive session may display a number of packages
> that can be upgraded, whereas the script fails to find any, even though
> both are run with the same `package-archives' setting.
>
> This is the script I wrote:
>
> ╭───── [ upgrade_packages.el ]
> │ (setq package-archives
> │       (quote
> │        (("gnu" . "http://elpa.gnu.org/packages/")
> │       ("melpa" . "http://melpa.org/packages/")
> │       ("marmalade" . "https://marmalade-repo.org/packages/")
> │       ("org" . "http://orgmode.org/elpa/"))))
> │ (package-initialize)
> │ (list-packages)
> │ (package-menu-mark-upgrades)
> │ (package-menu-execute t)
> ╰─────
>
> and this is how I run it:
>
> ---<--------------------cut here---------------start------------------->---
> $ emacs -q --script upgrade_packages.el
> Loading 00debian-vars...
> Loading /etc/emacs/site-start.d/20apel.el (source)...
> Loading /etc/emacs/site-start.d/50asymptote.el (source)...
> Loading /etc/emacs/site-start.d/50auctex.el (source)...
> Loading /usr/share/emacs/site-lisp/auctex.el (source)...
> Loading /usr/share/emacs/site-lisp/preview-latex.el (source)...
> Loading /etc/emacs/site-start.d/50autoconf.el (source)...
> Loading /etc/emacs/site-start.d/50bbdb3.el (source)...
> Loading /etc/emacs/site-start.d/50cmake-data.el (source)...
> Loading /etc/emacs/site-start.d/50devscripts-el.el (source)...
> Loading /etc/emacs/site-start.d/50dictionaries-common.el (source)...
> Loading debian-ispell...
> Loading /var/cache/dictionaries-common/emacsen-ispell-default.el (source)...
> Loading /var/cache/dictionaries-common/emacsen-ispell-dicts.el (source)...
> Loading /etc/emacs/site-start.d/50dictionary-el.el (source)...
> Loading dictionary-init...
> Loading /etc/emacs/site-start.d/50dpkg-dev-el.el (source)...
> Loading /etc/emacs/site-start.d/50el-get.el (source)...
> Loading /etc/emacs/site-start.d/50emacs-goodies-el.el (source)...
> Loading /etc/emacs/site-start.d/50festival.el (source)...
> Loading /etc/emacs/site-start.d/50flim.el (source)...
> Loading /etc/emacs/site-start.d/50gnugo.el (source)...
> Loading /etc/emacs/site-start.d/50mailutils-mh.el (source)...
> Loading /etc/emacs/site-start.d/50mh-e.el (source)...
> Loading /etc/emacs/site-start.d/50mu4e.el (source)...
> Loading /etc/emacs/site-start.d/50psvn.el (source)...
> Loading /etc/emacs/site-start.d/50pylint.el (source)...
> Loading /etc/emacs/site-start.d/50python-docutils.el (source)...
> Loading /etc/emacs/site-start.d/50texlive-lang-english.el (source)...
> Loading /etc/emacs/site-start.d/50w3m-el-snapshot.el (source)...
> Loading /etc/emacs/site-start.d/51debian-el.el (source)...
> Loading /etc/emacs/site-start.d/51semi.el (source)...
> Loading /etc/emacs/site-start.d/65wl.el (source)...
> Setting ‘package-selected-packages’ temporarily since "emacs -q" would overwrite customizations
> Waiting for refresh to finish...
> No operations specified
> ---<--------------------cut here---------------end--------------------->---
>
> Remove the -q option doesn't make a difference.  If I do the same in an
> interactive session, there are a number of packages available for
> upgrade.  Any idea why the script fails to work?


You may want to check out the package 'package-utils' which brings the
'package-utils-upgrade-all' function. I'm running this batch script to
do the job:

#!/bin/bash
emacs -q -u $USER -batch -f package-utils-upgrade-all

Cheers
Bastian

>
>
> --
> Seb
>
>



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: upgrading packages via script
  2017-09-27 14:21 ` Bastian Beischer
@ 2017-09-27 15:31   ` Sebastian P. Luque
  0 siblings, 0 replies; 6+ messages in thread
From: Sebastian P. Luque @ 2017-09-27 15:31 UTC (permalink / raw)
  To: help-gnu-emacs

On Wed, 27 Sep 2017 16:21:36 +0200,
Bastian Beischer <bastian.beischer@rwth-aachen.de> wrote:

[...]

> You may want to check out the package 'package-utils' which brings the
> 'package-utils-upgrade-all' function. I'm running this batch script to
> do the job:

> #!/bin/bash emacs -q -u $USER -batch -f package-utils-upgrade-all

> Cheers Bastian

Thanks, I'll give that a try, but I wonder what kind of magic this
package does that a script can't do.  Doesn't "-u $USER" defeat "-q"?

-- 
Seb




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: upgrading packages via script
  2017-09-27 13:21 ` Michael Heerdegen
@ 2017-09-27 15:33   ` Seb
  2017-09-27 22:39     ` Seb
  0 siblings, 1 reply; 6+ messages in thread
From: Seb @ 2017-09-27 15:33 UTC (permalink / raw)
  To: help-gnu-emacs

On Wed, 27 Sep 2017 15:21:26 +0200,
Michael Heerdegen <michael_heerdegen@web.de> wrote:

> Seb <spluque@gmail.com> writes:
>> ╭───── [ upgrade_packages.el ] │ (setq package-archives │ (quote │
>> (("gnu" . "http://elpa.gnu.org/packages/") │ ("melpa"
>> . "http://melpa.org/packages/") │ ("marmalade"
>> . "https://marmalade-repo.org/packages/") │ ("org"
>> . "http://orgmode.org/elpa/")))) │ (package-initialize) │
>> (list-packages) │ (package-menu-mark-upgrades) │
>> (package-menu-execute t) ╰─────

> My first guess would be that in nature, one has to wait until the
> package manager has refreshed the view before one can select packages
> to upgrade.  Your script finishes before that because updating the
> package list happens asynchronously.

That was also my first guess, but in that case shouldn't
(package-menu-execute t) fail altogether?

-- 
Seb




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: upgrading packages via script
  2017-09-27 15:33   ` Seb
@ 2017-09-27 22:39     ` Seb
  0 siblings, 0 replies; 6+ messages in thread
From: Seb @ 2017-09-27 22:39 UTC (permalink / raw)
  To: help-gnu-emacs

On Wed, 27 Sep 2017 10:33:50 -0500,
Seb <spluque@gmail.com> wrote:

> On Wed, 27 Sep 2017 15:21:26 +0200,
> Michael Heerdegen <michael_heerdegen@web.de> wrote:

>> Seb <spluque@gmail.com> writes:
>>> ╭───── [ upgrade_packages.el ] │ (setq package-archives │ (quote │
>>> (("gnu" . "http://elpa.gnu.org/packages/") │ ("melpa"
>>> . "http://melpa.org/packages/") │ ("marmalade"
>>> . "https://marmalade-repo.org/packages/") │ ("org"
>>> . "http://orgmode.org/elpa/")))) │ (package-initialize) │
>>> (list-packages) │ (package-menu-mark-upgrades) │
>>> (package-menu-execute t) ╰─────

>> My first guess would be that in nature, one has to wait until the
>> package manager has refreshed the view before one can select packages
>> to upgrade.  Your script finishes before that because updating the
>> package list happens asynchronously.

> That was also my first guess, but in that case shouldn't
> (package-menu-execute t) fail altogether?

Well, I found the variable package-menu-async, which if toggled answers
my question.  If set to nil in the script, then packages to upgrade are
found successfully against the latest candidates.  If non-nil, as by
default, then things go wrong as shown, so answer is no.

And the working script boils down to:

╭───── [ upgrade_packages.el ]
│ (setq package-archives
│       (quote
│        (("gnu" . "http://elpa.gnu.org/packages/")
│ 	("melpa" . "http://melpa.org/packages/")
│ 	("marmalade" . "https://marmalade-repo.org/packages/")
│ 	("org" . "http://orgmode.org/elpa/")))
│       package-menu-async nil)
│ (list-packages)
│ (package-menu-mark-upgrades)
│ (package-menu-execute t)
╰─────

-- 
Seb




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-09-27 22:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-26 14:55 upgrading packages via script Seb
2017-09-27 13:21 ` Michael Heerdegen
2017-09-27 15:33   ` Seb
2017-09-27 22:39     ` Seb
2017-09-27 14:21 ` Bastian Beischer
2017-09-27 15:31   ` Sebastian P. Luque

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.