├── .gitignore ├── .gitreview ├── LICENSE ├── README.adoc ├── bb-expand-vars.py ├── format-command-lines.py ├── setup-environment.d ├── priority └── ye.py ├── ye ├── ye-cd └── ye-completion.sh /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.pyc 3 | -------------------------------------------------------------------------------- /.gitreview: -------------------------------------------------------------------------------- 1 | [gerrit] 2 | host=code.ossystems.com.br 3 | port=29418 4 | project=apps/ye.git 5 | defaultbranch=master 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | 633 | Copyright (C) 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published by 637 | the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see . 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | . 662 | -------------------------------------------------------------------------------- /README.adoc: -------------------------------------------------------------------------------- 1 | :toc: 2 | 3 | = ye (Yocto Explorer) 4 | 5 | == Introduction 6 | 7 | `ye` is a command line tool to ease the manipulation of files under 8 | the directory structure adopted by O.S. Systems to organize projects 9 | that use the Yocto Project. `ye` provides means to quickly locate 10 | files and directories into projects' directory tree, and act on them. 11 | 12 | === The directory layout assumed by ye 13 | 14 | The infrastructure adopted by O.S. Systems assumes the following 15 | directory layout: 16 | 17 | .... 18 | 19 | .repo 20 | 21 | setup-environment 22 | sources 23 | .... 24 | 25 | `` is the root directory of the project you'll be working on. 26 | In it you'll initially find a `setup-environment` script, which is 27 | supposed to be source'd to set up the environment and will create 28 | ``, and a `sources` directory, under which the source code 29 | of all projects (git repositories) will be stored. 30 | 31 | The directory layout in the `` directory follows the 32 | standard layout as determined by the Yocto Project. 33 | 34 | === Notes on arguments, environment and interactive behavior 35 | 36 | Most `ye` commands accept a regular expression as argument. Thus, it's 37 | possible that it will obtain multiple results. In this case, if 38 | ``ye``'s output is attached to a terminal (i.e., not a pipe or a file), 39 | it will run interactively, prompting users for a specific result. 40 | 41 | When running interactively, `ye` will paginate the output in case it 42 | doesn't fit the terminal window and will highlight matches in red on 43 | the output. 44 | 45 | Some commands expect the `BUILDDIR` environment variable to be set in 46 | the environment (because they have to run `bitbake` behind the scenes 47 | to find out things). This variable is automatically set by the 48 | `setup-environment` script provided by O.S. Systems for Yocto 49 | Project-based projects. 50 | 51 | 52 | == Using ye 53 | 54 | This section will show in detail how to use `ye`. The help message 55 | displayed by `ye` when invoked with the `--help` option can be seen 56 | below. The next subsections provide more detailed information about 57 | each command. 58 | 59 | .... 60 | $ ye -h 61 | Usage: ye [ ] 62 | 63 | f [-e] 64 | find [-e] 65 | Locate paths (in the "sources" directory) that match the given 66 | expression . is case insensitive and implicitly 67 | surrounded by '.*'. -e disables the implicit use of '.*' around 68 | the given . Note that, unless contains /, matching 69 | is attempted on filenames only (not on dirnames). If 70 | contains /, matching is attempted on the full path. 71 | 72 | v [-e] 73 | view [-e] 74 | Shortcut to find & view. If multiple files are found, a prompt for 75 | files will be displayed (but not for actions). 76 | 77 | e [-e] 78 | edit [-e] 79 | Shortcut to find & edit. If multiple files are found, a prompt for 80 | files will be displayed (but not for actions). 81 | 82 | sf [-e] 83 | sysroot-find [-e] 84 | Locate paths (in the "sysroots" directory) that match the given 85 | expression . is case insensitive and implicitly 86 | surrounded by '.*'. -e disables the implicit use of '.*' around 87 | the given . Note that, unless contains /, matching 88 | is attempted on filenames only (not on dirnames). If 89 | contains /, matching is attempted on the full path. 90 | 91 | wsf [-e] 92 | work-shared-find [-e] 93 | Similar to sysroot-find, but instead of searching in the sysroots 94 | directories, search in the work-shared directory. 95 | 96 | pf [-e] 97 | pkg-find [-e] 98 | Like 'find', but for packages. 99 | 100 | pv [-e] 101 | pkg-view [-e] 102 | Shortcut to pkg-find & view. If multiple packages are found, a 103 | prompt for packages will be displayed (but not for actions). 104 | 105 | pi [-e] 106 | pkg-info [-e] 107 | Shortcut to pkg-find & info. If multiple packages are found, a 108 | prompt for packages will be displayed (but not for actions). 109 | 110 | ps [-e] 111 | pkg-scripts [-e] 112 | List scripts for package that matches . In case of multiple 113 | matches, ye will prompt for a specific package. is case 114 | insensitive and implicitly surrounded by '.*'. -e disables the 115 | implicit use of '.*' around the given . 116 | 117 | px [-e] [-c] [] 118 | pkg-extract [-e] [-c] [] 119 | Extract package that matches . In case of multiple matches, 120 | ye will prompt for a specific package. is case insensitive 121 | and implicitly surrounded by '.*'. -e disables the implicit use 122 | of '.*' around the given . 123 | If is provided, ye will extract only, otherwise the 124 | whole package content will be extracted to a directory named after 125 | the package filename (without extension). must match the exact 126 | file name in the package (usually starts with ./). 127 | -c is specific to .deb and .ipk packages -- ye will extract files 128 | from the control.tar.gz tarball in packages. 129 | 130 | wd [-e] 131 | workdir [-e] 132 | Locate the Yocto Project's workdir for . is 133 | implicitly surrounded by '.*', unless -e is provided. 134 | 135 | l [-e] [-H] [-R] [] 136 | log [-e] [-H] [] 137 | Show the log files for . -e is only applied to 138 | . is always implicitly surrounded 139 | by '.*', if provided. If -H ("human readable") is given on the 140 | command line, ye will try to make the lines that contain calls 141 | to gcc/g++ look more readable. If -R is provided, ye will apply 142 | some text replacements to make the output more readable. Currently, 143 | ye reverse expands some common variables whose expansion pollutes 144 | log files with long paths. The following variables are reverse 145 | expanded: 146 | * $B 147 | * $S 148 | * $WORKDIR 149 | * $TMPDIR 150 | * $HOME 151 | 152 | r [-e] [] 153 | run [-e] [] 154 | Show the log files for . -e is only applied to 155 | . is always implicitly 156 | surrounded by '.*', if provided. 157 | 158 | g 159 | grep 160 | Run 'repo grep '. 161 | 162 | sg 163 | sysroot-grep 164 | Run 'grep -r $BUILDDIR/tmp/sysroots/$MACHINE'. 165 | 166 | glg [-n ] [-i] 167 | git-log-grep [-n ] [-i] 168 | Run "git log -n --oneline | grep " on all the 169 | repositories and prompt the user for the commit to show. 170 | If -n is not provided, 1000 will be used. If -i is provided, search 171 | will be case insensitive. 172 | 173 | gbh [] 174 | grep-buildhistory [] 175 | Run "git grep [] " in the buildhistory directory. 176 | 177 | bh [-d] 178 | buildhistory [-d] 179 | Show changes in buildhistory (a positive integer). 180 | If -d is given, show the raw git diff output. 181 | 182 | d [-e] 183 | doc [-e] 184 | Search variable names in the reference manual that match the given 185 | expression and show the documentation for the selected 186 | match. is case insensitive and implicitly surrounded by 187 | '.*'. -e disables the implicit use of '.*' around the given 188 | . 189 | 190 | x 191 | expand 192 | Expand BitBake's variable in the context of and 193 | show the final value and the recursive expansion of all variables 194 | and expressions involved. 195 | 196 | cd [] 197 | Change to . The following options are 198 | available: 199 | 200 | top 201 | Change to project's TOPDIR 202 | 203 | wd [] 204 | Change to 's WORKDIR or to BUILDDIR/tmp/deploy/work if 205 | is not provided 206 | 207 | bd 208 | Change to BUILDDIR 209 | 210 | bh 211 | Change to the buildhistory directory 212 | 213 | sd 214 | Change to the sysroot directory for MACHINE 215 | 216 | src [] 217 | Change to 's source dir or to TOPDIR/sources 218 | if is not provided 219 | 220 | img 221 | Change to BUILDDIR/tmp/deploy/MACHINE/image/ 222 | 223 | pkg 224 | Change to BUILDDIR/tmp/deploy/PKG_TYPE/image/ 225 | 226 | manifest 227 | Change to TOPDIR/.repo/manifests 228 | 229 | When called without arguments, ye cd will change to BUILDDIR. 230 | 231 | To use this feature, source'ing the ye-cd shell helper is required. 232 | .... 233 | 234 | 235 | === Finding and operating on files 236 | 237 | `ye` provides commands to locate files and operate on them. Some 238 | commands are specific to some directories and some are specific to 239 | some file types (e.g., packages). The following sections provide a 240 | more in-depth explanation about them. 241 | 242 | 243 | ==== Finding and operating on files in the `sources` directory 244 | 245 | The `find` command (short: `f`) can be used to locate files under the 246 | `sources` directory. It's argument is a regular expression that will 247 | be matched against pathnames. If the given regex contains `/`, 248 | matching is attempted on filenames only (not on dirnames). If the 249 | given regex contains `/`, matching is attempted on the full path. 250 | 251 | After locating files that match the given pattern, `ye` will prompt 252 | you to select one of the matches and, next, what to do with it. In 253 | case the standard output is not a terminal (e.g., a file or a pipe), 254 | interactive commands will just print the results to the standard 255 | output (no prompt for action will be displayed). 256 | 257 | Example: 258 | 259 | .... 260 | $ ye f flex 261 | [0] ~/yocto/sources/poky/meta/recipes-devtools/flex/flex.inc [0] 262 | [1] ~/yocto/sources/poky/meta/recipes-devtools/flex/flex_2.5.35.bb [1] 263 | Option (ENTER to cancel): 1 264 | [v] View 265 | [e] Edit 266 | Option (ENTER to cancel): v 267 | 1 require flex.inc 268 | 2 PR = "r3" 269 | 3 LICENSE="BSD" 270 | 4 LIC_FILES_CHKSUM = "file://COPYING;md5=e4742cf92e89040b39486a6219b68067" 271 | 5 BBCLASSEXTEND = "native nativesdk" 272 | 6 273 | 7 SRC_URI += "file://avoid-FORTIFY-warnings.patch \ 274 | 8 file://int-is-not-the-same-size-as-size_t.patch" 275 | 9 276 | 10 SRC_URI[md5sum] = "10714e50cea54dc7a227e3eddcd44d57" 277 | 11 SRC_URI[sha256sum] = "0becbd4b2b36b99c67f8c22ab98f7f80c9860aec70..." 278 | .... 279 | 280 | NOTE: `ye` also allows you to use shortcuts for selecting options and 281 | actions at the same prompt. In the example above, we typed `0 ENTER` 282 | to select `flex.inc`, then `0 ENTER` to select the `View` action. The 283 | shortcut would be `0v ENTER` in the file selection prompt. For 284 | `Edit`, the shortcut would be `0e ENTER`. 285 | 286 | For cases you know in advance what to do with files (i.e., view or 287 | edit), `ye` provides commands to allow you to specify the action on 288 | the command line, so it won't prompt you for the action. Those 289 | commands are `view` (short: `v`) and `edit` (short: `e`). They are 290 | basically shortcuts to `find` -> `view` and `find` -> `edit`. 291 | 292 | The `view` and `edit` commands can be quite handy when you have a part 293 | of the full path to a file. Here's an example use-case: you want to 294 | understand how the `qemuarm` machine configuration is built. You 295 | start by looking at the content of `qemuarm.conf`: 296 | 297 | .... 298 | $ ye v qemuarm.conf 299 | ~/src/yocto/sources/poky/meta/conf/machine/qemuarm.conf 300 | 1 #@TYPE: Machine 301 | 2 #@NAME: arm_versatile_926ejs 302 | 3 #@DESCRIPTION: arm_versatile_926ejs 303 | 4 304 | 5 require conf/machine/include/qemu.inc 305 | 6 require conf/machine/include/tune-arm926ejs.inc 306 | 7 #require conf/machine/include/tune-arm1136jf-s.inc 307 | 8 308 | 9 KERNEL_IMAGETYPE = "zImage" 309 | 10 310 | 11 SERIAL_CONSOLE = "115200 ttyAMA0" 311 | 12 312 | /home/mario/src/yocto/sources/poky/meta/conf/machine/qemuarm.conf 313 | .... 314 | 315 | You see `qemuarm.conf` includes `conf/machine/include/qemu.inc`. 316 | Since you may not know what layer ships 317 | `conf/machine/include/qemu.inc`, to see its contents you first would 318 | have to locate it, then you'd need to call a viewer passing as 319 | argument the path to the file you found. With `ye`, you can just give 320 | it the partial path referenced in `qemuarm.conf`: 321 | 322 | .... 323 | $ ye v conf/machine/include/qemu.inc 324 | ~/src/yocto/sources/poky/meta/conf/machine/include/qemu.inc 325 | 1 PREFERRED_PROVIDER_virtual/xserver ?= "xserver-xorg" 326 | 2 PREFERRED_PROVIDER_virtual/egl ?= "mesa" 327 | 3 PREFERRED_PROVIDER_virtual/libgl ?= "mesa" 328 | 4 PREFERRED_PROVIDER_virtual/libgles1 ?= "mesa" 329 | 5 PREFERRED_PROVIDER_virtual/libgles2 ?= "mesa" 330 | 6 331 | 7 XSERVER ?= "xserver-xorg \ 332 | ... 333 | .... 334 | 335 | `ye` will locate and display the file in a single step. If it finds 336 | multiple results for `conf/machine/include/qemu.inc` it'll prompt you 337 | for the one you really want to see. 338 | 339 | 340 | ==== Finding and displaying files in the `sysroots` directories 341 | 342 | The `sysroot-find` (short: `sf`) command is pretty much equivalent to 343 | the `find` command, except it locates files under the sysroots 344 | directory (`/tmp/sysroots`). 345 | 346 | 347 | ==== Finding and displaying files in the `work-shared` directory 348 | 349 | The `work-shared-find` (short: `wsf`) command is similar to the 350 | `sysroot-find` command, but instead of searching in the sysroots 351 | directories, it searches in the `work-shared` directory. 352 | 353 | 354 | ==== Finding and operating on files in the `deploy` directory (for packages) 355 | 356 | The `pkg-find` (short: `pf`) command is equivalent to the `find` 357 | command, except it locates files under the deploy directory for 358 | packages (`/tmp/deploy/`). `ye` supports the 359 | most common package formats generated by Yocto Project: `.ipk`, `.deb` 360 | and `.rpm`. 361 | 362 | The actions for packages are different from the `find` command. `ye` 363 | supports the following actions on packages: 364 | 365 | `view`:: show the package contents 366 | 367 | `info`:: show the package metadata 368 | 369 | `scripts`:: list package scripts (.e.g., `postinstall`, `postrm`) 370 | 371 | `extract`:: extract package contents to a directory named after the 372 | package filename 373 | 374 | Just like the `view` and `edit` counterparts to the `find` command, 375 | `ye` provides `pkg-view` (short: `pv`), `pkg-info` (short: `pi`), 376 | `pkg-scripts` (short: `ps`) and `pkg-extract` (short: `px`) command 377 | line shortcuts to the corresponding actions. 378 | 379 | Examples: 380 | 381 | .... 382 | $ ye pf busybox_ 383 | ~/yocto/build/tmp/deploy/ipk/cortexa9hf-vfp-neon/busybox_1.22.1-r32.5_cortexa9hf-vfp-neon.ipk 384 | [v] View 385 | [i] Info 386 | [s] Scripts 387 | [x] Extract 388 | Option (ENTER to cancel): v 389 | drwxrwxrwx root/root 0 2015-04-17 11:50 ./ 390 | drwxr-xr-x root/root 0 2015-04-17 11:50 ./etc/ 391 | -rw-r--r-- root/root 108 2015-04-17 11:50 ./etc/busybox.links.suid 392 | -rw-r--r-- root/root 2217 2015-04-17 11:50 ./etc/busybox.links.nosuid 393 | drwxr-xr-x root/root 0 2015-04-17 11:50 ./bin/ 394 | -rwxr-xr-x root/root 544012 2015-04-17 11:50 ./bin/busybox.nosuid 395 | -rwsr-xr-x root/root 52804 2015-04-17 11:50 ./bin/busybox.suid 396 | lrwxrwxrwx root/root 0 2015-04-17 11:50 ./bin/busybox -> busybox.nosuid 397 | lrwxrwxrwx root/root 0 2015-04-17 11:50 ./bin/sh -> busybox.nosuid 398 | /home/mario/yocto/build/tmp/deploy/ipk/cortexa9hf-vfp-neon/busybox_1.22.1-r32.5_cortexa9hf-vfp-neon.ipk 399 | .... 400 | 401 | .... 402 | $ ye pi flex_ 403 | ~/yocto/build/tmp/deploy/ipk/cortexa9hf-vfp-neon/flex_2.5.39-r0.3_cortexa9hf-vfp-neon.ipk 404 | Package: flex 405 | Version: 2.5.39-r0.3 406 | Description: Flex (The Fast Lexical Analyzer) 407 | Flex is a fast lexical analyser generator. Flex is a tool for generating 408 | programs that recognize lexical patterns in text. 409 | Section: devel 410 | Priority: optional 411 | Maintainer: O.S. Systems Software LTDA. 412 | License: BSD 413 | Architecture: cortexa9hf-vfp-neon 414 | OE: flex 415 | Homepage: http://sourceforge.net/projects/flex/ 416 | Depends: m4, libc6 (>= 2.20) 417 | Source: http://downloads.sourceforge.net/flex/flex-2.5.39.tar.bz2 file://run-ptest file://do_not_create_pdf_doc.patch 418 | /home/mario/yocto/build/tmp/deploy/ipk/cortexa9hf-vfp-neon/flex_2.5.39-r0.3_cortexa9hf-vfp-neon.ipk 419 | .... 420 | 421 | 422 | TIP: If you want to see the contents of the "main" package generated 423 | by a recipe (i.e., not `-dev`, `-dbg`, `-locale` etc.), you can append 424 | `\_` to the package name. So, instead of `flex`, you can use `flex_` 425 | and `ye` won't match `flex-dev`, for example. 426 | 427 | 428 | === Locating the work directory for recipes 429 | 430 | The `workdir` command (short: `wd`) will print the work directory for 431 | the given recipe regular expression pattern. Like the other commands 432 | that deal with regular expressions, `workdir` implicitly surrounds the 433 | given regular expression pattern by `.*`, unless the `-e` option is 434 | provided. 435 | 436 | Example: 437 | 438 | .... 439 | $ ye wd busybox 440 | /home/mario/yocto/build/tmp/work/cortexa9hf-vfp-neon-oel-linux-gnueabi/busybox 441 | .... 442 | 443 | 444 | === Viewing log files and scripts 445 | 446 | Upon processing recipes, BitBake writes log files and scripts to the 447 | directory where it processes recipes. Log files are prefixed by 448 | `log.` and scripts are prefixed by `run.`: 449 | 450 | `run.`:: shows the code that was run to process `` 451 | 452 | `log.`:: shows the output of the execution of `run.` 453 | 454 | `ye` provides commands to display the contents of log files and 455 | scripts: `log` (short: `l`) and `run` (short: `r`). 456 | 457 | Both use as first argument a regex to be matched against recipe names. 458 | The second argument (optional), is a regex to be matched against log 459 | filenames or scripts. If the second argument is not provided, `ye` 460 | will list all log files or scripts and prompt for the one you want to 461 | see. 462 | 463 | Both commands accept a `-e` option to indicate that the recipe regex 464 | should not be automatically surrounded by `.*`. 465 | 466 | Examples: 467 | 468 | .... 469 | $ ye r base-files 470 | === Showing run scripts for base-files 471 | [0] run.do_packagedata [0] 472 | [1] run.do_package_write_ipk [1] 473 | [2] run.do_fetch [2] 474 | [3] run.do_install [3] 475 | [4] run.do_unpack [4] 476 | [5] run.do_populate_sysroot [5] 477 | [6] run.do_patch [6] 478 | [7] run.do_package [7] 479 | [8] run.do_prepare_copyleft_sources [8] 480 | [9] run.do_configure [9] 481 | [10] run.do_populate_lic [10] 482 | [11] run.do_compile [11] 483 | [12] run.do_package_qa [12] 484 | Option (ENTER to cancel): 11 485 | 1 #!/bin/sh 486 | 2 487 | 3 # Emit a useful diagnostic if something fails: 488 | 4 bb_exit_handler() { 489 | 5 ret=$? 490 | ... 491 | .... 492 | 493 | .... 494 | $ ye l base-files 495 | === Showing logs for base-files 496 | [0] log.do_package_qa [0] 497 | [1] log.do_unpack [1] 498 | [2] log.do_configure [2] 499 | [3] log.do_prepare_copyleft_sources [3] 500 | [4] log.do_fetch [4] 501 | [5] log.do_package [5] 502 | [6] log.do_populate_sysroot [6] 503 | [7] log.do_patch [7] 504 | [8] log.do_packagedata [8] 505 | [9] log.do_compile [9] 506 | [10] log.do_install [10] 507 | [11] log.do_populate_lic [11] 508 | [12] log.do_package_write_ipk [12] 509 | Option (ENTER to cancel): 11 510 | 1 DEBUG: Executing python function sstate_task_prefunc 511 | 2 DEBUG: Python function sstate_task_prefunc finished 512 | ... 513 | .... 514 | 515 | 516 | .... 517 | $ ye r base-files pack 518 | === Showing run scripts for base-files 519 | [0] run.do_packagedata [0] 520 | [1] run.do_package_write_ipk [1] 521 | [2] run.do_unpack [2] 522 | [3] run.do_package [3] 523 | [4] run.do_package_qa [4] 524 | Option (ENTER to cancel): 4 525 | 1 def do_package_qa(d): 526 | 2 import subprocess 527 | 3 import oe.packagedata 528 | 4 529 | ... 530 | .... 531 | 532 | The `log` command also handles the `-H` option, which tries to make 533 | compiler command lines more readable (and numbers them). See some 534 | examples below: 535 | 536 | Without `-H`: 537 | 538 | .... 539 | $ ye l busybox compile 540 | === Showing logs for busybox 541 | [0] log.do_compile_ptest_base [0] 542 | [1] log.do_compile [1] 543 | Option (ENTER to cancel): 1 544 | ... 545 | 1118 gcc -Wp,-MD,applets/.applet_tables.d -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -o applets/applet_tables applets/applet_tables.c 546 | ... 547 | .... 548 | 549 | With `-H` 550 | 551 | .... 552 | $ ye l -H busybox compile 553 | === Showing logs for busybox 554 | [0] log.do_compile_ptest_base [0] 555 | [1] log.do_compile [1] 556 | Option (ENTER to cancel): 1 557 | ... 558 | --------------[ command line 2 ]---------------------- 559 | gcc 560 | -Wp,-MD,applets/.applet_tables.d 561 | -Wall 562 | -Wstrict-prototypes 563 | -O2 564 | -fomit-frame-pointer 565 | -o applets/applet_tables 566 | applets/applet_tables.c 567 | ... 568 | .... 569 | 570 | Long paths can considerably clutter logs, making them quite difficult 571 | to read. Another useful argument to `log` is `-R`: it reverse expands 572 | some variables in log text, transforming long paths into their 573 | corresponding variable. Examples: 574 | 575 | Without `-R`: 576 | 577 | ---- 578 | $ ye l -H make$ compile 579 | ... 580 | Making all in doc 581 | make[2]: Entering directory '/home/mario/src/yocto/build/tmp/work/ppce500v2-oel-linux-gnuspe/make/4.0-r0/build/doc' 582 | make[2]: Leaving directory '/home/mario/src/yocto/build/tmp/work/ppce500v2-oel-linux-gnuspe/make/4.0-r0/build/doc' 583 | make[2]: Entering directory '/home/mario/src/yocto/build/tmp/work/ppce500v2-oel-linux-gnuspe/make/4.0-r0/build' 584 | ---------------[ command line 1 ]--------------- 585 | powerpc-oel-linux-gnuspe-gcc 586 | -m32 587 | -mcpu=8548 588 | -mabi=spe 589 | -mspe 590 | -mfloat-gprs=double 591 | --sysroot=/home/mario/src/yocto/build/tmp/sysroots/olt8820plus 592 | -DLOCALEDIR=\"/usr/share/locale\" 593 | -DLIBDIR=\"/usr/lib\" 594 | -DINCLUDEDIR=\"/usr/include\" 595 | -DHAVE_CONFIG_H 596 | -I. 597 | -I/home/mario/src/yocto/build/tmp/work/ppce500v2-oel-linux-gnuspe/make/4.0-r0/make-4.0 598 | -O2 599 | -pipe 600 | -g 601 | -feliminate-unused-debug-types 602 | -c 603 | -o ar.o 604 | /home/mario/src/yocto/build/tmp/work/ppce500v2-oel-linux-gnuspe/make/4.0-r0/make-4.0/ar.c 605 | ... 606 | ---- 607 | 608 | 609 | With `-R`: 610 | 611 | ---- 612 | $ ye l -H -R make$ compile 613 | ... 614 | Making all in doc 615 | make[2]: Entering directory '$B/doc' 616 | make[2]: Leaving directory '$B/doc' 617 | make[2]: Entering directory '$B' 618 | ---------------[ command line 1 ]--------------- 619 | powerpc-iep-linux-gnuspe-gcc 620 | -m32 621 | -mcpu=8548 622 | -mabi=spe 623 | -mspe 624 | -mfloat-gprs=double 625 | --sysroot=$TMPDIR/sysroots/olt8820plus 626 | -DLOCALEDIR=\"/usr/share/locale\" 627 | -DLIBDIR=\"/usr/lib\" 628 | -DINCLUDEDIR=\"/usr/include\" 629 | -DHAVE_CONFIG_H 630 | -I. 631 | -I$S 632 | -O2 633 | -pipe 634 | -g 635 | -feliminate-unused-debug-types 636 | -c 637 | -o ar.o 638 | $S/ar.c 639 | ... 640 | ---- 641 | 642 | 643 | === Finding text (_grepping_) 644 | 645 | `ye` provides commands to locate text in file contents and on summary 646 | lines of commit messages. The next subsections show these commands in 647 | detail. 648 | 649 | ==== Finding text in source files 650 | 651 | The `grep` command is a thin wrapper around `repo grep` (`repo` is the 652 | tool used by O.S. Systems to manage multiple git repositories -- see 653 | the http://doc.ossystems.com.br/managing-platforms.html[Managing 654 | platforms based on the Yocto Project] document for more information). 655 | Basically, `repo grep ` will run `git grep ` on 656 | each repository (in the `sources` directory) which is part of the 657 | project. 658 | 659 | The `grep` command will run `repo grep` plus the arguments provided on 660 | the command line (any valid argument for `git grep`) and will prompt 661 | you to select one of the matches, then the action to apply on the 662 | selected file. In case of a single match, you'll be only prompted for 663 | the action. 664 | 665 | Example: 666 | 667 | .... 668 | $ ye g -i libfoo 669 | [0] sources/meta-openembedded/meta-oe/recipes-connectivity/samba/samba-3.6.24/waf-as-source.patch:+ """example: bld.symlink_as('${PREFIX}/lib/libfoo.so', 'libfoo.so.1.2.3') """ [0] 670 | [1] sources/meta-openembedded/meta-oe/recipes-connectivity/samba/samba-3.6.24/waf-as-source.patch:+ libfoo.so is installed as libfoo.so.1.2.3 [1] 671 | [2] sources/poky/meta/classes/package.bbclass: # /opt/abc/lib/libfoo.so.1 and contains /usr/bin/abc depending on system library libfoo.so.1 [2] 672 | [3] sources/poky/meta/recipes-core/glibc/glibc/eglibc-install-pic-archives.patch: # $(inst_libdir)/libfoo.so -- for linking, symlink or ld script [3] 673 | [4] sources/poky/meta/recipes-core/glibc/glibc/eglibc-install-pic-archives.patch: # $(inst_slibdir)/libfoo.so.NN -- for loading by SONAME, symlink [4] 674 | Option (ENTER to cancel): 2v 675 | 1 # 676 | 2 # Packaging process 677 | 3 # 678 | 4 # Executive summary: This class iterates over the functions listed in PACKAGEFUNCS 679 | ... 680 | .... 681 | 682 | 683 | ==== Finding text in files in the sysroot directory 684 | 685 | The `sysroot-grep` (short: `sg`) command is similar to the `grep` 686 | command, but instead of searching for matches in the `sources` 687 | directory, it recursively searches for matches in the `sysroot` 688 | directory (`/tmp/sysroots/`, specifically). 689 | 690 | Example: 691 | 692 | .... 693 | $ ye sg -i '' 694 | Parsing recipes..done. 695 | [0] /home/mario/src/reach/dizzy/build/tmp/sysroots/g2h-solo-3/usr/lib/perl/ptest/lib/ExtUtils/Liblist.pm:you are using GCC, it gets translated to C, but for other win32 [0] 696 | [1] /home/mario/src/reach/dizzy/build/tmp/sysroots/g2h-solo-3/usr/lib/perl/ptest/cpan/ExtUtils-MakeMaker/lib/ExtUtils/Liblist.pm:you are using GCC, it gets translated to C, but for other win32 [1] 697 | [2] /home/mario/src/reach/dizzy/build/tmp/sysroots/g2h-solo-3/usr/lib/perl/5.20.0/ExtUtils/Liblist.pm:you are using GCC, it gets translated to C, but for other win32 [2] 698 | Option (ENTER to cancel): 1v 699 | 1 package ExtUtils::Liblist; 700 | 2 701 | 3 use strict; 702 | 4 703 | ... 704 | .... 705 | 706 | 707 | ==== Finding text in git logs 708 | 709 | The `git-log-grep` command (short: `glg`) basically runs 710 | 711 | .... 712 | git log --oneline | grep " 713 | .... 714 | 715 | for the given regular expressions on the summary lines of all git 716 | repositories that are part of the project. By default, it limits the 717 | repository history to 1000 commits. If you need to search in older 718 | commit summary lines, you can use the `-n ` option. 719 | 720 | Example: 721 | 722 | .... 723 | $ ye glg 'build error' 724 | [0] poky 7eb3e45 bitbake: toasterui: refactor log saving and save out-of-build errors [0] 725 | [1] meta-fsl-arm e45b4f8 linux-imx (2.6.35.3): Fix build errors when using make 3.82 [1] 726 | [2] meta-fsl-arm 7b30034 gst-fsl-plugin-2.0.3: fix build error due to missing uint declaration [2] 727 | [3] meta-fsl-arm c38a612 xf86-video-imxfb: fix build error due to missing uint declaration [3] 728 | [4] meta-openembedded 17ce4c6 libmtp: Fix 'Makefile.am: No such file or directory' build error. [4] 729 | Option (ENTER to cancel): 4 730 | commit 17ce4c6ac0d5b3651c7bd8758511679210a3286c 731 | Author: Charles Oram 732 | Date: Wed May 14 15:36:45 2014 +1200 733 | 734 | libmtp: Fix 'Makefile.am: No such file or directory' build error. 735 | 736 | * skip_udev_rules_generation() needs to reference Makefile.am in the recipe 737 | source directory. 738 | 739 | Signed-off-by: Charles Oram 740 | Signed-off-by: Martin Jansa 741 | 742 | diff --git a/meta-oe/recipes-connectivity/libmtp/libmtp_1.1.5.bb b/meta-oe/recipes-connectivity/libmtp/libmtp_1.1.5.bb 743 | index f4ea800..0c92ff9 100644 744 | --- a/meta-oe/recipes-connectivity/libmtp/libmtp_1.1.5.bb 745 | +++ b/meta-oe/recipes-connectivity/libmtp/libmtp_1.1.5.bb 746 | @@ -29,8 +29,8 @@ do_unpack[vardeps] += "skip_udev_rules_generation" 747 | do_unpack[postfuncs] += "skip_udev_rules_generation" 748 | 749 | skip_udev_rules_generation () { 750 | - sed -i -e '/^noinst_DATA=/,/util\/mtp-hotplug -H/d' Makefile.am 751 | - cp ${WORKDIR}/69-libmtp.rules ${S}/ 752 | + sed -i -e '/^noinst_DATA=/,/util\/mtp-hotplug -H/d' ${S}/Makefile.am 753 | + cp ${WORKDIR}/69-libmtp.rules ${S}/ 754 | } 755 | 756 | inherit autotools pkgconfig lib_package 757 | .... 758 | 759 | 760 | ==== Finding text in the buildhistory repository 761 | 762 | The `grep-buildhistory` commmand (short: `gbh`) is a wrapper around 763 | `git grep` in the buildhistory directory. 764 | 765 | Example: 766 | 767 | .... 768 | $ ye gbh 'passwd /bin/busybox' 769 | [0] packages/armv7a-vfp-neon-iep-linux-gnueabi/busybox/busybox/latest.pkg_postinst: update-alternatives --install /usr/bin/passwd passwd /bin/busybox.suid 50 [0] 770 | [1] packages/armv7a-vfp-neon-iep-linux-gnueabi/busybox/busybox/latest.pkg_postrm: update-alternatives --remove passwd /bin/busybox.suid [1] 771 | [2] packages/ppce500v2-iep-linux-gnuspe/busybox/busybox/latest.pkg_postinst: update-alternatives --install /usr/bin/passwd passwd /bin/busybox.suid 50 [2] 772 | [3] packages/ppce500v2-iep-linux-gnuspe/busybox/busybox/latest.pkg_postrm: update-alternatives --remove passwd /bin/busybox.suid [3] 773 | .... 774 | 775 | 776 | === Displaying buildhistory changes 777 | 778 | The `buildhistory` command (short: `bh`) can be used to display 779 | changes in the 780 | http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html#maintaining-build-output-quality[buildhistory]. 781 | The required argument (a positive integer) is the number of previous 782 | revisions to display. If the optional `-d` argument is given, 783 | `buildhistory` will show the raw diff output. 784 | 785 | `buildhistory` is basically a wrapper around `buildhistory-diff` or 786 | `git diff` in the buildhistory directory (when `-d` is provided). 787 | 788 | Example: 789 | 790 | .... 791 | $ ye bh 1 792 | packages/cortexa9hf-vfp-neon-oel-linux-gnueabi/tslib/tslib-calibrate: PKGR changed from r0.2 to r0.3 793 | packages/cortexa9hf-vfp-neon-oel-linux-gnueabi/tslib/tslib-conf: PKGR changed from r0.2 to r0.3 794 | packages/cortexa9hf-vfp-neon-oel-linux-gnueabi/tslib/tslib-dbg: PKGR changed from r0.2 to r0.3 795 | packages/cortexa9hf-vfp-neon-oel-linux-gnueabi/tslib/tslib-dev: PKGR changed from r0.2 to r0.3 796 | packages/cortexa9hf-vfp-neon-oel-linux-gnueabi/tslib/tslib-doc: PKGR changed from r0.2 to r0.3 797 | packages/cortexa9hf-vfp-neon-oel-linux-gnueabi/tslib/tslib-locale: PKGR changed from r0.2 to r0.3 798 | packages/cortexa9hf-vfp-neon-oel-linux-gnueabi/tslib/tslib-staticdev: PKGR changed from r0.2 to r0.3 799 | packages/cortexa9hf-vfp-neon-oel-linux-gnueabi/tslib/tslib-tests: PKGR changed from r0.2 to r0.3 800 | packages/cortexa9hf-vfp-neon-oel-linux-gnueabi/tslib/tslib: PKGR changed from r0.2 to r0.3 801 | .... 802 | 803 | 804 | === Finding documentation for variables 805 | 806 | The `doc` command (short: `d`) is a `man`-like tool for Yocto 807 | Project's variables. It searches the 808 | http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html[Yocto 809 | Project Reference Manual] for variables matching the given regular 810 | expression pattern (matching is case-insensitive). 811 | 812 | Example: 813 | 814 | .... 815 | $ ye d STAGING_DIR 816 | [0] STAGING_DIR [0] 817 | [1] STAGING_DIR_TARGET [1] 818 | [2] STAGING_DIR_HOST [2] 819 | [3] STAGING_DIR_NATIVE [3] 820 | Option (ENTER to cancel): 3 821 | 822 | === STAGING_DIR_NATIVE 823 | Specifies the path to the sysroot directory for the build host. 824 | .... 825 | 826 | `ye` maintains a cache of the Yocto project Reference Manual for seven 827 | days (under `$YE_DIR/doc-data`). If the cache is older than seven 828 | days, it will fetch the reference manual data and update the cache. 829 | 830 | 831 | === Expanding BitBake variables 832 | 833 | The `expand` command (short: `x`) can be very handy to find out 834 | variables' values and how they are assembled. It takes as argument a 835 | recipe and the variable you want to expand. It'll print the final 836 | variable value and the intermediary expansions (in case the variable 837 | value references other variables) in the context of the given recipe. 838 | 839 | Example: 840 | 841 | .... 842 | $ ye x core-image-minimal STAGING_DIR_TARGET 843 | Parsing recipes..done. 844 | === Final value 845 | STAGING_DIR_TARGET = /home/mario/src/yocto/build/tmp/sysroots/nitrogen6x-lite 846 | 847 | === Expansion 848 | STAGING_DIR_TARGET ==> ${STAGING_DIR}/${MACHINE} 849 | STAGING_DIR ==> ${TMPDIR}/sysroots 850 | TMPDIR ==> /home/mario/src/yocto/build/tmp 851 | MACHINE ==> nitrogen6x-lite 852 | .... 853 | 854 | 855 | Except for the `find` and `grep` commands, all commands expect the 856 | `BUILDDIR` environment variable to be set in the environment. This 857 | variable is automatically set by the `setup-environment` script 858 | provided by O.S. Systems for the Yocto Project-based projects. 859 | 860 | 861 | === Moving around: changing directories 862 | 863 | The `cd` command can be used to move around the project directory. 864 | `ye` provides some shortcut names for common directories in the layout 865 | adopted by O.S. Systems. See the documentation for the `cd` command 866 | for all available shortcuts. 867 | 868 | Using the `cd` command is just like using the shell's `cd` command, 869 | but giving the available shortcuts as arguments. Examples: 870 | 871 | .... 872 | $ pwd 873 | /home/mario/src/yocto 874 | 875 | $ ye cd 876 | $ pwd 877 | /home/mario/src/yocto/build 878 | 879 | $ ye cd src 880 | $ pwd 881 | /home/mario/src/yocto/sources 882 | 883 | $ ye cd src flex 884 | [0] ~/src/yocto/sources/poky/meta/recipes-bsp/grub/files/fix-issue-with-flex-2.5.37.patch [0] 885 | [1] ~/src/yocto/sources/poky/meta/recipes-devtools/flex/flex_2.5.39.bb [1] 886 | [2] ~/src/yocto/sources/poky/meta/recipes-devtools/flex/flex.inc [2] 887 | Option (ENTER to cancel): 0 888 | /home/mario/src/yocto/sources/poky/meta/recipes-bsp/grub/files/fix-issue-with-flex-2.5.37.patch 889 | $ pwd 890 | /home/mario/src/yocto/sources/poky/meta/recipes-bsp/grub/files 891 | 892 | $ ye cd wd flex 893 | [0] /home/mario/src/yocto/build/tmp/work/x86_64-linux/flex-native [0] 894 | [1] /home/mario/src/yocto/build/tmp/work/cortexa9hf-vfp-neon-poky-linux-gnueabi/flex [1] 895 | Option (ENTER to cancel): 1 896 | /home/mario/src/yocto/build/tmp/work/cortexa9hf-vfp-neon-poky-linux-gnueabi/flex 897 | $ pwd 898 | /home/mario/src/yocto/build/tmp/work/cortexa9hf-vfp-neon-poky-linux-gnueabi/flex 899 | .... 900 | 901 | NOTE: the `cd` command requires evaluating the `ye-cd` shell wrapper 902 | that is shipped with `ye`. O.S. Systems' `setup-environment` script 903 | will do that automatically if you have `ye` in your source tree. 904 | 905 | 906 | == Configuration 907 | 908 | `ye` allows you to customize the pager and the editor it uses for 909 | displaying and editing files, respectively. 910 | 911 | The configuration is via environment variables. `ye` uses `YE_PAGER` 912 | and `YE_EDITOR` for pager and editor, respectively. 913 | 914 | For the editor, `ye` first checks if `YE_EDITOR` is set in the 915 | environment. If it is not set, it checks the `EDITOR` environment 916 | variable. If it is not set, it resorts to `emacs`. If `emacs` cannot 917 | be found, you'll get an error. 918 | 919 | For the pager, `ye` first checks if `YE_PAGER` is set in the 920 | environment. If it is not set, it checks the `PAGER` environment 921 | variable. If it is not set, it resorts to `less -N %s`. If `less` 922 | cannot be found, you'll get an error. 923 | 924 | `%s` can be used as a placeholder for the file to act upon. 925 | 926 | 927 | == Requirements 928 | 929 | A Python installation and the directory structure in the layout 930 | created by O.S. System's Yocto Project-based platforms. 931 | 932 | `ye` has been more extensively tested with Python version 2.7.3, but 933 | it should work with other recent Python 2.x versions and with Python 934 | 3.x. 935 | 936 | For the `doc` command, the http://lxml.de/[lxml] module for Python is 937 | required. 938 | 939 | For the `cd` command, a Bourne-compatible shell is required. 940 | 941 | 942 | == Limitations 943 | 944 | Some `ye` commands use `bitbake` behind the scenes, and since 945 | `bitbake` doesn't support running multipl instances in parallel under 946 | the same build directory, some `ye` features may not work while you 947 | are using `bitbake`. 948 | 949 | 950 | == License 951 | 952 | `ye` is distributed under the GNU Affero General Public License. See 953 | the `LICENSE` file for the full license text. 954 | -------------------------------------------------------------------------------- /bb-expand-vars.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # -*- encoding: utf-8 -*- 3 | import os 4 | import sys 5 | 6 | PATH = os.getenv('PATH').split(':') 7 | bitbake_paths = [os.path.join(path, '..', 'lib') 8 | for path in PATH if os.path.exists(os.path.join(path, 'bitbake'))] 9 | if not bitbake_paths: 10 | raise ImportError("Unable to locate bitbake, please ensure PATH is set correctly.") 11 | 12 | sys.path[0:0] = bitbake_paths 13 | 14 | def find_yocto_root(): 15 | def inner_find(dir): 16 | repo_dir = os.path.join(dir, '.repo') 17 | if os.path.exists(repo_dir) and os.path.isdir(repo_dir): 18 | return dir 19 | elif dir == '/': 20 | return False 21 | else: 22 | return inner_find(os.path.dirname(dir)) 23 | BUILDDIR = os.environ.get('BUILDDIR') 24 | if BUILDDIR: 25 | yocto_root = inner_find(BUILDDIR) 26 | else: 27 | yocto_root = inner_find(os.getcwd()) 28 | return yocto_root or die("ERROR: won't search from /.") 29 | 30 | def get_yocto_path(): 31 | types = ['poky', 'openembedded-core', 'oe'] 32 | base = find_yocto_root() 33 | paths = [os.path.join(base, 'sources', t, 'scripts/lib') for t in types] 34 | path = list(filter(os.path.exists, paths)) 35 | if len(path) != 1: 36 | print("ERROR: Can't find scripts path") 37 | sys.exit(1) 38 | sys.path.append(path[0]) 39 | 40 | basepath = '' 41 | 42 | get_yocto_path() 43 | from devtool import setup_tinfoil 44 | 45 | # For printing indented expression expansions 46 | indent_step = 4 47 | 48 | class BBVar(): 49 | def __init__(self, name): 50 | self.name = name 51 | 52 | def __repr__(self): 53 | return 'BBVAR<' + str(self.name) + '>' 54 | 55 | def tokenize_expr(expr): 56 | def next(pos, expr): 57 | next_pos = pos + 1 58 | if next_pos < len(expr): 59 | return expr[next_pos] 60 | return None 61 | tokens = [] 62 | token = '' 63 | depth = 0 64 | for charno, char in enumerate(expr): 65 | if char == '$' and next(charno, expr) == '{': 66 | if token and depth == 0: 67 | tokens.append(token) 68 | token = '' 69 | depth += 1 70 | if char == '}': 71 | if depth == 1: 72 | tokens.append(token + char) 73 | token = '' 74 | else: 75 | token += char 76 | depth -= 1 77 | else: 78 | token += char 79 | if depth != 0: 80 | raise SyntaxError('Unexpected expression depth (> 0) when tokenizing %s' % expr) 81 | if token: 82 | tokens.append(token) 83 | return tokens 84 | 85 | def parse_expr(expr): 86 | if expr[0] == '$': 87 | return BBVar([parse_expr(token) for token in tokenize_expr(expr[2:-1])]) 88 | else: 89 | return expr 90 | 91 | def parse_exprs(exprs): 92 | return [parse_expr(expr) for expr in exprs] 93 | 94 | def unparse_expr(expr): 95 | if isinstance(expr, list): 96 | return ''.join(unparse_expr(exp) for exp in expr) 97 | elif isinstance(expr, BBVar): 98 | if isinstance(expr.name, list): 99 | return ''.join(unparse_expr(exp) for exp in expr.name) 100 | else: 101 | return expr.name 102 | else: 103 | return expr 104 | 105 | def show_expansion(var, val, indent): 106 | margin_spacing = indent - indent_step 107 | if margin_spacing == 0: 108 | margin = '' 109 | else: 110 | margin = ' ' * margin_spacing 111 | print(('%s%s ==> %s' % (margin, unparse_expr(var), val))) 112 | 113 | def get_var_val(var, metadata): 114 | val = None 115 | if var.startswith('@'): 116 | try: 117 | val = eval(var[1:], {'d': metadata}) 118 | except: 119 | val = '' 120 | else: 121 | val = metadata.getVar(var, False) 122 | return val 123 | 124 | def expand_var(var, metadata, indent): 125 | next_indent = indent + indent_step 126 | if isinstance(var, list): 127 | return expand_var(''.join([ expand_var(v, metadata, next_indent) for v in var ]), 128 | metadata, 129 | next_indent) 130 | else: 131 | if isinstance(var, BBVar): 132 | if isinstance(var.name, list): 133 | val = get_var_val(expand_var(var.name, metadata, next_indent), metadata) 134 | exprs = parse_exprs(tokenize_expr(val)) 135 | if filter(lambda e: isinstance(e, BBVar), exprs): 136 | show_expansion(var, val, next_indent) 137 | return expand_vars(exprs, metadata, next_indent) 138 | else: 139 | show_expansion(var.name[0], val, next_indent) 140 | return val 141 | else: 142 | name = var.name 143 | val = get_var_val(var.name, metadata) 144 | show_expansion(name, val, next_indent) 145 | return val 146 | else: 147 | return var 148 | 149 | def expand_vars(vars, metadata, indent=0): 150 | return ''.join([expand_var(v, metadata, indent) for v in vars]) 151 | 152 | def expand_expr(expr, metadata): 153 | return expand_vars(parse_exprs(tokenize_expr(expr)), metadata) 154 | 155 | def show_var_expansions(recipe, var, plumbing_mode=False): 156 | # When plumbing_mode is truthy, var is a list of variables 157 | try: 158 | tinfoil = setup_tinfoil(config_only=True, basepath=basepath) 159 | tinfoil.parseRecipes() 160 | 161 | try: 162 | metadata = tinfoil.parse_recipe(recipe) 163 | except: 164 | sys.exit(1) 165 | 166 | if plumbing_mode: 167 | vars_vals = {} 168 | for v in var: 169 | vars_vals[v] = metadata.getVar(v, True) 170 | return vars_vals 171 | else: 172 | val = metadata.getVar(var, True) 173 | 174 | if val is not None: 175 | print('=== Final value') 176 | print( '%s = %s' % (var, val)) 177 | 178 | print('\n=== Expansion') 179 | expand_expr('${' + var + '}', metadata) 180 | else: 181 | sys.stderr.write('%s: no such variable.\n' % var) 182 | sys.exit(1) 183 | 184 | finally: 185 | tinfoil.shutdown() 186 | 187 | 188 | if __name__ == '__main__': 189 | recipe = sys.argv[1] 190 | var = sys.argv[2] 191 | show_var_expansions(recipe, var) 192 | -------------------------------------------------------------------------------- /format-command-lines.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | import errno 4 | 5 | if len(sys.argv) < 2: 6 | sys.stderr.write('Usage: %s [ ...]' % sys.argv[0]) 7 | sys.exit(1) 8 | 9 | input_file = sys.argv[1] 10 | 11 | modes = sys.argv[2].split(',') # format-calls, apply-replacements 12 | format_calls = 'format-calls' in modes 13 | apply_replacements = 'apply-replacements' in modes 14 | 15 | replacement_args = [] 16 | if len(sys.argv) > 2: 17 | replacement_args = sys.argv[3:] 18 | 19 | 20 | def show(line): 21 | try: 22 | sys.stdout.write(line) 23 | sys.stdout.flush() 24 | except IOError as e: 25 | if e.errno == errno.EPIPE: 26 | input.close() 27 | sys.exit(0) 28 | 29 | input = open(input_file, 'r') 30 | command_line_counter = 0 31 | 32 | if apply_replacements: 33 | replacements = [] # a list because we want to keep order 34 | for arg in replacement_args: 35 | rep = arg.split('=') 36 | if len(rep) == 2: 37 | replacements.append((rep[0], rep[1])) 38 | else: 39 | sys.stderr.write('WARNING: invalid replacement: %s\n' % arg) 40 | 41 | if replacements: 42 | print('===\n=== Replacements made by ye\n===\n') 43 | for orig, rep in replacements: 44 | print('%s => %s' % (orig, rep)) 45 | print('\n' + '=' * 80 + '\n') 46 | 47 | while True: 48 | build_line = input.readline() 49 | if not build_line: 50 | break 51 | 52 | if apply_replacements: 53 | for orig, rep in replacements: 54 | build_line = build_line.replace(orig, rep) 55 | 56 | if format_calls: 57 | tokens = build_line.split() 58 | if len(tokens) > 0: 59 | prev = None 60 | first_token = tokens[0] 61 | 62 | filename = os.path.basename(first_token) 63 | if (filename.endswith('gcc') or 64 | filename.endswith('g++') or 65 | filename.endswith('xgcc') or 66 | filename.endswith('clang') or 67 | filename.endswith('clang++') or 68 | filename.endswith('javac')): 69 | command_line_counter += 1 70 | dashes = '-' * 15 71 | print('%s[ command line %s ]%s' % (dashes, command_line_counter, dashes)) 72 | lines = [first_token] 73 | for token in tokens[1:]: 74 | if prev in ['-o', '-isystem']: 75 | lines[-1] += ' ' + token 76 | else: 77 | lines.append(token) 78 | prev = token 79 | 80 | show(lines[0] + '\n') 81 | for line in lines[1:]: 82 | show(' ' + line + '\n') 83 | else: 84 | show(build_line) 85 | else: 86 | show(build_line) 87 | input.close() 88 | -------------------------------------------------------------------------------- /setup-environment.d/priority: -------------------------------------------------------------------------------- 1 | 7 2 | -------------------------------------------------------------------------------- /setup-environment.d/ye.py: -------------------------------------------------------------------------------- 1 | def __after_init_ye_yocto(): 2 | PLATFORM_ROOT_DIR = os.environ['PLATFORM_ROOT_DIR'] 3 | yedir = os.path.join(PLATFORM_ROOT_DIR, 'sources', 'ye') 4 | os.environ['PATH'] = os.environ['PATH'] + ':' + yedir 5 | 6 | run_after_init(__after_init_ye_yocto) 7 | -------------------------------------------------------------------------------- /ye: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | 3 | ## ye: Yocto Explorer 4 | ## 5 | ## Copyright (C) 2014, 2015, 2017 O.S. Systems Software LTDA 6 | ## 7 | ## This program is free software: you can redistribute it and/or modify 8 | ## it under the terms of the GNU Affero General Public License as 9 | ## published by the Free Software Foundation, either version 3 of the 10 | ## License, or (at your option) any later version. 11 | ## 12 | ## This program is distributed in the hope that it will be useful, 13 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ## GNU Affero General Public License for more details. 16 | ## 17 | ## You should have received a copy of the GNU Affero General Public License 18 | ## along with this program. If not, see . 19 | 20 | ### TODO 21 | # Implement exclusion pattern for grep (option should not clash with git grep's) 22 | 23 | import os 24 | import re 25 | import sys 26 | import time 27 | import glob 28 | import urllib.request, urllib.parse, urllib.error 29 | import locale 30 | import subprocess 31 | 32 | # lxml is required for parsing the documentation XML files 33 | is_lxml_available = True 34 | try: 35 | from lxml import etree 36 | except: 37 | is_lxml_available = False 38 | 39 | encoding = locale.getdefaultlocale()[1] 40 | if not encoding: 41 | sys.stderr.write('WARNING: could not determine locale. Forcing UTF-8.\n') 42 | encoding = 'UTF-8' 43 | 44 | def die(msg): 45 | sys.stderr.write(msg + '\n') 46 | sys.exit(1) 47 | 48 | def is_program_available(program): 49 | progpaths = os.environ['PATH'].split(':') 50 | for dir in progpaths: 51 | progpath = os.path.join(dir, program) 52 | if os.path.isfile(progpath) and os.access(progpath, os.X_OK): 53 | return True 54 | return False 55 | 56 | YE_DIR = os.path.join(os.environ['HOME'], '.ye') 57 | 58 | EDITOR_ALTERNATIVES = [('emacs', '-nw'), 'mg', 'zile', 'qemacs', 'nano', 'vim', 'vi'] 59 | 60 | def find_editor(): 61 | for option in EDITOR_ALTERNATIVES: 62 | editor = None 63 | args = None 64 | if isinstance(option, tuple): 65 | editor = option[0] 66 | args = option[1] 67 | else: 68 | editor = option 69 | if is_program_available(editor): 70 | return '%s %s' % (editor, args) 71 | die('Could not find an editor. Please, set the YE_EDITOR environment variable.') 72 | 73 | YE_PAGER = None 74 | if 'YE_PAGER' in os.environ: 75 | YE_PAGER = os.environ['YE_PAGER'] 76 | elif 'PAGER' in os.environ: 77 | YE_PAGER = os.environ['PAGER'] + ' %s' 78 | else: 79 | YE_PAGER = 'less -N "%s"' 80 | 81 | YE_EDITOR = None 82 | if 'YE_EDITOR' in os.environ: 83 | YE_EDITOR = os.environ['YE_EDITOR'] 84 | elif 'EDITOR' in os.environ: 85 | YE_EDITOR = os.environ['EDITOR'] 86 | else: 87 | YE_EDITOR = find_editor() 88 | YE_EDITOR += ' "%s"' 89 | 90 | BUILDDIR = None 91 | try: 92 | BUILDDIR = os.environ['BUILDDIR'] 93 | except: 94 | pass 95 | 96 | HOME = os.environ['HOME'] 97 | 98 | # `raw_input' has been replaced by `input' in Python 3 99 | try: 100 | input = raw_input 101 | except NameError: 102 | pass 103 | 104 | red = '\x1b[31;1m{}\x1b[0m' 105 | blue = '\x1b[34;1m{}\x1b[0m' 106 | bold = '\033[1m{}\033[0m' 107 | 108 | def colorize_layer(path): 109 | path_parts = path.split('/') 110 | sources_idx = None 111 | try: 112 | sources_idx = path_parts.index('sources') 113 | except ValueError: 114 | return path 115 | if sources_idx < (len(path_parts) - 2): 116 | layer_idx = sources_idx + 1 117 | path_parts[layer_idx] = bold.format(path_parts[layer_idx]) 118 | return '/'.join(path_parts) 119 | 120 | def colorize(text, pattern, color=red, case_sensitive=True, layer=True): 121 | if sys.stdout.isatty(): 122 | if not case_sensitive: 123 | pattern = '(?i)' + pattern 124 | colorized_pattern = re.sub(pattern, 125 | lambda m: color.format(m.group()), text) 126 | if layer: 127 | return colorize_layer(colorized_pattern) 128 | else: 129 | return colorized_pattern 130 | else: 131 | return text 132 | 133 | def paginate(text): 134 | p = subprocess.Popen(['less', '-FRX'], stdin=subprocess.PIPE, close_fds=True) 135 | p.communicate(text.encode(encoding)) 136 | 137 | def download_file(uri, output_file): 138 | dir = os.path.dirname(output_file) 139 | if dir and not os.path.exists(dir): 140 | os.makedirs(dir) 141 | try: 142 | uri_fd = urllib.request.urlopen(uri) 143 | except: 144 | die('Could not download %s. Aborting' % uri) 145 | with open(output_file, 'wb') as output_fd: 146 | output_fd.write(uri_fd.read()) 147 | 148 | def find_yocto_root(): 149 | def inner_find(dir): 150 | repo_dir = os.path.join(dir, '.repo') 151 | if os.path.exists(repo_dir) and os.path.isdir(repo_dir): 152 | return dir 153 | elif dir == '/': 154 | return False 155 | else: 156 | return inner_find(os.path.dirname(dir)) 157 | if BUILDDIR: 158 | yocto_root = inner_find(BUILDDIR) 159 | else: 160 | yocto_root = inner_find(os.getcwd()) 161 | return yocto_root or die("ERROR: won't search from /.") 162 | 163 | 164 | def find_files(basedir, maxdepth=None, pattern='.*'): 165 | depth = 0 166 | re_pattern = re.compile(pattern) 167 | re_skip_pattern = re.compile('.*~$|^\.#|^#.*#$|.*\.pyc$') 168 | results = [] 169 | match_whole_path = '/' in pattern 170 | for root, dirs, files in os.walk(basedir): 171 | dirs[:] = [d for d in dirs if not d[0] == '.'] 172 | depth += 1 173 | if maxdepth and depth > maxdepth: 174 | return results 175 | all_files = None 176 | if match_whole_path: 177 | all_files = [ os.path.join(root, f) for f in dirs + files ] 178 | else: 179 | all_files = dirs + files 180 | for file in all_files: 181 | if not re_skip_pattern.match(file) and re_pattern.match(file): 182 | results.append(os.path.join(root, file)) 183 | return results 184 | 185 | 186 | def parse_choice(choice, valid_shortcuts): 187 | result = None 188 | try: 189 | choice_num = int(choice) 190 | result = (choice_num, None) 191 | except: 192 | pass 193 | if result: 194 | return result 195 | shortcut = choice[-1:] 196 | choice = choice[:-1] 197 | result = (None, None) 198 | try: 199 | choice_num = int(choice) 200 | if not shortcut or shortcut in valid_shortcuts: 201 | result = (choice_num, shortcut) 202 | except: 203 | pass 204 | return result 205 | 206 | 207 | def prompt(options, option_formatter=lambda x: x, valid_shortcuts=[]): 208 | maxopts = len(options) - 1 209 | 210 | def inner_prompt(): 211 | text_options = '' 212 | for i, text in enumerate(options): 213 | text_options += '[%d] %s [%d]\n' % (i, option_formatter(text), i) 214 | paginate(text_options) 215 | print('Option (ENTER to cancel): ') 216 | return input() 217 | 218 | while True: 219 | choice = inner_prompt() 220 | if choice == '': # user cancelled 221 | sys.exit(0) 222 | choice, shortcut = parse_choice(choice, valid_shortcuts) 223 | if choice is not None and choice <= maxopts: 224 | return (choice, shortcut) 225 | 226 | def prompt_action(options): 227 | def inner_prompt(): 228 | for short, text in options: 229 | print('[%s] %s' % (short, text)) 230 | print('Option (ENTER to cancel): ') 231 | return input() 232 | 233 | short_options = [ o[0] for o in options ] 234 | while True: 235 | choice = inner_prompt() 236 | if choice == '': # user cancelled 237 | sys.exit(0) 238 | try: 239 | index = short_options.index(choice) 240 | return index 241 | except: 242 | pass 243 | 244 | def shorten_path(path): 245 | home_pos = path.find(HOME) 246 | if home_pos == 0: 247 | homeless_path = path[len(HOME):] 248 | if homeless_path.startswith('/'): 249 | return '~' + homeless_path 250 | else: 251 | return '~/' + homeless_path 252 | else: 253 | return path 254 | 255 | def find(pattern, basedir, exact, actions): 256 | ''' actions = [('label', 'shortcut', proc) ...] ''' 257 | results = [] 258 | shortcut = None 259 | orig_pattern = pattern 260 | if not exact: 261 | pattern = '.*%s.*' % pattern 262 | for file in find_files(basedir, pattern=pattern): 263 | if not os.path.isdir(file): 264 | results.append(file) 265 | if sys.stdout.isatty(): 266 | if results: 267 | valid_shortcuts = [ a[1] for a in actions ] 268 | if len(results) > 1: 269 | choice, shortcut = prompt(results, 270 | lambda file: colorize(shorten_path(file), 271 | orig_pattern), 272 | valid_shortcuts) 273 | file = results[choice] 274 | else: 275 | file = results[0] 276 | print(colorize(shorten_path(file), orig_pattern)) 277 | if len(actions) == 1: 278 | actions[0][2](file) 279 | return file 280 | if shortcut: 281 | for action in actions: 282 | if action[1] == shortcut: 283 | action[2](file) 284 | else: 285 | action = prompt_action([ (a[1], a[0]) for a in actions ]) 286 | actions[action][2](file) 287 | return file 288 | else: 289 | if len(results) == 1 and len(actions) == 1: 290 | actions[0][2](results[0]) 291 | else: 292 | return results 293 | 294 | def check_builddir(): 295 | if not BUILDDIR: 296 | die("ERROR: Could not determine the Yocto Project's build directory.") 297 | 298 | 299 | def find_workdir(pattern, exact): 300 | check_builddir() 301 | results = [] 302 | orig_pattern = pattern 303 | if not exact: 304 | pattern = '.*%s.*' % pattern 305 | re_pattern = re.compile(pattern) 306 | paths = glob.glob(os.path.join(BUILDDIR, 'tmp', 'work', '*', '*')) 307 | for path in paths: 308 | if os.path.isdir(path): 309 | dir = os.path.basename(path) 310 | if re_pattern.match(dir): 311 | results.append(path) 312 | return results 313 | 314 | 315 | def show_workdir(pattern, exact, plumbing_mode=False): 316 | results = find_workdir(pattern, exact) 317 | if plumbing_mode: 318 | len_results = len(results) 319 | if len_results > 1: 320 | choice, _ = prompt(results) 321 | if choice: 322 | write_plumbing_selection('wd', results[choice]) 323 | elif len_results == 1: 324 | write_plumbing_selection('wd', results[0]) 325 | else: 326 | write_plumbing_selection('wd', None) 327 | else: 328 | for result in results: 329 | print(colorize(result, pattern)) 330 | 331 | 332 | def print_matches(matches, plumbing_cmd=None): 333 | if matches: 334 | dest = None 335 | if plumbing_cmd: 336 | dest = open(os.path.join(YE_DIR, 'plumbing', plumbing_cmd), 'w') 337 | else: 338 | dest = sys.stdout 339 | if matches.__class__.__name__ == 'list': 340 | for match in matches: 341 | dest.write(match.encode(encoding).decode() + '\n') 342 | else: 343 | # a string 344 | dest.write(matches.encode(encoding).decode() + '\n') 345 | if plumbing_cmd: 346 | dest.close() 347 | 348 | 349 | def pkg_view(file): 350 | ext = os.path.splitext(file)[1] 351 | if ext in [ '.deb', '.ipk' ]: 352 | comp_type = os.popen("ar t %s" % file).read() 353 | if 'data.tar.gz' in comp_type: 354 | os.system("ar p %s data.tar.gz | tar tvzf -" % file) 355 | elif 'data.tar.xz' in comp_type: 356 | os.system("ar p %s data.tar.xz | tar tvJf -" % file) 357 | else: 358 | die("ERROR: Compression type not supported for %s" % ext) 359 | elif ext == '.rpm': 360 | os.system("rpm -qlvp %s" % file) 361 | else: 362 | die("ERROR: unsupported package file extension: %s" % ext) 363 | 364 | 365 | def pkg_info(file): 366 | ext = os.path.splitext(file)[1] 367 | if ext in ['.ipk', '.deb']: 368 | os.system("ar p %s control.tar.gz | tar xzf - ./control -O" % file) 369 | elif ext == '.rpm': 370 | os.system("rpm -qip %s" % file) 371 | else: 372 | die("ERROR: unsupported package file extension: %s" % ext) 373 | 374 | 375 | def pkg_scripts(file): 376 | ext = os.path.splitext(file)[1] 377 | if ext in ['.ipk', '.deb']: 378 | os.system("ar p %s control.tar.gz | tar tzf -" % file) 379 | else: 380 | die("ERROR: unsupported package file extension: %s" % ext) 381 | 382 | 383 | def pkg_extract(pkg_file, file, from_control): 384 | out_dir, ext = os.path.splitext(pkg_file) 385 | out_dir = os.path.basename(out_dir) 386 | if os.path.exists(out_dir): 387 | die("%s already exists. Won't clobber. Aborting." % out_dir) 388 | os.makedirs(out_dir) 389 | if ext in [ '.deb', '.ipk' ]: 390 | comp_type = os.popen("ar t %s" % pkg_file).read() 391 | if 'data.tar.gz' in comp_type: 392 | tarball = 'data.tar.gz' 393 | if from_control: 394 | tarball = 'control.tar.gz' 395 | status = os.system("ar p %s %s | tar xzf - %s -C %s" % (pkg_file, tarball, file, out_dir)) 396 | if not status: 397 | print('Extracted to %s' % out_dir) 398 | if 'data.tar.xz' in comp_type: 399 | tarball = 'data.tar.xz' 400 | if from_control: 401 | tarball = 'control.tar.gz' 402 | status = os.system("ar p %s %s | tar xJf - %s -C %s" % (pkg_file, tarball, file, out_dir)) 403 | if not status: 404 | print('Extracted to %s' % out_dir) 405 | elif ext == '.rpm': 406 | if is_program_available('rpm2cpio'): 407 | os.chdir(out_dir) 408 | status = os.system("rpm2cpio %s | cpio -id %s" % (pkg_file, file)) 409 | if not status: 410 | print('Extracted to %s' % out_dir) 411 | else: 412 | die('ERROR: This operation requires the "rpm2cpio" program to be installed.') 413 | else: 414 | die("ERROR: unsupported package file extension: %s" % ext) 415 | 416 | 417 | def human_readable_command_lines(file, raw, apply_replacements): 418 | formatter = os.path.join(os.path.dirname(os.path.realpath(__file__)), 419 | 'format-command-lines.py') 420 | if apply_replacements: 421 | expand_mod = __import__('bb-expand-vars') 422 | check_builddir() 423 | os.chdir(BUILDDIR) 424 | recipe = os.path.basename(os.path.dirname(os.path.dirname(os.path.dirname(file)))) 425 | ## Warning: the order of the variables below is important! 426 | ## Beware of unintended substring replacements. 427 | vars = ['B', 428 | 'S', 429 | 'WORKDIR', 430 | 'TMPDIR', 431 | 'HOME'] 432 | replacements = expand_mod.show_var_expansions(recipe, vars, True) 433 | replacement_args = ' '.join(map(lambda a: '\'%s=$%s\'' % (replacements[a], a), vars)) 434 | modes = 'apply-replacements' 435 | if not raw: 436 | modes += ',format-calls' 437 | os.system('python %s "%s" %s %s | less' % (formatter, file, modes, replacement_args)) 438 | else: 439 | if raw: 440 | view_action[2](file) 441 | else: 442 | os.system('python %s "%s" format-calls | less' % (formatter, file)) 443 | 444 | human_readable_command_lines_action = ('View', 'v', human_readable_command_lines) 445 | 446 | view_action = ('View', 'v', lambda file: os.system(YE_PAGER % file)) 447 | 448 | edit_action = ('Edit', 'e', lambda file: os.system(YE_EDITOR % file)) 449 | 450 | pkg_view_action = ('View', 'v', pkg_view) 451 | 452 | pkg_info_action = ('Info', 'i', pkg_info) 453 | 454 | pkg_scripts_action = ('Scripts', 's', pkg_scripts) 455 | 456 | def pkg_extract_action(file, from_control): 457 | return ('Extract', 'x', lambda pkg: pkg_extract(pkg, file, from_control)) 458 | 459 | 460 | def list_temp_files(file_type, recipe_pattern, log_pattern, exact, raw, apply_replacements): 461 | wds = find_workdir(recipe_pattern, exact) 462 | if not wds: 463 | sys.exit(1) 464 | if len(wds) > 1: 465 | choice, _ = prompt(wds, 466 | lambda path: os.path.join(os.path.basename(os.path.dirname(path)), 467 | os.path.basename(path))) 468 | wd = wds[choice] 469 | else: 470 | wd = wds[0] 471 | if not os.path.isdir(wd): 472 | sys.exit(1) 473 | if file_type == 'log': 474 | print('=== Showing logs for %s' % os.path.basename(wd)) 475 | else: 476 | print('=== Showing run scripts for %s' % os.path.basename(wd)) 477 | version_dirs = glob.glob(os.path.join(wd, '*')) 478 | if len(version_dirs) > 1: 479 | choice, _ = prompt(version_dirs, os.path.basename) 480 | version_dir = version_dirs[choice] 481 | else: 482 | version_dir = version_dirs[0] 483 | log_dir = os.path.join(version_dir, 'temp') 484 | all_files = find_files(log_dir, 485 | pattern='%s\..*%s.*' % (file_type, log_pattern)) 486 | logs = [ f for f in all_files if os.path.islink(f) ] 487 | log = None 488 | if logs: 489 | if len(logs) > 1: 490 | choice, _ = prompt(logs, os.path.basename) 491 | log = logs[choice] 492 | else: 493 | log = logs[0] 494 | print('=== %s' % log) 495 | human_readable_command_lines_action[2](log, raw, apply_replacements) 496 | print(log_dir) 497 | 498 | 499 | def list_logs(recipe_pattern, log_pattern, exact, raw, apply_replacements): 500 | list_temp_files('log', recipe_pattern, log_pattern, exact, raw, apply_replacements) 501 | 502 | 503 | def list_run_scripts(recipe_pattern, log_pattern, exact): 504 | list_temp_files('run', recipe_pattern, log_pattern, exact, True, False) 505 | 506 | def grep(args, actions, case_sensitive, dir=None, git=False): 507 | if git and dir: 508 | os.chdir(dir) 509 | p = subprocess.Popen(['git', 'grep'] + args, stdout=subprocess.PIPE) 510 | elif dir: 511 | os.chdir(dir) 512 | p = subprocess.Popen(['grep', '-r'] + args, stdout=subprocess.PIPE) 513 | else: 514 | p = subprocess.Popen(['repo', 'grep'] + args, stdout=subprocess.PIPE) 515 | regex_pattern = [ arg for arg in args if not arg.startswith('-') ] 516 | if not regex_pattern: 517 | die('Could not determine the pattern for grep.') 518 | if len(regex_pattern) > 1: 519 | die('Multiple patterns for grep is not supported.') 520 | regex_pattern = regex_pattern[0] 521 | output = p.communicate()[0] 522 | results = output.decode(encoding).split('\n')[:-1] # the last line is always empty 523 | if sys.stdout.isatty(): 524 | shortcut = None 525 | if len(results) == 0: 526 | return None 527 | elif len(results) > 1: 528 | choice, shortcut = prompt(results, 529 | option_formatter=lambda o: colorize(o, 530 | regex_pattern, 531 | case_sensitive=case_sensitive), 532 | valid_shortcuts=['v', 'e']) 533 | match = results[choice] 534 | else: 535 | match = results[0] 536 | actions = None 537 | if shortcut == 'v': 538 | actions = [view_action] 539 | elif shortcut == 'e': 540 | actions = [edit_action] 541 | else: 542 | actions = [view_action, edit_action] 543 | file = match.split(':')[0] # let's hope filenames don't contain ':' 544 | return find(file, 545 | dir or os.path.join(find_yocto_root(), 'sources'), 546 | False, 547 | actions) 548 | else: 549 | return results 550 | 551 | def git_log_grep(pattern, max_commits, case_sensitive): 552 | root_dir = find_yocto_root() 553 | os.chdir(root_dir) 554 | repos = [] 555 | repop = subprocess.Popen(['repo', 'list'], stdout=subprocess.PIPE) 556 | repos = repop.communicate()[0].strip() 557 | repos = [ line.split(':')[0].strip() for line in repos.decode(encoding).split('\n') ] 558 | repo_paths = [ os.path.realpath(os.path.join(root_dir, repo)) for repo in repos ] 559 | 560 | results = {} 561 | for repo_path in repo_paths: 562 | results[repo_path] = None 563 | os.chdir(repo_path) 564 | gitlog = subprocess.Popen(('git', 'log', '-n', str(max_commits), '--oneline'), 565 | stdout=subprocess.PIPE) 566 | if case_sensitive: 567 | grep_cmd = ('grep', pattern) 568 | else: 569 | grep_cmd = ('grep', '-i', pattern) 570 | grep = subprocess.Popen(grep_cmd, 571 | stdin=gitlog.stdout, 572 | stdout=subprocess.PIPE) 573 | gitlog.wait() 574 | out = grep.communicate()[0] 575 | if out: 576 | results[repo_path] = out.strip().split(b'\n') 577 | 578 | sources_dir = os.path.realpath(os.path.join(root_dir, 'sources')) 579 | options = [] 580 | for repo_path, commits in results.items(): 581 | repo_dir = repo_path[len(sources_dir) + 1:] # drop sources_dir 582 | if commits: 583 | for commit in commits: 584 | options.append('%s %s' % (repo_dir, commit)) 585 | 586 | if sys.stdout.isatty(): 587 | shortcut = None 588 | if len(options) == 0: 589 | return None 590 | elif len(options) > 1: 591 | choice, shortcut = prompt(options, 592 | option_formatter = 593 | lambda o: colorize(colorize(o, 594 | pattern, 595 | case_sensitive=case_sensitive), 596 | '^[^ ]+ ', 597 | blue)) 598 | match = options[choice] 599 | else: 600 | match = options[0] 601 | 602 | repo_dir, commit_hash = match.split()[0:2] 603 | repo_path = os.path.join(sources_dir, repo_dir) 604 | os.chdir(repo_path) 605 | os.system('git show %s' % commit_hash) 606 | else: 607 | for option in options: 608 | print(option) 609 | 610 | def grep_buildhistory(args): 611 | check_builddir() 612 | bhdir = os.path.join(BUILDDIR, 'buildhistory') 613 | if not os.path.isdir(bhdir): 614 | die('Could not find the buildhistory directory at %s.' % bhdir) 615 | print_matches(grep(args, 616 | [view_action, edit_action], 617 | '-i' in args, 618 | dir=bhdir, 619 | git=True)) 620 | 621 | def buildhistory(revisions, raw_diff): 622 | bhdir = os.path.join(BUILDDIR, 'buildhistory') 623 | if not os.path.isdir(bhdir): 624 | die('Could not find the buildhistory directory at %s.' % bhdir) 625 | rev_window = 'HEAD~%d..HEAD' % revisions 626 | if raw_diff: 627 | os.system('cd %s && git diff %s' % (bhdir, rev_window)) 628 | else: 629 | os.system('buildhistory-diff -p %s %s' % (bhdir, rev_window)) 630 | 631 | def doc(pattern, exact): 632 | if not is_lxml_available: 633 | die('You need the lxml Python module for documentation.') 634 | 635 | def remove_duplicate_spaces(text): 636 | return re.sub(' +', ' ', text) 637 | 638 | def refill_text(text): 639 | lines = [ line for line in text.split('\n') ] 640 | return(remove_duplicate_spaces(' '.join(lines))) 641 | 642 | def parse_itemized_list(l): 643 | text = [] 644 | for item in l.findall('listitem'): 645 | text.append('* ' + '\n'.join([ parse_paragraph(p) for p in item.findall('para') ])) 646 | return '\n\n' + '\n\n'.join(text) 647 | 648 | def parse_children(elt, sep=''): 649 | if elt.text: 650 | return elt.text 651 | else: 652 | children = elt.getchildren() 653 | if elt.tag in ['link', 'ulink'] and not children: 654 | return elt.get('url') 655 | else: 656 | return sep.join(map(parse_paragraph, children)) 657 | 658 | def parse_paragraph(p): 659 | text = [] 660 | if p.text: 661 | text.append(refill_text(p.text)) 662 | for elt in p: 663 | if elt.tag == 'filename': 664 | text.append('`%s`' % parse_children(elt)) 665 | elif elt.tag == 'listitem': 666 | text.append('\n\n* %s' % parse_children(elt, sep='\n')) 667 | elif elt.tag == 'itemizedlist': 668 | text.append(parse_itemized_list(elt)) 669 | elif elt.tag == 'literallayout': 670 | text.append('\n' + elt.text + '\n') 671 | elif elt.tag in ['link', 'ulink']: 672 | text.append(parse_children(elt)) 673 | elif elt.tag == 'note': 674 | text.append('\n\n' + parse_paragraph(elt)) 675 | elif elt.tag == 'title': 676 | text.append('\n\n' + elt.text + ': ') 677 | else: 678 | parse_paragraph(elt) 679 | if elt.tail: 680 | text.append(refill_text(elt.tail)) 681 | if text: # FIXME: this is a hack, should be fixed 682 | return ''.join([text[0].lstrip()] + text[1:]) 683 | else: 684 | return '' 685 | 686 | def show_doc(var, doc): 687 | print('\n=== ' + var) 688 | print(doc) 689 | 690 | doc_data_dir = os.path.join(YE_DIR, 'doc-data') 691 | ref_variables_xml = os.path.join(doc_data_dir, 'ref-manual', 'ref-variables.xml') 692 | 693 | # Check if we need to update documentation data 694 | update_window = 7 * 24 * 3600 # 7 days 695 | # We use documentation from master 696 | doc_base_uri = 'https://git.yoctoproject.org/cgit/cgit.cgi/yocto-docs/plain/documentation' 697 | if (not os.path.exists(ref_variables_xml) or 698 | os.stat(ref_variables_xml).st_mtime < time.time() - update_window): 699 | print('Updating documentation data...') 700 | download_file('%s/poky.ent' % doc_base_uri, 701 | os.path.join(doc_data_dir, 'poky.ent')) 702 | download_file('%s/ref-manual/ref-variables.xml' % doc_base_uri, 703 | ref_variables_xml) 704 | 705 | tree = etree.parse(ref_variables_xml) 706 | glossentries = tree.findall('//glossentry') 707 | docs = {} 708 | 709 | orig_pattern = pattern 710 | if not exact: 711 | pattern = '.*%s.*' % pattern 712 | 713 | for e in glossentries: 714 | glossterm = e.find('glossterm').text 715 | if re.compile(pattern).match(glossterm): 716 | glossdef = e.find('glossdef') 717 | paragraphs = glossdef.findall('para') 718 | text = [] 719 | for p in paragraphs: 720 | text.append(parse_paragraph(p)) 721 | docs[glossterm] = '\n\n'.join(text) 722 | if docs: 723 | options = list(docs.keys()) 724 | if len(options) == 1: 725 | show_doc(options[0], docs[options[0]]) 726 | elif sys.stdout.isatty(): 727 | choice, _ = prompt(options, 728 | lambda var: colorize(shorten_path(var), 729 | orig_pattern)) 730 | show_doc(options[choice], docs[options[choice]]) 731 | else: 732 | for o in options: 733 | print(o) 734 | else: 735 | die('No documentation entry for "%s".' % orig_pattern) 736 | 737 | 738 | def write_plumbing_selection(cmd, val): 739 | plumbing_selection_dir = os.path.join(YE_DIR, 'plumbing') 740 | cmd_file = os.path.join(plumbing_selection_dir, cmd) 741 | if val: 742 | if not os.path.isdir(plumbing_selection_dir): 743 | os.makedirs(plumbing_selection_dir) 744 | fd = open(cmd_file, 'w') 745 | if isinstance(val, dict): 746 | for var, value in list(val.items()): 747 | fd.write('%s=%s\n' % (var, value)) 748 | else: 749 | print(val) 750 | fd.write(val + '\n') 751 | fd.close() 752 | else: 753 | if os.path.exists(cmd_file): 754 | os.remove(cmd_file) 755 | 756 | 757 | def handle_plumbing(args): 758 | '''Plumbing is a hack to make the `cd' command possible. The ye-cd 759 | script must be evaluated on the user environment to define a ye 760 | shell function. This function will check if the command (first 761 | argument) is `cd' and will handle its arguments accordingly. If 762 | the command is not `cd' it will dispatch the command to ye. In 763 | case the command is `cd', the ye shell function may need some 764 | information from ye -- that's why the "plumbing" mode exists. In 765 | the plumbing mode, ye will receive a command from the ye shell 766 | function (plumbing []) and will write the results to 767 | YE_DIR/plumbing/, so that the ye shell function can use them 768 | upon ye's termination. 769 | ''' 770 | if args: 771 | cmd = args[0] 772 | cmd_args = args[1:] 773 | exact = False 774 | if '-e' in cmd_args: 775 | exact = True 776 | cmd_args.remove('-e') 777 | if cmd == 'wd': 778 | if cmd_args: 779 | if os.path.isdir(os.path.join(BUILDDIR, 'tmp', 'work')): 780 | show_workdir(cmd_args[0], exact, True) 781 | else: 782 | die('plumbing wd: missing argument.') 783 | elif cmd == 'topdir': 784 | print(find_yocto_root()) 785 | elif cmd == 'x': 786 | if cmd_args: 787 | expand_mod = __import__('bb-expand-vars') 788 | os.chdir(BUILDDIR) 789 | val = expand_mod.show_var_expansions('core-image-minimal', 790 | cmd_args, 791 | True) 792 | if val: 793 | write_plumbing_selection('x', val) 794 | else: 795 | die('plumbing x: missing argument.') 796 | elif cmd == 'find': 797 | print_matches(find(cmd_args[0], 798 | os.path.join(find_yocto_root(), 'sources'), 799 | exact, 800 | [('Print', 'p', lambda file: print(file))]), 801 | plumbing_cmd=cmd) 802 | else: 803 | die('plumbing: invalid command: %s' % cmd) 804 | else: 805 | die('plumbing requires an argument.') 806 | 807 | 808 | def usage(exit_code=None, cmd=None): 809 | printer = None 810 | if exit_code is not None and exit_code != 0: 811 | printer = sys.stderr.write 812 | else: 813 | printer = sys.stdout.write 814 | printer('''Usage: %s [ ] 815 | 816 | f [-e] 817 | find [-e] 818 | Locate paths (in the "sources" directory) that match the given 819 | expression . is case insensitive and implicitly 820 | surrounded by '.*'. -e disables the implicit use of '.*' around 821 | the given . Note that, unless contains /, matching 822 | is attempted on filenames only (not on dirnames). If 823 | contains /, matching is attempted on the full path. 824 | 825 | v [-e] 826 | view [-e] 827 | Shortcut to find & view. If multiple files are found, a prompt for 828 | files will be displayed (but not for actions). 829 | 830 | e [-e] 831 | edit [-e] 832 | Shortcut to find & edit. If multiple files are found, a prompt for 833 | files will be displayed (but not for actions). 834 | 835 | sf [-e] 836 | sysroot-find [-e] 837 | Locate paths (in the "sysroots" directory) that match the given 838 | expression . is case insensitive and implicitly 839 | surrounded by '.*'. -e disables the implicit use of '.*' around 840 | the given . Note that, unless contains /, matching 841 | is attempted on filenames only (not on dirnames). If 842 | contains /, matching is attempted on the full path. 843 | 844 | wsf [-e] 845 | work-shared-find [-e] 846 | Similar to sysroot-find, but instead of searching in the sysroots 847 | directories, search in the work-shared directory. 848 | 849 | pf [-e] 850 | pkg-find [-e] 851 | Like 'find', but for packages. 852 | 853 | pv [-e] 854 | pkg-view [-e] 855 | Shortcut to pkg-find & view. If multiple packages are found, a 856 | prompt for packages will be displayed (but not for actions). 857 | 858 | pi [-e] 859 | pkg-info [-e] 860 | Shortcut to pkg-find & info. If multiple packages are found, a 861 | prompt for packages will be displayed (but not for actions). 862 | 863 | ps [-e] 864 | pkg-scripts [-e] 865 | List scripts for package that matches . In case of multiple 866 | matches, ye will prompt for a specific package. is case 867 | insensitive and implicitly surrounded by '.*'. -e disables the 868 | implicit use of '.*' around the given . 869 | 870 | px [-e] [-c] [] 871 | pkg-extract [-e] [-c] [] 872 | Extract package that matches . In case of multiple matches, 873 | ye will prompt for a specific package. is case insensitive 874 | and implicitly surrounded by '.*'. -e disables the implicit use 875 | of '.*' around the given . 876 | If is provided, ye will extract only, otherwise the 877 | whole package content will be extracted to a directory named after 878 | the package filename (without extension). must match the exact 879 | file name in the package (usually starts with ./). 880 | -c is specific to .deb and .ipk packages -- ye will extract files 881 | from the control.tar.gz tarball in packages. 882 | 883 | wd [-e] 884 | workdir [-e] 885 | Locate the Yocto Project's workdir for . is 886 | implicitly surrounded by '.*', unless -e is provided. 887 | 888 | l [-e] [-H] [-R] [] 889 | log [-e] [-H] [] 890 | Show the log files for . -e is only applied to . is always implicitly surrounded by '.*', 892 | if provided. If -H ("human readable") is given on the command 893 | line, ye will try to make the lines that contain calls to 894 | clang/clang++/gcc/g++ look more readable. If -R is provided, ye 895 | will apply some text replacements to make the output more 896 | readable. Currently, ye reverse expands some common variables 897 | whose expansion pollutes log files with long paths. The following 898 | variables are reverse expanded: 899 | * $B 900 | * $S 901 | * $WORKDIR 902 | * $TMPDIR 903 | * $HOME 904 | 905 | r [-e] [] 906 | run [-e] [] 907 | Show the log files for . -e is only applied to 908 | . is always implicitly 909 | surrounded by '.*', if provided. 910 | 911 | g 912 | grep 913 | Run 'repo grep '. 914 | 915 | sg 916 | sysroot-grep 917 | Run 'grep -r $BUILDDIR/tmp/sysroots-components/$MACHINE'. 918 | 919 | glg [-n ] [-i] 920 | git-log-grep [-n ] [-i] 921 | Run "git log -n --oneline | grep " on all the 922 | repositories and prompt the user for the commit to show. 923 | If -n is not provided, 1000 will be used. If -i is provided, search 924 | will be case insensitive. 925 | 926 | gbh [] 927 | grep-buildhistory [] 928 | Run "git grep [] " in the buildhistory directory. 929 | 930 | bh [-d] 931 | buildhistory [-d] 932 | Show changes in buildhistory (a positive integer). 933 | If -d is given, show the raw git diff output. 934 | 935 | d [-e] 936 | doc [-e] 937 | Search variable names in the reference manual that match the given 938 | expression and show the documentation for the selected 939 | match. is case insensitive and implicitly surrounded by 940 | '.*'. -e disables the implicit use of '.*' around the given 941 | . 942 | 943 | x 944 | expand 945 | Expand BitBake's variable in the context of and 946 | show the final value and the recursive expansion of all variables 947 | and expressions involved. 948 | 949 | cd [] 950 | Change to . The following options are 951 | available: 952 | 953 | top 954 | Change to project's TOPDIR 955 | 956 | wd [] 957 | Change to 's WORKDIR or to BUILDDIR/tmp/deploy/work if 958 | is not provided 959 | 960 | bd 961 | Change to BUILDDIR 962 | 963 | bh 964 | Change to the buildhistory directory 965 | 966 | sd 967 | Change to the sysroot directory for MACHINE 968 | 969 | src [] 970 | Change to 's source dir or to TOPDIR/sources 971 | if is not provided 972 | 973 | img 974 | Change to BUILDDIR/tmp/deploy/MACHINE/image/ 975 | 976 | pkg 977 | Change to BUILDDIR/tmp/deploy/PKG_TYPE/image/ 978 | 979 | manifest 980 | Change to TOPDIR/.repo/manifests 981 | 982 | When called without arguments, ye cd will change to BUILDDIR. 983 | 984 | To use this feature, source'ing the ye-cd shell helper is required. 985 | ''' % os.path.basename(sys.argv[0])) 986 | if exit_code is not None: 987 | sys.exit(exit_code) 988 | 989 | 990 | def main(args): 991 | if not args: 992 | usage(1) 993 | if '-h' in args or '-help' in args or '--help' in args: 994 | usage(0) 995 | cmd = args[0] 996 | cmd_args = args[1:] 997 | 998 | if cmd == 'cd': 999 | yecd = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'ye-cd') 1000 | die('To use this feature you need to evaluate %s on the current environment (e.g., . %s).' % 1001 | (yecd, yecd)) 1002 | elif cmd in ['bh', 'buildhistory']: 1003 | check_builddir() 1004 | raw_diff = False 1005 | if '-d' in cmd_args: 1006 | raw_diff = True 1007 | cmd_args.remove('-d') 1008 | if len(cmd_args) != 1: 1009 | usage(1) 1010 | revisions = None 1011 | try: 1012 | revisions = int(cmd_args[0]) 1013 | except: 1014 | die('The argument to -d must be a positive integer.') 1015 | if revisions < 0: 1016 | die('The argument to -d must be a positive integer.') 1017 | buildhistory(revisions, raw_diff) 1018 | elif cmd == 'plumbing': 1019 | handle_plumbing(cmd_args) 1020 | elif cmd in ['x', 'expand']: 1021 | if len(cmd_args) != 2: 1022 | usage(1) 1023 | else: 1024 | check_builddir() 1025 | expand_mod = __import__('bb-expand-vars') 1026 | os.chdir(BUILDDIR) 1027 | expand_mod.show_var_expansions(cmd_args[0], cmd_args[1]) 1028 | elif cmd in ['gbh', 'grep-buildhistory']: 1029 | grep_buildhistory(cmd_args) 1030 | elif cmd in ['f', 'find', 'v', 'view', 'e', 'edit', 'sf', 'sysroot-find', 1031 | 'wd', 'workdir', 'pf', 'pkg-find', 'pv', 'pkg-view', 1032 | 'pi', 'pkg-info', 'px', 'pkg-extract', 'ps', 'pkg-scripts', 1033 | 'l', 'log', 'r', 'run', 'g', 'grep', 'sg', 'sysroot-grep', 1034 | 'glg', 'git-log-grep', 'd', 'doc', 'wsf', 'work-shared-find']: 1035 | exact = False 1036 | raw = True 1037 | apply_replacements = False 1038 | from_control = False 1039 | num_commits = 1000 1040 | case_sensitive = True 1041 | if '-e' in cmd_args: 1042 | exact = True 1043 | cmd_args.remove('-e') 1044 | if '-H' in cmd_args: 1045 | raw = False 1046 | cmd_args.remove('-H') 1047 | if '-R' in cmd_args: 1048 | apply_replacements = True 1049 | cmd_args.remove('-R') 1050 | if '-c' in cmd_args: 1051 | from_control = True 1052 | cmd_args.remove('-c') 1053 | if '-i' in cmd_args: 1054 | case_sensitive = False 1055 | if cmd in ['glg', 'git-log-grep']: 1056 | cmd_args.remove('-i') 1057 | should_die = False 1058 | try: 1059 | npos = cmd_args.index('-n') 1060 | if len(cmd_args) >= npos: 1061 | try: 1062 | num_commits = int(cmd_args[npos + 1]) 1063 | del cmd_args[npos] # remove -n 1064 | del cmd_args[npos] # remove the numeric arg 1065 | except: 1066 | should_die = True 1067 | else: 1068 | should_die = True 1069 | except: 1070 | pass 1071 | if should_die: 1072 | die("git-log-grep's -n parameter requires a positive integer as argument.") 1073 | if len(cmd_args) < 1: 1074 | usage(1) 1075 | else: 1076 | pattern = cmd_args[0] 1077 | if cmd_args: 1078 | if cmd in ['g', 'grep']: 1079 | print_matches(grep(cmd_args, 1080 | [view_action, edit_action], 1081 | case_sensitive)) 1082 | elif cmd in ['glg', 'git-log-grep']: 1083 | check_builddir() 1084 | git_log_grep(pattern, num_commits, case_sensitive) 1085 | elif cmd in ['sg', 'sysroot-grep']: 1086 | check_builddir() 1087 | expand_mod = __import__('bb-expand-vars') 1088 | os.chdir(BUILDDIR) 1089 | val = expand_mod.show_var_expansions('core-image-minimal', 1090 | ['MACHINE'], 1091 | True) 1092 | if val: 1093 | machine = val['MACHINE'] 1094 | else: 1095 | die('Could not determine MACHINE.') 1096 | sysroot_dir = os.path.join(BUILDDIR, 'tmp', 'sysroots-components', machine) 1097 | print_matches(grep(cmd_args, 1098 | [view_action, edit_action], 1099 | case_sensitive, 1100 | sysroot_dir)) 1101 | elif cmd in ['f', 'find', 'v', 'view', 'e', 'edit']: 1102 | actions = None 1103 | if cmd in ['v', 'view']: 1104 | actions = [view_action] 1105 | elif cmd in ['e', 'edit']: 1106 | actions = [edit_action] 1107 | else: 1108 | actions = [view_action, edit_action] 1109 | print_matches(find(pattern, 1110 | os.path.join(find_yocto_root(), 'sources'), 1111 | exact, 1112 | actions)) 1113 | elif cmd in ['sf', 'sysroot-find', 'wsf', 'work-shared-find']: 1114 | check_builddir() 1115 | if cmd in ['sf', 'sysroot-find']: 1116 | search_dir = os.path.join(BUILDDIR, 'tmp', 'sysroots-components') 1117 | else: 1118 | search_dir = os.path.join(BUILDDIR, 'tmp', 'work-shared') 1119 | if os.path.isdir(search_dir): 1120 | print_matches(find(pattern, 1121 | search_dir, 1122 | exact, 1123 | [view_action, edit_action])) 1124 | elif cmd in ['wd', 'workdir']: 1125 | check_builddir() 1126 | if os.path.isdir(os.path.join(BUILDDIR, 'tmp', 'work')): 1127 | show_workdir(pattern, exact) 1128 | elif cmd in ['d', 'doc']: 1129 | doc(pattern, exact) 1130 | elif cmd in ['pf', 'pkg-find', 'pv', 'pkg-view', 'pi', 'pkg-info', 1131 | 'px', 'pkg-extract', 'ps', 'pkg-scripts']: 1132 | check_builddir() 1133 | deploy_dir = os.path.join(BUILDDIR, 'tmp', 'deploy') 1134 | pkg_dirs = [ os.path.join(deploy_dir, fmt) for fmt in ['deb', 'ipk', 'rpm'] ] 1135 | pkg_dirs = [ d for d in pkg_dirs if os.path.isdir(d) ] 1136 | pkg_dir = None 1137 | file_to_extract = '' 1138 | if not pkg_dirs: 1139 | sys.exit(0) 1140 | if len(pkg_dirs) > 1: 1141 | fmts = [ os.path.basename(dir) for dir in pkg_dirs ] 1142 | choice = prompt_action([ (fmt[0], fmt) for fmt in fmts ]) 1143 | pkg_dir = pkg_dirs[choice] 1144 | else: 1145 | pkg_dir = pkg_dirs[0] 1146 | actions = None 1147 | if cmd in ['pv', 'pkg-view']: 1148 | actions = [pkg_view_action] 1149 | elif cmd in ['pi', 'pkg-info']: 1150 | actions = [pkg_info_action] 1151 | elif cmd in ['ps', 'pkg-scripts']: 1152 | actions = [pkg_scripts_action] 1153 | elif cmd in ['px', 'pkg-extract']: 1154 | if len(cmd_args) > 1: 1155 | file_to_extract = cmd_args[1] 1156 | actions = [pkg_extract_action(file_to_extract, from_control)] 1157 | else: 1158 | actions = [pkg_view_action, 1159 | pkg_info_action, 1160 | pkg_scripts_action, 1161 | pkg_extract_action(file_to_extract, from_control)] 1162 | print_matches(find(pattern, pkg_dir, exact, actions)) 1163 | elif cmd in ['l', 'log', 'r', 'run']: 1164 | log_pattern = '.*' 1165 | if len(cmd_args) > 1: 1166 | log_pattern = cmd_args[1] 1167 | if cmd in ['l', 'log']: 1168 | list_logs(pattern, log_pattern, exact, raw, apply_replacements) 1169 | else: 1170 | list_run_scripts(pattern, log_pattern, exact) 1171 | else: usage(1) 1172 | else: 1173 | usage(1) 1174 | 1175 | 1176 | main(sys.argv[1:]) 1177 | -------------------------------------------------------------------------------- /ye-cd: -------------------------------------------------------------------------------- 1 | # -*- shell-script -*- 2 | 3 | # If ye-cd has been source'd already, YE_SCRIPT will be in the 4 | # environment, so we should not re-source it, unless YE_FORCE_RELOAD 5 | # is set. 6 | if [ -n "$YE_SCRIPT" ] && [ ! -n "$YE_FORCE_RELOAD" ]; then 7 | cat <&2 8 | ye-cd has already been source'd. If you really want to re-evaluate it, 9 | set the YE_FORCE_RELOAD environment variable and source it again. 10 | EOF 11 | return 12 | fi 13 | 14 | YE_SCRIPT=`which ye` 15 | if [ $? -ne 0 ]; then 16 | echo "ERROR: could not find ye (is it in \$PATH?)." >&2 17 | return 18 | fi 19 | 20 | export YE_SCRIPT 21 | 22 | YE_PLUMBING_DIR=$HOME/.ye/plumbing 23 | 24 | yecd_error() { 25 | echo "ERROR: " $* >&2 26 | } 27 | 28 | yecd_get_bb_var() { 29 | if [ -e "$YE_PLUMBING_DIR/x" ]; then 30 | awk -F= "/^$1/"' {print $2}' $YE_PLUMBING_DIR/x 31 | else 32 | yecd_error "yecd_get_bb_var: could not determine $1." 33 | fi 34 | } 35 | 36 | ye() { 37 | 38 | if [ "$1" != "cd" ]; then 39 | $YE_SCRIPT "$@" 40 | return $? 41 | fi 42 | 43 | shift 44 | 45 | if [ -z "$BUILDDIR" ]; then 46 | yecd_error "BUILDDIR is not set" 47 | return 1 48 | fi 49 | 50 | local dir_shortcut=$1 51 | local topdir 52 | 53 | case $dir_shortcut in 54 | "top"|"topdir") 55 | topdir=`$YE_SCRIPT plumbing topdir` 56 | [ $? -eq 0 ] && cd $topdir 57 | ;; 58 | "wd"|"work"|"workdir") 59 | local recipe=$2 60 | if [ -z "$recipe" ]; then 61 | cd $BUILDDIR/tmp/work/ 62 | else 63 | $YE_SCRIPT plumbing wd "$recipe" 64 | if [ -e "$YE_PLUMBING_DIR/wd" ]; then 65 | cd `cat $YE_PLUMBING_DIR/wd` 66 | fi 67 | fi 68 | ;; 69 | "bd"|"build"|"builddir") 70 | cd $BUILDDIR 71 | ;; 72 | "bh"|"buildhistory") 73 | cd $BUILDDIR/buildhistory 74 | ;; 75 | "sd"|"sysroot"|"sysrootdir") 76 | $YE_SCRIPT plumbing x MACHINE 77 | local machine=`yecd_get_bb_var MACHINE | tr - _` 78 | [ -n "$machine" ] && cd $BUILDDIR/tmp/sysroots-components/$machine 79 | ;; 80 | "src"|"sources") 81 | local recipe=$2 82 | if [ -z "$recipe" ]; then 83 | topdir=`$YE_SCRIPT plumbing topdir` 84 | [ $? -eq 0 ] && cd $topdir/sources 85 | else 86 | cd $BUILDDIR 87 | $YE_SCRIPT plumbing find $recipe 88 | cd `dirname $(cat $YE_PLUMBING_DIR/find)` 89 | fi 90 | ;; 91 | "img"|"images") 92 | $YE_SCRIPT plumbing x MACHINE 93 | local machine=`yecd_get_bb_var MACHINE` 94 | [ -n "$machine" ] && cd $BUILDDIR/tmp/deploy/images/$machine 95 | ;; 96 | "pkg"|"packages") 97 | $YE_SCRIPT plumbing x IMAGE_PKGTYPE MACHINE 98 | local pkg_type=`yecd_get_bb_var IMAGE_PKGTYPE` 99 | local machine=`yecd_get_bb_var MACHINE | tr - _` 100 | [ -n "$pkg_type" ] && [ -n "$machine" ] && \ 101 | cd $BUILDDIR/tmp/deploy/$pkg_type/$machine 102 | ;; 103 | "manifest"|"manifests") 104 | topdir=`$YE_SCRIPT plumbing topdir` 105 | [ $? -eq 0 ] && cd $topdir/.repo/manifests 106 | ;; 107 | *) 108 | if [ -z "$dir_shortcut" ]; then 109 | cd $BUILDDIR 110 | else 111 | $YE_SCRIPT -h 112 | return $? 113 | fi 114 | ;; 115 | esac 116 | } 117 | -------------------------------------------------------------------------------- /ye-completion.sh: -------------------------------------------------------------------------------- 1 | _ye() { 2 | local cur 3 | 4 | compreply() { 5 | COMPREPLY=( $(compgen -W "$(ye plumbing find $cur > /dev/null; cat ~/.ye/plumbing/find | xargs dirname | xargs -n1 basename)" -- "$cur") ) 6 | } 7 | 8 | local command i 9 | for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do 10 | if [[ ${COMP_WORDS[i]} == @(cd|x|expand|e|edit|pv|pkg-view|pi|pkg-info) ]]; then 11 | command=${COMP_WORDS[i]} 12 | fi 13 | done 14 | 15 | cur=${COMP_WORDS[COMP_CWORD]} 16 | 17 | if [[ -n $command ]] && [[ -n $cur ]]; then 18 | if [[ $command = 'cd' ]]; then 19 | case "${COMP_WORDS[2]}" in 20 | wd|src) 21 | compreply 22 | return 0 23 | ;; 24 | *) 25 | return 0 26 | esac 27 | else 28 | compreply 29 | fi 30 | fi 31 | 32 | return 0 33 | } 34 | 35 | complete -F _ye ye 36 | --------------------------------------------------------------------------------