qi.texi 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408
  1. \input texinfo @c -*-texinfo-*-
  2. @comment $Id@w{$}
  3. @comment %**start of header
  4. @setfilename qi.info
  5. @settitle Qi manual
  6. @documentencoding ISO-8859-1
  7. @syncodeindex pg cp
  8. @comment %**end of header
  9. @set VERSION 1.0-rc4
  10. @set UPDATED 30 Jan 2017
  11. @copying
  12. This manual is for Qi (version @value{VERSION},
  13. @value{UPDATED}), which is a simple source builder and package manager.
  14. Copyright @copyright{} 2015, 2016, 2017 Matias A. Fonzo, Argentina,
  15. Santiago del Estero.
  16. @quotation
  17. Permission is granted to copy, distribute and/or modify this document
  18. under the terms of the GNU Free Documentation License, Version 1.3 or
  19. any later version published by the Free Software Foundation; with no
  20. Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
  21. Texts. A copy of the license is included in the section entitled
  22. ``GNU Free Documentation License''.
  23. @end quotation
  24. @end copying
  25. @dircategory Texinfo documentation system
  26. @direntry
  27. * Qi: (qi). Source builder and package manager.
  28. @end direntry
  29. @titlepage
  30. @finalout
  31. @title Qi
  32. @subtitle for version @value{VERSION}, @value{UPDATED}
  33. @author Matias A. Fonzo (@email{selk@@dragora.org})
  34. @page
  35. @vskip 0pt plus 1filll
  36. @insertcopying
  37. @end titlepage
  38. @contents
  39. @ifnottex
  40. @node Top
  41. @top
  42. This manual is for Qi (version @value{VERSION},
  43. @value{UPDATED}).
  44. @end ifnottex
  45. @menu
  46. * Introduction:: Purpose, description
  47. * Invocation:: Command-line interface
  48. * The qirc file:: Configuration file
  49. * Packages:: Managing packages
  50. * Recipes:: Building packages
  51. * Order files:: Handling the build order
  52. * Examine packages:: Debugging purposes
  53. * Messages:: Output messages
  54. * Exit status:: Exit codes
  55. * GNU Free Documentation License::
  56. * Index::
  57. @end menu
  58. @sp 1
  59. Copyright @copyright{} 2015-2017 Matias A. Fonzo, Argentina, Santiago
  60. del Estero.
  61. The Qi home page can be found at @uref{http://www.dragora.org}.
  62. @w{Send bug reports or suggestions to @email{dragora-users@@nongnu.org}.}
  63. @node Introduction
  64. @chapter Introduction
  65. @cindex introduction
  66. Qi is a source builder and a package manager:
  67. It contains a set of (individual) tools to build, install, remove, and
  68. upgrade software packages. It follows the philosophy of simplicity
  69. without adding too many features, such as those that can be found in
  70. popular package managers. Basically it does two things: builds
  71. packages and manages them.
  72. Qi constructs the sources using recipe names, files that contain
  73. specific instructions to build every source. As result, a binary
  74. package is obtained which can be installed, removed, upgraded, or
  75. inspected in the system.
  76. The packages are managed thanks to an external tool called
  77. @emph{graft(1)}, which provides a mechanism for managing multiple
  78. packages under a single directory hierarchy, it was inspired by both
  79. Depot (Carnegie Mellon University) and Stow (Bob Glickstein). In this
  80. aspect, Qi complements Graft: it can work with packages, check them,
  81. solve conflicts, and more...
  82. @node Invocation
  83. @chapter Invocation
  84. @cindex invocation
  85. The synopsis to invoke Qi is:
  86. @example
  87. pkg<action> [options] [package|recipe|order] ...
  88. @end example
  89. @noindent
  90. The following commands or actions are supported by Qi:
  91. @table @samp
  92. @item pkghelp
  93. Shows the help.
  94. @item pkgadd
  95. Add the packages to the system using @emph{graft(1)} for linking.
  96. @item pkgremove
  97. Remove the packages from the system.
  98. @item pkgupgrade
  99. Upgrade software packages.
  100. @item pkgbuild
  101. Build packages using recipe files.
  102. @item pkgorder
  103. Resolves the build order through .order files.
  104. @item pkgerupt
  105. Examine packages for debugging purposes.
  106. @sp 1
  107. @noindent
  108. @strong{Global options}
  109. There are global or common options for the commands, as well as specific to each one.
  110. @item -h
  111. Show options for the given command and exit.
  112. @sp 1
  113. @noindent
  114. @strong{Options for command @samp{pkgadd}:}
  115. @item -f
  116. Force package installation (implies -p).
  117. @item -P
  118. Extract package on an installation tree.
  119. This option sets @samp{$@{packagedir@}}.
  120. Default value: @emph{PREFIX/pkg}
  121. @item -p
  122. Prune conflicts.
  123. @item -t
  124. Target directory for linking.
  125. This option sets @samp{$@{targetdir@}}.
  126. Default value: @emph{/}
  127. @item -V
  128. @emph{graft(1)} very verbose.
  129. @item -w
  130. Warn about the files that will be linked.
  131. @sp 1
  132. @noindent
  133. @strong{Options for command @samp{pkgremove}:}
  134. @item -k
  135. Keep (don't delete) package directory.
  136. @item -P
  137. Remove from an installation tree.
  138. This option sets @samp{$@{packagedir@}}.
  139. Default value: @emph{PREFIX/pkg}
  140. @item -p
  141. Prune conflicts.
  142. @item -t
  143. Target directory for unlinking.
  144. This option sets @samp{$@{targetdir@}}.
  145. Default value: @emph{/}
  146. @item -V
  147. @emph{graft(1)} very verbose.
  148. @sp 1
  149. @noindent
  150. @strong{Options for command @samp{pkgupgrade}:}
  151. @item -k
  152. Keep (don't delete) package directory.
  153. @item -P
  154. Package installation tree.
  155. This option sets @samp{$@{packagedir@}}.
  156. Default value: @emph{PREFIX/pkg}
  157. @item -t
  158. Target directory.
  159. This option sets @samp{$@{targetdir@}}.
  160. Default value: @emph{/}
  161. @item -V
  162. Enable (very) verbose mode.
  163. @item -w
  164. Warn about packages that will be upgraded.
  165. @sp 1
  166. @noindent
  167. @strong{Options for command @samp{pkgbuild}:}
  168. @item -a
  169. Architecture to use.
  170. This option sets @samp{$@{arch@}}.
  171. Default value is obtained via @emph{uname(1)} as @samp{uname -m}.
  172. @item -i
  173. Increment release number.
  174. This option increment the release number when a package is produced.
  175. @item -j
  176. Parallel jobs for the compiler
  177. This option sets @samp{$@{jobs@}}.
  178. Default value: @emph{1}
  179. @item -k
  180. Keep (don't delete) @samp{$@{srcdir@}} and @samp{$@{destdir@}}.
  181. @item -n
  182. Don't create a .tlz package.
  183. @item -o
  184. Where the produced packages are written.
  185. This option sets @samp{$@{outdir@}}.
  186. Default value: @emph{/var/cache/qi/packages}
  187. @item -U
  188. Perform package upgrade after build.
  189. This option calls to @command{pkgupgrade}.
  190. @sp 1
  191. @noindent
  192. @strong{Options for command @samp{pkgorder}:}
  193. @item -x
  194. Exclude depends file.
  195. @section Environment
  196. @cindex environment
  197. Some influential environment variables:
  198. @item QICFLAGS
  199. C compiler flags for building packages.
  200. Default value: @emph{"-g0 -Os"}
  201. @item QICXXFLAGS
  202. C++ compiler flags for building packages.
  203. Default value: @emph{"-g0 -Os"}
  204. @item QILDFLAGS
  205. Linker flags for building packages.
  206. Default value: @emph{-s}
  207. @item DOPOST
  208. post-install script control variable.
  209. The @env{DOPOST} variable is currently used for @command{pkgadd},
  210. @command{pkgupgrade}, @command{pkgbuild} (when option -U is given).
  211. A different value than "DOPOST" omits the execution of the post-install
  212. script (if any).
  213. @item RC
  214. Runtime configuration file.
  215. A different value than "RC" overrides the configuration file.
  216. This is used by: @command{pkgadd}, @command{pkgremove},
  217. @command{pkgupgrade}, @command{pkgbuild}.
  218. @item TMPDIR
  219. Temporary directory (by default @emph{/tmp}).
  220. @env{TMPDIR} is expanded with random numbers for major security.
  221. This is used by: @command{pkgbuild}, @command{pkgerupt}.
  222. @end table
  223. @section Notes
  224. @cindex notes
  225. @itemize @bullet
  226. @item Command names has been prefixed with @samp{pkg} to facilitate the
  227. set in relation to its purpose.
  228. @item The @emph{PREFIX} reference is related with the installation
  229. prefix of Qi.
  230. @item All the options can be mixed. Options specified in the
  231. command-line have priority over the config file @file{qirc}.
  232. If there are no options, and if @file{qirc} is not present,
  233. default (internal) values will be used instead.
  234. @end itemize
  235. @node The qirc file
  236. @chapter The qirc file
  237. @cindex the qirc file
  238. @file{qirc} is the configuration file for Qi used at runtime during the
  239. installation, removal of a package or when a recipe is built. This
  240. file is optional, and it can be useful to define variables and
  241. configure external tools (such as a download manager) for default use.
  242. @itemize @bullet
  243. @item Variables are declared as @samp{name=value}.
  244. @item Declaration of values should only take one line, no line break.
  245. @item Assignments like @samp{name=$var} are only interpreted as
  246. literal.
  247. @end itemize
  248. @noindent
  249. The options specified in the command-line can override the values
  250. specified in the configuration file. For more information, see
  251. @ref{Invocation}.
  252. @noindent
  253. The order in which Qi looks for this file is:
  254. @enumerate
  255. @item
  256. @env{$@{HOME@}/.qirc}
  257. @- Effective user.
  258. @item
  259. @samp{$@{sysconfdir@}/qirc}
  260. @- System-wide.
  261. @end enumerate
  262. If you intend to run Qi for a specific user, you should copy the file
  263. @samp{$@{sysconfdir@}/qirc} to @env{$@{HOME@}/.qirc} setting
  264. @samp{$@{packagedir@}} and @samp{$@{targetdir@}} for your @env{$HOME}.
  265. @node Packages
  266. @chapter Packages
  267. @cindex packages
  268. A package is a suite of programs usually distributed in binary form
  269. which may also contain manual pages, documentation, or any other file
  270. associated to a specific software.
  271. The Qi package format is a simple redistributable @emph{tar(1)} archive
  272. compressed with @emph{lzip(1)}. The package extension ends in ".tlz".
  273. @noindent
  274. Both package installation and package deinstallation are managed using
  275. @samp{$@{packagedir@}} and @samp{$@{targetdir@}}:
  276. @samp{$@{packagedir@}} is a common directory tree where the package contents
  277. is decompressed (resides). By default the tree is located at
  278. @emph{PREFIX/pkg}.
  279. @samp{$@{targetdir@}} is a target directory where the links will be
  280. made taking @samp{$@{packagedir@}/package_name} into account.
  281. Packages are installed in self-contained directory trees and symbolic
  282. links from a common area are made to the package files. This allows
  283. multiple versions of the same package to co-exist on the one system.
  284. All the links to install or to remove a package are managed using
  285. @emph{graft(1)}. Since multiple packages can be installed or removed
  286. at the same time, certain conflicts may arise between the packages.
  287. According to the User's Guide of Graft@footnote{The official guide
  288. for Graft can be found at
  289. @url{http://peters.gormand.com.au/Home/tools/graft/graft.html}.},
  290. a conflict is defined as one of the following conditions:
  291. @itemize @bullet
  292. @item If the package object is a directory and the target object exists
  293. but is not a directory.
  294. @item If the package object is not a directory and the target object
  295. exists and is not a symbolic link.
  296. @item If the package object is not a directory and the target object
  297. exists and is a symbolic link to something other than the package
  298. object.
  299. @end itemize
  300. @noindent
  301. Qi's default behavior is to not proceed with the installation when a
  302. conflict occurs. But when a package that is going to be removed is in
  303. conflict with another package, @emph{graft(1)} removes those parts that
  304. are not in conflict, leaving the links belonging to the original
  305. package. This behavior can be changed if the option -p is specified
  306. (see the examples below).
  307. @section Adding packages
  308. @cindex adding packages
  309. This sort order is particularly useful just before the actual package
  310. installation, because it helps to understand how the package
  311. installation works:
  312. @enumerate
  313. @item Detects and reports if the package is already installed.
  314. @item Ignores some signals up to completing the installation:
  315. HUP INT QUIT ABRT TERM.
  316. @item The integrity of the file (package) is checked.
  317. @item Creates required directory for the package as
  318. @samp{$@{packagedir@}/package_name}.
  319. @item Decompress the content of the package in
  320. @samp{$@{packagedir@}/package_name}.
  321. @item A test of the package is performed before completing the
  322. installation to see if there are no conflicts with another package.
  323. This is the default behavior if -p is not supplied.
  324. @item @emph{graft(1)} is invoked to install symbolic links from
  325. the package installation directory to the target directory.
  326. @item If the meta file is readable, the description will be shown for
  327. the package.
  328. @item Run post install instructions from @file{post-install}, if any.
  329. @end enumerate
  330. @noindent
  331. @emph{Usage:} pkgadd [-hfpVw] [-P <DIR>] [-t <DIR>] [package.tlz ...]
  332. To install a single package, simply type:
  333. @example
  334. pkgadd coreutils-8.24-x86_64+1.tlz
  335. @end example
  336. To install multiple packages at once:
  337. @example
  338. pkgadd gcc-4.9.3-x86_64+1.tlz rafaela-2.2-i586+1.tlz ...
  339. @end example
  340. Warn about the files that will be linked:
  341. @example
  342. pkgadd -w gcc-4.9.3-x86_64+1.tlz
  343. @end example
  344. @itemize @bullet
  345. @item This is to verify the content of a package before installing it.
  346. @end itemize
  347. See what happens when a package is installed (very verbose):
  348. @example
  349. pkgadd -V mariana-3.0-x86_64+1.tlz
  350. @end example
  351. @itemize @bullet
  352. @item This is for a detailed (long) output.
  353. @end itemize
  354. Installing in a different directory tree and target:
  355. @example
  356. pkgadd -P /tmp/pkgdir -T /tmp/targetdir lzip-1.17-i586+1.tlz
  357. @end example
  358. When a package is already installed, @command{pkgadd} refuses to
  359. continue. This is to keep some control over the database of your
  360. packages, if you really want to force the installation of a package,
  361. you can use the -f option (which implies -p). See below.
  362. @strong{Pruning conflicts}
  363. Remove objects (files, links or directories) from the target
  364. directory that are in conflict with the package directory:
  365. @example
  366. pkgadd -p zutils-1.4-x86_64+1.tlz
  367. @end example
  368. When the -p option is used, it proceeds to install the package
  369. normally, but first will try to remove any conflict. Use it with care,
  370. combine this option with -V.
  371. @section Removing packages
  372. @cindex removing packages
  373. This sort order is particularly useful just before the actual package
  374. deinstallation, because it helps to understand how the package
  375. deinstallation works:
  376. @enumerate
  377. @item Look for a package name to remove inside of
  378. @samp{$@{packagedir@}}. Package names must be specified using the full
  379. package name, such as "name-version-arch+release.tlz" or specifying the
  380. package name directory.
  381. @item Ignores some signals up to completing the deinstallation:
  382. HUP INT QUIT ABRT TERM.
  383. @item @emph{graft(1)} is invoked to remove symbolic links from
  384. the package installation directory to the target directory:
  385. If a conflict exists with another package, those links that are not in
  386. conflict will be preserved. It's possible to prune all the conflicts
  387. using the -p option.
  388. @item Remove directories made empty by package deletion. This has
  389. effect on @samp{$@{targetdir@}} but not for @samp{$@{packagedir@}}.
  390. @item The package directory is deleted if the option -k is not
  391. supplied.
  392. @end enumerate
  393. @noindent
  394. @emph{Usage:} pkgremove [-hkpV] [-P <DIR>] [-t <DIR>] [package_name ...]
  395. To remove a package, just execute the command:
  396. @example
  397. pkgremove xz-5.2.2-x86_64+1
  398. @end example
  399. To remove multiple versions of the same package:
  400. @example
  401. pkgremove xz*
  402. @end example
  403. To remove multiple packages at once:
  404. @example
  405. pkgremove foo bar baz ...
  406. @end example
  407. Detailed output (very verbose):
  408. @example
  409. pkgremove -V xz-5.2.2-x86_64+1
  410. @end example
  411. Removing from a different directory tree and target:
  412. @example
  413. pkgremove -P /tmp/pkgdir -T /tmp/targetdir lzip-1.17-x86_64+1
  414. @end example
  415. Pruning conflicts:
  416. @example
  417. pkgremove -p -V hunter
  418. @end example
  419. @section Upgrading packages
  420. @cindex upgrading packages
  421. This sort order is particularly useful just before the actual package
  422. upgrade, because it helps to understand how the package upgrade works:
  423. @enumerate
  424. @item Prepare temporary location for the incoming package.
  425. @item Pre-install incoming package into the temporary location.
  426. @item Remove packages under the same name: this is considered
  427. as the old packages. (Default behaviour if -k is not supplied).
  428. @item Upgrade or install the package calling to @command{pkgadd}.
  429. @item Delete temporary location of the package.
  430. @end enumerate
  431. @noindent
  432. @emph{Usage:} pkgupgrade [-hkVw] [-P <DIR>] [-t <DIR>] [package.tlz ...]
  433. Upgrading a package is simple as:
  434. @example
  435. pkgupgrade coreutils-8.25-x86_64+1.tlz
  436. @end example
  437. @noindent
  438. @samp{pkgupgrade} uses @command{pkgadd} and @command{pkgremove} to
  439. upgrade software packages. So it inherits the properties of each
  440. utility, except here, only the essential options are provided. For
  441. example, the option -V (for a detailed output) belongs to when these
  442. utilities are invoked. The options -P and -t work in the same way as
  443. the previous examples for @command{pkgadd}, @command{pkgremove}.
  444. @samp{pkgupgrade} will try to update the package or to install it
  445. (in case it has not been installed).
  446. To see what packages will be updated (if any), always type:
  447. @example
  448. pkgupgrade -w coreutils-8.25-x86_64+1.tlz
  449. @end example
  450. @section Notes
  451. @cindex notes
  452. @itemize @bullet
  453. @item Some signals like HUP INT QUIT ABRT TERM are ignored on the
  454. package installation or deinstallation. The intention is to ignore
  455. the cancellation while the package is being installed or removed (e.g.
  456. Ctrl+C, terminal window closed, etc.). The installation or removal
  457. of a package can be crucial for the proper functioning of the system.
  458. @item The meta file is read from the directory where the package is
  459. found.
  460. @item A post-install script is read from
  461. @samp{$@{packagedir@}/package_name/var/lib/qi/post-install/name.install}.
  462. @item Default behavior is to upgrade or install a package removing old
  463. packages, this is "packages found under the same name". If you want to
  464. preserve the multiple versions of the same package, you must pass the
  465. -k option.
  466. @end itemize
  467. @node Recipes
  468. @chapter Recipes
  469. @cindex recipes
  470. A recipe is a file telling qi what to do. Most often, the recipe
  471. tells qi how to build a binary package from a source tarball.
  472. A recipe has two parts: a list of variable definitions and a list of
  473. sections. By convention, the syntax of a section is:
  474. @example
  475. section_name() @{
  476. section lines
  477. @}
  478. @end example
  479. The section name is followed by parentheses, one space and an opening
  480. brace. The line finishing the section contains just a closing brace.
  481. The section names or the function names currently recognized are
  482. @samp{build}.
  483. The @samp{build} section is an augmented shell script. This is the main
  484. section (or @strong{shell function}) which contains the instructions to
  485. build and produce a package.
  486. @section Variables
  487. @cindex variables
  488. A "variable" is a @strong{shell variable} defined either in @file{qirc}
  489. or in a recipe to represent a string of text, called the variable's
  490. "value". These values are substituted by explicit request in the
  491. definitions of other variables or in calls to external commands.
  492. Variables can represent lists of file names, options to pass to
  493. compilers, programs to run, directories to look in for source files,
  494. directories to write output in, or anything else you can imagine.
  495. Definitions of variables in qi have four levels of precedence.
  496. Options which define variables from the command-line override those
  497. specified in the @file{qirc} file, while variables defined in the recipe
  498. override those specified in @file{qirc}, taking priority over those
  499. variables settled by options via command-line. Finally, some variables
  500. (arch, jobs, outdir, worktree, tardir, netget, rsync) have default
  501. values if they are not defined anywhere.
  502. Options that set variables through the command-line can only reference
  503. variables defined in @file{qirc} and variables with default values.
  504. Definitions of variables in @file{qirc} can only reference variables
  505. previously defined in @file{qirc} and variables with default values.
  506. Definitions of variables in the recipe can only reference variables
  507. settled by command-line, variables previously defined in the recipe,
  508. variables defined in @file{qirc}, and variables with default values.
  509. @subsection Special variables
  510. @cindex special variables
  511. The three variables @samp{arch}, @samp{jobs}, and @samp{outdir} can
  512. only be set using command line options or in @file{qirc}. If not
  513. specified, they have default values.
  514. @samp{arch} is the architecture to compose the package name. Its
  515. value is available in the recipe as @samp{$@{arch@}}. Default value is
  516. the output of @samp{uname -m}.
  517. @samp{jobs} is the number of jobs to pass to the compiler. Its
  518. default value is available in the recipe as @samp{$@{jobs@}}. Defaults
  519. to @samp{1}.
  520. @samp{outdir} is the directory where the produced packages are
  521. written. This variable cannot be redefined in the recipe. Defaults to
  522. @samp{/var/cache/qi/packages}.
  523. @samp{worktree} is the working tree where archives, patches, and
  524. recipes are expected. This variable cannot be redefined in the
  525. recipe. Defaults to @samp{/usr/src/qi}.
  526. The variable @samp{tardir} is defined in the recipe to the directory
  527. where the tarball containing the source can be found. The full name of
  528. the tarball is commonly used as @samp{$@{tardir@}/$tarname}. A value
  529. of @samp{.} for @samp{tardir} sets it to the value of the CWD (Current
  530. Working Directory), this means, from where the recipe is located.
  531. The two variables @samp{srcdir} and @samp{destdir} can be defined in
  532. the recipe, as any other variable, but if they are not, Qi uses default
  533. values for them when building the package.
  534. @samp{srcdir} contains the source code to be compiled, and defaults to
  535. @samp{$@{program@}-$@{version@}}.
  536. @samp{destdir} is the place where the built package will be installed,
  537. and defaults to @samp{$@{TMPDIR@}/package-$@{program@}}.
  538. If @samp{pkgname} is left undefined, the special variable
  539. @samp{program} is assigned by default. If @samp{pkgversion} is left
  540. undefined, the special variable @samp{version} is assigned by default.
  541. @samp{pkgname}, @samp{pkgversion}, along with @samp{version},
  542. @samp{arch}, and @samp{release}, are used to produce the name of the
  543. package in the form
  544. @samp{$@{pkgname@}-$@{pkgversion@}-$@{arch@}+$@{release@}.tlz}. All of
  545. them must be defined in the recipe, excepting @samp{arch}, which is
  546. optional.
  547. @itemize @bullet
  548. @item @samp{program}: name of the package.
  549. @item @samp{version}: version of the package.
  550. @item @samp{arch}: architecture of the package.
  551. @item @samp{release}: release number of the package. It is recommended to
  552. increase this number after any significant change in the recipe is made.
  553. @end itemize
  554. @noindent
  555. Obtaining sources over the network must be declared in the recipe using
  556. the @samp{fetch} variable. Use double quotes for separated values.
  557. The variables @samp{netget} and @samp{rsync} can be defined in
  558. @file{qirc} to establish a network downloader in order to get the
  559. sources. If they are not defined, qi uses default values:
  560. @samp{netget} is the general network downloader tool for use, and
  561. defaults to @samp{wget -c -w1 -t3 --no-check-certificate}.
  562. @samp{rsync} is the network tool for sources containing the prefix for
  563. the RSYNC protocol, and defaults to
  564. @samp{rsync -v -a -L -z -i --progress}.
  565. @noindent
  566. There are three important variables to produce meta information of the
  567. package: @samp{description}, @samp{homepage}, @samp{license}.
  568. The variable @samp{description} is special to write the description of the
  569. package, which will be shown when installed.
  570. A description has two parts: a brief description and a long
  571. description. By convention, the syntax of a description is:
  572. @example
  573. description="
  574. Brief description.
  575. Long description.
  576. "
  577. @end example
  578. @noindent
  579. The first (substantial) line of the value is a brief description of the
  580. software (called the "blurb"). A new (blank) line is followed to
  581. separate the brief description from the long description.
  582. An example looks like:
  583. @example
  584. description="
  585. A source builder and a package manager.
  586. Qi is a source builder and a package manager. It contains a set of
  587. tools to build, install, remove, and upgrade software packages.
  588. Qi follows the philosophy of the simplicity without adding too many
  589. features, such as those that can be found in popular package managers.
  590. Basically it does two things: builds packages and manages them.
  591. "
  592. @end example
  593. @itemize @bullet
  594. @item Consider a length limit of 78 characters as maximum.
  595. @xref{Recipes, The meta file}.
  596. @end itemize
  597. @noindent
  598. The @samp{homepage} variable is used simply to declare the main site or
  599. home of the source, thus:
  600. @example
  601. homepage=http://www.dragora.org
  602. @end example
  603. @noindent
  604. The variable @samp{license} is used for license information@footnote{
  605. The proposal for @samp{license} was made by Richard M. Stallman at
  606. @url{http://lists.gnu.org/archive/html/gnu-linux-libre/2016-05/msg00003.html}.}.
  607. Some code in the program can be covered by license A, license B, or
  608. license C. For "separate licensing" or "heterogeneous licensing",
  609. we suggest using @strong{|} for a disjunction, @strong{&} for a
  610. conjunction (if that ever happens in a significant way), and comma
  611. for heterogeneous licensing. Comma would have lower precedence. Plus
  612. added special terms.
  613. @example
  614. license="LGPL, GPL | Artistic, GPL + added permission"
  615. @end example
  616. @subsection Variables from the environment
  617. @cindex variables from the environment
  618. The variables @env{QICFLAGS}, @env{QICXXFLAGS}, and @env{QILDFLAGS} have
  619. no effect by default. The environment variables such as @env{CFLAGS},
  620. @env{CXXFLAGS}, and @env{LDFLAGS} are unset at compile time.
  621. Recommended practices is to set variables in front of @samp{configure}
  622. or in front of @emph{make(1)} instead of exporting to the environment.
  623. As follows:
  624. @quotation
  625. Variables not defined in a site shell script can be set in the
  626. environment passed to configure. However, some packages may run
  627. configure again during the build, and the customized values of these
  628. variables may be lost. In order to avoid this problem, you should set
  629. them in the configure command line, using @samp{VAR=value}. For
  630. example:
  631. @code{./configure CC=/usr/local2/bin/gcc}
  632. @url{http://gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.69/html_node/Defining-Variables.html}
  633. @end quotation
  634. @quotation
  635. Indeed, while configure can notice the definition of CC in @samp{./configure
  636. CC=bizarre-cc}, it is impossible to notice it in @samp{CC=bizarre-cc
  637. ./configure}, which, unfortunately, is what most users do.
  638. [...]
  639. configure: error: changes in the environment can compromise the build.
  640. @url{http://gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.69/html_node/Setting-Output-Variables.html}
  641. @end quotation
  642. @quotation
  643. It is not wise for makefiles to depend for their functioning on
  644. environment variables set up outside their control, since this would
  645. cause different users to get different results from the same makefile.
  646. This is against the whole purpose of most makefiles.
  647. @url{http://gnu.org/software/make/manual/make.html#Environment}
  648. @end quotation
  649. @section The meta file
  650. @cindex the meta file
  651. The "meta file" is an external file created by @command{pkgbuild} when
  652. a recipe is processed and when a package is produced. The file is
  653. generated as @samp{$@{full_pkgname@}.tlz.txt} which contains
  654. information about the package such as @samp{program}, @samp{version},
  655. @samp{release}. Also definitions of the special variables
  656. @samp{fetch}, @samp{description}, @samp{homepage}, @samp{license}.
  657. A meta file has the purpose to extract information and the purpose to
  658. reflect essential information to the user without having to check
  659. inside the package itself.
  660. The meta file is basically composed as:
  661. @example
  662. # Description
  663. variable=value
  664. ...
  665. @end example
  666. @noindent
  667. The description is extracted from the declared variable
  668. @samp{description}, where each line is interpreted literally and where
  669. the description is pre-formatted to fit in (exactly) 80 columns. Plus
  670. @samp{# } is prepend to each line.
  671. Followed by new line, the rest is composed by variables; the inclusion
  672. of its values, may vary. For example, in addition to the special
  673. variables, there are implicit variables such as @samp{blurb},
  674. @samp{depends}.
  675. The @samp{blurb} variable is related to the special variable
  676. @samp{description}. Always taking the first (substantial) line
  677. or "brief description".
  678. The value of @samp{depends} only will be included if the
  679. @file{depends} file is a regular file. @xref{Order files, The depends
  680. file}.
  681. @noindent
  682. Now let's take a look on a real example of a meta file:
  683. @example
  684. # A lossless data compressor based on the LZMA algorithm.
  685. #
  686. # Clzip is a lossless data compressor with a user interface similar to
  687. # the one of gzip or bzip2. Clzip is about as fast as gzip, compresses
  688. # most files more than bzip2, and is better than both from a data
  689. # recovery perspective.
  690. #
  691. # Clzip uses the lzip file format; the files produced by clzip are fully
  692. # compatible with lzip-1.4 or newer, and can be rescued with lziprecover.
  693. #
  694. # Clzip is in fact a C language version of lzip, intended for embedded
  695. # devices or systems lacking a C++ compiler.
  696. QICFLAGS="-g0 -Os"
  697. QICXXFLAGS="-g0 -Os"
  698. QILDFLAGS="-s"
  699. program=clzip
  700. version=1.8
  701. release=1
  702. blurb="A lossless data compressor based on the LZMA algorithm."
  703. homepage="http://lzip.nongnu.org/clzip.html"
  704. license="GPLv2+"
  705. fetch="http://download.savannah.gnu.org/releases/lzip/clzip/clzip-1.8.tar.gz"
  706. depends=" "
  707. @end example
  708. Creation of the meta file is made in @samp{$@{outdir@}}.
  709. @section Building packages
  710. @cindex building packages
  711. This sort order is particularly useful just before the actual package
  712. build, because it helps to understand how a package is being built:
  713. @enumerate
  714. @item A recipe is read from the current directory, if not, it will be
  715. looked in @samp{$@{worktree@}/recipes}. Names of recipes can be
  716. invoked relative to @samp{$@{worktree@}/recipes}. The recipe must be
  717. a regular file and must be readable by the user who is running the
  718. command.
  719. @item Checks are made when the recipe is imported (included), essential
  720. variable names cannot be empty: @samp{program}, @samp{version},
  721. @samp{release}. Also the main function @samp{build()} must be present.
  722. @item @command{pkgbuild} tries to obtain the sources remotely if it
  723. does not exist locally (@samp{$@{tardir@}}). Once the source is
  724. already in place, its timestamp is updated, creating or updating the
  725. SHA1 sum.
  726. @item Required directories are created: @samp{$@{TMPDIR@}/$srcdir},
  727. @samp{$@{outdir@}}, @samp{$@{destdir@}/var/lib/qi/recipes}.
  728. @item Sane ownerships and permissions are applied to the full source
  729. directory: @samp{$@{TMPDIR@}/$srcdir}.
  730. @item The main function @samp{build()} is called. Exits immediately if
  731. a command exits with a non-zero status.
  732. @item A package is going to be created under the following conditions:
  733. @itemize @bullet
  734. @item If @samp{$@{destdir@}} is not empty.
  735. @item If the option -n was not given.
  736. @end itemize
  737. A copy of the recipe (file) is included on
  738. @samp{$@{destdir@}/var/lib/qi/recipes} as @samp{$@{full_pkgname@}.recipe}.
  739. If the @file{post-install} script is in the current working directory
  740. or from where the recipe name resides, it will be added as
  741. @samp{$@{destdir@}/var/lib/qi/post-install/$@{full_pkgname@}.install}.
  742. The package is produced from the content of @samp{$@{destdir@}}. First,
  743. creating a tarball, and then compressing it using the maximum level of
  744. compression of @emph{lzip(1)}.
  745. @item By default, directories like @samp{$@{TMPDIR@}/$srcdir} and
  746. @samp{$@{destdir@}} are deleted.
  747. @item If the option -U is given, @command{pkgupgrade} is invoked to
  748. install or upgrade the package.
  749. @end enumerate
  750. @noindent
  751. @emph{Usage:} pkgbuild [-hiknU] [-a <ARCH>] [-j <JOBS>] [-o <DIR>] [recipe ...]
  752. To build a single package, simply type:
  753. @example
  754. pkgbuild clzip.recipe
  755. @end example
  756. Compile passing parallel jobs to the compiler for speed up the process:
  757. @example
  758. pkgbuild -j4 clzip.recipe
  759. @end example
  760. To build and install or upgrade multiple packages at once:
  761. @example
  762. pkgbuild -U clzip.recipe zutils.recipe matias.recipe
  763. @end example
  764. Reading recipes and building from the output of a command:
  765. @example
  766. cat depends | pkgbuild -
  767. @end example
  768. Incrementing the release number after a significant change in a recipe:
  769. @example
  770. pkgbuild -i stargazer.recipe
  771. @end example
  772. @noindent
  773. If the recipe name cannot be read from the current directory or from
  774. a specific path name, @samp{$@{worktree@}/recipes} is used for the
  775. search:
  776. There is a special case for the names of recipes @samp{recipe}.
  777. @command{pkgbuild} can complete the recipe name without being required
  778. to be specified in the command-line, only if the name of the recipe is
  779. @samp{recipe}. For example:
  780. @example
  781. pkgbuild devel/gcc
  782. @end example
  783. Will complete the search as @samp{$@{worktree@}/recipes/devel/gcc/recipe}.
  784. @section Writing recipes
  785. @cindex writing recipes
  786. @subsection Internal functions
  787. @cindex internal functions
  788. Some internal functions are available to be applied on the recipe:
  789. @table @samp
  790. @item unpack()
  791. The unpack function can decompress multiple (compressed) files while
  792. verifies the integrity. Depending on where the function is called,
  793. the decompression occurs in the current working directory.
  794. Usage: @code{unpack file(s) ...}
  795. The cases supported for the special extensions are: *.tar, *.tar.*,
  796. *.tgz*, *.tbz*, *.tlz*, *.txz*, *.zip, *.ZIP, *.gz, *.bz2, *.lz.
  797. @end table
  798. @node Order files
  799. @chapter Order files
  800. @cindex .order files
  801. @command{pkgorder} has the purpose to resolve the build order through
  802. .order files. In other words, is a good complement for
  803. @command{pkgbuild}.
  804. @noindent
  805. @emph{Usage:} pkgorder [-x] [file_name.order ...]
  806. @noindent
  807. Basically, @command{pkgorder} reads from a declared file which ends in
  808. ".order". The output is an ordered list of recipe names which can be
  809. passed to @command{pkgbuild} (via a pipe) to build a number or a series
  810. of packages.
  811. @sc{Declaration}
  812. If 'a' depends on 'b' and 'c', and 'c' depends on 'b' as well, the file
  813. might look like:
  814. @example
  815. a.recipe: c.recipe b.recipe
  816. b.recipe:
  817. c.recipe: b.recipe
  818. @end example
  819. Each letter represents a recipe name, complete dependencies for
  820. the first recipe name are listed in descending order, which is
  821. printed from right to left, and removed from left to right:
  822. @sc{Output}
  823. @example
  824. b.recipe
  825. c.recipe
  826. a.recipe
  827. @end example
  828. @itemize @bullet
  829. @item Commented lines starting with a '#' are allowed. Blank lines,
  830. colons, parentheses, and end of line are removed.
  831. @end itemize
  832. @section The depends file
  833. @cindex the depends file
  834. When @command{pkgorder} read from an order file; by default, it will
  835. proceed to read the dependencies of each recipe. This behavior can be
  836. omitted if the -x option is given.
  837. The procedure for reading the dependencies of each recipe is
  838. extracting the directory location where the order file resides. Then
  839. it iterates over the declared items extracting its location in search
  840. of the special file @file{depends}.
  841. @itemize @bullet
  842. @item The @file{depends} file only is read (sequentially) if it is
  843. a regular file and is not empty.
  844. @end itemize
  845. @noindent
  846. The special file @file{depends} must contain a list of prerequisites
  847. for the recipe. Prerequisites are names of valid recipes, including
  848. its location. The location must be relative to @samp{$@{worktree@}}
  849. (variable described in @ref{Recipes}).
  850. Example of a @file{depends} file declared for @emph{bash.recipe}:
  851. @example
  852. libs/readline/readline.recipe
  853. @end example
  854. Then, if @emph{core/bash/bash.recipe} has been declared on
  855. @emph{core.order}, the output would be:
  856. @example
  857. ...
  858. libs/readline/readline.recipe
  859. core/bash/bash.recipe
  860. ...
  861. @end example
  862. Combined in a pipe, @emph{readline} represents the first dependency
  863. of @emph{bash}:
  864. @example
  865. @code{pkgorder core.order | pkgbuild -U -}
  866. @end example
  867. @node Examine packages
  868. @chapter Examine packages
  869. @cindex examine packages
  870. @command{pkgerupt} is a special command to examine packages for
  871. debugging purposes.
  872. @noindent
  873. @emph{Usage:} pkgerupt [-h] [package.tlz ...]
  874. When a package name is given @command{pkgerupt} will create a random
  875. directory for the package. The prefix directory where the random
  876. directory is created is controlled by the @env{TMPDIR} variable,
  877. by default @env{TMPDIR} is assigned to @emph{/tmp}. Creation mode
  878. is "u=,g=rwx,o=rwx" (0700).
  879. The extraction to inspecting a package is equivalent to the shell
  880. instruction:
  881. @example
  882. @code{( umask 000 && cd -- $PRVDIR && lzip -cd - | tar -xf - ) < $file}
  883. @end example
  884. The package content is decompressed in the random (private) directory
  885. via pipe. Creation mode is "u=rwx,g=rwx,o=rwx" (0777).
  886. If there is any substantial change, consider increasing the build
  887. number when repackaging: edit the value of the @samp{release} variable
  888. (recipe), compose the output file using the new number.
  889. @node Messages
  890. @chapter Messages
  891. @cindex output messages
  892. Some symbols are used for output messages to help to identify
  893. the messages shown by the tools in Qi. There are four simple
  894. categories where the symbols are represented:
  895. @sp 1
  896. @noindent
  897. @strong{Specifics}
  898. This symbols are unique to identify the running tool:
  899. @table @samp
  900. @item +
  901. This symbol belongs to the @command{pkgadd} tool.
  902. @item -
  903. This symbol belongs to the @command{pkgremove} tool.
  904. @item ~
  905. This symbol belongs to the @command{pkgupgrade} tool.
  906. @item #
  907. This symbol belongs to the @command{pkgbuild} tool.
  908. @item =
  909. This symbol belongs to the @command{pkgerupt} tool.
  910. @item %
  911. This symbol is used to scan a package or to warn when
  912. the option is used.
  913. Specific symbols are enclosed between @samp{( )}.
  914. @end table
  915. @table @samp
  916. @strong{Preventive}
  917. Preventive symbols are intended to alert the user about unforeseen
  918. or important situations, and to meet requirements before proceeding:
  919. @item *
  920. Normally used for testing compressed sources, obtain remote sources,
  921. or set system permissions.
  922. Preventive symbols are enclosed between @samp{[ ]}.
  923. @end table
  924. @table @samp
  925. @strong{Informative}
  926. Informative symbols are intended to inform users the most essential
  927. tasks during the execution:
  928. @item i
  929. Symbol used when a task is going to be performed or when a task has
  930. been completed.
  931. @item !
  932. This symbol informs about deleting files.
  933. Informative symbols are enclosed between @samp{[ ]}.
  934. @end table
  935. @strong{Transitory}
  936. Transitory symbols are part for occasional changes (@samp{@@}) but no
  937. less important. Also to invoke Qi tools externally (@samp{^}).
  938. Transitory symbols are enclosed between @samp{@{ @}}.
  939. @node Exit status
  940. @chapter Exit status
  941. @cindex exit codes
  942. All the conditions of exit codes are described in this chapter.
  943. @table @samp
  944. @item 0
  945. Successful completion (no errors).
  946. @item 1
  947. @strong{Minor common errors:}
  948. @itemize @minus
  949. @item Illegal option.
  950. @item Option requires an argument.
  951. @item Internal function to load not found.
  952. @item Program (prerequisite) is not available.
  953. @end itemize
  954. @item 2
  955. @strong{Command execution error}
  956. Evaluation of external commands or shell arguments. If it fails,
  957. returns 2.
  958. @item 3
  959. @strong{Integrity check error for compressed files}
  960. Compressed files means:
  961. @itemize @minus
  962. @item All the tarballs supported by @emph{tar(1)}.
  963. @item Zip files supported by @emph{unzip(1)}.
  964. @item Gzip files supported by @emph{gzip(1)}.
  965. @item Bzip2 files supported by @emph{bzip2(1)}.
  966. @item Lzip files supported by @emph{lzip(1)}.
  967. @end itemize
  968. @item 4
  969. @strong{File empty, not regular, or expected}
  970. Commonly, it is expected:
  971. @itemize @minus
  972. @item A binary package (.tlz).
  973. @item An installed package to remove.
  974. @item A recipe file.
  975. @item A file of order (.order).
  976. @end itemize
  977. @item 5
  978. @strong{Empty or not defined variable}
  979. This exit code is used for reporting about empty or undefined variables.
  980. Usually, variables of the recipe or assigned arrays that are tested.
  981. @item 6
  982. @strong{Package already installed}
  983. The package directory for an incoming package already exists.
  984. @item 10
  985. @strong{Network manager error}
  986. Exit status from the execution of the network manager tool and its
  987. arguments.
  988. @end table
  989. @noindent
  990. @cartouche
  991. Error messages are reported to the standard error.
  992. @end cartouche
  993. @node GNU Free Documentation License
  994. @appendix GNU Free Documentation License
  995. @include fdl.texi
  996. @node Index
  997. @unnumbered Index
  998. @printindex cp
  999. @bye