View previous topic :: View next topic |
Author |
Message |
belgarion n00b
Joined: 22 Jul 2003 Posts: 26
|
Posted: Fri Sep 05, 2003 2:10 pm Post subject: Script for networkless installs... |
|
|
As of Portage 2.0.49, the script "dl-list.sh" no longer works (well) for getting a list of download URLs, and the old "grep '://'" method doesn't work either, since emerge -pf now outputs two separate outputs: the URLs to standard error (unformatted, just in a jumble, even the URLs for files you already have) and the src_uri checks of already gotten files to standard output.
Since that script is life for anyone who doesn't have a network connection on their Gentoo PC, I was at a loss, and decided to write my own, since I'm learning (this actually used about 95% of what I'd just learned about *nix utilities) so I wrote a script I call "epack" on my system. All you have to do is type "epack packagename >> package.lst" or something of the sort to allow it to get all the URLs for files you still need and place them in package.lst.
epack -UD world also works. (For less confusion with the script, I'd suggest -UuD world)
Here we go:
Code: | #!/bin/bash
urls=`mktemp` # urls go here
md5=`mktemp` # src_uri's go here
files=`mktemp` # actual filenames here
urls2=`mktemp` # we swap between them with sed...
# Get the files
emerge -fp $@ >/dev/null >$md5 2>$urls
# Prepare the URLs:
grep '://' $urls | xargs -n1 echo | uniq > $urls2
cp $urls2 $urls > /dev/null
# Now prepare the files that we already have:
# /'s screw up sed and are a clear indicator of a non-file
cat $md5 | sed -e '1 d' -e '/\// d' > $files
cp $files $md5 > /dev/null
# And every file in Portage has a . in it somewhere:
cat $md5 | xargs -n1 echo | grep '\.' | uniq > $files
cp $files $md5 > /dev/null
# Delete the URLs for files we already have.
for i in `cat $md5`; do
cat $urls | sed "/"$i"/ d" > $urls2
cp $urls2 $urls > /dev/null
done
# Now print the URLs.
cat $urls
# And remove the files.
rm -f $urls $urls2 $md5 $files
|
It's not as efficient as it could be, and after every run of the program it leaves a little garbage that wget complains about, but it works really well
epack -e world is pretty fast on my system even with 350 packages installed... so there you go |
|
Back to top |
|
|
pilla Bodhisattva
Joined: 07 Aug 2002 Posts: 7729 Location: Underworld
|
Posted: Sat Sep 06, 2003 3:34 am Post subject: |
|
|
Moved to D, T & T, thanks slartibartfasz _________________ "I'm just very selective about the reality I choose to accept." -- Calvin |
|
Back to top |
|
|
belgarion n00b
Joined: 22 Jul 2003 Posts: 26
|
Posted: Sat Sep 06, 2003 1:46 pm Post subject: |
|
|
Wasn't sure if it belonged in Installing or DT&T... thanks |
|
Back to top |
|
|
OneOfOne Guru
Joined: 28 May 2003 Posts: 368
|
Posted: Thu Sep 11, 2003 10:06 am Post subject: |
|
|
i really like your script and i think it's very useful and i wanted to share a php version of it i made in my spare time.
to use just chmod +x it and execute it or php emerge_list whatever.
Code: | #!/usr/bin/php
<?php
# emerge_list : a script by OneOfOne (OneOfOne{at}limitlessfx{dot}com)
# to generate a list of files that needs to by downloaded for a package, mainly for dialup users.
# this needs >=php-4.3.2 (should work on lower versions but i haven't tried).
# use :
# chmod +x emerge_list && ./emerge_list blah blah blah -emerge_arg OR
# php emerge_list blah blah blah -emerge_arg
# ./emerge_list package > wget_list
# wget -c -i wget_list //you MUST add -c to wget or it'll redownload the file from each mirror.
#ps you need "register_argc_argv = On" in php.ini
$exit ="You must supply atleast 1 valid arg.\n";
if($argc > 1){
unset($argv[0]);
$args = trim(join(" ", $argv));
if($args){
$eo = trim(str_replace("\n", "", shell_exec("emerge -fp $args 2>&1 >/dev/null")));
$old_eo = explode(" ", $eo);
foreach($old_eo as $str){
if(strpos($str,"http://")!==FALSE || strpos($str,"ftp://")!==FALSE)
print($str."\n");
}
$exit="";
}
}
exit($exit);
?> |
peace |
|
Back to top |
|
|
TGL Bodhisattva
Joined: 02 Jun 2002 Posts: 1978 Location: Rennes, France
|
|
Back to top |
|
|
Omega21 l33t
Joined: 14 Feb 2004 Posts: 788 Location: Canada (brrr. Its cold up here)
|
Posted: Sun Feb 15, 2004 5:39 am Post subject: THANK YOU~~ |
|
|
Thank you soooo much for your work!!!
Many hours of time have been wasted with dl-list.sh
I appreciate your time.
THANK YOU! _________________ iMac G4 1GHz :: q6600 //2x 500GB//2GB RAM//8600GT//Gentoo :: MacBook Pro//2.53GHz |
|
Back to top |
|
|
|