xref: /haiku/headers/os/package/hpkg/HPKGDefs.h (revision 820dca4df6c7bf955c46e8f6521b9408f50b2900)
1 /*
2  * Copyright 2009,2011, Haiku, Inc.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _PACKAGE__HPKG__HPKG_DEFS_H_
6 #define _PACKAGE__HPKG__HPKG_DEFS_H_
7 
8 
9 #include <SupportDefs.h>
10 
11 
12 namespace BPackageKit {
13 
14 namespace BHPKG {
15 
16 
17 // magic & version of package and repository files
18 enum {
19 	B_HPKG_MAGIC	= 'hpkg',
20 	B_HPKG_VERSION	= 1,
21 	//
22 	B_HPKG_REPO_MAGIC	= 'hpkr',
23 	B_HPKG_REPO_VERSION	= 1
24 };
25 
26 
27 // package attribute IDs
28 enum BHPKGPackageSectionID {
29 	B_HPKG_SECTION_HEADER					= 0,
30 	B_HPKG_SECTION_HEAP						= 1,
31 	B_HPKG_SECTION_PACKAGE_TOC				= 2,
32 	B_HPKG_SECTION_PACKAGE_ATTRIBUTES		= 3,
33 	B_HPKG_SECTION_REPOSITORY_INFO			= 4,
34 	//
35 	B_HPKG_SECTION_ENUM_COUNT
36 };
37 
38 
39 // attribute types
40 enum {
41 	// types
42 	B_HPKG_ATTRIBUTE_TYPE_INVALID			= 0,
43 	B_HPKG_ATTRIBUTE_TYPE_INT				= 1,
44 	B_HPKG_ATTRIBUTE_TYPE_UINT				= 2,
45 	B_HPKG_ATTRIBUTE_TYPE_STRING			= 3,
46 	B_HPKG_ATTRIBUTE_TYPE_RAW				= 4,
47 	//
48 	B_HPKG_ATTRIBUTE_TYPE_ENUM_COUNT
49 };
50 
51 
52 // attribute encodings
53 enum {
54 	// signed/unsigned int encodings
55 	B_HPKG_ATTRIBUTE_ENCODING_INT_8_BIT		= 0,
56 	B_HPKG_ATTRIBUTE_ENCODING_INT_16_BIT	= 1,
57 	B_HPKG_ATTRIBUTE_ENCODING_INT_32_BIT	= 2,
58 	B_HPKG_ATTRIBUTE_ENCODING_INT_64_BIT	= 3,
59 
60 	// string encodings
61 	B_HPKG_ATTRIBUTE_ENCODING_STRING_INLINE	= 0,
62 		// null-terminated string
63 	B_HPKG_ATTRIBUTE_ENCODING_STRING_TABLE	= 1,
64 		// unsigned LEB128 index into string table
65 
66 	// raw data encodings
67 	B_HPKG_ATTRIBUTE_ENCODING_RAW_INLINE	= 0,
68 		// unsigned LEB128 size, raw bytes
69 	B_HPKG_ATTRIBUTE_ENCODING_RAW_HEAP		= 1
70 		// unsigned LEB128 size, unsigned LEB128 offset into the heap
71 };
72 
73 
74 // maximum number of bytes of data to be encoded inline; more will be allocated
75 // on the heap
76 #define B_HPKG_MAX_INLINE_DATA_SIZE	8
77 
78 
79 // name of file containing package information (in package's root folder)
80 #define B_HPKG_PACKAGE_INFO_FILE_NAME	".PackageInfo"
81 
82 
83 // package attribute IDs
84 enum BHPKGAttributeID {
85 	B_HPKG_ATTRIBUTE_ID_DIRECTORY_ENTRY 			=  0,
86 	B_HPKG_ATTRIBUTE_ID_FILE_TYPE					=  1,
87 	B_HPKG_ATTRIBUTE_ID_FILE_PERMISSIONS			=  2,
88 	B_HPKG_ATTRIBUTE_ID_FILE_USER					=  3,
89 	B_HPKG_ATTRIBUTE_ID_FILE_GROUP					=  4,
90 	B_HPKG_ATTRIBUTE_ID_FILE_ATIME					=  5,
91 	B_HPKG_ATTRIBUTE_ID_FILE_MTIME					=  6,
92 	B_HPKG_ATTRIBUTE_ID_FILE_CRTIME					=  7,
93 	B_HPKG_ATTRIBUTE_ID_FILE_ATIME_NANOS			=  8,
94 	B_HPKG_ATTRIBUTE_ID_FILE_MTIME_NANOS			=  9,
95 	B_HPKG_ATTRIBUTE_ID_FILE_CRTIM_NANOS			= 10,
96 	B_HPKG_ATTRIBUTE_ID_FILE_ATTRIBUTE				= 11,
97 	B_HPKG_ATTRIBUTE_ID_FILE_ATTRIBUTE_TYPE			= 12,
98 	B_HPKG_ATTRIBUTE_ID_DATA						= 13,
99 	B_HPKG_ATTRIBUTE_ID_DATA_SIZE					= 14,
100 	B_HPKG_ATTRIBUTE_ID_DATA_COMPRESSION			= 15,
101 	B_HPKG_ATTRIBUTE_ID_DATA_CHUNK_SIZE				= 16,
102 	B_HPKG_ATTRIBUTE_ID_SYMLINK_PATH				= 17,
103 	B_HPKG_ATTRIBUTE_ID_PACKAGE_NAME				= 18,
104 	B_HPKG_ATTRIBUTE_ID_PACKAGE_SUMMARY				= 19,
105 	B_HPKG_ATTRIBUTE_ID_PACKAGE_DESCRIPTION			= 20,
106 	B_HPKG_ATTRIBUTE_ID_PACKAGE_VENDOR				= 21,
107 	B_HPKG_ATTRIBUTE_ID_PACKAGE_PACKAGER			= 22,
108 	B_HPKG_ATTRIBUTE_ID_PACKAGE_FLAGS				= 23,
109 	B_HPKG_ATTRIBUTE_ID_PACKAGE_ARCHITECTURE		= 24,
110 	B_HPKG_ATTRIBUTE_ID_PACKAGE_VERSION_MAJOR		= 25,
111 	B_HPKG_ATTRIBUTE_ID_PACKAGE_VERSION_MINOR		= 26,
112 	B_HPKG_ATTRIBUTE_ID_PACKAGE_VERSION_MICRO		= 27,
113 	B_HPKG_ATTRIBUTE_ID_PACKAGE_VERSION_RELEASE		= 28,
114 	B_HPKG_ATTRIBUTE_ID_PACKAGE_COPYRIGHT			= 29,
115 	B_HPKG_ATTRIBUTE_ID_PACKAGE_LICENSE				= 30,
116 	B_HPKG_ATTRIBUTE_ID_PACKAGE_PROVIDES			= 31,
117 	B_HPKG_ATTRIBUTE_ID_PACKAGE_PROVIDES_TYPE		= 32,
118 	B_HPKG_ATTRIBUTE_ID_PACKAGE_REQUIRES			= 33,
119 	B_HPKG_ATTRIBUTE_ID_PACKAGE_SUPPLEMENTS			= 34,
120 	B_HPKG_ATTRIBUTE_ID_PACKAGE_CONFLICTS			= 35,
121 	B_HPKG_ATTRIBUTE_ID_PACKAGE_FRESHENS			= 36,
122 	B_HPKG_ATTRIBUTE_ID_PACKAGE_REPLACES			= 37,
123 	B_HPKG_ATTRIBUTE_ID_PACKAGE_RESOLVABLE_OPERATOR	= 38,
124 	B_HPKG_ATTRIBUTE_ID_PACKAGE_CHECKSUM			= 39,
125 	B_HPKG_ATTRIBUTE_ID_PACKAGE_VERSION_PRE_RELEASE	= 40,
126 	B_HPKG_ATTRIBUTE_ID_PACKAGE_PROVIDES_COMPATIBLE	= 41,
127 	B_HPKG_ATTRIBUTE_ID_PACKAGE_URL					= 42,
128 	B_HPKG_ATTRIBUTE_ID_PACKAGE_SOURCE_URL			= 43,
129 	B_HPKG_ATTRIBUTE_ID_PACKAGE_INSTALL_PATH		= 44,
130 	//
131 	B_HPKG_ATTRIBUTE_ID_ENUM_COUNT,
132 };
133 
134 
135 // compression types
136 enum {
137 	B_HPKG_COMPRESSION_NONE	= 0,
138 	B_HPKG_COMPRESSION_ZLIB	= 1
139 };
140 
141 
142 // file types (B_HPKG_ATTRIBUTE_ID_FILE_TYPE)
143 enum {
144 	B_HPKG_FILE_TYPE_FILE		= 0,
145 	B_HPKG_FILE_TYPE_DIRECTORY	= 1,
146 	B_HPKG_FILE_TYPE_SYMLINK	= 2
147 };
148 
149 
150 // default values
151 enum {
152 	B_HPKG_DEFAULT_FILE_TYPE				= B_HPKG_FILE_TYPE_FILE,
153 	B_HPKG_DEFAULT_FILE_PERMISSIONS			= 0644,
154 	B_HPKG_DEFAULT_DIRECTORY_PERMISSIONS	= 0755,
155 	B_HPKG_DEFAULT_SYMLINK_PERMISSIONS		= 0777,
156 	B_HPKG_DEFAULT_DATA_COMPRESSION			= B_HPKG_COMPRESSION_NONE,
157 	B_HPKG_DEFAULT_DATA_CHUNK_SIZE_ZLIB		= 64 * 1024
158 };
159 
160 
161 // Writer Init() flags
162 enum {
163 	B_HPKG_WRITER_UPDATE_PACKAGE	= 0x01,
164 		// update the package (don't truncate)
165 	B_HPKG_WRITER_FORCE_ADD			= 0x02,
166 		// when updating a pre-existing entry, don't fail, but replace the
167 		// entry, if possible (directories will be merged, but won't replace a
168 		// non-directory)
169 };
170 
171 
172 }	// namespace BHPKG
173 
174 }	// namespace BPackageKit
175 
176 
177 #endif	// _PACKAGE__HPKG__HPKG_DEFS_H_
178