ÿØÿà JFIF    ÿÛ „  ( %"1!%)+...383,7(-.+  -+++--++++---+-+-----+---------------+---+-++7-----ÿÀ  ß â" ÿÄ     ÿÄ H    !1AQaq"‘¡2B±ÁÑð#R“Ò Tbr‚²á3csƒ’ÂñDS¢³$CÿÄ   ÿÄ %  !1AQa"23‘ÿÚ   ? ôÿ ¨pŸªáÿ —åYõõ\?àÒü©ŠÄï¨pŸªáÿ —åYõõ\?àÓü©ŠÄá 0Ÿªáÿ Ÿå[úƒ ú®ði~TÁbqÐ8OÕpÿ ƒOò¤Oè`–RÂáœá™êi€ßÉ< FtŸI“öÌ8úDf´°å}“¾œ6  öFá°y¥jñÇh†ˆ¢ã/ÃÐ:ªcÈ "Y¡ðÑl>ÿ ”ÏËte:qž\oäŠe÷󲍷˜HT4&ÿ ÓÐü6ö®¿øþßèô Ÿ•7Ñi’•j|“ñì>b…þS?*Óôÿ ÓÐü*h¥£ír¶ü UãS炟[AÐaè[ûª•õ&õj?†Éö+EzP—WeÒírJFt ‘BŒ†Ï‡%#tE Øz ¥OÛ«!1›üä±Í™%ºÍãö]°î(–:@<‹ŒÊö×òÆt¦ãº+‡¦%ÌÁ²h´OƒJŒtMÜ>ÀÜÊw3Y´•牋4ǍýʏTì>œú=Íwhyë,¾Ôò×õ¿ßÊa»«þˆѪQ|%6ž™A õ%:øj<>É—ÿ Å_ˆCbõ¥š±ý¯Ýƒï…¶|RëócÍf溪“t.СøTÿ *Ä¿-{†çàczůŽ_–^XþŒ±miB[X±d 1,é”zEù»& î9gœf™9Ð'.;—™i}!ôšåîqêÛ٤ёý£½ÆA–àôe"A$˝Úsäÿ ÷Û #°xŸëí(l »ý3—¥5m! rt`†0~'j2(]S¦¦kv,ÚÇ l¦øJA£Šƒ J3E8ÙiŽ:cÉžúeZ°€¯\®kÖ(79«Ž:¯X”¾³Š&¡* ….‰Ž(ÜíŸ2¥ª‡×Hi²TF¤ò[¨íÈRëÉ䢍mgÑ.Ÿ<öäS0í„ǹÁU´f#Vß;Õ–…P@3ío<ä-±»Ž.L|kªÀê›fÂ6@»eu‚|ÓaÞÆŸ…¨ááå>åŠ?cKü6ùTÍÆ”†sĤÚ;H2RÚ†õ\Ö·Ÿn'¾ ñ#ºI¤Å´%çÁ­‚â7›‹qT3Iï¨ÖÚ5I7Ë!ÅOóŸ¶øÝñØôת¦$Tcö‘[«Ö³šÒ';Aþ ¸èíg A2Z"i¸vdÄ÷.iõ®§)¿]¤À†–‡É&ä{V¶iŽ”.Ó×Õÿ û?h¬Mt–íª[ÿ Ñÿ ÌV(í}=ibÔ¡›¥¢±b Lô¥‡piη_Z<‡z§èŒ)iÖwiÇ 2hÙ3·=’d÷8éŽ1¦¸c¤µ€7›7Ø ð\á)} ¹fËí›pAÃL%âc2 í§æQz¿;T8sæ°qø)QFMð‰XŒÂ±N¢aF¨…8¯!U  Z©RÊ ÖPVÄÀÍin™Ì-GˆªÅËŠ›•zË}º±ŽÍFò¹}Uw×#ä5B¤{î}Ð<ÙD é©¤&‡ïDbàÁôMÁ." ¤‡ú*õ'VŽ|¼´Úgllº¼klz[Æüï÷Aób‡Eÿ dÑ»Xx9ÃÜ£ÁT/`¼¸vI±Ýµ·Ë‚“G³þ*Ÿû´r|*}<¨îºœ @¦mÄ’M¹”.œ«Y–|6ÏU¤jç¥ÕÞqO ˜kDÆÁ¨5ÿ š;ÐЦ¦€GÙk \ –Þ=â¼=SͧµªS°ÚÍpÜãQűÀõ¬?ÃÁ1Ñ•õZà?hóœ€ L¦l{Y*K˜Ù›zc˜–ˆâ ø+¾ ­-Ök¥%ùEÜA'}ˆ><ÊIè“bpÍ/qÞâvoX€w,\úªò6Z[XdÒæ­@Ö—€$òJí#é>'°Ú ôª˜<)4ryÙ£|óAÅn5žêŸyÒäMÝ2{"}‰–¤l÷ûWX\l¾Á¸góÉOÔ /óñB¤f¸çñ[.P˜ZsÊË*ßT܈§QN¢’¡¨§V¼(Üù*eÕ“”5T¨‹Âê¥FŒã½Dü[8'Ò¥a…Ú¶k7a *•›¼'Ò·\8¨ª\@\õ¢¦íq+DÙrmÎ…_ªæ»ŠÓœ¡¯’Ré9MÅ×D™lælffc+ŒÑ,ý™ÿ ¯þǤ=Å’Á7µ÷ÚÛ/“Ü€ñýã¼àí¾ÕÑ+ƒ,uµMâÀÄbm:ÒÎPæ{˜Gz[ƒ¯«® KHà`ߨŠéí¯P8Aq.C‰ à€kòpj´kN¶qô€…Õ,ÜNŠª-­{Zö’æû44‰sŽè‰îVíRœÕm" 6?³D9¡ÇTíÅꋇ`4«¸ÝÁô ï’ýorqКÇZ«x4Žâéþuïf¹µö[P ,Q£éaX±`PÉÍZ ¸äYúg üAx ’6Lê‚xÝÓ*äQ  Ï’¨hÍ =²,6ï#rÃ<¯–£»ƒ‹,–ê•€ aÛsñ'%Æ"®ÛüìBᝠHÚ3ß°©$“XnœÖ’î2ËTeûìxîß ¦å¿çÉ ðK§þ{‘t‚Ϋ¬jéîZ[ ”š7L¥4VÚCE×]m¤Øy”ä4-dz£œ§¸x.*ãÊÊ b÷•h:©‡¦s`BTÁRû¾g⻩‹jø sF¢àJøFl‘È•Xᓁà~*j¯ +(ÚÕ6-£¯÷GŠØy‚<Ç’.F‹Hœw(+)ÜÜâÈzÄäT§FߘãÏ;DmVœ3Àu@mÚüXÝü•3B¨òÌÁÛ<·ÃÜ z,Ì@õÅ·d2]ü8s÷IôÞ¯^Ç9¢u„~ëAŸï4«M? K]­ÅàPl@s_ p:°¬ZR”´›JC[CS.h‹ƒïËœ«Æ]–÷ó‚wR×k7X‰k›‘´ù¦=¡«‰¨¨Â')—71ó’c‡Ðúµ `é.{§p¹ój\Ž{1h{o±Ý=áUÊïGÖŒõ–-BÄm+AZX¶¡ ïHðæ¥JmÙ;…䡟ˆ¦ ° äšiÉg«$üMk5¤L“’çÊvïâï ,=f“"íἊ5ô¬x6{ɏžID0e¸vçmi'︧ºð9$ò¹÷*£’9ÿ ²TÔ…×>JV¥}Œ}$p[bÔ®*[jzS*8 ”·T›Í–ñUîƒwo$áè=LT™ç—~ô·¤ÈÚ$榍q‰„+´kFm)ž‹©i–ËqÞŠ‰à¶ü( ‚•§ •°ò·‡#5ª•µÊ﯅¡X¨šÁ*F#TXJÊ ušJVÍ&=iÄs1‚3•'fý§5Ñ<=[íÞ­ PÚ;ѱÌ_~Ä££8rÞ ²w;’hDT°>ÈG¬8Á²ÚzŽ®ò®qZcqJêäÞ-ö[ܘbň±çb“ж31²n×iƒðÕ;1¶þÉ ªX‰,ßqÏ$>•î íZ¥Z 1{ç൵+ƒÕµ¥°T$§K]á»Ûï*·¤tMI’ÂZbŽÕiÒ˜}bÓ0£ª5›¨ [5Ž^ÝœWøÂÝh° ¢OWun£¤5 a2Z.G2³YL]jåtì”ä ÁÓ‘%"©<Ôúʰsº UZvä‡ÄiÆÒM .÷V·™ø#kèýiíÌ–ª)µT[)BˆõÑ xB¾B€ÖT¨.¥~ð@VĶr#¸ü*åZNDŽH;âi ],©£öØpù(šºãö¼T.uCê•4@ÿ GÕÛ)Cx›®0ø#:ÏðFÒbR\(€€Ä®fã4Þ‰Fä¯HXƒÅ,†öEÑÔÜ]Öv²?tLÃvBY£ú6Êu5ÅAQ³1‘’¬x–HŒÐ‡ ^ ¸KwJôÖŽ5×CÚ¨vÜ«/B0$×k°=ðbÇ(Ï)w±A†Á† 11Í=èQšµ626ŒÜ/`G«µ<}—-Ö7KEHÈÉðóȤmݱû±·ø«Snmá=“䫚mݱŸ¡¶~ó·“äUóJæúòB|E LêŽy´jDÔ$G¢þÐñ7óR8ýÒ…Ç› WVe#·Ÿ p·Fx~•ݤF÷0Èÿ K¯æS<6’¡WШ; ´ÿ ¥Êø\Òuî†åÝ–VNœkÒ7oòX¨Á­Ø÷FÎÑä±g÷ÿ M~Çî=p,X´ ÝÌÚÅ‹’ÃjÖ.ØöÏñ qïQ¤ÓZE†° =6·]܈ s¸>v•Ž^Ý\wq9r‰Î\¸¡kURÒ$­*‹Nq?Þª*!sŠÆ:TU_u±T+øX¡ ®¹¡,ÄâÃBTsÜ$Ø›4m椴zÜK]’’›Pƒ @€#â˜`é¹=I‡fiV•Ôî“nRm+µFPOhÍ0B£ €+¬5c v•:P'ÒyÎ ‰V~‚Ó†ÖuókDoh$å\*ö%Ю=£«…aȼ½÷Û.-½VŒŠ¼'lyî±1¬3ó#ÞE¿ÔS¤gV£m›=§\û"—WU¤ÚǼÿ ÂnÁGŒÃ ‚õN D³õNÚíŒÕ;HôyÄÈ©P¹Ä{:?R‘Ô¨âF÷ø£bÅó® JS|‚R÷ivýáâ€Æé¡è³´IئÑT!§˜•ت‚¬â@q€wnïCWÄ@JU€ê¯m6]Ï:£âx'+ÒðXvÓ¦Úm=–´7œ $ì“B£~p%ÕŸUþ« N@¼üï~w˜ñø5®—'Ôe»¤5ã//€ž~‰Tþ›Å7•#¤× Íö pÄ$ùeåì*«ÓŠEØWEÈsßg ¦ûvžSsLpºÊW–âµEWöˬH; ™!CYõZ ÃÄf æ#1W. \uWâ\,\Çf j’<qTbên›Î[vxx£ë 'ö¨1›˜ÀM¼Pÿ H)ƒêêŒA7s,|F“ 꺸k³9Ìö*ç®;Ö!Ö$Eiž•¹ÒÚ†ýóéÝû¾ÕS®ó$’NÝäŸz¤5r¦ãÄÃD÷Üø!°ø‡Ô&@m™Ì^Ãä­d q5Lnÿ N;.6½·N|#ä"1Nƒx“ã<3('&ñßt  ~ªu”1Tb㫨9ê–›–bìd$ߣ=#ÕãÒmU¯eí$EFù5ýYô櫨æì™Ç—±ssM]·á¿0ÕåJRÓªîiƒ+O58ÖñªŠÒx" \µâá¨i’¤i —Ö ” M+M¤ë9‚‰A¦°Qõ¾ßøK~¼Ã‘g…Ö´~÷Ï[3GUœÒ½#…kàÔ®Ò”‰³·dWV‰IP‰Ú8u¹”E ÖqLj¾êÕCBš{A^Âß;–¨`¯¬ìö ˼ ×tìø.tƐm*n¨y4o&Àx¥n¦×î‡aupáÛj8¿m›è¶ã!o½;ß0y^ý×^EÑ¿ÒjzŒ­)vÚÑnÄL …^ªô× ‡—‚3k Îý­hï]içå–îÏ*÷ñþ»Ô CÒjøjÍznˆ´ ¹#b'Fô‹ ‰v¥'’à'T´ƒHýÍ%M‰ ƒ&ÆÇŒï1 ‘ –Þ ‰i¬s žR-Ÿ kЬá¬7:þ 0ŒÅÒÕ/aÙ¬ÃÝ#Úøœ ©aiVc‰. ¹¦ãµ” ›Yg¦›ÆÎýº°f³7ƒhá·¸­}&D9¡ÂsÉÙÞèŠõØàC™¨ñbFC|´Ü(ŸƒÚÒ-%»'a Ì¿)ËÇn¿úÿ ÞŽX…4ÊÅH^ôΑí@ù¹Eh¶“L8Çjù ¼ÎåVªóR©Ï5uà V4lZß®=€xÖŸ–ÑÈ ÷”¨°¾__yM1tÉ?uÆþIkÄgæ@þ[¢†°XÃJ£j·:nkÅ¢u ‘}âGzö­/IµèЬ¼48q¦F°ŽR¼=ûì{´¯RýicS ÕÛ íNtÍÙï£,w4rêì®»~x(©Uñ§#Ñ&œÕ¤>ÎåÍÓ9’Ö{9eV­[Öjâ²ãu]˜å2›qÑšÕJç0€sÄ|Êëè0튔bÁ>“{×_F`Ø©ºê:µä,v¤ðfc1±"«ÔÍän1#=· Âøv~H½ÐßA¾¿Ü€Óš]Õ; I¾÷ç‚Qi†î¹9ywÔKG˜áñ zQY—§ÃÕZ07§X‚ Áh;ÁM)iÌCH-¯T‘ë|A0{Ò½LÚ–TâÖkÜ’dÀ“rmm»”جPF³ÖcbE§T€ÒxKºû’Ó®7±²(\4ŽÃ¸Uu@j™yĵ;³µ!Á¢b.W¤=mõ´êµK k ¸K^ÜÛ#p*Ü14qkZç5ïë †°5Ï%ÍÛ<Õ¤×Ô¥ê†C Õ´¼ú$ƒÖ“”]Ù¬qÞÚ[4©ý!ûÏ—Áb쳐XµA¬â~`›Çr¸8ìùÝ䫦<>ä÷«?xs´ÇÑ /á;¹øüÊÈÙà{"@Žïzâ¬[âß‚ U_<ÇŸ½4èN˜ú61®qŠu ¦þF£»äJ_ˆÙÎ~ ÞAã–݄ϗrŠD;xTž‘ô`É«…suãO`?³à™ô Lý#Íc5öoæØ‚y´´÷«ZR§<&JÇ+éâô´€i!Àˆ0æAoàðLèÖ-2ŸõW.’t^–(KÁmHµV@xÜÇy®Ñø­â^:Ú3w· 7½¹°ñ¸â¹®:',«Mœ—n­Á+Ãbš LÈ‘ÄnRÓÅœ%¦²‰¨ùQ:¤f‚ "PÕtô¸…cæl…&˜Ú˜Ôkv‹ž+vŠ,=¢v­6—Xy*¥t£«<™:“aîϲ=¦6rO]XI¿Œ÷¤zÚ­›¶ 6÷”w\d ü~v®ˆÌk«^m<ÿ ¢‰Õ\)ùºŽ;… lîÙÅEŠ®cѾ@vnMÏ,¼“ñ•ŽBxðÃzãÇç%3ˆ"}Ù•Åî> BÉú;Ò]V+P˜F_´ßé> Øše|ï‡ÄOmFæÇ ãqÞ$/xÐx­z`ï9"œÜij‚!7.\Td…9M‡•iŽ‹¾‘50ÞŽn¥ß4ÉôO ¹*í^QêËÜÇÌ8=ާs‰'ÂëÙ«á%Pú[O †ÅP¯Vsް.‰,kc¶ ¬A9n˜XÎ-ÞšN["¹QÕ‰ƒMýÁߺXJæÍaLj¾×Ãmã¾ãÚ uñÒþåQô¦¥ /ÄUx:‚ÍÜ’ Đ©ØÝ3V¨‰ÕnÐ6ó*óúK­«…c ¯U òhsý­jóÔj#,ímŒRµ«lbïUTŒÑ8†Ä0œÏr`ð¡¬É Ї ë"À² ™ 6¥ f¶ ¢ÚoܱԷ-<Àî)†a¶ž'Ú»¨TXqØæ¶÷YÄHy˜9ÈIW­YÀuMFë ºÏ’AqÌ4·/Ú †ô'i$øä­=Ä Ý|öK×40è|È6p‘0§)o¥ctî§H+CA-“ xØ|ÐXАç l8íºð3Ø:³¤¬KX¯UÿÙ #!/usr/bin/perl # # Copyright © 1996 Andy Guy # Copyright © 1998 Martin Schulze # Copyright © 1999, 2009 Raphaël Hertzog # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; version 2 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . use strict; use warnings; eval q{ pop @INC if $INC[-1] eq '.'; use Net::FTP; use File::Path qw(make_path remove_tree); use File::Basename; use File::Find; use Data::Dumper; }; if ($@) { warn "Please install the 'perl' package if you want to use the\n" . "FTP access method of dselect.\n\n"; exit 1; } use Dselect::Ftp; my $ftp; # exit value my $exit = 0; # deal with arguments my $vardir = $ARGV[0]; my $method = $ARGV[1]; my $option = $ARGV[2]; if ($option eq 'manual') { print "manual mode not supported yet\n"; exit 1; } #print "vardir: $vardir, method: $method, option: $option\n"; my $methdir = "$vardir/methods/ftp"; # get info from control file read_config("$methdir/vars"); chdir "$methdir"; make_path("$methdir/$CONFIG{dldir}", { mode => 0755 }); #Read md5sums already calculated my %md5sums; if (-f "$methdir/md5sums") { local $/; open(my $md5sums_fh, '<', "$methdir/md5sums") or die "couldn't read file $methdir/md5sums"; my $code = <$md5sums_fh>; close $md5sums_fh; my $VAR1; ## no critic (Variables::ProhibitUnusedVariables) my $res = eval $code; if ($@) { die "couldn't eval $methdir/md5sums content: $@\n"; } if (ref($res)) { %md5sums = %{$res} } } # get a block # returns a ref to a hash containing flds->fld contents # white space from the ends of lines is removed and newlines added # (no trailing newline). # die's if something unexpected happens sub getblk { my $fh = shift; my %flds; my $fld; while (<$fh>) { if (length != 0) { FLDLOOP: while (1) { if ( /^(\S+):\s*(.*)\s*$/ ) { $fld = lc($1); $flds{$fld} = $2; while (<$fh>) { if (length == 0) { return %flds; } elsif ( /^(\s.*)$/ ) { $flds{$fld} = $flds{$fld} . "\n" . $1; } else { next FLDLOOP; } } return %flds; } else { die "expected a start of field line, but got:\n$_"; } } } } return %flds; } # process status file # create curpkgs hash with version (no version implies not currently installed) # of packages we want print "Processing status file...\n"; my %curpkgs; sub procstatus { my (%flds, $fld); open(my $status_fh, '<', "$vardir/status") or die 'Could not open status file'; while (%flds = getblk($status_fh), %flds) { if($flds{'status'} =~ /^install ok/) { my $cs = (split(/ /, $flds{'status'}))[2]; if (($cs eq 'not-installed') || ($cs eq 'half-installed') || ($cs eq 'config-files')) { $curpkgs{$flds{'package'}} = ''; } else { $curpkgs{$flds{'package'}} = $flds{'version'}; } } } close($status_fh); } procstatus(); sub dcmpvers { my($a, $p, $b) = @_; my ($r); $r = system('dpkg', '--compare-versions', "$a", "$p", "$b"); $r = $r/256; if ($r == 0) { return 1; } elsif ($r == 1) { return 0; } die "dpkg --compare-versions $a $p $b - failed with $r"; } # process package files, looking for packages to install # create a hash of these packages pkgname => version, filenames... # filename => md5sum, size # for all packages my %pkgs; my %pkgfiles; sub procpkgfile { my $fn = shift; my $site = shift; my $dist = shift; my (@files, @sizes, @md5sums, $pkg, $ver, $nfs, $fld); my(%flds); open(my $pkgfile_fh, '<', $fn) or die "could not open package file $fn"; while (%flds = getblk($pkgfile_fh), %flds) { $pkg = $flds{'package'}; $ver = $curpkgs{$pkg}; @files = split(/[\s\n]+/, $flds{'filename'}); @sizes = split(/[\s\n]+/, $flds{'size'}); @md5sums = split(/[\s\n]+/, $flds{'md5sum'}); if (defined($ver) && (($ver eq '') || dcmpvers($ver, 'lt', $flds{'version'}))) { $pkgs{$pkg} = [ $flds{'version'}, [ @files ], $site ]; $curpkgs{$pkg} = $flds{'version'}; } $nfs = scalar(@files); if(($nfs != scalar(@sizes)) || ($nfs != scalar(@md5sums)) ) { print "Different number of filenames, sizes and md5sums for $flds{'package'}\n"; } else { my $i = 0; foreach my $fl (@files) { $pkgfiles{$fl} = [ $md5sums[$i], $sizes[$i], $site, $dist ]; $i++; } } } close $pkgfile_fh or die "cannot close package file $fn: $!\n"; } print "\nProcessing Package files...\n"; my ($fn, $i, $j); $i = 0; foreach my $site (@{$CONFIG{site}}) { $j = 0; foreach my $dist (@{$site->[2]}) { $fn = $dist; $fn =~ tr#/#_#; $fn = "Packages.$site->[0].$fn"; if (-f $fn) { print " $site->[0] $dist...\n"; procpkgfile($fn,$i,$j); } else { print "Could not find packages file for $site->[0] $dist distribution (re-run Update)\n" } $j++; } $i++; } my $dldir = $CONFIG{dldir}; # md5sum sub md5sum($) { my $fn = shift; my $m = qx(md5sum $fn); $m = (split(' ', $m))[0]; $md5sums{"$dldir/$fn"} = $m; return $m; } # construct list of files to get # hash of filenames => size of downloaded part # query user for each partial file print "\nConstructing list of files to get...\n"; my %downloads; my ($dir, @info, @files, $csize, $size); my $totsize = 0; foreach my $pkg (keys(%pkgs)) { @files = @{$pkgs{$pkg}[1]}; foreach my $fn (@files) { #Look for a partial file if (-f "$dldir/$fn.partial") { rename "$dldir/$fn.partial", "$dldir/$fn"; } $dir = dirname($fn); if(! -d "$dldir/$dir") { make_path("$dldir/$dir", { mode => 0755 }); } @info = @{$pkgfiles{$fn}}; $csize = int($info[1]/1024)+1; if(-f "$dldir/$fn") { $size = -s "$dldir/$fn"; if($info[1] > $size) { # partial download if (yesno('y', "continue file: $fn (" . nb($size) . '/' . nb($info[1]) . ')')) { $downloads{$fn} = $size; $totsize += $csize - int($size/1024); } else { $downloads{$fn} = 0; $totsize += $csize; } } else { # check md5sum if (! exists $md5sums{"$dldir/$fn"}) { $md5sums{"$dldir/$fn"} = md5sum("$dldir/$fn"); } if ($md5sums{"$dldir/$fn"} eq $info[0]) { print "already got: $fn\n"; } else { print "corrupted: $fn\n"; $downloads{$fn} = 0; } } } else { my $ffn = $fn; $ffn =~ s/binary-[^\/]+/.../; print 'want: ' . $CONFIG{site}[$pkgfiles{$fn}[2]][0] . " $ffn (${csize}k)\n"; $downloads{$fn} = 0; $totsize += $csize; } } } my $avsp = qx(df -Pk $dldir| awk '{ print \$4}' | tail -n 1); chomp $avsp; print "\nApproximate total space required: ${totsize}k\n"; print "Available space in $dldir: ${avsp}k\n"; #$avsp = qx(df -k $::dldir| paste -s | awk '{ print \$11}); #chomp $avsp; if($totsize == 0) { print 'Nothing to get.'; } else { if($totsize > $avsp) { print "Space required is greater than available space,\n"; print "you will need to select which items to get.\n"; } # ask user which files to get if (($totsize > $avsp) || yesno('n', 'Do you want to select the files to get')) { $totsize = 0; my @files = sort(keys(%downloads)); my $def = 'y'; foreach my $fn (@files) { my @info = @{$pkgfiles{$fn}}; my $csize = int($info[1] / 1024) + 1; my $rsize = int(($info[1] - $downloads{$fn}) / 1024) + 1; if ($rsize + $totsize > $avsp) { print "no room for: $fn\n"; delete $downloads{$fn}; } else { if(yesno($def, $downloads{$fn} ? "download: $fn ${rsize}k/${csize}k (total = ${totsize}k)" : "download: $fn ${rsize}k (total = ${totsize}k)")) { $def = 'y'; $totsize += $rsize; } else { $def = 'n'; delete $downloads{$fn}; } } } } } sub download() { my $i = 0; foreach my $site (@{$CONFIG{site}}) { my @getfiles = grep { $pkgfiles{$_}[2] == $i } keys %downloads; my @pre_dist = (); # Directory to add before $fn #Scan distributions for looking at "(../)+/dir/dir" my ($n,$cp); $cp = -1; foreach (@{$site->[2]}) { $cp++; $pre_dist[$cp] = ''; $n = (s{\.\./}{../}g); next if (! $n); if (m<^((?:\.\./){$n}(?:[^/]+/){$n})>) { $pre_dist[$cp] = $1; } } if (! @getfiles) { $i++; next; } $ftp = do_connect(ftpsite => $site->[0], ftpdir => $site->[1], passive => $site->[3], username => $site->[4], password => $site->[5], useproxy => $CONFIG{use_auth_proxy}, proxyhost => $CONFIG{proxyhost}, proxylogname => $CONFIG{proxylogname}, proxypassword => $CONFIG{proxypassword}); local $SIG{INT} = sub { die "Interrupted !\n"; }; my ($rsize, $res, $pre); foreach my $fn (@getfiles) { $pre = $pre_dist[$pkgfiles{$fn}[3]] || ''; if ($downloads{$fn}) { $rsize = ${pkgfiles{$fn}}[1] - $downloads{$fn}; print "getting: $pre$fn (" . nb($rsize) . '/' . nb($pkgfiles{$fn}[1]) . ")\n"; } else { print "getting: $pre$fn (". nb($pkgfiles{$fn}[1]) . ")\n"; } $res = $ftp->get("$pre$fn", "$dldir/$fn", $downloads{$fn}); if(! $res) { my $r = $ftp->code(); print $ftp->message() . "\n"; if (!($r == 550 || $r == 450)) { return 1; } else { #Try to find another file or this package print "Looking for another version of the package...\n"; my ($dir, $package) = ($fn =~ m{^(.*)/([^/]+)_[^/]+.deb$}); my $list = $ftp->ls("$pre$dir"); if ($ftp->ok() && ref($list)) { foreach my $file (@{$list}) { if ($file =~ m/($dir\/\Q$package\E_[^\/]+.deb)/i) { print "Package found : $file\n"; print "getting: $file (size not known)\n"; $res = $ftp->get($file, "$dldir/$1"); if (! $res) { $r = $ftp->code(); print $ftp->message() . "\n"; return 1 if ($r != 550 and $r != 450); } } } } } } # fully got, remove it from list in case we have to re-download delete $downloads{$fn}; } $ftp->quit(); $i++; } return 0; } # download stuff (protect from ^C) if($totsize != 0) { if (yesno('y', "\nDo you want to download the required files")) { DOWNLOAD_TRY: while (1) { print "Downloading files... use ^C to stop\n"; eval { if ((download() == 1) && yesno('y', "\nDo you want to retry downloading at once")) { next DOWNLOAD_TRY; } }; if($@ =~ /Interrupted|Timeout/i ) { # close the FTP connection if needed if ((ref($ftp) =~ /Net::FTP/) and ($@ =~ /Interrupted/i)) { $ftp->abort(); $ftp->quit(); undef $ftp; } print "FTP ERROR\n"; if (yesno('y', "\nDo you want to retry downloading at once")) { # get the first $fn that foreach would give: # this is the one that got interrupted. MY_ITER: foreach my $ffn (keys(%downloads)) { $fn = $ffn; last MY_ITER; } my $size = -s "$dldir/$fn"; # partial download if (yesno('y', "continue file: $fn (at $size)")) { $downloads{$fn} = $size; } else { $downloads{$fn} = 0; } next DOWNLOAD_TRY; } else { $exit = 1; last DOWNLOAD_TRY; } } elsif ($@) { print "An error occurred ($@) : stopping download\n"; } last DOWNLOAD_TRY; } } } # remove duplicate packages (keep latest versions) # move half downloaded files out of the way # delete corrupted files print "\nProcessing downloaded files...(for corrupt/old/partial)\n"; my %vers; # package => version my %files; # package-version => files... # check a deb or split deb file # return 1 if it a deb file, 2 if it is a split deb file # else 0 sub chkdeb($) { my ($fn) = @_; # check to see if it is a .deb file if(!system("dpkg-deb --info $fn 2>&1 >/dev/null && dpkg-deb --contents $fn 2>&1 >/dev/null")) { return 1; } elsif(!system("dpkg-split --info $fn 2>&1 >/dev/null")) { return 2; } return 0; } sub getdebinfo($) { my ($fn) = @_; my $type = chkdeb($fn); my ($pkg, $ver); if($type == 1) { open(my $pkgfile_fh, '-|', "dpkg-deb --field $fn") or die "cannot create pipe for 'dpkg-deb --field $fn'"; my %fields = getblk($pkgfile_fh); close($pkgfile_fh); $pkg = $fields{'package'}; $ver = $fields{'version'}; return $pkg, $ver; } elsif ( $type == 2) { open(my $pkgfile_fh, '-|', "dpkg-split --info $fn") or die "cannot create pipe for 'dpkg-split --info $fn'"; while (<$pkgfile_fh>) { /Part of package:\s*(\S+)/ and $pkg = $1; /\.\.\. version:\s*(\S+)/ and $ver = $1; } close($pkgfile_fh); return $pkg, $ver; } print "could not figure out type of $fn\n"; return $pkg, $ver; } # process deb file to make sure we only keep latest versions sub prcdeb($$) { my ($dir, $fn) = @_; my ($pkg, $ver) = getdebinfo($fn); if(!defined($pkg) || !defined($ver)) { print "could not get package info from file\n"; return 0; } if($vers{$pkg}) { if (dcmpvers($vers{$pkg}, 'eq', $ver)) { $files{$pkg . $ver} = [ $files{$pkg . $ver }, "$dir/$fn" ]; } elsif (dcmpvers($vers{$pkg}, 'gt', $ver)) { print "old version\n"; unlink $fn; } else { # else $ver is gt current version foreach my $c (@{$files{$pkg . $vers{$pkg}}}) { print "replaces: $c\n"; unlink "$vardir/methods/ftp/$dldir/$c"; } $vers{$pkg} = $ver; $files{$pkg . $ver} = [ "$dir/$fn" ]; } } else { $vers{$pkg} = $ver; $files{$pkg . $ver} = [ "$dir/$fn" ]; } } sub prcfile() { my ($fn) = $_; if (-f $fn and $fn ne '.') { my $dir = '.'; if (length($File::Find::dir) > length($dldir)) { $dir = substr($File::Find::dir, length($dldir)+1); } print "$dir/$fn\n"; if(defined($pkgfiles{"$dir/$fn"})) { my @info = @{$pkgfiles{"$dir/$fn"}}; my $size = -s $fn; if($size == 0) { print "zero length file\n"; unlink $fn; } elsif($size < $info[1]) { print "partial file\n"; rename $fn, "$fn.partial"; } elsif(( (exists $md5sums{"$dldir/$fn"}) and ($md5sums{"$dldir/$fn"} ne $info[0]) ) or (md5sum($fn) ne $info[0])) { print "corrupt file\n"; unlink $fn; } else { prcdeb($dir, $fn); } } elsif($fn =~ /.deb$/) { if(chkdeb($fn)) { prcdeb($dir, $fn); } else { print "corrupt file\n"; unlink $fn; } } else { print "non-debian file\n"; } } } find(\&prcfile, "$dldir/"); # install .debs if (yesno('y', "\nDo you want to install the files fetched")) { print "Installing files...\n"; #Installing pre-dependent package before ! my (@flds, $package, @filename, $r); while (@flds = qx(dpkg --predep-package), $? == 0) { foreach my $field (@flds) { $field =~ s/\s*\n//; $package = $field if $field =~ s/^Package: //i; @filename = split / +/, $field if $field =~ s/^Filename: //i; } @filename = map { "$dldir/$_" } @filename; next if (! @filename); $r = system('dpkg', '-iB', '--', @filename); if ($r) { print "DPKG ERROR\n"; $exit = 1; } } #Installing other packages after $r = system('dpkg', '-iGREOB', $dldir); if($r) { print "DPKG ERROR\n"; $exit = 1; } } sub removeinstalled { my $fn = $_; if (-f $fn and $fn ne '.') { my $dir = '.'; if (length($File::Find::dir) > length($dldir)) { $dir = substr($File::Find::dir, length($dldir)+1); } if($fn =~ /.deb$/) { my($pkg, $ver) = getdebinfo($fn); if(!defined($pkg) || !defined($ver)) { print "Could not get info for: $dir/$fn\n"; } else { if ($curpkgs{$pkg} and dcmpvers($ver, 'le', $curpkgs{$pkg})) { print "deleting: $dir/$fn\n"; unlink $fn; } else { print "leaving: $dir/$fn\n"; } } } else { print "non-debian: $dir/$fn\n"; } } } # remove .debs that have been installed (query user) # first need to reprocess status file if (yesno('y', "\nDo you wish to delete the installed package (.deb) files?")) { print "Removing installed files...\n"; %curpkgs = (); procstatus(); find(\&removeinstalled, "$dldir/"); } # remove whole ./debian directory if user wants to if (yesno('n', "\nDo you want to remove $dldir directory?")) { remove_tree($dldir); } #Store useful md5sums foreach my $file (keys %md5sums) { next if -f $file; delete $md5sums{$file}; } open(my $md5sums_fh, '>', "$methdir/md5sums") or die "can't open $methdir/md5sums in write mode: $!\n"; print { $md5sums_fh } Dumper(\%md5sums); close $md5sums_fh; exit $exit;