DaemonForums  

Go Back   DaemonForums > FreeBSD > FreeBSD Ports and Packages

FreeBSD Ports and Packages Installation and upgrading of ports and packages on FreeBSD.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 24th September 2008
DNAeon DNAeon is offline
Shell Scout
 
Join Date: Sep 2008
Location: Bulgaria
Posts: 138
Thanked 6 Times in 6 Posts
Default My version of pkg_add :)

Hello everyone!

First this is not a new pkg_add command, it's a pkg_add command which acts a little bit different . The idea about it came when a guy from another forum was asking about how to make pkg_add to look first in some local path and if the package was not there then pkg_add should install it from a remote ftp server.

Anyway, I wanted to share this with you too, since someone may find it useful. It is written in C (I know that I would do the same if I wrote a script for that, but I rarely write scripts though ) and you can see a screenshots here. And here's the code

It's nothing much and perhaps it's a waste of time, but I like programming

Any suggestions on how to improve it are welcome!

Last edited by DNAeon; 5th October 2008 at 05:43 PM. Reason: Program name has changed! name is now `pkg_add_it`
Reply With Quote
  #2   (View Single Post)  
Old 24th September 2008
anomie's Avatar
anomie anomie is offline
Local
 
Join Date: Apr 2008
Location: Texas
Posts: 446
Thanked 69 Times in 46 Posts
Default

I like the idea. One question: I see that when searching a local path it matches a pattern. Does it also try to match a pattern for a remote ftp server?
__________________
Kill your t.v.
Reply With Quote
  #3   (View Single Post)  
Old 24th September 2008
ephemera's Avatar
ephemera ephemera is offline
Knuth's homeboy
 
Join Date: Apr 2008
Posts: 537
Thanked 49 Times in 43 Posts
Default

> Does it also try to match a pattern for a remote ftp server?

that would be my feature request too.
Reply With Quote
  #4   (View Single Post)  
Old 24th September 2008
vermaden's Avatar
vermaden vermaden is offline
Administrator
 
Join Date: Apr 2008
Location: pl_PL.lodz
Posts: 1,052
Thanked 118 Times in 93 Posts
Default

Quote:
Originally Posted by DNAeon View Post
Hello everyone!

First this is not a new pkg_add command, it's a pkg_add command which acts a little bit different .
Very nice mate, add a post to lists.freebsd.org also, maybe you will start new base system utility.
__________________
religions, worst damnation of mankind
"If 386BSD had been available when I started on Linux, Linux would probably never had happened." Linus Torvalds

Linux is not UNIX! Face it! It is not an insult. It is fact: GNU is a recursive acronym for “GNU's Not UNIX”.
vermaden's: links resources deviantart spreadbsd
Reply With Quote
  #5   (View Single Post)  
Old 24th September 2008
Weaseal's Avatar
Weaseal Weaseal is offline
Package Pilot
 
Join Date: May 2008
Location: East Coast, US
Posts: 177
Thanked 7 Times in 7 Posts
Default

Quote:
Originally Posted by DNAeon View Post
First this is not a new pkg_add command, it's a pkg_add command which acts a little bit different . The idea about it came when a guy from another forum was asking about how to make pkg_add to look first in some local path and if the package was not there then pkg_add should install it from a remote ftp server.
You can sort of already do this with pkg_replace, which is in ports:
Code:
export PKGREPO=/usr/mypackages
export PACKAGEROOT=""
pkg_replace -P $PKGREPO/file.tgz
Granted your way seems to tie this together a lot easier, and this won't search online after it's done there anyway.
__________________
FreeBSD addict since 4.2-RELEASE.
My FreeBSD wiki.
Reply With Quote
  #6   (View Single Post)  
Old 24th September 2008
DNAeon DNAeon is offline
Shell Scout
 
Join Date: Sep 2008
Location: Bulgaria
Posts: 138
Thanked 6 Times in 6 Posts
Default

Quote:
Originally Posted by anomie
I like the idea. One question: I see that when searching a local path it matches a pattern. Does it also try to match a pattern for a remote ftp server?
No.
If you look at the code you'll see that it first tries to find every single match of the given pattern in the given path and make a list of them, so you can choose which one for example to install. This way if don't even know the real name of the package you will still have the chance to choose from a list of available options. If no match is found there then it tries to fetch it and install it from a remote FTP server (just using pkg_add -r pattern for this one)

For example if you run:
Code:
smart_add /cdrom/packages/ blablabla
And there is no found pattern it will run pkg_add this way assuming that the package is not in /cdrom/packages/ but it's a real name of package which will be installed from the ftp server:
Code:
pkg_add -r blablabla
This of course will not work if the package is not in the ftp server, but I think that your idea about searching a pattern on an ftp server is very good. Thanks for that idea! I'll give it a shot with this one - try to add a feature that searches an ftp server for a given pattern and include it in the program. I think that libcurl would do the job.

Quote:
Originally Posted by vermaden
Very nice mate, add a post to lists.freebsd.org also, maybe you will start new base system utility.
Thanks vermaden, maybe I'll will, but first I think that I have to include some extra features in it (like the one anomie and ephemera suggested) so it will be really useful (if of course someone finds it useful anyway) and that's why I posted here first, so I can gather up some ideas in my mind which to include in the code later

Quote:
Originally Posted by Weaseal
You can sort of already do this with pkg_replace, which is in ports:
Code:
export PKGREPO=/usr/mypackages
export PACKAGEROOT=""
pkg_replace -P $PKGREPO/file.tgz
Granted your way seems to tie this together a lot easier, and this won't search online after it's done there anyway.
I'm sorry, I didn't understand you. I know nothing about pkg_replace, but from what I've learned about it it is a tool for upgrading packages - just like portupgrade is. The program I wrote is not trying to upgrade any existing package, but installs it instead.
Of course you can easily change the behaviour of the program if you just change the CMD* macros In fact now I've got another idea on how to improve it - I'll add a command-line options for the various pkg_* commands - pkg_add, pkg_delete, pkg_info, etc.. and upon that option the specified action will be taken onto the chosen package.

Wow, that is long post I've written, hope I didn't bored you from reading

Thanks everyone!
Reply With Quote
  #7   (View Single Post)  
Old 24th September 2008
vermaden's Avatar
vermaden vermaden is offline
Administrator
 
Join Date: Apr 2008
Location: pl_PL.lodz
Posts: 1,052
Thanked 118 Times in 93 Posts
Default

Quote:
Originally Posted by DNAeon View Post
Thanks vermaden, maybe I'll will, but first I think that I have to include some extra features in it (like the one anomie and ephemera suggested) so it will be really useful (if of course someone finds it useful anyway) and that's why I posted here first, so I can gather up some ideas in my mind which to include in the code later
Maybe only some features you implemented will be just added to pkg_add for example.

You can sure start your port right now (under /usr/ports/ports-mgmt category), just post your source code on lists.freebsd.org ( really, they dont bite :] ) and talk to developers/contributors. You will get a lot more beta testers and feature requests at the same time.

I can only wish you good luck for moving and polishing it to be ready for the base system
__________________
religions, worst damnation of mankind
"If 386BSD had been available when I started on Linux, Linux would probably never had happened." Linus Torvalds

Linux is not UNIX! Face it! It is not an insult. It is fact: GNU is a recursive acronym for “GNU's Not UNIX”.
vermaden's: links resources deviantart spreadbsd
Reply With Quote
  #8   (View Single Post)  
Old 25th September 2008
J65nko J65nko is offline
Administrator
 
Join Date: May 2008
Location: Budel - the Netherlands
Posts: 3,246
Thanked 182 Times in 149 Posts
Default

OpenBSD has a environment variable PKG_PATH which you can set to a mix of local and remote directories.
Code:
     PKG_PATH     If a given package name cannot be found, the directories
                  named by PKG_PATH are searched.  It should contain a series
                  of entries separated by colons.  Each entry consists of a
                  directory name, ending in a slash.  URL schemes such as FTP,
                  HTTP, HTTPS, or SCP are also appropriate.  The current di-
                  rectory may be indicated implicitly by an empty directory
                  name, or explicitly by a single period (`./').
Doesn't the FreeBSD PKG_PATH do something similar? From the FBSD pkg_add man page:
Code:
     The value of the PKG_PATH is used if a given package cannot be found.
     The environment variable should be a series of entries separated by
     colons.  Each entry consists of a directory name.	The current directory
     may be indicated implicitly by an empty directory name, or explicitly by
     a single period.
The question of course is what in the FreeBSD PKG_PATH is a 'directory name'

FreeBSD pkg_add also knows PACKAGESITE. From the FBSD man page
Code:
     The environment variable PACKAGESITE specifies an alternate location for
     pkg_add to fetch from.  This variable subverts the automatic directory
     logic that pkg_add uses when the -r option is invoked.  Thus it should be
     a complete URL to the remote package file(s).
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump
Reply With Quote
  #9   (View Single Post)  
Old 25th September 2008
DNAeon DNAeon is offline
Shell Scout
 
Join Date: Sep 2008
Location: Bulgaria
Posts: 138
Thanked 6 Times in 6 Posts
Default

@J65nko

Yes, I could use these environment variables to set up an alternate location for the packages and they would be used when pkg_add is invoked.

The idea about the program is that you don't have to know the full name of the package (like in the screenshot above), so the program will search for a match of the given pattern and let you choose which package to install.

Thus if you want to install some of the xorg-fonts-* package, first you'll have to find the package, take it's full name and then install it with pkg_add.
For example if the package files are in /cdrom/packages/All/ perhaps you'll have to do something like this:
Code:
# find /cdrom/packages/All/ -name "xorg-fonts*" -print
--- some output here ---
# pkg_add /cdrom/packages/All/xorg-fonts-cyrillic-7.3.tbz # just an example
And if you do that with the above program, you'll just run a single command
Code:
# smart_add /cdrom/packages/ xorg-font
And then you can interactively choose which package to install, since you'll have all the available packages which match xorg-font for example.

Anyway you could still set these env variables to point to some FTP site(s) since when no matching pattern is found the program invokes pkg_add -r pattern and then the FTP sites will be searched for the package.

But as I mentioned in my first post - "this is not a new pkg_add command, it's a pkg_add command which acts a little bit different" - this way giving you the chance to search for a pattern and of course a little bit interactivity which I think pkg_add doesn't provide.

Cheers
<DNAeon>
Reply With Quote
Old 26th September 2008
DNAeon DNAeon is offline
Shell Scout
 
Join Date: Sep 2008
Location: Bulgaria
Posts: 138
Thanked 6 Times in 6 Posts
Default

Hi, again!

As vermaden suggested I sent an email to lists.freebsd.org (freebsd-ports@freebsd.org) about 24+ hours ago, but I didn't get a copy of my email to my mail account and the post isn't listed in the Archive section too.

This is my first post sent the mailing lists at FreeBSD, is it normal that after 24+ hours the post is still not processed?
Reply With Quote
Old 26th September 2008
vermaden's Avatar
vermaden vermaden is offline
Administrator
 
Join Date: Apr 2008
Location: pl_PL.lodz
Posts: 1,052
Thanked 118 Times in 93 Posts
Default

Sent emails to stable and current MLs.
__________________
religions, worst damnation of mankind
"If 386BSD had been available when I started on Linux, Linux would probably never had happened." Linus Torvalds

Linux is not UNIX! Face it! It is not an insult. It is fact: GNU is a recursive acronym for “GNU's Not UNIX”.
vermaden's: links resources deviantart spreadbsd
Reply With Quote
Old 26th September 2008
DNAeon DNAeon is offline
Shell Scout
 
Join Date: Sep 2008
Location: Bulgaria
Posts: 138
Thanked 6 Times in 6 Posts
Default

Thank you for your continuous support vermaden!

I've subscribed in the freebsd-stable and freebsd-current MLs too, and sent emails to these lists too ( freebsd-stable@freebsd.org and freebsd-current@freebsd.org ) and it's been about 4 hours since I sent those mail and I haven't still received a copy of my mails - so they are not already posted in the lists I think.

I guess it takes some time till the sent emails get posted, or not?
Reply With Quote
Old 26th September 2008
vermaden's Avatar
vermaden vermaden is offline
Administrator
 
Join Date: Apr 2008
Location: pl_PL.lodz
Posts: 1,052
Thanked 118 Times in 93 Posts
Default

No problem mate.

As for the current you should get at least info that you your post need to be aprooved.

Strange thing, It worked for, but indeed you have to wait little longer for messages to appear in the [Archive], dunno what else to try here, maybe try to add your source code as an attachement instead of links, maybe some antispam cut your message, generally try message without any links.
__________________
religions, worst damnation of mankind
"If 386BSD had been available when I started on Linux, Linux would probably never had happened." Linus Torvalds

Linux is not UNIX! Face it! It is not an insult. It is fact: GNU is a recursive acronym for “GNU's Not UNIX”.
vermaden's: links resources deviantart spreadbsd
Reply With Quote
Old 26th September 2008
DutchDaemon's Avatar
DutchDaemon DutchDaemon is offline
Real Name: Ben
Spam Refugee
 
Join Date: Jul 2008
Location: Rotterdam, The Netherlands
Posts: 337
Thanked 32 Times in 30 Posts
Default

Messages to the stable list are sent out immediately. Have you selected the option to receive your own e-mails through the list when signing up? I think it defaults to 'no' on Mailman lists.
Reply With Quote
Old 27th September 2008
DNAeon DNAeon is offline
Shell Scout
 
Join Date: Sep 2008
Location: Bulgaria
Posts: 138
Thanked 6 Times in 6 Posts
Default

The problem was in my mail server - qmail was keeping the messages in its queue for unknown reason - only messages sent to freebsd.org were left in the queue, so I had to flush the queue and now I'll see the results.

@DutchDaemon
The option is set to 'YES' by default and I haven't changed it.

I'll post back later for the result
Reply With Quote
Old 27th September 2008
DNAeon DNAeon is offline
Shell Scout
 
Join Date: Sep 2008
Location: Bulgaria
Posts: 138
Thanked 6 Times in 6 Posts
Default

The program is in the list now By tomorrow I guess I'll have a working version of the program which allows searching an FTP server for a package.

Cheers
--
DNAeon

Last edited by J65nko; 28th September 2008 at 07:03 AM. Reason: Thread drift prevention, send DNAeon a PM with the deleted qmail question and asked to start a new thread about it
Reply With Quote
Old 1st October 2008
DNAeon DNAeon is offline
Shell Scout
 
Join Date: Sep 2008
Location: Bulgaria
Posts: 138
Thanked 6 Times in 6 Posts
Default New version of the program with FTP search support..

Hi, again!

I've finished the new version of the program. I decided to name it pkg_add_it - pkg_add Interactive Tool

pkg_add_it now supports the following:
  • improved code for dynamic memory allocation
  • local package pattern search
  • remote (ftp) package pattern search
  • command line arguments to specify a local or remote installation
  • uses some env variables like PACKAGEROOT, OSRELEASE and MACHTYPE to determite which package and from where to be installed

The remote/ftp package pattern search is done by searching the INDEX file for a pattern and extracting the needed information from it. The program uses a default values for these environment variables if they have not been set:

It doesn't have any requirements, so it should build and run on any system that has fetch and pkg_add support.

Screenshots of various usage of the program can be found here:
http://unix-heaven.org/doc/pkg_add_it/gfx/

And the code is here:
http://unix-heaven.org/ports-mgmt/pkg_add_it-1.0.tar.gz

Well, I hope someone finds it useful

P.S: If someone have any suggestions on how to improve more - let me know

Cheers!

--DNAeon

Last edited by DNAeon; 5th October 2008 at 05:45 PM. Reason: Program name has changed!
Reply With Quote
Old 1st October 2008
Weaseal's Avatar
Weaseal Weaseal is offline
Package Pilot
 
Join Date: May 2008
Location: East Coast, US
Posts: 177
Thanked 7 Times in 7 Posts
Default

Quote:
Originally Posted by DNAeon View Post
I'm sorry, I didn't understand you. I know nothing about pkg_replace, but from what I've learned about it it is a tool for upgrading packages - just like portupgrade is. The program I wrote is not trying to upgrade any existing package, but installs it instead.
Of course you can easily change the behaviour of the program if you just change the CMD* macros In fact now I've got another idea on how to improve it - I'll add a command-line options for the various pkg_* commands - pkg_add, pkg_delete, pkg_info, etc.. and upon that option the specified action will be taken onto the chosen package.
pkg_replace -N will install new ports.
__________________
FreeBSD addict since 4.2-RELEASE.
My FreeBSD wiki.
Reply With Quote
Old 1st October 2008
DutchDaemon's Avatar
DutchDaemon DutchDaemon is offline
Real Name: Ben
Spam Refugee
 
Join Date: Jul 2008
Location: Rotterdam, The Netherlands
Posts: 337
Thanked 32 Times in 30 Posts
Default

Is one supposed to define $OSRELEASE? All I have is $OSTYPE (freebsd7.0) and $MACHTYPE (i386-portbld-freebsd7.0). I guess calling 'uname -r' would be sufficient (7.1-PRERELEASE in my case).

Last edited by DutchDaemon; 1st October 2008 at 01:35 PM.
Reply With Quote
Old 1st October 2008
DNAeon DNAeon is offline
Shell Scout
 
Join Date: Sep 2008
Location: Bulgaria
Posts: 138
Thanked 6 Times in 6 Posts
Default

Quote:
Originally Posted by DutchDaemon
Is one supposed to define $OSRELEASE? All I have is $OSTYPE (freebsd7.0) and $MACHTYPE (i386-portbld-freebsd7.0). I guess calling 'uname -r' would be sufficient (7.1-PRERELEASE in my case).
I decided to use the name OSRELEASE for the env variable since actually, there is no such a variable and that way when you run the program it will use it's value.

If you for example run FreeBSD 6.2 and want to install a package which is included in FreeBSD-8-CURRENT for example you will need to set $OSRELEASE = 8-current (which is the default behaviour), so the program will fetch the package file from 8-current directory of the FTP server.

I wanted to keep the code cleaner so that way only env variables will do the job.

====
EDIT:
The program is called now `pkg_add_it` - pkg_add interactive interface.

There are a few changes made to the code and I've included also a small but useful feature - a pager.
Now the program uses a pager defined by $PAGER for browsing through the package list.

Also the port has been submitted to the FreeBSD ports tree, so let's hope that it will be added soon to the ports tree
When this happens it will be under ports-mgmt/pkg_add_it

All best,
DNAeon

Last edited by DNAeon; 5th October 2008 at 05:49 PM. Reason: Program name has changed!!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
pkg_add problems with connecting Mr-Biscuit NetBSD Package System (pkgsrc) 2 26th May 2009 11:44 AM
pkg_add - can't resolve <packagename> nihonto OpenBSD Packages and Ports 11 28th January 2009 10:03 PM
pkg_add g95;g95 x.f95: cannot find g95 enpey OpenBSD Packages and Ports 8 27th August 2008 12:48 AM
pkg_add -r does not use exported packagesite kasse FreeBSD Ports and Packages 16 26th August 2008 08:42 PM
pkg_add error buba OpenBSD Packages and Ports 4 13th June 2008 03:29 PM


All times are GMT. The time now is 10:52 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick