Commit Graph

202 Commits

Author SHA1 Message Date
stephan-cr
3969e02b27
Fix Git HTTP smart host detection (#2854)
* Fix Git HTTP smart host detection

regression test test/issues/el-get-issue-1920.el revealed that Git
HTTP smart host detection is broken. Not all hosts support the HEAD
HTTP request method. For example, github.com for HEAD

(let ((url-request-method "HEAD"))
  (url-retrieve-synchronously
   "https://github.com/dimitri/el-get.git/info/refs\?service\=git-upload-pack"))

responds

HTTP/1.1 405 Method Not Allowed
Server: GitHub Babel 2.0
Content-Type: text/plain
Content-Security-Policy: default-src 'none'; sandbox
Content-Length: 0
X-Frame-Options: DENY
X-GitHub-Request-Id: C1DA:12E32:2B6C9D7:302B1C2:61C9A4E8

while for GET

(let ((url-request-method "GET"))
  (url-retrieve-synchronously
   "https://github.com/dimitri/el-get.git/info/refs\?service\=git-upload-pack"))

responds

HTTP/1.1 200 OK
Server: GitHub Babel 2.0
Content-Type: application/x-git-upload-pack-advertisement
Content-Security-Policy: default-src 'none'; sandbox
Transfer-Encoding: chunked
expires: Fri, 01 Jan 1980 00:00:00 GMT
pragma: no-cache
Cache-Control: no-cache, max-age=0, must-revalidate
Vary: Accept-Encoding
X-Frame-Options: DENY
X-GitHub-Request-Id: C22C:5E15:3923777:3D822AC:61CA332A

Other hosts like git.sr.ht do support HEAD, of course.

Furthermore, the HTTP status code wasn't checked, that's why hosts
like github.com would be classified as "dumb" hosts.

This commit checks the HTTP status code, and if the status is not 200
or 304 for the HEAD HTTP request method, it tries GET. HEAD is tried
first, because GET might be more expensive for big repositories.

The regression test is adapted as well.

* Fix byte compiler warnings
2023-01-01 13:31:18 +01:00
Stephan Creutz
4d6f30d165 Fix lambda invocation for Emacs 28 2021-06-13 16:03:08 +02:00
Stephan Creutz
21a75ba79b Fix missing requirements 2021-06-13 16:03:08 +02:00
Stephan Creutz
ccca97f226 Replace cl by cl-lib
Since Emacs 27 the package cl is deprecated, the replacement is
cl-lib, which is available since Emacs 24.3.

This patch replaces cl by cl-lib and drops support for Emacs versions
less than 24.3. Dropping older Emacsen is required, because cl-lib is
a builtin starting from version 24.3 and doesn't need an extra package
from ELPA.

Testcases for past issues still contain cl. Most of them seem to be
broken and need further investigation.

This patch is tested with test/run-ert.sh, which outputs:

Ran 10 tests, 10 results as expected, 0 unexpected (2021-01-30 13:24:54+0100, 0.672122 sec)
1 expected failures

and manually by daily usage for a month now.
2021-06-13 16:03:08 +02:00
Rafael Laboissière
9a2eae23ee Force response "yes" in apt-get install
Without this fix, the installation will get stuck while waiting a user
response, what makes the apt-get method dysfunctional.
2020-09-03 21:57:55 +02:00
Rafael Laboissière
be18ea515b Make apt-get commands run synchronously
If the "apt-get install" and "apt-get remove" are not run synchronously,
the later will prevent the former to run, because it is not possible to run
two dpkg processes simultaneously on a Debian-based system.
2020-09-03 21:55:36 +02:00
Rafael Laboissière
67358331cd Avoid errors when calling dpkg-query
When a package is not installed in the system, the dpkg-query command exits
with an error.  This will then make the function
el-get-dpkg-package-installed-p fails, which interrupts the installation of
the package, making the apt-get method useless.  This commits avoids the
problem by wrapping the call to process-lines into a condition-case
statement.
2020-09-03 21:51:13 +02:00
Noam Postavsky
08005ef89b Fix w32 elpa copy-directory call for Emacs 26+
In Emacs 26, copy-directory copies the directory itself, based on
whether NEWNAME is directory name (ends with a "/").  Earlier Emacs
versions actually checked whether NEWNAME was existing directory, so
we happened to get the right behaviour most of the time.

Pass t for COPY-CONTENTS to ensure the correct behaviour all of the
time.
2018-10-05 22:25:46 -04:00
Noam Postavsky
8e96907b8b methods/el-get-elpa: handle string PACKAGE args
By converting them to symbol.
2018-06-10 21:21:00 -04:00
yewton
175dbdee42 Allow latest org-mode git url to shallow clone
* Add `code.orgmode.org` to el-get-git-known-smart-domains
* Gogs not support HEAD request for now so `el-get-git-is-host-smart-http-p' check fails

https://github.com/dimitri/el-get/pull/2590
https://github.com/gogits/gogs/issues/2857
2018-01-11 00:53:05 +09:00
maxchaos
99bc5e1814 Fix symlink creation bug regarding elpa packages 2017-08-13 17:36:39 -04:00
Noam Postavsky
ddf128195b Give a nicer error for missing ELPA package 2017-06-29 20:08:00 -04:00
Noam Postavsky
a6510f13c1 Fix elpa auto generating for 24.4+ package.el
* methods/el-get-elpa.el (package-desc-archive): Define it for old Emacs
versions that don't provide it.
(el-get-elpa-build-local-recipes): Use that instead of hard-coding
offset into package-desc array.
2017-01-13 01:04:29 -05:00
Noam Postavsky
c00a03a26f Fix secure URL checking for :type elpa
* el-get-methods.el (el-get-insecure-check): Also consider URLs
satisfying `file-name-absolute-p' to be secure.  `package-archives' uses
absolute file names *without* file:// prefix, so we have allow this too.
* methods/el-get-elpa.el (el-get-elpa-package-id):
(el-get-elpa-package-archive-base): New compat functions.
* methods/el-get-elpa.el (el-get-elpa-install): Call
`el-get-insecure-check' after ensuring `package-archive-contents' is
initialized.
2016-10-08 22:00:41 -04:00
Mykola Nikishov
63be589c1d Delegate install and update actions for github to git
github method, as a derived method, should build a final repository URL
and let parent's respective methods do the actual work.

Register new 'el-get-github-pull function as update method.

Make both methods, 'el-get-github-pull and 'el-get-github-clone,
implement the same pattern:

- Delegate check if URL is a secure one to the parent method
- Ignore :url from package's recipe passed by 'el-get-do-update as it
  makes no sense
- Unconditionally build package repository URL with 'el-get-github-url
- Call respective git method
2016-09-19 08:42:04 +03:00
Mykola Nikishov
e899853c03 Fix logic when deciding if apt-get package should be installed
Install apt-get package only if it's not installed.
2016-09-08 08:15:53 +03:00
Mykola Nikishov
a6638a664a Make check for apt-get package work (#2434)
* Pass package name to dpkg-query

* dpkg-query reports status as 'install ok installed'

* when el-get name is different from apt-get name
2016-08-27 22:05:14 +02:00
Noam Postavsky
9f2833c749 el-get-apt-get-install: use apt-get package name
in name of buffer, rather than el-get package name.  Since we write what
looks like the command being executed, "apt-get install FOO", it's
confusing if FOO isn't the actual package being passed to apt-get.

Fixes #2358.
2016-06-28 19:19:22 -04:00
Noam Postavsky
344ab643f4 Don't call apt-get if package already installed
This avoids asking for root priviledges if it's not needed.

* methods/el-get-apt-get.el (el-get-dpkg-package-installed-p): Renamed
from el-get-dpkg-package-status, don't use shell.
(el-get-apt-get-install-if-needed): New function.
(el-get-register-method :apt-get): Use it as :install method.
2016-05-19 20:31:59 -04:00
Noam Postavsky
52e7d9bc40 el-get-{emacswiki,elpa}-build-local-recipes: fix, optimize
Escape the value of :description properly generating recipes.

Make auto generation of recipes from package.el descriptors quieter and
faster (forego nice indentation).
2016-02-06 02:40:28 -05:00
Noam Postavsky
458a9a3844 el-get-http-install: allow for non-http urls
fix #2276
2015-10-27 20:12:20 -04:00
Noam Postavsky
a60eaccf9c el-get-executable-find: use it consistently
for better error messages.

fix #2226
2015-07-27 14:56:02 -04:00
Noam Postavsky
f4e71160b8 el-get-http-install: `<=' only takes 2 args
in Emacs 24.3 and below.
2015-04-07 09:18:20 -04:00
Noam Postavsky
265eb14abb el-get-http-install: check http 2xx in sync case 2015-03-29 10:46:25 -04:00
anthony cantor
cafbb02077 dont assume tar options
recipes should provide the appropriate options for whatever
they are downloading
2015-03-10 23:35:43 -07:00
anthony cantor
8b31cedd33 fix command line options for tar method
tar needs the x and f options to decompress a tar file.
2015-03-08 19:31:08 -07:00
anthony cantor
091f4b149e http-tar, http-zip methods: verify checksum before handling archive
Both the http-tar and http-zip methods are modified to manually
verify the checksum before handling the archive. This is a
security precaution and also prevents unexpected consequences from
attempting to work with a corrupted archive file.

The checksum verification code is factored out of el-get-post-install
so that the tar and zip methods can verify using the same code as
other methods.
2015-03-08 19:27:06 -07:00
anthony cantor
4866c13964 Add support for checksums to http-tar and http-zip methods.
The compute-checksum function is the same for these methods as
the plain http method.
2015-03-08 18:11:03 -07:00
Noam Postavsky
856ed17bf7 el-get-git-compute-checksum: use call-process
instead of shell-command-to-string. This works even if the path to git
has spaces in it.
2015-03-05 12:25:58 -05:00
Noam Postavsky
4e825ca5e4 el-get-git-compute-checksum: don't call cd
in a temp buffer, just let-bind default-directory.
2015-03-05 12:25:58 -05:00
Noam Postavsky
5e32662bb9 el-get-emacswiki-build-local-recipes: don't indent
The auto-generated is simple enough that it's pretty readable without
indentation, and on Emacs 24.4 the indent-region function prints a
message.

Also, since we didn't change to elisp mode, the indentation wasn't doing
anything until now anyway.
2015-02-23 22:24:47 -05:00
Noam Postavsky
5100568f94 make-progress-reporter for wiki recipes generation
* methods/el-get-emacswiki.el (el-get-emacswiki-build-local-recipes):
  Use make-progress-reporter instead of calling message.
2015-01-13 23:48:00 -05:00
Noam Postavsky
6fa9c19ec1 improve wiki list parser
* methods/el-get-emacswiki.el (el-get-emacswiki-retrieve-package-list):
  Use regexp to catch description part, and avoid .gz files.
(el-get-emacswiki-elisp-file-list-url): Update url.
2015-01-13 23:47:23 -05:00
Noam Postavsky
64ab96511a check download status of emacswiki package list
* methods/el-get-emacswiki.el (el-get-emacswiki-retrieve-package-list):
  Throw error if we didn't get HTTP 2xx.
* el-get-install.el: Show warning if
  `el-get-emacswiki-build-local-recipes' fails.
2014-12-25 12:43:34 -05:00
Noam Postavsky
42cc1e3a98 Take sha1 of buffer contents, not buffer
This prevents the sha1 function from attempting and then failing to
encode the buffer contents in the wrong encoding.

* methods/el-get-http.el (el-get-http-compute-checksum): Call `sha1' on
  result of `buffer-string', not `current-buffer'.
2014-11-21 18:53:29 -05:00
Saulius Grigaliunas
8eaacdf899 Fix melpa host name
Now lives at melpa.org
2014-10-23 21:33:08 +03:00
Noam Postavsky
85867029f4 Warn if apt-get package installed no elisp
Using just message makes it too easy to overlook. The warning only
triggers on installation (not update or init) so it shouldn't be too
annoying.

* methods/el-get-apt-get.el (el-get-dpkg-symlink): use lwarn instead of
  message.
2014-10-22 19:44:28 -04:00
Noam Postavsky
e3f82e764a Create empty dir if no apt-get dir to symlink to
If the apt-get package doesn't contain any elisp files symlinking to the
non-existant /usr/share/emacs/site-lisp/<package> directory will leave
us with a broken link that will raise an error when we attempt to look
for autoloads, clean stale elc files and the like. In this case, simply
create an empty directory instead of a link.

* methods/el-get-apt-get.el (el-get-dpkg-symlink): call `make-directory'
  instead of symlink when `debdir' doesn't exist.
2014-10-22 19:44:28 -04:00
Noam Postavsky
8ccda8a6fd Do use elpa deps if there are no el-get :depends
* methods/el-get-elpa.el (el-get-elpa-install-1-package): rename to
el-get-elpa-install-package, take another argument have-deps-p. Only
call package-download-transaction directly if have-deps-p.
(el-get-elpa-install, el-get-elpa-update): el-get-elpa-install{-1
=>}-package name change and new arg.
2014-10-18 12:27:27 -04:00
Noam Postavsky
85a0ad62c8 Fix call to package-download-transaction on 24.4
* methods/el-get-elpa.el (el-get-elpa-install-1-package): new wrapping
  function for package-download-transaction.
  (el-get-elpa-install, el-get-elpa-update): use it.
2014-10-16 01:07:29 -04:00
Iqbal Ansari
bb7ccfb49a Do not depend on url-parse for extracting hosts from urls
This fixes for #1939. Tests have been added to test/el-get-issue-1939.el
2014-10-15 21:37:52 +05:30
Noam Postavsky
1f7e915416 Don't let elpa download dependencies
Since el-get also downloads dependencies we end up installing things
twice.

* methods/el-get-elpa.el (el-get-elpa-install): call
  package-download-transaction instead of package-install.
2014-10-07 20:18:27 -04:00
Iqbal Ansari
4c065f189d Fix some typos and style issues 2014-10-05 20:53:21 +05:30
Iqbal Ansari
16d65943e8 Improve support for shallow clones using git
The current algorithm is
1) If the protocol used is not http (file, ssh, git) clone is supported
2) Otherwise check if repo belongs to know smart host, if so assume
   shallow clone is supported
3) If none of the above work, make a HEAD request and parse response
   headers to determine the host is smart explained (here)[http://stackoverflow.com/questions/9270488/]
2014-10-05 12:46:59 +05:30
Noam Postavsky
6aafc8a851 elpa-symlink: Use make-symbolic-link
instead of shell-command which is sensitive to the user's choice of
shell.

* el-get-elpa.el (el-get-elpa-symlink-package): use make-symbolic-link
instead of shell-command "ln -s %s %s".
2014-10-04 21:07:35 -04:00
Dimitri Fontaine
a2d24ecd0f Merge pull request #1875 from technomancy/allow-insecure
Fix a bug where el-get-github-clone used the wrong URL.
2014-08-27 23:09:50 +02:00
Phil Hagelberg
e3203d6858 Fix a bug where el-get-github-clone used the wrong URL. 2014-08-27 13:59:49 -07:00
Noam Postavsky
c1144f55f3 fix http download with non-nil before-save-hook
* methods/el-get-http.el (el-get-http-retrieve-callback): use
  write-region instead of write-file to avoid before-save-hook.
2014-08-23 17:32:23 -04:00
Phil Hagelberg
acdcb6e5b2
Don't install insecurely without el-get-allow-insecure.
In most cases, we assume any connection is insecure unless the URL
starts with "https://", "$USERNAME@", or "ssh". There are a few
exceptions: I'm assuming all Emacswiki packages are insecure, and I
don't think we can know whether packages installed via Google Go are
secure or not.
2014-08-12 11:42:08 -07:00
Noam Postavsky
abfd259688 http callback: don't write-file directly to dest
When downloading a .gz file, if we actually write-file to that filename
the compressed data would be compressed a second time thanks to
auto-compress-mode. Instead, write to .part file first and then rename
to the destination, as it was before
92a39c84fe.
2014-06-07 19:23:54 -04:00