Bug 1557 - pkg_add's auto dependency get .. doesn't work
Summary: pkg_add's auto dependency get .. doesn't work
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 2.2-CURRENT
Hardware: Any Any
: Normal Affects Only Me
Assignee: jkh
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 1996-08-31 08:10 UTC by David Leonard
Modified: 1996-10-14 20:41 UTC (History)
0 users

See Also:


Attachments
file.diff (985 bytes, patch)
1996-08-31 08:10 UTC, David Leonard
no flags Details | Diff
file.diff (1.14 KB, patch)
1996-08-31 08:10 UTC, David Leonard
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Leonard 1996-08-31 08:10:01 UTC
	When you pkg_add something from a URL when the dependencies
	aren't all installed, pkg_add will attempt to auto-install
	the dependent packages for you. but it doesn't work.

Fix: ------------------------------------------------------------
	for src/lib/libftpio/

------------------------------------------------------------

	for src/usr.sbin/pkg_install/lib

	might also want to add the '.tar.gz' case too?
How-To-Repeat: 
	without having autoconf or m4 installed, i did

# pkg_add -v  "ftp://ftp/u9/freebsd/packages-2.1.5/All/autoconf-2.10.tgz"
Trying to fetch ftp://ftp/u9/freebsd/packages-2.1.5/All/autoconf-2.10.tgz.
Extracting from FTP connection into /var/tmp/instmp.014625
+CONTENTS
[... and so on ...]
share/autoconf/config.sub
tar command returns 0 status
Package `autoconf-2.10' depends on `m4-1.4'.
Trying to fetch ftp://ftp/u9/freebsd/packages-2.1.5/All/m4-1.4.
Error: FTP Unable to get ftp://ftp/u9/freebsd/packages-2.1.5/All/m4-1.4
Segmentation fault (core dumped)

	So, i looked into why the .tgz extension isn't being added in, and
	added that (see patches to pkg_install/lib/file.c below) then
	retried

	after a similar output it died on a 'Broken Pipe' signal after
	trying to fetch the right file. (i can't cut and paste because 
	vi trashed the scrollback buffer)

	anyway, i traced this to a thing inside libftpio where with
	ftpGetURL, an static FILE* is being closed on each re-open.

	I suspect that the fclose done in ftpGetURL() is to avoid
	exhausting file descriptors... anyway what i have now works,
	even though some FILE*'s are left unclosed. i could not see
	straight away where the sigpipe was coming from... should have
	kept the core :(
Comment 1 Jordan K. Hubbard 1996-08-31 22:23:51 UTC
> 	So, i looked into why the .tgz extension isn't being added in, and
> 	added that (see patches to pkg_install/lib/file.c below) then
> 	retried

Genuine bug, thanks.

> 	anyway, i traced this to a thing inside libftpio where with
> 	ftpGetURL, an static FILE* is being closed on each re-open.
> 
> 	I suspect that the fclose done in ftpGetURL() is to avoid
> 	exhausting file descriptors... anyway what i have now works,

Erm, sort of. :-(

That construct is very deliberately the way it is, due to the fact
that when you open a connection to an FTP, that returns one FILE*.  If
you then ask for a file from that connection, it returns another
FILE*.  Now, and this is the important part, if you close the first
file pointer before finishing with the second, you lose.  The intended
use of ftpGetURL() was that you'd process the file it returned all the
way to completion and close it before asking for another URL.  This is
clearly not what pkg_add is doing, and pkg_add has a bug I'll have to
look into.  Leaving leaks in libftpio is not an acceptable solution by
any conceivable stretch.

However, you have suggested an important optimization to me, and
that's to cache the old host connection when getting ftpGetURL()
requests back-to-back for the same host.  That just makes simple
sense, and was easy to do.  I'll commit the changes shortly to
libftpio, as well as some fixes to pkg_add.

					Jordan
Comment 2 Wolfram Schneider freebsd_committer freebsd_triage 1996-09-27 01:08:00 UTC
Responsible Changed
From-To: freebsd-bugs->jkh

pkg_* is Jordans area. 
Comment 3 jkh freebsd_committer freebsd_triage 1996-10-14 20:22:08 UTC
State Changed
From-To: open->closed

There were indeed entomological artifacts in this code - thanks for 
the bug report.  Fixed!