]> git.ipfire.org Git - pakfire.git/blob - src/pakfire/constants.py
Fix execution of scriptlets in a dirty environment
[pakfire.git] / src / pakfire / constants.py
1 #!/usr/bin/python
2 ###############################################################################
3 # #
4 # Pakfire - The IPFire package management system #
5 # Copyright (C) 2011 Pakfire development team #
6 # #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
11 # #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
16 # #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
19 # #
20 ###############################################################################
21
22 import os.path
23
24 from errors import *
25
26 from __version__ import PAKFIRE_VERSION
27
28 PAKFIRE_LEAST_COMPATIBLE_VERSION = PAKFIRE_VERSION
29
30 # The default hub to connect to.
31 PAKFIRE_HUB = "https://pakfirehub.ipfire.org/"
32
33 SYSCONFDIR = "/etc"
34 SCRIPT_DIR = "/usr/lib/pakfire"
35
36 CONFIG_DIR = os.path.join(SYSCONFDIR, "pakfire")
37 CONFIG_REPOS_DIR = os.path.join(CONFIG_DIR, "repos")
38 CONFIG_DISTRO_DIR = os.path.join(CONFIG_DIR, "distros")
39
40 KEYRING_DIR = os.path.join(CONFIG_DIR, "gnupg")
41
42 CACHE_DIR = "/var/cache/pakfire"
43 CCACHE_CACHE_DIR = os.path.join(CACHE_DIR, "ccache")
44 CACHE_ENVIRON_DIR = os.path.join(CACHE_DIR, "environments")
45 REPO_CACHE_DIR = os.path.join(CACHE_DIR, "downloads")
46
47 LOCAL_BUILD_REPO_PATH = "/var/lib/pakfire/local"
48 LOCAL_TMP_PATH = "/var/tmp"
49
50 PACKAGES_DB_DIR = "var/lib/pakfire"
51 PACKAGES_DB = os.path.join(PACKAGES_DB_DIR, "packages.db")
52 PACKAGES_SOLV = os.path.join(PACKAGES_DB_DIR, "packages.solv")
53 REPOSITORY_DB = "index.db"
54
55 BUFFER_SIZE = 102400
56
57 # The size of the data chunks that are uploaded to the
58 # pakfire hub.
59 CHUNK_SIZE = BUFFER_SIZE
60
61 MIRRORLIST_MAXSIZE = 1024**2
62
63 MACRO_FILE_DIR = "/usr/lib/pakfire/macros"
64 MACRO_EXTENSION = ".macro"
65
66 METADATA_FORMAT = 0
67 METADATA_DOWNLOAD_LIMIT = 1024**2
68 METADATA_DOWNLOAD_PATH = "repodata"
69 METADATA_DOWNLOAD_FILE = "repomd.json"
70 METADATA_DATABASE_FILE = "packages.solv"
71
72 PACKAGE_FORMAT = 5
73 # XXX implement this properly
74 PACKAGE_FORMATS_SUPPORTED = [0, 1, 2, 3, 4, 5]
75 PACKAGE_EXTENSION = "pfm"
76 MAKEFILE_EXTENSION = "nm"
77
78 DATABASE_FORMAT = 7
79 DATABASE_FORMATS_SUPPORTED = [0, 1, 2, 3, 4, 5, 6, 7]
80
81 PACKAGE_FILENAME_FMT = "%(name)s-%(version)s-%(release)s.%(arch)s.%(ext)s"
82
83 BUILD_PACKAGES = [
84 "@Build",
85 "pakfire-build>=%s" % PAKFIRE_LEAST_COMPATIBLE_VERSION,
86 ]
87
88 # A script that is called, when a user is dropped to a chroot shell.
89 SHELL_SCRIPT = "/usr/lib/pakfire/chroot-shell"
90 SHELL_PACKAGES = ["elinks", "less", "vim", SHELL_SCRIPT,]
91 BUILD_ROOT = "/var/lib/pakfire/build"
92
93 MINIMAL_ENVIRONMENT = {
94 "HOME" : "/root",
95 "LANG" : "C",
96 "PATH" : "/usr/bin:/bin:/usr/sbin:/sbin",
97 "PS1" : "\u:\w\$ ",
98 "TERM" : "vt100",
99 }
100
101 SOURCE_DOWNLOAD_URL = "http://source.ipfire.org/source-3.x/"
102 SOURCE_CACHE_DIR = os.path.join(CACHE_DIR, "sources")
103
104 TIME_10M = 10
105 TIME_24H = 60*24
106
107 ORPHAN_DIRECTORIES = [
108 "lib", "lib64", "usr/lib", "usr/lib64", "libexec", "usr/libexec",
109 "bin", "sbin", "usr/bin", "usr/sbin", "usr/include", "usr/share",
110 "usr/share/man", "usr/share/man/man0", "usr/share/man/man1",
111 "usr/share/man/man2", "usr/share/man/man3", "usr/share/man/man4",
112 "usr/share/man/man5", "usr/share/man/man6", "usr/share/man/man7",
113 "usr/share/man/man8", "usr/share/man/man9", "usr/lib/pkgconfig",
114 ]
115 for i in ORPHAN_DIRECTORIES:
116 i = os.path.dirname(i)
117
118 if not i or i in ORPHAN_DIRECTORIES:
119 continue
120
121 ORPHAN_DIRECTORIES.append(i)
122
123 ORPHAN_DIRECTORIES.sort(cmp=lambda x,y: cmp(len(x), len(y)), reverse=True)
124
125 PACKAGE_INFO = """\
126 # Pakfire %(pakfire_version)s
127
128 # Package information
129 package
130 name = %(name)s
131 version = %(version)s
132 release = %(release)s
133 epoch = %(epoch)s
134 arch = %(arch)s
135
136 uuid = %(uuid)s
137 groups = %(groups)s
138 maintainer = %(maintainer)s
139 url = %(url)s
140 license = %(license)s
141
142 summary = %(summary)s
143
144 def description
145 %(description)s
146 end
147
148 type = %(type)s
149 size = %(inst_size)d
150 end
151
152 # Build information
153 build
154 host = %(build_host)s
155 id = %(build_id)s
156 time = %(build_time)d
157 end
158
159 # Distribution information
160 distribution
161 name = %(distro_name)s
162 release = %(distro_release)s
163 vendor = %(distro_vendor)s
164 maintainer = %(distro_maintainer)s
165 end
166
167 # Dependency information
168 dependencies
169 def prerequires
170 %(prerequires)s
171 end
172
173 def requires
174 %(requires)s
175 end
176
177 def provides
178 %(provides)s
179 end
180
181 def conflicts
182 %(conflicts)s
183 end
184
185 def obsoletes
186 %(obsoletes)s
187 end
188
189 def recommends
190 %(recommends)s
191 end
192
193 def suggests
194 %(suggests)s
195 end
196 end
197
198 # EOF
199 """
200 PACKAGE_INFO_DESCRIPTION_LINE = PACKAGE_INFO_DEPENDENCY_LINE = "\t\t%s"
201
202 # XXX make this configurable in pakfire.conf
203 PAKFIRE_MULTIINSTALL = [
204 "kernel",
205 "kernel-exynos",
206 "kernel-kirkwood",
207 "kernel-legacy",
208 "kernel-omap",
209 "kernel-versatile",
210 "kernel-devel",
211 ]
212
213 SCRIPTLET_INTERPRETER = "/bin/sh"
214 SCRIPTLET_TIMEOUT = 60 * 15
215
216 SCRIPTS = (
217 "pretransin",
218 "pretransun",
219 "pretransup",
220 "prein",
221 "postin",
222 "preun",
223 "postun",
224 "preup",
225 "postup",
226 "posttransin",
227 "posttransun",
228 "posttransup",
229 )
230
231 SCRIPTS_PREREQUIRES = (
232 "prein",
233 "postin",
234 "preup",
235 "postup",
236 )
237
238 LDCONFIG = "/sbin/ldconfig"
239
240 CONFIG_FILE_SUFFIX_NEW = ".paknew"
241 CONFIG_FILE_SUFFIX_SAVE = ".paksave"