From owner-freebsd-hackers@FreeBSD.ORG Mon Apr 12 00:34:33 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 50034106564A for ; Mon, 12 Apr 2010 00:34:33 +0000 (UTC) (envelope-from freebsd-hackers@m.gmane.org) Received: from lo.gmane.org (lo.gmane.org [80.91.229.12]) by mx1.freebsd.org (Postfix) with ESMTP id D04D98FC0A for ; Mon, 12 Apr 2010 00:34:32 +0000 (UTC) Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1O17bg-0007tM-Di for freebsd-hackers@freebsd.org; Mon, 12 Apr 2010 02:34:28 +0200 Received: from static-78-8-147-77.ssp.dialog.net.pl ([78.8.147.77]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 12 Apr 2010 02:34:28 +0200 Received: from mwisnicki+freebsd by static-78-8-147-77.ssp.dialog.net.pl with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 12 Apr 2010 02:34:28 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: freebsd-hackers@freebsd.org From: Marcin Wisnicki Date: Mon, 12 Apr 2010 00:34:16 +0000 (UTC) Lines: 47 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: static-78-8-147-77.ssp.dialog.net.pl User-Agent: Pan/0.132 (Waxed in Black) Subject: Re: make pkg_install suite reusable, please X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Apr 2010 00:34:33 -0000 On Sun, 11 Apr 2010 12:37:27 +0100, Robert Watson wrote: > On Fri, 9 Apr 2010, Alexander Churanov wrote: > >> 2010/4/9 Leinier Cruz Salfran >> >>> i want to ask you one thing: can you make the 'pkg_install' suite >>> reusable .. means install 'libinstall.a' as a shared object in order >>> to make it reusable by others devs >> >> I'd like to add my 50 cents. From my point of view, the true UNIX way >> is re-using whole programs. This provides unbelievable isolation and >> correctness. If you don't want to fork myriads of processes each >> second, then, it's, probably, better to ask for pipe mode of pkg_* >> tools. For example, aspell works that way. You start a process, write >> commands and queries and read results. > > While there are clearly benefits to process isolation, there are > countless situations in UNIX where I've said to myself "Oh, I wish I had > a lib not just a command". This is particularly the case for > monitoring tools, where third-party applications have a lot of trouble > parsing and tracking the output of tools like ps(1), etc. This is why > recently we've been working on libmemstat(3), libprocstat(3), > libnetstat(3), etc -- so that tools can avoid rewriting that code as > well as avoid the parsing problem. A middle-ground solution to this is to standardise on a common data exchange format with a schema definition language. With schema you can autogenerate high level parsers and generators, validators and other things for free. It does not have to be XML with XML-Schema (though there are good plaintext schema languages like RelaxNG-compact and you could possibly find less verbose text encoding for XML). Fine human readable competitors to XML exists like OGDL, YAML or JSON. OGDL project even have patches for OGDL output in GNU utlities. If, say ps or ipfw, had a switch like '--format-output-yaml' and '--print-output-schema' (alternatively schema files could be stored somewhere in $prefix/share) it would be trivial to use them anywhere. Similar approach could be adopted to input passing with possibility of pipe mode. Any utilitily, with mere tweaks to output formatting and pipe mode would in fact be a class that you could instantiate (run) and use like any other object in your programming language and all of that for free, autogenerated from schema descriptions ;) The only problem I see is agreeing on a single format and forcing everyone to use it. Which is probably why it will never happen :(