package 186 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429
  1. USAGE_LICENSE="[-author?Glenn Fowler <gsf@research.att.com>][-copyright?Copyright (c) 1994-2012 AT&T Intellectual Property][-license?http://www.eclipse.org/org/documents/epl-v10.html]"
  2. ########################################################################
  3. # #
  4. # This software is part of the ast package #
  5. # Copyright (c) 1994-2012 AT&T Intellectual Property #
  6. # and is licensed under the #
  7. # Eclipse Public License, Version 1.0 #
  8. # by AT&T Intellectual Property #
  9. # #
  10. # A copy of the License is available at #
  11. # http://www.eclipse.org/org/documents/epl-v10.html #
  12. # (with md5 checksum b35adb5213ca9657e911e9befb180842) #
  13. # #
  14. # Information and Software Systems Research #
  15. # AT&T Research #
  16. # Florham Park NJ #
  17. # #
  18. # Glenn Fowler <gsf@research.att.com> #
  19. # #
  20. ########################################################################
  21. ### this script contains archaic constructs that work with all sh variants ###
  22. # package - source and binary package control
  23. # Glenn Fowler <gsf@research.att.com>
  24. command=package
  25. (command set -o posix) 2>/dev/null && set -o posix
  26. path=Bad
  27. case $PATH in
  28. Bad*) echo "Cannot be run by zsh in native mode; use a sh symlink to zsh" >&2
  29. exit 1 ;;
  30. esac
  31. unset CDPATH
  32. case $0 in
  33. -*)
  34. echo "dodgy \$0: $0" >&2
  35. exit 1 ;;
  36. */package)
  37. mydir=`echo "$0" | sed 's,/package$,,'`
  38. cd "$mydir" || exit
  39. case $PWD in
  40. */bin) ;;
  41. *) echo "this script must live in bin/" >&2
  42. exit 1 ;;
  43. esac
  44. cd .. || exit
  45. unset mydir ;;
  46. package)
  47. echo "this script must be invoked with a direct path, e.g. bin/package" >&2
  48. exit 1 ;;
  49. *)
  50. echo "this script must be named 'package'" >&2
  51. exit 1 ;;
  52. esac
  53. # shell checks
  54. checksh()
  55. {
  56. "$1" -ec '
  57. # reject csh
  58. case 1 in
  59. 1) ;;
  60. esac
  61. # reject special use of $path (to use zsh, use a "sh -> zsh" symlink, which disables this)
  62. path=Bad
  63. case $PATH in
  64. Bad*) exit 1 ;;
  65. esac
  66. # catch (our own) pipe/socket configuration mismatches
  67. date | "$1" -c "read x" || exit 1
  68. # check Bourne/POSIX compatible trap exit status (should exit with status 0)
  69. trap "exit 0" 0
  70. exit 1
  71. ' x "$1" 2>/dev/null || return 1
  72. }
  73. LC_ALL=C
  74. export LC_ALL
  75. TMPDIR=${TMPDIR:-/tmp}
  76. export TMPDIR
  77. src="cmd contrib etc lib"
  78. use="/usr/common /exp /usr/local /usr/add-on /usr/addon /usr/tools /usr /opt"
  79. usr="/home"
  80. lib="" # nee /usr/local/lib /usr/local/shlib
  81. ccs="/usr/kvm /usr/ccs/bin"
  82. org="gnu GNU"
  83. makefiles="Mamfile" # ksh 93u+m no longer uses these: Nmakefile nmakefile Makefile makefile
  84. env="HOSTTYPE NPROC PACKAGEROOT INSTALLROOT PATH"
  85. checksum=md5sum
  86. checksum_commands="$checksum md5"
  87. checksum_empty="d41d8cd98f00b204e9800998ecf8427e"
  88. package_use='=$HOSTTYPE=$PACKAGEROOT=$INSTALLROOT=$EXECROOT=$CC='
  89. PACKAGE_admin_tail_timeout=${PACKAGE_admin_tail_timeout:-"1m"}
  90. CROSS=0
  91. admin_db=admin.db
  92. admin_env=admin.env
  93. admin_ditto="ditto --checksum --delete --verbose"
  94. admin_ditto_update=--update
  95. admin_ditto_skip="OFFICIAL|core|old|*.core|*.tmp|.nfs*"
  96. admin_list='PACKAGE.$type.lst'
  97. admin_ping="ping -c 1 -w 5"
  98. default_url=default.url
  99. MAKESKIP=${MAKESKIP:-"*[-.]*"}
  100. RATZ=ratz
  101. SED=
  102. TAR=tar
  103. TARFLAGS=xv
  104. TARPROBE=B
  105. TR=
  106. all_types='*.*|sun4' # all but sun4 match *.*
  107. case `(getopts '[-][123:xyz]' opt --xyz; echo 0$opt) 2>/dev/null` in
  108. 0123) USAGE=$'
  109. [-?
  110. @(#)$Id: package (AT&T Research) 2012-06-28 $
  111. ]'$USAGE_LICENSE$'
  112. [+NAME?package - source and binary package control]
  113. [+DESCRIPTION?The \bpackage\b command controls source and binary
  114. packages. It is a \bsh\b(1) script coded for maximal portability. All
  115. package files are in the \b$PACKAGEROOT\b directory tree.
  116. \b$PACKAGEROOT\b must at minimum contain a \bbin/package\b command or a
  117. \blib/package\b directory. Binary package files are in the
  118. \b$INSTALLROOT\b (\b$PACKAGEROOT/arch/\b\ahosttype\a) tree, where
  119. \ahosttpe\a=`\bpackage\b`. All \aactions\a but \bhost\b and \buse\b
  120. require the current directory to be under \b$PACKAGEROOT\b. See
  121. \bDETAILS\b for more information.]
  122. [+?Note that no environment variables need be set by the user;
  123. \bpackage\b determines the environment based on the current working
  124. directory. The \buse\b action starts a \bsh\b(1) with the environment
  125. initialized. \bCC\b, \bCCFLAGS\b, \bHOSTTYPE\b and \bSHELL\b may be set
  126. by explicit command argument assignments to override the defaults.]
  127. [+?Packages are composed of components. Each component is built and
  128. installed by an \bast\b \bnmake\b(1) makefile. Each package is also
  129. described by an \bnmake\b makefile that lists its components and
  130. provides a content description. The package makefile and component
  131. makefiles provide all the information required to read, write, build
  132. and install packages.]
  133. [+?Package recipients only need \bsh\b(1) and \bcc\b(1) to build and
  134. install source packages, and \bsh\b to install binary packages.
  135. \bnmake\b and \bksh93\b are required to write new packages. An
  136. \b$INSTALLROOT/bin/cc\b script may be supplied for some architectures.
  137. This script supplies a reasonable set of default options for compilers
  138. that accept multiple dialects or generate multiple object/executable
  139. formats.]
  140. [+?The command arguments are composed of a sequence of words: zero or
  141. more \aqualifiers\a, one \aaction\a, and zero or more action-specific
  142. \aarguments\a, and zero or more \aname=value\a definitions. \apackage\a
  143. names a particular package. The naming scheme is a \b-\b separated
  144. hierarchy; the leftmost parts describe ownership, e.g.,
  145. \bgnu-fileutils\b, \bast-base\b. If no packages are specified then all
  146. packages are operated on. \boptget\b(3) documentation options are also
  147. supported. The default with no arguments is \bhost type\b.]
  148. [+?The qualifiers are:]
  149. {
  150. [+authorize \aname\a?Remote authorization user name or license
  151. acceptance phrase.]
  152. [+debug|environment?Show environment and actions but do not
  153. execute.]
  154. [+flat?Collapse \b$INSTALLROOT\b { bin fun include lib } onto
  155. \b$PACKAGEROOT\b.]
  156. [+force?Force the action to override saved state.]
  157. [+never?Run make -N and show other actions.]
  158. [+only?Only operate on the specified packages.]
  159. [+password \apassword\a?Remote authorization or license
  160. acceptance password.]
  161. [+quiet?Do not list captured action output.]
  162. [+show?Run make -n and show other actions.]
  163. [+verbose?Provide detailed action output.]
  164. [+DEBUG?Trace the package script actions in detail.]
  165. }
  166. [+?The actions are:]
  167. {
  168. [+admin\b [\ball\b]] [\bdb\b \afile\a]] [\bon\b \apattern\a]][\aaction\a ...]]?Apply
  169. \aaction\a ... to the hosts listed in \afile\a. If \afile\a is
  170. omitted then \badmin.db\b is assumed. The caller must have
  171. \brcp\b(1) and \brsh\b(1) or \bscp\b(1) and \bssh\b(1) access
  172. to the hosts. Output for \aaction\a is saved per-host in the
  173. file \aaction\a\b.log/\b\ahost\a. Logs can be viewed by
  174. \bpackage admin\b [\bon\b \ahost\a]] \bresults\b [\aaction\a]].
  175. By default only local PACKAGEROOT hosts are selected from
  176. \afile\a; \ball\b selects all hosts. \bon\b \apattern\a selects
  177. only hosts matching the \b|\b separated \apattern\a. \afile\a
  178. contains four types of lines. Blank lines and lines beginning
  179. with \b#\b are ignored. Lines starting with \aid\a=\avalue\a
  180. are variable assignments. Set admin_ping to local conventions
  181. if \"'$admin_ping$'\" fails. If a package list is not specified
  182. on the command line the \aaction\a applies to all packages; a
  183. variable assignment \bpackage\b=\"\alist\a\" applies \aaction\a
  184. to the packages in \alist\a for subsequent hosts in \afile\a.
  185. The remaining line type is a host description consisting of 6
  186. tab separated fields. The first 3 are mandatory; the remaining
  187. 3 are updated by the \badmin\b action. \afile\a is saved in
  188. \afile\a\b.old\b before update. The fields are:]
  189. {
  190. [+hosttype?The host type as reported by
  191. \"\bpackage\b\".]
  192. [+[user@]]host?The host name and optionally user name
  193. for \brcp\b(1) and \brsh\b(1) access.]
  194. [+[remote::[[master]]::]]]]PACKAGEROOT?The absolute remote package
  195. root directory and optionally the remote protocol (rsh
  196. or ssh) if the directory is on a different server than
  197. the master package root directory. If
  198. \blib/package/admin/'$admin_env$'\b exists under this
  199. directory then it is sourced by \bsh\b(1) before
  200. \aaction\a is done. If this field begins with \b-\b
  201. then the host is ignored. If this field contains \b:\b
  202. then \bditto\b(1) is used to sync the remote \bsrc\b
  203. directory hierarchy to the local one. If [\amaster\a]]:
  204. is specified then the sync is deferred to the \amaster\a
  205. host. If \amaster\a is omitted (two :) then the sync is
  206. disabled. These directories must exist on the remote side:
  207. \blib/package\b, \bsrc/cmd\b, \bsrc/lib\b.]
  208. [+date?\aYYMMDD\a of the last action.]
  209. [+time?Elapsed wall time for the last action.]
  210. [+M T W?The \badmin\b action \bmake\b, \btest\b and
  211. \bwrite\b action error counts. A non-numeric value in
  212. any of these fields disables the corresponding action.]
  213. [+owner?The owner contact information.]
  214. [+attributes?\aname=value\a attributes. Should at least contain
  215. \bcc\b=\acompiler-version\a.]
  216. }
  217. [+clean | clobber?Delete the \barch/\b\aHOSTTYPE\a hierarchy; this
  218. deletes all generated files and directories for \aHOSTTYPE\a.
  219. The hierarchy can be rebuilt by \bpackage make\b.]
  220. [+contents\b [ \apackage\a ... ]]?List description and
  221. components for \apackage\a on the standard output.]
  222. [+copyright\b [ \apackage\a ... ]]?List the general copyright
  223. notice(s) for \apackage\a on the standard output. Note that
  224. individual components in \apackage\a may contain additional or
  225. replacement notices.]
  226. [+export\b [ \avariable\a ...]]?List \aname\a=\avalue\a for
  227. \avariable\a, one per line. If the \bonly\b attribute is
  228. specified then only the variable values are listed. If no
  229. variables are specified then \b'$env$'\b are assumed.]
  230. [+help\b [ \aaction\a ]]?Display help text on the standard
  231. error (standard output for \aaction\a).]
  232. [+host\b [ \aattribute\a ... ]]?List
  233. architecture/implementation dependent host information on the
  234. standard output. \btype\b is listed if no attributes are
  235. specified. Information is listed on a single line in
  236. \aattribute\a order. The attributes are:]
  237. {
  238. [+canon \aname\a?An external host type name to be
  239. converted to \bpackage\b syntax.]
  240. [+cpu?The number of cpus; 1 if the host is not a
  241. multiprocessor.]
  242. [+name?The host name.]
  243. [+rating?The cpu rating in pseudo mips; the value is
  244. useful useful only in comparisons with rating values of
  245. other hosts. Other than a vax rating (mercifully) fixed
  246. at 1, ratings can vary wildly but consistently from
  247. vendor mips ratings. \bcc\b(1) may be required to
  248. determine the rating.]
  249. [+type?The host type, usually in the form
  250. \avendor\a.\aarchitecture\a, with an optional trailing
  251. -\aversion\a. The main theme is that type names within
  252. a family of architectures are named in a similar,
  253. predictable style. OS point release information is
  254. avoided as much as possible, but vendor resistance to
  255. release incompatibilities has for the most part been
  256. futile.]
  257. }
  258. [+html\b [ \aaction\a ]]?Display html help text on the standard
  259. error (standard output for \aaction\a).]
  260. [+install\b [ \aarchitecture\a ... ]] \adirectory\a [ \apackage\a ... ]]?Copy
  261. the package binary hierarchy to \adirectory\a. If
  262. \aarchitecture\a is omitted then all architectures are
  263. installed. If \bflat\b is specified then exactly one
  264. \aarchitecture\a must be specified; this architecture will be
  265. installed in \adirectory\a without the \barch/\b\aHOSTTYPE\a
  266. directory prefixes. Otherwise each architecture will be
  267. installed in a separate \barch/\b\aHOSTTYPE\a subdirectory of
  268. \adirectory\a. The \aarchitecture\a \b-\b names the current
  269. architecture. \adirectory\a must be an existing directory. If
  270. \apackage\a is omitted then all binary packages are installed.
  271. This action requires \bnmake\b.]
  272. [+license\b [ \apackage\a ... ]]?List the source license(s) for
  273. \apackage\a on the standard output. Note that individual
  274. components in \apackage\a may contain additional or replacement
  275. licenses.]
  276. [+list\b [ \apackage\a ... ]]?List the name, version and
  277. prerequisites for \apackage\a on the standard output.]
  278. [+make\b [ \apackage\a ]] [ \aoption\a ... ]] [ \atarget\a ... ]]?Build
  279. and install. The default \atarget\a is \binstall\b, which makes
  280. and installs \apackage\a. If the standard output is a terminal
  281. then the output is also captured in
  282. \b$INSTALLROOT/lib/package/gen/make.out\b. The build is done in
  283. the \b$INSTALLROOT\b directory tree viewpathed on top of the
  284. \b$PACKAGEROOT\b directory tree. If \bflat\b is specified then
  285. the \b$INSTALLROOT\b { bin fun include lib } directories are
  286. linked to the same directories in the package root. Only one
  287. architecture may be \bflat\b. Leaf directory names matching the
  288. \b|\b-separated shell pattern \b$MAKESKIP\b are ignored. The
  289. \bview\b action is done before making. \aoption\a operands are
  290. passed to the underlying make command.]
  291. [+read\b [ \apackage\a ... | \aarchive\a ... ]]?Read the named
  292. package or archive(s). Must be run from the package root
  293. directory. Archives are searched for in \b.\b and
  294. \blib/package/tgz\b. Each package archive is read only once.
  295. The file \blib/package/tgz/\b\apackage\a[.\atype\a]]\b.tim\b
  296. tracks the read time. See the \bwrite\b action for archive
  297. naming conventions. Text file archive member are assumed to be
  298. ASCII or UTF-8 encoded.]
  299. [+regress?\bdiff\b(1) the current and previous \bpackage test\b
  300. results.]
  301. [+release\b [ [\aCC\a]]\aYY-MM-DD\a [ [\acc\a]]\ayy-mm-dd\a ]]]] [ \apackage\a ]]?Display
  302. recent changes for the date range [\aCC\a]]\aYY-MM-DD\a (up to
  303. [\acc\a]]\ayy-mm-dd\a.), where \b-\b means lowest (or highest.)
  304. If no dates are specified then changes for the last 4 months
  305. are listed. \apackage\a may be a package or component name.]
  306. [+remove\b [ \apackage\a ]]?Remove files installed for
  307. \apackage\a.]
  308. [+results\b [ \bfailed\b ]] [ \bpath\b ]] [ \bold\b ]] [\bmake\b | \btest\b | \bwrite\b ]]?List
  309. results and interesting messages captured by the most recent
  310. \bmake\b (default), \btest\b or \bwrite\b action. \bold\b
  311. specifies the previous results, if any (current and previous
  312. results are retained.) \b$HOME/.pkgresults\b, if it exists,
  313. must contain an \begrep\b(1) expression of result lines to be
  314. ignored. \bfailed\b lists failures only and \bpath\b lists the
  315. results file path name only.]
  316. [+setup\b [ beta ]] [ binary ]] [ source ]] [ \aarchitecture\a ... ]] [ \aurl\a ]] [ \apackage\a ... ]]?This
  317. action initializes the current directory as a package root, runs the
  318. \bupdate\b action to download new or out of date packages, and runs the
  319. \bread\b action on those packages. If \bflat\b is specified then the
  320. \b$INSTALLROOT\b { bin fun include lib } directories are linked to the
  321. same directories in the package root. Only one architecture may be
  322. \bflat\b. See the \bupdate\b and \bread\b action descriptions for
  323. argument details.]
  324. [+test\b [ \apackage\a ]]?Run the regression tests for
  325. \apackage\a. If the standard output is a terminal then the
  326. output is also captured in
  327. \b$INSTALLROOT/lib/package/gen/test.out\b. In general a package
  328. must be made before it can be tested. Components tested with
  329. the \bregress\b(1) command require \bksh93\b. If \bonly\b is
  330. also specified then only the listed package components are
  331. tested, otherwise the closure of the components is tested.]
  332. [+update\b [ beta ]] [ binary ]] [ source ]] [\aarchitecture\a ... ]] [ \aurl\a ]] [ \apackage\a ... ]]?Download
  333. the latest release of the selected and required packages from \aurl\a
  334. (e.g., \bhttp://www.research.att.com/sw/download\b) into the directory
  335. \b$PACKAGEROOT/lib/package/tgz\b. \bbeta\b accesses beta packages;
  336. download these at your own risk. If \aarchitecture\a is omitted then
  337. only architectures already present in the \btgz\b directory will be
  338. downloaded. If \aarchitecture\a is \b-\b then all posted architectures
  339. will be downloaded. If \aurl\a matches \b*.url\b then it is interpreted
  340. as a file containing shell variable assignments for \burl\b,
  341. \bauthorize\b and \bpassword\b. If \aurl\a is omitted then the
  342. definitions for \burl\b, \bauthorize\b and \bpassword\b in
  343. \b$PACKAGEROOT/lib/package/tgz/default.url\b, if it exists, are used.
  344. If \b$PACKAGEROOT/lib/package/tgz/default.url\b does not exist then it
  345. is initialized with the current \burl\b, \bauthorize\b and \bpassword\b
  346. values and read permission for the current user only. If \apackage\a is
  347. omitted then only packages already present in the tgz directory will be
  348. downloaded. If \apackage\a is \b-\b then all posted packages will be
  349. downloaded. If \bsource\b and \bbinary\b are omitted then both source
  350. and binary packages will be downloaded. If \bonly\b is specified then
  351. only the named packages are updated; otherwise the closure of required
  352. packages is updated. This action requires \bwget\b(1), \blynx\b(1),
  353. \bcurl\b(1) or a shell that supports io to
  354. \b/dev/tcp/\b\ahost\a/\aport\a.]
  355. [+use\b [ \auid\a | \apackage\a | . [ 32 | 64 ]] | 32 | 64 | - ]] [ command ...]]?Run
  356. \acommand\a, or an interactive shell if \acommand\a is omitted,
  357. with the environment initialized for using the package (can you
  358. say \ashared\a \alibrary\a or \adll\a without cussing?) If
  359. \auid\a or \apackage\a or \a.\a is specified then it is used
  360. to determine a \b$PACKAGEROOT\b, possibly different from
  361. the current directory. For example, to try out bozo`s package:
  362. \bpackage use bozo\b. The \buse\b action may be run from any
  363. directory. If the file \b$INSTALLROOT/lib/package/profile\b is
  364. readable then it is sourced to initialize the environment. 32 or 64
  365. implies \b$PACKAGEROOT\b of . and specifies the target architecture
  366. word size (which may be silently ignored.)]
  367. [+verify\b [ \apackage\a ]]?Verify installed binary files
  368. against the checksum files in
  369. \b$INSTALLROOT/lib/\b\apackage\a\b/gen/*.sum\b. The checksum
  370. files contain mode, user and group information. If the checksum
  371. matches for a given file then the mode, user and group are
  372. changed as necessary to match the checksum entry. A warning is
  373. printed on the standard error for each mismatch. Requires the
  374. \bast\b package \bcksum\b(1) command.]
  375. [+view\b?Initialize the architecture specific viewpath
  376. hierarchy. If \bflat\b is specified then the \b$INSTALLROOT\b {
  377. bin fun include lib } directories are linked to the same
  378. directories in the package root. Only one architecture may be
  379. \bflat\b. The \bmake\b action implicitly calls this action.]
  380. [+write\b [\aformat\a]] \atype\a ... [ \apackage\a ...]]?Write
  381. a package archive for \apackage\a. All work is done in the
  382. \b$PACKAGEROOT/lib/package\b directory. \aformat\a-specific
  383. files are placed in the \aformat\a subdirectory. A
  384. \apackage\a[.\atype\a]]\b.tim\b file in this directory tracks
  385. the write time and prevents a package from being read in the
  386. same root it was written. If more than one file is generated
  387. for a particular \aformat\a then those files are placed in the
  388. \aformat\a/\apackage\a subdirectory. File names in the
  389. \aformat\a subdirectory will contain the package name, a
  390. \ayyyy-mm-dd\a date, and for binary packages, \aHOSTTYPE\a. If
  391. \apackage\a is omitted then an ordered list of previously
  392. written packages is generated. If \bonly\b is specified then
  393. only the named packages will be written; otherwise prerequisite
  394. packages are written first. Package components must be listed
  395. in \apackage\a\b.pkg\b. \aformat\a may be one of:]
  396. {
  397. [+cyg?Generate a \bcygwin\b package.]
  398. [+exp?Generate an \bexptools\b maintainer source
  399. archive and \aNPD\a file, suitable for \bexpmake\b(1)]
  400. [+lcl?Generate a package archive suitable for
  401. restoration into the local source tree (i.e., the
  402. source is not annotated for licencing.)]
  403. [+pkg?Generate a \bpkgmk\b(1) package suitable for
  404. \bpkgadd\b(1).]
  405. [+rpm?Generate an \brpm\b(1) package.]
  406. [+tgz?Generate a \bgzip\b(1) \btar\b(1) package
  407. archive. This is the default.]
  408. [+tst?Generate a \btgz\b format package archive in the
  409. \btst\b subdirectory. Version state files are not updated.]
  410. }
  411. [+?\btype\b specifies the package type which must be one of
  412. \bsource\b, \bbinary\b or \bruntime\b. A source package
  413. contains the source needed to build the corresponding binary
  414. package. A binary package includes the libraries and headers
  415. needed for compiling and linking against the public interfaces.
  416. A runtime package contains the commands and required dynamic
  417. libraries.]
  418. [+?A package may be either a \bbase\b or \bdelta\b. A base
  419. package contains a complete copy of all components. A delta
  420. package contains only changes from a previous base package.
  421. Delta recipients must have the \bast\b \bpax\b(1) command (in
  422. the \bast-base\b package.) If neither \bbase\b nor \bdelta\b is
  423. specified, then the current base is overwritten if there are no
  424. deltas referring to the current base. Only the \btgz\b and
  425. \blcl\b formats support \bdelta\b. If \bbase\b is specified
  426. then a new base and two delta archives are generated: one delta
  427. to generate the new base from the old, and one delta to
  428. generate the old base from the new; the old base is then
  429. removed. If \bdelta\b is specified then a new delta referring
  430. to the current base is written.]
  431. [+?\apackage\a\b.pkg\b may reference other packages. By default
  432. a pointer to those packages is written. The recipient \bpackage
  433. read\b will then check that all required packages have been
  434. downloaded. If \bclosure\b is specified then the components for
  435. all package references are included in the generated package.
  436. This may be useful for \blcl\b and versioning.]
  437. [+?All formats but \blcl\b annotate each \bsource\b file (not
  438. already annotated) with a license comment as it is written to
  439. the package archive using \bproto\b(1).]
  440. }
  441. [+DETAILS?The package directory hierarchy is rooted at
  442. \b$PACKAGEROOT\b. All source and binaries reside under this tree. A two
  443. level viewpath is used to separate source and binaries. The top view is
  444. architecture specific, the bottom view is shared source. All building
  445. is done in the architecture specific view; no source view files are
  446. intentionally changed. This means that many different binary
  447. architectures can be made from a single copy of the source.]
  448. [+?Independent \b$PACKAGEROOT\b hierarchies can be combined by
  449. appending \b$INSTALLROOT:$PACKAGEROOT\b pairs to \bVPATH\b. The
  450. \bVPATH\b viewing order is from left to right. Each \b$PACKAGEROOT\b
  451. must have a \b$PACKAGEROOT/lib/package\b directory.]
  452. [+?Each package contains one or more components. Component source for
  453. the \afoo\a command is in \b$PACKAGEROOT/src/cmd/\b\afoo\a, and source
  454. for the \abar\a library is in \b$PACKAGEROOT/src/lib/lib\b\abar\a. This
  455. naming is for convenience only; the underlying makefiles handle
  456. inter-component build order. The \bINIT\b component, which contains
  457. generic package support files, is always made first, then the
  458. components named \bINIT\b*, then the component order determined by the
  459. closure of component makefile dependencies.]
  460. [+?\b$PACKAGEROOT/lib/package\b contains package specific files. The
  461. package naming convention is \agroup\a[-\apart\a]]; e.g., \bast-base\b,
  462. \bgnu-fileutils\b. The *\b.pkg\b files are ast \bnmake\b(1) makefiles
  463. that contain the package name, package components, references to other
  464. packages, and a short package description. *\b.pkg\b files are used by
  465. \bpackage write\b to generate new source and binary packages.]
  466. [+?\b$PACKAGEROOT/lib/package/\b\agroup\a\b.lic\b files contain license
  467. information that is used by the \bast\b \bproto\b(1) and \bnmake\b(1)
  468. commands to generate source and binary license strings. \agroup\a is
  469. determined by the first \b:PACKAGE:\b operator name listed in the
  470. component \bnmake\b makefile. \agroup\a\b.lic\b files are part of the
  471. licensing documentation. Each component may have its own \bLICENSE\b file
  472. that overrides the \agroup\a\b.lic\b file. The full text of the licenses
  473. are in the \b$PACKAGEROOT/lib/package/LICENSES\b and
  474. \b$INSTALLROOT/lib/package/LICENSES\b directories.]
  475. [+?A few files are generated in \b$PACKAGEROOT/lib/package/gen\b and
  476. \b$INSTALLROOT/lib/package/gen\b. \apackage\a\b.ver\b contains one line
  477. consisting of \apackage version release\a \b1\b for the most recent
  478. instance of \apackage\a read into \b$PACKAGEROOT\b, where \apackage\a
  479. is the package name, \aversion\a is the \aYYYY-MM-DD\a base version,
  480. and \arelease\a is \aversion\a for the base release or \aYYYY-MM-DD\a
  481. for delta releases. \apackage\a\b.req\b contains *\b.ver\b entries for
  482. the packages required by \apackage\a, except that the fourth field is
  483. \b0\b instead of \b1\b. All packages except \bINIT\b require the
  484. \bINIT\b package. A simple sort of \apackage\a\b.pkg\b and *\b.ver\b
  485. determines if the required package have been read in. Finally,
  486. \apackage\a\b.README\b and \apackage\a\a.html\b contain the README text
  487. for \apackage\a and all its components. Included are all changes added
  488. to the component \bRELEASE\b, \bCHANGES\b or \bChangeLog\b files dated
  489. since the two most recent base releases. Component \bRELEASE\b files
  490. contain tag lines of the form [\aYY\a]]\aYY-MM-DD\a [ \atext\a ]] (or
  491. \bdate\b(1) format dates) followed by README text, in reverse
  492. chronological order (newer entries at the top of the file.) \bpackage
  493. release\b lists this information, and \bpackage contents ...\b lists
  494. the descriptions and components.]
  495. [+?\b$HOSTYPE\b names the current binary architecture and is determined
  496. by the output of \bpackage\b (no arguments.) The \b$HOSTTYPE\b naming
  497. scheme is used to separate incompatible executable and object formats.
  498. All architecture specific binaries are placed under \b$INSTALLROOT\b
  499. (\b$PACKAGEROOT/arch/$HOSTTYPE\b.) There are a few places that match
  500. against \b$HOSTTYPE\b when making binaries; these are limited to
  501. makefile compiler workarounds, e.g., if \b$HOSTTYPE\b matches \bhp.*\b
  502. then turn off the optimizer for these objects. All other architecture
  503. dependent logic is handled either by the \bast\b \biffe\b(1) command or
  504. by component specific configure scripts. Explicit \b$HOSTYPE\b
  505. values matching *,*cc*[,-*,...]] optionally set the default \bCC\b and
  506. \bCCFLAGS\b. This is handy for build farms that support different
  507. compilers on the same architecture.]
  508. [+?Each component contains an \bast\b \bnmake\b(1) makefile (either
  509. \bNmakefile\b or \bMakefile\b) and a \bMAM\b (make abstract machine)
  510. file (\bMamfile\b.) A Mamfile contains a portable makefile description
  511. that is used by \bmamake\b(1) to simulate \bnmake\b. Currently there is
  512. no support for old-make/gnu-make makefiles; if the binaries are just
  513. being built then \bmamake\b will suffice; if source or makefile
  514. modifications are anticipated then \bnmake\b (in the \bast-base\b
  515. package) should be used. Mamfiles are automatically generated by
  516. \bpackage write\b.]
  517. [+?Most component C source is prototyped. If \b$CC\b (default value
  518. \bcc\b) is not a prototyping C compiler then \bpackage make\b runs
  519. \bproto\b(1) on portions of the \b$PACKAGEROOT/src\b tree and places
  520. the converted output files in the \b$PACKAGEROOT/proto/src\b tree.
  521. Converted files are then viewpathed over the original source.
  522. \bproto\b(1) converts an ANSI C subset to code that is compatible with
  523. K&R, ANSI, and C++ dialects.]
  524. [+?All scripts and commands under \b$PACKAGEROOT\b use \b$PATH\b
  525. relative pathnames (via the \bast\b \bpathpath\b(3) function); there
  526. are no embedded absolute pathnames. This means that binaries generated
  527. under \b$PACKAGEROOT\b may be copied to a different root; users need
  528. only change their \b$PATH\b variable to reference the new installation
  529. root \bbin\b directory. \bpackage install\b installs binary packages in
  530. a new \b$INSTALLROOT\b.]
  531. [ qualifier ... ] [ action ] [ arg ... ] [ n=v ... ]
  532. [+SEE ALSO?\bautoconfig\b(1), \bcksum\b(1), \bexecrate\b(1), \bexpmake\b(1),
  533. \bgzip\b(1), \bmake\b(1), \bmamake\b(1), \bnmake\b(1), \bpax\b(1),
  534. \bpkgadd\b(1), \bpkgmk\b(1), \bproto\b(1), \bratz\b(1), \brpm\b(1),
  535. \bsh\b(1), \btar\b(1), \boptget\b(3)]
  536. '
  537. case $* in
  538. help) set -- --man ;;
  539. esac
  540. while getopts -a $command "$USAGE" OPT
  541. do :
  542. done
  543. shift $OPTIND-1
  544. ;;
  545. esac
  546. # check the args
  547. case $AR in
  548. '') AR=ar ;;
  549. esac
  550. case $CC in
  551. '') CC=cc ;;
  552. esac
  553. case $LD in
  554. '') LD=ld ;;
  555. esac
  556. case $NM in
  557. '') NM=nm ;;
  558. esac
  559. action=
  560. admin_all=1
  561. admin_on=
  562. authorize=
  563. bit=
  564. exec=
  565. flat=0
  566. force=0
  567. global=
  568. hi=
  569. html=0
  570. ifs=${IFS-'
  571. '}
  572. lo=
  573. make=
  574. makeflags='-K'
  575. nmakeflags=
  576. nmakesep=
  577. nl="
  578. "
  579. noexec=
  580. only=0
  581. output=
  582. package_src=
  583. password=
  584. quiet=0
  585. show=:
  586. tab=" "
  587. verbose=0
  588. AUTHORIZE=
  589. DEBUG=
  590. HURL=
  591. PROTOROOT=-
  592. SHELLMAGIC=-
  593. unset FIGNORE BINDIR DLLDIR ETCDIR FUNDIR INCLUDEDIR LIBDIR LOCALEDIR MANDIR SHAREDIR 2>/dev/null || true
  594. while :
  595. do case $# in
  596. 0) set host type ;;
  597. esac
  598. case $1 in
  599. admin|clean|clobber|contents|copyright|export|host|install|license|list|make|read|regress|release|remove|results|setup|test|update|use|verify|view|write|TEST)
  600. action=$1
  601. shift
  602. break
  603. ;;
  604. authorize)
  605. case $# in
  606. 1) echo $command: $1: authorization user name argument expected >&2; exit 1 ;;
  607. esac
  608. shift
  609. authorize=$1
  610. shift
  611. continue
  612. ;;
  613. debug|environment)
  614. exec=echo make=echo show=echo
  615. ;;
  616. flat) flat=1
  617. ;;
  618. force) force=1
  619. ;;
  620. never) exec=echo noexec=-N
  621. ;;
  622. only) only=1
  623. ;;
  624. password)
  625. case $# in
  626. 1) echo $command: $1: authorization password argument expected >&2; exit 1 ;;
  627. esac
  628. shift
  629. password=$1
  630. shift
  631. continue
  632. ;;
  633. quiet) quiet=1
  634. ;;
  635. show) exec=echo noexec=-n
  636. ;;
  637. verbose)verbose=1
  638. ;;
  639. DEBUG) DEBUG=1
  640. PS4='+$LINENO:$SECONDS+ '
  641. set -x
  642. ;;
  643. help|HELP|html|man|--[?m]*)
  644. case $1 in
  645. help) code=0
  646. case $2 in
  647. '') exec 1>&2 ;;
  648. esac
  649. ;;
  650. html) code=0 html=1
  651. ;;
  652. *) code=2
  653. exec 1>&2
  654. ;;
  655. esac
  656. case $html in
  657. 1) bO="<HTML>
  658. <HEAD>
  659. <TITLE>$2 package installation instructions</TITLE>
  660. <HEAD>
  661. <BODY bgcolor=white link=teal vlink=dimgray>"
  662. eO='</BODY>
  663. </HTML>'
  664. bH="<CENTER><H3><FONT face=courier color=red>"
  665. eH='</FONT></H3></CENTER>'
  666. bP='<P>'
  667. bL='<P><TABLE cellpadding=0 cellspacing=2>'
  668. bL2='<P><TABLE border=0 cellpadding=0 cellspacing=2>'
  669. eL='</TABLE><P>'
  670. bT='<TR><TD align=right valign=top><B>'
  671. bD='</B></TD><TD align=left>' eD='</TD></TR>'
  672. bB='<B>' eB='</B>'
  673. bI='<I>' eI='</I>'
  674. bX='<PRE>' eX='</PRE>'
  675. bF='<TT>' eF='</TT>'
  676. Camp='&amp;'
  677. Mcurl='<A href=../../man/man1/curl.html>curl</A>(1)'
  678. Mdate='<A href=../../man/man1/date.html>date</A>(1)'
  679. Mfile='<A href=../../man/man1/file.html>file</A>(1)'
  680. Mgunzip='<A href=../../man/man1/gzip.html>gunzip</A>(1)'
  681. Mhurl='<A href=../../man/man1/hurl.html>hurl</A>(1)'
  682. Mlynx='<A href=../../man/man1/lynx.html>lynx</A>(1)'
  683. Mnmake='<A href=../../man/man1/nmake.html>nmake</A>(1)'
  684. Mpackage='<A href=../../man/man1/package.html>package</A>(1)'
  685. Mproto='<A href=../../man/man1/proto.html>proto</A>(1)'
  686. Mratz='<A href=../../man/man1/ratz.html>ratz</A>'
  687. Mtar='<A href=../../man/man1/tar.html>tar</A>(1)'
  688. Mwget='<A href=../../man/man1/wget.html>wget</A>(1)'
  689. ;;
  690. *) bO='' eO=''
  691. bH='' eH=':'
  692. bP=''
  693. bL='' eL=''
  694. bL2=''
  695. bT=' '
  696. bD=' ' eD=''
  697. bB='' eB=''
  698. bI='' eI=''
  699. bX='' eX=''
  700. bF='"' eF='"'
  701. Camp='&'
  702. Mcurl='curl(1)'
  703. Mdate='date(1)'
  704. Mfile='file(1)'
  705. Mgunzip='gunzip(1)'
  706. Mhurl='hurl(1)'
  707. Mlynx='lynx(1)'
  708. Mnmake='nmake(1)'
  709. Mpackage='package(1)'
  710. Mproto='proto(1)'
  711. Mratz='ratz'
  712. Mtar='tar(1)'
  713. Mwget='wget(1)'
  714. ;;
  715. esac
  716. case $2 in
  717. binary) echo "${bO}
  718. ${bH}Binary Package Installation Instructions${eH}
  719. ${bL}
  720. ${bT}(1)${bD}Do not install packages as ${bI}root/super-user${eI}. Although some components may
  721. have setuid executables, few must be owned by ${bI}root${eI}. These are best
  722. changed manually when the security implications are understood.${eD}
  723. ${bT}(2)${bD}Choose a package root directory and cd to it. This will be a local work
  724. area for all packages.${eD}
  725. ${bT}(3)${bD}These instructions bypass the ${bI}click to download${eI} package links on the
  726. download site. If you already clicked, or if your system does not have
  727. ${Mcurl}, ${Mhurl}, ${Mlynx} or ${Mwget} then use the alternate instructions
  728. for (3),(4),(5) in plan ${bB}B${eB} below. Plan ${bB}B${eB} installs the ${Mhurl}
  729. script which works with ksh and modern bash. The top level URL is:${bX}
  730. URL=http://www.research.att.com/sw/download${eX}${eD}
  731. ${bT}(4)${bD}If the ${bB}bin/package${eB} script does not exist then run:${bX}
  732. test -d bin || mkdir bin
  733. url=\$URL/package
  734. (wget -O - \$url||curl -L \$url||hurl \$url) > bin/package
  735. chmod +x bin/package${eX}${eD}
  736. ${bT}(5)${bD}Determine the list of package names you want from the download site, then
  737. use the ${Mpackage} command to do the actual download:${bX}
  738. bin/package authorize \"${bI}NAME${eI}\" password \"${bI}PASSWORD${eI}\" \\
  739. setup binary \$URL ${bI}PACKAGE${eI} ...${eX}
  740. (Refer to the ${bB}AUTHORIZATION${eB} paragraph on the main download page for
  741. ${bI}NAME${eI}/${bI}PASSWORD${eI} details.) This downloads the closure of the latest
  742. binary package(s); covered and up-to-date packages are not downloaded again unless
  743. ${bB}package force ...${eB} is specified. Package content is verified using ${bB}${checksum}${eB}.
  744. If the package root will contain only one architecture then you can install in ${bB}bin${eB} and
  745. ${bB}lib${eB} instead of ${bB}arch/${eB}${bI}HOSTTYPE${eI}${bB}/bin${eB} and ${bB}arch/${eB}${bI}HOSTTYPE${eI}${bB}/lib${eB} by running this
  746. instead:${bX}
  747. bin/package authorize \"${bI}NAME${eI}\" password \"${bI}PASSWORD${eI}\" \\
  748. flat setup binary \$URL ${bB}PACKAGE${eB} ...${eX}
  749. To update the same packages from the same URL run:${bX}
  750. bin/package setup binary${eX}${eD}
  751. ${bT}(6)${bD}The packaged binaries are position independent, i.e., they do not
  752. contain hard-coded paths. However, commands with related files, like
  753. ${Mfile} and ${Mnmake}, require the path of the bin directory to be
  754. exported in ${bB}PATH${eb}.${eD}
  755. ${bT}(7)${bD}You can run the binaries directly from the package root, or you can
  756. install them in a public root (requires the ${bI}AT${Camp}T${eI} ${Mnmake} command):${bX}
  757. bin/package flat install ${bI}DIRECTORY PACKAGE${eI}${eX}
  758. This will install in ${bI}DIRECTORY${eI}${bB}/bin${eB} and ${bI}DIRECTORY${eI}${bB}/lib${eB}. If you want to
  759. preserve the ${bB}arch/${eB}${bI}HOSTTYPE${eI} hierarchy under ${bI}DIRECTORY${eI} then omit the
  760. ${bB}flat${eB} argument. If you don't have ${Mnmake} then the following will do a
  761. flat install:${bX}
  762. cd \$INSTALLROOT
  763. cp -p -r bin lib include ${bI}DIRECTORY${eI}${eX}${eD}
  764. ${bT}(8)${bD}To summarize, after the first time, the download cycle for the latest
  765. binary release is:${bX}
  766. bin/package setup binary${eX}${eD}${eL}
  767. ${bH}Binary Package Installation Instructions -- Plan B${eH}
  768. ${bL}
  769. ${bT}(3)${bD}Create the subdirectory ${bB}lib/package/tgz${eB} and download all package archives
  770. into that directory.${eD}
  771. ${bT}(4)${bD}If the ${bB}bin/package${eB} script does not exist then manually read the ${bB}INIT${eB}
  772. binary package:${bX}
  773. gunzip < lib/package/tgz/INIT.${bI}YYYY-MM-DD.HOSTTYPE${eI}.tgz |
  774. ${TAR} ${TARFLAGS}f -${eX}
  775. Note that some browsers automatically unzip downloaded without warning.
  776. If the gunzip fails try:
  777. ${TAR} ${TARFLAGS}f -${eX} lib/package/tgz/INIT.${bI}YYYY-MM-DD.HOSTTYPE${eI}.tgz
  778. If your system does not have ${Mtar} or ${Mgunzip} then download the ${Mratz}
  779. binary package:${bX}
  780. mkdir bin
  781. cp lib/package/tgz/ratz.${bI}YYYY-MM-DD.HOSTTYPE${eI}.exe bin/ratz
  782. chmod +x bin/ratz
  783. bin/ratz -lm < lib/package/tgz/INIT.${bI}YYYY-MM-DD/HOSTTYPE${eI}.tgz
  784. ${bT}(5)${bD}Read all unread package archive(s):${bX}
  785. bin/package read${eX}
  786. Both source and binary packages will be read by this step.${eD}${eL}${eO}"
  787. ;;
  788. intro) echo "${bO}
  789. ${bH}Package Hierarchy Details${eH}
  790. ${bP}
  791. The package directory hierarchy is rooted at ${bB}\$PACKAGEROOT${eB}. All source and
  792. binaries reside under this tree. A two level viewpath is used to separate
  793. source and binaries. The top view is architecture specific, the bottom view
  794. is shared source. All building is done in the architecture specific view;
  795. no source view files are intentionally changed. This means that many
  796. different binary architectures can be made from a single copy of the source.
  797. ${bP}
  798. Each package contains one or more components. Component source for the ${bI}FOO${eI}
  799. command is in ${bB}\$PACKAGEROOT/src/cmd/${eB}${bI}FOO${eI}, and source for the ${bI}BAR${eI} library is
  800. in ${bB}\$PACKAGEROOT/src/lib/lib${eB}${bI}BAR${eI}. This naming is for convenience only; the
  801. underlying makefiles handle inter-component build order. The ${bB}INIT${eB} component,
  802. which contains generic package support files, is always made first, then the
  803. components named ${bB}INIT${eB}*, then the order determined by the closure of component
  804. makefile dependencies.
  805. ${bP}
  806. ${bB}\$PACKAGEROOT/lib/package${eB} contains package specific files. The package naming
  807. convention is ${bI}GROUP${eI}[${bI}-PART${eI}]; e.g., ${bB}ast-base${eB}, ${bB}gnu-fileutils${eB}. The *${bB}.pkg${eB} files
  808. are ${bB}ast${eB} ${Mnmake} makefiles that contain the package name, package components,
  809. references to other packages, and a short package description. *${bB}.pkg${eB} files
  810. are used by ${bF}package write${eF} to generate new source and binary packages.
  811. ${bP}
  812. ${bB}\$PACKAGEROOT/lib/package/${eB}${bI}GROUP${eI}${bB}.lic${eB} files contain license information that
  813. is used by the ${bB}ast${eB} ${Mproto} and ${Mnmake} commands to generate source and
  814. binary license strings. ${bI}GROUP${eI} is determined by the first ${bB}:PACKAGE:${eB} operator
  815. name listed in the component ${bB}nmake${eB} makefile. ${bI}GROUP${eI}${bB}.lic${eB} files are part of the
  816. licensing documentation. Each component may have its own ${bB}LICENSE${eB} file that
  817. overrides the ${bI}GROUP${eI}${bB}.lic${eB} file. The full text of the licenses are in the
  818. ${bB}\$PACKAGEROOT/lib/package/LICENSES${eB} and ${bB}\$INSTALLROOT/lib/package/LICENSES${eB}
  819. directories.
  820. ${bP}
  821. A few files are generated in ${bB}\$PACKAGEROOT/lib/package/gen${eB} and
  822. ${bB}\$INSTALLROOT/lib/package/gen${eB}. ${bI}PACKAGE${eI}${bB}.ver${eB} contains one line consisting of${bX}
  823. ${bI}PACKAGE VERSION RELEASE${eI} 1${eX}
  824. for the most recent instance of ${bI}PACKAGE${eI} read into ${bB}\$PACKAGEROOT${eB}, where
  825. ${bI}PACKAGE${eI} is the package name, ${bI}VERSION${eI} is the ${bI}YYYY-MM-DD${eI} base version,
  826. and ${bI}RELEASE${eI} is ${bI}VERSION${eI} for the base release or ${bI}YYYY-MM-DD${eI} for delta releases.
  827. ${bI}PACKAGE${eI}${bB}.req${eB} contains *${bB}.ver${eB} entries for the packages required by
  828. ${bI}PACKAGE${eI}, except that the fourth field is 0 instead of 1. All packages
  829. except ${bB}INIT${eB} and ${Mratz} require the ${bB}INIT${eB} package. A simple sort of ${bI}PACKAGE${eI}${bB}.pkg${eB}
  830. and *${bB}.ver${eB} determines if the required package have been read in. Finally,
  831. ${bI}PACKAGE${eI}${bB}.README${eB} contains the ${bB}README${eB} text for ${bI}PACKAGE${eI} and all its
  832. components. Included are all changes added to the component ${bB}RELEASE${eB},
  833. ${bB}CHANGES${eB} or ${bB}ChangeLog${eB} files dated since the two most recent base
  834. releases. Component ${bB}RELEASE${eB} files contain tag lines of the form
  835. [${bI}CC${eI}]${bI}YY-MM-DD${eI} [ ${bI}TEXT${eI} ] (or ${Mdate} format dates) followed by README
  836. text, in reverse chronological order (newer entries at the top of the
  837. file.) ${bF}package release${eF} generates this information, and
  838. ${bF}package contents ...${eF} lists the descriptions and components.
  839. ${bP}
  840. ${bB}\$HOSTYPE${eB} names the current binary architecture and is determined by the
  841. output of ${bF}package${eF} (no arguments.) The ${bB}\$HOSTTYPE${eB} naming scheme is used
  842. to separate incompatible executable and object formats. All architecture
  843. specific binaries are placed under ${bB}\$INSTALLROOT${eB} (${bB}\$PACKAGEROOT/arch/\$HOSTTYPE${eB}.)
  844. There are a few places that match against ${bB}\$HOSTTYPE${eB} when making binaries; these
  845. are limited to makefile compiler workarounds, e.g., if ${bB}\$HOSTTYPE${eB} matches
  846. 'hp.*' then turn off the optimizer for these objects. All other architecture
  847. dependent logic is handled either by ${bB}\$INSTALLROOT/bin/iffe${eB} or by component
  848. specific configure scripts. Explicit ${bB}\$HOSTYPE${eB} values matching *,*cc*[,-*,...]
  849. optionally set the default ${bB}CC${eB} and ${bB}CCFLAGS${eB}. This is handy for build
  850. farms that support different compilers on the same architecture.
  851. ${bP}
  852. Each component contains an ${bB}ast${eB} ${Mnmake} makefile (either ${bB}Nmakefile${eB} or ${bB}Makefile${eB})
  853. and a ${bI}MAM${eI} (make abstract machine) file (${bB}Mamfile${eB}.) A Mamfile contains a portable
  854. makefile description that is used by ${bB}\$INSTALLROOT/bin/mamake${eB} to simulate
  855. ${bB}nmake${eB}. Currently there is no support for old-make/gnu-make makefiles; if
  856. the binaries are just being built then ${bB}mamake${eB} will suffice; if source or
  857. makefile modifications are anticipated then ${bB}nmake${eB} (from the ${bB}ast-open${eB} or
  858. ${bB}ast-base${eB} package) should be used. Mamfiles are automatically generated by
  859. ${bF}package write${eF}.
  860. ${bP}
  861. Most component C source is prototyped. If ${bB}\$CC${eB} (default value ${bB}cc${eB}) is not a
  862. prototyping C compiler then ${bF}package make${eF} runs ${Mproto} on portions of the
  863. ${bB}\$PACKAGEROOT/src${eB} tree and places the converted output files in the
  864. ${bB}\$PACKAGEROOT/proto/src${eB} tree. Converted files are then viewpathed over the
  865. original source. The ${bB}ast${eB} ${Mproto} command converts an ANSI C subset to code
  866. that is compatible with K&R, ANSI, and C++ dialects.
  867. ${bP}
  868. All scripts and commands under ${bB}\$PACKAGEROOT${eB} use ${bB}\$PATH${eB} relative pathnames;
  869. there are no embedded absolute pathnames. This means that binaries generated
  870. under ${bB}\$PACKAGEROOT${eB} may be copied to a different root; users need only change
  871. their ${bB}\$PATH${eB} variable to reference the new installation root bin directory.
  872. ${bF}package install${eF} installs binary packages in a new ${bB}\$INSTALLROOT${eB}.
  873. ${eO}"
  874. ;;
  875. source) echo "${bO}
  876. ${bH}Source Package Installation Instructions${eH}
  877. ${bL}
  878. ${bT}(1)${bD}Do not install packages as ${bI}root/super-user${eI}. Although some components may
  879. have setuid executables, few must be owned by ${bI}root${eI}. These are best
  880. changed manually when the security implications are understood.${eD}
  881. ${bT}(2)${bD}Choose a package root directory and cd to it. This will be a local work
  882. area for all packages.
  883. ${bT}(3)${bD}These instructions bypass the ${bI}click to download${eI} package links on the
  884. download site. If you already clicked, or if your system does not have
  885. ${Mcurl}, ${Mhurl}, ${Mlynx} or ${Mwget} then use the alternate instructions
  886. for (3),(4),(5) in plan ${bB}B${eB} below. Plan ${bB}B${eB} installs the ${Mhurl}
  887. script which works with ksh and modern bash. The top level URL is:${bX}
  888. URL=http://www.research.att.com/sw/download${eX}${eD}
  889. ${bT}(4)${bD}If the ${bB}bin/package${eB} script does not exist then run:${bX}
  890. test -d bin || mkdir bin
  891. url=\$URL/package
  892. (wget -O - \$url||curl -L \$url||hurl \$url) > bin/package
  893. chmod +x bin/package${eX}${eD}
  894. ${bT}(5)${bD}Determine the list of package names you want from the download site, then
  895. use the ${Mpackage} command to do the actual download:${bX}
  896. bin/package authorize \"${bI}NAME${eI}\" password \"${bI}PASSWORD${eI}\" \\
  897. setup source \$URL ${bB}PACKAGE${eB} ...${eX}
  898. (Refer to the ${bB}AUTHORIZATION${eB} paragraph on the main download page for
  899. ${bI}NAME${eI}/${bI}PASSWORD${eI} details.) This downloads the closure of the latest
  900. source package(s); covered and up-to-date packages are not downloaded again unless
  901. ${bB}package force ...${eB} is specified. Package content is verified using ${bB}${checksum}${eB}.
  902. If the package root will contain only one architecture then you can install in ${bB}bin${eB} and
  903. ${bB}lib${eB} instead of ${bB}arch/${eB}${bI}HOSTTYPE${eI}${bB}/bin${eB} and ${bB}arch/${eB}${bI}HOSTTYPE${eI}${bB}/lib${eB} by running this
  904. instead:${bX}
  905. bin/package authorize \"${bI}NAME${eI}\" password \"${bI}PASSWORD${eI}\" \\
  906. flat setup source \$URL ${bB}PACKAGE${eB} ...${eX}
  907. To update the same packages from the same URL run:${bX}
  908. bin/package setup source${eX}${eD}
  909. ${bT}(6)${bD}Build and install; all generated files are placed under ${bB}arch/${eB}${bI}HOSTTYPE${eI}
  910. (${bB}\$INSTALLROOT${eB}), where ${bI}HOSTTYPE${eI} is the output of ${bB}bin/package${eB} (with no
  911. arguments.) ${bI}name=value${eI} arguments are supported; ${bB}CC${eB} and ${bB}debug=1${eB} (compile
  912. with -g instead of -O) are likely candidates. The output is written to
  913. the terminal and captured in ${bB}\$INSTALLROOT/lib/package/gen/make.out${eB}:${bX}
  914. bin/package make${eX}${eD}
  915. ${bT}(7)${bD}List make results and interesting errors:${bX}
  916. bin/package results${eX}
  917. Run the regression tests:${bX}
  918. bin/package test${eX}
  919. List test results and errors:${bX}
  920. bin/package results test${eX}${eD}
  921. ${bT}(8)${bD}The generated binaries are position independent, i.e., they do not
  922. contain hard-coded paths. However, commands with related files, like
  923. ${Mfile} and ${Mnmake}, require the path of the bin directory to be
  924. exported in ${bB}PATH${eb}.${eD}
  925. ${bT}(9)${bD}You can run the binaries directly from the package root, or you can
  926. install them in a public root after you are satisfied with the make and
  927. test actions (requires the ${bI}AT${Camp}T${eI} ${Mnmake} command):${bX}
  928. bin/package flat install ${bI}DIRECTORY PACKAGE${eI}${eX}
  929. This will install in ${bI}DIRECTORY${eI}${bB}/bin${eB} and ${bI}DIRECTORY${eI}${bB}/lib${eB}. If you want to
  930. preserve the ${bB}arch/${eB}${bI}HOSTTYPE${eI} hierarchy under ${bI}DIRECTORY${eI} then omit the
  931. ${bB}flat${eB} argument. If you don't have ${Mnmake} then the following will do a
  932. flat install:${bX}
  933. cd \$INSTALLROOT
  934. cp -p -r bin lib include ${bI}DIRECTORY${eI}${eX}${eD}
  935. ${bT}(10)${bD}To summarize, after the first time the download, build, and test cycle
  936. for the latest source release is:${bX}
  937. bin/package setup source
  938. bin/package make
  939. bin/package test${eX}${eD}${eL}
  940. ${bH}Source Package Installation Instructions -- Plan B${eH}
  941. ${bL}
  942. ${bT}(3)${bD}Create the subdirectory ${bB}lib/package/tgz${eB} and download all package archives
  943. into that directory.${eD}
  944. ${bT}(4)${bD}If the ${bB}bin/package${eB} script does not exist then manually read the ${bB}INIT${eB}
  945. source package:${bX}
  946. gunzip < lib/package/tgz/INIT.${bI}YYYY-MM-DD${eI}.tgz | ${TAR} ${TARFLAGS}f -${eX}
  947. Note that some browsers automatically unzip downloaded without warning.
  948. If the gunzip fails try:
  949. ${TAR} ${TARFLAGS}f -${eX} lib/package/tgz/INIT.${bI}YYYY-MM-DD${eI}.tgz
  950. If your system does not have ${Mtar} or ${Mgunzip} then download the ${Mratz}
  951. source package, compile it, and manually read the ${bB}INIT${eB}
  952. source package:${bX}
  953. mkdir bin
  954. cp lib/package/tgz/ratz.${bI}YYYY-MM-DD${eI}.c lib/package/tgz/ratz.c
  955. cc -o bin/ratz lib/package/tgz/ratz.c
  956. bin/ratz -lm < lib/package/tgz/INIT.${bI}YYYY-MM-DD${eI}.tgz
  957. ${bT}(5)${bD}Read all unread package archive(s):${bX}
  958. bin/package read${eX}
  959. Both source and binary packages will be read by this step.${eD}${eL}${eO}"
  960. ;;
  961. *) echo "Usage: $command [ qualifier ... ] [ action ] [ arg ... ] [ n=v ... ]
  962. The $command command controls source and binary packages. It must be run
  963. within the package root directory tree. See \"$command help intro\" for
  964. details. In the following, PACKAGE names either a package or a component
  965. within a package; if omitted, all packages are operated on. The default
  966. action is \"host type\".
  967. qualifier:
  968. authorize NAME Remote authorization name or license acceptance phrase.
  969. debug|environment Show environment and actions; do not execute.
  970. flat Collapse \$INSTALLROOT { bin fun include lib } onto \$PACKAGEROOT.
  971. force Force the action to override saved state.
  972. never Run make -N; otherwise show other actions.
  973. only Only operate on the specified packages.
  974. password PASSWORD Remote authorization or license acceptance password.
  975. quiet Do not list captured make and test action output.
  976. show Run make -n; otherwise show other actions.
  977. DEBUG Trace the package script actions in detail for debugging.
  978. action:
  979. admin [ all ] [ db FILE ] [ on PATTERN ] [ action ... ]
  980. Apply ACTION ... to the hosts listed in FILE. If FILE is
  981. omitted then "admin.db" is assumed. The caller must have rcp(1)
  982. and rsh(1) or scp(1) and ssh(1) access to the hosts. Output
  983. for the action is saved per-host in ACTION.log/HOST. Logs
  984. can be viewed by \"package admin [on HOST] results [ACTION]\".
  985. By default only local PACKAGEROOT hosts are selected from FILE;
  986. \"all\" selects all hosts. \"on PATTERN\" selects only
  987. hosts matching the | separated PATTERN. FILE contains four
  988. types of lines. Blank lines and lines beginning with # are
  989. ignored. Lines starting with id=value are variable assignments.
  990. Set admin_ping to local conventions if \"$admin_ping\" fails.
  991. If a package list is not specified on the command line the
  992. action applies to all packages; a variable assignment
  993. package=list applies action to the packages in list for
  994. subsequent hosts in FILE. The remaining line type is a host
  995. description consisting of 6 tab separated fields. The first 3
  996. are mandatory; the remaining 3 are updated by the admin action:
  997. hosttype
  998. The host type as reported by package.
  999. [user@]host
  1000. The host name and optionally user name for rcp(1)
  1001. and rsh(1) access.
  1002. [remote:[[master]:]]PACKAGEROOT
  1003. The absolute remote package root directory and
  1004. optionally the remote prorocol (rsh or ssh) if
  1005. the directory is on a different server than the
  1006. master package root directory. If
  1007. lib/package/admin/$admin_env exists under
  1008. this directory then it is sourced by sh(1)
  1009. before ACTION is done. If this field begins with -
  1010. then the host is ignored. If this field contains
  1011. : then ditto(1) is used to sync the remote src
  1012. directory hierarchy to the local one. If [master]:
  1013. is specified then the sync is deferred to the
  1014. master host. If master is omitted (two :) then
  1015. the sync is disabled. These directories must exist
  1016. on the remote side: lib/package, src/cmd, src/lib.
  1017. date YYMMDD of the last action.
  1018. date Elapsed wall time of the last action.
  1019. M T W The admin action make, test and write action error
  1020. counts. A non-numeric value in any of these fields
  1021. disables the corresponding action.
  1022. owner The owner contact information.
  1023. attributes
  1024. NAME=VALUE attributes. Should at least contain
  1025. cc=compiler-version.
  1026. clean | clobber
  1027. Delete the arch/HOSTTYPE hierarchy; this deletes all generated
  1028. files and directories for HOSTTYPE. The hierarchy can be rebuilt
  1029. by package make.]
  1030. contents [ package ... ]
  1031. List description and components for PACKAGE on the standard
  1032. output.
  1033. copyright [ package ... ]
  1034. List the general copyright notice(s) for PACKAGE on the
  1035. standard output. Note that individual components in PACKAGE
  1036. may contain additional or replacement notices.
  1037. export [ VARIABLE ... ]
  1038. List NAME=VALUE for each VARIABLE, one per line. If the
  1039. \"only\" attribute is specified then only the variable
  1040. values are listed. If no variables are specified then
  1041. $env are assumed.
  1042. help [ ACTION ]
  1043. Display help text on the standard error [ standard output
  1044. for ACTION ].
  1045. host [ canon cpu name rating type ... ]
  1046. List architecture/implementation dependent host information
  1047. on the standard output. type is listed if no attributes are
  1048. specified. Information is listed on a single line in attributes
  1049. order. The attributes are:
  1050. canon The next argument is a host type name to be
  1051. converted to package syntax.
  1052. cpu The number of cpus; 1 if the host is not a
  1053. multiprocessor.
  1054. name The host name.
  1055. rating The cpu rating in pseudo mips; the value is useful
  1056. useful only in comparisons with rating values of
  1057. other hosts. Other than a vax rating fixed at 1,
  1058. ratings can vary wildly but consistently from
  1059. vendor mips ratings. cc(1) may be required to
  1060. determine the rating.
  1061. type The host type, usually of the form
  1062. vendor.architecture, with an optional trailing
  1063. -version. The main theme is that type names within
  1064. a family of architectures are named in a similar,
  1065. predictable style. Os point release information is
  1066. avoided as much as possible, but vendor resistance
  1067. to release incompatibilities has for the most part
  1068. been futile.
  1069. html [ ACTION ]
  1070. Display html help text on the standard error [ standard output
  1071. for ACTION ].
  1072. install [ ARCHITECTURE ... ] DIR [ PACKAGE ... ]
  1073. Copy the package binary hierarchy to DIR. If ARCHITECTURE is
  1074. omitted then all architectures are installed. If the \"flat\"
  1075. attribute is specified then exactly one ARCHITECTURE must be
  1076. specified; this architecture will be installed in DIR without
  1077. the \"arch/HOSTTYPE\" directory prefixes. Otherwise each
  1078. architecture will be installed in a separate \"arch/HOSTTYPE\"
  1079. subdirectory of DIR. The ARCHITECTURE - names the current
  1080. architecture. DIR must be an existing directory. If PACKAGE
  1081. is omitted then all binary packages are installed. This action
  1082. requires nmake.
  1083. license [ package ... ]
  1084. List the source license(s) for PACKAGE on the standard output.
  1085. Note that individual components in PACKAGE may contain
  1086. additional or replacement licenses.
  1087. list [ PACKAGE ... ]
  1088. List the name, version and prerequisites for PACKAGE on the
  1089. standard output.
  1090. make [ PACKAGE ] [ OPTION ... ] [ TARGET ... ]
  1091. Build and install. The default TARGET is install, which
  1092. makes and installs all packages. If the standard output
  1093. is a terminal then the output is also captured in
  1094. \$INSTALLROOT/lib/package/gen/make.out. The build is done
  1095. in the \$INSTALLROOT directory tree viewpathed on top of
  1096. the \$PACKAGEROOT directory tree. If \"flat\" is specified then
  1097. the \$INSTALLROOT { bin fun include lib } directories are
  1098. linked to the same directories in the package root. Only
  1099. one architecture may be flat. Leaf directory names matching
  1100. the |-separated shell pattern \$MAKESKIP are ignored. The
  1101. view action is done before making. OPTION operands are
  1102. passed to the underlying make command.
  1103. read [ package ... | archive ... ]
  1104. Read the named package archive(s). Must be run from the
  1105. package root directory. Archives are searched for in .
  1106. and lib/package/tgz. Each package is read only once. The
  1107. file lib/package/tgz/package[.type].tim tracks the read time.
  1108. See the write action for archive naming conventions. Text
  1109. file archive member are assumed to be ASCII or UTF-8 encoded.
  1110. regress diff(1) the current and previous package test results.
  1111. release [ [CC]YY-MM-DD [ [cc]yy-mm-dd ] ] [ package ]
  1112. Display recent changes since [CC]YY-MM-DD (up to [cc]yy-mm-dd),
  1113. where - means lowest (or highest.) If no dates are specified
  1114. then changes for the last 4 months are listed. PACKAGE may
  1115. be a package or component name.
  1116. remove PACKAGE
  1117. Remove files installed for PACKAGE.
  1118. results [ path ] [ old ] [ make | test ]
  1119. List results and interesting messages captured by the most
  1120. recent make (default), test or write action. old specifies the
  1121. previous results, if any (current and previous results are
  1122. retained.) $HOME/.pkgresults, if it exists, must contain an
  1123. egrep(1) expression of result lines to be ignored. failed lists
  1124. failures only and path lists the results file path only.
  1125. setup [ beta ] [ binary ] [ source ] [ ARCHITECTURE ... ] [ URL ] [ PACKAGE ... ]
  1126. The action initializes the current directory as a package root,
  1127. runs the update action to download new or out of date packages,
  1128. and runs the read action on those packages. If \"flat\" is
  1129. specified then the \$INSTALLROOT { bin fun include lib }
  1130. directories are linked to the same directories in the package
  1131. root. Only one architecture may be flat. See the update and
  1132. read actions for argument details.
  1133. test [ PACKAGE ]
  1134. Run the regression tests for PACKAGE. If the standard output
  1135. is a terminal then the output is also captured in
  1136. \$INSTALLROOT/lib/package/gen/test.out. In general a package
  1137. must be made before it can be tested. Components tested with
  1138. the \bregress\b(1) command require \bksh93\b. If only is
  1139. also specified then only the listed package components are
  1140. tested, otherwise the closure of the components is tested.
  1141. update [ beta ] [ binary ] [ source ] [ ARCHITECTURE ... ] [ URL ] [ PACKAGE ... ]
  1142. Download the latest release of the selected and required
  1143. packages from URL (e.g.,
  1144. http://www.research.att.com/sw/download) into the directory
  1145. \$PACKAGEROOT/lib/package/tgz. beta accesses beta packages;
  1146. download these at your own risk. If ARCHITECTURE is omitted
  1147. then only architectures already present in the tgz directory
  1148. will be downloaded. If ARCHITECTURE is - then all posted
  1149. architectures will be downloaded. If URL matches *.url then
  1150. it is interpreted as a file containing shell variable
  1151. assignments for url, authorize and password. If URL is
  1152. omitted then the definitions for url, authorize and password
  1153. in \$PACKAGEROOT/lib/package/tgz/$default_url, if it exists,
  1154. are used. If \$PACKAGEROOT/lib/package/tgz/$default_url does
  1155. not exist then it is initialized with the current url,
  1156. authorize and password values and read permission for the
  1157. current user only. If PACKAGE is omitted then only
  1158. packages already present in the tgz directory will be
  1159. downloaded. If PACKAGE is - then all posted packages will be
  1160. downloaded. If source and binary are omitted then both source
  1161. and binary packages will be downloaded. If \bonly\b is
  1162. specified then only the named packages are updated; otherwise
  1163. the closure of required packages is updated. This action
  1164. requires wget(1), lynx(1), curl(1) or a shell that supports
  1165. io to /dev/tcp/HOST/PORT.
  1166. use [ uid | PACKAGE | . [ 32 | 64 ] | 32 | 64 | - ] [ COMMAND ... ]
  1167. Run COMMAND or an interactive shell if COMMAND is omitted, with
  1168. the environment initialized for using the package (can you say
  1169. shared library without cussing?) If uid or PACKAGE or . is
  1170. specified then it is used to determine a \$PACKAGEROOT,
  1171. possibly different from the current directory. For example, to
  1172. try out bozo's package: \"package use bozo\". In this case the
  1173. command may be run from any directory. If the file
  1174. \$INSTALLROOT/lib/package/profile is readable then it is
  1175. sourced to initialize the environment. 32 or 64 implies
  1176. \$PACKAGEROOT of . and specifies the target architecture word
  1177. size (which may be silently ignored.)
  1178. verify [ PACKAGE ]
  1179. Verify installed binary files against the checksum files in
  1180. \$INSTALLROOT/lib/package/gen/*.sum. The checksum files contain
  1181. mode, user and group information. If the checksum matches
  1182. for a given file then the mode, user and group are changed
  1183. as necessary to match the checksum entry. A warning is printed
  1184. on the standard error for each mismatch. Requires the ast
  1185. package cksum(1) command.
  1186. view
  1187. Initialize the architecture specific viewpath hierarchy. The
  1188. make action implicitly calls this action. If \"flat\" is specified
  1189. then the \$INSTALLROOT { bin fun include lib } directories are
  1190. linked to the same directories in the package root. Only one
  1191. architecture may be flat.
  1192. write [closure] [cyg|exp|lcl|pkg|rpm|tgz|tst] [base|delta]
  1193. [binary|runtime|source] PACKAGE
  1194. Write a package archive for PACKAGE. All work is done in the
  1195. \$PACKAGEROOT/lib/package directory. FORMAT-specific files
  1196. are placed in the FORMAT subdirectory. A PACKAGE[.TYPE].tim
  1197. file in this directory tracksthe write time and prevents a
  1198. package from being read in the same root it was written. If
  1199. more than one file is generated for a particular FORMAT then
  1200. those files are placed in the FORMAT/PACKAGE subdirectory.
  1201. File names in the FORMAT subdirectory will contain the package
  1202. name, a YYYY-MM-DD date, and for binary packages, HOSTTYPE.
  1203. If PACKAGE is omitted then an ordered list of previously
  1204. written packages is generated. If \"only\" is specified then
  1205. only the named packages will be written; otherwise
  1206. prerequisite packages are written first. Package components
  1207. must be listed in PACKAGE.pkg. FORMAT may be one of:
  1208. cyg generate a cygwin package
  1209. exp generate an exptools(1) maintainer source archive
  1210. and NPD file in the exp subdirectory, suitable for
  1211. expmake(1); support files are placed in the
  1212. exp/PACKAGE subdirectory
  1213. lcl generate a package archive or delta in the lcl
  1214. subdirectory, suitable for restoration into the
  1215. primary source tree (no source licence annotation)
  1216. pkg generate a pkgmk(1) package, suitable for pkgadd(1)
  1217. rpm generate an rpm(1) package
  1218. tgz generate a gzip(1) tar(1) package archive; this is
  1219. the default
  1220. tst generate tgz FORMAT package archive in the tst
  1221. subdirectory; version state files are not updated
  1222. The package type must be one of source, binary or runtime.
  1223. A source package contains the source needed to build the
  1224. corresponding binary package. A binary package includes the
  1225. libraries and headers needed for compiling and linking
  1226. against the public interfaces. A runtime package contains
  1227. the commands and required dynamic libraries. A package may
  1228. be either a base or delta. A base package contains a
  1229. complete copy of all components. A delta package contains
  1230. only changes from a previous base package. Delta recipients
  1231. must have the ast pax(1) command (in the ast-base package.)
  1232. If neither base nor delta is specified, then the current
  1233. base is overwritten if there are no deltas referring to the
  1234. current base. Only the tgz and lcl formats support delta.
  1235. If base is specified then a new base and two delta archives
  1236. are generated: one delta to generate the new base from the
  1237. old, and one delta to generate the old base from the new;
  1238. the old base is then removed. If delta is specified then a
  1239. new delta referring to the current base is written.
  1240. package.pkg may reference other packages. By default a
  1241. pointer to those packages is written. The recipient package
  1242. read will then check that all required packages have been
  1243. downloaded. If closure is specified then the components for
  1244. all package references are included in the generated
  1245. package. This may be useful for lcl and versioning. All
  1246. formats but lcl annotate each source file (not already
  1247. annotated) with a license comment as it is written to the
  1248. package archive using proto(1).
  1249. name=value:
  1250. variable definition: typically CC=cc or CCFLAGS=-g."
  1251. ;;
  1252. esac
  1253. exit $code
  1254. ;;
  1255. *=*) set DEFAULT host type "$@"
  1256. ;;
  1257. *) echo "Usage: $command [ options ] [ qualifier ... ] [ action ] [ arg ... ] [ n=v ... ]" >&2
  1258. exit 2
  1259. ;;
  1260. esac
  1261. global="$global $1"
  1262. shift
  1263. done
  1264. # gather HOSTTYPE *,* options
  1265. # ,*cc*,-*,... set CC and CCFLAGS
  1266. hostopts()
  1267. {
  1268. _ifs_=$IFS
  1269. IFS=,
  1270. set '' $HOSTTYPE
  1271. IFS=$_ifs_
  1272. shift
  1273. while :
  1274. do case $# in
  1275. 0|1) break ;;
  1276. esac
  1277. shift
  1278. case $1 in
  1279. *cc*) CC=$1
  1280. while :
  1281. do case $# in
  1282. 0|1) break ;;
  1283. esac
  1284. case $2 in
  1285. -*) case $assign_CCFLAGS in
  1286. ?*) assign_CCFLAGS="$assign_CCFLAGS " ;;
  1287. esac
  1288. assign_CCFLAGS="$assign_CCFLAGS$2"
  1289. shift
  1290. ;;
  1291. *) break
  1292. ;;
  1293. esac
  1294. done
  1295. ;;
  1296. esac
  1297. done
  1298. }
  1299. # collect command line targets and definitions
  1300. case $_PACKAGE_HOSTTYPE_ in
  1301. ?*) HOSTTYPE=$_PACKAGE_HOSTTYPE_
  1302. KEEP_HOSTTYPE=1
  1303. ;;
  1304. *) KEEP_HOSTTYPE=0
  1305. ;;
  1306. esac
  1307. KEEP_PACKAGEROOT=0
  1308. KEEP_SHELL=0
  1309. USER_VPATH=
  1310. args=
  1311. assign=
  1312. assign_CCFLAGS=
  1313. for i
  1314. do case $i in
  1315. *:*=*) args="$args $i"
  1316. continue
  1317. ;;
  1318. *=*) eval `echo ' ' "$i" | sed 's,^[ ]*\([^=]*\)=\(.*\),n=\1 v='\''\2'\'','`
  1319. ;;
  1320. esac
  1321. case $i in
  1322. AR=*|LD=*|NM=*)
  1323. assign="$assign $n='$v'"
  1324. eval $n='$'v
  1325. ;;
  1326. CC=*) eval $n='$'v
  1327. ;;
  1328. CCFLAGS=*)
  1329. eval $n='$'v
  1330. assign_CCFLAGS="CCFLAGS=\"\$CCFLAGS\""
  1331. ;;
  1332. HOSTTYPE=*)
  1333. eval $n='$'v
  1334. case $HOSTTYPE in
  1335. ?*) KEEP_HOSTTYPE=1 ;;
  1336. esac
  1337. ;;
  1338. HURL=*) eval $n='$'v
  1339. ;;
  1340. PACKAGEROOT=*)
  1341. eval $n='$'v
  1342. case $PACKAGEROOT in
  1343. ?*) KEEP_PACKAGEROOT=1 ;;
  1344. esac
  1345. ;;
  1346. SHELL=*)eval $n='$'v
  1347. case $SHELL in
  1348. ?*) KEEP_SHELL=1 ;;
  1349. esac
  1350. ;;
  1351. TAR=*) eval $n='$'v
  1352. ;;
  1353. TARFLAGS=*)
  1354. eval $n='$'v
  1355. ;;
  1356. VPATH=*)eval USER_$n='$'v
  1357. ;;
  1358. 'debug=1')
  1359. makeflags="$makeflags --debug-symbols"
  1360. ;;
  1361. 'strip=1')
  1362. makeflags="$makeflags --strip-symbols"
  1363. ;;
  1364. *=*) assign="$assign $n='$v'"
  1365. ;;
  1366. *) args="$args $i"
  1367. ;;
  1368. esac
  1369. done
  1370. case $HOSTTYPE in
  1371. *,*) hostopts $HOSTTYPE ;;
  1372. esac
  1373. case $assign_CCFLAGS in
  1374. ?*) assign="$assign $assign_CCFLAGS"
  1375. esac
  1376. case $CC in
  1377. ''|cc) ;;
  1378. *) export CC ;;
  1379. esac
  1380. # Add build type flags via KSH_RELFLAGS, which is used in src/cmd/ksh93/Mamfile.
  1381. # (Avoid using CCFLAGS; setting it would overwrite autodetected optimization flags.)
  1382. ksh_relflags=
  1383. case `git branch 2>/dev/null` in
  1384. '' | *\*\ [0-9]*.[0-9]*)
  1385. # If we're not on a git branch (tarball) or on a branch that starts
  1386. # with a number (release branch), then compile as a release version
  1387. ksh_relflags="${ksh_relflags:+$ksh_relflags }-D_AST_ksh_release" ;;
  1388. *) # Otherwise, add 8-character git commit hash if available, and if the working dir is clean
  1389. git_commit=`git status >/dev/null 2>&1 && git diff-index --quiet HEAD && git rev-parse --short=8 HEAD`
  1390. case $git_commit in
  1391. ????????)
  1392. ksh_relflags="${ksh_relflags:+$ksh_relflags }-D_AST_git_commit=\\\"$git_commit\\\"" ;;
  1393. esac
  1394. unset git_commit ;;
  1395. esac
  1396. case $ksh_relflags in
  1397. ?*) # add the extra flags as an argument to mamake
  1398. assign="${assign:+$assign }KSH_RELFLAGS=\"\$ksh_relflags\"" ;;
  1399. esac
  1400. # Add ksh compile-options via KSH_SHOPTFLAGS.
  1401. SHOPT()
  1402. {
  1403. case $1 in
  1404. *=?*) ksh_shoptflags="${ksh_shoptflags:+$ksh_shoptflags }-DSHOPT_$1" ;;
  1405. esac
  1406. }
  1407. ksh_shoptflags=
  1408. shopt_sh='src/cmd/ksh93/SHOPT.sh' # this script calls SHOPT() to set options
  1409. if test -f "$shopt_sh"
  1410. then . "$shopt_sh"
  1411. else echo "WARNING: $shopt_sh is missing" >&2
  1412. fi
  1413. case $ksh_shoptflags in
  1414. ?*) # add the extra flags as an argument to mamake
  1415. assign="${assign:+$assign }KSH_SHOPTFLAGS=\"\$ksh_shoptflags\"" ;;
  1416. esac
  1417. # grab action specific args
  1418. case $action in
  1419. admin) while :
  1420. do case $# in
  1421. 0) set list
  1422. break
  1423. ;;
  1424. esac
  1425. case $1 in
  1426. all) admin_all=1
  1427. ;;
  1428. db) case $# in
  1429. 1) echo $command: $action: $1: db file argument expected >&2
  1430. exit 1
  1431. ;;
  1432. esac
  1433. shift
  1434. admin_db=$1
  1435. ;;
  1436. on) case $# in
  1437. 1) echo $command: $action: $1: host pattern argument expected >&2
  1438. exit 1
  1439. ;;
  1440. esac
  1441. shift
  1442. admin_on=$1
  1443. ;;
  1444. *) break
  1445. ;;
  1446. esac
  1447. shift
  1448. done
  1449. admin_action=$1
  1450. admin_args=$*
  1451. for i
  1452. do case $i in
  1453. debug|environment|force|never|only|quiet|show|DEBUG)
  1454. ;;
  1455. *) admin_action=$i
  1456. break
  1457. ;;
  1458. esac
  1459. done
  1460. ;;
  1461. setup) PACKAGEROOT=${PWD:-`pwd`}
  1462. export PACKAGEROOT
  1463. KEEP_PACKAGEROOT=1
  1464. ;;
  1465. use) case $1 in
  1466. .|32|64)case $1 in
  1467. 32|64) bit=$1 ;;
  1468. esac
  1469. shift
  1470. # HOSTTYPE specific setup
  1471. case $HOSTTYPE in
  1472. win32.*)sys=uwin
  1473. wow=`uname -i`
  1474. case $bit in
  1475. 32) case $HOSTTYPE in
  1476. *-64) HOSTTYPE=${HOSTTYPE%-64} ;;
  1477. esac
  1478. ;;
  1479. 64) case $HOSTTYPE in
  1480. *-64) ;;
  1481. *) HOSTTYPE=$HOSTTYPE-64 ;;
  1482. esac
  1483. case $wow in
  1484. */32) echo $command: cannot build $bit-bit on $wow $sys >&2; exit 2 ;;
  1485. esac
  1486. ;;
  1487. esac
  1488. case $bit in
  1489. '') PS1="($sys) " ;;
  1490. *) PS1="($sys-$bit) " ;;
  1491. esac
  1492. $exec umask 002
  1493. $exec unset MAKESKIP
  1494. $exec export P=$PWD
  1495. $exec export A=$P/arch/$HOSTTYPE
  1496. $exec export CDPATH=:..:$A/src/cmd:$A/src/lib:$A/src/uwin:$P/lib/package
  1497. $exec export INSTALLROOT=$A
  1498. $exec export PACKAGEROOT=$P
  1499. $exec export PATH=$A/bin:$P/bin:$PATH
  1500. $exec export PS1="$PS1"
  1501. $exec export VPATH=$A:$P
  1502. $exec export nativepp=/usr/lib
  1503. if test '' != "$INSTALLROOT" -a -d $INSTALLROOT/include/ast
  1504. then $exec export PACKAGE_ast=$INSTALLROOT
  1505. elif test -d ${PWD%/*}/ast/arch/$HOSTTYPE
  1506. then $exec export PACKAGE_ast=${PWD%/*}/ast/arch/$HOSTTYPE
  1507. fi
  1508. # run the command
  1509. case $# in
  1510. 0) case $show in
  1511. ':') $exec exec $SHELL ;;
  1512. esac
  1513. ;;
  1514. *) $exec exec $SHELL -c "$@"
  1515. ;;
  1516. esac
  1517. exit
  1518. ;;
  1519. esac
  1520. PACKAGEROOT=${PWD:-`pwd`}
  1521. $show export PACKAGEROOT
  1522. esac
  1523. ;;
  1524. esac
  1525. # true if arg is a valid PACKAGEROOT
  1526. packageroot() # dir
  1527. {
  1528. test -d $1/lib/$command -o -x $1/bin/$command
  1529. }
  1530. # true if arg is executable
  1531. executable() # [!] command
  1532. {
  1533. case $1 in
  1534. '!') test ! -x "$2" -a ! -x "$2.exe"; return ;;
  1535. *) test -x "$1" -o -x "$1.exe"; return ;;
  1536. esac
  1537. }
  1538. # initialize SHELLMAGIC
  1539. # tangible proof of cygwin's disdain for unix (well, this and execrate)
  1540. shellmagic()
  1541. {
  1542. case $SHELLMAGIC in
  1543. '') ;;
  1544. -) if test -f /emx/bin/sh.exe
  1545. then SHELLMAGIC='#!/emx/bin/sh.exe'$nl
  1546. elif test -f /bin/env.exe
  1547. then SHELLMAGIC='#!/bin/env sh'$nl
  1548. else SHELLMAGIC=
  1549. fi
  1550. ;;
  1551. esac
  1552. }
  1553. # true if arg is executable command on $PATH
  1554. onpath() # command
  1555. {
  1556. _onpath_b=$1
  1557. case $_onpath_b in
  1558. /*) if executable $_onpath_b
  1559. then _onpath_=$_onpath_b
  1560. return 0
  1561. fi
  1562. return 1
  1563. ;;
  1564. esac
  1565. IFS=':'
  1566. set '' $PATH
  1567. IFS=$ifs
  1568. shift
  1569. for _onpath_d
  1570. do case $_onpath_d in
  1571. '') _onpath_d=. ;;
  1572. esac
  1573. if executable "$_onpath_d/$_onpath_b"
  1574. then _onpath_=$_onpath_d/$_onpath_b
  1575. return 0
  1576. fi
  1577. done
  1578. return 1
  1579. }
  1580. # true if no nmake or nmake not from AT&T or nmake too old
  1581. nonmake() # nmake
  1582. {
  1583. _nonmake_version=`( $1 -n -f - 'print $(MAKEVERSION:@/.*AT&T.* //:/-//G:@/.* .*/19960101/)' . ) </dev/null 2>/dev/null || echo 19840919`
  1584. if test $_nonmake_version -lt 20001031
  1585. then return 0
  1586. fi
  1587. return 1
  1588. }
  1589. # determine local host attributes
  1590. hostinfo() # attribute ...
  1591. {
  1592. case $DEBUG in
  1593. 1) set -x ;;
  1594. esac
  1595. map=
  1596. something=
  1597. path=$PATH
  1598. for i in $ccs
  1599. do PATH=$PATH:$i
  1600. done
  1601. for i in $use
  1602. do for j in $org
  1603. do PATH=$PATH:$i/$j/bin
  1604. done
  1605. PATH=$PATH:$i/bin
  1606. done
  1607. # LD_LIBRARY_PATH may be out of sync with PATH here
  1608. case $SED in
  1609. '') SED=sed
  1610. $SED 1d < /dev/null > /dev/null 2>&1 ||
  1611. for dir in /bin /usr/bin
  1612. do if test -x $dir/$SED
  1613. then SED=$dir/$SED
  1614. break
  1615. fi
  1616. done
  1617. TR=tr
  1618. $TR < /dev/null > /dev/null 2>&1 ||
  1619. for dir in /bin /usr/bin
  1620. do if test -x $dir/$TR
  1621. then TR=$dir/$TR
  1622. break
  1623. fi
  1624. done
  1625. ;;
  1626. esac
  1627. case $PACKAGE_PATH in
  1628. ?*) for i in `echo $PACKAGE_PATH | $SED 's,:, ,g'`
  1629. do PATH=$PATH:$i/bin
  1630. done
  1631. ;;
  1632. esac
  1633. # validate the args
  1634. canon=
  1635. cc=$CC
  1636. for info
  1637. do case $canon in
  1638. -) canon=$info
  1639. ;;
  1640. *) case $info in
  1641. */*|*[cC][cC])
  1642. cc=$info
  1643. ;;
  1644. canon) canon=-
  1645. something=1
  1646. ;;
  1647. cpu|name|rating|type)
  1648. something=1
  1649. ;;
  1650. *) echo "$command: $action: $info: unknown attribute" >&2
  1651. exit 1
  1652. ;;
  1653. esac
  1654. ;;
  1655. esac
  1656. done
  1657. case $canon in
  1658. -) echo "$command: $action: canon: host type name expected" >&2
  1659. exit 1
  1660. ;;
  1661. esac
  1662. case $something in
  1663. "") set "$@" type ;;
  1664. esac
  1665. case $DEBUG in
  1666. '') exec 9>&2
  1667. exec 2>/dev/null
  1668. ;;
  1669. esac
  1670. # compute the info
  1671. _hostinfo_=
  1672. for info
  1673. do
  1674. case $info in
  1675. cpu) case $NPROC in
  1676. [123456789]*)
  1677. _hostinfo_="$_hostinfo_ $NPROC"
  1678. continue
  1679. ;;
  1680. esac
  1681. cpu=`sysctl -n hw.ncpu`
  1682. case $cpu in
  1683. [123456789]*)
  1684. _hostinfo_="$_hostinfo_ $cpu"
  1685. continue
  1686. ;;
  1687. esac
  1688. cpu=`grep -ic '^processor[ ][ ]*:[ ]*[0123456789]' /proc/cpuinfo`
  1689. case $cpu in
  1690. [123456789]*)
  1691. _hostinfo_="$_hostinfo_ $cpu"
  1692. continue
  1693. ;;
  1694. esac
  1695. cpu=1
  1696. # exact match
  1697. set \
  1698. hinv '^Processor [0123456789]' \
  1699. psrinfo 'on-line' \
  1700. 'cat /reg/LOCAL_MACHINE/Hardware/Description/System/CentralProcessor' '.' \
  1701. 'cat /proc/registry/HKEY_LOCAL_MACHINE/Hardware/Description/System/CentralProcessor' '.' \
  1702. while :
  1703. do case $# in
  1704. 0) break ;;
  1705. esac
  1706. i=`$1 2>/dev/null | grep -c "$2"`
  1707. case $i in
  1708. [123456789]*)
  1709. cpu=$i
  1710. break
  1711. ;;
  1712. esac
  1713. shift;shift
  1714. done
  1715. case $cpu in
  1716. 0|1) set \
  1717. /bin/mpstat
  1718. while :
  1719. do case $# in
  1720. 0) break ;;
  1721. esac
  1722. if executable $1
  1723. then case `$1 | grep -ic '^cpu '` in
  1724. 1) cpu=`$1 | grep -ic '^ *[0123456789][0123456789]* '`
  1725. break
  1726. ;;
  1727. esac
  1728. fi
  1729. shift
  1730. done
  1731. ;;
  1732. esac
  1733. case $cpu in
  1734. 0|1) # token match
  1735. set \
  1736. /usr/kvm/mpstat 'cpu[0123456789]' \
  1737. /usr/etc/cpustatus 'enable' \
  1738. /usr/alliant/showsched 'CE' \
  1739. 'ls /config/hw/system/cpu' 'cpu' \
  1740. prtconf 'cpu-unit' \
  1741. while :
  1742. do case $# in
  1743. 0) break ;;
  1744. esac
  1745. i=`$1 2>/dev/null | $TR ' ' '
  1746. ' | grep -c "^$2"`
  1747. case $i in
  1748. [123456789]*)
  1749. cpu=$i
  1750. break
  1751. ;;
  1752. esac
  1753. shift;shift
  1754. done
  1755. ;;
  1756. esac
  1757. case $cpu in
  1758. 0|1) # special match
  1759. set \
  1760. \
  1761. hinv \
  1762. '/^[0123456789][0123456789]* .* Processors*$/' \
  1763. '/[ ].*//' \
  1764. \
  1765. /usr/bin/hostinfo \
  1766. '/^[0123456789][0123456789]* .* physically available\.*$/' \
  1767. '/[ ].*//' \
  1768. while :
  1769. do case $# in
  1770. 0) break ;;
  1771. esac
  1772. i=`$1 2>/dev/null | $SED -e "${2}!d" -e "s${3}"`
  1773. case $i in
  1774. [123456789]*)
  1775. cpu=$i
  1776. break
  1777. ;;
  1778. esac
  1779. shift;shift;shift
  1780. done
  1781. ;;
  1782. esac
  1783. case $cpu in
  1784. 0|1) cpu=`(
  1785. cd "$TMPDIR"
  1786. tmp=hi$$
  1787. trap 'rm -f $tmp.*' 0 1 2
  1788. cat > $tmp.c <<!
  1789. #include <stdio.h>
  1790. #include <pthread.h>
  1791. int main()
  1792. {
  1793. printf("%d\n", pthread_num_processors_np());
  1794. return 0;
  1795. }
  1796. !
  1797. for o in -lpthread ''
  1798. do if $CC $o -O -o $tmp.exe $tmp.c $o >/dev/null 2>&1 ||
  1799. gcc $o -O -o $tmp.exe $tmp.c $o >/dev/null 2>&1
  1800. then ./$tmp.exe
  1801. break
  1802. fi
  1803. done
  1804. )`
  1805. case $cpu in
  1806. [0123456789]*) ;;
  1807. *) cpu=1 ;;
  1808. esac
  1809. ;;
  1810. esac
  1811. _hostinfo_="$_hostinfo_ $cpu"
  1812. ;;
  1813. name) _name_=`hostname || uname -n || cat /etc/whoami || echo local`
  1814. _hostinfo_="$_hostinfo_ $_name_"
  1815. ;;
  1816. rating) for rating in `grep -i ^bogomips /proc/cpuinfo 2>/dev/null | $SED -e 's,.*:[ ]*,,' -e 's,\(...*\)\..*,\1,' -e 's,\(\..\).*,\1,'`
  1817. do case $rating in
  1818. [0123456789]*) break ;;
  1819. esac
  1820. done
  1821. case $rating in
  1822. [0123456789]*) ;;
  1823. *) cd "$TMPDIR"
  1824. tmp=hi$$
  1825. trap 'rm -f $tmp.*' 0 1 2
  1826. cat > $tmp.c <<!
  1827. #include <stdio.h>
  1828. #include <sys/types.h>
  1829. #if TD || TZ
  1830. #include <sys/time.h>
  1831. #else
  1832. extern time_t time();
  1833. #endif
  1834. int main()
  1835. {
  1836. register unsigned long i;
  1837. register unsigned long j;
  1838. register unsigned long k;
  1839. unsigned long l;
  1840. unsigned long m;
  1841. unsigned long t;
  1842. int x;
  1843. #if TD || TZ
  1844. struct timeval b;
  1845. struct timeval e;
  1846. #if TZ
  1847. struct timezone z;
  1848. #endif
  1849. #endif
  1850. l = 500;
  1851. m = 890;
  1852. x = 0;
  1853. for (;;)
  1854. {
  1855. #if TD || TZ
  1856. #if TZ
  1857. gettimeofday(&b, &z);
  1858. #else
  1859. gettimeofday(&b);
  1860. #endif
  1861. #else
  1862. t = (unsigned long)time((time_t*)0);
  1863. #endif
  1864. k = 0;
  1865. for (i = 0; i < l; i++)
  1866. for (j = 0; j < 50000; j++)
  1867. k += j;
  1868. #if TD || TZ
  1869. #if TZ
  1870. gettimeofday(&e, &z);
  1871. #else
  1872. gettimeofday(&e);
  1873. #endif
  1874. t = (e.tv_sec - b.tv_sec) * 1000 + (e.tv_usec - b.tv_usec) / 1000;
  1875. if (!x++ && t < 1000)
  1876. {
  1877. t = 10000 / t;
  1878. l = (l * t) / 10;
  1879. continue;
  1880. }
  1881. #else
  1882. t = ((unsigned long)time((time_t*)0) - t) * 1000;
  1883. if (!x++ && t < 20000)
  1884. {
  1885. t = 200000l / t;
  1886. l = (l * t) / 10;
  1887. continue;
  1888. }
  1889. #endif
  1890. #if PR
  1891. printf("[ k=%lu l=%lu m=%lu t=%lu ] ", k, l, m, t);
  1892. #endif
  1893. if (t == 0)
  1894. t = 1;
  1895. break;
  1896. }
  1897. printf("%lu\n", ((l * m) / 10) / t);
  1898. return k == 0;
  1899. }
  1900. !
  1901. rating=
  1902. for o in -DTZ -DTD ''
  1903. do if $CC $o -O -o $tmp.exe $tmp.c >/dev/null 2>&1 ||
  1904. gcc $o -O -o $tmp.exe $tmp.c >/dev/null 2>&1
  1905. then rating=`./$tmp.exe`
  1906. break
  1907. fi
  1908. done
  1909. case $rating in
  1910. [0123456789]*) ;;
  1911. *) rating=1 ;;
  1912. esac
  1913. ;;
  1914. esac
  1915. _hostinfo_="$_hostinfo_ $rating"
  1916. ;;
  1917. type|canon)
  1918. case $CROSS:$canon in
  1919. 0:) case $cc in
  1920. cc) case $KEEP_HOSTTYPE:$HOSTTYPE in
  1921. 0:?*) if test -d ${PACKAGEROOT:-.}/arch/$HOSTTYPE
  1922. then KEEP_HOSTTYPE=1
  1923. fi
  1924. ;;
  1925. esac
  1926. ;;
  1927. esac
  1928. case $KEEP_HOSTTYPE in
  1929. 1) _hostinfo_="$_hostinfo_ $HOSTTYPE"
  1930. continue
  1931. ;;
  1932. esac
  1933. ;;
  1934. esac
  1935. case $cc in
  1936. /*) a=`$cc -dumpmachine $CCFLAGS 2>/dev/null`
  1937. case $a in
  1938. '') case $CCFLAGS in
  1939. ?*) a=`$cc -dumpmachine 2>/dev/null` ;;
  1940. esac
  1941. ;;
  1942. esac
  1943. case $a in
  1944. ''|*' '*|*/*:*)
  1945. ;;
  1946. *.*-*) _hostinfo_="$_hostinfo_ $a"
  1947. continue
  1948. ;;
  1949. *-*-*) case $canon in
  1950. '') canon=$a ;;
  1951. esac
  1952. ;;
  1953. *) _hostinfo_="$_hostinfo_ $a"
  1954. continue
  1955. ;;
  1956. esac
  1957. ;;
  1958. esac
  1959. IFS=:
  1960. set /$IFS$PATH
  1961. IFS=$ifs
  1962. shift
  1963. f=../lib/hostinfo/typemap
  1964. for i
  1965. do case $i in
  1966. "") i=. ;;
  1967. esac
  1968. case $canon in
  1969. '') case $cc in
  1970. /*|cc) ;;
  1971. *) if executable $i/$cc
  1972. then a=`$i/$cc -dumpmachine $CCFLAGS 2>/dev/null`
  1973. case $a in
  1974. '') case $CCFLAGS in
  1975. ?*) a=`$cc -dumpmachine 2>/dev/null` ;;
  1976. esac
  1977. ;;
  1978. esac
  1979. case $a in
  1980. ''|*' '*|*/*:*)
  1981. ;;
  1982. *-*) canon=$a
  1983. ;;
  1984. *) _hostinfo_="$_hostinfo_ $a"
  1985. continue 2
  1986. ;;
  1987. esac
  1988. fi
  1989. ;;
  1990. esac
  1991. ;;
  1992. esac
  1993. if test -f "$i/$f"
  1994. then map="`grep -v '^#' $i/$f` $map"
  1995. fi
  1996. done
  1997. # inconsistent -dumpmachine filtered here
  1998. case -${canon}- in
  1999. --|*-powerpc-*)
  2000. h=`hostname || uname -n || cat /etc/whoami`
  2001. case $h in
  2002. '') h=local ;;
  2003. esac
  2004. a=`arch || uname -m || att uname -m || uname -s || att uname -s`
  2005. case $a in
  2006. *[\ \ ]*) a=`echo $a | $SED "s/[ ]/-/g"` ;;
  2007. esac
  2008. case $a in
  2009. '') a=unknown ;;
  2010. esac
  2011. m=`mach || machine || uname -p || att uname -p`
  2012. case $m in
  2013. *[\ \ ]*) m=`echo $m | $SED "s/[ ]/-/g"` ;;
  2014. esac
  2015. case $m in
  2016. '') m=unknown ;;
  2017. esac
  2018. x=`uname -a || att uname -a`
  2019. case $x in
  2020. '') x="unknown $host unknown unknown unknown unknown unknown" ;;
  2021. esac
  2022. set "" $h $a $m $x
  2023. expected=$1 host=$2 arch=$3 mach=$4 os=$5 sys=$6 rel=$7 ver=$8
  2024. ;;
  2025. *) case $canon in
  2026. *-*) IFS=-
  2027. set "" $canon
  2028. shift
  2029. IFS=$ifs
  2030. case $# in
  2031. 2) host= mach= arch=$1 os=$2 sys= rel= ;;
  2032. *) host= mach=$2 arch=$1 os=$3 sys= rel= ;;
  2033. esac
  2034. case $os in
  2035. [abcdefghijklmnopqrstuvwxyz]*[0123456789])
  2036. eval `echo $os | $SED -e 's/^\([^0123456789.]*\)\.*\(.*\)/os=\1 rel=\2/'`
  2037. ;;
  2038. esac
  2039. ;;
  2040. *) arch=$canon mach= os= sys= rel=
  2041. ;;
  2042. esac
  2043. ;;
  2044. esac
  2045. type=unknown
  2046. case $host in
  2047. *.*) host=`echo $host | $SED -e 's/\..*//'` ;;
  2048. esac
  2049. case $mach in
  2050. unknown)
  2051. mach=
  2052. ;;
  2053. [Rr][0123][0123456789][0123456789][0123456789])
  2054. mach=mips1
  2055. ;;
  2056. [Rr][4][0123456789][0123456789][0123456789])
  2057. mach=mips2
  2058. ;;
  2059. [Rr][56789][0123456789][0123456789][0123456789]|[Rr][123456789][0123456789][0123456789][0123456789][0123456789])
  2060. mach=mips4
  2061. ;;
  2062. pc) arch=i386
  2063. mach=
  2064. ;;
  2065. [Pp][Oo][Ww][Ee][Rr][Pp][Cc])
  2066. arch=ppc
  2067. mach=
  2068. ;;
  2069. *) case $arch in
  2070. 34[0123456789][0123456789])
  2071. os=ncr
  2072. arch=i386
  2073. ;;
  2074. esac
  2075. ;;
  2076. esac
  2077. case $canon in
  2078. '') set \
  2079. \
  2080. /NextDeveloper -d next - \
  2081. /config/hw/system/cpu -d tandem mach \
  2082. while :
  2083. do case $# in
  2084. 0) break ;;
  2085. esac
  2086. if test $2 $1
  2087. then os=$3
  2088. case $4 in
  2089. arch) mach=$arch ;;
  2090. mach) arch=$mach ;;
  2091. esac
  2092. break
  2093. fi
  2094. shift;shift;shift;shift
  2095. done
  2096. ;;
  2097. esac
  2098. case $os in
  2099. AIX*|aix*)
  2100. type=ibm.risc
  2101. ;;
  2102. HP-UX) case $arch in
  2103. 9000/[78]*)
  2104. type=hp.pa
  2105. ;;
  2106. */*) type=hp.`echo $arch | $SED 's,/,_,g'`
  2107. ;;
  2108. *) type=hp.$arch
  2109. ;;
  2110. esac
  2111. ;;
  2112. [Ii][Rr][Ii][Xx]*)
  2113. set xx `hinv | $SED -e '/^CPU:/!d' -e 's/CPU:[ ]*\([^ ]*\)[ ]*\([^ ]*\).*/\1 \2/' -e q | $TR ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
  2114. shift
  2115. type=$1
  2116. n=
  2117. case $2 in
  2118. r[0123][0123456789][0123456789][0123456789])
  2119. n=1
  2120. ;;
  2121. r[4][0123][0123456789][0123456789])
  2122. n=2
  2123. ;;
  2124. r[4][456789][0123456789][0123456789]|r[5][0123456789][0123456789][0123456789])
  2125. n=3
  2126. ;;
  2127. r[6789][0123456789][0123456789][0123456789]|r[123456789][0123456789][0123456789][0123456789][0123456789])
  2128. n=4
  2129. ;;
  2130. esac
  2131. case $rel in
  2132. [01234].*|5.[012]|5.[012].*)
  2133. case $n in
  2134. 1) ;;
  2135. *) n=2 ;;
  2136. esac
  2137. ;;
  2138. 5.*) case $n in
  2139. 2) n=3 ;;
  2140. esac
  2141. ;;
  2142. esac
  2143. if executable $cc
  2144. then a=$cc
  2145. else IFS=:
  2146. set /$IFS$PATH
  2147. IFS=$ifs
  2148. shift
  2149. for i
  2150. do a=$i/$cc
  2151. if executable $a
  2152. then break
  2153. fi
  2154. done
  2155. fi
  2156. split='
  2157. '
  2158. a=`strings $a < /dev/null | $SED -e 's/[^abcdefghijklmnopqrstuvwxyz0123456789]/ /g' -e 's/[ ][ ]*/\'"$split"'/g' | $SED -e "/^${type}[0123456789]$/!d" -e "s/^${type}//" -e q`
  2159. case $a in
  2160. [0123456789]) n=$a ;;
  2161. esac
  2162. case $n in
  2163. 4) a=`$cc -${type}3 2>&1`
  2164. case $a in
  2165. *unknown*|*install*|*conflict*)
  2166. ;;
  2167. *) n=3
  2168. ;;
  2169. esac
  2170. ;;
  2171. esac
  2172. a=`$cc -show F0oB@r.c 2>&1`
  2173. case $n:$a in
  2174. [!2]:*mips2*) n=2 ;;
  2175. [!23]:*mips3*) n=3 ;;
  2176. [!234]:*mips4*) n=4 ;;
  2177. esac
  2178. case $n:$a in
  2179. [!2]:*[Oo]32*) abi=-o32 ;;
  2180. [!3]:*[Nn]32*) abi=-n32 ;;
  2181. esac
  2182. mach=${type}$n
  2183. type=sgi.$mach
  2184. ;;
  2185. OSx*|SMP*|pyramid)
  2186. type=pyr
  2187. ;;
  2188. OS/390) type=mvs.390
  2189. ;;
  2190. [Ss][Cc][Oo]*)
  2191. type=sco
  2192. ;;
  2193. [Ss]ol*)
  2194. v=`echo $rel | $SED -e 's/^[25]\.//' -e 's/\.[^.]*$//'`
  2195. case $v in
  2196. [6789]|[1-9][0-9])
  2197. ;;
  2198. *) v=
  2199. ;;
  2200. esac
  2201. case $arch in
  2202. '') case $mach in
  2203. '') arch=sun4 ;;
  2204. *) arch=$mach ;;
  2205. esac
  2206. ;;
  2207. esac
  2208. case $arch in
  2209. sparc) arch=sun4 ;;
  2210. esac
  2211. type=sol$v.$arch
  2212. ;;
  2213. [Ss]un*)type=`echo $arch | $SED -e 's/\(sun.\).*/\1/'`
  2214. case $type in
  2215. sparc) type=sun4 ;;
  2216. esac
  2217. case $rel in
  2218. [01234]*)
  2219. ;;
  2220. '') case $os in
  2221. *[Oo][Ss])
  2222. ;;
  2223. *) type=sol.$type
  2224. ;;
  2225. esac
  2226. ;;
  2227. *) case $type in
  2228. '') case $mach in
  2229. sparc*) type=sun4 ;;
  2230. *) type=$mach ;;
  2231. esac
  2232. ;;
  2233. esac
  2234. v=`echo $rel | $SED -e 's/^[25]\.//' -e 's/\.[^.]*$//'`
  2235. case $v in
  2236. [6789]|[1-9][0-9])
  2237. ;;
  2238. *) v=
  2239. ;;
  2240. esac
  2241. type=sol$v.$type
  2242. ;;
  2243. esac
  2244. case $type in
  2245. sun*|*.*)
  2246. ;;
  2247. *) type=sun.$type
  2248. ;;
  2249. esac
  2250. ;;
  2251. [Uu][Nn][Ii][Xx]_[Ss][Vv])
  2252. type=unixware
  2253. ;;
  2254. UTS*|uts*)
  2255. if test -x /bin/u370 -o -x /bin/u390
  2256. then type=uts.390
  2257. else case $arch in
  2258. '') arch=$mach ;;
  2259. esac
  2260. type=uts.$arch
  2261. fi
  2262. ;;
  2263. $host) type=$arch
  2264. case $type in
  2265. *.*|*[0123456789]*86|*68*)
  2266. ;;
  2267. *) case $mach in
  2268. *[0123456789]*86|*68*|mips)
  2269. type=$type.$mach
  2270. ;;
  2271. esac
  2272. ;;
  2273. esac
  2274. ;;
  2275. unknown)
  2276. case $arch in
  2277. ?*) case $arch in
  2278. sun*) mach= ;;
  2279. esac
  2280. type=$arch
  2281. case $mach in
  2282. ?*) type=$type.$mach ;;
  2283. esac
  2284. ;;
  2285. esac
  2286. ;;
  2287. *) case $ver in
  2288. FTX*|ftx*)
  2289. case $mach in
  2290. *[0123456789][abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]*)
  2291. mach=`echo $mach | $SED -e 's/[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]*$//'`
  2292. ;;
  2293. esac
  2294. type=stratus.$mach
  2295. ;;
  2296. *) case $arch in
  2297. [Oo][Ss][-/.]2)
  2298. type=os2
  2299. arch=$rel
  2300. ;;
  2301. *) type=`echo $os | $SED -e 's/[0123456789].*//' -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_0123456789.].*//'`
  2302. ;;
  2303. esac
  2304. case $type in
  2305. [Cc][Yy][Gg][Ww][Ii][Nn]_*)
  2306. type=cygwin
  2307. ;;
  2308. [Uu][Ww][Ii][Nn]*|[Ww]indows_[0123456789][0123456789]|[Ww]indows_[Nn][Tt])
  2309. type=win32
  2310. arch=`echo $arch | $SED -e 's/_[^_]*$//'`
  2311. ;;
  2312. esac
  2313. case $arch in
  2314. '') case $mach in
  2315. ?*) type=$type.$mach ;;
  2316. esac
  2317. ;;
  2318. *) type=$type.$arch ;;
  2319. esac
  2320. ;;
  2321. esac
  2322. esac
  2323. case $type in
  2324. [0123456789]*)
  2325. case $mach in
  2326. ?*) type=$mach ;;
  2327. esac
  2328. case $type in
  2329. */MC) type=ncr.$type ;;
  2330. esac
  2331. ;;
  2332. *.*) ;;
  2333. *[0123456789]*86|*68*)
  2334. case $rel in
  2335. [34].[0123456789]*)
  2336. type=att.$type
  2337. ;;
  2338. esac
  2339. ;;
  2340. [abcdefghijklmnopqrstuvwxyz]*[0123456789])
  2341. ;;
  2342. [abcdefghijklmnopqrstuvwxyz]*) case $mach in
  2343. $type) case $ver in
  2344. Fault*|fault*|FAULT*)
  2345. type=ft.$type
  2346. ;;
  2347. esac
  2348. ;;
  2349. ?*) case $arch in
  2350. '') type=$type.$mach ;;
  2351. *) type=$type.$arch ;;
  2352. esac
  2353. ;;
  2354. esac
  2355. ;;
  2356. esac
  2357. case $type in
  2358. *[-_]32|*[-_]64|*[-_]128)
  2359. bits=`echo $type | $SED 's,.*[-_],,'`
  2360. type=`echo $type | $SED 's,[-_][0-9]*$,,'`
  2361. ;;
  2362. *) bits=
  2363. ;;
  2364. esac
  2365. type=`echo $type | $SED -e 's%[-+/].*%%' | $TR ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
  2366. case $type in
  2367. *.*) lhs=`echo $type | $SED -e 's/\..*//'`
  2368. rhs=`echo $type | $SED -e 's/.*\.//'`
  2369. case $rhs in
  2370. [x0123456789]*86) rhs=i$rhs ;;
  2371. 68*) rhs=m$rhs ;;
  2372. esac
  2373. case $rhs in
  2374. i[x23456789]86|i?[x23456789]86|*86pc)
  2375. rhs=i386 ;;
  2376. powerpc) rhs=ppc ;;
  2377. s[0123456789]*[0123456789]x)
  2378. rhs=`echo $rhs | $SED -e 's/x$/-64/'` ;;
  2379. esac
  2380. case $rhs in
  2381. arm[abcdefghijklmnopqrstuvwxyz_][0123456789]*)
  2382. rhs=arm ;;
  2383. hppa) rhs=pa ;;
  2384. esac
  2385. case $lhs in
  2386. ?*coff|?*dwarf|?*elf)
  2387. case $lhs in
  2388. ?*coff) x=coff ;;
  2389. ?*dwarf)x=coff ;;
  2390. ?*elf) x=elf ;;
  2391. esac
  2392. lhs=`echo ${lhs}XXX | $SED -e "s/${x}XXX//"`
  2393. ;;
  2394. esac
  2395. case $lhs in
  2396. bsdi) lhs=bsd ;;
  2397. darwin) case `/usr/bin/cc --version` in
  2398. *'(GCC)'*) case $rel in
  2399. [0-9].*|10.*) lhs=darwin07 ;;
  2400. *) lhs=darwin11 ;;
  2401. esac ;;
  2402. esac
  2403. ;;
  2404. freebsd) case $rel in
  2405. [01234].*) lhs=${lhs}4 ;;
  2406. [123456789]*.*) lhs=${lhs}`echo $rel | $SED -e 's/\..*//'` ;;
  2407. esac
  2408. ;;
  2409. hpux) lhs=hp ;;
  2410. mvs) rhs=390 ;;
  2411. esac
  2412. case $lhs in
  2413. '') type=$rhs ;;
  2414. $rhs) type=$lhs ;;
  2415. *) type=$lhs.$rhs ;;
  2416. esac
  2417. ;;
  2418. esac
  2419. case $type in
  2420. sgi.mips*)
  2421. case $mach in
  2422. mips2) type=sgi.$mach
  2423. abi=-o32
  2424. ;;
  2425. mips3) type=sgi.$mach
  2426. abi=-n32
  2427. ;;
  2428. mips[456789])
  2429. type=sgi.$mach
  2430. case $abi in
  2431. *-n32) ;;
  2432. *) abi=-64 ;;
  2433. esac
  2434. ;;
  2435. *) pwd=`pwd`
  2436. cd "$TMPDIR"
  2437. tmp=hi$$
  2438. trap 'rm -f $tmp.*' 0 1 2
  2439. cat > $tmp.a.c <<!
  2440. extern int b();
  2441. int main() { return b(); }
  2442. !
  2443. cat > $tmp.b.c <<!
  2444. int b() { return 0; }
  2445. !
  2446. abi=
  2447. if $cc -c $tmp.a.c
  2448. then for i in -n32 -o32 -64
  2449. do if $cc $i -c $tmp.b.c &&
  2450. $cc -o $tmp.exe $tmp.a.o $tmp.b.o
  2451. then abi=$i
  2452. for i in 2 3 4 5 6 7 8 9
  2453. do case $i:$abi in
  2454. 2:-n32|2:-64|3:-64)
  2455. continue
  2456. ;;
  2457. esac
  2458. if $cc $abi -mips$i -c $tmp.b.c &&
  2459. $cc -o $tmp.exe $tmp.a.o $tmp.b.o
  2460. then type=`echo $type | $SED -e 's/.$//'`$i
  2461. break
  2462. fi
  2463. done
  2464. break
  2465. fi
  2466. done
  2467. fi </dev/null >/dev/null 2>&1
  2468. rm -f $tmp.*
  2469. trap - 0 1 2
  2470. cd $pwd
  2471. ;;
  2472. esac
  2473. case $type$abi in
  2474. sgi.mips2-o32)
  2475. ;;
  2476. sgi.mips3)
  2477. type=$type-o32
  2478. ;;
  2479. sgi.mips3-n32)
  2480. ;;
  2481. sgi.mips4)
  2482. type=$type-o32
  2483. ;;
  2484. sgi.mips[456789]-64)
  2485. ;;
  2486. *) type=$type$abi
  2487. ;;
  2488. esac
  2489. ;;
  2490. *) case $bits in
  2491. '') bits=` cd "$TMPDIR"
  2492. tmp=hi$$
  2493. trap 'rm -f $tmp.*' 0 1 2
  2494. echo 'int main() { return 0; }' > $tmp.a.c
  2495. $cc $CCFLAGS -o $tmp.a.exe $tmp.a.c </dev/null >/dev/null 2>&1
  2496. file $tmp.a.exe 2>/dev/null | sed "s/$tmp\.a\.exe//g" `
  2497. case $bits in
  2498. *64*) bits=64 ;;
  2499. *) bits= ;;
  2500. esac
  2501. ;;
  2502. esac
  2503. ;;
  2504. esac
  2505. case $bits in
  2506. 32) case $type in
  2507. *.i386) bits= ;;
  2508. esac
  2509. ;;
  2510. esac
  2511. case $bits in
  2512. ?*) type=$type-$bits ;;
  2513. esac
  2514. # last chance mapping
  2515. set "" "" $map
  2516. while :
  2517. do case $# in
  2518. [012]) break ;;
  2519. esac
  2520. shift;shift
  2521. eval " case \$type in
  2522. $1) type=\$2; break ;;
  2523. esac"
  2524. done
  2525. _hostinfo_="$_hostinfo_ $type"
  2526. ;;
  2527. esac
  2528. done
  2529. set '' $_hostinfo_
  2530. shift
  2531. _hostinfo_=$*
  2532. # restore the global state
  2533. PATH=$path
  2534. case $DEBUG in
  2535. '') exec 2>&9
  2536. exec 9>&-
  2537. ;;
  2538. esac
  2539. }
  2540. # info message
  2541. note() # message ...
  2542. {
  2543. echo $command: "$@" >&2
  2544. }
  2545. # cc checks
  2546. #
  2547. # CC: compiler base name name
  2548. # cc: full path, empty if not found
  2549. checkcc()
  2550. {
  2551. cc=
  2552. if onpath $CC
  2553. then cc=$_onpath_
  2554. else case $CC in
  2555. cc) if onpath gcc
  2556. then CC=gcc
  2557. cc=$_onpath_
  2558. fi
  2559. ;;
  2560. esac
  2561. fi
  2562. case $cc in
  2563. '') case $action in
  2564. make|test) note "$CC: not found"; exit 1 ;;
  2565. *) note "warning: $CC: not found" ;;
  2566. esac
  2567. ;;
  2568. esac
  2569. }
  2570. # some actions have their own PACKAGEROOT or kick out early
  2571. case $action in
  2572. host) eval u=$package_use
  2573. case $u in
  2574. $PACKAGE_USE)
  2575. ;;
  2576. *) if onpath $0
  2577. then case $_onpath_ in
  2578. */arch/$HOSTTYPE/bin/package)
  2579. KEEP_HOSTTYPE=1
  2580. ;;
  2581. *) KEEP_HOSTTYPE=0
  2582. ;;
  2583. esac
  2584. else KEEP_HOSTTYPE=0
  2585. fi
  2586. ;;
  2587. esac
  2588. hostinfo $args
  2589. echo $_hostinfo_
  2590. exit 0
  2591. ;;
  2592. export|setup|use)
  2593. x=
  2594. ;;
  2595. *) x=
  2596. eval u=$package_use
  2597. case $u in
  2598. $PACKAGE_USE)
  2599. case :$PATH: in
  2600. *:$INSTALLROOT/bin:*)
  2601. case $LIBPATH: in
  2602. $INSTALLROOT/bin:$INSTALLROOT/lib:*)
  2603. case $SHLIB_PATH: in
  2604. $INSTALLROOT/lib:*)
  2605. x=1
  2606. ;;
  2607. esac
  2608. ;;
  2609. esac
  2610. ;;
  2611. esac
  2612. ;;
  2613. esac
  2614. ;;
  2615. esac
  2616. run=-
  2617. case $x in
  2618. 1) : accept the current package use environment
  2619. OK=ok
  2620. KSH=$EXECROOT/bin/ksh
  2621. MAKE=nmake
  2622. NMAKE=$EXECROOT/bin/$MAKE
  2623. SUM=$EXECROOT/bin/sum
  2624. TEE=$EXECROOT/bin/tee
  2625. INITROOT=$PACKAGEROOT/src/cmd/INIT
  2626. checkcc
  2627. ;;
  2628. *) hosttype=
  2629. case $KEEP_PACKAGEROOT in
  2630. 0) case $action in
  2631. use) PACKAGEROOT=
  2632. case $show in
  2633. echo) exec=echo make=echo show=echo ;;
  2634. esac
  2635. set '' $args
  2636. shift
  2637. case $# in
  2638. 0) ;;
  2639. *) case $1 in
  2640. -|.) ;;
  2641. /*) PACKAGEROOT=$1
  2642. ;;
  2643. *) i=`echo ~$1`
  2644. if packageroot $i
  2645. then PACKAGEROOT=$i
  2646. else for i in `echo $HOME | sed -e 's,/[^/]*$,,'` $usr $use
  2647. do if packageroot $i/$1
  2648. then PACKAGEROOT=$i/$1
  2649. break
  2650. fi
  2651. done
  2652. case $PACKAGEROOT in
  2653. '') hosttype=$1 ;;
  2654. esac
  2655. fi
  2656. ;;
  2657. esac
  2658. shift
  2659. ;;
  2660. esac
  2661. run="$@"
  2662. ;;
  2663. esac
  2664. case $PACKAGEROOT in
  2665. '') PACKAGEROOT=${PWD:-`pwd`} ;;
  2666. esac
  2667. # . must be within the PACKAGEROOT tree
  2668. i=X$PACKAGEROOT
  2669. IFS=/
  2670. set $i
  2671. IFS=$ifs
  2672. while :
  2673. do i=$1
  2674. shift
  2675. case $i in
  2676. X) break ;;
  2677. esac
  2678. done
  2679. case $PACKAGEROOT in
  2680. //*) d=/ ;;
  2681. *) d= ;;
  2682. esac
  2683. case $1 in
  2684. home) k=1 ;;
  2685. *) k=0 ;;
  2686. esac
  2687. for i
  2688. do case $i in
  2689. '') continue ;;
  2690. esac
  2691. d=$d/$i
  2692. case $k in
  2693. 2) k=1
  2694. ;;
  2695. 1) k=0
  2696. ;;
  2697. 0) case $i in
  2698. arch) k=2
  2699. ;;
  2700. *) if packageroot $d
  2701. then PACKAGEROOT=$d
  2702. fi
  2703. ;;
  2704. esac
  2705. ;;
  2706. esac
  2707. done
  2708. ;;
  2709. esac
  2710. INITROOT=$PACKAGEROOT/src/cmd/INIT
  2711. $show PACKAGEROOT=$PACKAGEROOT
  2712. $show export PACKAGEROOT
  2713. export PACKAGEROOT
  2714. # initialize the architecture environment
  2715. case $KEEP_HOSTTYPE in
  2716. 0) hostinfo type
  2717. HOSTTYPE=$_hostinfo_
  2718. ;;
  2719. 1) _PACKAGE_HOSTTYPE_=$HOSTTYPE
  2720. export _PACKAGE_HOSTTYPE_
  2721. ;;
  2722. esac
  2723. $show HOSTTYPE=$HOSTTYPE
  2724. $show export HOSTTYPE
  2725. export HOSTTYPE
  2726. INSTALLROOT=$PACKAGEROOT/arch/$HOSTTYPE
  2727. case $action in
  2728. admin|install|make|read|remove|test|verify|view|write)
  2729. ;;
  2730. *) if test ! -d $INSTALLROOT
  2731. then INSTALLROOT=$PACKAGEROOT
  2732. fi
  2733. ;;
  2734. esac
  2735. $show INSTALLROOT=$INSTALLROOT
  2736. $show export INSTALLROOT
  2737. export INSTALLROOT
  2738. # check the basic package hierarchy
  2739. case $action in
  2740. export|use)
  2741. packageroot $PACKAGEROOT || {
  2742. echo "$command: $PACKAGEROOT: invalid package root directory" >&2
  2743. exit 1
  2744. }
  2745. case $KEEP_HOSTTYPE:$hosttype in
  2746. 0:?*) if test -d ${PACKAGEROOT:-.}/arch/$hosttype
  2747. then KEEP_HOSTTYPE=1
  2748. HOSTTYPE=$hosttype
  2749. else echo "$command: $hosttype: package root not found" >&2
  2750. exit 1
  2751. fi
  2752. ;;
  2753. esac
  2754. ;;
  2755. *) packageroot $PACKAGEROOT || {
  2756. case $KEEP_PACKAGEROOT in
  2757. 1) ;;
  2758. *) echo "$command: $PACKAGEROOT: must be in the package root directory tree" >&2
  2759. exit 1
  2760. ;;
  2761. esac
  2762. }
  2763. case $action in
  2764. admin) ;;
  2765. *) for i in arch arch/$HOSTTYPE
  2766. do test -d $PACKAGEROOT/$i || $exec mkdir $PACKAGEROOT/$i || exit
  2767. done
  2768. for i in lib
  2769. do test -d $INSTALLROOT/$i || $exec mkdir $INSTALLROOT/$i || exit
  2770. done
  2771. ;;
  2772. esac
  2773. # no $INITROOT means INIT already installed elsewhere
  2774. if test -d $INITROOT
  2775. then
  2776. # update the basic package commands
  2777. for i in execrate ignore mamprobe silent
  2778. do test -h $PACKAGEROOT/bin/$i 2>/dev/null ||
  2779. case `ls -t $INITROOT/$i.sh $PACKAGEROOT/bin/$i 2>/dev/null` in
  2780. "$INITROOT/$i.sh"*)
  2781. note update $PACKAGEROOT/bin/$i
  2782. shellmagic
  2783. case $SHELLMAGIC in
  2784. '') $exec cp $INITROOT/$i.sh $PACKAGEROOT/bin/$i || exit
  2785. ;;
  2786. *) case $exec in
  2787. '') {
  2788. echo "$SHELLMAGIC"
  2789. cat $INITROOT/$i.sh
  2790. } > $PACKAGEROOT/bin/$i || exit
  2791. ;;
  2792. *) echo "{
  2793. echo \"$SHELLMAGIC\"
  2794. cat $INITROOT/$i.sh
  2795. } > $PACKAGEROOT/bin/$i"
  2796. ;;
  2797. esac
  2798. ;;
  2799. esac
  2800. $exec chmod +x $PACKAGEROOT/bin/$i || exit
  2801. ;;
  2802. esac
  2803. done
  2804. fi
  2805. ;;
  2806. esac
  2807. path=$PATH
  2808. PATH=$INSTALLROOT/bin:$PACKAGEROOT/bin:$PATH
  2809. checkcc
  2810. PATH=$path
  2811. case $cc in
  2812. ?*) if test -f $INITROOT/hello.c
  2813. then
  2814. # check if $CC (full path $cc) is a cross compiler
  2815. (
  2816. cd "$TMPDIR" || exit 3
  2817. cp $INITROOT/hello.c pkg$$.c || exit 3
  2818. $cc -o pkg$$.exe pkg$$.c > pkg$$.e 2>&1 || {
  2819. if $cc -Dnew=old -o pkg$$.exe pkg$$.c > /dev/null 2>&1
  2820. then echo "$command: ${warn}$CC: must be a C compiler (not C++)" >&2
  2821. else cat pkg$$.e
  2822. echo "$command: ${warn}$CC: failed to compile and link $INITROOT/hello.c -- is it a C compiler?" >&2
  2823. fi
  2824. exit 2
  2825. }
  2826. if ./pkg$$.exe >/dev/null 2>&1
  2827. then code=0
  2828. else code=1
  2829. fi
  2830. rm -f pkg$$.*
  2831. exit $code
  2832. )
  2833. code=$?
  2834. case $code in
  2835. 1) CROSS=1 ;;
  2836. esac
  2837. fi
  2838. ;;
  2839. esac
  2840. EXECTYPE=$HOSTTYPE
  2841. EXECROOT=$INSTALLROOT
  2842. case $CROSS in
  2843. 0) # dll hackery -- why is this so complicated?
  2844. abi=
  2845. case $HOSTTYPE in
  2846. sgi.mips[0123456789]*)
  2847. x=rld
  2848. if executable /lib32/$x || executable /lib64/$x
  2849. then case $INSTALLROOT in
  2850. */sgi.mips[0123456789]*)
  2851. u=`echo $INSTALLROOT | sed -e 's,-[^-/]*$,,' -e 's,.$,,'`
  2852. ;;
  2853. *) u=
  2854. ;;
  2855. esac
  2856. for a in "n=2 v= l=" "n=3 v=N32 l=lib32" "n=4-n32 v=N32 l=lib32" "n=4 v=64 l=lib64"
  2857. do eval $a
  2858. case $v in
  2859. N32) case $n:$HOSTTYPE in
  2860. *-n32:*-n32) ;;
  2861. *-n32:*) continue ;;
  2862. *:*-n32) continue ;;
  2863. esac
  2864. ;;
  2865. esac
  2866. case $l in
  2867. ?*) if executable ! /$l/$x
  2868. then continue
  2869. fi
  2870. ;;
  2871. esac
  2872. case $u in
  2873. '') case $HOSTTYPE in
  2874. sgi.mips$n|sgi.mips$n-*)
  2875. abi="$abi 'd=$INSTALLROOT v=$v'"
  2876. ;;
  2877. *) continue
  2878. ;;
  2879. esac
  2880. ;;
  2881. *) if test -d $u$n
  2882. then abi="$abi 'd=$u$n v=$v'"
  2883. fi
  2884. ;;
  2885. esac
  2886. done
  2887. fi
  2888. ;;
  2889. esac
  2890. case $abi in
  2891. '') abi="'d=$INSTALLROOT v='" ;;
  2892. esac
  2893. p=0
  2894. eval "
  2895. for a in $abi
  2896. do eval \$a
  2897. eval \"
  2898. case \\\$LD_LIBRARY\${v}_PATH: in
  2899. \\\$d/lib:*)
  2900. ;;
  2901. *) x=\\\$LD_LIBRARY\${v}_PATH
  2902. case \\\$x in
  2903. ''|:*) ;;
  2904. *) x=:\\\$x ;;
  2905. esac
  2906. LD_LIBRARY\${v}_PATH=\$d/lib\\\$x
  2907. export LD_LIBRARY\${v}_PATH
  2908. p=1
  2909. ;;
  2910. esac
  2911. \"
  2912. done
  2913. "
  2914. case $LD_LIBRARY_PATH in
  2915. '') ;;
  2916. *) for d in $lib
  2917. do case $HOSTTYPE in
  2918. *64) if test -d ${d}64
  2919. then d=${d}64
  2920. fi
  2921. ;;
  2922. esac
  2923. case :$LD_LIBRARY_PATH: in
  2924. *:$d:*) ;;
  2925. *) if test -d $d
  2926. then LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$d
  2927. p=1
  2928. fi
  2929. ;;
  2930. esac
  2931. done
  2932. ;;
  2933. esac
  2934. case $p in
  2935. 1) $show LD_LIBRARY_PATH=$LD_LIBRARY_PATH
  2936. $show export LD_LIBRARY_PATH
  2937. export LD_LIBRARY_PATH
  2938. ;;
  2939. esac
  2940. case $LIBPATH: in
  2941. $INSTALLROOT/bin:$INSTALLROOT/lib:*)
  2942. ;;
  2943. *) case $LIBPATH in
  2944. '') LIBPATH=/usr/lib:/lib ;;
  2945. esac
  2946. LIBPATH=$INSTALLROOT/bin:$INSTALLROOT/lib:$LIBPATH
  2947. $show LIBPATH=$LIBPATH
  2948. $show export LIBPATH
  2949. export LIBPATH
  2950. ;;
  2951. esac
  2952. case $SHLIB_PATH: in
  2953. $INSTALLROOT/lib:*)
  2954. ;;
  2955. *) SHLIB_PATH=$INSTALLROOT/lib${SHLIB_PATH:+:$SHLIB_PATH}
  2956. $show SHLIB_PATH=$SHLIB_PATH
  2957. $show export SHLIB_PATH
  2958. export SHLIB_PATH
  2959. ;;
  2960. esac
  2961. case $DYLD_LIBRARY_PATH: in
  2962. $INSTALLROOT/lib:*)
  2963. ;;
  2964. *) DYLD_LIBRARY_PATH=$INSTALLROOT/lib${DYLD_LIBRARY_PATH:+:$DYLD_LIBRARY_PATH}
  2965. $show DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH
  2966. $show export DYLD_LIBRARY_PATH
  2967. export DYLD_LIBRARY_PATH
  2968. ;;
  2969. esac
  2970. case $_RLD_ROOT in
  2971. $INSTALLROOT/arch*) ;;
  2972. ':') _RLD_ROOT=$INSTALLROOT/arch:/ ;;
  2973. /|*:/) _RLD_ROOT=$INSTALLROOT/arch:$_RLD_ROOT ;;
  2974. *) _RLD_ROOT=$INSTALLROOT/arch:$_RLD_ROOT:/ ;;
  2975. esac
  2976. $show _RLD_ROOT=$_RLD_ROOT
  2977. $show export _RLD_ROOT
  2978. export _RLD_ROOT
  2979. # now set up PATH
  2980. #
  2981. # NOTE: PACKAGEROOT==INSTALLROOT is possible for binary installations
  2982. case $PATH: in
  2983. $PACKAGEROOT/bin:*)
  2984. ;;
  2985. *) PATH=$PACKAGEROOT/bin:$PATH
  2986. ;;
  2987. esac
  2988. case $PATH: in
  2989. $INSTALLROOT/bin:*)
  2990. ;;
  2991. *) PATH=$INSTALLROOT/bin:$PATH
  2992. ;;
  2993. esac
  2994. $show PATH=$PATH
  2995. $show export PATH
  2996. export PATH
  2997. ;;
  2998. *) for i in package proto nmake
  2999. do if onpath $i
  3000. then EXECROOT=`echo $_onpath_ | sed -e 's,//*[^/]*//*[^/]*$,,'`
  3001. EXECTYPE=`echo $EXECROOT | sed -e 's,.*/,,'`
  3002. break
  3003. fi
  3004. done
  3005. case $HOSTTYPE in
  3006. $EXECTYPE)
  3007. OCC=$CC
  3008. CC=cc
  3009. hostinfo type
  3010. EXECTYPE=$_hostinfo_
  3011. case $HOSTTYPE in
  3012. $EXECTYPE)
  3013. echo "$command: $CC: seems to be a cross-compiler" >&2
  3014. echo "$command: set HOSTTYPE to something other than the native $EXECTYPE" >&2
  3015. echo "$command: If not, your $TMPDIR directory may be mounted without execute permission." >&2
  3016. echo "$command: Try exporting TMPDIR as a directory where you can execute binary files." >&2
  3017. exit 1
  3018. ;;
  3019. esac
  3020. ;;
  3021. esac
  3022. $show EXECTYPE=$EXECTYPE
  3023. $show export EXECTYPE
  3024. export EXECTYPE
  3025. ;;
  3026. esac
  3027. $show EXECROOT=$EXECROOT
  3028. $show export EXECROOT
  3029. export EXECROOT
  3030. # use these if possible
  3031. OK=ok
  3032. KSH=$EXECROOT/bin/ksh
  3033. MAKE=nmake
  3034. NMAKE=$EXECROOT/bin/$MAKE
  3035. SUM=$EXECROOT/bin/sum
  3036. TEE=$EXECROOT/bin/tee
  3037. # grab a decent default shell
  3038. checksh "$SHELL" || KEEP_SHELL=0
  3039. case $KEEP_SHELL in
  3040. 0) save_PATH=$PATH
  3041. if PATH=`getconf PATH 2>/dev/null`
  3042. then PATH=$PATH:$path
  3043. else PATH=/bin:/usr/bin:/sbin:/usr/sbin:$path
  3044. fi
  3045. for i in ksh ksh93 mksh yash bash sh
  3046. do if onpath "$i" && checksh "$_onpath_"
  3047. then SHELL=$_onpath_
  3048. KEEP_SHELL=1
  3049. break
  3050. fi
  3051. done
  3052. PATH=$save_PATH
  3053. unset save_PATH
  3054. case $KEEP_SHELL in
  3055. 0) echo "Cannot find good default shell, please supply SHELL=/path/to/shell" >&2
  3056. exit 1 ;;
  3057. esac
  3058. ;;
  3059. esac
  3060. export SHELL
  3061. $show SHELL=$SHELL
  3062. $show export SHELL
  3063. # tame the environment
  3064. case $action in
  3065. use) ;;
  3066. *) ENV=
  3067. ERROR_OPTIONS=
  3068. export ENV ERROR_OPTIONS
  3069. ;;
  3070. esac
  3071. # finalize the views
  3072. case $USER_VPATH in
  3073. '') case $VPATH in
  3074. ?*) IFS=':'
  3075. set '' $VPATH
  3076. shift
  3077. IFS=$ifs
  3078. USER_VPATH=
  3079. for i
  3080. do case $i in
  3081. */arch/$HOSTTYPE) ;;
  3082. */arch/*/*) ;;
  3083. */arch/*) continue ;;
  3084. esac
  3085. if packageroot $i
  3086. then case $USER_VPATH in
  3087. '') USER_VPATH=$i ;;
  3088. ?*) USER_VPATH=$USER_VPATH:$i ;;
  3089. esac
  3090. fi
  3091. done
  3092. esac
  3093. ;;
  3094. esac
  3095. case $USER_VPATH in
  3096. ?*) IFS=':'
  3097. set '' $USER_VPATH
  3098. shift
  3099. IFS=$ifs
  3100. USER_VPATH=
  3101. USER_VPATH_CHAIN=
  3102. p=$PACKAGEROOT
  3103. for i
  3104. do case $i in
  3105. ''|$PACKAGEROOT|$INSTALLROOT)
  3106. ;;
  3107. ?*) USER_VPATH=$USER_VPATH:$i
  3108. USER_VPATH_CHAIN="$USER_VPATH_CHAIN $p $i"
  3109. p=$i
  3110. case $PROTOROOT in
  3111. -) executable $i/bin/mamake && PROTOROOT= ;;
  3112. esac
  3113. ;;
  3114. esac
  3115. done
  3116. ;;
  3117. esac
  3118. ;;
  3119. esac
  3120. PACKAGESRC=$PACKAGEROOT/lib/package
  3121. PACKAGEBIN=$INSTALLROOT/lib/package
  3122. case $action:$run in
  3123. use:-) set '' $args
  3124. shift
  3125. case $# in
  3126. 0) ;;
  3127. *) shift ;;
  3128. esac
  3129. run="$@"
  3130. ;;
  3131. esac
  3132. # HOSTTYPE specific package profile
  3133. if test -r $INSTALLROOT/lib/package/profile
  3134. then . $INSTALLROOT/lib/package/profile
  3135. fi
  3136. # more cygwin hassles
  3137. case $HOSTTYPE in
  3138. cygwin.*)
  3139. lose=
  3140. case $CYGWIN in
  3141. *nontsec*)
  3142. lose=ntsec
  3143. ;;
  3144. *ntsec*);;
  3145. *) exe=$TMPDIR/pkg$$.exe
  3146. rm -f "$exe"
  3147. : > "$exe"
  3148. if test -x "$exe"
  3149. then lose=ntsec
  3150. fi
  3151. ;;
  3152. esac
  3153. case $CYGWIN in
  3154. *nobinmode*)
  3155. case $lose in
  3156. '') lose=binmode ;;
  3157. *) lose="$lose binmode" ;;
  3158. esac
  3159. ;;
  3160. esac
  3161. case $lose in
  3162. ?*) echo "$command: $HOSTTYPE: export '$lose' in CYGWIN or languish in windows" >&2
  3163. exit 1
  3164. ;;
  3165. esac
  3166. ;;
  3167. esac
  3168. # set up the view state
  3169. VIEW_bin=$INSTALLROOT VIEW_src=$PACKAGEROOT VIEW_all="$INSTALLROOT $PACKAGEROOT"
  3170. VPATH=$INSTALLROOT:$PACKAGEROOT$USER_VPATH
  3171. $show VPATH=$VPATH
  3172. $show export VPATH
  3173. export VPATH
  3174. IFS=':'
  3175. set '' $VPATH
  3176. shift
  3177. IFS=$ifs
  3178. for i
  3179. do case $i in
  3180. */arch/*/*)
  3181. VIEW_src="$VIEW_src $i"
  3182. ;;
  3183. */arch/*)
  3184. VIEW_bin="$VIEW_bin $i"
  3185. ;;
  3186. *)
  3187. VIEW_src="$VIEW_src $i"
  3188. ;;
  3189. esac
  3190. VIEW_all="$VIEW_all $i"
  3191. done
  3192. # return 0 if arg in src|bin|all view
  3193. view() # [test] [-|type] [src|bin|all] file
  3194. {
  3195. case $1 in
  3196. -[dfsx])_view_T_=$1; shift ;;
  3197. *) _view_T_=-f ;;
  3198. esac
  3199. case $1 in
  3200. -) _view_t_= ;;
  3201. *) _view_t_=$1 ;;
  3202. esac
  3203. shift
  3204. case $1 in
  3205. all) shift; _view_v_=$VIEW_all ;;
  3206. bin) shift; _view_v_=$VIEW_bin ;;
  3207. src) shift; _view_v_=$VIEW_src ;;
  3208. *) _view_v_=$VIEW_all ;;
  3209. esac
  3210. case $1 in
  3211. /*) if test $_view_T_ $1
  3212. then _view_=$1
  3213. return 0
  3214. fi
  3215. ;;
  3216. *) for _view_d_ in $_view_v_
  3217. do if test $_view_T_ $_view_d_/$1
  3218. then _view_=$_view_d_/$1
  3219. return 0
  3220. fi
  3221. done
  3222. ;;
  3223. esac
  3224. _view_=
  3225. case $_view_t_ in
  3226. ?*) echo $command: $1: $_view_t_ not found >&2 ;;
  3227. esac
  3228. return 1
  3229. }
  3230. # determine the package and targets
  3231. case $action in
  3232. admin) case $admin_action in
  3233. results)action=$admin_action
  3234. set '' $admin_args
  3235. shift;shift
  3236. admin_args="admin $*"
  3237. case $admin_on in
  3238. '') target=$admin_args ;;
  3239. *) target="on $admin_on $admin_args" ;;
  3240. esac
  3241. ;;
  3242. esac
  3243. ;;
  3244. release)set '' $args
  3245. target=
  3246. while :
  3247. do shift
  3248. case $1 in
  3249. -|[0123456789][0123456789]-[0123456789][0123456789]-[0123456789][0123456789]|[0123456789][0123456789][0123456789][0123456789]-[0123456789][0123456789]-[0123456789][0123456789])
  3250. target="$target $1"
  3251. ;;
  3252. *) break
  3253. ;;
  3254. esac
  3255. done
  3256. package=$*
  3257. ;;
  3258. setup) # { update read } with optional (bin|fun|include|lib) symlinks
  3259. # flat option sets up { bin fun include lib } symlinks from
  3260. # $INSTALLROOT to $PACKAGEROOT
  3261. # . is the package root
  3262. set '' $args
  3263. shift
  3264. types=
  3265. url=
  3266. while :
  3267. do case $# in
  3268. 0) break ;;
  3269. esac
  3270. case $1 in
  3271. --) shift
  3272. break
  3273. ;;
  3274. flat) flat=1 # backwards compatibility -- documentation dropped
  3275. ;;
  3276. *://*|*.url)
  3277. url=$1
  3278. shift
  3279. break
  3280. ;;
  3281. *) types="$types $1"
  3282. ;;
  3283. esac
  3284. shift
  3285. done
  3286. if test ! -d $PACKAGEROOT/lib/package/tgz
  3287. then $exec mkdir -p $PACKAGEROOT/lib/package/tgz || exit
  3288. fi
  3289. case " $types " in
  3290. *" source "*)
  3291. case " $* " in
  3292. ' ') ;;
  3293. *" INIT "*)
  3294. ;;
  3295. *) view - all src/cmd/INIT ||
  3296. set INIT "$@"
  3297. ;;
  3298. esac
  3299. ;;
  3300. esac
  3301. packages=`$0 $global authorize "$authorize" password "$password" update setup $types $url "$@" PACKAGEROOT=$PACKAGEROOT`
  3302. case $packages in
  3303. ?*) $0 $global read $packages PACKAGEROOT=$PACKAGEROOT
  3304. esac
  3305. exit
  3306. ;;
  3307. *) package=
  3308. target=
  3309. set '' $args
  3310. while :
  3311. do shift
  3312. case $# in
  3313. 0) break ;;
  3314. esac
  3315. case $1 in
  3316. ''|-) target="$target $package"
  3317. package=
  3318. ;;
  3319. *) if view - src "lib/package/$1.pkg"
  3320. then package="$package $1"
  3321. else target="$target $package $1"
  3322. package=
  3323. fi
  3324. ;;
  3325. esac
  3326. done
  3327. ;;
  3328. esac
  3329. # flatten -- assumes symlink support
  3330. case $flat in
  3331. 1) case $action in
  3332. make|read|setup|update|use|view)
  3333. if test ! -d $INSTALLROOT
  3334. then $exec mkdir -p $INSTALLROOT || exit
  3335. fi
  3336. for i in bin include lib fun man share
  3337. do if test ! -d $INSTALLROOT/../../$i
  3338. then $exec mkdir $INSTALLROOT/../../$i
  3339. fi
  3340. if test ! -d $INSTALLROOT/$i
  3341. then if test ! -h $INSTALLROOT/$i
  3342. then $exec ln -s ../../$i $INSTALLROOT/$i
  3343. fi
  3344. elif test ! -h $INSTALLROOT/$i
  3345. then for x in $INSTALLROOT/$i/.[a-z]* $INSTALLROOT/$i/*
  3346. do if test -f $x -o -d $x
  3347. then if test ! -d $INSTALLROOT/$i/$x || test ! -d $INSTALLROOT/../../$i/$x
  3348. then $exec mv $x $INSTALLROOT/../../$i
  3349. fi
  3350. fi
  3351. done
  3352. $exec rm -rf $INSTALLROOT/$i
  3353. $exec ln -s ../../$i $INSTALLROOT/$i
  3354. fi
  3355. done
  3356. ;;
  3357. esac
  3358. ;;
  3359. esac
  3360. # check that cmd args are up to date a.out's
  3361. checkaout() # cmd ...
  3362. {
  3363. case $PROTOROOT in
  3364. -) PROTOROOT=
  3365. case $* in
  3366. ratz) if test -f $INITROOT/ratz.c -a -w $PACKAGEROOT
  3367. then test -f $INITROOT/hello.c || {
  3368. cat > $INITROOT/hello.c <<'!'
  3369. #ifndef printf
  3370. #include <stdio.h>
  3371. #endif
  3372. int main() { int new = 0; printf("hello world\n"); return new;}
  3373. !
  3374. }
  3375. test -f $INITROOT/p.c || {
  3376. cat > $INITROOT/p.c <<'!'
  3377. /*
  3378. * small test for prototyping cc
  3379. */
  3380. int main(int argc, char** argv) { return argc || argv; }
  3381. !
  3382. }
  3383. fi
  3384. ;;
  3385. esac
  3386. test -f $INITROOT/hello.c -a -f $INITROOT/p.c -a -w $PACKAGEROOT || {
  3387. for i
  3388. do onpath $i || {
  3389. echo "$command: $i: command not found" >&2
  3390. return 1
  3391. }
  3392. done
  3393. return 0
  3394. }
  3395. case $cc in
  3396. '') _PACKAGE_cc=0
  3397. ;;
  3398. *) _PACKAGE_cc=1
  3399. test -f $INITROOT/hello.c -a -f $INITROOT/p.c || {
  3400. echo "$command: $INITROOT: INIT package source not found" >&2
  3401. return 1
  3402. }
  3403. executable $INSTALLROOT/bin/nmake || {
  3404. # check for prototyping cc
  3405. # NOTE: proto.c must be K&R compatible
  3406. $CC -c $INITROOT/p.c >/dev/null 2>&1
  3407. c=$?
  3408. rm -f p.*
  3409. test 0 != "$c" && {
  3410. checkaout proto || return
  3411. PROTOROOT=$PACKAGEROOT/proto
  3412. $show PROTOROOT=$PACKAGEROOT/proto
  3413. export PROTOROOT
  3414. INITPROTO=$PROTOROOT/src/cmd/INIT
  3415. note proto convert $PACKAGEROOT/src into $PROTOROOT/src
  3416. if test -d $PACKAGEROOT/src/cmd/nmake
  3417. then dirs="src/cmd/INIT src/lib/libast src/lib/libardir src/lib/libpp src/cmd/probe src/cmd/cpp src/cmd/nmake"
  3418. else dirs="src"
  3419. fi
  3420. (
  3421. if test -f $PROTOROOT/UPDATE
  3422. then newer="-newer $PROTOROOT/UPDATE"
  3423. else newer=""
  3424. fi
  3425. case $exec in
  3426. '') cd $PACKAGEROOT
  3427. find $dirs -name '*.[CcHh]' $newer -print | proto -v -L - -C proto
  3428. ;;
  3429. *) $exec cd $PACKAGEROOT
  3430. $exec "find $dirs -name '*.[CcHh]' $newer -print | proto -L - -C proto"
  3431. ;;
  3432. esac
  3433. $exec touch $PROTOROOT/UPDATE
  3434. )
  3435. VPATH=$INSTALLROOT:$PROTOROOT:$PACKAGEROOT$USER_VPATH
  3436. $show VPATH=$VPATH
  3437. export VPATH
  3438. }
  3439. }
  3440. for i in arch arch/$HOSTTYPE arch/$HOSTTYPE/bin
  3441. do test -d $PACKAGEROOT/$i || $exec mkdir $PACKAGEROOT/$i || return
  3442. done
  3443. ;;
  3444. esac
  3445. ;;
  3446. esac
  3447. case $_PACKAGE_cc in
  3448. '') case $cc in
  3449. '') _PACKAGE_cc=0 ;;
  3450. *) _PACKAGE_cc=1 ;;
  3451. esac
  3452. ;;
  3453. esac
  3454. for i
  3455. do eval j=\$_PACKAGE_AOUT_$i
  3456. case $j in
  3457. '') eval _PACKAGE_AOUT_$i=1 ;;
  3458. *) continue ;;
  3459. esac
  3460. k=$_PACKAGE_cc
  3461. if test -f $INITROOT/$i.c
  3462. then k=${k}1
  3463. else k=${k}0
  3464. fi
  3465. if executable $EXECROOT/bin/$i
  3466. then k=${k}1
  3467. else k=${k}0
  3468. fi
  3469. : $k : compiler : source : binary :
  3470. case $k in
  3471. *00) view - bin/$i && continue ;;
  3472. esac
  3473. case $k in
  3474. 000) echo "$command: $i: not found: download the INIT package $HOSTTYPE binary to continue" >&2
  3475. return 1
  3476. ;;
  3477. 010) echo "$command: $i: not found: set CC=C-compiler or download the INIT package $HOSTTYPE binary to continue" >&2
  3478. return 1
  3479. ;;
  3480. 100) echo "$command: $i: not found: download the INIT package source or $HOSTTYPE binary to continue" >&2
  3481. return 1
  3482. ;;
  3483. 110) case $CROSS in
  3484. 1) echo "$command: $i: not found: make the local $EXECTYPE binary package before $HOSTTYPE" >&2
  3485. return 1
  3486. ;;
  3487. esac
  3488. ;;
  3489. ?01) : accept binary
  3490. continue
  3491. ;;
  3492. 011) : accept binary
  3493. continue
  3494. ;;
  3495. ??1) case $CROSS in
  3496. 1) continue ;;
  3497. esac
  3498. ;;
  3499. esac
  3500. case `ls -t $INITROOT/$i.c $INSTALLROOT/bin/$i 2>/dev/null` in
  3501. "$INITROOT/$i.c"*)
  3502. note update $INSTALLROOT/bin/$i
  3503. if test proto != "$i" && executable $INSTALLROOT/bin/proto
  3504. then case $exec in
  3505. '') $INSTALLROOT/bin/proto -p $INITROOT/$i.c > $i.c || return ;;
  3506. *) $exec "$INSTALLROOT/bin/proto -p $INITROOT/$i.c > $i.c" ;;
  3507. esac
  3508. $exec $CC $CCFLAGS -o $INSTALLROOT/bin/$i $i.c || return
  3509. $exec rm -f $i.c
  3510. else if test ! -d $INSTALLROOT/bin
  3511. then for j in arch arch/$HOSTTYPE arch/$HOSTTYPE/bin
  3512. do test -d $PACKAGEROOT/$j || $exec mkdir $PACKAGEROOT/$j || return
  3513. done
  3514. fi
  3515. if test '' != "$PROTOROOT" -a -f $INITPROTO/$i.c
  3516. then $exec $CC $CCFLAGS -o $INSTALLROOT/bin/$i $INITPROTO/$i.c || return
  3517. else $exec $CC $CCFLAGS -o $INSTALLROOT/bin/$i $INITROOT/$i.c || return
  3518. fi
  3519. case $i:$exec in
  3520. proto:) test -d $INSTALLROOT/include || mkdir $INSTALLROOT/include
  3521. $INSTALLROOT/bin/proto -f /dev/null > $i.c
  3522. cmp -s $i.c $INSTALLROOT/include/prototyped.h 2>/dev/null || cp $i.c $INSTALLROOT/include/prototyped.h
  3523. rm $i.c
  3524. ;;
  3525. esac
  3526. fi
  3527. test -f $i.o && $exec rm -f $i.o
  3528. i=$PATH
  3529. PATH=/bin
  3530. PATH=$i
  3531. ;;
  3532. esac
  3533. done
  3534. return 0
  3535. }
  3536. # check package requirements against received packages
  3537. requirements() # source|binary [ package ]
  3538. {
  3539. case $1 in
  3540. binary) r=$VIEW_BIN ;;
  3541. source) r=$VIEW_SRC ;;
  3542. *) r=$VIEW_ALL ;;
  3543. esac
  3544. shift
  3545. case $1 in
  3546. '') x= ;;
  3547. *) x=$* ;;
  3548. esac
  3549. set ''
  3550. for d in $r
  3551. do set "$@" $d/gen/*.ver
  3552. case $x in
  3553. '') set "$@" $d/gen/*.req
  3554. ;;
  3555. *) for p in $x
  3556. do set "$@" $d/gen/$p.req
  3557. done
  3558. ;;
  3559. esac
  3560. done
  3561. shift
  3562. e=0
  3563. x=$*
  3564. y=
  3565. n=
  3566. set ''
  3567. for i in $x
  3568. do p=`echo $i | sed -e 's,.*/,,' -e 's,\....$,,'`
  3569. if test -f $i
  3570. then set "$@" $i
  3571. y="$y $p"
  3572. else case $p in
  3573. '*') ;;
  3574. *) n="$n $p" ;;
  3575. esac
  3576. fi
  3577. done
  3578. for i in $n
  3579. do case " $y " in
  3580. *" $i "*)
  3581. ;;
  3582. *) echo "$command: $i: must read or write package" >&2
  3583. e=1
  3584. ;;
  3585. esac
  3586. done
  3587. case $e in
  3588. 1) exit 1 ;;
  3589. esac
  3590. shift
  3591. test 0 != "$#" && release=`sort -r "$@" | {
  3592. q=
  3593. e=0
  3594. o=
  3595. while read p v r s
  3596. do q="$q
  3597. $v $r"
  3598. case $p in
  3599. $o) continue ;;
  3600. esac
  3601. case $s in
  3602. 0) e=1
  3603. case $r in
  3604. base) echo "$command: base package $p.$v or newer required" >&2 ;;
  3605. *) echo "$command: delta package $p.$v.$r or newer required" >&2 ;;
  3606. esac
  3607. ;;
  3608. esac
  3609. o=$p
  3610. done
  3611. case $e in
  3612. 0) echo "$q" | sort | { read v r; read v r; echo $v; } ;;
  3613. 1) echo ERROR ;;
  3614. esac
  3615. }`
  3616. case $release in
  3617. ERROR) case $force in
  3618. 0) exit 1 ;;
  3619. esac
  3620. ;;
  3621. ?*) eval `echo $release | sed -e 's,\(.*\)-\(.*\)-\(.*\),yy=\1 mm=\2 dd=\3,'`
  3622. # slide back 4 months
  3623. case $mm in
  3624. 01) mm=09 dd=1 ;;
  3625. 02) mm=10 dd=1 ;;
  3626. 03) mm=11 dd=1 ;;
  3627. 04) mm=12 dd=1 ;;
  3628. 05) mm=01 dd=0 ;;
  3629. 06) mm=02 dd=0 ;;
  3630. 07) mm=03 dd=0 ;;
  3631. 08) mm=04 dd=0 ;;
  3632. 09) mm=05 dd=0 ;;
  3633. 10) mm=06 dd=0 ;;
  3634. 11) mm=07 dd=0 ;;
  3635. 12) mm=08 dd=0 ;;
  3636. esac
  3637. case $dd in
  3638. 1) yy=`expr $yy - 1` ;;
  3639. esac
  3640. release=$yy-$mm-01
  3641. count=1
  3642. lo=$release
  3643. release="-f $release -r $count"
  3644. ;;
  3645. esac
  3646. }
  3647. # write ordered package prerequisite list to the standard output
  3648. order() # [ package ]
  3649. {
  3650. _order_t_=lib/package/tgz
  3651. case $action in
  3652. binary) _order_a_=.$HOSTTYPE ;;
  3653. *) _order_a_= ;;
  3654. esac
  3655. _order_n_=$#
  3656. case $_order_n_ in
  3657. 0) _order_p_=
  3658. for _order_v_ in $VIEW_all
  3659. do for _order_f_ in $_order_v_/lib/package/*.pkg
  3660. do if test -f $_order_f_
  3661. then _order_p_="$_order_p_ $_order_f_"
  3662. fi
  3663. done
  3664. done
  3665. set '' $_order_p_
  3666. shift
  3667. esac
  3668. {
  3669. if test ratz != "$*"
  3670. then for _order_f_ in ratz INIT
  3671. do if view -s - src $_order_t_/$_order_f_$_order_a_.tim
  3672. then echo $_order_f_ $_order_f_
  3673. fi
  3674. done
  3675. fi
  3676. for _order_f_
  3677. do while :
  3678. do view - src $_order_f_ && break
  3679. case $_order_f_ in
  3680. *.pkg) ;;
  3681. *) _order_f_=$_order_f_.pkg; view - src $_order_f_ && break ;;
  3682. esac
  3683. case $_order_f_ in
  3684. */*) ;;
  3685. *) _order_f_=lib/package/$_order_f_; view - src $_order_f_ && break ;;
  3686. esac
  3687. echo "$command: $_order_f_: not a package" >&2
  3688. continue 2
  3689. done
  3690. _order_f_=$_view_
  3691. _order_p_=`echo $_order_f_ | sed -e 's,.*/,,' -e 's,\.pkg$,,'`
  3692. case $_order_n_ in
  3693. 0) view -s - src $_order_t_/$_order_p_$_order_a_.tim || continue ;;
  3694. esac
  3695. echo $_order_p_ $_order_p_
  3696. case $_order_p_ in
  3697. INIT|ratz)
  3698. ;;
  3699. *) echo INIT $_order_p_
  3700. ;;
  3701. esac
  3702. {
  3703. req= req_sep=
  3704. op=::
  3705. while read line
  3706. do IFS=' \\'
  3707. set '' $line
  3708. IFS=$ifs
  3709. while :
  3710. do shift
  3711. case $# in
  3712. 0) break ;;
  3713. esac
  3714. case $1 in
  3715. :*:) op=$1
  3716. ;;
  3717. INIT|'$('*|*')')
  3718. ;;
  3719. *) case $op in
  3720. :REQUIRES:)
  3721. req="$req$req_sep$1"
  3722. req_sep=" "
  3723. ;;
  3724. esac
  3725. ;;
  3726. esac
  3727. done
  3728. done
  3729. for _order_i_ in $req
  3730. do if view - src lib/package/$_order_i_.pkg
  3731. then case $_order_u_ in
  3732. 0) view -s - src $_order_t_/$_order_i_$_order_a_.tim || continue ;;
  3733. esac
  3734. echo $_order_i_ $_order_i_; echo INIT $_order_i_; echo $_order_i_ $_order_p_
  3735. fi
  3736. done
  3737. } < $_order_f_
  3738. done
  3739. } | tsort
  3740. }
  3741. # generate the package component list in _components_
  3742. components() # [ package ]
  3743. {
  3744. _components_=
  3745. for p
  3746. do case $p in
  3747. '') ;;
  3748. INIT) case " $_components_ " in
  3749. *" $p "*) ;;
  3750. *) _components_="$_components_ $p" ;;
  3751. esac
  3752. ;;
  3753. *) if view - src lib/package/$p.pkg
  3754. then p=$_view_
  3755. op=::
  3756. exec < $p
  3757. while read line
  3758. do IFS=' \\'
  3759. set '' $line
  3760. IFS=$ifs
  3761. while :
  3762. do shift
  3763. case $# in
  3764. 0) break ;;
  3765. esac
  3766. case $1 in
  3767. :*:) op=$1
  3768. ;;
  3769. INIT|'$('*|*')')
  3770. ;;
  3771. *) case $op in
  3772. :PACKAGE:)
  3773. case " $_components_ " in
  3774. *" $1 "*) ;;
  3775. *) _components_="$_components_ $1" ;;
  3776. esac
  3777. ;;
  3778. esac
  3779. ;;
  3780. esac
  3781. done
  3782. done
  3783. exec < /dev/null
  3784. elif test -d $PACKAGEROOT/src/cmd/$p -o -d $PACKAGEROOT/src/lib/$p
  3785. then _components_="$_components_ $p"
  3786. else echo "$command: $p: package or component not found" >&2
  3787. exit 1
  3788. fi
  3789. ;;
  3790. esac
  3791. done
  3792. }
  3793. # list main environment values
  3794. showenv()
  3795. {
  3796. case $1 in
  3797. ''|make)for __i__ in CC SHELL $env
  3798. do eval echo $__i__='$'$__i__
  3799. done
  3800. ;;
  3801. esac
  3802. }
  3803. # capture command output
  3804. capture() # file command ...
  3805. {
  3806. case $make:$noexec in
  3807. :) case $action in
  3808. install|make|view)
  3809. o=$action
  3810. ;;
  3811. *) case $package in
  3812. ''|*' '*)
  3813. o=$action
  3814. ;;
  3815. *) o=$package
  3816. ;;
  3817. esac
  3818. ;;
  3819. esac
  3820. case $action in
  3821. write) d=$PACKAGESRC/gen ;;
  3822. *) d=$PACKAGEBIN/gen ;;
  3823. esac
  3824. test -d $d || $exec mkdir $d
  3825. o=$d/$o
  3826. case $o in
  3827. $output)o=$o.out
  3828. s=
  3829. ;;
  3830. *) output=$o
  3831. if test -f $o.old
  3832. then mv $o.old $o.out.1
  3833. if test -f $o.out
  3834. then mv $o.out $o.out.2
  3835. fi
  3836. elif test -f $o.out
  3837. then for i in `ls -t $o.out.? 2>/dev/null`
  3838. do break
  3839. done
  3840. case $i in
  3841. *.1) i=2 ;;
  3842. *.2) i=3 ;;
  3843. *.3) i=4 ;;
  3844. *.4) i=5 ;;
  3845. *.5) i=6 ;;
  3846. *.6) i=7 ;;
  3847. *.7) i=8 ;;
  3848. *.8) i=9 ;;
  3849. *) i=1 ;;
  3850. esac
  3851. mv $o.out $o.out.$i
  3852. fi
  3853. o=$o.out
  3854. : > $o
  3855. note $action output captured in $o
  3856. s="$command: $action start at `date` in $INSTALLROOT"
  3857. case $quiet in
  3858. 0) trap "echo \"$command: $action done at \`date\`\" in $INSTALLROOT 2>&1 | \$TEE -a $o" 0 1 2 ;;
  3859. *) trap "echo \"$command: $action done at \`date\`\" in $INSTALLROOT >> $o" 0 1 2 ;;
  3860. esac
  3861. ;;
  3862. esac
  3863. case $quiet in
  3864. 0) if executable ! $TEE
  3865. then TEE=tee
  3866. fi
  3867. # Connect 'tee' to a FIFO instead of a pipe, so that the build is invoked from
  3868. # the main shell environment and its exit status can be used for $error_status
  3869. rm -f $o.fifo
  3870. mkfifo -m 600 $o.fifo || exit
  3871. (
  3872. sleep 1
  3873. # unlink early
  3874. exec rm $o.fifo
  3875. ) &
  3876. $TEE -a $o < $o.fifo &
  3877. {
  3878. case $s in
  3879. ?*) echo "$s" ;;
  3880. esac
  3881. showenv $action
  3882. "$@"
  3883. } < /dev/null > $o.fifo 2>&1
  3884. ;;
  3885. *) {
  3886. case $s in
  3887. ?*) echo "$s" ;;
  3888. esac
  3889. showenv $action
  3890. "$@"
  3891. } < /dev/null > $o 2>&1
  3892. ;;
  3893. esac
  3894. ;;
  3895. *) $make "$@"
  3896. ;;
  3897. esac
  3898. exit_status=$?
  3899. if test "$exit_status" -gt "$error_status"
  3900. then error_status=$exit_status
  3901. fi
  3902. }
  3903. package_install() # dest sum
  3904. {
  3905. dest=$1 sum=$2
  3906. ot=
  3907. code=0
  3908. sed -e '/ /!d' -e 's,[^ ]* ,,' -e 's, \(arch/[^/]*\)/, \1 ,' -e '/ arch\//!s,^[^ ]* [^ ]* [^ ]*,& .,' -e 's,/\([^ /]*\)$, \1,' $sum |
  3909. while read mode user group arch dir file
  3910. do case $flat:$arch in
  3911. 1:*|?:.)t=$dest/$dir ;;
  3912. *) t=$dest/$arch/$dir ;;
  3913. esac
  3914. case $t in
  3915. $ot) ;;
  3916. *) if test ! -d "$t"
  3917. then $exec mkdir -p "$t" || exit
  3918. fi
  3919. ot=$t
  3920. ;;
  3921. esac
  3922. case $file in
  3923. ?*) case $arch in
  3924. .) f=$dir/$file ;;
  3925. *) f=$arch/$dir/$file ;;
  3926. esac
  3927. if test -f "$f"
  3928. then t=$t/$file
  3929. case $quiet in
  3930. 0) echo "$t" ;;
  3931. esac
  3932. $exec cp -f "$f" "$t" || code=1
  3933. $exec chmod $mode "$t" || code=1
  3934. fi
  3935. ;;
  3936. esac
  3937. done
  3938. return $code
  3939. }
  3940. package_verify() # sum
  3941. {
  3942. $exec $SUM -cp $1
  3943. }
  3944. make_recurse() # dir
  3945. {
  3946. for _make_recurse_j in $makefiles
  3947. do if view - $1/$_make_recurse_j
  3948. then return
  3949. fi
  3950. done
  3951. }
  3952. get() # host path [ file size ]
  3953. {
  3954. case $HURL in
  3955. '') HURL=.
  3956. for i in wget lynx curl
  3957. do if onpath $i
  3958. then HURL=$i
  3959. break;
  3960. fi
  3961. done
  3962. AUTHORIZE="User-Agent: package AT&T Research\\r\\n"
  3963. case $HURL:$authorize in
  3964. .:?*) AUTHORIZE="${AUTHORIZE}Authorization: Basic `print -n -r -- $authorize:$password | uuencode -h -x base64`\\r\\n" ;;
  3965. esac
  3966. ;;
  3967. esac
  3968. getfd=8
  3969. case $3 in
  3970. '') case $HURL in
  3971. .) host=$1
  3972. path=$2
  3973. while :
  3974. do eval "exec $getfd<> /dev/tcp/$host/80" || exit
  3975. case $path in
  3976. /*) ;;
  3977. *) path=/$path ;;
  3978. esac
  3979. print "GET $path HTTP/1.0\\r\\nHost: $host\\r\\n$AUTHORIZE\\r" >&$getfd
  3980. cat <&8 > get.tmp
  3981. got=`sed -e 1q get.tmp`
  3982. case $got in
  3983. *" "200" "*)
  3984. got=`sed -e '1,/^.$/d' -e '/^[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWYZ]/!d' get.tmp`
  3985. : > get.err
  3986. code=0
  3987. break
  3988. ;;
  3989. *" "30[123]" "*)
  3990. got=`sed -e '/^Location: /!d' -e 's,^Location: \(.*\)://\([^/]*\)\(/.*\),prot='\''\1'\'' host='\''\2'\'' path='\''\3'\'',' get.tmp`
  3991. case $got in
  3992. '') rm get.tmp
  3993. echo "$command: $action: $url: redirect error" >&2
  3994. exit 1
  3995. ;;
  3996. esac
  3997. eval $got
  3998. ;;
  3999. *) rm get.tmp
  4000. echo "$command: $action: $url: $got" >&2
  4001. echo '' "$got" > get.err
  4002. code=1
  4003. break
  4004. ;;
  4005. esac
  4006. done
  4007. ;;
  4008. curl) case $authorize in
  4009. '') curl -s -L -o get.tmp http://$1/$2 2> get.err; code=$? ;;
  4010. *) curl -s -L -o get.tmp -u "$authorize":"$password" http://$1/$2 2> get.err; code=$? ;;
  4011. esac
  4012. got=`grep '^[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWYZ]' get.tmp 2>/dev/null`
  4013. case $code in
  4014. 0) if grep '^<H1>Authorization Required</H1>' get.tmp > get.err
  4015. then code=1
  4016. fi
  4017. ;;
  4018. esac
  4019. ;;
  4020. hurl) case $authorize in
  4021. '') hurl http://$1/$2 > get.tmp 2> get.err; code=$? ;;
  4022. *) hurl -a "$authorize":"$password" http://$1/$2 > get.tmp 2> get.err; code=$? ;;
  4023. esac
  4024. got=`grep '^[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWYZ]' get.tmp`
  4025. ;;
  4026. lynx) case $authorize in
  4027. '') lynx -source http://$1/$2 > get.tmp 2> get.err; code=$? ;;
  4028. *) lynx -source -auth "$authorize":"$password" http://$1/$2 > get.tmp 2> get.err; code=$? ;;
  4029. esac
  4030. got=`grep '^[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWYZ]' get.tmp`
  4031. ;;
  4032. wget) wget -nv -O get.tmp ${authorize:+--http-user="$authorize"} ${password:+--http-passwd="$password"} http://$1/$2 2> get.err
  4033. code=$?
  4034. got=`grep '^[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWYZ]' get.tmp 2>/dev/null`
  4035. ;;
  4036. *) echo $command: $action: $HURL: url get command not found >&2
  4037. exit 1
  4038. ;;
  4039. esac
  4040. if test 0 != "$code"
  4041. then case `cat get.err get.tmp 2>/dev/null` in
  4042. *[Aa][Uu][Tt][Hh][Oo][Rr][Ii][SsZz]*|*[Dd][Ee][Nn][Ii][Ee][Dd]*)
  4043. echo $command: $action: authorization required -- see $url for license acceptance authorization name and password >&2
  4044. ;;
  4045. *) cat get.err
  4046. ;;
  4047. esac
  4048. rm -f get.tmp get.err
  4049. echo $command: $action: $2: download failed >&2
  4050. exit 1
  4051. fi
  4052. rm -f get.tmp get.err
  4053. ;;
  4054. *) case $exec in
  4055. '') echo "$3 ($4 bytes):" >&2
  4056. case $HURL in
  4057. .) eval "exec $getfd<> /dev/tcp/$1/80" || exit
  4058. path=$2/$3
  4059. case $path in
  4060. /*) ;;
  4061. *) path=/$path ;;
  4062. esac
  4063. print "GET $path HTTP/1.0\\r\\nHost: $host\\r\\n$AUTHORIZE\\r" >&$getfd
  4064. read got <&$getfd
  4065. case $got in
  4066. *" 200 "*)
  4067. code=0
  4068. : > get.err
  4069. ;;
  4070. *) echo '' "$got" > get.err
  4071. code=1
  4072. ;;
  4073. esac
  4074. while read got <&$getfd
  4075. do case $got in
  4076. ''|?) break ;;
  4077. esac
  4078. done
  4079. cat <&$getfd > get.tmp
  4080. ;;
  4081. curl) case $authorize in
  4082. '') curl -s -L -o get.tmp http://$1/$2/$3 2> get.err; code=$? ;;
  4083. *) curl -s -L -o get.tmp -u "$authorize":"$password" http://$1/$2/$3 2> get.err; code=$?
  4084. esac
  4085. case $code in
  4086. 0) if grep '^<H1>Authorization Required</H1>' get.tmp > get.err
  4087. then code=1
  4088. fi
  4089. ;;
  4090. esac
  4091. ;;
  4092. hurl) case $authorize in
  4093. '') ksh -x hurl http://$1/$2/$3 > get.tmp 2> get.err; code=$? ;;
  4094. *) ksh -x hurl -a "$authorize":"$password" http://$1/$2/$3 > get.tmp 2> get.err; code=$? ;;
  4095. esac
  4096. ;;
  4097. lynx) case $authorize in
  4098. '') lynx -source http://$1/$2/$3 > get.tmp 2> get.err; code=$? ;;
  4099. *) lynx -source -auth "$authorize":"$password" http://$1/$2/$3 > get.tmp 2> get.err; code=$? ;;
  4100. esac
  4101. ;;
  4102. wget) wget -nv -O get.tmp ${authorize:+--http-user="$authorize"} ${password:+--http-passwd="$password"} http://$1/$2/$3 2> get.err
  4103. code=$?
  4104. ;;
  4105. *) echo $command: $action: $HURL: url get command not found >&2
  4106. exit 1
  4107. ;;
  4108. esac
  4109. if test 0 != "$code"
  4110. then case `cat get.err get.tmp` in
  4111. *[Aa][Uu][Tt][Hh][Oo][Rr][Ii][SsZz]*|*[Dd][Ee][Nn][Ii][Ee][Dd]*)
  4112. echo $command: $action: authorization required -- see $url for license acceptance authorization name and password >&2
  4113. ;;
  4114. *) cat get.err
  4115. ;;
  4116. esac
  4117. rm get.tmp get.err
  4118. echo $command: $action: $3: download failed >&2
  4119. exit 1
  4120. fi
  4121. rm get.err
  4122. case $checksum:$5 in
  4123. :*|*:-) z=`wc -c < get.tmp`
  4124. case " $z " in
  4125. *" $4 "*)
  4126. ;;
  4127. *) rm -f get.tmp
  4128. echo $command: $3: download error: expected $4 bytes, got $z >&2
  4129. exit 1
  4130. ;;
  4131. esac
  4132. ;;
  4133. *) z=`$checksum < get.tmp | sed -e 's,^[ ][ ]*,,' -e 's,[ ].*,,'`
  4134. case " $z " in
  4135. *" $5 "*)
  4136. ;;
  4137. *) rm -f get.tmp
  4138. echo $command: $3: download $checksum error: expected $5, got $z >&2
  4139. exit 1
  4140. ;;
  4141. esac
  4142. ;;
  4143. esac
  4144. mv get.tmp $3 || exit
  4145. ;;
  4146. *) echo "$3 ($4 bytes)" >&2
  4147. ;;
  4148. esac
  4149. esac
  4150. }
  4151. # generate copyright notice
  4152. copyright()
  4153. {
  4154. if test -f $1.lic
  4155. then echo $1 package general copyright notice
  4156. echo
  4157. proto -c'#' -p -s -l $1.lic -o type=verbose,author='*' /dev/null
  4158. return 0
  4159. fi
  4160. case $1 in
  4161. *-*) eval `echo '' $1 | sed 's/\([^-]*\)-\(.*\)/__j__="\1" __i__="\2"/'`
  4162. if copyright $__i__ || copyright $__j__
  4163. then return 0
  4164. fi
  4165. ;;
  4166. esac
  4167. return 1
  4168. }
  4169. # run remote make on host
  4170. remote() # host no-exec-background
  4171. {
  4172. host=$1
  4173. background=$2
  4174. eval name=\$${host}_name user=\$${host}_user snarf=\$${host}_snarf type=\$${host}_type rsh=\$${host}_rsh root=\$${host}_root keep=\$${host}_keep log=\$${host}_log
  4175. case $keep in
  4176. 1*) ;;
  4177. *) return ;;
  4178. esac
  4179. case $host in
  4180. $main) ;;
  4181. *) case $exec in
  4182. '') exec > $admin_log/$log 2>&1 ;;
  4183. *) echo "exec > $admin_log/$log 2>&1" ;;
  4184. esac
  4185. ;;
  4186. esac
  4187. if $admin_ping $name >/dev/null 2>&1 || $admin_ping $name >/dev/null 2>&1
  4188. then cmd=". ./.profile"
  4189. case $root in
  4190. .) root=
  4191. ;;
  4192. *) cmd="$cmd && cd $root"
  4193. root=$root/
  4194. ;;
  4195. esac
  4196. cmd="$cmd && { test -f lib/package/admin/$admin_env && . ./lib/package/admin/$admin_env || true ;} && PATH=\${PWD:-\`pwd\`}/bin:\$PATH \${SHELL:-/bin/sh} -c 'package $admin_args PACKAGEROOT=\${PWD:-\`pwd\`} HOSTTYPE=$type VPATH='"
  4197. case $admin_binary in
  4198. '') snarf= ;;
  4199. esac
  4200. case $snarf in
  4201. '') $exec $rsh $user$name "$cmd" $background
  4202. ;;
  4203. *?) rcp=`echo $rsh | sed 's/\(.\).*/\1/'`cp
  4204. case $background in
  4205. ?*) $exec "{" ;;
  4206. esac
  4207. $exec $rsh $user$name "$cmd"
  4208. eval lst=$admin_list
  4209. case $admin_pkgs in
  4210. '') filter=cat ;;
  4211. *) filter="egrep lib/package/tgz/($admin_pkgs)\\." ;;
  4212. esac
  4213. if $exec $rcp $user$name:${root}lib/package/tgz/$lst $PACKAGESRC/tgz
  4214. then $exec $rcp `$filter $PACKAGESRC/tgz/$lst | sed "s,^,$user$name:,"` $PACKAGESRC/tgz
  4215. else echo "$command: $user$name:${root}lib/package/tgz/$lst: not found" >&2
  4216. fi
  4217. case $background in
  4218. ?*) $exec "} $background" ;;
  4219. esac
  4220. ;;
  4221. esac
  4222. else echo "$command: $name: down" >&2
  4223. fi
  4224. }
  4225. # update package_src
  4226. checksrc()
  4227. {
  4228. case $package_src in
  4229. '') package_src=$src
  4230. for _i_ in `cd $PACKAGESRC; ls *.def *.lic *.pkg 2>/dev/null | sed 's/[-.].*//'`
  4231. do case " $package_src " in
  4232. *" $_i_ "*)
  4233. ;;
  4234. *) package_src="$package_src $_i_"
  4235. ;;
  4236. esac
  4237. done
  4238. ;;
  4239. esac
  4240. }
  4241. # check for native ascii 0:yes 1:no
  4242. __isascii__=
  4243. isascii()
  4244. {
  4245. case $__isascii__ in
  4246. '') case `echo A | od -o | sed -e 's/[ ]*$//' -e '/[ ]/!d' -e 's/.*[ ]//'` in
  4247. 005101|040412) __isascii__=0 ;;
  4248. *) __isascii__=1 ;;
  4249. esac
  4250. esac
  4251. return $__isascii__
  4252. }
  4253. error_status=0
  4254. case $action in
  4255. admin) while test ! -f $admin_db
  4256. do case $admin_db in
  4257. /*) echo $command: $action: $admin_db: data file not found >&2
  4258. exit 1
  4259. ;;
  4260. esac
  4261. view file src lib/package/admin/$admin_db || exit 1
  4262. admin_db=$_view_
  4263. done
  4264. admin_components=
  4265. case $admin_action in
  4266. list) cat $admin_db
  4267. exit
  4268. ;;
  4269. test) set $admin_args
  4270. while :
  4271. do case $# in
  4272. 1) break ;;
  4273. esac
  4274. shift
  4275. case $1 in
  4276. *=*) ;;
  4277. *) admin_components=-$1
  4278. break
  4279. ;;
  4280. esac
  4281. done
  4282. ;;
  4283. esac
  4284. : all work done in $PACKAGESRC/admin
  4285. cd $PACKAGESRC/admin || exit
  4286. checksrc
  4287. packages=
  4288. admin_log=${admin_action}${admin_components}.log
  4289. exec < $admin_db || exit
  4290. test -d $admin_log || $exec mkdir $admin_log || exit
  4291. case $admin_on in
  4292. '') admin_on="*" ;;
  4293. esac
  4294. hostname=
  4295. hosts=
  4296. logs=
  4297. local_hosts=
  4298. local_types=
  4299. pids=
  4300. remote_hosts=
  4301. sync_hosts=
  4302. admin_host=_admin_host_
  4303. admin_out=
  4304. case " $admin_args " in
  4305. *" write binary "*|*" write "*" binary "*)
  4306. admin_binary=1
  4307. ;;
  4308. *) admin_binary=
  4309. ;;
  4310. esac
  4311. case $only in
  4312. 1) admin_args="only $admin_args" ;;
  4313. esac
  4314. trap 'kill $pids >/dev/null 2>&1' 1 2 3 15
  4315. index=0
  4316. while read type host root date time make test write owner attributes
  4317. do case $type in
  4318. ''|'#'*);;
  4319. *=*) eval "$type $host $root $date $time $make $test $write $owner $attributes"
  4320. ;;
  4321. *) case $admin_action in
  4322. make|test|write)
  4323. eval f='$'$admin_action
  4324. case $f in
  4325. *[!0123456789]*) continue ;;
  4326. esac
  4327. ;;
  4328. esac
  4329. rsh=rsh
  4330. case $host in
  4331. *@*) IFS=@
  4332. set '' $host
  4333. IFS=$ifs
  4334. user=${2}@
  4335. host=$3
  4336. ;;
  4337. *) user=
  4338. ;;
  4339. esac
  4340. : type=$type host=$host root=$root date=$date time=$time make=$make test=$test write=$write :
  4341. name=$host
  4342. host=`echo $name | sed 's,[^abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789],__,g'`
  4343. eval x='$'${host}_index
  4344. eval ${host}_index=1
  4345. case $x in
  4346. 1) i=0
  4347. while :
  4348. do case $i in
  4349. $index) h=''
  4350. break
  4351. ;;
  4352. esac
  4353. i=`expr $i + 1`
  4354. eval h='$'${admin_host}${i}_name
  4355. case $h in
  4356. $host) host=${admin_host}${i}
  4357. eval user='$'${host}_user root='$'${host}_rsh:$host:'$'${host}_root
  4358. break
  4359. ;;
  4360. esac
  4361. done
  4362. ;;
  4363. esac
  4364. case $root in
  4365. *:$name:*)root=`echo '' $root | sed 's,:.*,:,'` ;;
  4366. esac
  4367. case $root in
  4368. *:*:*) index=`expr $index + 1`
  4369. host=${admin_host}$index
  4370. ;;
  4371. *:*) case " $sync_hosts " in
  4372. *" $name ${admin_host}"*)
  4373. set '' '' $sync_hosts
  4374. while :
  4375. do shift
  4376. shift
  4377. case $1 in
  4378. $name) host=$2
  4379. break
  4380. ;;
  4381. esac
  4382. done
  4383. ;;
  4384. *) index=`expr $index + 1`
  4385. host=${admin_host}$index
  4386. sync_hosts="$sync_hosts $name $host"
  4387. ;;
  4388. esac
  4389. ;;
  4390. *) index=`expr $index + 1`
  4391. host=${admin_host}$index
  4392. ;;
  4393. esac
  4394. case $root in
  4395. -*) continue
  4396. ;;
  4397. *:*) case $admin_all in
  4398. 0) continue ;;
  4399. esac
  4400. case $root in
  4401. *:) root=${root}. ;;
  4402. esac
  4403. IFS=:
  4404. set '' $root
  4405. IFS=$ifs
  4406. sync=$host
  4407. case $hostname in
  4408. '') hostinfo name
  4409. hostname=$_hostinfo_
  4410. ;;
  4411. esac
  4412. shift
  4413. case $# in
  4414. 0) ;;
  4415. 1) root=$1
  4416. ;;
  4417. 2) rsh=$1 root=$2
  4418. ;;
  4419. *) rsh=$1 sync=$2 root=$3
  4420. case $sync in
  4421. ${admin_host}*)
  4422. ;;
  4423. ?*) case " $sync_hosts " in
  4424. *" $sync ${admin_host}"*)
  4425. set '' '' $sync_hosts
  4426. while :
  4427. do shift
  4428. shift
  4429. case $1 in
  4430. $sync) sync=$2
  4431. break
  4432. ;;
  4433. esac
  4434. done
  4435. ;;
  4436. *) index=`expr $index + 1`
  4437. x=${admin_host}$index
  4438. sync_hosts="$sync_hosts $sync $x"
  4439. sync=$x
  4440. ;;
  4441. esac
  4442. ;;
  4443. esac
  4444. ;;
  4445. esac
  4446. ;;
  4447. *) sync=
  4448. ;;
  4449. esac
  4450. case $name in
  4451. $admin_on)
  4452. keep=1
  4453. ;;
  4454. *) case " $admin_on " in
  4455. *" $name "*) keep=1 ;;
  4456. *) keep=0 ;;
  4457. esac
  4458. ;;
  4459. esac
  4460. case " $admin_out " in
  4461. *" $name "*)
  4462. log=$name.$type
  4463. ;;
  4464. *) admin_out="$admin_out $name"
  4465. log=$name
  4466. ;;
  4467. esac
  4468. case $sync in
  4469. '') local_types="$local_types $type" ;;
  4470. esac
  4471. case $sync in
  4472. $host) remote_hosts="$remote_hosts $host"
  4473. ;;
  4474. ?*) eval ${sync}_share=\"\$${sync}_share $host\"
  4475. ;;
  4476. '') local_hosts="$local_hosts $host"
  4477. ;;
  4478. esac
  4479. eval ${host}_name='$'name ${host}_type='$'type ${host}_user='$'user ${host}_sync='$'sync ${host}_snarf='$'sync ${host}_rsh='$'rsh ${host}_root='$'root ${host}_keep='$'keep ${host}_log='$'log
  4480. ;;
  4481. esac
  4482. done
  4483. p=
  4484. for i in $admin_args
  4485. do p="$i $p"
  4486. done
  4487. admin_pkgs=
  4488. for i in $p
  4489. do if view - src "lib/package/$i.pkg"
  4490. then case $admin_pkgs in
  4491. '') admin_pkgs="$i" ;;
  4492. *) admin_pkgs="$admin_pkgs|$i" ;;
  4493. esac
  4494. fi
  4495. done
  4496. : "admin_binary :" $admin_binary
  4497. : "admin_args :" $admin_args
  4498. : "admin_pkgs :" $admin_pkgs
  4499. : "admin_on :" "$admin_on"
  4500. : "local_hosts :" $local_hosts
  4501. : "local_types :" $local_types
  4502. : "remote_hosts :" $remote_hosts
  4503. : "sync_hosts :" $sync_hosts
  4504. : "sync_share :" $sync_share
  4505. case $admin_binary in
  4506. 1) admin_bin_types=
  4507. admin_bin_main=
  4508. for main in $local_hosts $remote_hosts
  4509. do eval share=\$${main}_share keep=\$${main}_keep
  4510. case $keep in
  4511. 0*) continue ;;
  4512. esac
  4513. for host in $main $share
  4514. do case " $admin_bin_hosts " in
  4515. *" $host "*)
  4516. continue
  4517. ;;
  4518. esac
  4519. eval type=\$${host}_type
  4520. case " $admin_bin_types " in
  4521. *" $type "*)
  4522. continue
  4523. ;;
  4524. esac
  4525. case " $types " in
  4526. " ") ;;
  4527. *" $type "*)
  4528. ;;
  4529. *) continue
  4530. ;;
  4531. esac
  4532. admin_bin_hosts="$admin_bin_hosts $host"
  4533. admin_bin_types="$admin_bin_types $type"
  4534. case " $admin_bin_hosts " in
  4535. *" $main "*)
  4536. ;;
  4537. *) case " $admin_bin_main " in
  4538. *" $main "*)
  4539. ;;
  4540. *) admin_bin_main="$admin_bin_main $main"
  4541. ;;
  4542. esac
  4543. ;;
  4544. esac
  4545. done
  4546. done
  4547. local=
  4548. remote=
  4549. for host in $admin_bin_main $admin_bin_hosts
  4550. do case " $local_hosts " in
  4551. *" $host "*)
  4552. local="$local $host"
  4553. ;;
  4554. *) case " $remote_hosts " in
  4555. *" $host "*)
  4556. remote="$remote $host"
  4557. ;;
  4558. esac
  4559. ;;
  4560. esac
  4561. done
  4562. local_hosts=$local
  4563. remote_hosts=$remote
  4564. ;;
  4565. esac
  4566. for host in $remote_hosts $local_hosts
  4567. do eval share=\$${host}_share
  4568. case $share in
  4569. ?*) while :
  4570. do oshare=$share
  4571. for s in $share
  4572. do eval r='$'${s}_share
  4573. case $r in
  4574. ?*) case " $share " in
  4575. *" $r "*) ;;
  4576. *) share="$share $r" ;;
  4577. esac
  4578. ;;
  4579. esac
  4580. done
  4581. case $share in
  4582. $oshare) eval ${host}_share="'$share'"
  4583. break
  4584. ;;
  4585. esac
  4586. done
  4587. ;;
  4588. esac
  4589. done
  4590. for host in $remote_hosts
  4591. do eval type=\$${host}_type
  4592. case " $local_types " in
  4593. *" $type "*)
  4594. eval ${host}_snarf=
  4595. ;;
  4596. esac
  4597. eval name=\$${host}_name keep=\$${host}_keep share=\$${host}_share
  4598. for share in $share
  4599. do eval type=\$${share}_type keep=\$keep\$${share}_keep
  4600. case " $local_types " in
  4601. *" $type "*)
  4602. eval ${share}_snarf=
  4603. ;;
  4604. esac
  4605. done
  4606. case $keep in
  4607. 0*1*) keep=2$keep ;;
  4608. *1*) ;;
  4609. *) keep=0 ;;
  4610. esac
  4611. eval ${host}_keep=$keep
  4612. done
  4613. for host in $remote_hosts $local_hosts
  4614. do eval name=\$${host}_name user=\$${host}_user type=\$${host}_type sync=\$${host}_sync snarf=\$${host}_snarf share=\$${host}_share rsh=\$${host}_rsh root=\$${host}_root keep=\$${host}_keep
  4615. case $keep in
  4616. 0*) continue ;;
  4617. esac
  4618. case $sync in
  4619. '') case $admin_action in
  4620. ditto) continue ;;
  4621. esac
  4622. case $admin_binary in
  4623. 1) case $keep in
  4624. 1*|?*1*);;
  4625. *) continue ;;
  4626. esac
  4627. ;;
  4628. esac
  4629. ;;
  4630. esac
  4631. eval main_log='$'${host}_log
  4632. main=
  4633. share_keep=
  4634. for i in $host $share
  4635. do eval n='$'${i}_name t='$'${i}_type q='$'${i}_sync s='$'${i}_snarf l='$'${i}_log k='$'${i}_keep
  4636. case $main:$k in
  4637. :*) ;;
  4638. *:0) continue ;;
  4639. esac
  4640. case $admin_binary in
  4641. 1) case $s:$q in
  4642. :?*) continue ;;
  4643. esac
  4644. case " $admin_bin_hosts " in
  4645. *" $i "*)
  4646. ;;
  4647. *) continue
  4648. ;;
  4649. esac
  4650. ;;
  4651. esac
  4652. case $main in
  4653. '') main=$i ;;
  4654. *) share_keep="$share_keep $i" ;;
  4655. esac
  4656. echo package "$admin_args" "[ $n $t ]"
  4657. case $exec in
  4658. '') : > $admin_log/$l ;;
  4659. *) $exec ": > $admin_log/$l" ;;
  4660. esac
  4661. done
  4662. host=$main
  4663. share=$share_keep
  4664. case $force in
  4665. 0) admin_ditto_update=--update ;;
  4666. *) admin_ditto_update= ;;
  4667. esac
  4668. case $exec in
  4669. '') {
  4670. case $admin_binary:$sync in
  4671. :?*) eval syncname='$'${sync}_name
  4672. test -x $PACKAGEROOT/bin/package && $admin_ditto $admin_ditto_update --remote=$rsh --expr="name=='package'" $PACKAGEROOT/bin $user$syncname:$root/bin
  4673. test -d $PACKAGESRC && $admin_ditto $admin_ditto_update --remote=$rsh --expr="if(level>1&&path!='LICENSES/*')status=SKIP;path=='LICENSES*|*.(pkg|lic|def)'" $PACKAGESRC $user$syncname:$root/lib/package
  4674. for dir in $package_src
  4675. do case $MAKESKIP in
  4676. '') expr="--expr=if(name=='$admin_ditto_skip')status=SKIP" ;;
  4677. *) expr="--expr=if(name=='$admin_ditto_skip'||level==1&&name=='$MAKESKIP')status=SKIP" ;;
  4678. esac
  4679. test -d $PACKAGEROOT/src/$dir && $admin_ditto $admin_ditto_update --remote=$rsh "$expr" $PACKAGEROOT/src/$dir $user$syncname:$root/src/$dir
  4680. done
  4681. ;;
  4682. esac
  4683. case $admin_action in
  4684. ditto) ;;
  4685. ?*) pids=
  4686. set '' $host $share
  4687. while :
  4688. do shift
  4689. case $# in
  4690. 0) break
  4691. ;;
  4692. 1) remote $1
  4693. ;;
  4694. *) remote $1 &
  4695. pids="$pids $!"
  4696. ;;
  4697. esac
  4698. done
  4699. case $pids in
  4700. ?*) wait $pids ;;
  4701. esac
  4702. ;;
  4703. esac
  4704. } < /dev/null > $admin_log/$main_log 2>&1 &
  4705. pids="$pids $!"
  4706. ;;
  4707. *) echo "{"
  4708. case $admin_binary:$sync in
  4709. :?*) eval syncname='$'${sync}_name
  4710. test -d $PACKAGESRC && echo $admin_ditto $admin_ditto_update --remote=$rsh --expr="if(level>1)status=SKIP;name=='*.(pkg|lic|def)'" $PACKAGESRC $user$syncname:$root/lib/package
  4711. for dir in $package_src
  4712. do case $MAKESKIP in
  4713. '') expr="--expr=if(name=='$admin_ditto_skip')status=SKIP" ;;
  4714. *) expr="--expr=if(name=='$admin_ditto_skip'||level==1&&name=='$MAKESKIP')status=SKIP" ;;
  4715. esac
  4716. test -d $PACKAGEROOT/src/$dir && echo $admin_ditto $admin_ditto_update --remote=$rsh "$expr" $PACKAGEROOT/src/$dir $user$syncname:$root/src/$dir
  4717. done
  4718. ;;
  4719. esac
  4720. case $admin_action in
  4721. ditto) ;;
  4722. ?*) pids=
  4723. set '' $host $share
  4724. while :
  4725. do shift
  4726. case $# in
  4727. 0) break
  4728. ;;
  4729. 1) remote $1
  4730. ;;
  4731. *) remote $1 "&"
  4732. pids=1
  4733. ;;
  4734. esac
  4735. done
  4736. case $pids in
  4737. 1) echo wait ;;
  4738. esac
  4739. ;;
  4740. esac
  4741. echo "} < /dev/null > $admin_log/$main_log 2>&1 &"
  4742. ;;
  4743. esac
  4744. eval name='$'${main}_name
  4745. hosts="$hosts $name"
  4746. logs="$logs $main_log"
  4747. for share in $share
  4748. do eval keep=\$${share}_keep
  4749. case $keep in
  4750. 1) eval name='$'${share}_name log='$'${share}_log
  4751. hosts="$hosts $name"
  4752. logs="$logs $log"
  4753. ;;
  4754. esac
  4755. done
  4756. done
  4757. case $exec in
  4758. '') # track the progress
  4759. case $quiet in
  4760. 0) cd $admin_log
  4761. tail -t $PACKAGE_admin_tail_timeout -f $logs
  4762. cd ..
  4763. ;;
  4764. esac
  4765. # wait for the remote actions to complete
  4766. wait
  4767. trap - 1 2 3 15
  4768. # update the db
  4769. exec < $admin_db || exit
  4770. exec 9>&1
  4771. D=`date +%y%m%d`
  4772. while read line
  4773. do set -- $line
  4774. case $1 in
  4775. ''|'#'*|*=*)
  4776. ;;
  4777. *) case " $hosts " in
  4778. *" $2 "*)
  4779. : ast date command assumed :
  4780. E=`eval date -E \`egrep '[ ](start|done)[ ][ ]*at[ ]' $admin_log/$2 | sed -e 's/.*[ ][ ]*at[ ][ ]*//' -e 's/[ ][ ]*in[ ].*$//' -e 's/.*/"&"/'\``
  4781. M=$6 T=$7 W=$8
  4782. case $admin_action in
  4783. make|view)
  4784. M=`egrep -c ']:.* (\*\*\*.* code|don'\''t know) | \*\*\* termination code ' $admin_log/$2` ;;
  4785. test) T=`grep -ci 'fail[es]' $admin_log/$2` ;;
  4786. *) W=`grep '^[abcdefghijklmnopqrstuvwxyz][abcdefghijklmnopqrstuvwxyz]*:.' $admin_log/$2 | egrep -cv 'start at|done at|output captured|warning:|: package not found|whence: command not found'` ;;
  4787. esac
  4788. case $1 in
  4789. ?|??|???|????|?????|??????|???????)
  4790. t1=' '
  4791. ;;
  4792. ????????|?????????|??????????|???????????|????????????|?????????????|??????????????|???????????????)
  4793. t1=' '
  4794. ;;
  4795. *) t1=''
  4796. ;;
  4797. esac
  4798. case $2 in
  4799. ?|??|???|????|?????|??????|???????)
  4800. t2=' '
  4801. ;;
  4802. *) t2=''
  4803. ;;
  4804. esac
  4805. case $3 in
  4806. ?|??|???|????|?????|??????|???????)
  4807. t3=' '
  4808. ;;
  4809. *) t3=''
  4810. ;;
  4811. esac
  4812. case $E in
  4813. ?????) E=" $E" ;;
  4814. ????) E=" $E" ;;
  4815. ???) E=" $E" ;;
  4816. ??) E=" $E" ;;
  4817. ?) E=" $E" ;;
  4818. esac
  4819. case $M in
  4820. ???) M="$M" ;;
  4821. ??) M=" $M" ;;
  4822. ?) M=" $M" ;;
  4823. '') M=" 0" ;;
  4824. esac
  4825. case $T in
  4826. ???) T="$T" ;;
  4827. ??) T=" $T" ;;
  4828. ?) T=" $T" ;;
  4829. '') T=" 0" ;;
  4830. esac
  4831. case $W in
  4832. ???) W="$W" ;;
  4833. ??) W=" $W" ;;
  4834. ?) W=" $W" ;;
  4835. '') W=" 0" ;;
  4836. esac
  4837. A=$1$t1
  4838. H=$2$t2
  4839. R=$3$t3
  4840. case $# in
  4841. [0-8]) O=
  4842. K=
  4843. ;;
  4844. *) shift 8
  4845. O=$1
  4846. K=$2
  4847. case $O in
  4848. ''|?|??|???) K=" $K" ;;
  4849. esac
  4850. case $# in
  4851. [0-2]) ;;
  4852. *) K="$K $*" ;;
  4853. esac
  4854. ;;
  4855. esac
  4856. echo "$A $H $R $D $E $M $T $W $O $K"
  4857. echo "$A $H $R $D $E $M $T $W $O $K" >&9
  4858. continue
  4859. ;;
  4860. esac
  4861. ;;
  4862. esac
  4863. echo "$line"
  4864. done > $admin_db.new
  4865. mv $admin_db $admin_db.old
  4866. mv $admin_db.new $admin_db
  4867. ;;
  4868. esac
  4869. ;;
  4870. clean|clobber)
  4871. cd $PACKAGEROOT
  4872. $exec rm -rf arch/$HOSTTYPE
  4873. if test "$flat" = 1
  4874. then $exec rm -rf \
  4875. bin/.paths \
  4876. bin/ar \
  4877. bin/cc \
  4878. bin/crossexec \
  4879. bin/ditto \
  4880. bin/filter \
  4881. bin/hurl \
  4882. bin/iffe \
  4883. bin/ksh \
  4884. bin/mamake \
  4885. bin/mktest \
  4886. bin/ok/ \
  4887. bin/proto \
  4888. bin/pty \
  4889. bin/ratz \
  4890. bin/regress \
  4891. bin/release \
  4892. bin/rt \
  4893. bin/shcomp \
  4894. bin/suid_exec \
  4895. bin/*.old \
  4896. fun/ \
  4897. include/ \
  4898. lib/file/ \
  4899. lib/lib/ \
  4900. lib/libast.a \
  4901. lib/libcmd.a \
  4902. lib/libdll.a \
  4903. lib/libshell.a \
  4904. lib/libsum.a \
  4905. lib/*.old \
  4906. lib/make/ \
  4907. lib/package/gen/ \
  4908. lib/probe/ \
  4909. man/
  4910. fi
  4911. exit
  4912. ;;
  4913. contents|list)
  4914. # all work in $PACKAGESRC
  4915. cd $PACKAGESRC
  4916. # generate the package list
  4917. set '' $target $package
  4918. shift
  4919. argc=$#
  4920. case $# in
  4921. 0) set '' *.pkg
  4922. case $2 in
  4923. '*.pkg')
  4924. echo $command: $action: no packages >&2
  4925. exit 1
  4926. ;;
  4927. esac
  4928. set '' `echo $* | sed 's,\.pkg,,g'`
  4929. shift
  4930. ;;
  4931. esac
  4932. sep="$nl "
  4933. echo packages in $PACKAGEROOT
  4934. case $action in
  4935. list) echo
  4936. echo "NAME${nl}VERSION${nl}RELEASE${nl}TYPE${nl}STATUS${nl}REQUIRES${nl}----${nl}-------${nl}-------${nl}----${nl}------${nl}--------" | pr -6 -a -o4 -t
  4937. ;;
  4938. esac
  4939. {
  4940. omit=:
  4941. for pkg
  4942. do if test ! -f $pkg.pkg
  4943. then echo $command: $action: $pkg: not a package >&2
  4944. else if test -f gen/$pkg.ver
  4945. then set '' `cat gen/$pkg.ver`
  4946. case $3 in
  4947. $2) ver=base ;;
  4948. *) ver=$3 ;;
  4949. esac
  4950. if test -s tgz/$pkg.tim
  4951. then sts=local
  4952. else sts=
  4953. fi
  4954. else ver=
  4955. sts=unwritten
  4956. fi
  4957. typ=
  4958. txt=
  4959. cmp= cmp_sep=
  4960. req= req_sep=
  4961. op=::
  4962. exec < $pkg.pkg
  4963. while read line
  4964. do IFS=' \\'
  4965. set '' $line
  4966. IFS=$ifs
  4967. while :
  4968. do shift
  4969. case $# in
  4970. 0) break ;;
  4971. esac
  4972. case $1 in
  4973. :*:) op=$1
  4974. ;;
  4975. INIT|'$('*|*')')
  4976. ;;
  4977. *) case $op in
  4978. :DESCRIPTION:)
  4979. txt="$txt$sep$line"
  4980. break
  4981. ;;
  4982. :PACKAGE:)
  4983. cmp="$cmp$cmp_sep$1"
  4984. cmp_sep=$nl
  4985. ;;
  4986. :REQUIRES:)
  4987. req="$req$req_sep$1"
  4988. req_sep=" "
  4989. ;;
  4990. esac
  4991. ;;
  4992. esac
  4993. done
  4994. done
  4995. exec < /dev/null
  4996. case $txt in
  4997. ?*) txt="$nl$txt" ;;
  4998. esac
  4999. case :$ver: in
  5000. *::*) ;;
  5001. *) case $action in
  5002. list) case $sts in
  5003. '') case `ls -t "tgz/$pkg.$ver.base" "tgz/$pkg.tim" 2>/dev/null` in
  5004. "tgz/$pkg.tim"*)
  5005. sts=read
  5006. ;;
  5007. *) sts=unread
  5008. ;;
  5009. esac
  5010. ;;
  5011. esac
  5012. echo "$pkg${nl}$ver${nl}base${nl}$typ${nl}$sts${nl}$req"
  5013. case $typ in
  5014. '') omit=$omit$pkg.$ver.base: ;;
  5015. esac
  5016. ;;
  5017. *) case $req in
  5018. ?*) req=": $req" ;;
  5019. esac
  5020. echo
  5021. echo $pkg $ver $req "$txt"
  5022. case $cmp in
  5023. ?*) echo "${sep}Components in this package:$nl"
  5024. echo "$cmp" | pr -4 -o4 -t ;;
  5025. esac
  5026. ;;
  5027. esac
  5028. ;;
  5029. esac
  5030. fi
  5031. done
  5032. case $argc:$action in
  5033. 0:list) if test -d tgz
  5034. then cd tgz
  5035. # f:file p:package v:version r:release t:type u:update
  5036. for f in `find . -name '*?[_.][0123456789][0123456789][0123456789][0123456789]-[0123456789][0123456789]-[0123456789][0123456789][_.]*' -print | sed 's,^\./,,' | sort -r`
  5037. do eval `echo "$f" | sed -e 's,\.c$,,' -e 's,\.gz$,,' -e 's,\.exe$,,' -e 's,\.tgz$,,' -e 's,\([^_.]*\)[_.]\([0123456789][0123456789][0123456789][0123456789]-[0123456789][0123456789]-[0123456789][0123456789]\)[_.]\([0123456789][0123456789][0123456789][0123456789][^_.]*\)[_.]*\(.*\),p=\1 v=\2 r=\3 t=\4,' -e 's,\([^_.]*\)[_.]\([0123456789][0123456789][0123456789][0123456789]-[0123456789][0123456789]-[0123456789][0123456789]\)[_.]*\(.*\),p=\1 v=\2 r=base t=\3,'`
  5038. case $t in
  5039. '') case $omit in
  5040. *:$p.$v.$r:*) continue ;;
  5041. esac
  5042. u=$p.tim
  5043. ;;
  5044. *) u=$p.$t.tim
  5045. ;;
  5046. esac
  5047. if test -s "$u"
  5048. then s=local
  5049. elif test -f "$u"
  5050. then case `ls -t "$f" "$u" 2>/dev/null` in
  5051. "$u"*) s=read ;;
  5052. *) s=unread ;;
  5053. esac
  5054. else s=unread
  5055. fi
  5056. echo "$p$nl$v$nl$r$nl$t$nl$s$nl"
  5057. done
  5058. fi
  5059. ;;
  5060. esac
  5061. } |
  5062. case $action in
  5063. list) pr -6 -a -o4 -t | sort -u ;;
  5064. *) cat ;;
  5065. esac
  5066. case $argc in
  5067. 0) if test -d $PACKAGEROOT/arch
  5068. then echo
  5069. echo architectures in $PACKAGEROOT
  5070. echo
  5071. for i in `ls $PACKAGEROOT/arch`
  5072. do if test -f $PACKAGEROOT/arch/$i/lib/package/gen/host
  5073. then h=`cat $PACKAGEROOT/arch/$i/lib/package/gen/host`
  5074. else h=
  5075. fi
  5076. echo $i
  5077. echo $h
  5078. echo
  5079. echo
  5080. done | pr -4 -a -o4 -t
  5081. fi
  5082. ;;
  5083. esac
  5084. ;;
  5085. copyright)
  5086. # all work in $PACKAGESRC
  5087. cd $PACKAGESRC
  5088. # generate the package list
  5089. set '' $target $package
  5090. shift
  5091. argc=$#
  5092. case $# in
  5093. 0) set '' `echo *.lic | sed 's,\.lic,,g'`
  5094. shift
  5095. case $1 in
  5096. '*') echo $command: $action: no packages >&2
  5097. exit 1
  5098. ;;
  5099. esac
  5100. ;;
  5101. esac
  5102. checkaout proto || exit
  5103. for i
  5104. do copyright $i
  5105. done
  5106. ;;
  5107. export) case $INSTALLROOT in
  5108. $PACKAGEROOT)
  5109. INSTALLROOT=$INSTALLROOT/arch/$HOSTTYPE
  5110. ;;
  5111. esac
  5112. case $only in
  5113. 0) v='$i=' ;;
  5114. *) v= ;;
  5115. esac
  5116. set '' $target $package
  5117. case $# in
  5118. 1) set '' $env ;;
  5119. esac
  5120. while :
  5121. do case $# in
  5122. 1) break ;;
  5123. esac
  5124. shift
  5125. i=$1
  5126. eval echo ${v}'$'${i}
  5127. done
  5128. ;;
  5129. install)cd $PACKAGEROOT
  5130. set '' $package
  5131. shift
  5132. case $only in
  5133. 0) set '' `order "$@"`
  5134. shift
  5135. ;;
  5136. esac
  5137. case $# in
  5138. 0) echo "$command: at least one package name expected" >&2
  5139. exit 1
  5140. ;;
  5141. esac
  5142. package=$*
  5143. requirements - $package
  5144. set '' $target
  5145. shift
  5146. case $1 in
  5147. flat) flat=1 # backwards compatibility -- documentation dropped
  5148. shift
  5149. ;;
  5150. esac
  5151. case $# in
  5152. 0) echo "$command: $action: target directory argument expected" >&2
  5153. exit 1
  5154. ;;
  5155. esac
  5156. target=
  5157. while :
  5158. do case $# in
  5159. 1) directory=$1
  5160. break
  5161. ;;
  5162. esac
  5163. target="$target $1"
  5164. shift
  5165. done
  5166. if test ! -d $directory
  5167. then echo "$command: $action: $directory: target directory not found" >&2
  5168. exit 1
  5169. fi
  5170. case $target in
  5171. '') cd arch
  5172. set '' *
  5173. shift
  5174. target=$*
  5175. cd ..
  5176. ;;
  5177. esac
  5178. code=0
  5179. makecheck=1
  5180. for a in $target
  5181. do case $a in
  5182. -) a=$HOSTTYPE ;;
  5183. esac
  5184. case $flat:$a in
  5185. 1:*|?:.)dest=$directory
  5186. ;;
  5187. *) dest=$directory/arch/$a
  5188. if test "" = "$exec" -a ! -d $dest
  5189. then mkdir -p $dest || {
  5190. echo "$command: $dest: destination directory must exist" >&2
  5191. exit 1
  5192. }
  5193. fi
  5194. ;;
  5195. esac
  5196. for i in $package
  5197. do if test "ratz" = "$i"
  5198. then : skip
  5199. elif test -f arch/$a/lib/package/gen/$i.sum
  5200. then package_install $directory arch/$a/lib/package/gen/$i.sum || code=1
  5201. elif test ! -d arch/$a/bin
  5202. then echo "$command: $a: invalid architecture" >&2
  5203. elif test ! -d $dest
  5204. then echo "$command: $dest: destination directory must exist" >&2
  5205. else if test "" != "$makecheck"
  5206. then if onpath $MAKE
  5207. then MAKE=$_onpath_
  5208. else echo "$command: $MAKE: not found" >&2
  5209. exit 1
  5210. fi
  5211. makecheck=
  5212. fi
  5213. if test "" != "$exec"
  5214. then (
  5215. trap - 0 1 2 15
  5216. echo "=== $i installation manifest ==="
  5217. cd arch/$a
  5218. (
  5219. cd lib/package
  5220. INSTALLROOT=$PACKAGEROOT/arch/$a
  5221. VPATH=$INSTALLROOT:$PACKAGEROOT:$VPATH
  5222. export INSTALLROOT VPATH
  5223. $MAKE -s $makeflags -f $i.pkg $qualifier list.installed $assign
  5224. ) | sort -u
  5225. )
  5226. else (
  5227. set -
  5228. cd arch/$a
  5229. (
  5230. cd lib/package
  5231. INSTALLROOT=$PACKAGEROOT/arch/$a
  5232. VPATH=$INSTALLROOT:$PACKAGEROOT:$VPATH
  5233. export INSTALLROOT VPATH
  5234. echo lib/$command
  5235. $MAKE -s $makeflags -f $i.pkg $qualifier list.installed $assign
  5236. ) | sort -u | pax -drw -ps $dest
  5237. )
  5238. fi
  5239. fi
  5240. done
  5241. done
  5242. exit $code
  5243. ;;
  5244. license)# all work in $PACKAGESRC/LICENSES
  5245. cd $PACKAGESRC/LICENSES || exit
  5246. # generate the package list
  5247. set '' $target $package
  5248. shift
  5249. argc=$#
  5250. case $# in
  5251. 0) set '' *
  5252. shift
  5253. case $1 in
  5254. '*') echo $command: $action: no licenses >&2
  5255. exit 1
  5256. ;;
  5257. esac
  5258. ;;
  5259. *) checkaout proto || exit
  5260. a=
  5261. for i
  5262. do while :
  5263. do if test -f ../$i.lic
  5264. then j=`proto -df -l ../$i.lic -o query=type /dev/null 2>/dev/null`
  5265. case $j in
  5266. ?*) if test -f $j
  5267. then case " $a " in
  5268. *" $j "*) ;;
  5269. *) a="$a $j" ;;
  5270. esac
  5271. fi
  5272. break
  5273. ;;
  5274. esac
  5275. fi
  5276. case $i in
  5277. *-*) i=`echo $i | sed 's/-[^-]*$//'`
  5278. ;;
  5279. *) echo "$command: $i: package license not found" >&2
  5280. break
  5281. ;;
  5282. esac
  5283. done
  5284. done
  5285. set '' $a
  5286. shift
  5287. ;;
  5288. esac
  5289. for i
  5290. do case $exec in
  5291. '') echo
  5292. echo " --- $i source license ---"
  5293. echo
  5294. cat $i
  5295. ;;
  5296. *) echo $PACKAGESRC/LICENSES/$i
  5297. ;;
  5298. esac
  5299. done
  5300. ;;
  5301. make|view)
  5302. cd $PACKAGEROOT
  5303. case $package in
  5304. '') lic="lib/package/*.lic"
  5305. ;;
  5306. *) for i in $package
  5307. do lic="$lic lib/package/$i.lic"
  5308. case $i in
  5309. *-*) lic="$lic lib/package/"`echo $i | sed 's,-.*,,'`".lic" ;;
  5310. esac
  5311. done
  5312. ;;
  5313. esac
  5314. checksrc
  5315. requirements source $package
  5316. components $package
  5317. package=$_components_
  5318. # check for some required commands
  5319. must="$AR"
  5320. warn="$NM yacc bison"
  5321. test="$must $warn"
  5322. have=
  5323. IFS=:
  5324. set /$IFS$PATH
  5325. IFS=$ifs
  5326. shift
  5327. for t in $test
  5328. do if executable $t
  5329. then have="$have $t"
  5330. fi
  5331. done
  5332. for d
  5333. do for t in $test
  5334. do case " $have " in
  5335. *" $t "*)
  5336. ;;
  5337. *) if executable $d/$t
  5338. then have="$have $t"
  5339. fi
  5340. ;;
  5341. esac
  5342. done
  5343. done
  5344. case " $have " in
  5345. *" bison "*) ;;
  5346. *" yacc "*) have="$have bison" ;;
  5347. esac
  5348. case " $have " in
  5349. *" yacc "*) ;;
  5350. *" bison "*) have="$have yacc" ;;
  5351. esac
  5352. for t in $test
  5353. do case " $have " in
  5354. *" $t "*)
  5355. ;;
  5356. *) case " $must " in
  5357. *" $t "*)
  5358. echo "$command: $t: not found -- must be on PATH to $action" >&2
  5359. exit 1
  5360. ;;
  5361. *) echo "$command: warning: $t: not found -- some $action actions may fail" >&2
  5362. ;;
  5363. esac
  5364. ;;
  5365. esac
  5366. done
  5367. # verify the top view
  5368. if test ! -d $PACKAGEROOT/src
  5369. then note no source packages to make
  5370. exit 0
  5371. elif test ! -d $INSTALLROOT/src
  5372. then note initialize the $INSTALLROOT view
  5373. fi
  5374. for i in arch arch/$HOSTTYPE
  5375. do test -d $PACKAGEROOT/$i || $exec mkdir $PACKAGEROOT/$i || exit
  5376. done
  5377. for i in bin bin/$OK bin/$OK/lib fun include lib lib/package lib/package/gen src man man/man1 man/man3 man/man8
  5378. do test -d $INSTALLROOT/$i || $exec mkdir $INSTALLROOT/$i || exit
  5379. done
  5380. make_recurse src
  5381. o= k=
  5382. for i in $makefiles
  5383. do case $o in
  5384. ?*) o="$o -o" k="$k|" ;;
  5385. esac
  5386. o="$o -name $i"
  5387. k="$k$i"
  5388. done
  5389. o="( $o ) -print"
  5390. for d in $package_src
  5391. do i=src/$d
  5392. if test -d $i
  5393. then test -d $INSTALLROOT/$i || $exec mkdir $INSTALLROOT/$i || exit
  5394. make_recurse $i
  5395. for j in `cd $i; find . $o 2>/dev/null | sed -e 's,^\./,,' -e '/\//!d' -e 's,/[^/]*$,,' | sort -u`
  5396. do case $j in
  5397. $k|$MAKESKIP) continue ;;
  5398. esac
  5399. test -d $INSTALLROOT/$i/$j ||
  5400. $exec mkdir -p $INSTALLROOT/$i/$j || exit
  5401. done
  5402. fi
  5403. done
  5404. def=
  5405. for i in $lic
  5406. do test -f $i || continue
  5407. cmp -s $i $INSTALLROOT/$i 2>/dev/null ||
  5408. $exec cp $PACKAGEROOT/$i $INSTALLROOT/$i
  5409. for j in `grep '^. .*\.def$' $i`
  5410. do case $j in
  5411. .) ;;
  5412. *) case " $def " in
  5413. *" $i "*) ;;
  5414. *) def="$def $i" ;;
  5415. esac
  5416. ;;
  5417. esac
  5418. done
  5419. done
  5420. for i in $def
  5421. do i=lib/package/$i
  5422. test -f $i || continue
  5423. cmp -s $i $INSTALLROOT/$i 2>/dev/null ||
  5424. $exec cp $PACKAGEROOT/$i $INSTALLROOT/$i
  5425. done
  5426. # check $CC and { ar cc ld ldd } intercepts
  5427. h="${HOSTTYPE} ${HOSTTYPE}.*"
  5428. case $HOSTTYPE in
  5429. *.*) t=`echo $HOSTTYPE | sed 's/[.][^.]*//'`
  5430. h="$h $t"
  5431. ;;
  5432. *) t=$HOSTTYPE
  5433. ;;
  5434. esac
  5435. case $t in
  5436. *[0123456789])
  5437. t=`echo $t | sed 's/[0123456789]*$//'`
  5438. h="$h $t"
  5439. ;;
  5440. esac
  5441. case $CC in
  5442. cc) c=cc
  5443. b=$INSTALLROOT/bin/$c
  5444. t=$INSTALLROOT/lib/package/gen/$c.tim
  5445. intercept=0
  5446. for k in $h
  5447. do for s in $INITROOT/$c.$k
  5448. do test -x "$s" || continue
  5449. if cmp -s "$s" "$b" >/dev/null 2>&1
  5450. then intercept=1
  5451. break 2
  5452. fi
  5453. case `ls -t "$t" "$b" "$s" 2>/dev/null` in
  5454. $t*) ;;
  5455. $b*) cc=$b
  5456. ;;
  5457. $s*) cd $INSTALLROOT/lib/package/gen
  5458. tmp=pkg$$
  5459. eval '$'exec echo "'int main(){return 0;}' > $tmp.c"
  5460. if $exec $s -o $tmp.exe $tmp.c >/dev/null 2>&1 &&
  5461. test -x $tmp.exe
  5462. then case $HOSTTYPE in
  5463. *.mips*)$s -version >/dev/null 2>&1 || s= ;;
  5464. esac
  5465. case $s in
  5466. ?*) $exec sed "s/^HOSTTYPE=.*/HOSTTYPE=$HOSTTYPE/" < "$s" > "$b" || exit
  5467. $exec chmod +x "$b" || exit
  5468. cc=$b
  5469. intercept=1
  5470. note update $b
  5471. ;;
  5472. esac
  5473. fi
  5474. $exec rm -f $tmp.*
  5475. $exec touch "$t"
  5476. cd $PACKAGEROOT
  5477. ;;
  5478. esac
  5479. break 2
  5480. done
  5481. done
  5482. case $intercept in
  5483. 1) c=ld
  5484. b=$INSTALLROOT/bin/$c
  5485. for k in $h
  5486. do for s in $INITROOT/$c.$k
  5487. do test -x "$s" || continue
  5488. case `ls -t "$b" "$s" 2>/dev/null` in
  5489. $b*) ;;
  5490. $s*) $exec cp "$s" "$b"
  5491. note update $b
  5492. ;;
  5493. esac
  5494. done
  5495. done
  5496. ;;
  5497. esac
  5498. ;;
  5499. esac
  5500. c=ldd
  5501. b=$INSTALLROOT/bin/$c
  5502. for t in $h
  5503. do s=$INITROOT/$c.$t
  5504. test -x "$s" || continue
  5505. onpath $c ||
  5506. case `ls -t "$b" "$s" 2>/dev/null` in
  5507. $b*) ;;
  5508. $s*) $exec cp "$s" "$b"
  5509. note update $b
  5510. ;;
  5511. esac
  5512. done
  5513. c=ar
  5514. b=$INSTALLROOT/bin/$c
  5515. for t in $h
  5516. do s=$INITROOT/$c.$t
  5517. test -x "$s" || continue
  5518. case `ls -t "$b" "$s" 2>/dev/null` in
  5519. $b*) ;;
  5520. $s*) $exec cp "$s" "$b"
  5521. note update $b
  5522. ;;
  5523. esac
  5524. done
  5525. # following code stubbed out just in case ar.ibm.risc is needed
  5526. # c=ar
  5527. # b=$INSTALLROOT/bin/$c
  5528. # for t in $h
  5529. # do s=$INITROOT/$c.$t
  5530. # test -x "$s" || continue
  5531. # onpath $c ||
  5532. # case `ls -t "$b" "$s" 2>/dev/null` in
  5533. # $b*) ;;
  5534. # $s*) x=`$s -tv /foo/bar.a 2>&1 | egrep -i 'option|usage'`
  5535. # case $x in
  5536. # '') $exec cp "$s" "$b"
  5537. # note update $b
  5538. # ;;
  5539. # esac
  5540. # ;;
  5541. # esac
  5542. # done
  5543. case $cc in
  5544. /*) ;;
  5545. *) echo "$command: $CC: not found -- set CC=C-compiler" >&2
  5546. exit 1
  5547. ;;
  5548. esac
  5549. case $exec in
  5550. '') cd $INSTALLROOT/lib/package/gen
  5551. tmp=pkg$$
  5552. echo 'int main(){return 0;}' > $tmp.c
  5553. if $CC -o $tmp.exe $tmp.c > /dev/null 2> $tmp.err &&
  5554. test -x $tmp.exe
  5555. then : ok
  5556. else echo "$command: $CC: failed to compile this program:" >&2
  5557. cat $tmp.c >&2
  5558. if test -s $tmp.err
  5559. then cat $tmp.err >&2
  5560. else echo "$command: $CC: not a C compiler" >&2
  5561. fi
  5562. rm -f $tmp.*
  5563. exit 1
  5564. fi
  5565. rm -f $tmp.*
  5566. cd $PACKAGEROOT
  5567. ;;
  5568. esac
  5569. # remember the default $CC
  5570. case $CC in
  5571. cc) ;;
  5572. *) if test -x $INSTALLROOT/bin/cc
  5573. then case `sed 1q $INSTALLROOT/bin/cc` in
  5574. ": $CC :")
  5575. CC=cc
  5576. export CC
  5577. ;;
  5578. *) assign="$assign CC=\"\$CC\""
  5579. ;;
  5580. esac
  5581. else case $CROSS in
  5582. 1) assign="$assign CC=\"\$CC\""
  5583. ;;
  5584. *) case $exec in
  5585. '') {
  5586. echo ": $CC :"
  5587. echo "$CC \"\$@\""
  5588. } > $INSTALLROOT/bin/cc
  5589. chmod +x $INSTALLROOT/bin/cc
  5590. ;;
  5591. *) note generate a $INSTALLROOT/bin/cc wrapper for $CC
  5592. ;;
  5593. esac
  5594. CC=cc
  5595. export CC
  5596. ;;
  5597. esac
  5598. fi
  5599. ;;
  5600. esac
  5601. # no $INITROOT means INIT already installed elsewhere
  5602. if test -d $INITROOT
  5603. then
  5604. # update probe scripts
  5605. for i in lib/probe lib/probe/C lib/probe/C/make
  5606. do test -d $INSTALLROOT/$i || $exec mkdir $INSTALLROOT/$i || exit
  5607. done
  5608. i=$INSTALLROOT/lib/probe/C/make/probe
  5609. j=$INITROOT/C+probe
  5610. k=$INITROOT/make.probe
  5611. case `ls -t $i $j $k 2>/dev/null` in
  5612. $i*) ;;
  5613. *) if test -f $j -a -f $k
  5614. then note update $i
  5615. shellmagic
  5616. case $exec in
  5617. '') {
  5618. case $SHELLMAGIC in
  5619. ?*) echo "$SHELLMAGIC" ;;
  5620. esac
  5621. cat $j $k
  5622. } > $i || exit
  5623. ;;
  5624. *) echo "{
  5625. echo $SHELLMAGIC
  5626. cat $j $k
  5627. } > $i"
  5628. ;;
  5629. esac
  5630. $exec chmod +x $i || exit
  5631. fi
  5632. ;;
  5633. esac
  5634. fi
  5635. # initialize a few mamake related commands
  5636. checkaout mamake proto ratz release || exit
  5637. # execrate if necessary
  5638. if (execrate) >/dev/null 2>&1
  5639. then execrate=execrate
  5640. $make cd $INSTALLROOT/bin
  5641. for i in chmod chgrp cmp cp ln mv rm
  5642. do if test ! -x $OK/$i -a -x /bin/$i.exe
  5643. then shellmagic
  5644. case $exec in
  5645. '') echo "$SHELLMAGIC"'execrate /bin/'$i' "$@"' > $OK/$i
  5646. chmod +x $OK/$i
  5647. ;;
  5648. *) $exec echo \'"$SHELLMAGIC"'execrate /bin/'$i' "$@"'\'' >' $OK/$i
  5649. $exec chmod +x $OK/$i
  5650. ;;
  5651. esac
  5652. fi
  5653. done
  5654. PATH=$INSTALLROOT/bin/$OK:$PATH
  5655. export PATH
  5656. else execrate=
  5657. fi
  5658. case $action in
  5659. view) exit 0 ;;
  5660. esac
  5661. # all work under $INSTALLROOT/src
  5662. $make cd $INSTALLROOT/src
  5663. # record the build host name
  5664. case $noexec in
  5665. '') hostinfo name
  5666. echo "$_hostinfo_" | sed 's,\..*,,' > $PACKAGEBIN/gen/host
  5667. ;;
  5668. esac
  5669. # make in parallel if possible
  5670. case $NPROC in
  5671. '') hostinfo cpu
  5672. case $_hostinfo_ in
  5673. 0|1) ;;
  5674. *) NPROC=$_hostinfo_
  5675. $show NPROC=$NPROC
  5676. $show export NPROC
  5677. export NPROC
  5678. ;;
  5679. esac
  5680. ;;
  5681. esac
  5682. # separate flags from target list
  5683. case $target in
  5684. *-*) a=
  5685. for t in $target
  5686. do case $t in
  5687. -[eiknFKNV]*|--*-symbols)
  5688. makeflags="$makeflags $t"
  5689. ;;
  5690. -*) nmakeflags="$nmakeflags $t"
  5691. ;;
  5692. *) a="$a $t"
  5693. ;;
  5694. esac
  5695. done
  5696. target=$a
  5697. ;;
  5698. esac
  5699. # generate nmake first if possible
  5700. if executable ! $NMAKE && test -d $PACKAGEROOT/src/cmd/nmake
  5701. then if nonmake $MAKE
  5702. then note make $NMAKE with mamake
  5703. c=$CC
  5704. a=$assign
  5705. case $HOSTTYPE in
  5706. win32*|cygwin*)
  5707. CC="$CC -D_BLD_STATIC"
  5708. accept="libast"
  5709. case $assign in
  5710. *' CC='*) ;;
  5711. *) assign="$assign CC=\"\$CC\"" ;;
  5712. esac
  5713. ;;
  5714. *) accept=nmake
  5715. ;;
  5716. esac
  5717. eval capture mamake \$makeflags \$nmakeflags \$noexec install nmake $assign
  5718. assign=$a
  5719. CC=$c
  5720. case $make$noexec in
  5721. '') if executable ! $NMAKE
  5722. then echo "$command: $action: errors making $NMAKE" >&2
  5723. exit 1
  5724. fi
  5725. ;;
  5726. *) make=echo
  5727. ;;
  5728. esac
  5729. if test '' != "$PROTOROOT"
  5730. then VPATH=$INSTALLROOT:$PACKAGEROOT$USER_VPATH
  5731. $show VPATH=$VPATH
  5732. export VPATH
  5733. fi
  5734. note believe generated files for $accept
  5735. eval capture \$NMAKE \$makeflags \$nmakeflags \$noexec recurse believe \$nmakesep $accept $assign
  5736. $exec touch $INSTALLROOT/bin/.paths
  5737. note make the remaining targets with $NMAKE
  5738. else eval capture $MAKE \$makeflags \$nmakeflags \$noexec install nmake $assign
  5739. case $make$noexec in
  5740. '') if executable ! $NMAKE
  5741. then echo "$command: $action: errors making $NMAKE" >&2
  5742. exit 1
  5743. fi
  5744. ;;
  5745. *) make=echo
  5746. ;;
  5747. esac
  5748. fi
  5749. fi
  5750. # generate ksh next if possible
  5751. if nonmake $MAKE
  5752. then : no need to generate ksh next -- it could be the only package
  5753. elif test "$KEEP_SHELL" != 1 -a -d $PACKAGEROOT/src/cmd/ksh93 && executable ! $KSH
  5754. then eval capture nmake $nmakeflags \$makeflags \$noexec install ksh93 $assign
  5755. case $make$noexec in
  5756. '') if executable ! $KSH
  5757. then echo "$command: $action: errors making $KSH" >&2
  5758. exit 1
  5759. fi
  5760. ;;
  5761. *) make=echo
  5762. ;;
  5763. esac
  5764. fi
  5765. # mamprobe data should have been generated by this point
  5766. case $exec in
  5767. '') if test ! -f $INSTALLROOT/bin/.paths -o -w $INSTALLROOT/bin/.paths
  5768. then N='
  5769. '
  5770. b= f= h= n= p= u= B= L=
  5771. if test -f $INSTALLROOT/bin/.paths
  5772. then exec < $INSTALLROOT/bin/.paths
  5773. while read x
  5774. do case $x in
  5775. '#'?*) case $h in
  5776. '') h=$x ;;
  5777. esac
  5778. ;;
  5779. *BUILTIN_LIB=*) b=$x
  5780. ;;
  5781. *FPATH=*) f=$x
  5782. ;;
  5783. *PLUGIN_LIB=*) p=$x
  5784. ;;
  5785. *) case $u in
  5786. ?*) u=$u$N ;;
  5787. esac
  5788. u=$u$x
  5789. ;;
  5790. esac
  5791. done
  5792. fi
  5793. ifs=$IFS
  5794. m=
  5795. case $p in
  5796. ?*) b=
  5797. ;;
  5798. esac
  5799. case $b in
  5800. ?*) IFS='='
  5801. set $b
  5802. IFS=$ifs
  5803. shift
  5804. p="PLUGIN_LIB=$*"
  5805. case $b in
  5806. [Nn][Oo]*) p=no$p ;;
  5807. esac
  5808. m=1
  5809. ;;
  5810. esac
  5811. case $f in
  5812. '') f="FPATH=../fun"
  5813. m=1
  5814. ;;
  5815. esac
  5816. case $h in
  5817. '') h='# use { no NO } prefix to permanently disable #' ;;
  5818. esac
  5819. case $p in
  5820. '') p="PLUGIN_LIB=cmd"
  5821. if grep '^setv mam_cc_DIALECT .* EXPORT=[AD]LL' $INSTALLROOT/lib/probe/C/mam/* >/dev/null 2>&1
  5822. then p=no$p
  5823. fi
  5824. m=1
  5825. ;;
  5826. esac
  5827. case $m in
  5828. 1) case $u in
  5829. ?*) u=$N$u ;;
  5830. esac
  5831. echo "$h$N$p$N$f$N$u" > $INSTALLROOT/bin/.paths
  5832. ;;
  5833. esac
  5834. fi
  5835. ;;
  5836. esac
  5837. # run from separate copies since nmake and ksh may be rebuilt
  5838. case $EXECROOT in
  5839. $INSTALLROOT)
  5840. $make cd $INSTALLROOT/bin
  5841. if executable /bin/cp
  5842. then cp=/bin/cp
  5843. else cp=cp
  5844. fi
  5845. if executable /bin/mv
  5846. then mv=/bin/mv
  5847. else mv=mv
  5848. fi
  5849. if executable /bin/rm
  5850. then rm=/bin/rm
  5851. else rm=rm
  5852. fi
  5853. for i in \
  5854. ksh nmake tee cp ln mv rm \
  5855. *ast*.dll *cmd*.dll *dll*.dll *shell*.dll
  5856. do executable $i && {
  5857. cmp -s $i $OK/$i 2>/dev/null || {
  5858. test -f $OK/$i &&
  5859. $exec $execrate $rm $OK/$i </dev/null
  5860. test -f $OK/$i &&
  5861. $exec $execrate $mv $OK/$i $OK/$i.old </dev/null
  5862. test -f $OK/$i &&
  5863. case $exec:$i in
  5864. :nmake|:ksh)
  5865. echo "$command: $OK/$i: cannot update [may be in use by a running process] remove manually and try again" >&2
  5866. exit 1
  5867. ;;
  5868. esac
  5869. $exec $execrate $cp $i $OK/$i
  5870. }
  5871. }
  5872. done
  5873. if test -f ../lib/make/makerules.mo
  5874. then cmp -s ../lib/make/makerules.mo $OK/lib/makerules.mo ||
  5875. $exec $execrate $cp -p ../lib/make/makerules.mo $OK/lib/makerules.mo ||
  5876. $exec $execrate $cp ../lib/make/makerules.mo $OK/lib/makerules.mo
  5877. fi
  5878. if executable $OK/nmake
  5879. then MAKE="$INSTALLROOT/bin/$OK/nmake LOCALRULESPATH=$INSTALLROOT/bin/$OK/lib"
  5880. fi
  5881. if executable $OK/tee
  5882. then TEE=$INSTALLROOT/bin/$OK/tee
  5883. fi
  5884. if test "$KEEP_SHELL" != 1 && executable $OK/ksh
  5885. then SHELL=$INSTALLROOT/bin/$OK/ksh
  5886. export SHELL
  5887. fi
  5888. case :$PATH: in
  5889. *:$INSTALLROOT/bin/$OK:*)
  5890. ;;
  5891. *) PATH=$INSTALLROOT/bin/$OK:$PATH
  5892. export PATH
  5893. ;;
  5894. esac
  5895. $make cd $INSTALLROOT/src
  5896. ;;
  5897. esac
  5898. # fall back to mamake if nmake not found or too old
  5899. if nonmake $MAKE
  5900. then note make with mamake
  5901. case $target in
  5902. '') target="install" ;;
  5903. esac
  5904. eval capture mamake \$makeflags \$noexec \$target $assign
  5905. else case $target in
  5906. '') target="install cc-" ;;
  5907. esac
  5908. eval capture \$MAKE \$makeflags \$nmakeflags \$noexec recurse \$target \$nmakesep \$package $assign
  5909. fi
  5910. ;;
  5911. read) case ${PWD:-`pwd`} in
  5912. $PACKAGEROOT)
  5913. ;;
  5914. *) echo "$command: must be in package root directory" >&2
  5915. exit 1
  5916. ;;
  5917. esac
  5918. PAX=
  5919. if onpath pax
  5920. then case `$_onpath_ -rw --?meter 2>&1` in
  5921. *--meter*) PAX=pax ;;
  5922. esac
  5923. fi
  5924. code=0
  5925. i=
  5926. x=
  5927. remove=
  5928. touch=
  5929. set '' $target
  5930. case $2 in
  5931. lcl|tgz)tgz=$2
  5932. shift 2
  5933. target=$*
  5934. ;;
  5935. *) tgz=tgz
  5936. ;;
  5937. esac
  5938. set '' $package $target
  5939. case $# in
  5940. 1) verbose=:
  5941. set '' `ls lib/package/$tgz/*?[_.][0123456789][0123456789][0123456789][0123456789]-[0123456789][0123456789]-[0123456789][0123456789][_.]* 2>/dev/null`
  5942. ;;
  5943. *) verbose=
  5944. ;;
  5945. esac
  5946. shift
  5947. files=
  5948. for f
  5949. do if test -f "$f"
  5950. then : ok
  5951. elif test -f "lib/package/$tgz/$f"
  5952. then f=lib/package/$tgz/$f
  5953. else set '' `ls -r ${f}[_.][0123456789][0123456789][0123456789][0123456789]-[0123456789][0123456789]-[0123456789][0123456789][_.]* 2>/dev/null`
  5954. if test '' != "$2" -a -f "$2"
  5955. then f=$2
  5956. else set '' `ls -r lib/package/$tgz/${f}[_.][0123456789][0123456789][0123456789][0123456789]-[0123456789][0123456789]-[0123456789][0123456789][_.]* 2>/dev/null`
  5957. if test '' != "$2" -a -f "$2"
  5958. then f=$2
  5959. else echo "$command: $f: package archive not found" >&2
  5960. continue
  5961. fi
  5962. fi
  5963. fi
  5964. files="$files $f"
  5965. done
  5966. case $files in
  5967. '') echo "$command: lib/package/$tgz: no package archives" >&2
  5968. exit 1
  5969. ;;
  5970. esac
  5971. set '' `ls -r $files 2>/dev/null`
  5972. shift
  5973. f1= f2= f3= f4=
  5974. for f
  5975. do case $f in
  5976. ratz.*|*/ratz.*)
  5977. f1="$f1 $f"
  5978. ;;
  5979. INIT.*|*/INIT.*)
  5980. f2="$f2 $f"
  5981. ;;
  5982. INIT*|*/INIT*)
  5983. f3="$f3 $f"
  5984. ;;
  5985. *) f4="$f4 $f"
  5986. ;;
  5987. esac
  5988. done
  5989. gen=
  5990. set '' $f1 $f2 $f3 $f4
  5991. while :
  5992. do shift
  5993. case $# in
  5994. 0) break ;;
  5995. esac
  5996. f=$1
  5997. case $f in
  5998. *.gz) : standalone packages unbundled manually
  5999. continue
  6000. ;;
  6001. *.md5) : tarball checksum
  6002. continue
  6003. ;;
  6004. *?[_.][0123456789][0123456789][0123456789][0123456789]-[0123456789][0123456789]-[0123456789][0123456789][_.]*)
  6005. ;;
  6006. *) echo "$command: $f: not a package archive" >&2
  6007. code=1
  6008. continue
  6009. ;;
  6010. esac
  6011. case $f in
  6012. */*) eval `echo "$f" | sed -e 's,\(.*/\)\(.*\),d=\1 a=\2,'` ;;
  6013. *) d= a=$f ;;
  6014. esac
  6015. # f:file d:dir a:base p:package v:version r:release t:type
  6016. eval `echo "$a" | sed -e 's,\.c$,,' -e 's,\.gz$,,' -e 's,\.exe$,,' -e 's,\.tgz$,,' -e 's,\([^_.]*\)[_.]\([0123456789][0123456789][0123456789][0123456789]-[0123456789][0123456789]-[0123456789][0123456789]\)[_.]\([0123456789][0123456789][0123456789][0123456789][^_.]*\)[_.]*\(.*\),p=\1 v=\2 r=\3 t=\4,' -e 's,\([^_.]*\)[_.]\([0123456789][0123456789][0123456789][0123456789]-[0123456789][0123456789]-[0123456789][0123456789]\)[_.]*\(.*\),p=\1 v=\2 r=base t=\3,'`
  6017. case $r in
  6018. base) y=$p.base ;;
  6019. *) y=$p.delta ;;
  6020. esac
  6021. case " $x " in
  6022. *" $y "*)
  6023. continue
  6024. ;;
  6025. esac
  6026. case $t in
  6027. '') w=$PACKAGESRC
  6028. q=
  6029. Q=
  6030. m=
  6031. ;;
  6032. *) w=$PACKAGEROOT/arch/$t/lib/package
  6033. q=".$t"
  6034. Q="_$t"
  6035. m="[_.]$t"
  6036. ;;
  6037. esac
  6038. u=$d$p$q.tim
  6039. if test -s "$u"
  6040. then continue
  6041. else case $force in
  6042. 0) case `ls -t "$f" "$u" 2>/dev/null` in
  6043. "$u"*) case $verbose in
  6044. 1) note $p already read ;;
  6045. esac
  6046. continue
  6047. ;;
  6048. esac
  6049. ;;
  6050. esac
  6051. fi
  6052. case $p in
  6053. INIT) if test -f $PACKAGEROOT/bin/package
  6054. then $exec mv $PACKAGEROOT/bin/package $PACKAGEROOT/bin/package.old
  6055. fi
  6056. ;;
  6057. esac
  6058. z=
  6059. case $r in
  6060. base) # base archive
  6061. if test ratz = "$p"
  6062. then # ratz packages are not archives
  6063. case $t in
  6064. '') for i in src src/cmd src/cmd/INIT
  6065. do test -d $PACKAGEROOT/$i || $exec mkdir $PACKAGEROOT/$i || exit
  6066. done
  6067. $exec cp $f $PACKAGEROOT/src/cmd/INIT/$p.c
  6068. ;;
  6069. *) for i in arch arch/$t arch/$t/bin
  6070. do test -d $PACKAGEROOT/$i || $exec mkdir $PACKAGEROOT/$i || exit
  6071. done
  6072. $exec cp $f $PACKAGEROOT/arch/$t/bin/$p &&
  6073. $exec chmod +x $PACKAGEROOT/arch/$t/bin/$p
  6074. ;;
  6075. esac
  6076. elif test "" != "$PAX"
  6077. then $exec pax -L --from=ascii --local -m -ps -rvf "$f" || {
  6078. code=1
  6079. continue
  6080. }
  6081. else if onpath gunzip && onpath $TAR && isascii
  6082. then case $TARPROBE in
  6083. ?*) for i in $TARPROBE
  6084. do if $TAR ${i}f - /dev/null > /dev/null 2>&1
  6085. then TARFLAGS=$TARFLAGS$i
  6086. fi
  6087. done
  6088. TARPROBE=
  6089. ;;
  6090. esac
  6091. if gunzip -l < "$f" > /dev/null 2>&1
  6092. then case $exec in
  6093. '') $exec gunzip < "$f" | $TAR ${TARFLAGS}f - ;;
  6094. *) $exec "gunzip < $f | $TAR ${TARFLAGS}f -" ;;
  6095. esac || {
  6096. code=1
  6097. continue
  6098. }
  6099. else $exec $TAR ${TARFLAGS}f "$f" || {
  6100. code=1
  6101. continue
  6102. }
  6103. fi
  6104. else checkaout ratz && onpath ratz || {
  6105. code=1
  6106. continue
  6107. }
  6108. RATZ=$_onpath_
  6109. case $exec in
  6110. '') echo $f:
  6111. $exec $RATZ -lm < "$f"
  6112. ;;
  6113. *) $exec "$RATZ -lm < $f"
  6114. ;;
  6115. esac || {
  6116. code=1
  6117. continue
  6118. }
  6119. fi
  6120. if test -f $PACKAGEBIN/gen/$p.sum
  6121. then while read md5 mode usr grp file
  6122. do case $file in
  6123. -*) file=./$file ;;
  6124. esac
  6125. case $mode in
  6126. [01234567][01234567][01234567][01234567])
  6127. case $grp in
  6128. -) ;;
  6129. *) $exec chgrp $grp "$file" ;;
  6130. esac
  6131. case $usr in
  6132. -) ;;
  6133. *) $exec chown $usr "$file" ;;
  6134. esac
  6135. $exec chmod $mode "$file"
  6136. ;;
  6137. esac
  6138. done < $PACKAGEBIN/gen/$p.sum
  6139. fi
  6140. fi
  6141. ;;
  6142. *) # delta archive
  6143. test "" != "$PAX" || {
  6144. echo "$command: $f: pax required to read delta archive" >&2
  6145. code=1
  6146. continue
  6147. }
  6148. case `echo "$v:
  6149. $r:" | sort` in
  6150. $r:*) y=$p.base
  6151. b=${d}${p}_${r}${Q}.tgz
  6152. test -f "$b" || b=${d}${p}.${r}${q}.tgz
  6153. test -f "$b" || {
  6154. case " $gen " in
  6155. *" $b "*)
  6156. ;;
  6157. *) case $# in
  6158. 1) echo "$command: $f: base archive $b required to read delta" >&2
  6159. code=1
  6160. ;;
  6161. *) shift
  6162. y=$1
  6163. shift
  6164. set '' $y $f "$@"
  6165. esac
  6166. continue
  6167. ;;
  6168. esac
  6169. }
  6170. # -m with delta bug fixed 2005-02-08
  6171. $exec pax -L --from=ascii --local -ps -rvf "$f" -z "$b" || {
  6172. code=1
  6173. continue
  6174. }
  6175. note $f: generate new base $d$p.$v$q.tgz
  6176. $exec pax -rf "$f" -z "$b" -wf $d$p.$v$q.tgz -x tgz || {
  6177. code=1
  6178. continue
  6179. }
  6180. case $exec in
  6181. '') echo $p $v $v 1 > $w/gen/$p.ver
  6182. ;;
  6183. *) z=$d${p}[_.]$v$q.tgz
  6184. $exec "echo $p $v $v 1 > $w/gen/$p.ver"
  6185. gen="$gen $d$p.$v$q.tgz"
  6186. ;;
  6187. esac
  6188. case " $remove " in
  6189. *" $f "*) ;;
  6190. *) remove="$remove $f" ;;
  6191. esac
  6192. ;;
  6193. *) b=${d}${p}_${v}${Q}.tgz
  6194. test -f "$b" || b=${d}${p}.${v}${q}.tgz
  6195. test -f "$b" || {
  6196. case " $gen " in
  6197. *" $b "*)
  6198. ;;
  6199. *) case $# in
  6200. 1) echo "$command: $f: base archive $b required to read delta" >&2
  6201. code=1
  6202. ;;
  6203. *) shift
  6204. y=$1
  6205. shift
  6206. set '' $y $f "$@"
  6207. esac
  6208. continue
  6209. ;;
  6210. esac
  6211. }
  6212. # -m with delta bug fixed 2005-02-08
  6213. $exec pax -L --from=ascii --local -ps -rvf "$f" -z "$b" || {
  6214. code=1
  6215. continue
  6216. }
  6217. ;;
  6218. esac
  6219. ;;
  6220. *) echo "$command: $f: unknown archive type" >&2
  6221. code=1
  6222. continue
  6223. ;;
  6224. esac
  6225. # check for ini files
  6226. if executable $w/$p.ini
  6227. then $exec $w/$p.ini read || {
  6228. code=1
  6229. continue
  6230. }
  6231. fi
  6232. # add to the obsolete list
  6233. k=
  6234. for i in `ls $d$p[_.][0123456789][0123456789][0123456789][0123456789]-[0123456789][0123456789]-[0123456789][0123456789][_.]????$m* $z 2>/dev/null`
  6235. do case $i in
  6236. *.md5) continue
  6237. ;;
  6238. $d${p}[_.][0123456789][0123456789][0123456789][0123456789]-[0123456789][0123456789]-[0123456789][0123456789][_.][0123456789][0123456789][0123456789][0123456789]-[0123456789][0123456789]-[0123456789][0123456789]$m*)
  6239. ;;
  6240. $d${p}[_.][0123456789][0123456789][0123456789][0123456789]-[0123456789][0123456789]-[0123456789][0123456789]$m*)
  6241. continue
  6242. ;;
  6243. esac
  6244. case $k in
  6245. ?*) case " $remove " in
  6246. *" $k "*) ;;
  6247. *) remove="$remove $k" ;;
  6248. esac
  6249. ;;
  6250. esac
  6251. k=$i
  6252. done
  6253. x="$x $y"
  6254. case " $touch " in
  6255. *" $u "*) ;;
  6256. *) touch="$touch $u" ;;
  6257. esac
  6258. done
  6259. if test ! -f $PACKAGEROOT/bin/package -a -f $PACKAGEROOT/bin/package.old
  6260. then $exec cp $PACKAGEROOT/bin/package.old $PACKAGEROOT/bin/package
  6261. fi
  6262. # drop obsolete archives
  6263. case $remove in
  6264. ?*) $exec rm -f $remove ;;
  6265. esac
  6266. # mark the updated archives
  6267. case $touch in
  6268. ?*) sleep 1; $exec touch $touch ;;
  6269. esac
  6270. # check the requirements
  6271. case $code$exec in
  6272. 0) requirements - $x ;;
  6273. esac
  6274. exit $code
  6275. ;;
  6276. regress)if test ! -d $PACKAGEBIN/gen
  6277. then echo "$command: 'package make' and 'package test' required for regression" >&2
  6278. exit 1
  6279. fi
  6280. dir=$PACKAGEBIN/gen
  6281. cd $dir
  6282. for s in out old
  6283. do case `ls -t regress.$s test.$s 2>/dev/null` in
  6284. regress*)
  6285. ;;
  6286. test*) if test -f regress.$s
  6287. then $exec mv regress.$s regress.old
  6288. fi
  6289. case $exec in
  6290. '') egrep -i '\*\*\*|FAIL|^TEST.* [123456789][0123456789]* error|core.*dump' test.$s |
  6291. sed -e '/\*\*\* [0123456789]/d' \
  6292. -e '/^TEST.\//s,/[^ ]*/,,' \
  6293. -e 's,[ ][ ]*$,,' \
  6294. -e 's/[0123456789][0123456789]*:* \([abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789 ]*([abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789 ]*[Cc][Oo][Rr][Ee][abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789 ]*)\)/\1/' \
  6295. -e 's/\.sh failed at .* with /.sh failed /' \
  6296. > regress.$s
  6297. ;;
  6298. *) $exec filter test failures from $dir/test.$s to $dir/regress.$s
  6299. ;;
  6300. esac
  6301. ;;
  6302. esac
  6303. done
  6304. if test -f regress.out -a -f regress.old
  6305. then $exec diff -b regress.out regress.old
  6306. else echo "$command: at least 2 test runs required for regression" >&2
  6307. exit 1
  6308. fi
  6309. ;;
  6310. release)count= lo= hi=
  6311. checksrc
  6312. checkaout release || exit
  6313. requirements source $package
  6314. components $package
  6315. package=$_components_
  6316. set '' $target
  6317. shift
  6318. case $# in
  6319. 0) ;;
  6320. *) case $1 in
  6321. -|[0123456789][0123456789]-[0123456789][0123456789]-[0123456789][0123456789]|[0123456789][0123456789][0123456789][0123456789]-[0123456789][0123456789]-[0123456789][0123456789])
  6322. case $1 in
  6323. -) lo= release= ;;
  6324. *) lo=$1 release="-f $1" ;;
  6325. esac
  6326. shift
  6327. case $1 in
  6328. -|[0123456789][0123456789]-[0123456789][0123456789]-[0123456789][0123456789]|[0123456789][0123456789][0123456789][0123456789]-[0123456789][0123456789]-[0123456789][0123456789])
  6329. case $1 in
  6330. -) hi= ;;
  6331. *) hi=$1 release="$release -t $1" ;;
  6332. esac
  6333. shift
  6334. ;;
  6335. esac
  6336. ;;
  6337. [0123456789]|[0123456789][0123456789]|[0123456789][0123456789][0123456789]|[0123456789][0123456789][0123456789][0123456789]|[0123456789][0123456789][0123456789][0123456789][0123456789]*)
  6338. count=$1
  6339. release="-r $count"
  6340. shift
  6341. ;;
  6342. esac
  6343. ;;
  6344. esac
  6345. case $# in
  6346. 0) case $package in
  6347. '') package=* ;;
  6348. esac
  6349. ;;
  6350. *) case $package in
  6351. '') package=$*
  6352. ;;
  6353. *) echo $command: $*: lo-date hi-date arguments expected >&2
  6354. exit 1
  6355. ;;
  6356. esac
  6357. ;;
  6358. esac
  6359. echo
  6360. case $count:$lo:$hi in
  6361. ::) echo "All recorded changes follow." ;;
  6362. 1::) echo "Changes since the last release follow." ;;
  6363. ?*::) echo "Changes since the last $count releases follow." ;;
  6364. 1:?*:) echo "Changes since $lo or the last release follow." ;;
  6365. *:?*:*) echo "Changes since $lo follow." ;;
  6366. *::?*) echo "Changes before $hi follow." ;;
  6367. *) echo "Changes between $lo and $hi follow." ;;
  6368. esac
  6369. x=
  6370. for r in $INSTALLROOT $PACKAGEROOT
  6371. do for s in $package_src
  6372. do d=$r/src/$s
  6373. if test -d $d
  6374. then cd $d
  6375. for i in $package
  6376. do if test -h $i 2>/dev/null
  6377. then continue
  6378. fi
  6379. case " $x " in
  6380. *" $i "*) continue ;;
  6381. esac
  6382. for f in RELEASE CHANGES ChangeLog
  6383. do if test -f $i/$f
  6384. then $exec release $release $i/$f
  6385. x="$x $i"
  6386. for f in $i/*/$f
  6387. do if test -f $f
  6388. then $exec release $release $f
  6389. fi
  6390. done
  6391. break
  6392. fi
  6393. done
  6394. done
  6395. fi
  6396. done
  6397. done
  6398. ;;
  6399. remove) echo "$command: $action: not implemented yet" >&2
  6400. exit 1
  6401. ;;
  6402. results)set '' $target
  6403. shift
  6404. def=make
  6405. dir=$PACKAGEBIN/gen
  6406. case $verbose in
  6407. 0) filter=yes ;;
  6408. *) filter=cat ;;
  6409. esac
  6410. path=0
  6411. suf=out
  6412. on=
  6413. while :
  6414. do case $# in
  6415. 0) break ;;
  6416. esac
  6417. case $1 in
  6418. --) shift
  6419. break
  6420. ;;
  6421. admin) dir=$PACKAGESRC/admin
  6422. ;;
  6423. error*|fail*)
  6424. filter=errors
  6425. ;;
  6426. make|test|view|write)
  6427. def=$1
  6428. case $filter:$1:$SHELL in
  6429. errors:*:*) ;;
  6430. *:test:*/ksh*) filter=rt ;;
  6431. esac
  6432. ;;
  6433. old) suf=old
  6434. ;;
  6435. on) case $# in
  6436. 1) echo $command: $action: $1: host pattern argument expected >&2
  6437. exit 1
  6438. ;;
  6439. esac
  6440. shift
  6441. case $on in
  6442. ?*) on="$on|" ;;
  6443. esac
  6444. on="$on$1"
  6445. ;;
  6446. path) path=1
  6447. ;;
  6448. test) def=test
  6449. filter=rt
  6450. ;;
  6451. *) break
  6452. ;;
  6453. esac
  6454. shift
  6455. done
  6456. case $dir in
  6457. */admin)case $on in
  6458. '') on="*" ;;
  6459. *) on="@($on)" ;;
  6460. esac
  6461. def=$def.log/$on
  6462. ;;
  6463. esac
  6464. case $# in
  6465. 0) set "$def" ;;
  6466. esac
  6467. m=
  6468. t=
  6469. for i
  6470. do k=0
  6471. eval set '""' $i - $i.$suf - $dir/$i - $dir/$i.$suf -
  6472. shift
  6473. for j
  6474. do case $j in
  6475. -) case $k in
  6476. 1) continue 2 ;;
  6477. esac
  6478. ;;
  6479. *) if test -f $j
  6480. then k=1
  6481. case /$j in
  6482. */test.*) t="$t $j" ;;
  6483. *) m="$m $j" ;;
  6484. esac
  6485. fi
  6486. ;;
  6487. esac
  6488. done
  6489. echo "$command: $i action output not found" >&2
  6490. exit 1
  6491. done
  6492. sep=
  6493. case $t in
  6494. ?*) case $path in
  6495. 0) for j in $t
  6496. do echo "$sep==> $j <=="
  6497. sep=$nl
  6498. case $filter in
  6499. cat) $exec cat $j
  6500. ;;
  6501. errors) $exec egrep -i '\*\*\*|FAIL[ES]|^TEST.* [123456789][0123456789]* error|core.*dump' $j | sed -e '/^TEST.\//s,/[^ ]*/,,'
  6502. ;;
  6503. rt) $exec $KSH rt - $j
  6504. ;;
  6505. *) $exec egrep -i '^TEST|FAIL' $j
  6506. ;;
  6507. esac
  6508. done
  6509. ;;
  6510. 1) echo $t
  6511. ;;
  6512. esac
  6513. ;;
  6514. esac
  6515. case $m in
  6516. ?*) case $path in
  6517. 0) case $filter in
  6518. cat) cat $m
  6519. ;;
  6520. *) if test -f $HOME/.pkgresults
  6521. then i="`cat $HOME/.pkgresults`"
  6522. case $i in
  6523. '|'*) ;;
  6524. *) i="|$i" ;;
  6525. esac
  6526. else i=
  6527. fi
  6528. for j in $m
  6529. do echo "$sep==> $j <=="
  6530. sep=$nl
  6531. case $filter in
  6532. errors) $exeg egrep '^pax:|\*\*\*' $j
  6533. ;;
  6534. *) $exec egrep -iv '^($||[\+\[]|cc[^-:]|kill |make.*(file system time|has been replaced)|so|[0123456789]+ error|uncrate |[0123456789]+ block|ar: creat|iffe: test: |conf: (check|generate|test)|[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_][abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789]*=|gsf@research|ar:.*warning|cpio:|ld:.*(duplicate symbol|to obtain more information)|[0123456789]*$|(checking|creating|touch) [/abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789])| obsolete predefined symbol | is (almost always misused|dangerous|deprecated|not implemented)| trigraph| assigned to | cast .* different size| integer overflow .*<<| optimization may be attained | passed as |::__builtin|pragma.*prototyped|^creating.*\.a$|warning.*not optimized|exceeds size thresh|ld:.*preempts|is unchanged|with value >=|(-l|lib)\*|/(ast|sys)/(dir|limits|param|stropts)\.h.*redefined|usage|base registers|`\.\.\.` obsolete'"$i" $j |
  6535. $exec grep :
  6536. ;;
  6537. esac
  6538. done
  6539. ;;
  6540. esac
  6541. ;;
  6542. 1) echo $m
  6543. ;;
  6544. esac
  6545. esac
  6546. ;;
  6547. test) requirements source $package
  6548. components $package
  6549. package=$_components_
  6550. case $only in
  6551. 0) only= ;;
  6552. 1) only=--recurse=only ;;
  6553. esac
  6554. # must have nmake
  6555. if nonmake $MAKE
  6556. then echo $command: $action: must have $MAKE to test >&2
  6557. exit 1
  6558. fi
  6559. # all work under $INSTALLROOT/src
  6560. $make cd $INSTALLROOT/src
  6561. # disable core dumps (could be disastrous over nfs)
  6562. (ulimit -c 0) > /dev/null 2>&1 && ulimit -c 0
  6563. # do the tests
  6564. eval capture \$MAKE \$makeflags \$noexec \$only recurse test \$target \$nmakesep \$package $assign
  6565. ;;
  6566. update) # download the latest release.version for selected packages
  6567. # all work in $PACKAGEROOT/lib/package/tgz
  6568. if test ! -d $PACKAGEROOT/lib/package/tgz
  6569. then $exec mkdir -p $PACKAGEROOT/lib/package/tgz || exit
  6570. $exec cd $PACKAGEROOT/lib/package/tgz
  6571. else cd $PACKAGEROOT/lib/package/tgz
  6572. fi
  6573. # get the architectures, update query url, and packages
  6574. set '' $args
  6575. op=update
  6576. tgz=tgz
  6577. source=
  6578. binary=
  6579. setup=
  6580. types=
  6581. url=
  6582. urlfile=$default_url
  6583. while :
  6584. do shift
  6585. case $# in
  6586. 0) break ;;
  6587. esac
  6588. case $1 in
  6589. --) shift
  6590. break
  6591. ;;
  6592. beta) op=beta
  6593. tgz=beta
  6594. ;;
  6595. binary) binary=1
  6596. ;;
  6597. setup) setup=1
  6598. ;;
  6599. source) source=1
  6600. ;;
  6601. *://*) url=$1
  6602. shift
  6603. break
  6604. ;;
  6605. *.url) urlfile=$1
  6606. if test ! -s $urlfile
  6607. then echo $command: $urlfile: not found >&2; exit 1
  6608. fi
  6609. break
  6610. ;;
  6611. $all_types)
  6612. binary=1
  6613. types="$types $1"
  6614. ;;
  6615. *) break
  6616. ;;
  6617. esac
  6618. done
  6619. case $source:$binary in
  6620. :) source=1 binary=1
  6621. ;;
  6622. :1) case $types in
  6623. '') types=$HOSTTYPE ;;
  6624. esac
  6625. ;;
  6626. esac
  6627. case $url in
  6628. '') case $urlfile in
  6629. $default_url)
  6630. if test ! -s $urlfile
  6631. then echo $command: url argument expected >&2; exit 1
  6632. fi
  6633. ;;
  6634. *) default_url=
  6635. ;;
  6636. esac
  6637. url=
  6638. if grep '^url=' $urlfile >/dev/null
  6639. then a=$authorize
  6640. p=$password
  6641. case $urlfile in
  6642. */*) ;;
  6643. *) urlfile=./$urlfile ;;
  6644. esac
  6645. . $urlfile
  6646. case $a:$p in
  6647. $authorize:$password)
  6648. default_url=
  6649. ;;
  6650. *) case $a in
  6651. ?*) authorize=$a ;;
  6652. esac
  6653. case $p in
  6654. ?*) password=$p ;;
  6655. esac
  6656. ;;
  6657. esac
  6658. else url=`cat $urlfile`
  6659. fi
  6660. ;;
  6661. esac
  6662. case $exec in
  6663. ?*) default_url= ;;
  6664. esac
  6665. # get the update list
  6666. eval `echo $url | sed 's,\(.*\)://\([^/]*\)/\(.*\),prot=\"\1\" host=\"\2\" dir=\"\3\",'`
  6667. get $host $dir/$op.html
  6668. # get/check the package names
  6669. case " $* " in
  6670. *" - "*)case $source in
  6671. 1) source_packages=$* ;;
  6672. *) source_packages= ;;
  6673. esac
  6674. case $binary in
  6675. 1) binary_packages=$* ;;
  6676. *) binary_packages= ;;
  6677. esac
  6678. package_hit=$*
  6679. ;;
  6680. " ") nl="
  6681. "
  6682. case $source in
  6683. 1) p=
  6684. for f in `ls *.????-??-??.* 2>/dev/null`
  6685. do case $f in
  6686. *.????-??-??.????-??-??.*.*)
  6687. ;;
  6688. *.????-??-??.????-??-??.*)
  6689. p=$p$nl$f
  6690. ;;
  6691. *.????-??-??.*.*)
  6692. ;;
  6693. *.????-??-??.*)
  6694. p=$p$nl$f
  6695. ;;
  6696. esac
  6697. done
  6698. set '' `echo "$p" | sed 's,\..*,,' | sort -u`
  6699. shift
  6700. source_packages=$*
  6701. ;;
  6702. *) source_packages=
  6703. ;;
  6704. esac
  6705. case $binary in
  6706. 1) p=
  6707. for f in `ls *.????-??-??.* 2>/dev/null`
  6708. do case $f in
  6709. *.????-??-??.????-??-??.*.*)
  6710. p=$p$nl$f
  6711. ;;
  6712. *.????-??-??.????-??-??.*)
  6713. ;;
  6714. *.????-??-??.*.*)
  6715. p=$p$nl$f
  6716. ;;
  6717. *.????-??-??.*)
  6718. ;;
  6719. esac
  6720. done
  6721. set '' `echo "$p" | sed 's,\..*,,' | sort -u`
  6722. shift
  6723. binary_packages=$*
  6724. ;;
  6725. *) binary_packages=
  6726. ;;
  6727. esac
  6728. package_hit="$source_packages $binary_packages"
  6729. ;;
  6730. *) case $source in
  6731. 1) source_packages=$* ;;
  6732. *) source_packages= ;;
  6733. esac
  6734. case $binary in
  6735. 1) binary_packages=$* ;;
  6736. *) binary_packages= ;;
  6737. esac
  6738. package_hit=
  6739. ;;
  6740. esac
  6741. # get the latest updates
  6742. types_test=
  6743. types_local=
  6744. dir=$dir/$tgz
  6745. case $default_url in
  6746. ?*) echo "url='$url' authorize='$authorize' password='$password'" > $default_url
  6747. case $authorize in
  6748. ?*) chmod go-rwx $default_url ;;
  6749. esac
  6750. ;;
  6751. esac
  6752. echo "$got" > got.tmp
  6753. case $only in
  6754. 0) exec < got.tmp
  6755. covered=
  6756. while read name suffix type base base_size delta delta_size sync sync_size requires covers base_sum delta_sum sync_sum comment
  6757. do case $requires in
  6758. ''|-*) continue ;;
  6759. esac
  6760. IFS=:
  6761. set '' $requires
  6762. IFS=$ifs
  6763. case $type in
  6764. -) case " $source_packages " in
  6765. *" $name "*|*" - "*)
  6766. for name
  6767. do case " $source_packages " in
  6768. *" $name "*)
  6769. ;;
  6770. *) source_packages="$source_packages $name"
  6771. covered=$covered:$covers
  6772. ;;
  6773. esac
  6774. done
  6775. ;;
  6776. esac
  6777. ;;
  6778. *) case " $binary_packages " in
  6779. *" $name "*|*" - "*)
  6780. for name
  6781. do case " $binary_packages " in
  6782. *" $name "*)
  6783. ;;
  6784. *) binary_packages="$binary_packages $name"
  6785. covered=$covered:$covers
  6786. ;;
  6787. esac
  6788. done
  6789. ;;
  6790. esac
  6791. ;;
  6792. esac
  6793. done
  6794. case $covered in
  6795. ?*) x=$source_packages
  6796. source_packages=
  6797. for name in $x
  6798. do case :$covered: in
  6799. *:$name:*) ;;
  6800. *) source_packages="$source_packages $name" ;;
  6801. esac
  6802. done
  6803. x=$binary_packages
  6804. binary_packages=
  6805. for name in $x
  6806. do case :$covered: in
  6807. *:$name:*) ;;
  6808. *) binary_packages="$binary_packages $name" ;;
  6809. esac
  6810. done
  6811. ;;
  6812. esac
  6813. ;;
  6814. esac
  6815. checksum=
  6816. for i in $checksum_commands
  6817. do case `( $i ) < /dev/null 2> /dev/null` in
  6818. ${checksum_empty}|${checksum_empty}[\ \ ]*)
  6819. checksum=$i
  6820. break
  6821. ;;
  6822. esac
  6823. done
  6824. case $checksum in
  6825. '') echo $command: warning: '{' $checksum_commands '}' command not found -- only download sizes will be checked >&2 ;;
  6826. esac
  6827. exec < got.tmp
  6828. while read name suffix type base base_size delta delta_size sync sync_size requires covers base_sum delta_sum sync_sum comment
  6829. do case $verbose in
  6830. 1) case $type in
  6831. -) i= ;;
  6832. *) i=.$type ;;
  6833. esac
  6834. j="$name.$base$i.$suffix"
  6835. case $delta in
  6836. -) j="$j -" ;;
  6837. *) j="$j $name.$base.$delta$i.$suffix" ;;
  6838. esac
  6839. case $sync in
  6840. -) j="$j -" ;;
  6841. *) j="$j $name.$base.$sync$i.$suffix" ;;
  6842. esac
  6843. echo $command: $j $base_size:$base_sum $delta_size:$delta_sum $sync_size:$sync_sum $requires >&2
  6844. esac
  6845. case " $package_hit " in
  6846. *" $name "*|*" - "*)
  6847. ;;
  6848. *) package_hit="$package_hit $name"
  6849. ;;
  6850. esac
  6851. case $type in
  6852. -) case " $source_packages " in
  6853. *" $name "*|*" - "*)
  6854. if test -s $name.tim
  6855. then continue
  6856. fi
  6857. lcl=$name.$base.$suffix
  6858. if test -f $lcl
  6859. then case $checksum:$base_sum in
  6860. :*|*:-) size=`wc -c < $lcl | sed 's, ,,g'` sum=$base_sum ;;
  6861. *) size=$base_size sum=`$checksum < $lcl | sed -e 's,^[ ][ ]*,,' -e 's,[ ].*,,'` ;;
  6862. esac
  6863. else size=X sum=X
  6864. fi
  6865. if test "0" != "$force" -a "X-" = "X$delta" -o "$base_size" != "$size" -o "$base_sum" != "$sum"
  6866. then rmt=
  6867. case $sync:$sync_size in
  6868. -*|*[-:])
  6869. ;;
  6870. *) lcl=$name.$base.$sync.$suffix
  6871. if test -f $lcl
  6872. then rmt=1
  6873. get $host $dir $lcl $sync_size $sync_sum
  6874. fi
  6875. ;;
  6876. esac
  6877. case $base:$base_size in
  6878. -*|*[-:])
  6879. ;;
  6880. *) case $rmt in
  6881. '') lcl=$name.$base.$suffix
  6882. get $host $dir $lcl $base_size $base_sum
  6883. ;;
  6884. esac
  6885. ;;
  6886. esac
  6887. fi
  6888. case $delta:$delta_size in
  6889. -*|*[-:])
  6890. ;;
  6891. *) lcl=$name.$delta.$base.$suffix
  6892. if test -f $lcl
  6893. then case $checksum:$delta_sum in
  6894. :*|*:-) size=`wc -c < $lcl | sed 's, ,,g'` sum=$delta_sum ;;
  6895. *) size=$base_size sum=`$checksum < $lcl | sed -e 's,^[ ][ ]*,,' -e 's,[ ].*,,'` ;;
  6896. esac
  6897. else size=X sum=X
  6898. fi
  6899. if test "0" != "$force" -o "$delta_size" != "$size" -o "$delta_sum" != "$sum"
  6900. then get $host $dir $lcl $delta_size $delta_sum
  6901. fi
  6902. ;;
  6903. esac
  6904. ;;
  6905. esac
  6906. ;;
  6907. *) case " $binary_packages " in
  6908. *" $name "*|*" - "*)
  6909. if test -s $name.$type.tim
  6910. then continue
  6911. fi
  6912. case " $types " in
  6913. *" - "*);;
  6914. " ") case " $types_test " in
  6915. *" $type "*)
  6916. ;;
  6917. *) types_test="$types_test $type"
  6918. for i in *.????-??-??.$type.* *.????-??-??.????-??-??.$type.*
  6919. do if test -f $i
  6920. then types_local="$types_local $type"
  6921. fi
  6922. break
  6923. done
  6924. ;;
  6925. esac
  6926. case " $types_local " in
  6927. *" $type "*)
  6928. ;;
  6929. *) continue
  6930. ;;
  6931. esac
  6932. ;;
  6933. *) case " $types " in
  6934. *" $type "*)
  6935. ;;
  6936. *) continue
  6937. ;;
  6938. esac
  6939. ;;
  6940. esac
  6941. lcl=$name.$base.$type.$suffix
  6942. if test -f $lcl
  6943. then case $checksum:$base_sum in
  6944. :*|*:-) size=`wc -c < $lcl | sed 's, ,,g'` sum=$base_sum ;;
  6945. *) size=$base_size sum=`$checksum < $lcl | sed -e 's,^[ ][ ]*,,' -e 's,[ ].*,,'` ;;
  6946. esac
  6947. else size=X sum=X
  6948. fi
  6949. if test "0" != "$force" -a "X-" = "X$delta" -o "$base_size" != "$size" -o "$base_sum" != "$sum"
  6950. then rmt=
  6951. case $sync:$sync_size in
  6952. -*|*[-:])
  6953. ;;
  6954. *) lcl=$name.$base.$sync.$type.$suffix
  6955. if test -f $lcl
  6956. then rmt=1
  6957. get $host $dir $lcl $sync_size $sync_sum
  6958. fi
  6959. ;;
  6960. esac
  6961. case $base:$base_size in
  6962. -*|*[-:])
  6963. ;;
  6964. *) case $rmt in
  6965. '') lcl=$name.$base.$type.$suffix
  6966. get $host $dir $lcl $base_size $base_sum
  6967. ;;
  6968. esac
  6969. ;;
  6970. esac
  6971. fi
  6972. case $delta:$delta_size in
  6973. -*|*[-:])
  6974. ;;
  6975. *) lcl=$name.$delta.$base.$type.$suffix
  6976. if test -f $lcl
  6977. then sum=`$checksum < $lcl | sed -e 's,^[ ][ ]*,,' -e 's,[ ].*,,'`
  6978. else sum=X
  6979. fi
  6980. if test -f $lcl
  6981. then case $checksum:$delta_sum in
  6982. :*|*:-) size=`wc -c < $lcl | sed 's, ,,g'` sum=$delta_sum ;;
  6983. *) size=$base_size sum=`$checksum < $lcl | sed -e 's,^[ ][ ]*,,' -e 's,[ ].*,,'` ;;
  6984. esac
  6985. else size=X sum=X
  6986. fi
  6987. if test "0" != "$force" -o "$delta_size" != "$size" -o "$delta_sum" != "$sum"
  6988. then get $host $dir $lcl $delta_size $delta_sum
  6989. fi
  6990. ;;
  6991. esac
  6992. ;;
  6993. esac
  6994. ;;
  6995. esac
  6996. done
  6997. closure=
  6998. for name in $source_packages $binary_packages
  6999. do case $name in
  7000. -) ;;
  7001. *) case " $package_hit " in
  7002. *" $name "*)
  7003. case $setup in
  7004. 1) case " $closure " in
  7005. *" $name "*)
  7006. ;;
  7007. *) closure="$closure $name"
  7008. ;;
  7009. esac
  7010. ;;
  7011. esac
  7012. ;;
  7013. *) echo $command: $name: unknown package >&2
  7014. ;;
  7015. esac
  7016. ;;
  7017. esac
  7018. done
  7019. exec <&-
  7020. rm -f got.tmp
  7021. case $closure in
  7022. ?*) echo $closure ;;
  7023. esac
  7024. ;;
  7025. use) # finalize the environment
  7026. x=:..
  7027. for d in `( cd $PACKAGEROOT; ls src/*/Mamfile 2>/dev/null | sed 's,/[^/]*$,,' | sort -u )`
  7028. do x=$x:$INSTALLROOT/$d
  7029. done
  7030. x=$x:$INSTALLROOT
  7031. case $CDPATH: in
  7032. $x:*) ;;
  7033. *) CDPATH=$x:$CDPATH
  7034. $show CDPATH=$CDPATH
  7035. $show export CDPATH
  7036. export CDPATH
  7037. ;;
  7038. esac
  7039. P=$PACKAGEROOT
  7040. $show P=$P
  7041. $show export P
  7042. export P
  7043. A=$INSTALLROOT
  7044. $show A=$A
  7045. $show export A
  7046. export A
  7047. case $NPROC in
  7048. '') hostinfo cpu
  7049. case $_hostinfo_ in
  7050. 0|1) ;;
  7051. *) NPROC=$_hostinfo_
  7052. $show NPROC=$NPROC
  7053. $show export NPROC
  7054. export NPROC
  7055. ;;
  7056. esac
  7057. ;;
  7058. esac
  7059. eval PACKAGE_USE=$package_use
  7060. export PACKAGE_USE
  7061. # run the command
  7062. case $run in
  7063. '') case $show in
  7064. ':') $exec exec $SHELL ;;
  7065. esac
  7066. ;;
  7067. *) $exec exec $SHELL -c "$run"
  7068. ;;
  7069. esac
  7070. ;;
  7071. verify) cd $PACKAGEROOT
  7072. requirements binary $package
  7073. if executable ! $SUM
  7074. then echo "$command: $action: $SUM command required" >&2
  7075. exit 1
  7076. fi
  7077. case $target in
  7078. '') cd arch
  7079. set '' *
  7080. shift
  7081. target=$*
  7082. cd ..
  7083. ;;
  7084. esac
  7085. code=0
  7086. for a in $target
  7087. do case $package in
  7088. '') set '' arch/$a/lib/package/gen/*.sum
  7089. shift
  7090. if test -f $1
  7091. then for i
  7092. do package_verify $i || code=1
  7093. done
  7094. else echo "$command: warning: $a: no binary packages" >&2
  7095. fi
  7096. ;;
  7097. *) for i in $package
  7098. do if test -f arch/$a/lib/package/gen/$i.sum
  7099. then package_verify arch/$a/lib/package/gen/$i.sum || code=1
  7100. else echo "$command: warning: $a: no binary package for $i" >&2
  7101. fi
  7102. done
  7103. ;;
  7104. esac
  7105. done
  7106. exit $code
  7107. ;;
  7108. write) set '' $target
  7109. shift
  7110. action=
  7111. list=
  7112. qualifier=
  7113. while :
  7114. do case $1 in
  7115. base|closure|delta|exp|lcl|pkg|rpm|tgz)
  7116. qualifier="$qualifier $1"
  7117. ;;
  7118. binary) action=$1
  7119. type=$HOSTTYPE
  7120. eval list=$PACKAGESRC/tgz/$admin_list
  7121. ;;
  7122. cyg) qualifier="$qualifier $1"
  7123. assign="$assign closure=1"
  7124. only=1
  7125. ;;
  7126. runtime|source)
  7127. action=$1
  7128. ;;
  7129. tst) qualifier="$qualifier tgz"
  7130. assign="$assign copyright=0 'PACKAGEDIR=\$(PACKAGESRC)/tst'"
  7131. ;;
  7132. nocopyright)
  7133. assign="$assign copyright=0"
  7134. ;;
  7135. *) break
  7136. ;;
  7137. esac
  7138. shift
  7139. done
  7140. case $action in
  7141. '') echo "$command: binary or source operand expected" >&2
  7142. exit 1
  7143. ;;
  7144. esac
  7145. set '' "$@" $package
  7146. shift
  7147. case $only in
  7148. 0) set '' `order "$@"`
  7149. shift
  7150. ;;
  7151. esac
  7152. case $# in
  7153. 0) echo "$command: at least one package name expected" >&2
  7154. exit 1
  7155. ;;
  7156. esac
  7157. if nonmake $MAKE
  7158. then echo "$command: must have $MAKE to generate archives" >&2
  7159. exit 1
  7160. fi
  7161. # all work under $PACKAGEBIN
  7162. $make cd $PACKAGEBIN
  7163. case $list in
  7164. ?*) $exec rm -f $list ;;
  7165. esac
  7166. # go for it
  7167. for package
  7168. do if view - all $package.pkg || view - all lib/package/$package.pkg
  7169. then eval capture \$MAKE \$makeflags -X ignore \$noexec -f \$package.pkg \$qualifier \$action $assign
  7170. else echo "$command: $package: not a package" >&2
  7171. fi
  7172. done
  7173. ;;
  7174. TEST) set '' $target $package
  7175. shift
  7176. case $1 in
  7177. binary|source)
  7178. action=$1
  7179. shift
  7180. ;;
  7181. esac
  7182. order "$@"
  7183. ;;
  7184. *) echo "$command: $action: internal error" >&2
  7185. exit 1
  7186. ;;
  7187. esac
  7188. exit "$error_status"