Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Perl <-> debian apt interface

by Nomis52 (Friar)
on Feb 21, 2003 at 12:43 UTC ( [id://237419]=perlquestion: print w/replies, xml ) Need Help??

Nomis52 has asked for the wisdom of the Perl Monks concerning the following question:

I'm writing a small script to automate the task of setting up workstations in a non-profit organisation where I help out. The clients (all running Debian) need to be configured to authenticate users to a LDAP server and also mount nfs shares. This involes installing a few packages using apt and then editing a few text files. Being lazy I don't particularly want to have to do this for every client so I'm trying to write a script to do it for me.

What I'm after is a Perl interface to the debian apt mechanism, so I can grab a few debs, install them and then edit the config files. So far the only solution I can find is to use system() to call apt-get with the -y option to turn off prompts.

Any ideas?
Many thanks

Replies are listed 'Best First'.
Re: Perl <-> debian apt interface
by cees (Curate) on Feb 21, 2003 at 14:34 UTC

    Would it not be easier to create your own debian package to do this? If you set the dependancies correctly, all required packages will be installed automatically, and you can have the post installation script (in perl) do the configuration for you.

    So instead of running your script on every computer, just install one .deb on each computer.

Re: Perl <-> debian apt interface
by Corion (Patriarch) on Feb 21, 2003 at 13:32 UTC

    At least debconf has a lot of Perl modules, but unfortunately, the Debian developers deem these not fit for release on CPAN, as they are Debian specific... I can't gather any callbacks back to apt-get though.

    More googling returns apt-dialog, some Tk frontend for apt and apt-src, supposedly an apt library with an interface from Perl.

    perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web
Re: Perl <-> debian apt interface
by IlyaM (Parson) on Feb 21, 2003 at 15:54 UTC

      I did briefly and also took a look at cfengine. However we needed to get this out relatively quickly and on existing workstations. As far as I know, another guy is working on custom installs based on FAI, so I'll just add the LDAP bit onto that when his done.

      Thanks for the reference though, It's good to know we're on the right track

      Simon N
Re: Perl <-> debian apt interface
by hardburn (Abbot) on Feb 21, 2003 at 14:46 UTC

    I'd put this in a shell script. Perl is kinda overkill for this job.

    Reinvent a rounder wheel.

    Note: All code is untested, unless otherwise stated

Re: Perl <-> debian apt interface
by jonadab (Parson) on Feb 22, 2003 at 02:52 UTC
    So far the only solution I can find is to use system() to call apt-get with the -y option to turn off prompts.

    You are right to hesitate to do this. There are a number of very worthwhile reasons to avoid such a technique, in general.

    However, in this case...

    Almost all the reasons to avoid calling system binaries involve one of two factors: portability or efficiency. Neither matters here.

    Portability is utterly unimportant because the whole point of what you want to do is centered on one specific OS and one specific distribution. Portability is not involved.

    Efficiency is similarly non-critical. Shelling out to a non-Perl process takes extra microseconds, but you're doing it a small handful of times; it won't add up to an extra five seconds, and you're doing that once at install time. It's a non-issue.

    So don't waste time on a more elegant solution; throw your apt-get command in backticks and be done. Perl, according to the first sentence of the Camel, is a language for getting your job done. You can write this script (well, the apt-get part) in five or ten minutes and be done.

Re: Perl <-> debian apt interface
by maksl (Pilgrim) on Feb 23, 2003 at 12:48 UTC
    not exactly a response but .. : take a look at apt-proxy it's quite usefull to save bandwith when mantaining several debian machines ;)

      I use apt-cacher, not a proxy in a true sense but a Perl cgi script that mimics a proxy. I caught Jonathan Oxer's talk about it at debConf @ Linux Conf Au 03 and went home and installed it that night. Rusty (of iptables fame and who also wrote apt-proxy) was in the audience and he made some interesting comments about his own software :)

      Simon N
        Nomis52 you make me curious what did Rusty say?

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://237419]
Approved by pfaut
Front-paged by broquaint
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (2)
As of 2024-07-16 03:54 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.