You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

130 lines
5.6 KiB

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
  1. # Cuper (DRAFT)
  2. ## RIZ file header
  3. ```plain
  4. 32 bits
  5. <---------------------------------------------->
  6. 16 bits 8 bits
  7. <----------------------> <---------->
  8. +----------------------------------------------+ <----------------------+
  9. 0 | IDENTIFICATOR | |
  10. +----------------------------------------------+ |
  11. 1 | ARCH | OS | |
  12. +----------------------------------------------+ |
  13. 2 | TIME | |
  14. +----------------------------------------------+ |
  15. 3 | TYPE | PROT. | VER | Base informations. |
  16. +----------------------------------------------+ Frame 0-9 |
  17. 4 | HL | MDL | + OPTIONS. |
  18. +----------------------------------------------+ |
  19. 5-9 | RESERVED | |
  20. +----------------------------------------------+ |
  21. | OPTIONS | <----------------------+
  22. +----------------------------------------------+ <----------------------+
  23. | METADATA | |
  24. +----------------------------------------------+ Contents. |
  25. | PAYLOAD | Frame post-OPTIONS-n. |
  26. +----------------------------------------------+ <----------------------+
  27. ```
  28. **Description**
  29. | Nom du champ | Position | Longeur (bits) | Valeur(s) |
  30. |:-------------|:--------:|:--------------:|:----------|
  31. | **Identificator** | 0 | 32 | `0x7f 0x52 0x49 0x5a` |
  32. | **Arch** | 4 | 16 | `0x0000` = no arch |
  33. |||| `0x0001` = i386 |
  34. |||| `0x0002` = x86_64 |
  35. | **OS** | 6 | 16 | `0x0000` = no OS |
  36. |||| `0x0001` = Linux |
  37. | **Time** | 8 | 32 | *current timestamp* |
  38. | **Type** | 12 | 16 | `0x0000` = container |
  39. |||| `0x0001` = meta container |
  40. | **Protected** | 14 | 8 | `0x00` = unprotected |
  41. |||| `0x01` = AES-128 |
  42. |||| `0x02` = AES-192 |
  43. |||| `0x04` = AES-256 |
  44. | **Version** | 15 | 8 | `0x00` = first (current) |
  45. | **HL** | 16 | 16 | `0x000a` = no options |
  46. | **MDL** | 18 | 16 | `0x0000` = no metadata |
  47. | **RESERVED** | 20 | 120 | `0x0000` = not used |
  48. * **ARCH**: l'identifiant de la machine cible (architecture du processeur).
  49. * **OS**: l'identifiant de la machine cible (environnement d'execution).
  50. * **TIME**: le timestamp de compilation.
  51. * **TYPE**: le type de conteneur, ex: conteneur, méta-conteneur, etc...
  52. * **VER**: la version de l'entête.
  53. * **HL**: la taille de l'entête en **mot de 32 bits**.
  54. * **MDL**: la taille des méta-données en **mot de 32 bits**.
  55. * **RESERVED**: 20 octets réservés.
  56. * **OPTIONS**: des données optionnels.
  57. * **METADATA**: les informations du contenu (see Cupfile).
  58. * **PAYLOAD**: le contenu.
  59. > **NOTE**:
  60. * Si `HL` égale `10d` (`000ah`), alors il n'y à pas d'options.
  61. * Si `MDL` égale `0d` (`0000h`), alors il n'y à pas de méta-données.
  62. ## Cupfile
  63. Le fichier **Cupfile** permet de **rassembler des informations** qui seront utilisés lors de la compilation.
  64. Voici la structure d'un Cupfile:
  65. ```plain
  66. +-------------------->
  67. | VAR1 = value1
  68. | User variables. VAR2 = value2
  69. | VAR3 = value3
  70. +-------------------->
  71. | ([add:] | set:)X-CONST1 = value1
  72. | Constantes. ([add:] | set:)X-CONST2 = value2
  73. | ([add:] | set:)X-CONST3 = value3
  74. +-------------------->
  75. +--------------------> (2x LF: `0x0a 0x0a` or 2x CRLF: `0x0d 0x0a 0x0d 0x0a`)
  76. +--------------------> `exec` executable_file [arguments]
  77. ```
  78. Le Cupfile doit se situer à la raçine de votre projet, exemple:
  79. ```plain
  80. reader:
  81. |-- .git/
  82. |-- test/
  83. |-- python-windows-x86-64/
  84. |-- libraries.dll
  85. `-- python.exe
  86. |-- python-linux-x86-64/
  87. |-- libraries.so
  88. `-- python
  89. |-- Cupfile
  90. |-- main.py
  91. ```
  92. Voici un exemple de Cupfile, ce conteneur permet l'execution d'un script Python, en incluant toutes les dépendances:
  93. ```bash
  94. AUTOR = Maiuri Gaëtan <maiuri.gaetan@lessonsharing.fr>
  95. DATE = 2017-09-22
  96. DESCRIPTION = A simple Cuper container with a text reader.
  97. X-ENV = ["set:VERBOSE=1", "LD_LIBRARY_PATH=$_CWD/python-linux-x86-64/"] # LD_LIBRARY_PATH=... => is equivalent of add:LD_LIBRARY_PATH=...
  98. X-INCLUDES = ["python-linux-x86-64/", "main.py"]
  99. # POSIX
  100. exec ./python-linux-x86-64/python main.py -v -i myfile.txt
  101. # Windows
  102. #exec python-windows-x86-64\python.exe main.py -v -i myfile.txt
  103. ```
  104. ## Constantes internes
  105. Des constantes internes sont utilisable dans le Cupfile, afin de formater dynamiquement votre environnement d'execution.
  106. > **NOTE**: Ces constantes ne sont pas modifiable.
  107. | Non | Type | Description | Exemple |
  108. |-----|:----:|-------------|---------|
  109. | `$_CWD` | string | Le path du dossier courant post-extraction | `/path/to/riz/contents` |
  110. | `$_HOME` | string | Le path du dossier utilisateur (de la machine cible) | `/home/batman` or `C:\Users\batman` |
  111. ## Attributs d'extension
  112. Les attributs d'extension permettent d'injecter des intructions à la compilation.
  113. | Non | Type | Description | Exemple |
  114. |-----|:----:|-------------|---------|
  115. | `X-ENV` | array | Inject des variables d'environnement dans le contexte d'execution (sur la machine cible) | `["VERBOSE=1", "LD_LIBRARY_PATH=libs/"]` |
  116. | `X-INCLUDES` | array | Inclure seulement ces fichiers/dossiers dans le conteneur | `["myfile", "mydir/"]` |

Powered by TurnKey Linux.