qi-content.texi 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194
  1. @c -*-texinfo-*-
  2. @c qi-content.texi
  3. @c This is part of the Qi user guide.
  4. @c Copyright (C) 2019-2022 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 keep_destdir
  509. @end example
  510. This will leave the 'keep_srcdir' and 'keep_destdir' variables blank to
  511. continue with the rest of the recipes.
  512. @noindent
  513. A typical recipe contains the following variables:
  514. @itemize @bullet
  515. @item @samp{program}: Software name.
  516. It matches the source name. It is also used to compose the name of the
  517. package if @samp{$@{pkgname@}} is not specified.
  518. @item @samp{version}: Software version.
  519. It matches the source name. It is also used to compose the version of the
  520. package if @samp{$@{pkgversion@}} is not specified.
  521. @item @samp{arch}: Software architecture.
  522. It is used to compose the architecture of the package in which it is
  523. build.
  524. @item @samp{release}: Release number.
  525. This is used to reflect the release number of the package. It is
  526. recommended to increase this number after any significant change in
  527. the recipe or post-install script.
  528. @item @samp{pkgcategory}: Package category.
  529. Optional but recommended variable to categorize the package name when it is
  530. created.
  531. @end itemize
  532. @noindent
  533. Obtaining sources over the network must be declared in the recipe using
  534. the @samp{fetch} variable.
  535. The variables @samp{netget} and @samp{rsync} can be defined in @file{qirc}
  536. to establish a network downloader in order to get the sources. If they
  537. are not defined, qi uses default values:
  538. @samp{netget} is the general network downloader tool, defaults sets to
  539. @samp{wget2 -c -w1 -t3 --no-check-certificate}.
  540. @samp{rsync} is the network tool for sources containing the prefix for
  541. the RSYNC protocol, default sets to
  542. @samp{rsync -v -a -L -z -i --progress}.
  543. The variable @samp{description} is used to print the package description
  544. when a package is installed.
  545. A description has two parts: a brief description, and a long description.
  546. By convention, the syntax of @samp{description} is:
  547. @example
  548. description="
  549. Brief description.
  550. Long description.
  551. "
  552. @end example
  553. The first line of the value represented is a brief description of the
  554. software (called "blurb"). A blank line separates the @emph{brief
  555. description} from the @emph{long description}, which should contain a more
  556. descriptive description of the software.
  557. @noindent
  558. An example looks like:
  559. @example
  560. description="
  561. The GNU core utilities.
  562. The GNU core utilities are the basic file, shell and text manipulation
  563. utilities of the GNU operating system. These are the core utilities
  564. which are expected to exist on every operating system.
  565. "
  566. @end example
  567. Please consider a length limit of 78 characters as maximum, because the same
  568. one would be used on the meta file creation. See
  569. @ref{Recipes, The meta file} section.
  570. The @samp{homepage} variable is used to declare the main site or home page:
  571. @example
  572. homepage=https://www.gnu.org/software/gcc
  573. @end example
  574. The variable @samp{license} is used for license information@footnote{
  575. The proposal for @samp{license} was made by Richard M. Stallman at
  576. @url{https://lists.gnu.org/archive/html/gnu-linux-libre/2016-05/msg00003.html}.}.
  577. Some code in the program can be covered by license A, license B, or
  578. license C. For "separate licensing" or "heterogeneous licensing", we
  579. suggest using @strong{|} for a disjunction, @strong{&} for a conjunction
  580. (if that ever happens in a significant way), and comma for heterogeneous
  581. licensing. Comma would have lower precedence, plus added special terms.
  582. @example
  583. license="LGPL, GPL | Artistic - added permission"
  584. @end example
  585. @section Writing recipes
  586. @cindex writing recipes
  587. Originally, Qi was designed for the series of Dragora GNU/Linux-Libre 3;
  588. this doesn't mean you can't use it in another distribution, just that if
  589. you do, you'll have to try it out for yourself. To help with this, here
  590. are some references to well-written recipes:
  591. @itemize @bullet
  592. @item @url{https://git.savannah.nongnu.org/cgit/dragora.git/tree/recipes}
  593. @item @url{https://notabug.org/dragora/dragora/src/master/recipes}
  594. @item @url{https://notabug.org/dragora/dragora-extras/src/master/recipes}
  595. @item @url{https://git.savannah.nongnu.org/cgit/dragora/dragora-extras.git/tree/recipes}
  596. @end itemize
  597. @section Building packages
  598. @cindex package build
  599. A recipe is any valid regular file. Qi sets priorities for reading a
  600. recipe, the order in which qi looks for a recipe is:
  601. @enumerate
  602. @item
  603. Current working directory.
  604. @item
  605. If the specified path name does not contain "recipe" as the last
  606. component. Qi will complete it by adding "recipe" to the path name.
  607. @item
  608. If the recipe is not in the current working directory, it will be
  609. searched under @samp{$@{worktree@}/recipes}. The last component will be
  610. completed adding "recipe" to the specified path name.
  611. @end enumerate
  612. @noindent
  613. To build a single package, type:
  614. @example
  615. qi build x-apps/xterm
  616. @end example
  617. @noindent
  618. Multiple jobs can be passed to the compiler to speed up the build process:
  619. @example
  620. qi build --jobs 3 x-apps/xterm
  621. @end example
  622. @noindent
  623. Update or install the produced package (if not already installed) when the
  624. build command ends:
  625. @example
  626. qi build -j3 --upgrade x-apps/xterm
  627. @end example
  628. @noindent
  629. Only process a recipe but do not create the binary package:
  630. @example
  631. qi build --no-package dict/aspell
  632. @end example
  633. The options --install or --upgrade have no effect when --no-package
  634. is given.
  635. @noindent
  636. This is useful to inspect the build process of the above recipe:
  637. qi build --keep --no-package dict/aspell 2>&1 | tee aspell-log.txt
  638. The --keep option could preserve the source directory and the destination
  639. directory for later inspection. A log file of the build process will be
  640. created redirecting both, standard error and standard output to tee(1).
  641. @section Variables from the environment
  642. @cindex environment variables
  643. Qi has environment variables which can be used at build time:
  644. The variable @env{TMPDIR} sets the temporary directory for sources, which is
  645. used for package extractions (see @ref{Examining packages}) and is
  646. prepended to the value of @samp{$@{srcdir@}} and @samp{$@{destdir@}} in
  647. build command. By convention its default value is equal to
  648. @samp{/usr/src/qi/build}.
  649. The variables @env{QICFLAGS}, @env{QICXXFLAGS}, @env{QILDFLAGS}, and
  650. @env{QICPPFLAGS} have no effect by default. The environment variables
  651. such as @env{CFLAGS}, @env{CXXFLAGS}, @env{LDFLAGS}, and @env{CPPFLAGS}
  652. are unset at compile time:
  653. @noindent
  654. Recommended practice is to set variables in the command line of
  655. @samp{configure} or @emph{make(1)} instead of exporting to the
  656. environment. As follows:
  657. @url{https://www.gnu.org/software/make/manual/html_node/Environment.html}
  658. @quotation
  659. It is not wise for makefiles to depend for their functioning on environment
  660. variables set up outside their control, since this would cause different
  661. users to get different results from the same makefile. This is against the
  662. whole purpose of most makefiles.
  663. @end quotation
  664. Setting environment variables for configure is deprecated because running
  665. configure in varying environments can be dangerous.
  666. @url{https://gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.69/html_node/Defining-Variables.html}
  667. @quotation
  668. Variables not defined in a site shell script can be set in the environment
  669. passed to configure. However, some packages may run configure again
  670. during the build, and the customized values of these variables may be
  671. lost. In order to avoid this problem, you should set them in the
  672. configure command line, using @samp{VAR=value}. For example:
  673. @code{./configure CC=/usr/local2/bin/gcc}
  674. @end quotation
  675. @url{https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.69/html_node/Setting-Output-Variables.html}
  676. @quotation
  677. If for instance the user runs @samp{CC=bizarre-cc ./configure}, then the cache,
  678. config.h, and many other output files depend upon bizarre-cc being the C
  679. compiler. If for some reason the user runs ./configure again, or if it is
  680. run via @samp{./config.status --recheck}, (See Automatic Remaking, and see
  681. config.status Invocation), then the configuration can be inconsistent,
  682. composed of results depending upon two different compilers.
  683. [...]
  684. Indeed, while configure can notice the definition of CC in @samp{./configure
  685. CC=bizarre-cc}, it is impossible to notice it in @samp{CC=bizarre-cc
  686. ./configure}, which, unfortunately, is what most users do.
  687. [...]
  688. configure: error: changes in the environment can compromise the build.
  689. @end quotation
  690. If the @env{SOURCE_DATE_EPOCH} environment variable is set to a UNIX timestamp
  691. (defined as the number of seconds, excluding leap seconds, since 01 Jan 1970
  692. 00:00:00 UTC.); then the given timestamp will be used to overwrite any newer
  693. timestamps on the package contents (when it is created). More information
  694. about this can be found at
  695. @uref{https://reproducible-builds.org/specs/source-date-epoch/}.
  696. @section The meta file
  697. @cindex the meta file
  698. The "meta file" is a regular file created during the build process, it
  699. contains information about the package such as package name, package
  700. version, architecture, release, fetch address, description, and other
  701. minor data extracted from processed recipes. The name of the file is
  702. generated as @samp{$@{full_pkgname@}.tlz.txt}, and its purpose is to
  703. reflect essential information to the user without having to look inside
  704. the package content. The file format is also intended to be used by
  705. other scripts or by common Unix tools.
  706. The content of a meta file looks like:
  707. @example
  708. #
  709. # Pattern scanning and processing language.
  710. #
  711. # The awk utility interprets a special-purpose programming language
  712. # that makes it possible to handle simple data-reformatting jobs
  713. # with just a few lines of code. It is a free version of 'awk'.
  714. #
  715. # GNU awk implements the AWK utility which is part of
  716. # IEEE Std 1003.1 Shell and Utilities (XCU).
  717. #
  718. QICFLAGS="-O2"
  719. QICXXFLAGS="-O2"
  720. QILDFLAGS=""
  721. QICPPFLAGS=""
  722. pkgname=gawk
  723. pkgversion=5.0.1
  724. arch=amd64
  725. release=1
  726. pkgcategory="tools"
  727. full_pkgname=gawk_5.0.1_amd64-1@@tools
  728. blurb="Pattern scanning and processing language."
  729. homepage="https://www.gnu.org/software/gawk"
  730. license="GPLv3+"
  731. fetch="https://ftp.gnu.org/gnu/gawk/gawk-5.0.1.tar.lz"
  732. replace=""
  733. @end example
  734. A package descriptions is extracted from the variable @samp{description}
  735. where each line is interpreted literally and pre-formatted to fit in
  736. (exactly) @strong{80 columns}, plus the character @samp{#} and a blank
  737. space is prefixed to every line (shell comments).
  738. @noindent
  739. In addition to the Special variables, there are implicit variables such as
  740. @samp{blurb}:
  741. The @samp{blurb} variable is related to the special variable
  742. @samp{description}. Its value is made from the first (substantial)
  743. line of @samp{description}, mentioned as the "brief description".
  744. The build flags such as @samp{QICFLAGS}, @samp{QICXXFLAGS},
  745. @samp{QILDFLAGS}, and @samp{QICPPFLAGS} are only added to the meta file
  746. if the declared variable @samp{arch} is not equal to the "noarch" value.
  747. @node Order files
  748. @chapter Order files
  749. @cindex handling build order
  750. The order command has the purpose of resolving the build order through
  751. .order files. An order file contains a list of recipe names, by default
  752. does not perform any action other than to print a resolved list in
  753. descending order. For example, if @strong{a} depends on @strong{b} and
  754. @strong{c}, and @strong{c} depends on @strong{b} as well, the file might
  755. look like:
  756. @example
  757. a: c b
  758. b:
  759. c: b
  760. @end example
  761. Each letter represents a recipe name, complete dependencies for
  762. the first recipe name are listed in descending order, which is
  763. printed from right to left, and removed from left to right:
  764. @sc{Output}
  765. @example
  766. b
  767. c
  768. a
  769. @end example
  770. Blank lines, colons and parentheses are simply ignored. Comment lines
  771. beginning with @samp{#} are allowed.
  772. @noindent
  773. An order file could be used to build a series of packages, for example,
  774. if the content is:
  775. @example
  776. # Image handling libraries
  777. libs/libjpeg-turbo: devel/nasm
  778. x-libs/jasper: libs/libjpeg-turbo
  779. libs/tiff: libs/libjpeg-turbo
  780. @end example
  781. To proceed with each recipe, we can type:
  782. @example
  783. qi order imglibs.order | qi build --install -
  784. @end example
  785. The output of @samp{qi order imglibs.order} tells to qi in which order it
  786. should build the recipes:
  787. @example
  788. devel/nasm
  789. libs/libjpeg-turbo
  790. x-libs/jasper
  791. libs/tiff
  792. @end example
  793. @node Creating packages
  794. @chapter Creating packages
  795. @cindex package creation
  796. The creation command is an internal function of qi to make new Qi
  797. compatible packages. A package is produced using the contents of
  798. the Current Working Directory and the package file is written out.
  799. @example
  800. Usage: qi create [@var{Output/PackageName.tlz}]...
  801. @end example
  802. The argument for the file name to be written must contain a fully
  803. qualified named directory as the output directory where the package
  804. produced will be written. The file name should be composed using the
  805. full name: name-version-architecture-release[@@pkgcategory].tlz
  806. @sc{Example}
  807. @example
  808. cd /usr/pkg
  809. cd claws-mail_3.17.1_amd64-1@@x-apps
  810. qi create /var/cache/qi/packages/claws-mail_3.17.1_amd64-1@@x-apps
  811. @end example
  812. In this case, the package "claws-mail_3.17.1_amd64-1@@x-apps" will be
  813. written into @samp{/var/cache/qi/packages/}.
  814. @noindent
  815. All packages produced are complemented by a checksum file (.sha256).
  816. @node Examining packages
  817. @chapter Examining packages
  818. @cindex package examination
  819. The extraction command serves to examine binary packages for debugging
  820. purposes. It decompresses a package into a single directory, verifying
  821. its integrity and preserving all of its properties (owner and permissions).
  822. @example
  823. Usage: qi extract [@var{packagename.tlz}]...
  824. @end example
  825. @sc{Example}
  826. @example
  827. qi extract mksh_R56c_amd64-1@@shells.tlz
  828. @end example
  829. This action will put the content of "mksh_R56c_amd64-1@@shells.tlz" into a
  830. single directory, this is a private directory for the user who requested
  831. the action, creation operation will be equal to @strong{u=rwx,g=,o= (0700)}.
  832. The package content will reside on this location, default mask to deploy
  833. the content will be equal to @strong{u=rwx,g=rwx,o=rwx (0000)}.
  834. @noindent
  835. Note: the creation of the custom directory is influenced by the value
  836. of the @env{TMPDIR} variable.
  837. @node Qi exit status
  838. @chapter Qi exit status
  839. @cindex exit codes
  840. All the exit codes are described in this chapter.
  841. @table @samp
  842. @item 0
  843. Successful completion (no errors).
  844. @item 1
  845. Minor common errors:
  846. @itemize @bullet
  847. @item Help usage on invalid options or required arguments.
  848. @item Program needed by qi (prerequisite) is not available.
  849. @end itemize
  850. @item 2
  851. Command execution error:
  852. This code is used to return the evaluation of an external command or shell
  853. arguments in case of failure.
  854. @item 3
  855. Integrity check error for compressed files.
  856. Compressed files means:
  857. @itemize @bullet
  858. @item A tarball file from tar(1).
  859. Supported extensions: .tar, .tar.gz, .tgz, .tar.Z, .tar.bz2, .tbz2, .tbz,
  860. .tar.xz, .txz
  861. @item A tarball file from tarlz(1).
  862. Supported extensions: .tar.lz, .tlz
  863. @item Zip files from unzip(1).
  864. Supported extensions: .zip, .ZIP
  865. @item Gzip files from gzip(1).
  866. Supported extensions: .gz, .Z
  867. @item Bzip2 files from bzip2(1).
  868. Supported extension: .bz2
  869. @item Lzip files from lzip(1).
  870. Supported extension: .lz
  871. @item Xz files from xz(1).
  872. Supported extension: .xz
  873. @end itemize
  874. @item 4
  875. File empty, not regular, or expected.
  876. It's commonly expected:
  877. @itemize @bullet
  878. @item An argument for giving commands.
  879. @item A regular file or readable directory.
  880. @item An expected extension: .tlz, .sha256, .order.
  881. @item A protocol supported by the network downloader tool.
  882. @end itemize
  883. @item 5
  884. Empty or not defined variable:
  885. This code is used to report empty or undefined variables (usually
  886. variables coming from a recipe or assigned arrays that are tested).
  887. @item 6
  888. Package already installed:
  889. The package directory for an incoming .tlz package already exists.
  890. @item 10
  891. Network manager error:
  892. This code is used if the network downloader tool fails for some reason.
  893. @end table