design.txt 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. Lucas Skoeldqvist <frusen@dragora.org>
  2. 2016-11-30 rev 1: initial write up
  3. 1 INTRODUCTION
  4. ==============
  5. Dragora does have a system for managing packages already (pkgsystem[1] in
  6. Dragora version 2 and qi[2] in version 3). Both of them can build, install,
  7. remove, and upgrade packages, but with limited flexibility; they only work
  8. with local packages on the system. There is no way to search for available
  9. packages, check for upgrades, or fetch packages.
  10. This is where jul comes in. Jul uses the existing package managers and adds
  11. aditional functionality on top. There is a working yet incomplete version
  12. available for use today on Dragora 2.
  13. One can think of pkgsystem/qi as dpkg and jul as apt-get (in Debian) but with
  14. a simpler design.
  15. [1] http://www.dragora.org/repo.fsl/doc/trunk/www/dragora2/guides/pkgmanager.md
  16. [2] http://www.dragora.org/repo.fsl/dir?name=qi
  17. 2 DESIGN
  18. ========
  19. Jul is written in Tcl[1] and has a command line interface. The interface is
  20. modeled after Fossil[2] but commands are named similar to that of pkgsystem
  21. and qi. Some examples:
  22. $ jul search foo
  23. $ jul help add
  24. $ jul add -h
  25. [1] https://tcl.tk/
  26. [2] http://fossil-scm.org/
  27. 2.1 COMMANDS
  28. ============
  29. The following commands are needed:
  30. 1) add/install
  31. 2) list
  32. 3) search
  33. 4) sync/update
  34. 5) upgrade
  35. 6) help
  36. 2.1.1 ADD/INSTALL
  37. =================
  38. These commands do the same thing; adds a package to system. Jul will do a
  39. search for the given package(s) and list the matches. One can then choose from
  40. the list of packages which package(s) to install.
  41. In jul 0.5 you can only add one package at a time, and a list of matches makes
  42. sense. But it is not clear how this would work when multiple packages are
  43. specified on the command line.
  44. 2.1.2 LIST
  45. ==========
  46. This command lists installed packages. It can have options to only list
  47. packages from certain repositories (see section 3) or match against a search
  48. term.
  49. 2.1.3 SEARCH
  50. ============
  51. `search' takes on or more search-terms and looks for packages. By default it
  52. searches in all enabled repositories but it could take an option to only search
  53. in one or more repositories.
  54. Currently searches in a local copy of the database of available packages. One
  55. might want to do an update simultaneously (see section 4).
  56. 2.1.4 SYNC/UPDATE
  57. =================
  58. These commands fetch the latest changes from the repositories.
  59. 2.1.5 UPGRADE
  60. =============
  61. `upgrade' compares the installed packages with the ones in the database, and
  62. if they are newer in the database, they can be upgraded.
  63. Some useful options to this commands could be:
  64. 1) --list/-l only list available upgrade, don't prompt to upgrade
  65. 2) --onlysec/-o only list/upgrade packages that are vulnerable
  66. 2.1.6 HELP
  67. ==========
  68. The `help' command is used to display help screens. It shows the same help
  69. that the `-h' option does, so these command lines are equivalent:
  70. $ jul help
  71. $ jul -h
  72. $ jul help add
  73. $ jul add -h
  74. 3 REPOSITORIES
  75. ==============
  76. A repository is a SQLite[1] database with a few tables. Currently (see section
  77. 3.2) it has support for basic package information plus descriptions.
  78. Packages are added to the database and then the database is downloaded by jul
  79. when doing a sync/update. The copy is stored in $HOME/.jul and used by most
  80. commands.
  81. Up until now I've manually (or via scripts) added package information to the
  82. database. It is a lot of work and we need a better and simpler way...
  83. [1] https://sqlite.org/
  84. 3.1 GENERATING DATABASES
  85. ========================
  86. Qi introduces `.meta' files, which contain most of the information needed for
  87. an entry in the database. A meta file could look something like this:
  88. name="foo"
  89. version="1.3"
  90. desc="Simple program"
  91. license="GPLv3+"
  92. order="bar zab foo"
  93. If each package has one of these files a database can easily be generated by
  94. parsing these files.
  95. 3.2 SQLITE SCHEMA
  96. =================
  97. CREATE TABLE repository (
  98. name text,
  99. url text,
  100. PRIMARY KEY(name)
  101. );
  102. CREATE TABLE description (
  103. name text,
  104. lang text,
  105. desc text,
  106. PRIMARY KEY(name)
  107. );
  108. CREATE TABLE location (
  109. name text,
  110. url text,
  111. PRIMARY KEY(name)
  112. );
  113. CREATE TABLE package (
  114. repo text,
  115. name text,
  116. version text,
  117. arch text,
  118. build integer,
  119. FOREIGN KEY(repo) REFERENCES repository,
  120. FOREIGN KEY(name) REFERENCES description
  121. );
  122. 3.3 HOSTING AND SYNCHRONISING
  123. =============================
  124. One hosts a database simply by serving it via HTTP. The database on
  125. gungre.ch is available at: https://gungre.ch/jul/gungre.db
  126. (the databases contain one or more repositories)
  127. Curl[1] is used for fetching so other protocols are supported as well.
  128. Jul supports multiple databases so you could point at dragora.org for the
  129. default repository, gungre.ch for community repositories, and so on.
  130. It would be better if each host could synchronise the other hosts databases and
  131. packages so if one goes down there are other mirrors available.
  132. So each host has a directory tree with packages. The host then runs a script
  133. (see section 3.4) each time packages are added (or using a cron job, or
  134. something) to generate the database.
  135. The hosts will then, maybe twice a day, or every hour, use rsync[2] to fetch
  136. the new version of the database and the new packages.
  137. [1] https://curl.haxx.se/
  138. [2] https://rsync.samba.org/
  139. 3.4 VERSION COMPARISON
  140. ======================
  141. The script that generates the databases should only add the latest packages
  142. to the database. To achive this the different versions of a package need to be
  143. compared.
  144. To compare versions we need a specification how to version packages. For
  145. example the author of a package might use the version 1.2-alpha1 and another
  146. author might use the version 2.0a. We need to decide which style to use, to be
  147. able to compare them.
  148. All package managers that does version comparison does this, Gentoo's portage
  149. is not an exception[1].
  150. Besides the specification, some algorithms are needed. I'm currently
  151. translating the algorithms from portage[2].
  152. When the code is written it will be used for jul's `upgrade' command as well.
  153. [1] https://dev.gentoo.org/~ulm/pms/head/pms.html#x1-300003.2
  154. [2] https://dev.gentoo.org/~ulm/pms/head/pms.html#x1-310003.3
  155. 4 CONFIGURATION FILES
  156. =====================
  157. The configuration file is just a Tcl script where you can set some variables.
  158. There is a system wide configuration file in `/etc' and a local configuration
  159. file in the users home directory. Like most programs.
  160. Examples of settings:
  161. 1) which packages to show (archs)
  162. 2) which repositories to use
  163. 3) always run the sync/update command before most of the other
  164. commands
  165. Most, if not all, of the settings should be modified via the command line as
  166. options.
  167. 5 DISCUSSION
  168. ============
  169. A limited version of jul is available[1,2] today, and a few people in the
  170. community including me use it a lot even if the most exiting features aren't
  171. complete or even missing.
  172. The most pressing thing at the moment is the code for version comparison. I'm
  173. working on it but we need a version specification for it to work. I'm using
  174. portage's version spec. temporarily.
  175. This document was written in somewhat of a hurry and I'm sure things were left
  176. out.
  177. Please discuss on the mailing list and IRC so we have something ready for the
  178. long awaited Dragora 3. :-)
  179. [1] https://gungre.ch/dragora/repo/frusen/stable/jul/
  180. [2] http://dragora.org/repo.fsl/dir?name=jul