qi-content.texi 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195
  1. @c -*-texinfo-*-
  2. @c qi-content.texi
  3. @c This is part of the Qi user guide.
  4. @c Copyright (C) 2019-2021 Matias Fonzo, <selk@dragora.org>.
  5. @c See the file qi-header.texi for copying conditions.
  6. @c
  7. @c If something is modified here, be aware of the increase of VERSION in
  8. @c qi-header.texi, this will produce the result of the manual: qi.info
  9. @node Introduction to Qi
  10. @chapter Introduction to Qi
  11. @cindex introduction to qi
  12. Qi is a simple but well-integrated package manager. It can create,
  13. install, remove, and upgrade software packages. Qi produces binary
  14. packages using recipes, which are files containing specific instructions
  15. to build each package from source. Qi can manage multiple packages
  16. under a single directory hierarchy. This method allows to maintain a set
  17. of packages and multiple versions of them. This means that Qi could be
  18. used as the main package manager or complement the existing one.
  19. Qi offers a friendly command line interface, a global configuration
  20. file, a simple recipe layout to deploy software packages; also works
  21. with binary packages in parallel, speeding up installations and packages
  22. in production. The format used for packages is a simplified and safer
  23. variant of POSIX pax archive compressed in lzip format.
  24. Qi is a modern (POSIX-compliant) shell script released under the
  25. terms of the GNU General Public License. There are only two major
  26. dependencies for the magic: graft(1) and tarlz(1), the rest is expected
  27. to be found in any Unix-like system.
  28. @node Invoking qi
  29. @chapter Invoking qi
  30. @cindex invocation
  31. This chapter describes the synopsis for invoking Qi.
  32. @example
  33. Usage: qi COMMAND [@var{OPTION}...] [@var{FILE}]...
  34. @end example
  35. @noindent
  36. One mandatory command specifies the operation that @samp{qi} should
  37. perform, options are meant to detail how this operation should be
  38. performed during or after the process.
  39. @noindent
  40. Qi supports the following commands:
  41. @table @code
  42. @item warn
  43. Warn about files that will be installed.
  44. @item install
  45. Install packages.
  46. @item remove
  47. Remove packages.
  48. @item upgrade
  49. Upgrade packages.
  50. @item extract
  51. Extract packages for debugging purposes.
  52. @item create
  53. Create a .tlz package from directory.
  54. @item build
  55. Build packages using recipe names.
  56. @item order
  57. Resolve build order through .order files
  58. @end table
  59. @noindent
  60. Options when installing, removing, or upgrading software packages:
  61. @table @code
  62. @item -f
  63. @itemx --force
  64. Force upgrade of pre-existing packages.
  65. @item -k
  66. @itemx --keep
  67. Keep directories when build/remove/upgrade.
  68. Keep (don't delete) the package directory when using remove/upgrade command.
  69. This will also try to preserve the directories @samp{$@{srcdir@}} and
  70. @samp{$@{destdir@}} when using build command. Its effect is available in
  71. recipes as @samp{$@{keep_srcdir@}} and @samp{$@{keep_destdir@}}. See
  72. @ref{Recipes, Special variables} for details.
  73. @item -p
  74. @itemx --prune
  75. Prune conflicts.
  76. @item -P
  77. @itemx --packagedir=<dir>
  78. Set directory for package installations.
  79. @item -t
  80. @itemx --targetdir=<dir>
  81. Set target directory for symbolic links.
  82. @item -r
  83. @itemx --rootdir=<dir>
  84. Use the fully qualified named directory as the root directory for all qi
  85. operations.
  86. Note: the target directory and the package directory will be
  87. relative to the specified directory, excepting the graft log file.
  88. @end table
  89. @noindent
  90. Options when building software packages using recipes:
  91. @table @code
  92. @item -a
  93. @itemx --architecture
  94. Set architecture name for the package.
  95. @item -j
  96. @itemx --jobs
  97. Parallel jobs for the compiler.
  98. This option sets the variable @samp{$@{jobs@}}. If not specified, default
  99. sets to 1.
  100. @item -S
  101. @itemx --skip-questions
  102. Skip questions on completed recipes.
  103. @item -1
  104. @itemx --increment
  105. Increment release number (@samp{$@{release@}} + 1).
  106. The effect of this option will be omitted if --no-package is being used.
  107. @item -n
  108. @itemx --no-package
  109. Do not create a .tlz package.
  110. @item -i
  111. @itemx --install
  112. Install package after the build.
  113. @item -u
  114. @itemx --upgrade
  115. Upgrade package after the build.
  116. @item -o
  117. @itemx --outdir=<dir>
  118. Where the packages produced will be written.
  119. This option sets the variable @samp{$@{outdir@}}.
  120. @item -w
  121. @itemx --worktree=<dir>
  122. Where archives, patches, recipes are expected.
  123. This option sets the variable @samp{$@{worktree@}}.
  124. @item -s
  125. @itemx --sourcedir=<dir>
  126. Where compressed sources will be found.
  127. This option sets the variable @samp{$@{tardir@}}.
  128. @end table
  129. @noindent
  130. Other options:
  131. @table @code
  132. @item -v
  133. @itemx --verbose
  134. Be verbose (an extra -v gives more).
  135. It sets the verbosity level, default sets to 0.
  136. The value 1 is used for more verbosity while the value 2 is too detailed.
  137. Although at the moment it is limited to graft(1) verbosity.
  138. @item -N
  139. @itemx --no-rc
  140. Do not read the configuration file.
  141. This will ignore reading the qirc file.
  142. @item -L
  143. @itemx --show-location
  144. Print default directory locations and exit.
  145. This will print the target directory, package directory, working tree,
  146. the directory for sources, and the output directory for the packages
  147. produced.
  148. @item -h
  149. @itemx --help
  150. Display the usage and exit.
  151. @item -V
  152. @itemx --version
  153. This will print the (short) version information and then exit.
  154. The same can be achieved if Qi is invoked as @samp{qi version}.
  155. @end table
  156. When FILE is -, qi can read from the standard input. See examples from
  157. the @ref{Packages} section.
  158. Exit status: 0 for a normal exit, 1 for minor common errors (help usage,
  159. support not available, etc), 2 to indicate a command execution error;
  160. 3 for integrity check error on compressed files, 4 for empty, not
  161. regular, or expected files, 5 for empty or not defined variables,
  162. 6 when a package already exist, 10 for network manager errors.
  163. For more details, see the @ref{Qi exit status} section.
  164. @node The qirc file
  165. @chapter The qirc file
  166. @cindex configuration file
  167. The global @file{qirc} file offers a way to define variables and tools
  168. (such as a download manager) for default use. This file is used by qi
  169. at runtime, e.g., to build, install, remove or upgrade packages.
  170. Variables and their possible values must be declared as any other
  171. variable in the shell.
  172. @noindent
  173. The command line options related to the package directory and target
  174. directory and some of the command line options used for the build command,
  175. have the power to override the values declared on @file{qirc}.
  176. See @ref{Invoking qi}.
  177. @noindent
  178. The order in which qi looks for this file is:
  179. @enumerate
  180. @item
  181. @env{$@{HOME@}/.qirc}
  182. @- Effective user.
  183. @item
  184. @samp{$@{sysconfdir@}/qirc}
  185. @- System-wide.
  186. @end enumerate
  187. If you intend to run qi as effective user, the file
  188. @samp{$@{sysconfdir@}/qirc} could be copied to @env{$@{HOME@}/.qirc}
  189. setting the paths for @samp{$@{packagedir@}} and @samp{$@{targetdir@}}
  190. according to the @env{$HOME}.
  191. @node Packages
  192. @chapter Packages
  193. @cindex managing packages
  194. A package is a suite of programs usually distributed in binary form
  195. which may also contain manual pages, documentation, or any other file
  196. associated to a specific software.
  197. The package format used by qi is a simplified POSIX pax archive
  198. compressed using lzip@footnote{For more details about tarlz and the
  199. lzip format, visit @url{https://lzip.nongnu.org/tarlz.html}.}. The
  200. file extension for packages ends in @samp{.tlz}.
  201. @noindent
  202. Both package installation and package de-installation are managed using
  203. two important (internal) variables: @samp{$@{packagedir@}} and
  204. @samp{$@{targetdir@}}, these values can be changed in the
  205. configuration file or via options.
  206. @samp{$@{packagedir@}} is a common directory tree where the package
  207. contents will be decompressed (will reside).
  208. @samp{$@{targetdir@}} is a target directory where the links will be
  209. made by graft(1) taking @samp{$@{packagedir@}/package_name} into account.
  210. @noindent
  211. Packages are installed in self-contained directory trees and symbolic
  212. links from a common area are made to the package files. This allows
  213. multiple versions of the same package to coexist on the same system.
  214. @section Package conflicts
  215. @cindex package conflicts
  216. All the links to install or remove a package are handled by graft(1).
  217. Since multiple packages can be installed or removed at the same time,
  218. certain conflicts may arise between the packages.
  219. @noindent
  220. graft@footnote{The official guide for Graft can be found at
  221. @url{https://peters.gormand.com.au/Home/tools/graft/graft.html}.}
  222. defines a CONFLICT as one of the following conditions:
  223. @itemize @bullet
  224. @item
  225. If the package object is a directory and the target object exists but is
  226. not a directory.
  227. @item
  228. If the package object is not a directory and the target object exists
  229. and is not a symbolic link.
  230. @item
  231. If the package object is not a directory and the target object exists
  232. and is a symbolic link to something other than the package object.
  233. @end itemize
  234. @noindent
  235. The default behavior of qi for an incoming package is to ABORT if a
  236. conflict arises. When a package is going to be deleted, qi tells to
  237. graft(1) to remove those parts that are not in conflict, leaving the
  238. links to the belonging package. This behavior can be forced if the
  239. --prune option is given.
  240. @section Installing packages
  241. @cindex package installation
  242. To install a single package, simply type:
  243. @example
  244. qi install coreutils_8.30_i586-1@@tools.tlz
  245. @end example
  246. @noindent
  247. To install multiple packages at once, type:
  248. @example
  249. qi install gcc_8.3.0_i586-1@@devel.tlz rafaela_2.2_i586-1@@legacy.tlz ...
  250. @end example
  251. @noindent
  252. Warn about the files that will be linked:
  253. @example
  254. qi warn bash_5.0_i586-1@@shells.tlz
  255. @end example
  256. This is to verify the content of a package before installing it.
  257. @noindent
  258. See the process of an installation:
  259. @example
  260. qi install --verbose mariana_3.0_i586-1@@woman.tlz
  261. @end example
  262. A second --verbose or -v option gives more (very verbose).
  263. @noindent
  264. Installing package in a different location:
  265. @example
  266. qi install --rootdir=/media/floppy lzip_1.21_i586-1@@compressors.tlz
  267. @end example
  268. Important: the --rootdir option assumes @samp{$@{targetdir@}} and
  269. @samp{$@{packagedir@}}. See the following example:
  270. @example
  271. qi install --rootdir=/home/selk lzip_1.21_i586-1@@compressors.tlz
  272. @end example
  273. The content of "lzip_1.21_i586-1@@compressors.tlz" will be decompressed
  274. into @samp{/home/selk/pkgs/lzip_1.21_i586-1@@compressors}.
  275. Assuming that the main binary for lzip is under
  276. @samp{/home/selk/pkgs/lzip_1.21_i586-1@@compressors/usr/bin/}
  277. the target for "usr/bin" will be created at @samp{/home/selk}. Considering
  278. that you have exported the @env{PATH} as @samp{$@{HOME@}/usr/bin}, now the
  279. system is able to see the recent lzip command.
  280. @noindent
  281. Installing from a list of packages using standard input:
  282. @example
  283. qi install - < PACKAGELIST.txt
  284. @end example
  285. Or in combination with another tool:
  286. @example
  287. sort -u PACKAGELIST.txt | qi install -
  288. @end example
  289. The sort command will read and sorts the list of declared packages,
  290. while trying to have unique entries for each statement. The output
  291. produced is captured by Qi to install each package.
  292. An example of a list containing package names is:
  293. @example
  294. /var/cache/qi/packages/amd64/tcl_8.6.9_amd64-1@@devel.tlz
  295. /var/cache/qi/packages/amd64/tk_8.6.9.1_amd64-1@@devel.tlz
  296. /var/cache/qi/packages/amd64/vala_0.42.3_amd64-1@@devel.tlz
  297. @end example
  298. @section Removing packages
  299. @cindex package de-installation
  300. To remove a package, simply type:
  301. @example
  302. qi remove xz_5.2.4_i586-1@@compressors.tlz
  303. @end example
  304. @noindent
  305. Remove command will match the package name using @samp{$@{packagedir@}} as
  306. prefix. For example, if the value of @samp{$@{packagedir@}} has been
  307. set to /usr/pkg, this will be equal to:
  308. @example
  309. qi remove /usr/pkg/xz_5.2.4_i586-1@@compressors
  310. @end example
  311. @noindent
  312. Detailed output:
  313. @example
  314. qi remove --verbose /usr/pkg/xz_5.2.4_i586-1@@compressors
  315. @end example
  316. A second --verbose or -v option gives more (very verbose).
  317. @noindent
  318. By default the remove command does not preserve a package directory after
  319. removing its links from @samp{$@{targetdir@}}, but this behavior can be
  320. changed if the --keep option is passed:
  321. @example
  322. qi remove --keep /usr/pkg/lzip_1.21_i586-1@@compressors
  323. @end example
  324. This means that the links to the package can be reactivated, later:
  325. @example
  326. cd /usr/pkg && graft -i lzip_1.21_i586-1@@compressors
  327. @end example
  328. @noindent
  329. Removing package from a different location:
  330. @example
  331. qi remove --rootdir=/home/cthulhu xz_5.2.4_i586-1@@compressors
  332. @end example
  333. @noindent
  334. Removing a package using standard input:
  335. @example
  336. echo vala_0.42.3_amd64-1@@devel | qi remove -
  337. @end example
  338. This will match with the package directory.
  339. @section Upgrading packages
  340. @cindex package upgrade
  341. The upgrade command inherits the properties of the installation and removal
  342. process. To make sure that a package is updated, the package is installed
  343. in a temporary directory taking @samp{$@{packagedir@}} into account. Once
  344. the incoming package is pre-installed, qi can proceed to search and delete
  345. packages that have the same name (considered as previous ones). Finally,
  346. the package is re-installed at its final location and the temporary
  347. directory is removed.
  348. Since updating a package can be crucial and so to perform a successful
  349. upgrade, from start to finish, you will want to ignore some important
  350. system signals during the upgrade process, those signals are SIGHUP,
  351. SIGINT, SIGQUIT, SIGABRT, and SIGTERM.
  352. @noindent
  353. To upgrade a package, just type:
  354. @example
  355. qi upgrade gcc_9.0.1_i586-1@@devel.tlz
  356. @end example
  357. This will proceed to upgrade "gcc_9.0.1_i586-1@@devel" removing any other
  358. version of "gcc" (if any).
  359. @noindent
  360. If you want to keep the package directories of versions found during the
  361. upgrade process, just pass:
  362. @example
  363. qi upgrade --keep gcc_9.0.1_i586-1@@devel.tlz
  364. @end example
  365. @noindent
  366. To see the upgrade process:
  367. @example
  368. qi upgrade --verbose gcc_9.0.1_i586-1@@devel.tlz
  369. @end example
  370. A second --verbose or -v option gives more (very verbose).
  371. @noindent
  372. To force the upgrade of an existing package:
  373. @example
  374. qi upgrade --force gcc_9.0.1_i586-1@@devel.tlz
  375. @end example
  376. @subsection Package blacklist
  377. @cindex package blacklist
  378. To implement general package facilities, either to install, remove or
  379. maintain the hierarchy of packages in a clean manner, qi makes use of the
  380. pruning operation via graft(1) by default:
  381. There is a risk if those are crucial packages for the proper functioning
  382. of the system, because it implies the deactivation of symbolic from the
  383. target directory, @emph{especially} when transitioning an incoming package
  384. into its final location during an upgrade.
  385. @noindent
  386. A blacklist of package names has been devised for the case where
  387. a user decides to upgrade all the packages in the system, or
  388. just the crucial ones, such as the C library.
  389. The blacklist is related to the upgrade command only, consists in installing
  390. a package instead of updating it or removing previous versions of it;
  391. the content of the package will be updated over the existing content at
  392. @samp{$@{packagedir@}}, while the existing links from
  393. @samp{$@{targetdir@}} will be preserved. A pruning of links will be
  394. carried out in order to re-link possible differences with the recent
  395. content, this helps to avoid leaving dead links in the target directory.
  396. @noindent
  397. Package names for the blacklist to be declared must be set from the
  398. configuration file. By default, it is declared using the package name,
  399. which is more than enough for critical system packages, but if you want to
  400. be more specific, you can declare a package using:
  401. @samp{$@{pkgname@}_$@{pkgversion@}_$@{arch@}-$@{release@}} where
  402. the package category is avoided for common matching. See
  403. @ref{Recipes, Special variables} for a description of these variables.
  404. @node Recipes
  405. @chapter Recipes
  406. @cindex recipes
  407. A recipe is a file telling qi what to do. Most often, the recipe tells
  408. qi how to build a binary package from a source tarball.
  409. A recipe has two parts: a list of variable definitions and a list of
  410. sections. By convention, the syntax of a section is:
  411. @example
  412. section_name()
  413. @{
  414. section lines
  415. @}
  416. @end example
  417. The section name is followed by parentheses, one newline and an opening
  418. brace. The line finishing the section contains just a closing brace.
  419. The section names or the function names currently recognized are
  420. @samp{build}.
  421. The @samp{build} section (or @strong{shell function}) is an augmented
  422. shell script that contains the main instructions to build software
  423. from source.
  424. If there are other functions defined by the packager, Qi detects them
  425. for later execution.
  426. @section Variables
  427. @cindex variables
  428. A "variable" is a @strong{shell variable} defined either in @file{qirc}
  429. or in a recipe to represent a string of text, called the variable's
  430. "value". These values are substituted by explicit request in the
  431. definitions of other variables or in calls to external commands.
  432. Variables can represent lists of file names, options to pass to
  433. compilers, programs to run, directories to look in for source files,
  434. directories to write output to, or anything else you can imagine.
  435. Definitions of variables in qi have four levels of precedence.
  436. Options which define variables from the command-line override those
  437. specified in the @file{qirc} file, while variables defined in the recipe
  438. override those specified in @file{qirc}, taking priority over those
  439. variables set by command-line options. Finally, the variables have
  440. default values if they are not defined anywhere.
  441. Options that set variables through the command-line can only reference
  442. variables defined in @file{qirc} and variables with default values.
  443. Definitions of variables in @file{qirc} can only reference variables
  444. previously defined in @file{qirc} and variables with default values.
  445. Definitions of variables in the recipe can only reference variables
  446. set by the command-line, variables previously defined in the recipe,
  447. variables defined in @file{qirc}, and variables with default values.
  448. @section Special variables
  449. @cindex special variables
  450. There are variables which can only be set using the command line options or
  451. via @file{qirc}, there are other special variables which can be defined or
  452. redefined in a recipe. See the following definitions:
  453. @samp{outdir} is the directory where the packages produced are written.
  454. This variable can be redefined per-recipe. Default sets to
  455. @samp{/var/cache/qi/packages}.
  456. @samp{worktree} is the working tree where archives, patches, and recipes
  457. are expected. This variable can not be redefined in the recipe. Default
  458. sets to @samp{/usr/src/qi}.
  459. @samp{tardir} is defined in the recipe to the directory where the tarball
  460. containing the source can be found. The full name of the tarball is
  461. composed as @samp{$@{tardir@}/$tarname}. Its value is available in the
  462. recipe as @samp{$@{tardir@}}; a value of . for @samp{tardir} sets it to
  463. the value of CWD (Current Working Directory), this is where the recipe
  464. lives.
  465. @samp{arch} is the architecture to compose the package name. Its value is
  466. available in the recipe as @samp{$@{arch@}}. Default value is the one
  467. that was set in the Qi configuration.
  468. @samp{jobs} is the number of parallel jobs to pass to the compiler. Its
  469. value is available in the recipe as @samp{$@{jobs@}}. The default value
  470. is 1.
  471. The two variables @samp{$@{srcdir@}} and @samp{$@{destdir@}} can be
  472. set in the recipe, as any other variable, but if they are not, qi uses
  473. default values for them when building a package.
  474. @samp{srcdir} contains the source code to be compiled, and defaults to
  475. @samp{$@{program@}-$@{version@}}. @samp{destdir} is the place where the
  476. built package will be installed, and defaults to
  477. @samp{$@{TMPDIR@}/package-$@{program@}}.
  478. If @samp{pkgname} is left undefined, the special variable @samp{program}
  479. is assigned by default. If @samp{pkgversion} is left undefined, the
  480. special variable @samp{version} is assigned by default.
  481. @samp{pkgname} and @samp{pkgversion} along with: @samp{version}, @samp{arch},
  482. @samp{release}, and (optionally) @samp{pkgcategory} are used to produce the
  483. package name in the form:
  484. @samp{$@{pkgname@}_$@{pkgversion@}_$@{arch@}-$@{release@}[@@$@{pkgcategory@}].tlz}
  485. @samp{pkgcategory} is an optional special variable that can be defined on the
  486. recipe to categorize the package name. If it is defined, then the
  487. package output will be composed as
  488. @samp{$@{pkgname@}_$@{pkgversion@}_$@{arch@}-$@{release@}[@@$@{pkgcategory@}.tlz}.
  489. Automatically, the value of @samp{pkgcategory} will be prefixed using the
  490. @samp{@@} (at) symbol which will be added to the last part of the package name.
  491. A special variable called @samp{replace} can be used to declare package names
  492. that will be replaced at installation time.
  493. The special variables @samp{keep_srcdir} and @samp{keep_destdir} are provided
  494. in order to preserve the directories @samp{$@{srcdir@}} or @samp{$@{destdir@}},
  495. if those exists as such. Note: The declaration of these variables are subject
  496. to manual deactivation; its purpose in recipes is to preserve the directories
  497. that relate to the package's build (source) and destination directory, that is
  498. so that another recipe can get a new package (or meta package) from there. For
  499. example, the declarations can be done as:
  500. @example
  501. keep_srcdir=keep_srcdir
  502. keep_destdir=keep_destdir
  503. @end example
  504. Then from another recipe you would proceed to copy the necessary files that
  505. will compose the meta package, from the main function you must deactivate
  506. the variables at the end:
  507. @example
  508. unset -v keep_srcdir
  509. unset -v keep_destdir
  510. @end example
  511. This will leave the 'keep_srcdir' and 'keep_destdir' variables blank to
  512. continue with the rest of the recipes.
  513. @noindent
  514. A typical recipe contains the following variables:
  515. @itemize @bullet
  516. @item @samp{program}: Software name.
  517. It matches the source name. It is also used to compose the name of the
  518. package if @samp{$@{pkgname@}} is not specified.
  519. @item @samp{version}: Software version.
  520. It matches the source name. It is also used to compose the version of the
  521. package if @samp{$@{pkgversion@}} is not specified.
  522. @item @samp{arch}: Software architecture.
  523. It is used to compose the architecture of the package in which it is
  524. build.
  525. @item @samp{release}: Release number.
  526. This is used to reflect the release number of the package. It is
  527. recommended to increase this number after any significant change in
  528. the recipe or post-install script.
  529. @item @samp{pkgcategory}: Package category.
  530. Optional but recommended variable to categorize the package name when it is
  531. created.
  532. @end itemize
  533. @noindent
  534. Obtaining sources over the network must be declared in the recipe using
  535. the @samp{fetch} variable.
  536. The variables @samp{netget} and @samp{rsync} can be defined in @file{qirc}
  537. to establish a network downloader in order to get the sources. If they
  538. are not defined, qi uses default values:
  539. @samp{netget} is the general network downloader tool, defaults sets to
  540. @samp{wget2 -c -w1 -t3 --no-check-certificate}.
  541. @samp{rsync} is the network tool for sources containing the prefix for
  542. the RSYNC protocol, default sets to
  543. @samp{rsync -v -a -L -z -i --progress}.
  544. The variable @samp{description} is used to print the package description
  545. when a package is installed.
  546. A description has two parts: a brief description, and a long description.
  547. By convention, the syntax of @samp{description} is:
  548. @example
  549. description="
  550. Brief description.
  551. Long description.
  552. "
  553. @end example
  554. The first line of the value represented is a brief description of the
  555. software (called "blurb"). A blank line separates the @emph{brief
  556. description} from the @emph{long description}, which should contain a more
  557. descriptive description of the software.
  558. @noindent
  559. An example looks like:
  560. @example
  561. description="
  562. The GNU core utilities.
  563. The GNU core utilities are the basic file, shell and text manipulation
  564. utilities of the GNU operating system. These are the core utilities
  565. which are expected to exist on every operating system.
  566. "
  567. @end example
  568. Please consider a length limit of 78 characters as maximum, because the same
  569. one would be used on the meta file creation. See
  570. @ref{Recipes, The meta file} section.
  571. The @samp{homepage} variable is used to declare the main site or home page:
  572. @example
  573. homepage=https://www.gnu.org/software/gcc
  574. @end example
  575. The variable @samp{license} is used for license information@footnote{
  576. The proposal for @samp{license} was made by Richard M. Stallman at
  577. @url{https://lists.gnu.org/archive/html/gnu-linux-libre/2016-05/msg00003.html}.}.
  578. Some code in the program can be covered by license A, license B, or
  579. license C. For "separate licensing" or "heterogeneous licensing", we
  580. suggest using @strong{|} for a disjunction, @strong{&} for a conjunction
  581. (if that ever happens in a significant way), and comma for heterogeneous
  582. licensing. Comma would have lower precedence, plus added special terms.
  583. @example
  584. license="LGPL, GPL | Artistic - added permission"
  585. @end example
  586. @section Writing recipes
  587. @cindex writing recipes
  588. Originally, Qi was designed for the series of Dragora GNU/Linux-Libre 3;
  589. this doesn't mean you can't use it in another distribution, just that if
  590. you do, you'll have to try it out for yourself. To help with this, here
  591. are some references to well-written recipes:
  592. @itemize @bullet
  593. @item @url{https://git.savannah.nongnu.org/cgit/dragora.git/tree/recipes}
  594. @item @url{https://notabug.org/dragora/dragora/src/master/recipes}
  595. @item @url{https://notabug.org/dragora/dragora-extras/src/master/recipes}
  596. @item @url{https://git.savannah.nongnu.org/cgit/dragora/dragora-extras.git/tree/recipes}
  597. @end itemize
  598. @section Building packages
  599. @cindex package build
  600. A recipe is any valid regular file. Qi sets priorities for reading a
  601. recipe, the order in which qi looks for a recipe is:
  602. @enumerate
  603. @item
  604. Current working directory.
  605. @item
  606. If the specified path name does not contain "recipe" as the last
  607. component. Qi will complete it by adding "recipe" to the path name.
  608. @item
  609. If the recipe is not in the current working directory, it will be
  610. searched under @samp{$@{worktree@}/recipes}. The last component will be
  611. completed adding "recipe" to the specified path name.
  612. @end enumerate
  613. @noindent
  614. To build a single package, type:
  615. @example
  616. qi build x-apps/xterm
  617. @end example
  618. @noindent
  619. Multiple jobs can be passed to the compiler to speed up the build process:
  620. @example
  621. qi build --jobs 3 x-apps/xterm
  622. @end example
  623. @noindent
  624. Update or install the produced package (if not already installed) when the
  625. build command ends:
  626. @example
  627. qi build -j3 --upgrade x-apps/xterm
  628. @end example
  629. @noindent
  630. Only process a recipe but do not create the binary package:
  631. @example
  632. qi build --no-package dict/aspell
  633. @end example
  634. The options --install or --upgrade have no effect when --no-package
  635. is given.
  636. @noindent
  637. This is useful to inspect the build process of the above recipe:
  638. qi build --keep --no-package dict/aspell 2>&1 | tee aspell-log.txt
  639. The --keep option could preserve the source directory and the destination
  640. directory for later inspection. A log file of the build process will be
  641. created redirecting both, standard error and standard output to tee(1).
  642. @section Variables from the environment
  643. @cindex environment variables
  644. Qi has environment variables which can be used at build time:
  645. The variable @env{TMPDIR} sets the temporary directory for sources, which is
  646. used for package extractions (see @ref{Examining packages}) and is
  647. prepended to the value of @samp{$@{srcdir@}} and @samp{$@{destdir@}} in
  648. build command. By convention its default value is equal to
  649. @samp{/usr/src/qi/build}.
  650. The variables @env{QICFLAGS}, @env{QICXXFLAGS}, @env{QILDFLAGS}, and
  651. @env{QICPPFLAGS} have no effect by default. The environment variables
  652. such as @env{CFLAGS}, @env{CXXFLAGS}, @env{LDFLAGS}, and @env{CPPFLAGS}
  653. are unset at compile time:
  654. @noindent
  655. Recommended practice is to set variables in the command line of
  656. @samp{configure} or @emph{make(1)} instead of exporting to the
  657. environment. As follows:
  658. @url{https://www.gnu.org/software/make/manual/html_node/Environment.html}
  659. @quotation
  660. It is not wise for makefiles to depend for their functioning on environment
  661. variables set up outside their control, since this would cause different
  662. users to get different results from the same makefile. This is against the
  663. whole purpose of most makefiles.
  664. @end quotation
  665. Setting environment variables for configure is deprecated because running
  666. configure in varying environments can be dangerous.
  667. @url{https://gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.69/html_node/Defining-Variables.html}
  668. @quotation
  669. Variables not defined in a site shell script can be set in the environment
  670. passed to configure. However, some packages may run configure again
  671. during the build, and the customized values of these variables may be
  672. lost. In order to avoid this problem, you should set them in the
  673. configure command line, using @samp{VAR=value}. For example:
  674. @code{./configure CC=/usr/local2/bin/gcc}
  675. @end quotation
  676. @url{https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.69/html_node/Setting-Output-Variables.html}
  677. @quotation
  678. If for instance the user runs @samp{CC=bizarre-cc ./configure}, then the cache,
  679. config.h, and many other output files depend upon bizarre-cc being the C
  680. compiler. If for some reason the user runs ./configure again, or if it is
  681. run via @samp{./config.status --recheck}, (See Automatic Remaking, and see
  682. config.status Invocation), then the configuration can be inconsistent,
  683. composed of results depending upon two different compilers.
  684. [...]
  685. Indeed, while configure can notice the definition of CC in @samp{./configure
  686. CC=bizarre-cc}, it is impossible to notice it in @samp{CC=bizarre-cc
  687. ./configure}, which, unfortunately, is what most users do.
  688. [...]
  689. configure: error: changes in the environment can compromise the build.
  690. @end quotation
  691. If the @env{SOURCE_DATE_EPOCH} environment variable is set to a UNIX timestamp
  692. (defined as the number of seconds, excluding leap seconds, since 01 Jan 1970
  693. 00:00:00 UTC.); then the given timestamp will be used to overwrite any newer
  694. timestamps on the package contents (when it is created). More information
  695. about this can be found at
  696. @uref{https://reproducible-builds.org/specs/source-date-epoch/}.
  697. @section The meta file
  698. @cindex the meta file
  699. The "meta file" is a regular file created during the build process, it
  700. contains information about the package such as package name, package
  701. version, architecture, release, fetch address, description, and other
  702. minor data extracted from processed recipes. The name of the file is
  703. generated as @samp{$@{full_pkgname@}.tlz.txt}, and its purpose is to
  704. reflect essential information to the user without having to look inside
  705. the package content. The file format is also intended to be used by
  706. other scripts or by common Unix tools.
  707. The content of a meta file looks like:
  708. @example
  709. #
  710. # Pattern scanning and processing language.
  711. #
  712. # The awk utility interprets a special-purpose programming language
  713. # that makes it possible to handle simple data-reformatting jobs
  714. # with just a few lines of code. It is a free version of 'awk'.
  715. #
  716. # GNU awk implements the AWK utility which is part of
  717. # IEEE Std 1003.1 Shell and Utilities (XCU).
  718. #
  719. QICFLAGS="-O2"
  720. QICXXFLAGS="-O2"
  721. QILDFLAGS=""
  722. QICPPFLAGS=""
  723. pkgname=gawk
  724. pkgversion=5.0.1
  725. arch=amd64
  726. release=1
  727. pkgcategory="tools"
  728. full_pkgname=gawk_5.0.1_amd64-1@@tools
  729. blurb="Pattern scanning and processing language."
  730. homepage="https://www.gnu.org/software/gawk"
  731. license="GPLv3+"
  732. fetch="https://ftp.gnu.org/gnu/gawk/gawk-5.0.1.tar.lz"
  733. replace=""
  734. @end example
  735. A package descriptions is extracted from the variable @samp{description}
  736. where each line is interpreted literally and pre-formatted to fit in
  737. (exactly) @strong{80 columns}, plus the character @samp{#} and a blank
  738. space is prefixed to every line (shell comments).
  739. @noindent
  740. In addition to the Special variables, there are implicit variables such as
  741. @samp{blurb}:
  742. The @samp{blurb} variable is related to the special variable
  743. @samp{description}. Its value is made from the first (substantial)
  744. line of @samp{description}, mentioned as the "brief description".
  745. The build flags such as @samp{QICFLAGS}, @samp{QICXXFLAGS},
  746. @samp{QILDFLAGS}, and @samp{QICPPFLAGS} are only added to the meta file
  747. if the declared variable @samp{arch} is not equal to the "noarch" value.
  748. @node Order files
  749. @chapter Order files
  750. @cindex handling build order
  751. The order command has the purpose of resolving the build order through
  752. .order files. An order file contains a list of recipe names, by default
  753. does not perform any action other than to print a resolved list in
  754. descending order. For example, if @strong{a} depends on @strong{b} and
  755. @strong{c}, and @strong{c} depends on @strong{b} as well, the file might
  756. look like:
  757. @example
  758. a: c b
  759. b:
  760. c: b
  761. @end example
  762. Each letter represents a recipe name, complete dependencies for
  763. the first recipe name are listed in descending order, which is
  764. printed from right to left, and removed from left to right:
  765. @sc{Output}
  766. @example
  767. b
  768. c
  769. a
  770. @end example
  771. Blank lines, colons and parentheses are simply ignored. Comment lines
  772. beginning with @samp{#} are allowed.
  773. @noindent
  774. An order file could be used to build a series of packages, for example,
  775. if the content is:
  776. @example
  777. # Image handling libraries
  778. libs/libjpeg-turbo: devel/nasm
  779. x-libs/jasper: libs/libjpeg-turbo
  780. libs/tiff: libs/libjpeg-turbo
  781. @end example
  782. To proceed with each recipe, we can type:
  783. @example
  784. qi order imglibs.order | qi build --install -
  785. @end example
  786. The output of @samp{qi order imglibs.order} tells to qi in which order it
  787. should build the recipes:
  788. @example
  789. devel/nasm
  790. libs/libjpeg-turbo
  791. x-libs/jasper
  792. libs/tiff
  793. @end example
  794. @node Creating packages
  795. @chapter Creating packages
  796. @cindex package creation
  797. The creation command is an internal function of qi to make new Qi
  798. compatible packages. A package is produced using the contents of
  799. the Current Working Directory and the package file is written out.
  800. @example
  801. Usage: qi create [@var{Output/PackageName.tlz}]...
  802. @end example
  803. The argument for the file name to be written must contain a fully
  804. qualified named directory as the output directory where the package
  805. produced will be written. The file name should be composed using the
  806. full name: name-version-architecture-release[@@pkgcategory].tlz
  807. @sc{Example}
  808. @example
  809. cd /usr/pkg
  810. cd claws-mail_3.17.1_amd64-1@@x-apps
  811. qi create /var/cache/qi/packages/claws-mail_3.17.1_amd64-1@@x-apps
  812. @end example
  813. In this case, the package "claws-mail_3.17.1_amd64-1@@x-apps" will be
  814. written into @samp{/var/cache/qi/packages/}.
  815. @noindent
  816. All packages produced are complemented by a checksum file (.sha256).
  817. @node Examining packages
  818. @chapter Examining packages
  819. @cindex package examination
  820. The extraction command serves to examine binary packages for debugging
  821. purposes. It decompresses a package into a single directory, verifying
  822. its integrity and preserving all of its properties (owner and permissions).
  823. @example
  824. Usage: qi extract [@var{packagename.tlz}]...
  825. @end example
  826. @sc{Example}
  827. @example
  828. qi extract mksh_R56c_amd64-1@@shells.tlz
  829. @end example
  830. This action will put the content of "mksh_R56c_amd64-1@@shells.tlz" into a
  831. single directory, this is a private directory for the user who requested
  832. the action, creation operation will be equal to @strong{u=rwx,g=,o= (0700)}.
  833. The package content will reside on this location, default mask to deploy
  834. the content will be equal to @strong{u=rwx,g=rwx,o=rwx (0000)}.
  835. @noindent
  836. Note: the creation of the custom directory is influenced by the value
  837. of the @env{TMPDIR} variable.
  838. @node Qi exit status
  839. @chapter Qi exit status
  840. @cindex exit codes
  841. All the exit codes are described in this chapter.
  842. @table @samp
  843. @item 0
  844. Successful completion (no errors).
  845. @item 1
  846. Minor common errors:
  847. @itemize @bullet
  848. @item Help usage on invalid options or required arguments.
  849. @item Program needed by qi (prerequisite) is not available.
  850. @end itemize
  851. @item 2
  852. Command execution error:
  853. This code is used to return the evaluation of an external command or shell
  854. arguments in case of failure.
  855. @item 3
  856. Integrity check error for compressed files.
  857. Compressed files means:
  858. @itemize @bullet
  859. @item A tarball file from tar(1).
  860. Supported extensions: .tar, .tar.gz, .tgz, .tar.Z, .tar.bz2, .tbz2, .tbz,
  861. .tar.xz, .txz
  862. @item A tarball file from tarlz(1).
  863. Supported extensions: .tar.lz, .tlz
  864. @item Zip files from unzip(1).
  865. Supported extensions: .zip, .ZIP
  866. @item Gzip files from gzip(1).
  867. Supported extensions: .gz, .Z
  868. @item Bzip2 files from bzip2(1).
  869. Supported extension: .bz2
  870. @item Lzip files from lzip(1).
  871. Supported extension: .lz
  872. @item Xz files from xz(1).
  873. Supported extension: .xz
  874. @end itemize
  875. @item 4
  876. File empty, not regular, or expected.
  877. It's commonly expected:
  878. @itemize @bullet
  879. @item An argument for giving commands.
  880. @item A regular file or readable directory.
  881. @item An expected extension: .tlz, .sha256, .order.
  882. @item A protocol supported by the network downloader tool.
  883. @end itemize
  884. @item 5
  885. Empty or not defined variable:
  886. This code is used to report empty or undefined variables (usually
  887. variables coming from a recipe or assigned arrays that are tested).
  888. @item 6
  889. Package already installed:
  890. The package directory for an incoming .tlz package already exists.
  891. @item 10
  892. Network manager error:
  893. This code is used if the network downloader tool fails for some reason.
  894. @end table