Compare commits
993 Commits
rhel8-1943
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
3958d2aa8b | ||
|
fa47a11197 | ||
|
4d10a0ea0c | ||
|
4e956ff173 | ||
|
58e6ca5d7b | ||
|
9536415907 | ||
|
c9e90ec0b2 | ||
|
105e6891f6 | ||
|
4581039da8 | ||
|
ddbb68f61e | ||
|
57675826cd | ||
|
80ee534afc | ||
|
2cb1c84600 | ||
|
918cf2c29d | ||
|
7d45b51ad8 | ||
|
94ef6ed036 | ||
|
d39a5f625e | ||
|
ea0c6c3b3a | ||
|
03da17fb37 | ||
|
d7a845c2d4 | ||
|
774e44060a | ||
|
55eee7d22d | ||
|
e1092c0ee9 | ||
|
eb4866c73d | ||
|
6b2c4d1a88 | ||
|
3c66730d7e | ||
|
8c61a4c5b3 | ||
|
bc46724b1d | ||
|
2dde5eb55f | ||
|
000667fbf5 | ||
|
152b503042 | ||
|
debfb498e3 | ||
|
cc90406a58 | ||
|
ab9068c2d0 | ||
|
f8af828a80 | ||
|
d692ce3662 | ||
|
22c3e76d6c | ||
|
4a678d6670 | ||
|
b9a3f8a788 | ||
|
7c6e3e6800 | ||
|
a01f62def7 | ||
|
506c9a18ff | ||
|
f4e0adc090 | ||
|
8532b683a4 | ||
|
710e65fa6f | ||
|
223f1755ec | ||
|
b3876337c3 | ||
|
ec0eafacd9 | ||
|
6160d340c4 | ||
|
74128fcd59 | ||
|
e144c69535 | ||
|
f2ae286739 | ||
|
c4aba2e47f | ||
|
87f9f77e24 | ||
|
5d9830e88d | ||
|
7a1de81b09 | ||
|
5286e4d917 | ||
|
1e66ac669c | ||
|
c811ba98d4 | ||
|
1adbeef14c | ||
|
96fca67621 | ||
|
a9451842eb | ||
|
6451060bda | ||
|
69c15c9bbe | ||
|
fbb7c5aeef | ||
|
6fc2648121 | ||
|
f783ff77d4 | ||
|
49ff2c7d5c | ||
|
a3810024ac | ||
|
bd9197c76e | ||
|
1843f8b0e0 | ||
|
d3bd740254 | ||
|
fa2e465d51 | ||
|
de2c88883a | ||
|
0b2ce51d96 | ||
|
3f04cf9b59 | ||
|
5dfa95d769 | ||
|
3801c802c5 | ||
|
35cb8f71a7 | ||
|
fab286e785 | ||
|
ea72ace122 | ||
|
0748dbe28c | ||
|
5c0c1a0b84 | ||
|
2342f53aff | ||
|
ff5c5dfe66 | ||
|
322a810403 | ||
|
7ce07c5a7c | ||
|
19ed6ed871 | ||
|
065e0a7f8d | ||
|
9cb34c5520 | ||
|
79a1fd9c46 | ||
|
cc7430fbbd | ||
|
d8e35d73c1 | ||
|
9164f4509d | ||
|
99ba2fe12c | ||
|
b75b692607 | ||
|
823e54dabf | ||
|
2762cf95da | ||
|
e9fa729b2e | ||
|
8602e653ff | ||
|
18fd73ae82 | ||
|
4b6aa1add1 | ||
|
1ffe2125d0 | ||
|
a8e37cdbed | ||
|
856d7d70f3 | ||
|
563db6608d | ||
|
55371c9968 | ||
|
561339c6dc | ||
|
5cf7943305 | ||
|
6d7a1df8fa | ||
|
07a1d8e88a | ||
|
730621808c | ||
|
02c185c9c0 | ||
|
202f90e541 | ||
|
5e4b058bae | ||
|
6803bae6d4 | ||
|
0dc1edb564 | ||
|
83ddffd377 | ||
|
9defb143da | ||
|
7df94aed4d | ||
|
04ce221a65 | ||
|
f6924f8f1f | ||
|
b0318efead | ||
|
a33efe7c51 | ||
|
6400515880 | ||
|
07600b2418 | ||
|
a4e87a07e0 | ||
|
bd37cd5b87 | ||
|
78eec89cda | ||
|
5ae6dce983 | ||
|
c0ec02b3ed | ||
|
0e9262ba20 | ||
|
cd77f6d4d5 | ||
|
b07151c6ee | ||
|
ee2496d672 | ||
|
51a4a93f90 | ||
|
6a8901fb09 | ||
|
d094708f08 | ||
|
46ab9e55f5 | ||
|
abbd86a2f6 | ||
|
1246bd8fba | ||
|
c3c3605b70 | ||
|
f1aee05167 | ||
|
9d6211f1b3 | ||
|
918669f538 | ||
|
468f651af4 | ||
|
83df17ea76 | ||
|
9b06645196 | ||
|
e3e8ff884b | ||
|
5e4bdbfb01 | ||
|
0eda7829a8 | ||
|
7616a10373 | ||
|
506d5d9ebd | ||
|
46ba3d541d | ||
|
44a213ee9a | ||
|
4ce386fe2d | ||
|
2078c83704 | ||
|
c1d247e0f5 | ||
|
86f0e72224 | ||
|
a9a155ff58 | ||
|
92463f16cb | ||
|
ea375ebe60 | ||
|
07f3e48c28 | ||
|
3359b896d1 | ||
|
afa7e2af37 | ||
|
a87f438af1 | ||
|
f36481c8aa | ||
|
e1785d13b8 | ||
e5f50e81c3 | |||
|
47822e5932 | ||
|
5165beef73 | ||
|
556fdf3020 | ||
|
8966c675ee | ||
|
b7e69596e3 | ||
|
d830829929 | ||
|
cc29b99659 | ||
|
27c4c67a59 | ||
|
04bc5e9e86 | ||
|
eb7748236c | ||
|
1c218ecbae | ||
|
abcbbf3194 | ||
|
123827c90a | ||
|
7b08fa8838 | ||
|
4dd7cf8798 | ||
|
d68e01b7e1 | ||
|
14a3c8d5a7 | ||
|
f1c15c67e0 | ||
|
52fd0f823b | ||
|
be2c9333fc | ||
|
68c26bf87b | ||
|
c2a3b7dbf3 | ||
|
48b268dc9e | ||
|
0b9841d5f7 | ||
|
0b5285a3e2 | ||
|
c080180885 | ||
|
e91e38e29c | ||
|
03ff3bb53a | ||
|
65d7397cf2 | ||
|
261e5af463 | ||
|
432a558ad6 | ||
|
bf1be846e5 | ||
|
9a17eba974 | ||
|
a3c4fbb66c | ||
|
e9b088068c | ||
|
d97687a496 | ||
|
0dbfe28745 | ||
|
9b8e0e2335 | ||
|
fa98321942 | ||
|
3c745aed8d | ||
|
4b1a4f8f16 | ||
|
f5de2de821 | ||
|
019cac8a7c | ||
|
9a76c20c6b | ||
|
74f8cd4f34 | ||
|
564f78e629 | ||
|
f83ae2fed3 | ||
|
b97dea0450 | ||
|
2e585c98f3 | ||
|
26e3bc555a | ||
|
6fdb09f9e2 | ||
|
cb639fc30f | ||
|
0f3b517f51 | ||
|
0c44e84cdb | ||
|
c9c1283c56 | ||
|
1d5a0a378b | ||
|
b992350f6b | ||
|
6025da1421 | ||
|
ccb5e1906f | ||
|
f94171bb0f | ||
|
91d71b09a4 | ||
|
d6ce9c907d | ||
|
bc6a080af7 | ||
|
e2e8deb906 | ||
|
a30531d41b | ||
|
92336963f0 | ||
|
54548e4076 | ||
|
622e15c85a | ||
|
cc47ca1f54 | ||
|
0d96f7d86c | ||
|
6820c48372 | ||
|
9af650798c | ||
|
ad54403c6d | ||
|
354c909b9b | ||
|
06d727e4fd | ||
|
d1d30bb974 | ||
|
7d7d158399 | ||
|
fe45fa3610 | ||
|
9dd160ba44 | ||
|
50d0c6e0c1 | ||
|
e31fccc4ae | ||
|
718ac31c47 | ||
|
67410a9770 | ||
|
210fe3d8ef | ||
|
2ee92b75b0 | ||
|
b159555f3f | ||
|
5ca385ce80 | ||
|
35348636c5 | ||
|
a0fce98109 | ||
|
a60cef3e1e | ||
|
5561bbb3bc | ||
|
d265824564 | ||
|
9bb1a0916e | ||
|
0d3cff0dde | ||
|
b86926e275 | ||
|
bae3cb06bc | ||
|
ca876483db | ||
|
887fb6ce35 | ||
|
b69e6d725d | ||
|
350baad384 | ||
|
c038bb53c6 | ||
|
59924fbafb | ||
|
badc07854c | ||
|
ed15b81818 | ||
|
cd65758ebe | ||
|
3b7ab99991 | ||
|
534f437d0c | ||
|
e82ae6b82a | ||
|
10473f59e9 | ||
|
c69c76e9c9 | ||
|
80dd997b9c | ||
|
045bddb37a | ||
|
30d45a8880 | ||
|
70baff3bc2 | ||
|
82e7335761 | ||
|
90b340f828 | ||
|
03d4583cdc | ||
|
f7688f9c8d | ||
|
cc689c0cb9 | ||
|
e38e2ead1e | ||
|
f52e56c628 | ||
|
6839390be2 | ||
|
fad9b324f7 | ||
|
95fd12e1f0 | ||
|
c5f6fd6d30 | ||
|
c345afdc65 | ||
|
ea53a201f2 | ||
|
36422ee944 | ||
|
58f629b020 | ||
|
dcd92cf8c0 | ||
|
637d3ea643 | ||
|
f74a5cc4a6 | ||
|
94b2b58d99 | ||
|
da5ba2421e | ||
|
2b578dcee8 | ||
|
c43ba9e78f | ||
|
1351c4dc63 | ||
|
e7e70313ef | ||
|
b197e448ff | ||
|
cb7e391792 | ||
|
89539a7bf4 | ||
|
454af0c5d5 | ||
|
d67745d755 | ||
|
e1b45958f4 | ||
|
4705ff3b1e | ||
|
a0ae10c2d7 | ||
|
e3654e8297 | ||
|
df7a018ee2 | ||
|
b8bf258a3c | ||
|
d8bf3427a6 | ||
|
cdcfaf562b | ||
|
e365e476af | ||
|
af3494fc46 | ||
|
88162780a7 | ||
|
ba0784d0ee | ||
|
51ce751b16 | ||
|
009c051003 | ||
|
53fba4c2b1 | ||
|
3fdc783850 | ||
|
a02538fdc3 | ||
|
0eb01b84a8 | ||
|
6f0473c742 | ||
|
2fdcfc2e4c | ||
|
63816d9764 | ||
|
4256a1d4f2 | ||
|
2a2313151b | ||
|
eee7a3e47d | ||
|
b5df65f658 | ||
|
3e9b56e66d | ||
|
6a2f465217 | ||
|
1969711d8c | ||
|
4276a68cf3 | ||
|
a414988ee8 | ||
|
27a4165089 | ||
|
c2620b0c85 | ||
|
a59c0241c4 | ||
|
146560b959 | ||
|
b91d742ecb | ||
|
b23c73e52c | ||
|
d16e8f5bfc | ||
|
577c56ebaa | ||
|
b307ff0430 | ||
|
0eda252d61 | ||
|
fd2330c4b7 | ||
|
acbf63013a | ||
|
7396c272b2 | ||
|
ade8945da3 | ||
|
f8f06ccd23 | ||
|
fd55bee85d | ||
|
c384b687ba | ||
|
b2fc391677 | ||
|
5d7aa95f2f | ||
|
bc06abceab | ||
|
1030dd083c | ||
|
de314a0046 | ||
|
4da569442c | ||
|
45498f2b93 | ||
|
1b84f90963 | ||
|
1a6bc098d9 | ||
|
3a453eaad7 | ||
|
2692e8138c | ||
|
584a2d2076 | ||
|
a2c67385e4 | ||
|
29c308ae73 | ||
|
697233c14a | ||
|
3aac31482c | ||
|
6cebc3da88 | ||
|
5efaa876e1 | ||
|
5322664432 | ||
|
f978d4b01c | ||
|
4643afa58d | ||
|
6f01aedc8a | ||
|
58e762f3a1 | ||
|
52f84adde3 | ||
|
8af9723c37 | ||
|
836f0ddf7a | ||
|
ea98969014 | ||
|
421cc9c22f | ||
|
562eb0a15d | ||
|
beff4f6967 | ||
|
66cd1fdb52 | ||
|
a0322afec3 | ||
|
3ee07001b1 | ||
|
1581842132 | ||
|
64ac615fa4 | ||
|
114c1bbda7 | ||
|
584cad72a0 | ||
|
cda497f0cb | ||
|
3b6c6a35d7 | ||
|
4da4b665ef | ||
|
6f686ff9d6 | ||
|
b8c1e706bb | ||
|
40bb80f10f | ||
|
0935a10a0b | ||
|
1e88a99443 | ||
|
278214ff8e | ||
|
f5bb2dca8c | ||
|
985b0bbc48 | ||
|
b9d18216ef | ||
|
361c6de2de | ||
|
babf823b1b | ||
|
835c912e12 | ||
|
1983bddb65 | ||
|
12e632a058 | ||
|
8612ca30db | ||
|
fb1fcce0fd | ||
|
f4a81d6c26 | ||
|
c46f9f034f | ||
|
fcd2d39860 | ||
|
1796489839 | ||
|
cb91fa3c78 | ||
|
cf10fb40f3 | ||
|
9f9cba35a2 | ||
|
0708302464 | ||
|
90626f97b6 | ||
|
9bf8d8a2fc | ||
|
3cb007a25b | ||
|
d496da00d9 | ||
|
d0e947fe3b | ||
|
197c326530 | ||
|
2c141950b0 | ||
|
1f811523b5 | ||
|
6b55c8f8f0 | ||
|
38f1edd2aa | ||
|
4174186c14 | ||
|
e11fc2037f | ||
|
fd57e1106e | ||
|
fce196ad4a | ||
|
dc98837667 | ||
|
eb7f528071 | ||
|
998d0140be | ||
|
fef76930bc | ||
|
e70aae69da | ||
|
f810924042 | ||
|
e947e01331 | ||
|
7ff4d7ac9e | ||
|
f1733369fa | ||
|
13a7dcf2b1 | ||
|
61059a2699 | ||
|
bad9e93c3c | ||
|
61fc4d2b4e | ||
|
682f8a9295 | ||
|
e7ce7cda72 | ||
|
c1aa57022b | ||
|
f0992bc649 | ||
|
fb89e6f275 | ||
|
abe7df34fc | ||
|
932ff5812c | ||
|
9011a564e8 | ||
|
316257fbc0 | ||
|
ffc3432cf2 | ||
|
6d50a5874e | ||
|
7071e62985 | ||
|
f64fe0f1f3 | ||
|
f61dfcc2c7 | ||
|
688f70eefa | ||
|
22b0eb28bc | ||
|
b725eb141a | ||
|
649a9e2239 | ||
|
16fd1a2340 | ||
|
eb8ca5b5bf | ||
|
33151372df | ||
|
42c7c0691c | ||
|
a4dcc34396 | ||
|
4bd03cb8f6 | ||
|
a164ed3d7d | ||
|
ce3a277100 | ||
|
b50f1967c6 | ||
|
8ed910b29a | ||
|
3587ed3663 | ||
|
b71e8f74d8 | ||
|
b67ce5379c | ||
|
6c2b34bf15 | ||
|
c5ae344b4f | ||
|
5dda214c39 | ||
|
29cf2c4e8c | ||
|
ed8a21a627 | ||
|
f24877b06e | ||
|
be15fa6ea8 | ||
|
708314a1fe | ||
|
1ac75e98b4 | ||
|
1e5a5921e3 | ||
|
6120f74c73 | ||
|
795cc3400c | ||
|
3b467f1cd7 | ||
|
c261cec33d | ||
|
4783f6562f | ||
|
6ddaa5e0dd | ||
|
bdffaa02f4 | ||
|
40e9c54cbb | ||
|
303a69bcbd | ||
|
77acc8972b | ||
|
ca171424eb | ||
|
5f5a2d5337 | ||
|
1ba2e6fd4b | ||
|
250f49f78d | ||
|
aa9c2e13b1 | ||
|
5d05deae64 | ||
|
ddb82ef598 | ||
|
2949edf733 | ||
|
c98f9ee40b | ||
|
947cbb1b84 | ||
|
afb745552b | ||
|
d4d050496b | ||
|
123b5c269d | ||
|
596cba2255 | ||
|
40d3055229 | ||
|
fa4bda8317 | ||
|
72ff8e72a9 | ||
|
3e08389a0f | ||
|
4f701e7e92 | ||
|
1111aee92d | ||
|
6ea1c45734 | ||
|
4d35668ab5 | ||
|
e5a8700bdf | ||
|
67007dfa60 | ||
|
2929deaf01 | ||
|
9bdbb29662 | ||
|
95c288d829 | ||
|
21e141a84c | ||
|
0fa5af2e30 | ||
|
65b8a2be68 | ||
|
933fad9ded | ||
|
e45e645fd0 | ||
|
7cbb324ae5 | ||
|
209bdd6911 | ||
|
9c39e73969 | ||
|
8a89edf7bf | ||
|
613d91299d | ||
|
b57de93468 | ||
|
db7b1e4fcd | ||
|
35e44ffb37 | ||
|
44e14176bb | ||
|
434fe58c28 | ||
|
c6fcf9d1eb | ||
|
bd804c271b | ||
|
c941b82b0c | ||
|
c585b91422 | ||
|
8ef4f431d8 | ||
|
3d3dda1400 | ||
|
ba2d834425 | ||
|
6fd06c6931 | ||
|
049f68cb60 | ||
|
69d0913070 | ||
|
2acd13d612 | ||
|
1855ffeb8e | ||
|
d178189ef3 | ||
|
6c6e4fced1 | ||
|
df3aeee802 | ||
|
6ccbfe0585 | ||
|
5dea308080 | ||
|
f9665940bb | ||
|
235813212f | ||
|
59464286f9 | ||
|
655e7e40c0 | ||
|
32d5ff8615 | ||
|
33498b8a87 | ||
|
8c2184d59e | ||
|
02f757d231 | ||
|
61efa91a03 | ||
|
c26477a63c | ||
|
cd8c884adb | ||
|
f6f2308765 | ||
|
d7b96c8f0f | ||
|
372bef945f | ||
|
b1407900ac | ||
|
5f530bd501 | ||
|
f5286e1243 | ||
|
85dfbd7911 | ||
|
e39d2aec22 | ||
|
eef11ef405 | ||
|
d32f477e0b | ||
|
26bd2c1378 | ||
|
b936dfb198 | ||
|
11955f0550 | ||
|
fc9ccb51ee | ||
|
a7e96ab828 | ||
|
f3c147448a | ||
|
3b8de2a233 | ||
|
822bc7ac68 | ||
|
6c5e89ed14 | ||
|
8eaad3bc5e | ||
|
a0ff34dcb1 | ||
|
b47554d716 | ||
|
d27b4fcbd4 | ||
|
ce110afd22 | ||
|
28bd68793b | ||
|
6443f34337 | ||
|
2272b2b189 | ||
|
9041174142 | ||
|
d64a320ba1 | ||
|
1c731b5618 | ||
|
ea78cce882 | ||
|
c95d7084a6 | ||
|
387a71e4cd | ||
|
7e78dc368f | ||
|
d35232d9cc | ||
|
301cb15120 | ||
|
7f562db31f | ||
|
6961dce08b | ||
|
022e9eba3e | ||
|
e194b5926c | ||
|
2af0973155 | ||
|
5dc895fbee | ||
|
57be7313c4 | ||
|
20ebfce164 | ||
|
f26fcba902 | ||
|
8a8802aab7 | ||
|
e918ff807c | ||
|
069c1faa4f | ||
|
24a1a345ab | ||
|
5217215c4b | ||
|
008911d938 | ||
|
98482e444d | ||
|
458d120afe | ||
|
3676cb65bb | ||
|
9577f719ae | ||
|
2a3c41e1ce | ||
|
e4fe1aab32 | ||
|
cc6fdb2fac | ||
|
67dcff18d9 | ||
|
d8439bdc11 | ||
|
961ea18145 | ||
|
de6419f0d1 | ||
|
6680e2ffec | ||
|
677c858f60 | ||
|
612f043b51 | ||
|
2d3f266373 | ||
|
4885434ac9 | ||
|
8a2e2a7a36 | ||
|
f9ade497d3 | ||
|
2950f2641b | ||
|
4fe21135e3 | ||
|
e85bcf4359 | ||
|
f66bff5aa7 | ||
|
6bb64f94ff | ||
|
7ee3b3d661 | ||
|
c53de4e63c | ||
|
35ab6a1336 | ||
|
ca2c3d9e77 | ||
|
3817671587 | ||
|
f9de60b2b7 | ||
|
e939469524 | ||
|
a477db33d6 | ||
|
34ab13b68a | ||
|
d34acfc14c | ||
|
3625e8e27c | ||
|
fd173f7265 | ||
|
3d1d79eea5 | ||
|
6f141658d4 | ||
|
fee5d4594c | ||
|
6b5c4df8b5 | ||
|
26a684932b | ||
|
3762264f56 | ||
|
fa461dc837 | ||
|
883a959442 | ||
|
6563a33f63 | ||
|
d619430d6d | ||
|
6524bb0985 | ||
|
d18934775c | ||
|
4dd9004d13 | ||
|
642b909d24 | ||
|
543a4d88d9 | ||
|
16260c1569 | ||
|
59050df710 | ||
|
e0c8cdc5a8 | ||
|
8f430be2a6 | ||
|
57b4f2e8f3 | ||
|
4b4f4bd0e0 | ||
|
ed63611cb7 | ||
|
ab048947cb | ||
|
14ae0fcac9 | ||
|
9ac4508135 | ||
|
8b11705ea0 | ||
|
9ea1f4c09d | ||
|
35b8957f12 | ||
|
cd6f4fdb67 | ||
|
b88466fd74 | ||
|
c9d706a382 | ||
|
366ae55abe | ||
|
c11bffc357 | ||
|
763ca83f9f | ||
|
af2ae790ce | ||
|
13fbd0861b | ||
|
d6dcb38a78 | ||
|
b61a91954a | ||
|
6ae78fbd47 | ||
|
fb4e6f2588 | ||
|
d69f01d4a8 | ||
|
063a1770e1 | ||
|
bab4b20d0d | ||
|
8e749efbbf | ||
|
134a333d92 | ||
|
fb87db0e1e | ||
|
cc69478249 | ||
|
2e36e941ce | ||
|
e8fd8a496b | ||
|
8a26d0648e | ||
|
6a42570eea | ||
|
6005f98123 | ||
|
9906ad6da3 | ||
|
6631002a81 | ||
|
59d8c91ae5 | ||
|
efaf2bf793 | ||
|
7d2b9d2d30 | ||
|
2eb62014db | ||
|
453b1c1236 | ||
|
a4783ba29f | ||
|
befa3128d7 | ||
|
f80cc97a42 | ||
|
7500a17f27 | ||
|
27e611629f | ||
|
df70e3d677 | ||
|
27aff75aa3 | ||
|
e9e5139750 | ||
|
e1dc54ea8c | ||
|
5409748e75 | ||
|
fa2158c7a9 | ||
|
de8124366e | ||
|
e7f45d333f | ||
|
876ec52215 | ||
|
4e0c7b3fba | ||
|
7e0a288f5b | ||
|
faa65bca3c | ||
|
d7951e3a10 | ||
|
75644689de | ||
|
65b769984b | ||
|
aafa271608 | ||
|
7cc6e86299 | ||
|
98f8b23129 | ||
|
ac9a2fdbc5 | ||
|
6fab72d894 | ||
|
69a2835387 | ||
|
2a7a323ddf | ||
|
c017300ad6 | ||
|
9087de3c86 | ||
|
3b41faae2c | ||
|
81d38b6445 | ||
|
9717b3fd98 | ||
|
0086362f0b | ||
|
c7b0644ee5 | ||
|
6da3079349 | ||
|
6a37f80f0f | ||
|
e7bfab8b4a | ||
|
edc5490a99 | ||
|
acedb3a0ed | ||
|
8ed443ff58 | ||
|
e4c098b7e0 | ||
|
37f264c010 | ||
|
51c73f7570 | ||
|
7e31a2c138 | ||
|
ef8bc70cdd | ||
|
b2eadff77c | ||
|
f360ef9216 | ||
|
003108b15f | ||
|
d5a1993640 | ||
|
1056bfc25b | ||
|
e0c236ff36 | ||
|
18188bf6cf | ||
|
847fff4e11 | ||
|
e33b1e1636 | ||
|
160044ba9d | ||
|
9736dff762 | ||
|
c97a6985fb | ||
|
8e0b7ba2ca | ||
|
c9be91c879 | ||
|
3246c01443 | ||
|
e36b89e9e8 | ||
|
4a66b5b085 | ||
|
78717054d7 | ||
|
ec1ebbc623 | ||
|
ab85ad5c86 | ||
|
c00036251e | ||
|
b4b8985caa | ||
|
a65b93c77d | ||
|
e129c4c4f5 | ||
|
0432c6d56e | ||
|
45e093241d | ||
|
d514696880 | ||
|
330ee6c8b6 | ||
|
40b3eda232 | ||
|
8abf6be950 | ||
|
044d7381a2 | ||
|
a0aab15311 | ||
|
5c0dfb74e6 | ||
|
4a5591e9a4 | ||
|
7e19a4f671 | ||
|
18df16e2b7 | ||
|
4d9ef60460 | ||
|
07acd2e780 | ||
|
55e9653cde | ||
|
8b0d2648dd | ||
|
e0cad3dcf8 | ||
|
57674c9a1a | ||
|
ec908fcd2a | ||
|
972b5c4142 | ||
|
0a76d635ca | ||
|
4e32026354 | ||
|
fb39d9a418 | ||
|
86d556e87c | ||
|
ee98d87cea | ||
|
c52ba4236a | ||
|
deff4d325f | ||
|
40f23f093d | ||
|
844ff9998b | ||
|
04fd94f44b | ||
|
be5d50e6f3 | ||
|
94453ff94e | ||
|
c638926880 | ||
|
83e5f3f885 | ||
|
07de4c371a | ||
|
b1daf6fcd3 | ||
|
47d3a72014 | ||
|
b1e2bbfd17 | ||
|
c8283adc17 | ||
|
fb9e5c4a2b | ||
|
faba254be5 | ||
|
473ee99eb9 | ||
|
d03a198a8c | ||
|
6a3ccd6ade | ||
|
c1af7dd69d | ||
|
f67e2c5d52 | ||
|
785ee7bcc3 | ||
|
2f8f076b1f | ||
|
a2ce0686ca | ||
|
b26d12e457 | ||
|
2efbd7cae5 | ||
|
6c3b0b3cd2 | ||
|
f557b28d19 | ||
|
0e97afdbd6 | ||
|
316a829ff7 | ||
|
55dd45de6e | ||
|
ec4c555174 | ||
|
f93f64a061 | ||
|
2d01bec2b2 | ||
|
439a894947 | ||
|
741e73265c | ||
|
e2dd59c6dc | ||
|
991416adf5 | ||
|
fc9a469ca2 | ||
|
7379102923 | ||
|
b4f9fb5c1f | ||
|
8a2a43be99 | ||
|
76f714eab5 | ||
|
ea7b22a8f5 | ||
|
022734ab01 | ||
|
495dcd13ec | ||
|
e42b797295 | ||
|
ab76c6170e | ||
|
ae19bc7343 | ||
|
aec0e09caa | ||
|
18b03936c2 | ||
|
2ce3752f90 | ||
|
0c19c3304e | ||
|
08fb780bb9 | ||
|
db587afb16 | ||
|
f0dd50fbae | ||
|
42ad6ad0cc | ||
|
4e3044de20 | ||
|
b40c3b2ce3 | ||
|
08c2965fab | ||
|
2d5f434b12 | ||
|
2251c540c8 | ||
|
01582e227d | ||
|
80e2e8e6db | ||
|
bf95a3310b | ||
|
86d836897b | ||
|
18521cec1a | ||
|
066276ed65 | ||
|
8b271aa917 | ||
|
0ff9a674ca | ||
|
b1dd22afa6 | ||
|
83680d92b0 | ||
|
816f1658db | ||
|
231a8ed4b2 | ||
|
fbda20b8b7 | ||
|
e151c8399d | ||
|
8c4804eb15 | ||
|
76d376fe18 | ||
|
bb8fdcb854 | ||
|
eba5658a71 | ||
|
3c6478e179 | ||
|
460a277d4e | ||
|
9e41052992 | ||
|
0eb823ee94 | ||
|
4a3f9e12aa | ||
|
f38f5cc168 | ||
|
7adc5162fb | ||
|
779153a1cf | ||
|
378099cc10 | ||
|
56926baaec | ||
|
86c4ef5f45 | ||
|
59847db275 | ||
|
7f805287ca | ||
|
6d9187d559 | ||
|
82e9df0ac1 | ||
|
e8894b7266 | ||
|
936d193413 | ||
|
98de565979 | ||
|
594e762d63 | ||
|
6cf4e56d2a | ||
|
ca6030c5c7 | ||
|
d8ce013a2b | ||
|
d5d3dd3be3 | ||
|
c9ca451568 | ||
|
a038d76f64 | ||
|
84ee526d3f | ||
|
d47d38e0c8 | ||
|
6f6ce410c0 | ||
|
afa89ea657 | ||
|
dd8e4d9e99 | ||
|
666d7f1e03 | ||
|
1034cfd9a7 | ||
|
23f4b2a3ec | ||
|
22070dcf42 | ||
|
6d677b2207 | ||
|
1f8da3f1a7 | ||
|
bb3d8edd06 | ||
|
095829171a | ||
|
d406fbdf83 | ||
|
3edc85e0b9 | ||
|
683ec03cc8 | ||
|
4a905bdfb0 | ||
|
cd189aa97e | ||
|
8188d921c7 | ||
|
e963af3b1a | ||
|
48e318b391 | ||
|
081da8859a | ||
|
c726f19434 | ||
|
ad549a4601 | ||
|
db67c1267a | ||
|
9eb35c364d | ||
|
6e5ca1f062 | ||
|
e6d64dad61 | ||
|
b1319c7bc1 | ||
|
0455a5d740 | ||
|
12cb2736ac | ||
|
3c31e52b3c | ||
|
9a1dce5619 | ||
|
3974a4e479 | ||
|
a363aee971 | ||
|
07ea61be77 | ||
|
25bec0b50d | ||
|
29ceea3d05 | ||
|
825d1931e4 | ||
|
a9b626a706 | ||
|
5e0246d4a9 | ||
|
5c25f98db7 | ||
|
c9187ce4ca | ||
|
48671b682a | ||
|
d478864fb3 | ||
|
8ed039107b | ||
|
88d8905c0f | ||
|
0a3e6598b2 | ||
|
733c824c49 | ||
|
719aceac82 | ||
|
2fa1da0f5e | ||
|
9b9b627fe5 | ||
|
e86f4f9a36 | ||
|
06c227598c | ||
|
454c74035c | ||
|
63b473d4ba | ||
|
d31bea7bd3 | ||
|
4a91936dd2 | ||
|
94e525f3c7 | ||
|
094c30eda4 | ||
|
89050f068d | ||
|
8e2e0b4ed3 | ||
|
88139bcc03 | ||
|
dc348fac25 | ||
|
1d32a0cb36 | ||
|
d95cb93df0 | ||
|
2fd3174684 | ||
|
1e9ae623d1 | ||
|
db9e2a1e41 | ||
|
106f330bb2 | ||
|
1cf2d8fe6f | ||
|
4462124848 | ||
|
dfaac5c84d | ||
|
f03933e726 | ||
|
e49c49ecb5 | ||
|
567e103058 | ||
|
2ed8b7f86e | ||
|
2f3de6060b |
5
.coveragerc
Normal file
@ -0,0 +1,5 @@
|
||||
[paths]
|
||||
source = .
|
||||
/lorax/
|
||||
[run]
|
||||
relative_files = True
|
2
.dockerignore
Normal file
@ -0,0 +1,2 @@
|
||||
.git/
|
||||
.coverage
|
28
.github/workflows/tests.yml
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
name: Tests and Coverage
|
||||
# Make sure only one action triggers the job, otherwise pushing to a
|
||||
# pull-request will run it twice.
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- "*"
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- rhel8-branch
|
||||
- rhel7-branch
|
||||
- f31-branch
|
||||
- f32-branch
|
||||
- f33-branch
|
||||
|
||||
jobs:
|
||||
unit-tests:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: "Clone Repository"
|
||||
uses: actions/checkout@v2
|
||||
- name: Run lorax tests in podman
|
||||
run: sudo make test-in-podman && cp .test-results/.coverage .coverage
|
||||
- name: Coveralls
|
||||
uses: AndreMiras/coveralls-python-action@develop
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
7
.gitignore
vendored
@ -1,7 +1,14 @@
|
||||
*.pyc
|
||||
*.rpm
|
||||
src/pylorax/version.py*
|
||||
_build/
|
||||
tests/pylint/.pylint.d/
|
||||
__pycache__/
|
||||
.coverage
|
||||
pylint-log
|
||||
.pytest_cache/
|
||||
.test-results/
|
||||
/lorax-*.tar.gz
|
||||
/bots
|
||||
/test/images
|
||||
/tmp
|
||||
|
7
Dockerfile.test
Normal file
@ -0,0 +1,7 @@
|
||||
FROM registry.fedoraproject.org/fedora:rawhide
|
||||
COPY test-packages .
|
||||
RUN dnf -y install $(cat test-packages) && touch /.in-container
|
||||
RUN useradd weldr
|
||||
VOLUME /lorax-ro
|
||||
VOLUME /test-results
|
||||
WORKDIR /lorax-ro
|
30
HACKING.md
Normal file
@ -0,0 +1,30 @@
|
||||
# Hacking on Lorax
|
||||
|
||||
Here's where to get the code:
|
||||
|
||||
$ git clone https://github.com/weldr/lorax
|
||||
$ cd lorax/
|
||||
|
||||
How to build it:
|
||||
|
||||
$ make
|
||||
|
||||
## How to run the tests
|
||||
|
||||
To run the tests you need the following dependencies installed:
|
||||
|
||||
$ yum install python3-nose python3-pytest-mock python3-pocketlint \
|
||||
python3-mock python3-magic
|
||||
|
||||
Run the basic linting tests like this:
|
||||
|
||||
$ make check
|
||||
|
||||
|
||||
To run the broader unit and integration tests we use:
|
||||
|
||||
$ make test
|
||||
|
||||
The tests may also be run using a podman container:
|
||||
|
||||
$ make test-in-podman
|
136
Makefile
@ -1,11 +1,30 @@
|
||||
PYTHON ?= /usr/bin/python3
|
||||
DESTDIR ?= /
|
||||
PREFIX ?= /usr
|
||||
mandir ?= $(PREFIX)/share/man
|
||||
DOCKER ?= podman
|
||||
PODMAN ?= $(DOCKER)
|
||||
DOCS_VERSION ?= next
|
||||
RUN_TESTS ?= ci
|
||||
|
||||
PKGNAME = lorax
|
||||
VERSION = $(shell awk '/Version:/ { print $$2 }' $(PKGNAME).spec)
|
||||
RELEASE = $(shell awk '/Release:/ { print $$2 }' $(PKGNAME).spec | sed -e 's|%.*$$||g')
|
||||
TAG = lorax-$(VERSION)-$(RELEASE)
|
||||
|
||||
IMAGE_RELEASE = $(shell awk -F: '/FROM/ { print $$2}' Dockerfile.test)
|
||||
|
||||
ifeq ($(TEST_OS),)
|
||||
OS_ID = $(shell awk -F= '/^ID/ {print $$2}' /etc/os-release)
|
||||
OS_VERSION = $(shell awk -F= '/^VERSION_ID/ {print $$2}' /etc/os-release)
|
||||
TEST_OS = $(OS_ID)-$(OS_VERSION)
|
||||
endif
|
||||
export TEST_OS
|
||||
VM_IMAGE=$(CURDIR)/test/images/$(TEST_OS)
|
||||
|
||||
ifeq ($(REPOS_DIR),)
|
||||
REPOS_DIR = /etc/yum.repos.d
|
||||
endif
|
||||
|
||||
default: all
|
||||
|
||||
@ -16,10 +35,10 @@ all: src/pylorax/version.py
|
||||
$(PYTHON) setup.py build
|
||||
|
||||
install: all
|
||||
$(PYTHON) setup.py install --root=$(DESTDIR)
|
||||
$(PYTHON) setup.py install --root=$(DESTDIR) --prefix=$(PREFIX)
|
||||
mkdir -p $(DESTDIR)/$(mandir)/man1
|
||||
install -m 644 docs/man/lorax.1 $(DESTDIR)/$(mandir)/man1
|
||||
install -m 644 docs/man/livemedia-creator.1 $(DESTDIR)/$(mandir)/man1
|
||||
install -m 644 docs/man/*.1 $(DESTDIR)/$(mandir)/man1
|
||||
mkdir -p $(DESTDIR)/etc/bash_completion.d
|
||||
|
||||
check:
|
||||
@echo "*** Running pylint ***"
|
||||
@ -27,13 +46,27 @@ check:
|
||||
|
||||
test:
|
||||
@echo "*** Running tests ***"
|
||||
PYTHONPATH=$(PYTHONPATH):./src/ $(PYTHON) -m nose -v --with-coverage --cover-erase --cover-branches \
|
||||
--cover-package=pylorax --cover-package=bin --cover-package=sbin --cover-inclusive \
|
||||
./tests/pylorax/
|
||||
PYTHONPATH=$(PYTHONPATH):./src/ $(PYTHON) -X dev -m pytest -v --cov-branch \
|
||||
--cov=pylorax ./tests/pylorax/ ./tests/image-minimizer/
|
||||
|
||||
coverage3 report -m
|
||||
[ -f "/usr/bin/coveralls" ] && [ -n "$(COVERALLS_REPO_TOKEN)" ] && coveralls || echo
|
||||
|
||||
test_cli:
|
||||
sudo -E ./tests/test_cli.sh
|
||||
|
||||
test_mkksiso:
|
||||
sudo -E ./tests/mkksiso/test_mkksiso.sh
|
||||
|
||||
clean_cloud_envs:
|
||||
# clean beakerlib logs from previous executions
|
||||
sudo rm -rf /var/tmp/beakerlib-*/
|
||||
sudo -E ./tests/cleanup/remove_old_objects_aws.sh
|
||||
sudo -E ./tests/cleanup/remove_old_objects_openstack.sh
|
||||
sudo -E ./tests/cleanup/remove_old_objects_azure.sh
|
||||
sudo -E ./tests/cleanup/remove_old_objects_vmware.sh
|
||||
# make sure all cleanup scripts finished successfully
|
||||
sudo sh -c 'grep RESULT_STRING /var/tmp/beakerlib-*/TestResults | grep -v PASS && exit 1 || exit 0'
|
||||
|
||||
clean:
|
||||
-rm -rf build src/pylorax/version.py
|
||||
@ -42,16 +75,26 @@ tag:
|
||||
git tag -f $(TAG)
|
||||
|
||||
docs:
|
||||
$(MAKE) -C docs apidoc
|
||||
$(MAKE) -C docs apidoc html man
|
||||
|
||||
# This is needed to reset the ownership of the new docs files after they are created in a container
|
||||
set-docs-owner:
|
||||
sudo chown -R $(LOCAL_UID):$(LOCAL_GID) docs/
|
||||
|
||||
archive:
|
||||
@git archive --format=tar --prefix=$(PKGNAME)-$(VERSION)/ $(TAG) > $(PKGNAME)-$(VERSION).tar
|
||||
@gzip $(PKGNAME)-$(VERSION).tar
|
||||
@gzip -f $(PKGNAME)-$(VERSION).tar
|
||||
@echo "The archive is in $(PKGNAME)-$(VERSION).tar.gz"
|
||||
|
||||
dist: tag archive
|
||||
scp $(PKGNAME)-$(VERSION).tar.gz fedorahosted.org:lorax
|
||||
|
||||
srpm: archive $(PKGNAME).spec
|
||||
rpmbuild -bs \
|
||||
--define "_sourcedir $(CURDIR)" \
|
||||
--define "_srcrpmdir $(CURDIR)" \
|
||||
lorax.spec
|
||||
|
||||
local:
|
||||
@rm -rf $(PKGNAME)-$(VERSION).tar.gz
|
||||
@rm -rf /var/tmp/$(PKGNAME)-$(VERSION)
|
||||
@ -61,4 +104,81 @@ local:
|
||||
@rm -rf /var/tmp/$(PKGNAME)-$(VERSION)
|
||||
@echo "The archive is in $(PKGNAME)-$(VERSION).tar.gz"
|
||||
|
||||
local-srpm: local $(PKGNAME).spec
|
||||
rpmbuild -bs \
|
||||
--define "_sourcedir $(CURDIR)" \
|
||||
--define "_srcrpmdir $(CURDIR)" \
|
||||
lorax.spec
|
||||
|
||||
test-in-copy:
|
||||
rsync -a --exclude=.git /lorax-ro/ /lorax/
|
||||
make -C /lorax/ $(RUN_TESTS)
|
||||
cp /lorax/.coverage /test-results/
|
||||
|
||||
test-in-docker: test-in-podman
|
||||
|
||||
test-in-podman:
|
||||
$(DOCKER) build -t welder/lorax-tests:$(IMAGE_RELEASE) -f Dockerfile.test .
|
||||
@mkdir -p `pwd`/.test-results
|
||||
$(DOCKER) run --rm -it -v `pwd`/.test-results/:/test-results \
|
||||
-v `pwd`:/lorax-ro:ro --security-opt label=disable \
|
||||
--env RUN_TESTS="$(RUN_TESTS)" \
|
||||
welder/lorax-tests:$(IMAGE_RELEASE) make test-in-copy
|
||||
# rootless podman leaves them owned by the container UID
|
||||
$(MAKE) set-docs-owner
|
||||
|
||||
docs-in-docker: docs-in-podman
|
||||
|
||||
docs-in-podman:
|
||||
$(DOCKER) build -t welder/lorax-tests:$(IMAGE_RELEASE) -f Dockerfile.test .
|
||||
$(DOCKER) run -it --rm -v `pwd`:/lorax-ro:ro \
|
||||
-v `pwd`/docs/:/lorax-ro/docs/ \
|
||||
--env LORAX_VERSION=$(DOCS_VERSION) \
|
||||
--env LOCAL_UID=`id -u` --env LOCAL_GID=`id -g` \
|
||||
--security-opt label=disable welder/lorax-tests:$(IMAGE_RELEASE) make docs
|
||||
|
||||
|
||||
ci: check test
|
||||
|
||||
$(VM_IMAGE): TAG=HEAD
|
||||
$(VM_IMAGE): srpm bots
|
||||
rm -f $(VM_IMAGE) $(VM_IMAGE).qcow2
|
||||
srpm=$(shell rpm --qf '%{Name}-%{Version}-%{Release}.src.rpm\n' -q --specfile lorax.spec | head -n1) ; \
|
||||
bots/image-customize -v \
|
||||
--resize 20G \
|
||||
--upload $$srpm:/var/tmp \
|
||||
--upload $(CURDIR)/test/vm.install:/var/tmp/vm.install \
|
||||
--upload $(realpath tests):/ \
|
||||
--run-command "chmod +x /var/tmp/vm.install" \
|
||||
--run-command "cd /var/tmp; /var/tmp/vm.install $$srpm" \
|
||||
$(TEST_OS)
|
||||
[ -f ~/.config/lorax-test-env ] && bots/image-customize \
|
||||
--upload ~/.config/lorax-test-env:/var/tmp/lorax-test-env \
|
||||
$(TEST_OS) || echo
|
||||
|
||||
|
||||
# convenience target for the above
|
||||
vm: $(VM_IMAGE)
|
||||
echo $(VM_IMAGE)
|
||||
|
||||
# grab all repositories from the host system, overwriting what's inside the VM
|
||||
# and update the image. Mostly used when testing downstream snapshots to make
|
||||
# sure VM_IMAGE is as close as possible to the host!
|
||||
vm-local-repos: vm
|
||||
|
||||
vm-reset:
|
||||
rm -f $(VM_IMAGE) $(VM_IMAGE).qcow2
|
||||
|
||||
# checkout Cockpit's bots for standard test VM images and API to launch them
|
||||
# must be from master, as only that has current and existing images; but testvm.py API is stable
|
||||
# support CI testing against a bots change
|
||||
bots:
|
||||
git clone --quiet --reference-if-able $${XDG_CACHE_HOME:-$$HOME/.cache}/cockpit-project/bots https://github.com/cockpit-project/bots.git
|
||||
if [ -n "$$COCKPIT_BOTS_REF" ]; then git -C bots fetch --quiet --depth=1 origin "$$COCKPIT_BOTS_REF"; git -C bots checkout --quiet FETCH_HEAD; fi
|
||||
@echo "checked out bots/ ref $$(git -C bots rev-parse HEAD)"
|
||||
|
||||
.PHONY: ci_after_success
|
||||
ci_after_success:
|
||||
# nothing to do here, but Jenkins expects this to be present, otherwise fails
|
||||
|
||||
.PHONY: docs check test srpm vm vm-reset docs-in-docker docs-in-podman test-in-docker test-in-podman
|
||||
|
51
README
@ -1,51 +0,0 @@
|
||||
I am the Lorax. I speak for the trees [and images].
|
||||
|
||||
Tree building tools such as pungi and revisor rely on 'buildinstall' in
|
||||
anaconda/scripts/ to produce the boot images and other such control files
|
||||
in the final tree. The existing buildinstall scripts written in a mix of
|
||||
bash and Python are unmaintainable. Lorax is an attempt to replace them
|
||||
with something more flexible.
|
||||
|
||||
|
||||
EXISTING WORKFLOW:
|
||||
|
||||
pungi and other tools call scripts/buildinstall, which in turn call other
|
||||
scripts to do the image building and data generation. Here's how it
|
||||
currently looks:
|
||||
|
||||
-> buildinstall
|
||||
* process command line options
|
||||
* write temporary yum.conf to point to correct repo
|
||||
* find anaconda release RPM
|
||||
* unpack RPM, pull in those versions of upd-instroot, mk-images,
|
||||
maketreeinfo.py, makestamp.py, and buildinstall
|
||||
|
||||
-> call upd-instroot
|
||||
|
||||
-> call maketreeinfo.py
|
||||
|
||||
-> call mk-images (which figures out which mk-images.ARCH to call)
|
||||
|
||||
-> call makestamp.py
|
||||
|
||||
* clean up
|
||||
|
||||
|
||||
PROBLEMS:
|
||||
|
||||
The existing workflow presents some problems with maintaining the scripts.
|
||||
First, almost all knowledge of what goes in to the stage 1 and stage 2
|
||||
images lives in upd-instroot. The mk-images* scripts copy things from the
|
||||
root created by upd-instroot in order to build the stage 1 image, though
|
||||
it's not completely clear from reading the scripts.
|
||||
|
||||
|
||||
NEW IDEAS:
|
||||
|
||||
Create a new central driver with all information living in Python modules.
|
||||
Configuration files will provide the knowledge previously contained in the
|
||||
upd-instroot and mk-images* scripts.
|
||||
|
||||
|
||||
--
|
||||
David Cantrell <dcantrell@redhat.com>
|
6
README.md
Normal file
@ -0,0 +1,6 @@
|
||||
Lorax is a set of tools used to create bootable images.
|
||||
|
||||
* lorax - creates the Anaconda boot.iso used to install Fedora
|
||||
* livemedia-creator - uses Anaconda to create bootable images
|
||||
|
||||
See the [Weldr blog](https://weldr.io) for more info about BDCS and the [Lorax documentation](https://weldr.io/lorax) for more information about Lorax and associated tools.
|
135
RELEASE.md
Normal file
@ -0,0 +1,135 @@
|
||||
How to release a new version of Lorax for Fedora
|
||||
================================================
|
||||
|
||||
Install `tito` and `podman` on your system.
|
||||
|
||||
Optionally patch `tito` to support signing the tags with your gpg key. If you
|
||||
do this your key should be available on the public gpg keyservers so that
|
||||
people can verify your signature.
|
||||
|
||||
The upstream `tito` PR can be found [here](https://github.com/dgoodwin/tito/pull/328).
|
||||
|
||||
You will need to have permission to push to the lorax repository, and to the
|
||||
Fedora dist-git repository. If your FAS name isn't listed on the [lorax package
|
||||
page](https://src.fedoraproject.org/rpms/lorax/) members list then you need to
|
||||
contact one of the project admins and ask to be added.
|
||||
|
||||
|
||||
Run the tests
|
||||
-------------
|
||||
You can run the tests using `podman` instead of `docker` by running this from the
|
||||
top level of the checked-out lorax repo:
|
||||
|
||||
DOCKER=podman RUN_TESTS="ci test_cli" make test-in-docker
|
||||
|
||||
If they fail, fix them and submit a PR :)
|
||||
|
||||
You can also run the cockpit CI tests locally:
|
||||
|
||||
make vm
|
||||
./test/check-cli
|
||||
|
||||
See the `./test/README.md` documentation for more details about the cockpit CI
|
||||
tests.
|
||||
|
||||
|
||||
Update the documentation
|
||||
------------------------
|
||||
If there are changes to the code that would effect the documentation you should
|
||||
rebuild the `sphinx` based documents:
|
||||
|
||||
DOCKER=podman make docs-in-docker
|
||||
git add docs/
|
||||
git commit -m "New lorax documentation - x.y"
|
||||
|
||||
The documentation is accessible [from here](https://weldr.io/lorax), and the
|
||||
source for those pages is stored in the `gh-pages` branch of lorax. I have a
|
||||
second `lorax` repository checked out that I use for updating the `gh-pages`
|
||||
branch:
|
||||
|
||||
git clone git@github.com:weldr/lorax.git lorax-gh-pages
|
||||
cd lorax-gh-pages
|
||||
git checkout gh-pages
|
||||
git pull
|
||||
|
||||
And then I rsync the new documentation over from the current lorax build
|
||||
directory:
|
||||
|
||||
rsync -aP --exclude .git --exclude .nojekyll ../lorax/docs/html/ ./
|
||||
git add .
|
||||
git commit -m "Add lorax x.y documentation"
|
||||
git push
|
||||
|
||||
After a few minutes the online version of the documentation should appear.
|
||||
|
||||
Tag and build the release tar.gz
|
||||
--------------------------------
|
||||
We use the `tito` tool to handle incrementing the version number and updating
|
||||
the `lorax.spec` file changelog section using the git commits since the last
|
||||
tag. `tito tag` will open an editor, allowing you to edit the changelog. Make
|
||||
sure it looks clean, entries starting with '- ' and no wrapped lines:
|
||||
|
||||
tito tag
|
||||
git push --follow-tags origin
|
||||
|
||||
Build the release tarball:
|
||||
|
||||
tito build --tgz
|
||||
|
||||
The release tarball will be placed into /tmp/tito/lorax-x.y.z.tar.gz
|
||||
|
||||
|
||||
Build the Fedora lorax package
|
||||
------------------------------
|
||||
The first time you do this you need to clone the Fedora dist-git repository
|
||||
[from here](https://src.fedoraproject.org/rpms/lorax/) using your ssh key:
|
||||
|
||||
git clone URL lorax-fedora
|
||||
|
||||
After that the steps are the same each time, make sure your `lorax-fedora` repo
|
||||
is up to date:
|
||||
|
||||
git co master
|
||||
git pull
|
||||
|
||||
Copy the `lorax.spec` that tito modified from your `lorax` project repo:
|
||||
|
||||
cp /path/to/lorax/repo/lorax.spec .
|
||||
|
||||
Make sure you have a current fedoraproject kerberos ticket, you can use
|
||||
`kswitch -p FEDORAPROJECT.ORG` to switch to it if you need to, or `kinit` to
|
||||
get one. See [the Fedora
|
||||
wiki](https://fedoraproject.org/wiki/Infrastructure/Kerberos) for more details
|
||||
and debugging tips.
|
||||
|
||||
Upload the new release's tar to build system, making sure you pick the right
|
||||
one. The `/tmp/tito/` directory is only cleared out when you reboot, so it may
|
||||
have several versions in there:
|
||||
|
||||
fedpkg new-sources /tmp/tito/lorax-x.y.tar.gz
|
||||
|
||||
Update the changelog. Yes, fedpkg changes the formatting and it is annoying.
|
||||
Make sure the lines start with '- ' and that any wrapped lines are un-wrapped.
|
||||
Usually the committer email address is what will get bumped to the next line:
|
||||
|
||||
fedpkg clog
|
||||
vim clog
|
||||
|
||||
Add all the updated files, make sure nothing has been forgotten (lorax.spec, sources, .gitignore):
|
||||
|
||||
git add -u
|
||||
git status (just to be sure you have all the files added )
|
||||
git commit -F clog
|
||||
git show
|
||||
|
||||
Examine the commit with care. Make sure the sources have changed, that the NVR
|
||||
is correct, and that it contains the %changelog
|
||||
|
||||
At this point anything can be changed, either reset the checkout to the last
|
||||
commit and start over, or fix the problems and squash the changes together into
|
||||
the commit you just made. There should be one commit per-release.
|
||||
|
||||
fedpkg push && fedpkg build
|
||||
|
||||
If there are errors in the build, check the logs in koji at the link provided by fedpkg.
|
||||
|
@ -7,8 +7,8 @@ SPHINXBUILD = sphinx-build-3
|
||||
SPHINXAPIDOC = sphinx-apidoc-3
|
||||
PAPER =
|
||||
BUILDDIR = .
|
||||
SOURCEDIR = ../src/pylorax
|
||||
MODULE_NAMES = pylorax.rst modules.rst
|
||||
SOURCEDIR = ../src
|
||||
MODULE_NAMES = pylorax.rst pylorax.api.rst modules.rst composer.rst composer.cli.rst
|
||||
|
||||
# User-friendly check for sphinx-build
|
||||
ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
|
||||
|
44
docs/conf.py
@ -51,20 +51,37 @@ master_doc = 'index'
|
||||
|
||||
# General information about the project.
|
||||
project = u'Lorax'
|
||||
copyright = u'2015, Red Hat, Inc.' # pylint: disable=redefined-builtin
|
||||
copyright = u'2018, Red Hat, Inc.' # pylint: disable=redefined-builtin
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
# |version| and |release|, also used in various other places throughout the
|
||||
# built documents.
|
||||
# Pass in LORAX_VERSION to set a specific version
|
||||
# Set LORAX_VERSION=next to bump it to the next release
|
||||
def read_version():
|
||||
""" Read version from ../lorax.spec"""
|
||||
"""Read version from $LORAX_VERSION or ../lorax.spec, or bump the version from lorax.spec"""
|
||||
# This allows the .spec version to be overridded. eg. when documenting an upcoming release
|
||||
if "LORAX_VERSION" in os.environ and "next" not in os.environ["LORAX_VERSION"]:
|
||||
return os.environ["LORAX_VERSION"]
|
||||
|
||||
doc_version = None
|
||||
import re
|
||||
version_re = re.compile(r"Version:\s+(.*)")
|
||||
with open("../lorax.spec", "rt") as f:
|
||||
for line in f:
|
||||
m = version_re.match(line)
|
||||
if m:
|
||||
return m.group(1)
|
||||
doc_version = m.group(1)
|
||||
if not doc_version:
|
||||
raise RuntimeError("Failed to find current version")
|
||||
|
||||
# Make it easier to generate docs for the next release
|
||||
if "next" in os.environ["LORAX_VERSION"]:
|
||||
fields = doc_version.split(".")
|
||||
fields[-1] = str(int(fields[-1]) + 1)
|
||||
doc_version = ".".join(fields)
|
||||
|
||||
return doc_version
|
||||
|
||||
#
|
||||
# The short X.Y version.
|
||||
@ -155,6 +172,9 @@ html_static_path = ['_static']
|
||||
# using the given strftime format.
|
||||
#html_last_updated_fmt = '%b %d, %Y'
|
||||
|
||||
# Turn off smartquotes, it mangles dashes in the docstrings
|
||||
smartquotes = False
|
||||
|
||||
# If true, SmartyPants will be used to convert quotes and dashes to
|
||||
# typographically correct entities.
|
||||
#html_use_smartypants = True
|
||||
@ -214,7 +234,7 @@ latex_elements = {
|
||||
# author, documentclass [howto, manual, or own class]).
|
||||
latex_documents = [
|
||||
('index', 'Lorax.tex', u'Lorax Documentation',
|
||||
u'Anaconda Team', 'manual'),
|
||||
u'Weldr Team', 'manual'),
|
||||
]
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top of
|
||||
@ -243,8 +263,10 @@ latex_documents = [
|
||||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
('lorax', 'lorax', u'Lorax Documentation', [u'Anaconda Team'], 1),
|
||||
('livemedia-creator', 'livemedia-creator', u'Live Media Creator Documentation', [u'Anaconda Team'], 1)
|
||||
('lorax', 'lorax', u'Lorax Documentation', [u'Weldr Team'], 1),
|
||||
('livemedia-creator', 'livemedia-creator', u'Live Media Creator Documentation', [u'Weldr Team'], 1),
|
||||
('mkksiso', 'mkksiso', u'Make Kickstart ISO Utility Documentation', [u'Weldr Team'], 1),
|
||||
('image-minimizer', 'image-minimizer', u'Utility script to remove files and packages', [u'Weldr Team'], 1),
|
||||
]
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
@ -258,7 +280,7 @@ man_pages = [
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
('index', 'Lorax', u'Lorax Documentation',
|
||||
u'Anaconda Team', 'Lorax', 'One line description of project.',
|
||||
u'Weldr Team', 'Lorax', 'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
]
|
||||
|
||||
@ -279,9 +301,9 @@ texinfo_documents = [
|
||||
|
||||
# Bibliographic Dublin Core info.
|
||||
epub_title = u'Lorax'
|
||||
epub_author = u'Anaconda Team'
|
||||
epub_publisher = u'Anaconda Team'
|
||||
epub_copyright = u'2015, Red Hat, Inc.'
|
||||
epub_author = u'Weldr Team'
|
||||
epub_publisher = u'Weldr Team'
|
||||
epub_copyright = u'2018, Red Hat, Inc.'
|
||||
|
||||
# The basename for the epub file. It defaults to the project name.
|
||||
#epub_basename = u'src'
|
||||
@ -388,6 +410,6 @@ class Mock(object):
|
||||
def __getitem__(cls, key):
|
||||
return cls.__getattr__(key)
|
||||
|
||||
MOCK_MODULES = ["selinux", "dnf", "rpmUtils", "rpmUtils.arch"]
|
||||
MOCK_MODULES = ["selinux", "dnf", "dnf.logging", "dnf.transaction", "rpmUtils", "rpmUtils.arch"]
|
||||
for mod_name in MOCK_MODULES:
|
||||
sys.modules[mod_name] = Mock()
|
||||
|
@ -7,16 +7,12 @@ url --url="http://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/Ever
|
||||
rootpw --plaintext replace-this-pw
|
||||
# Network information
|
||||
network --bootproto=dhcp --activate
|
||||
# System authorization information
|
||||
auth --useshadow --passalgo=sha512
|
||||
# System keyboard
|
||||
keyboard --xlayouts=us --vckeymap=us
|
||||
# System language
|
||||
lang en_US.UTF-8
|
||||
# SELinux configuration
|
||||
selinux --enforcing
|
||||
# Installation logging level
|
||||
logging --level=info
|
||||
# Shutdown after installation
|
||||
shutdown
|
||||
# System timezone
|
||||
|
@ -14,13 +14,11 @@ url --url="http://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/Ever
|
||||
# Network information
|
||||
network --bootproto=dhcp --device=link --activate
|
||||
|
||||
# System authorization information
|
||||
auth --useshadow --passalgo=sha512
|
||||
# SELinux configuration
|
||||
selinux --enforcing
|
||||
|
||||
# System services
|
||||
services --disabled="network,sshd" --enabled="NetworkManager,ModemManager"
|
||||
services --disabled="sshd" --enabled="NetworkManager,ModemManager"
|
||||
|
||||
# livemedia-creator modifications.
|
||||
shutdown
|
||||
@ -30,6 +28,7 @@ bootloader --location=none
|
||||
clearpart --all --initlabel
|
||||
rootpw rootme
|
||||
# Disk partitioning information
|
||||
reqpart
|
||||
part / --size=6656
|
||||
|
||||
%post
|
||||
@ -64,21 +63,14 @@ livedir="LiveOS"
|
||||
for arg in \`cat /proc/cmdline\` ; do
|
||||
if [ "\${arg##rd.live.dir=}" != "\${arg}" ]; then
|
||||
livedir=\${arg##rd.live.dir=}
|
||||
return
|
||||
continue
|
||||
fi
|
||||
if [ "\${arg##live_dir=}" != "\${arg}" ]; then
|
||||
livedir=\${arg##live_dir=}
|
||||
return
|
||||
fi
|
||||
done
|
||||
|
||||
# enable swaps unless requested otherwise
|
||||
swaps=\`blkid -t TYPE=swap -o device\`
|
||||
if ! strstr "\`cat /proc/cmdline\`" noswap && [ -n "\$swaps" ] ; then
|
||||
for s in \$swaps ; do
|
||||
action "Enabling swap partition \$s" swapon \$s
|
||||
done
|
||||
fi
|
||||
# enable swapfile unless requested otherwise
|
||||
if ! strstr "\`cat /proc/cmdline\`" noswap && [ -f /run/initramfs/live/\${livedir}/swap.img ] ; then
|
||||
action "Enabling swap file" swapon /run/initramfs/live/\${livedir}/swap.img
|
||||
fi
|
||||
@ -123,7 +115,6 @@ findPersistentHome() {
|
||||
for arg in \`cat /proc/cmdline\` ; do
|
||||
if [ "\${arg##persistenthome=}" != "\${arg}" ]; then
|
||||
homedev=\${arg##persistenthome=}
|
||||
return
|
||||
fi
|
||||
done
|
||||
}
|
||||
@ -143,7 +134,7 @@ if [ -n "\$configdone" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# add fedora user with no passwd
|
||||
# add liveuser user with no passwd
|
||||
action "Adding live user" useradd \$USERADDARGS -c "Live System User" liveuser
|
||||
passwd -d liveuser > /dev/null
|
||||
usermod -aG wheel liveuser > /dev/null
|
||||
@ -176,6 +167,10 @@ systemctl --no-reload disable atd.service 2> /dev/null || :
|
||||
systemctl stop crond.service 2> /dev/null || :
|
||||
systemctl stop atd.service 2> /dev/null || :
|
||||
|
||||
# turn off abrtd on a live image
|
||||
systemctl --no-reload disable abrtd.service 2> /dev/null || :
|
||||
systemctl stop abrtd.service 2> /dev/null || :
|
||||
|
||||
# Don't sync the system clock when running live (RHBZ #1018162)
|
||||
sed -i 's/rtcsync//' /etc/chrony.conf
|
||||
|
||||
@ -183,9 +178,7 @@ sed -i 's/rtcsync//' /etc/chrony.conf
|
||||
touch /.liveimg-configured
|
||||
|
||||
# add static hostname to work around xauth bug
|
||||
# https://bugzilla.redhat.com/show_bug.cgi?id=679486
|
||||
echo "localhost" > /etc/hostname
|
||||
|
||||
hostnamectl set-hostname "localhost-live"
|
||||
EOF
|
||||
|
||||
# bah, hal starts way too late
|
||||
@ -268,7 +261,7 @@ releasever=$(rpm -q --qf '%{version}\n' --whatprovides system-release)
|
||||
basearch=$(uname -i)
|
||||
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch
|
||||
echo "Packages within this LiveCD"
|
||||
rpm -qa
|
||||
rpm -qa --qf '%{size}\t%{name}-%{version}-%{release}.%{arch}\n' |sort -rn
|
||||
# Note that running rpm recreates the rpm db files which aren't needed or wanted
|
||||
rm -f /var/lib/rpm/__db*
|
||||
|
||||
@ -278,18 +271,23 @@ rm -f /var/lib/rpm/__db*
|
||||
# make sure there aren't core files lying around
|
||||
rm -f /core*
|
||||
|
||||
# remove random seed, the newly installed instance should make it's own
|
||||
rm -f /var/lib/systemd/random-seed
|
||||
|
||||
# convince readahead not to collect
|
||||
# FIXME: for systemd
|
||||
|
||||
echo 'File created by kickstart. See systemd-update-done.service(8).' \
|
||||
| tee /etc/.updated >/var/.updated
|
||||
|
||||
# Remove random-seed
|
||||
rm /var/lib/systemd/random-seed
|
||||
|
||||
# Remove the rescue kernel and image to save space
|
||||
# Installation will recreate these on the target
|
||||
rm -f /boot/*-rescue*
|
||||
|
||||
# Remove machine-id on pre generated images
|
||||
rm -f /etc/machine-id
|
||||
touch /etc/machine-id
|
||||
|
||||
%end
|
||||
|
||||
%post
|
||||
@ -303,10 +301,30 @@ cat >> /usr/share/glib-2.0/schemas/org.gnome.software.gschema.override << FOE
|
||||
download-updates=false
|
||||
FOE
|
||||
|
||||
# don't autostart gnome-software session service
|
||||
rm -f /etc/xdg/autostart/gnome-software-service.desktop
|
||||
|
||||
# disable the gnome-software shell search provider
|
||||
cat >> /usr/share/gnome-shell/search-providers/org.gnome.Software-search-provider.ini << FOE
|
||||
DefaultDisabled=true
|
||||
FOE
|
||||
|
||||
# don't run gnome-initial-setup
|
||||
mkdir ~liveuser/.config
|
||||
touch ~liveuser/.config/gnome-initial-setup-done
|
||||
|
||||
# suppress anaconda spokes redundant with gnome-initial-setup
|
||||
cat >> /etc/sysconfig/anaconda << FOE
|
||||
[NetworkSpoke]
|
||||
visited=1
|
||||
|
||||
[PasswordSpoke]
|
||||
visited=1
|
||||
|
||||
[UserSpoke]
|
||||
visited=1
|
||||
FOE
|
||||
|
||||
# make the installer show up
|
||||
if [ -f /usr/share/applications/liveinst.desktop ]; then
|
||||
# Show harddisk install in shell dash
|
||||
@ -316,7 +334,7 @@ if [ -f /usr/share/applications/liveinst.desktop ]; then
|
||||
|
||||
cat >> /usr/share/glib-2.0/schemas/org.gnome.shell.gschema.override << FOE
|
||||
[org.gnome.shell]
|
||||
favorite-apps=['firefox.desktop', 'evolution.desktop', 'rhythmbox.desktop', 'shotwell.desktop', 'org.gnome.Nautilus.desktop', 'anaconda.desktop']
|
||||
favorite-apps=['firefox.desktop', 'org.gnome.Calendar.desktop', 'rhythmbox.desktop', 'org.gnome.Photos.desktop', 'org.gnome.Nautilus.desktop', 'anaconda.desktop']
|
||||
FOE
|
||||
|
||||
# Make the welcome screen show up
|
||||
@ -326,6 +344,11 @@ FOE
|
||||
cp /usr/share/anaconda/gnome/fedora-welcome.desktop ~liveuser/.config/autostart/
|
||||
fi
|
||||
|
||||
# Disable GNOME welcome tour so it doesn't overlap with Fedora welcome screen
|
||||
cat >> /usr/share/glib-2.0/schemas/org.gnome.shell.gschema.override << FOE
|
||||
welcome-dialog-last-shown-version='4294967295'
|
||||
FOE
|
||||
|
||||
# Copy Anaconda branding in place
|
||||
if [ -d /usr/share/lorax/product/usr/share/anaconda ]; then
|
||||
cp -a /usr/share/lorax/product/* /
|
||||
@ -356,36 +379,37 @@ EOF
|
||||
%end
|
||||
|
||||
%packages
|
||||
@^workstation-product-environment
|
||||
@anaconda-tools
|
||||
@base-x
|
||||
@core
|
||||
@firefox
|
||||
@fonts
|
||||
@guest-desktop-agents
|
||||
@hardware-support
|
||||
@libreoffice
|
||||
@multimedia
|
||||
@networkmanager-submodules
|
||||
@printing
|
||||
@workstation-product
|
||||
gnome-terminal
|
||||
aajohan-comfortaa-fonts
|
||||
anaconda
|
||||
anaconda-install-env-deps
|
||||
anaconda-live
|
||||
dracut-config-generic
|
||||
dracut-live
|
||||
fedora-productimg-workstation
|
||||
glibc-all-langpacks
|
||||
grub2-efi
|
||||
kernel
|
||||
# Make sure that DNF doesn't pull in debug kernel to satisfy kmod() requires
|
||||
kernel-modules
|
||||
kernel-modules-extra
|
||||
memtest86+
|
||||
syslinux
|
||||
-@dial-up
|
||||
-@input-methods
|
||||
-@standard
|
||||
-gfs2-utils
|
||||
-reiserfs-utils
|
||||
-gnome-boxes
|
||||
|
||||
# This package is needed to boot the iso on UEFI
|
||||
shim
|
||||
shim-ia32
|
||||
grub2
|
||||
grub2-efi
|
||||
grub2-efi-*-cdboot
|
||||
grub2-efi-ia32
|
||||
efibootmgr
|
||||
|
||||
# no longer in @core since 2018-10, but needed for livesys script
|
||||
initscripts
|
||||
chkconfig
|
||||
|
||||
%end
|
||||
|
@ -10,16 +10,12 @@ network --bootproto=dhcp --device=link --activate
|
||||
|
||||
# Root password
|
||||
rootpw --plaintext removethispw
|
||||
# System authorization information
|
||||
auth --useshadow --passalgo=sha512
|
||||
# System keyboard
|
||||
keyboard --xlayouts=us --vckeymap=us
|
||||
# System language
|
||||
lang en_US.UTF-8
|
||||
# SELinux configuration
|
||||
selinux --enforcing
|
||||
# Installation logging level
|
||||
logging --level=info
|
||||
# Shutdown after installation
|
||||
shutdown
|
||||
# System timezone
|
||||
@ -29,6 +25,7 @@ bootloader --location=mbr
|
||||
# Partition clearing information
|
||||
clearpart --all --initlabel
|
||||
# Disk partitioning information
|
||||
reqpart
|
||||
part / --fstype="ext4" --size=4000
|
||||
part swap --size=1000
|
||||
|
||||
@ -47,7 +44,6 @@ kernel
|
||||
kernel-modules
|
||||
kernel-modules-extra
|
||||
|
||||
memtest86+
|
||||
grub2-efi
|
||||
grub2
|
||||
shim
|
||||
|
@ -10,16 +10,12 @@ network --bootproto=dhcp --device=link --activate
|
||||
|
||||
# Root password
|
||||
rootpw --plaintext removethispw
|
||||
# System authorization information
|
||||
auth --useshadow --passalgo=sha512
|
||||
# System keyboard
|
||||
keyboard --xlayouts=us --vckeymap=us
|
||||
# System language
|
||||
lang en_US.UTF-8
|
||||
# SELinux configuration
|
||||
selinux --enforcing
|
||||
# Installation logging level
|
||||
logging --level=info
|
||||
# Shutdown after installation
|
||||
shutdown
|
||||
# System timezone
|
||||
@ -47,7 +43,6 @@ kernel
|
||||
kernel-modules
|
||||
kernel-modules-extra
|
||||
|
||||
memtest86+
|
||||
grub2-efi
|
||||
grub2
|
||||
shim
|
||||
|
@ -9,16 +9,12 @@ url --url="http://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/Ever
|
||||
rootpw --plaintext replace-this-pw
|
||||
# Network information
|
||||
network --bootproto=dhcp --activate
|
||||
# System authorization information
|
||||
auth --useshadow --passalgo=sha512
|
||||
# System keyboard
|
||||
keyboard --xlayouts=us --vckeymap=us
|
||||
# System language
|
||||
lang en_US.UTF-8
|
||||
# SELinux configuration
|
||||
selinux --enforcing
|
||||
# Installation logging level
|
||||
logging --level=info
|
||||
# Shutdown after installation
|
||||
shutdown
|
||||
# System timezone
|
||||
@ -44,7 +40,6 @@ kernel
|
||||
kernel-modules
|
||||
kernel-modules-extra
|
||||
|
||||
memtest86+
|
||||
grub2-efi
|
||||
grub2
|
||||
shim
|
||||
|
@ -15,16 +15,12 @@ rootpw --lock
|
||||
user --name=vagrant
|
||||
sshkey --username=vagrant "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key"
|
||||
|
||||
# System authorization information
|
||||
auth --useshadow --passalgo=sha512
|
||||
# System keyboard
|
||||
keyboard --xlayouts=us --vckeymap=us
|
||||
# System language
|
||||
lang en_US.UTF-8
|
||||
# SELinux configuration
|
||||
selinux --enforcing
|
||||
# Installation logging level
|
||||
logging --level=info
|
||||
# Shutdown after installation
|
||||
shutdown
|
||||
# System timezone
|
||||
@ -56,7 +52,6 @@ kernel
|
||||
kernel-modules
|
||||
kernel-modules-extra
|
||||
|
||||
memtest86+
|
||||
grub2-efi
|
||||
grub2
|
||||
shim
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Sphinx build info version 1
|
||||
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
|
||||
config: f1415c4a8da85a626a1e43de08e00a62
|
||||
config: 3dbb02a107cfe7acde05f2a0794f42a8
|
||||
tags: 645f666f9bcd5a90fca523b33c5a78b7
|
||||
|
BIN
docs/html/.doctrees/image-minimizer.doctree
Normal file
BIN
docs/html/.doctrees/mkksiso.doctree
Normal file
@ -1,75 +1,31 @@
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
|
||||
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
|
||||
<html class="writer-html5" lang="en" >
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>Overview: module code — Lorax 28.2 documentation</title>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Overview: module code — Lorax 36.5 documentation</title>
|
||||
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
||||
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="index" title="Index"
|
||||
href="../genindex.html"/>
|
||||
<link rel="search" title="Search" href="../search.html"/>
|
||||
<link rel="top" title="Lorax 28.2 documentation" href="../index.html"/>
|
||||
|
||||
|
||||
<script src="../_static/js/modernizr.min.js"></script>
|
||||
|
||||
<script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
|
||||
<script src="../_static/jquery.js"></script>
|
||||
<script src="../_static/underscore.js"></script>
|
||||
<script src="../_static/doctools.js"></script>
|
||||
<script src="../_static/js/theme.js"></script>
|
||||
<link rel="index" title="Index" href="../genindex.html" />
|
||||
<link rel="search" title="Search" href="../search.html" />
|
||||
</head>
|
||||
|
||||
<body class="wy-body-for-nav" role="document">
|
||||
|
||||
|
||||
<body class="wy-body-for-nav">
|
||||
<div class="wy-grid-for-nav">
|
||||
|
||||
|
||||
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
|
||||
<div class="wy-side-scroll">
|
||||
<div class="wy-side-nav-search">
|
||||
|
||||
|
||||
|
||||
<div class="wy-side-nav-search" >
|
||||
<a href="../index.html" class="icon icon-home"> Lorax
|
||||
|
||||
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="version">
|
||||
28.2
|
||||
36.5
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div role="search">
|
||||
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
|
||||
<input type="text" name="q" placeholder="Search docs" />
|
||||
@ -77,80 +33,36 @@
|
||||
<input type="hidden" name="area" value="default" />
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../intro.html">Introduction to Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../intro.html#before-lorax">Before Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../lorax.html">Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../livemedia-creator.html">livemedia-creator</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../mkksiso.html">mkksiso</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../product-images.html">Product and Updates Images</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../modules.html">pylorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../image-minimizer.html">image-minimizer</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../modules.html">src</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
|
||||
|
||||
|
||||
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
|
||||
|
||||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
|
||||
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
||||
<a href="../index.html">Lorax</a>
|
||||
|
||||
</nav>
|
||||
|
||||
|
||||
|
||||
<div class="wy-nav-content">
|
||||
<div class="rst-content">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div role="navigation" aria-label="breadcrumbs navigation">
|
||||
|
||||
<div role="navigation" aria-label="Page navigation">
|
||||
<ul class="wy-breadcrumbs">
|
||||
|
||||
<li><a href="../index.html">Docs</a> »</li>
|
||||
|
||||
<li><a href="../index.html" class="icon icon-home"></a> »</li>
|
||||
<li>Overview: module code</li>
|
||||
|
||||
|
||||
<li class="wy-breadcrumbs-aside">
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
<hr/>
|
||||
</div>
|
||||
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
|
||||
@ -161,11 +73,14 @@
|
||||
<ul><li><a href="pylorax/base.html">pylorax.base</a></li>
|
||||
<li><a href="pylorax/buildstamp.html">pylorax.buildstamp</a></li>
|
||||
<li><a href="pylorax/cmdline.html">pylorax.cmdline</a></li>
|
||||
<li><a href="pylorax/creator.html">pylorax.creator</a></li>
|
||||
<li><a href="pylorax/decorators.html">pylorax.decorators</a></li>
|
||||
<li><a href="pylorax/discinfo.html">pylorax.discinfo</a></li>
|
||||
<li><a href="pylorax/dnfbase.html">pylorax.dnfbase</a></li>
|
||||
<li><a href="pylorax/dnfhelper.html">pylorax.dnfhelper</a></li>
|
||||
<li><a href="pylorax/executils.html">pylorax.executils</a></li>
|
||||
<li><a href="pylorax/imgutils.html">pylorax.imgutils</a></li>
|
||||
<li><a href="pylorax/installer.html">pylorax.installer</a></li>
|
||||
<li><a href="pylorax/ltmpl.html">pylorax.ltmpl</a></li>
|
||||
<li><a href="pylorax/monitor.html">pylorax.monitor</a></li>
|
||||
<li><a href="pylorax/mount.html">pylorax.mount</a></li>
|
||||
@ -174,66 +89,31 @@
|
||||
<li><a href="pylorax/treeinfo.html">pylorax.treeinfo</a></li>
|
||||
</ul></ul>
|
||||
|
||||
</div>
|
||||
<div class="articleComments">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<footer>
|
||||
|
||||
|
||||
<hr/>
|
||||
|
||||
<div role="contentinfo">
|
||||
<p>
|
||||
© Copyright 2015, Red Hat, Inc..
|
||||
|
||||
</p>
|
||||
<p>© Copyright 2018, Red Hat, Inc..</p>
|
||||
</div>
|
||||
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||||
|
||||
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
|
||||
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
|
||||
provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||||
|
||||
|
||||
</footer>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
var DOCUMENTATION_OPTIONS = {
|
||||
URL_ROOT:'../',
|
||||
VERSION:'28.2',
|
||||
COLLAPSE_INDEX:false,
|
||||
FILE_SUFFIX:'.html',
|
||||
HAS_SOURCE: true,
|
||||
SOURCELINK_SUFFIX: '.txt'
|
||||
};
|
||||
</script>
|
||||
<script type="text/javascript" src="../_static/jquery.js"></script>
|
||||
<script type="text/javascript" src="../_static/underscore.js"></script>
|
||||
<script type="text/javascript" src="../_static/doctools.js"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript" src="../_static/js/theme.js"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
<script>
|
||||
jQuery(function () {
|
||||
SphinxRtdTheme.StickyNav.enable();
|
||||
SphinxRtdTheme.Navigation.enable(true);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,76 +1,31 @@
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
|
||||
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
|
||||
<html class="writer-html5" lang="en" >
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>pylorax — Lorax 28.2 documentation</title>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pylorax — Lorax 36.4 documentation</title>
|
||||
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
||||
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="index" title="Index"
|
||||
href="../genindex.html"/>
|
||||
<link rel="search" title="Search" href="../search.html"/>
|
||||
<link rel="top" title="Lorax 28.2 documentation" href="../index.html"/>
|
||||
<link rel="up" title="Module code" href="index.html"/>
|
||||
|
||||
|
||||
<script src="../_static/js/modernizr.min.js"></script>
|
||||
|
||||
<script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
|
||||
<script src="../_static/jquery.js"></script>
|
||||
<script src="../_static/underscore.js"></script>
|
||||
<script src="../_static/doctools.js"></script>
|
||||
<script src="../_static/js/theme.js"></script>
|
||||
<link rel="index" title="Index" href="../genindex.html" />
|
||||
<link rel="search" title="Search" href="../search.html" />
|
||||
</head>
|
||||
|
||||
<body class="wy-body-for-nav" role="document">
|
||||
|
||||
|
||||
<body class="wy-body-for-nav">
|
||||
<div class="wy-grid-for-nav">
|
||||
|
||||
|
||||
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
|
||||
<div class="wy-side-scroll">
|
||||
<div class="wy-side-nav-search">
|
||||
|
||||
|
||||
|
||||
<div class="wy-side-nav-search" >
|
||||
<a href="../index.html" class="icon icon-home"> Lorax
|
||||
|
||||
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="version">
|
||||
28.2
|
||||
36.4
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div role="search">
|
||||
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
|
||||
<input type="text" name="q" placeholder="Search docs" />
|
||||
@ -78,82 +33,36 @@
|
||||
<input type="hidden" name="area" value="default" />
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../intro.html">Introduction to Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../intro.html#before-lorax">Before Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../lorax.html">Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../livemedia-creator.html">livemedia-creator</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../mkksiso.html">mkksiso</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../product-images.html">Product and Updates Images</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../modules.html">pylorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../modules.html">src</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
|
||||
|
||||
|
||||
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
|
||||
|
||||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
|
||||
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
||||
<a href="../index.html">Lorax</a>
|
||||
|
||||
</nav>
|
||||
|
||||
|
||||
|
||||
<div class="wy-nav-content">
|
||||
<div class="rst-content">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div role="navigation" aria-label="breadcrumbs navigation">
|
||||
|
||||
<div role="navigation" aria-label="Page navigation">
|
||||
<ul class="wy-breadcrumbs">
|
||||
|
||||
<li><a href="../index.html">Docs</a> »</li>
|
||||
|
||||
<li><a href="../index.html" class="icon icon-home"></a> »</li>
|
||||
<li><a href="index.html">Module code</a> »</li>
|
||||
|
||||
<li>pylorax</li>
|
||||
|
||||
|
||||
<li class="wy-breadcrumbs-aside">
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
<hr/>
|
||||
</div>
|
||||
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
|
||||
@ -194,22 +103,22 @@
|
||||
<span class="kn">import</span> <span class="nn">configparser</span>
|
||||
<span class="kn">import</span> <span class="nn">tempfile</span>
|
||||
<span class="kn">import</span> <span class="nn">locale</span>
|
||||
<span class="kn">from</span> <span class="nn">subprocess</span> <span class="k">import</span> <span class="n">CalledProcessError</span>
|
||||
<span class="kn">from</span> <span class="nn">subprocess</span> <span class="kn">import</span> <span class="n">CalledProcessError</span>
|
||||
<span class="kn">import</span> <span class="nn">selinux</span>
|
||||
<span class="kn">from</span> <span class="nn">glob</span> <span class="k">import</span> <span class="n">glob</span>
|
||||
<span class="kn">from</span> <span class="nn">glob</span> <span class="kn">import</span> <span class="n">glob</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">pylorax.base</span> <span class="k">import</span> <span class="n">BaseLoraxClass</span><span class="p">,</span> <span class="n">DataHolder</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.base</span> <span class="kn">import</span> <span class="n">BaseLoraxClass</span><span class="p">,</span> <span class="n">DataHolder</span>
|
||||
<span class="kn">import</span> <span class="nn">pylorax.output</span> <span class="k">as</span> <span class="nn">output</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">dnf</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">pylorax.sysutils</span> <span class="k">import</span> <span class="n">joinpaths</span><span class="p">,</span> <span class="n">remove</span><span class="p">,</span> <span class="n">linktree</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.sysutils</span> <span class="kn">import</span> <span class="n">joinpaths</span><span class="p">,</span> <span class="n">remove</span><span class="p">,</span> <span class="n">linktree</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">pylorax.treebuilder</span> <span class="k">import</span> <span class="n">RuntimeBuilder</span><span class="p">,</span> <span class="n">TreeBuilder</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.buildstamp</span> <span class="k">import</span> <span class="n">BuildStamp</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.treeinfo</span> <span class="k">import</span> <span class="n">TreeInfo</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.discinfo</span> <span class="k">import</span> <span class="n">DiscInfo</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.executils</span> <span class="k">import</span> <span class="n">runcmd</span><span class="p">,</span> <span class="n">runcmd_output</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.treebuilder</span> <span class="kn">import</span> <span class="n">RuntimeBuilder</span><span class="p">,</span> <span class="n">TreeBuilder</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.buildstamp</span> <span class="kn">import</span> <span class="n">BuildStamp</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.treeinfo</span> <span class="kn">import</span> <span class="n">TreeInfo</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.discinfo</span> <span class="kn">import</span> <span class="n">DiscInfo</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.executils</span> <span class="kn">import</span> <span class="n">runcmd</span><span class="p">,</span> <span class="n">runcmd_output</span>
|
||||
|
||||
|
||||
<span class="c1"># get lorax version</span>
|
||||
@ -220,17 +129,19 @@
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">vernum</span> <span class="o">=</span> <span class="n">pylorax</span><span class="o">.</span><span class="n">version</span><span class="o">.</span><span class="n">num</span>
|
||||
|
||||
<span class="c1"># List of drivers to remove on ppc64 arch to keep initrd < 32MiB</span>
|
||||
<span class="n">REMOVE_PPC64_DRIVERS</span> <span class="o">=</span> <span class="s2">"floppy scsi_debug nouveau radeon cirrus mgag200"</span>
|
||||
<span class="n">REMOVE_PPC64_MODULES</span> <span class="o">=</span> <span class="s2">"drm plymouth"</span>
|
||||
<span class="n">DRACUT_DEFAULT</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"--xz"</span><span class="p">,</span> <span class="s2">"--install"</span><span class="p">,</span> <span class="s2">"/.buildstamp"</span><span class="p">,</span> <span class="s2">"--no-early-microcode"</span><span class="p">,</span> <span class="s2">"--add"</span><span class="p">,</span> <span class="s2">"fips"</span><span class="p">]</span>
|
||||
|
||||
<span class="c1"># Used for DNF conf.module_platform_id</span>
|
||||
<span class="n">DEFAULT_PLATFORM_ID</span> <span class="o">=</span> <span class="s2">"platform:f36"</span>
|
||||
<span class="n">DEFAULT_RELEASEVER</span> <span class="o">=</span> <span class="s2">"36"</span>
|
||||
|
||||
<div class="viewcode-block" id="ArchData"><a class="viewcode-back" href="../pylorax.html#pylorax.ArchData">[docs]</a><span class="k">class</span> <span class="nc">ArchData</span><span class="p">(</span><span class="n">DataHolder</span><span class="p">):</span>
|
||||
<span class="n">lib64_arches</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"x86_64"</span><span class="p">,</span> <span class="s2">"ppc64"</span><span class="p">,</span> <span class="s2">"ppc64le"</span><span class="p">,</span> <span class="s2">"s390x"</span><span class="p">,</span> <span class="s2">"ia64"</span><span class="p">,</span> <span class="s2">"aarch64"</span><span class="p">)</span>
|
||||
<span class="n">lib64_arches</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"x86_64"</span><span class="p">,</span> <span class="s2">"ppc64le"</span><span class="p">,</span> <span class="s2">"s390x"</span><span class="p">,</span> <span class="s2">"ia64"</span><span class="p">,</span> <span class="s2">"aarch64"</span><span class="p">)</span>
|
||||
<span class="n">bcj_arch</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span><span class="n">i386</span><span class="o">=</span><span class="s2">"x86"</span><span class="p">,</span> <span class="n">x86_64</span><span class="o">=</span><span class="s2">"x86"</span><span class="p">,</span>
|
||||
<span class="n">ppc</span><span class="o">=</span><span class="s2">"powerpc"</span><span class="p">,</span> <span class="n">ppc64</span><span class="o">=</span><span class="s2">"powerpc"</span><span class="p">,</span> <span class="n">ppc64le</span><span class="o">=</span><span class="s2">"powerpc"</span><span class="p">,</span>
|
||||
<span class="n">ppc64le</span><span class="o">=</span><span class="s2">"powerpc"</span><span class="p">,</span>
|
||||
<span class="n">arm</span><span class="o">=</span><span class="s2">"arm"</span><span class="p">,</span> <span class="n">armhfp</span><span class="o">=</span><span class="s2">"arm"</span><span class="p">)</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">buildarch</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">buildarch</span><span class="p">):</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">ArchData</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">()</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">buildarch</span> <span class="o">=</span> <span class="n">buildarch</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">basearch</span> <span class="o">=</span> <span class="n">dnf</span><span class="o">.</span><span class="n">rpm</span><span class="o">.</span><span class="n">basearch</span><span class="p">(</span><span class="n">buildarch</span><span class="p">)</span>
|
||||
@ -239,7 +150,7 @@
|
||||
|
||||
<div class="viewcode-block" id="Lorax"><a class="viewcode-back" href="../pylorax.html#pylorax.Lorax">[docs]</a><span class="k">class</span> <span class="nc">Lorax</span><span class="p">(</span><span class="n">BaseLoraxClass</span><span class="p">):</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="n">BaseLoraxClass</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_configured</span> <span class="o">=</span> <span class="kc">False</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">product</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
@ -342,7 +253,10 @@
|
||||
<span class="n">add_template_vars</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
|
||||
<span class="n">add_arch_templates</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
|
||||
<span class="n">add_arch_template_vars</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
|
||||
<span class="n">verify</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span>
|
||||
<span class="n">verify</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
|
||||
<span class="n">user_dracut_args</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
|
||||
<span class="n">squashfs_only</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
|
||||
<span class="n">skip_branding</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
|
||||
|
||||
<span class="k">assert</span> <span class="bp">self</span><span class="o">.</span><span class="n">_configured</span>
|
||||
|
||||
@ -370,6 +284,8 @@
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">init_file_logging</span><span class="p">(</span><span class="n">logdir</span><span class="p">)</span>
|
||||
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">"version is </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">vernum</span><span class="p">)</span>
|
||||
<span class="n">log_selinux_state</span><span class="p">()</span>
|
||||
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">"using work directory </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">workdir</span><span class="p">)</span>
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">"using log directory </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">logdir</span><span class="p">)</span>
|
||||
|
||||
@ -385,22 +301,6 @@
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">critical</span><span class="p">(</span><span class="s2">"no root privileges"</span><span class="p">)</span>
|
||||
<span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
|
||||
|
||||
<span class="c1"># is selinux disabled?</span>
|
||||
<span class="c1"># With selinux in enforcing mode the rpcbind package required for</span>
|
||||
<span class="c1"># dracut nfs module, which is in turn required by anaconda module,</span>
|
||||
<span class="c1"># will not get installed, because it's preinstall scriptlet fails,</span>
|
||||
<span class="c1"># resulting in an incomplete initial ramdisk image.</span>
|
||||
<span class="c1"># The reason is that the scriptlet runs tools from the shadow-utils</span>
|
||||
<span class="c1"># package in chroot, particularly groupadd and useradd to add the</span>
|
||||
<span class="c1"># required rpc group and rpc user. This operation fails, because</span>
|
||||
<span class="c1"># the selinux context on files in the chroot, that the shadow-utils</span>
|
||||
<span class="c1"># tools need to access (/etc/group, /etc/passwd, /etc/shadow etc.),</span>
|
||||
<span class="c1"># is wrong and selinux therefore disallows access to these files.</span>
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"checking the selinux mode"</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">selinux</span><span class="o">.</span><span class="n">is_selinux_enabled</span><span class="p">()</span> <span class="ow">and</span> <span class="n">selinux</span><span class="o">.</span><span class="n">security_getenforce</span><span class="p">():</span>
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">critical</span><span class="p">(</span><span class="s2">"selinux must be disabled or in Permissive mode"</span><span class="p">)</span>
|
||||
<span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
|
||||
|
||||
<span class="c1"># do we have a proper dnf base object?</span>
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"checking dnf base object"</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dbo</span><span class="p">,</span> <span class="n">dnf</span><span class="o">.</span><span class="n">Base</span><span class="p">):</span>
|
||||
@ -436,14 +336,16 @@
|
||||
<span class="n">installpkgs</span><span class="o">=</span><span class="n">installpkgs</span><span class="p">,</span>
|
||||
<span class="n">excludepkgs</span><span class="o">=</span><span class="n">excludepkgs</span><span class="p">,</span>
|
||||
<span class="n">add_templates</span><span class="o">=</span><span class="n">add_templates</span><span class="p">,</span>
|
||||
<span class="n">add_template_vars</span><span class="o">=</span><span class="n">add_template_vars</span><span class="p">)</span>
|
||||
<span class="n">add_template_vars</span><span class="o">=</span><span class="n">add_template_vars</span><span class="p">,</span>
|
||||
<span class="n">skip_branding</span><span class="o">=</span><span class="n">skip_branding</span><span class="p">)</span>
|
||||
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"installing runtime packages"</span><span class="p">)</span>
|
||||
<span class="n">rb</span><span class="o">.</span><span class="n">install</span><span class="p">()</span>
|
||||
|
||||
<span class="c1"># write .buildstamp</span>
|
||||
<span class="n">buildstamp</span> <span class="o">=</span> <span class="n">BuildStamp</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">product</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">product</span><span class="o">.</span><span class="n">version</span><span class="p">,</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">product</span><span class="o">.</span><span class="n">bugurl</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">product</span><span class="o">.</span><span class="n">isfinal</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">arch</span><span class="o">.</span><span class="n">buildarch</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">product</span><span class="o">.</span><span class="n">bugurl</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">product</span><span class="o">.</span><span class="n">isfinal</span><span class="p">,</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">arch</span><span class="o">.</span><span class="n">buildarch</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">product</span><span class="o">.</span><span class="n">variant</span><span class="p">)</span>
|
||||
|
||||
<span class="n">buildstamp</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">joinpaths</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">inroot</span><span class="p">,</span> <span class="s2">".buildstamp"</span><span class="p">))</span>
|
||||
|
||||
@ -487,9 +389,20 @@
|
||||
<span class="n">compressargs</span> <span class="o">+=</span> <span class="p">[</span><span class="s2">"-Xbcj"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">arch</span><span class="o">.</span><span class="n">bcj</span><span class="p">]</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"no BCJ filter for arch </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">arch</span><span class="o">.</span><span class="n">basearch</span><span class="p">)</span>
|
||||
<span class="n">rb</span><span class="o">.</span><span class="n">create_runtime</span><span class="p">(</span><span class="n">joinpaths</span><span class="p">(</span><span class="n">installroot</span><span class="p">,</span><span class="n">runtime</span><span class="p">),</span>
|
||||
<span class="k">if</span> <span class="n">squashfs_only</span><span class="p">:</span>
|
||||
<span class="c1"># Create an ext4 rootfs.img and compress it with squashfs</span>
|
||||
<span class="n">rc</span> <span class="o">=</span> <span class="n">rb</span><span class="o">.</span><span class="n">create_squashfs_runtime</span><span class="p">(</span><span class="n">joinpaths</span><span class="p">(</span><span class="n">installroot</span><span class="p">,</span><span class="n">runtime</span><span class="p">),</span>
|
||||
<span class="n">compression</span><span class="o">=</span><span class="n">compression</span><span class="p">,</span> <span class="n">compressargs</span><span class="o">=</span><span class="n">compressargs</span><span class="p">,</span>
|
||||
<span class="n">size</span><span class="o">=</span><span class="n">size</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="c1"># Create an ext4 rootfs.img and compress it with squashfs</span>
|
||||
<span class="n">rc</span> <span class="o">=</span> <span class="n">rb</span><span class="o">.</span><span class="n">create_ext4_runtime</span><span class="p">(</span><span class="n">joinpaths</span><span class="p">(</span><span class="n">installroot</span><span class="p">,</span><span class="n">runtime</span><span class="p">),</span>
|
||||
<span class="n">compression</span><span class="o">=</span><span class="n">compression</span><span class="p">,</span> <span class="n">compressargs</span><span class="o">=</span><span class="n">compressargs</span><span class="p">,</span>
|
||||
<span class="n">size</span><span class="o">=</span><span class="n">size</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">rc</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">:</span>
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="s2">"rootfs.img creation failed. See program.log"</span><span class="p">)</span>
|
||||
<span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
|
||||
|
||||
<span class="n">rb</span><span class="o">.</span><span class="n">finished</span><span class="p">()</span>
|
||||
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"preparing to build output tree and boot images"</span><span class="p">)</span>
|
||||
@ -503,17 +416,17 @@
|
||||
<span class="n">workdir</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">workdir</span><span class="p">)</span>
|
||||
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"rebuilding initramfs images"</span><span class="p">)</span>
|
||||
<span class="n">dracut_args</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"--xz"</span><span class="p">,</span> <span class="s2">"--install"</span><span class="p">,</span> <span class="s2">"/.buildstamp"</span><span class="p">,</span> <span class="s2">"--no-early-microcode"</span><span class="p">,</span> <span class="s2">"--add"</span><span class="p">,</span> <span class="s2">"fips"</span><span class="p">]</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">user_dracut_args</span><span class="p">:</span>
|
||||
<span class="n">dracut_args</span> <span class="o">=</span> <span class="n">DRACUT_DEFAULT</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">dracut_args</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">user_dracut_args</span><span class="p">:</span>
|
||||
<span class="n">dracut_args</span> <span class="o">+=</span> <span class="n">arg</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" "</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
|
||||
|
||||
<span class="n">anaconda_args</span> <span class="o">=</span> <span class="n">dracut_args</span> <span class="o">+</span> <span class="p">[</span><span class="s2">"--add"</span><span class="p">,</span> <span class="s2">"anaconda pollcdrom qemu qemu-net"</span><span class="p">]</span>
|
||||
|
||||
<span class="c1"># ppc64 cannot boot an initrd > 32MiB so remove some drivers</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">arch</span><span class="o">.</span><span class="n">basearch</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"ppc64"</span><span class="p">,</span> <span class="s2">"ppc64le"</span><span class="p">):</span>
|
||||
<span class="n">dracut_args</span><span class="o">.</span><span class="n">extend</span><span class="p">([</span><span class="s2">"--omit-drivers"</span><span class="p">,</span> <span class="n">REMOVE_PPC64_DRIVERS</span><span class="p">])</span>
|
||||
|
||||
<span class="c1"># Only omit dracut modules from the initrd so that they're kept for</span>
|
||||
<span class="c1"># upgrade.img</span>
|
||||
<span class="n">anaconda_args</span><span class="o">.</span><span class="n">extend</span><span class="p">([</span><span class="s2">"--omit"</span><span class="p">,</span> <span class="n">REMOVE_PPC64_MODULES</span><span class="p">])</span>
|
||||
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"dracut args = </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">dracut_args</span><span class="p">)</span>
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"anaconda args = </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">anaconda_args</span><span class="p">)</span>
|
||||
<span class="n">treebuilder</span><span class="o">.</span><span class="n">rebuild_initrds</span><span class="p">(</span><span class="n">add_args</span><span class="o">=</span><span class="n">anaconda_args</span><span class="p">)</span>
|
||||
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"populating output tree and building boot images"</span><span class="p">)</span>
|
||||
@ -582,6 +495,8 @@
|
||||
<span class="n">f</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">abspath</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">dirname</span><span class="p">(</span><span class="n">logfile</span><span class="p">))</span><span class="o">+</span><span class="s2">"/program.log"</span>
|
||||
<span class="n">fh</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">FileHandler</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="n">f</span><span class="p">,</span> <span class="n">mode</span><span class="o">=</span><span class="s2">"w"</span><span class="p">)</span>
|
||||
<span class="n">fh</span><span class="o">.</span><span class="n">setLevel</span><span class="p">(</span><span class="n">logging</span><span class="o">.</span><span class="n">DEBUG</span><span class="p">)</span>
|
||||
<span class="n">fmt</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">Formatter</span><span class="p">(</span><span class="s2">"</span><span class="si">%(asctime)s</span><span class="s2"> </span><span class="si">%(levelname)s</span><span class="s2">: </span><span class="si">%(message)s</span><span class="s2">"</span><span class="p">)</span>
|
||||
<span class="n">fh</span><span class="o">.</span><span class="n">setFormatter</span><span class="p">(</span><span class="n">fmt</span><span class="p">)</span>
|
||||
<span class="n">program_log</span><span class="o">.</span><span class="n">addHandler</span><span class="p">(</span><span class="n">fh</span><span class="p">)</span></div>
|
||||
|
||||
|
||||
@ -603,68 +518,43 @@
|
||||
<span class="k">except</span> <span class="ne">IndexError</span><span class="p">:</span>
|
||||
<span class="k">pass</span>
|
||||
<span class="k">return</span> <span class="n">templatedir</span></div>
|
||||
</pre></div>
|
||||
|
||||
</div>
|
||||
<div class="articleComments">
|
||||
<div class="viewcode-block" id="log_selinux_state"><a class="viewcode-back" href="../pylorax.html#pylorax.log_selinux_state">[docs]</a><span class="k">def</span> <span class="nf">log_selinux_state</span><span class="p">():</span>
|
||||
<span class="sd">"""Log the current state of selinux"""</span>
|
||||
<span class="k">if</span> <span class="n">selinux</span><span class="o">.</span><span class="n">is_selinux_enabled</span><span class="p">():</span>
|
||||
<span class="k">if</span> <span class="n">selinux</span><span class="o">.</span><span class="n">security_getenforce</span><span class="p">():</span>
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"selinux is enabled and in Enforcing mode"</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"selinux is enabled and in Permissive mode"</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"selinux is Disabled"</span><span class="p">)</span></div>
|
||||
</pre></div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<footer>
|
||||
|
||||
|
||||
<hr/>
|
||||
|
||||
<div role="contentinfo">
|
||||
<p>
|
||||
© Copyright 2015, Red Hat, Inc..
|
||||
|
||||
</p>
|
||||
<p>© Copyright 2018, Red Hat, Inc..</p>
|
||||
</div>
|
||||
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||||
|
||||
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
|
||||
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
|
||||
provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||||
|
||||
|
||||
</footer>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
var DOCUMENTATION_OPTIONS = {
|
||||
URL_ROOT:'../',
|
||||
VERSION:'28.2',
|
||||
COLLAPSE_INDEX:false,
|
||||
FILE_SUFFIX:'.html',
|
||||
HAS_SOURCE: true,
|
||||
SOURCELINK_SUFFIX: '.txt'
|
||||
};
|
||||
</script>
|
||||
<script type="text/javascript" src="../_static/jquery.js"></script>
|
||||
<script type="text/javascript" src="../_static/underscore.js"></script>
|
||||
<script type="text/javascript" src="../_static/doctools.js"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript" src="../_static/js/theme.js"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
<script>
|
||||
jQuery(function () {
|
||||
SphinxRtdTheme.StickyNav.enable();
|
||||
SphinxRtdTheme.Navigation.enable(true);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,57 +1,50 @@
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
|
||||
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
|
||||
<html class="writer-html5" lang="en" >
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>pylorax.base — Lorax 28.2 documentation</title>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<meta charset="utf-8" />
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
|
||||
<title>pylorax.base — Lorax 35.1 documentation</title>
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
|
||||
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="index" title="Index"
|
||||
href="../../genindex.html"/>
|
||||
<link rel="search" title="Search" href="../../search.html"/>
|
||||
<link rel="top" title="Lorax 28.2 documentation" href="../../index.html"/>
|
||||
<link rel="up" title="pylorax" href="../pylorax.html"/>
|
||||
|
||||
|
||||
<script src="../../_static/js/modernizr.min.js"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
|
||||
<script src="../../_static/jquery.js"></script>
|
||||
<script src="../../_static/underscore.js"></script>
|
||||
<script src="../../_static/doctools.js"></script>
|
||||
|
||||
<script type="text/javascript" src="../../_static/js/theme.js"></script>
|
||||
|
||||
|
||||
<link rel="index" title="Index" href="../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../search.html" />
|
||||
</head>
|
||||
|
||||
<body class="wy-body-for-nav" role="document">
|
||||
<body class="wy-body-for-nav">
|
||||
|
||||
|
||||
<div class="wy-grid-for-nav">
|
||||
|
||||
|
||||
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
|
||||
<div class="wy-side-scroll">
|
||||
<div class="wy-side-nav-search">
|
||||
<div class="wy-side-nav-search" >
|
||||
|
||||
|
||||
|
||||
@ -65,7 +58,7 @@
|
||||
|
||||
|
||||
<div class="version">
|
||||
28.2
|
||||
35.1
|
||||
</div>
|
||||
|
||||
|
||||
@ -82,6 +75,7 @@
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
|
||||
|
||||
|
||||
@ -94,20 +88,22 @@
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../intro.html#before-lorax">Before Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../lorax.html">Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../livemedia-creator.html">livemedia-creator</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../mkksiso.html">mkksiso</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../product-images.html">Product and Updates Images</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../modules.html">pylorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../modules.html">src</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
|
||||
|
||||
|
||||
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
|
||||
<nav class="wy-nav-top" aria-label="top navigation">
|
||||
|
||||
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
||||
<a href="../../index.html">Lorax</a>
|
||||
@ -115,8 +111,8 @@
|
||||
</nav>
|
||||
|
||||
|
||||
|
||||
<div class="wy-nav-content">
|
||||
|
||||
<div class="rst-content">
|
||||
|
||||
|
||||
@ -134,11 +130,14 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div role="navigation" aria-label="breadcrumbs navigation">
|
||||
|
||||
<ul class="wy-breadcrumbs">
|
||||
|
||||
<li><a href="../../index.html">Docs</a> »</li>
|
||||
<li><a href="../../index.html" class="icon icon-home"></a> »</li>
|
||||
|
||||
<li><a href="../index.html">Module code</a> »</li>
|
||||
|
||||
@ -149,8 +148,6 @@
|
||||
|
||||
<li class="wy-breadcrumbs-aside">
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
@ -183,7 +180,7 @@
|
||||
<span class="c1"># Red Hat Author(s): Martin Gracik <mgracik@redhat.com></span>
|
||||
<span class="c1">#</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">abc</span> <span class="k">import</span> <span class="n">ABCMeta</span><span class="p">,</span> <span class="n">abstractmethod</span>
|
||||
<span class="kn">from</span> <span class="nn">abc</span> <span class="kn">import</span> <span class="n">ABCMeta</span><span class="p">,</span> <span class="n">abstractmethod</span>
|
||||
<span class="kn">import</span> <span class="nn">sys</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">pylorax.output</span> <span class="k">as</span> <span class="nn">output</span>
|
||||
@ -191,7 +188,7 @@
|
||||
|
||||
<div class="viewcode-block" id="BaseLoraxClass"><a class="viewcode-back" href="../../pylorax.html#pylorax.base.BaseLoraxClass">[docs]</a><span class="k">class</span> <span class="nc">BaseLoraxClass</span><span class="p">(</span><span class="nb">object</span><span class="p">,</span> <span class="n">metaclass</span><span class="o">=</span><span class="n">ABCMeta</span><span class="p">):</span>
|
||||
<span class="nd">@abstractmethod</span>
|
||||
<span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">output</span> <span class="o">=</span> <span class="n">output</span><span class="o">.</span><span class="n">LoraxOutput</span><span class="p">()</span>
|
||||
|
||||
<div class="viewcode-block" id="BaseLoraxClass.pcritical"><a class="viewcode-back" href="../../pylorax.html#pylorax.base.BaseLoraxClass.pcritical">[docs]</a> <span class="k">def</span> <span class="nf">pcritical</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">msg</span><span class="p">,</span> <span class="n">fobj</span><span class="o">=</span><span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="p">):</span>
|
||||
@ -212,19 +209,19 @@
|
||||
|
||||
<div class="viewcode-block" id="DataHolder"><a class="viewcode-back" href="../../pylorax.html#pylorax.base.DataHolder">[docs]</a><span class="k">class</span> <span class="nc">DataHolder</span><span class="p">(</span><span class="nb">dict</span><span class="p">):</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="nb">dict</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">attr</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
|
||||
<span class="bp">self</span><span class="p">[</span><span class="n">attr</span><span class="p">]</span> <span class="o">=</span> <span class="n">value</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">__getattr__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">attr</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="fm">__getattr__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">attr</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="n">attr</span> <span class="ow">in</span> <span class="bp">self</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="p">[</span><span class="n">attr</span><span class="p">]</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="ne">AttributeError</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">__setattr__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">attr</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="fm">__setattr__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">attr</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="p">[</span><span class="n">attr</span><span class="p">]</span> <span class="o">=</span> <span class="n">value</span>
|
||||
|
||||
<div class="viewcode-block" id="DataHolder.copy"><a class="viewcode-back" href="../../pylorax.html#pylorax.base.DataHolder.copy">[docs]</a> <span class="k">def</span> <span class="nf">copy</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
@ -232,25 +229,28 @@
|
||||
</pre></div>
|
||||
|
||||
</div>
|
||||
<div class="articleComments">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<footer>
|
||||
|
||||
|
||||
<hr/>
|
||||
|
||||
<div role="contentinfo">
|
||||
<p>
|
||||
© Copyright 2015, Red Hat, Inc..
|
||||
© Copyright 2018, Red Hat, Inc..
|
||||
|
||||
</p>
|
||||
</div>
|
||||
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||||
|
||||
|
||||
|
||||
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
|
||||
|
||||
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
|
||||
|
||||
provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||||
|
||||
</footer>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -259,38 +259,16 @@
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
var DOCUMENTATION_OPTIONS = {
|
||||
URL_ROOT:'../../',
|
||||
VERSION:'28.2',
|
||||
COLLAPSE_INDEX:false,
|
||||
FILE_SUFFIX:'.html',
|
||||
HAS_SOURCE: true,
|
||||
SOURCELINK_SUFFIX: '.txt'
|
||||
};
|
||||
</script>
|
||||
<script type="text/javascript" src="../../_static/jquery.js"></script>
|
||||
<script type="text/javascript" src="../../_static/underscore.js"></script>
|
||||
<script type="text/javascript" src="../../_static/doctools.js"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript" src="../../_static/js/theme.js"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
jQuery(function () {
|
||||
SphinxRtdTheme.StickyNav.enable();
|
||||
SphinxRtdTheme.Navigation.enable(true);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,76 +1,31 @@
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
|
||||
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
|
||||
<html class="writer-html5" lang="en" >
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>pylorax.buildstamp — Lorax 28.2 documentation</title>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pylorax.buildstamp — Lorax 36.0 documentation</title>
|
||||
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
|
||||
<link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="index" title="Index"
|
||||
href="../../genindex.html"/>
|
||||
<link rel="search" title="Search" href="../../search.html"/>
|
||||
<link rel="top" title="Lorax 28.2 documentation" href="../../index.html"/>
|
||||
<link rel="up" title="pylorax" href="../pylorax.html"/>
|
||||
|
||||
|
||||
<script src="../../_static/js/modernizr.min.js"></script>
|
||||
|
||||
<script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
|
||||
<script src="../../_static/jquery.js"></script>
|
||||
<script src="../../_static/underscore.js"></script>
|
||||
<script src="../../_static/doctools.js"></script>
|
||||
<script src="../../_static/js/theme.js"></script>
|
||||
<link rel="index" title="Index" href="../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../search.html" />
|
||||
</head>
|
||||
|
||||
<body class="wy-body-for-nav" role="document">
|
||||
|
||||
|
||||
<body class="wy-body-for-nav">
|
||||
<div class="wy-grid-for-nav">
|
||||
|
||||
|
||||
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
|
||||
<div class="wy-side-scroll">
|
||||
<div class="wy-side-nav-search">
|
||||
|
||||
|
||||
|
||||
<div class="wy-side-nav-search" >
|
||||
<a href="../../index.html" class="icon icon-home"> Lorax
|
||||
|
||||
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="version">
|
||||
28.2
|
||||
36.0
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div role="search">
|
||||
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
|
||||
<input type="text" name="q" placeholder="Search docs" />
|
||||
@ -78,84 +33,37 @@
|
||||
<input type="hidden" name="area" value="default" />
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../intro.html">Introduction to Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../intro.html#before-lorax">Before Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../lorax.html">Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../livemedia-creator.html">livemedia-creator</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../mkksiso.html">mkksiso</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../product-images.html">Product and Updates Images</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../modules.html">pylorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../modules.html">src</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
|
||||
|
||||
|
||||
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
|
||||
|
||||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
|
||||
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
||||
<a href="../../index.html">Lorax</a>
|
||||
|
||||
</nav>
|
||||
|
||||
|
||||
|
||||
<div class="wy-nav-content">
|
||||
<div class="rst-content">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div role="navigation" aria-label="breadcrumbs navigation">
|
||||
|
||||
<div role="navigation" aria-label="Page navigation">
|
||||
<ul class="wy-breadcrumbs">
|
||||
|
||||
<li><a href="../../index.html">Docs</a> »</li>
|
||||
|
||||
<li><a href="../../index.html" class="icon icon-home"></a> »</li>
|
||||
<li><a href="../index.html">Module code</a> »</li>
|
||||
|
||||
<li><a href="../pylorax.html">pylorax</a> »</li>
|
||||
|
||||
<li>pylorax.buildstamp</li>
|
||||
|
||||
|
||||
<li class="wy-breadcrumbs-aside">
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
<hr/>
|
||||
</div>
|
||||
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
|
||||
@ -187,16 +95,22 @@
|
||||
<span class="n">logger</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="s2">"pylorax.buildstamp"</span><span class="p">)</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">datetime</span>
|
||||
<span class="kn">import</span> <span class="nn">os</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="BuildStamp"><a class="viewcode-back" href="../../pylorax.html#pylorax.buildstamp.BuildStamp">[docs]</a><span class="k">class</span> <span class="nc">BuildStamp</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">product</span><span class="p">,</span> <span class="n">version</span><span class="p">,</span> <span class="n">bugurl</span><span class="p">,</span> <span class="n">isfinal</span><span class="p">,</span> <span class="n">buildarch</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">product</span><span class="p">,</span> <span class="n">version</span><span class="p">,</span> <span class="n">bugurl</span><span class="p">,</span> <span class="n">isfinal</span><span class="p">,</span> <span class="n">buildarch</span><span class="p">,</span> <span class="n">variant</span><span class="o">=</span><span class="s2">""</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">product</span> <span class="o">=</span> <span class="n">product</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">version</span> <span class="o">=</span> <span class="n">version</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">bugurl</span> <span class="o">=</span> <span class="n">bugurl</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">isfinal</span> <span class="o">=</span> <span class="n">isfinal</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">variant</span> <span class="o">=</span> <span class="n">variant</span>
|
||||
|
||||
<span class="k">if</span> <span class="s1">'SOURCE_DATE_EPOCH'</span> <span class="ow">in</span> <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">:</span>
|
||||
<span class="n">now</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">datetime</span><span class="o">.</span><span class="n">utcfromtimestamp</span><span class="p">(</span>
|
||||
<span class="nb">int</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">[</span><span class="s1">'SOURCE_DATE_EPOCH'</span><span class="p">]))</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">now</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">datetime</span><span class="o">.</span><span class="n">now</span><span class="p">()</span>
|
||||
<span class="n">now</span> <span class="o">=</span> <span class="n">now</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s2">"%Y%m</span><span class="si">%d</span><span class="s2">%H%M"</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">uuid</span> <span class="o">=</span> <span class="s2">"</span><span class="si">{0}</span><span class="s2">.</span><span class="si">{1}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">now</span><span class="p">,</span> <span class="n">buildarch</span><span class="p">)</span>
|
||||
@ -218,70 +132,37 @@
|
||||
<span class="n">fobj</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s2">"BugURL=</span><span class="si">{0.bugurl}</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="p">))</span>
|
||||
<span class="n">fobj</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s2">"IsFinal=</span><span class="si">{0.isfinal}</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="p">))</span>
|
||||
<span class="n">fobj</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s2">"UUID=</span><span class="si">{0.uuid}</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="p">))</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">variant</span><span class="p">:</span>
|
||||
<span class="n">fobj</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s2">"Variant=</span><span class="si">{0.variant}</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="p">))</span>
|
||||
<span class="n">fobj</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s2">"[Compose]</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span>
|
||||
<span class="n">fobj</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s2">"Lorax=</span><span class="si">{0}</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">vernum</span><span class="p">))</span></div></div>
|
||||
</pre></div>
|
||||
|
||||
</div>
|
||||
<div class="articleComments">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<footer>
|
||||
|
||||
|
||||
<hr/>
|
||||
|
||||
<div role="contentinfo">
|
||||
<p>
|
||||
© Copyright 2015, Red Hat, Inc..
|
||||
|
||||
</p>
|
||||
<p>© Copyright 2018, Red Hat, Inc..</p>
|
||||
</div>
|
||||
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||||
|
||||
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
|
||||
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
|
||||
provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||||
|
||||
|
||||
</footer>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
var DOCUMENTATION_OPTIONS = {
|
||||
URL_ROOT:'../../',
|
||||
VERSION:'28.2',
|
||||
COLLAPSE_INDEX:false,
|
||||
FILE_SUFFIX:'.html',
|
||||
HAS_SOURCE: true,
|
||||
SOURCELINK_SUFFIX: '.txt'
|
||||
};
|
||||
</script>
|
||||
<script type="text/javascript" src="../../_static/jquery.js"></script>
|
||||
<script type="text/javascript" src="../../_static/underscore.js"></script>
|
||||
<script type="text/javascript" src="../../_static/doctools.js"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript" src="../../_static/js/theme.js"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
<script>
|
||||
jQuery(function () {
|
||||
SphinxRtdTheme.StickyNav.enable();
|
||||
SphinxRtdTheme.Navigation.enable(true);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,76 +1,31 @@
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
|
||||
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
|
||||
<html class="writer-html5" lang="en" >
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>pylorax.cmdline — Lorax 28.2 documentation</title>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pylorax.cmdline — Lorax 36.4 documentation</title>
|
||||
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
|
||||
<link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="index" title="Index"
|
||||
href="../../genindex.html"/>
|
||||
<link rel="search" title="Search" href="../../search.html"/>
|
||||
<link rel="top" title="Lorax 28.2 documentation" href="../../index.html"/>
|
||||
<link rel="up" title="pylorax" href="../pylorax.html"/>
|
||||
|
||||
|
||||
<script src="../../_static/js/modernizr.min.js"></script>
|
||||
|
||||
<script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
|
||||
<script src="../../_static/jquery.js"></script>
|
||||
<script src="../../_static/underscore.js"></script>
|
||||
<script src="../../_static/doctools.js"></script>
|
||||
<script src="../../_static/js/theme.js"></script>
|
||||
<link rel="index" title="Index" href="../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../search.html" />
|
||||
</head>
|
||||
|
||||
<body class="wy-body-for-nav" role="document">
|
||||
|
||||
|
||||
<body class="wy-body-for-nav">
|
||||
<div class="wy-grid-for-nav">
|
||||
|
||||
|
||||
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
|
||||
<div class="wy-side-scroll">
|
||||
<div class="wy-side-nav-search">
|
||||
|
||||
|
||||
|
||||
<div class="wy-side-nav-search" >
|
||||
<a href="../../index.html" class="icon icon-home"> Lorax
|
||||
|
||||
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="version">
|
||||
28.2
|
||||
36.4
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div role="search">
|
||||
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
|
||||
<input type="text" name="q" placeholder="Search docs" />
|
||||
@ -78,84 +33,37 @@
|
||||
<input type="hidden" name="area" value="default" />
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../intro.html">Introduction to Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../intro.html#before-lorax">Before Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../lorax.html">Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../livemedia-creator.html">livemedia-creator</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../mkksiso.html">mkksiso</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../product-images.html">Product and Updates Images</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../modules.html">pylorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../modules.html">src</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
|
||||
|
||||
|
||||
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
|
||||
|
||||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
|
||||
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
||||
<a href="../../index.html">Lorax</a>
|
||||
|
||||
</nav>
|
||||
|
||||
|
||||
|
||||
<div class="wy-nav-content">
|
||||
<div class="rst-content">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div role="navigation" aria-label="breadcrumbs navigation">
|
||||
|
||||
<div role="navigation" aria-label="Page navigation">
|
||||
<ul class="wy-breadcrumbs">
|
||||
|
||||
<li><a href="../../index.html">Docs</a> »</li>
|
||||
|
||||
<li><a href="../../index.html" class="icon icon-home"></a> »</li>
|
||||
<li><a href="../index.html">Module code</a> »</li>
|
||||
|
||||
<li><a href="../pylorax.html">pylorax</a> »</li>
|
||||
|
||||
<li>pylorax.cmdline</li>
|
||||
|
||||
|
||||
<li class="wy-breadcrumbs-aside">
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
<hr/>
|
||||
</div>
|
||||
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
|
||||
@ -186,11 +94,11 @@
|
||||
<span class="kn">import</span> <span class="nn">sys</span>
|
||||
<span class="kn">import</span> <span class="nn">argparse</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">pylorax</span> <span class="k">import</span> <span class="n">vernum</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax</span> <span class="kn">import</span> <span class="n">DEFAULT_RELEASEVER</span><span class="p">,</span> <span class="n">vernum</span>
|
||||
|
||||
<span class="n">version</span> <span class="o">=</span> <span class="s2">"</span><span class="si">{0}</span><span class="s2">-</span><span class="si">{1}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">basename</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">[</span><span class="mi">0</span><span class="p">]),</span> <span class="n">vernum</span><span class="p">)</span>
|
||||
|
||||
<div class="viewcode-block" id="lorax_parser"><a class="viewcode-back" href="../../pylorax.html#pylorax.cmdline.lorax_parser">[docs]</a><span class="k">def</span> <span class="nf">lorax_parser</span><span class="p">():</span>
|
||||
<div class="viewcode-block" id="lorax_parser"><a class="viewcode-back" href="../../pylorax.html#pylorax.cmdline.lorax_parser">[docs]</a><span class="k">def</span> <span class="nf">lorax_parser</span><span class="p">(</span><span class="n">dracut_default</span><span class="o">=</span><span class="s2">""</span><span class="p">):</span>
|
||||
<span class="sd">""" Return the ArgumentParser for lorax"""</span>
|
||||
|
||||
<span class="n">parser</span> <span class="o">=</span> <span class="n">argparse</span><span class="o">.</span><span class="n">ArgumentParser</span><span class="p">(</span><span class="n">description</span><span class="o">=</span><span class="s2">"Create the Anaconda boot.iso"</span><span class="p">)</span>
|
||||
@ -210,7 +118,7 @@
|
||||
<span class="n">optional</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">"-m"</span><span class="p">,</span> <span class="s2">"--mirrorlist"</span><span class="p">,</span>
|
||||
<span class="n">help</span><span class="o">=</span><span class="s2">"mirrorlist repository (may be listed multiple times)"</span><span class="p">,</span>
|
||||
<span class="n">metavar</span><span class="o">=</span><span class="s2">"REPOSITORY"</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s2">"append"</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="p">[])</span>
|
||||
<span class="n">optional</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">"-t"</span><span class="p">,</span> <span class="s2">"--variant"</span><span class="p">,</span>
|
||||
<span class="n">optional</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">"-t"</span><span class="p">,</span> <span class="s2">"--variant"</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="s2">""</span><span class="p">,</span>
|
||||
<span class="n">help</span><span class="o">=</span><span class="s2">"variant name"</span><span class="p">,</span> <span class="n">metavar</span><span class="o">=</span><span class="s2">"VARIANT"</span><span class="p">)</span>
|
||||
<span class="n">optional</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">"-b"</span><span class="p">,</span> <span class="s2">"--bugurl"</span><span class="p">,</span>
|
||||
<span class="n">help</span><span class="o">=</span><span class="s2">"bug reporting URL for the product"</span><span class="p">,</span> <span class="n">metavar</span><span class="o">=</span><span class="s2">"URL"</span><span class="p">,</span>
|
||||
@ -239,12 +147,12 @@
|
||||
<span class="n">action</span><span class="o">=</span><span class="s2">"store_false"</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">dest</span><span class="o">=</span><span class="s2">"doupgrade"</span><span class="p">)</span>
|
||||
<span class="n">optional</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">"--logfile"</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="s2">"./lorax.log"</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">abspath</span><span class="p">,</span>
|
||||
<span class="n">help</span><span class="o">=</span><span class="s2">"Path to logfile"</span><span class="p">)</span>
|
||||
<span class="n">optional</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">"--tmp"</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="s2">"/var/tmp"</span><span class="p">,</span>
|
||||
<span class="n">optional</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">"--tmp"</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="s2">"/var/tmp/lorax"</span><span class="p">,</span>
|
||||
<span class="n">help</span><span class="o">=</span><span class="s2">"Top level temporary directory"</span> <span class="p">)</span>
|
||||
<span class="n">optional</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">"--cachedir"</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">abspath</span><span class="p">,</span>
|
||||
<span class="n">help</span><span class="o">=</span><span class="s2">"DNF cache directory. Default is a temporary dir."</span><span class="p">)</span>
|
||||
<span class="n">optional</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">"--workdir"</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">abspath</span><span class="p">,</span>
|
||||
<span class="n">help</span><span class="o">=</span><span class="s2">"Work directory, overrides --tmp. Default is a temporary dir under /var/tmp"</span><span class="p">)</span>
|
||||
<span class="n">help</span><span class="o">=</span><span class="s2">"Work directory, overrides --tmp. Default is a temporary dir under /var/tmp/lorax"</span><span class="p">)</span>
|
||||
<span class="n">optional</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">"--force"</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s2">"store_true"</span><span class="p">,</span>
|
||||
<span class="n">help</span><span class="o">=</span><span class="s2">"Run even when the destination directory exists"</span><span class="p">)</span>
|
||||
<span class="n">optional</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">"--add-template"</span><span class="p">,</span> <span class="n">dest</span><span class="o">=</span><span class="s2">"add_templates"</span><span class="p">,</span>
|
||||
@ -271,6 +179,23 @@
|
||||
<span class="n">help</span><span class="o">=</span><span class="s2">"Size of root filesystem in GiB. Defaults to 2."</span><span class="p">)</span>
|
||||
<span class="n">optional</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">"--noverifyssl"</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s2">"store_true"</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
|
||||
<span class="n">help</span><span class="o">=</span><span class="s2">"Do not verify SSL certificates"</span><span class="p">)</span>
|
||||
<span class="n">optional</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">"--dnfplugin"</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s2">"append"</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="p">[],</span> <span class="n">dest</span><span class="o">=</span><span class="s2">"dnfplugins"</span><span class="p">,</span>
|
||||
<span class="n">help</span><span class="o">=</span><span class="s2">"Enable a DNF plugin by name/glob, or * to enable all of them."</span><span class="p">)</span>
|
||||
<span class="n">optional</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">"--squashfs-only"</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s2">"store_true"</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
|
||||
<span class="n">help</span><span class="o">=</span><span class="s2">"Use a plain squashfs filesystem for the runtime."</span><span class="p">)</span>
|
||||
<span class="n">optional</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">"--skip-branding"</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s2">"store_true"</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
|
||||
<span class="n">help</span><span class="o">=</span><span class="s2">"Disable automatic branding package selection. Use --installpkgs to add custom branding."</span><span class="p">)</span>
|
||||
|
||||
<span class="c1"># dracut arguments</span>
|
||||
<span class="n">dracut_group</span> <span class="o">=</span> <span class="n">parser</span><span class="o">.</span><span class="n">add_argument_group</span><span class="p">(</span><span class="s2">"dracut arguments: (default: </span><span class="si">%s</span><span class="s2">)"</span> <span class="o">%</span> <span class="n">dracut_default</span><span class="p">)</span>
|
||||
<span class="n">dracut_group</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">"--dracut-conf"</span><span class="p">,</span>
|
||||
<span class="n">help</span><span class="o">=</span><span class="s2">"Path to a dracut.conf file to use instead of the "</span>
|
||||
<span class="s2">"default arguments. See the dracut.conf(5) manpage."</span><span class="p">)</span>
|
||||
<span class="n">dracut_group</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">"--dracut-arg"</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s2">"append"</span><span class="p">,</span> <span class="n">dest</span><span class="o">=</span><span class="s2">"dracut_args"</span><span class="p">,</span>
|
||||
<span class="n">help</span><span class="o">=</span><span class="s2">"Argument to pass to dracut when "</span>
|
||||
<span class="s2">"rebuilding the initramfs. Pass this "</span>
|
||||
<span class="s2">"once for each argument. NOTE: this "</span>
|
||||
<span class="s2">"overrides the defaults."</span><span class="p">)</span>
|
||||
|
||||
<span class="c1"># add the show version option</span>
|
||||
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">"-V"</span><span class="p">,</span> <span class="n">help</span><span class="o">=</span><span class="s2">"show program's version number and exit"</span><span class="p">,</span>
|
||||
@ -300,6 +225,8 @@
|
||||
<span class="n">help</span><span class="o">=</span><span class="s2">"Build an ami image"</span><span class="p">)</span>
|
||||
<span class="n">action</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">"--make-tar"</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s2">"store_true"</span><span class="p">,</span>
|
||||
<span class="n">help</span><span class="o">=</span><span class="s2">"Build a tar of the root filesystem"</span><span class="p">)</span>
|
||||
<span class="n">action</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">"--make-tar-disk"</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s2">"store_true"</span><span class="p">,</span>
|
||||
<span class="n">help</span><span class="o">=</span><span class="s2">"Build a tar of a partitioned disk image"</span><span class="p">)</span>
|
||||
<span class="n">action</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">"--make-pxe-live"</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s2">"store_true"</span><span class="p">,</span>
|
||||
<span class="n">help</span><span class="o">=</span><span class="s2">"Build a live pxe boot squashfs image"</span><span class="p">)</span>
|
||||
<span class="n">action</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">"--make-ostree-live"</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s2">"store_true"</span><span class="p">,</span>
|
||||
@ -355,6 +282,9 @@
|
||||
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">"--nomacboot"</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s2">"store_false"</span><span class="p">,</span>
|
||||
<span class="n">dest</span><span class="o">=</span><span class="s2">"domacboot"</span><span class="p">)</span>
|
||||
|
||||
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">"--extra-boot-args"</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="s2">""</span><span class="p">,</span> <span class="n">dest</span><span class="o">=</span><span class="s2">"extra_boot_args"</span><span class="p">,</span>
|
||||
<span class="n">help</span><span class="o">=</span><span class="s2">"Extra arguments to add to the bootloader kernel cmdline in the templates"</span><span class="p">)</span>
|
||||
|
||||
<span class="n">image_group</span> <span class="o">=</span> <span class="n">parser</span><span class="o">.</span><span class="n">add_argument_group</span><span class="p">(</span><span class="s2">"disk/fs image arguments"</span><span class="p">)</span>
|
||||
<span class="n">image_group</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">"--disk-image"</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">abspath</span><span class="p">,</span>
|
||||
<span class="n">help</span><span class="o">=</span><span class="s2">"Path to existing disk image to use for creating final image."</span><span class="p">)</span>
|
||||
@ -364,8 +294,12 @@
|
||||
<span class="n">help</span><span class="o">=</span><span class="s2">"Path to existing filesystem image to use for creating final image."</span><span class="p">)</span>
|
||||
<span class="n">image_group</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">"--image-name"</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
|
||||
<span class="n">help</span><span class="o">=</span><span class="s2">"Name of output file to create. Used for tar, fs and disk image. Default is a random name."</span><span class="p">)</span>
|
||||
<span class="n">image_group</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">"--tar-disk-name"</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
|
||||
<span class="n">help</span><span class="o">=</span><span class="s2">"Name of the archive member for make-tar-disk."</span><span class="p">)</span>
|
||||
<span class="n">image_group</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">"--fs-label"</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="s2">"Anaconda"</span><span class="p">,</span>
|
||||
<span class="n">help</span><span class="o">=</span><span class="s2">"Label to set on fsimage, default is 'Anaconda'"</span><span class="p">)</span>
|
||||
<span class="n">image_group</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">"--image-size-align"</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="nb">int</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span>
|
||||
<span class="n">help</span><span class="o">=</span><span class="s2">"Create a disk image with a size that is a multiple of this value in MiB."</span><span class="p">)</span>
|
||||
<span class="n">image_group</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">"--image-type"</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
|
||||
<span class="n">help</span><span class="o">=</span><span class="s2">"Create an image with qemu-img. See qemu-img --help for supported formats."</span><span class="p">)</span>
|
||||
<span class="n">image_group</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">"--qemu-arg"</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s2">"append"</span><span class="p">,</span> <span class="n">dest</span><span class="o">=</span><span class="s2">"qemu_args"</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="p">[],</span>
|
||||
@ -389,7 +323,7 @@
|
||||
|
||||
<span class="c1"># Group of arguments to pass to qemu</span>
|
||||
<span class="n">virt_group</span> <span class="o">=</span> <span class="n">parser</span><span class="o">.</span><span class="n">add_argument_group</span><span class="p">(</span><span class="s2">"qemu arguments"</span><span class="p">)</span>
|
||||
<span class="n">virt_group</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">"--ram"</span><span class="p">,</span> <span class="n">metavar</span><span class="o">=</span><span class="s2">"MEMORY"</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="nb">int</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="mi">1024</span><span class="p">,</span>
|
||||
<span class="n">virt_group</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">"--ram"</span><span class="p">,</span> <span class="n">metavar</span><span class="o">=</span><span class="s2">"MEMORY"</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="nb">int</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="mi">2048</span><span class="p">,</span>
|
||||
<span class="n">help</span><span class="o">=</span><span class="s2">"Memory to allocate for installer in megabytes."</span><span class="p">)</span>
|
||||
<span class="n">virt_group</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">"--vcpus"</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="nb">int</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
|
||||
<span class="n">help</span><span class="o">=</span><span class="s2">"Passed to qemu -smp command"</span><span class="p">)</span>
|
||||
@ -407,14 +341,19 @@
|
||||
<span class="n">help</span><span class="o">=</span><span class="s2">"Use OVMF firmware to boot the VM in UEFI mode"</span><span class="p">)</span>
|
||||
<span class="n">virt_group</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">"--no-kvm"</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s2">"store_true"</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
|
||||
<span class="n">help</span><span class="o">=</span><span class="s2">"Skip using kvm with qemu even if it is available."</span><span class="p">)</span>
|
||||
<span class="n">virt_group</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">"--with-rng"</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="s2">"/dev/random"</span><span class="p">,</span>
|
||||
<span class="n">help</span><span class="o">=</span><span class="s2">"RNG device for QEMU (none for no RNG)"</span><span class="p">)</span>
|
||||
|
||||
<span class="c1"># dracut arguments</span>
|
||||
<span class="n">dracut_group</span> <span class="o">=</span> <span class="n">parser</span><span class="o">.</span><span class="n">add_argument_group</span><span class="p">(</span><span class="s2">"dracut arguments"</span><span class="p">)</span>
|
||||
<span class="n">dracut_group</span> <span class="o">=</span> <span class="n">parser</span><span class="o">.</span><span class="n">add_argument_group</span><span class="p">(</span><span class="s2">"dracut arguments: (default: </span><span class="si">%s</span><span class="s2">)"</span> <span class="o">%</span> <span class="n">dracut_default</span><span class="p">)</span>
|
||||
<span class="n">dracut_group</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">"--dracut-conf"</span><span class="p">,</span>
|
||||
<span class="n">help</span><span class="o">=</span><span class="s2">"Path to a dracut.conf file to use instead of the "</span>
|
||||
<span class="s2">"default arguments. See the dracut.conf(5) manpage."</span><span class="p">)</span>
|
||||
<span class="n">dracut_group</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">"--dracut-arg"</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s2">"append"</span><span class="p">,</span> <span class="n">dest</span><span class="o">=</span><span class="s2">"dracut_args"</span><span class="p">,</span>
|
||||
<span class="n">help</span><span class="o">=</span><span class="s2">"Argument to pass to dracut when "</span>
|
||||
<span class="s2">"rebuilding the initramfs. Pass this "</span>
|
||||
<span class="s2">"once for each argument. NOTE: this "</span>
|
||||
<span class="s2">"overrides the default. (default: </span><span class="si">%s</span><span class="s2">)"</span> <span class="o">%</span> <span class="n">dracut_default</span><span class="p">)</span>
|
||||
<span class="s2">"overrides the defaults."</span><span class="p">)</span>
|
||||
|
||||
<span class="c1"># pxe to live arguments</span>
|
||||
<span class="n">pxelive_group</span> <span class="o">=</span> <span class="n">parser</span><span class="o">.</span><span class="n">add_argument_group</span><span class="p">(</span><span class="s2">"pxe to live arguments"</span><span class="p">)</span>
|
||||
@ -437,15 +376,13 @@
|
||||
<span class="n">vagrant_group</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">"--vagrantfile"</span><span class="p">,</span>
|
||||
<span class="n">help</span><span class="o">=</span><span class="s2">"optional vagrantfile"</span><span class="p">)</span>
|
||||
|
||||
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">"--title"</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="s2">"Linux Live Media"</span><span class="p">,</span>
|
||||
<span class="n">help</span><span class="o">=</span><span class="s2">"Substituted for @TITLE@ in bootloader config files"</span><span class="p">)</span>
|
||||
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">"--project"</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="s2">"Linux"</span><span class="p">,</span>
|
||||
<span class="n">help</span><span class="o">=</span><span class="s2">"substituted for @PROJECT@ in bootloader config files"</span><span class="p">)</span>
|
||||
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">"--releasever"</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="s2">"25"</span><span class="p">,</span>
|
||||
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">"--releasever"</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="n">DEFAULT_RELEASEVER</span><span class="p">,</span>
|
||||
<span class="n">help</span><span class="o">=</span><span class="s2">"substituted for @VERSION@ in bootloader config files"</span><span class="p">)</span>
|
||||
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">"--volid"</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">help</span><span class="o">=</span><span class="s2">"volume id"</span><span class="p">)</span>
|
||||
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">"--squashfs_args"</span><span class="p">,</span>
|
||||
<span class="n">help</span><span class="o">=</span><span class="s2">"additional squashfs args"</span><span class="p">)</span>
|
||||
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">"--squashfs-only"</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s2">"store_true"</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
|
||||
<span class="n">help</span><span class="o">=</span><span class="s2">"Use a plain squashfs filesystem for the runtime."</span><span class="p">)</span>
|
||||
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s2">"--timeout"</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="nb">int</span><span class="p">,</span>
|
||||
<span class="n">help</span><span class="o">=</span><span class="s2">"Cancel installer after X minutes"</span><span class="p">)</span>
|
||||
|
||||
@ -456,66 +393,31 @@
|
||||
<span class="k">return</span> <span class="n">parser</span></div>
|
||||
</pre></div>
|
||||
|
||||
</div>
|
||||
<div class="articleComments">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<footer>
|
||||
|
||||
|
||||
<hr/>
|
||||
|
||||
<div role="contentinfo">
|
||||
<p>
|
||||
© Copyright 2015, Red Hat, Inc..
|
||||
|
||||
</p>
|
||||
<p>© Copyright 2018, Red Hat, Inc..</p>
|
||||
</div>
|
||||
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||||
|
||||
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
|
||||
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
|
||||
provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||||
|
||||
|
||||
</footer>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
var DOCUMENTATION_OPTIONS = {
|
||||
URL_ROOT:'../../',
|
||||
VERSION:'28.2',
|
||||
COLLAPSE_INDEX:false,
|
||||
FILE_SUFFIX:'.html',
|
||||
HAS_SOURCE: true,
|
||||
SOURCELINK_SUFFIX: '.txt'
|
||||
};
|
||||
</script>
|
||||
<script type="text/javascript" src="../../_static/jquery.js"></script>
|
||||
<script type="text/javascript" src="../../_static/underscore.js"></script>
|
||||
<script type="text/javascript" src="../../_static/doctools.js"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript" src="../../_static/js/theme.js"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
<script>
|
||||
jQuery(function () {
|
||||
SphinxRtdTheme.StickyNav.enable();
|
||||
SphinxRtdTheme.Navigation.enable(true);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
851
docs/html/_modules/pylorax/creator.html
Normal file
@ -0,0 +1,851 @@
|
||||
<!DOCTYPE html>
|
||||
<html class="writer-html5" lang="en" >
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pylorax.creator — Lorax 36.4 documentation</title>
|
||||
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
|
||||
<link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
|
||||
|
||||
<script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
|
||||
<script src="../../_static/jquery.js"></script>
|
||||
<script src="../../_static/underscore.js"></script>
|
||||
<script src="../../_static/doctools.js"></script>
|
||||
<script src="../../_static/js/theme.js"></script>
|
||||
<link rel="index" title="Index" href="../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../search.html" />
|
||||
</head>
|
||||
|
||||
<body class="wy-body-for-nav">
|
||||
<div class="wy-grid-for-nav">
|
||||
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
|
||||
<div class="wy-side-scroll">
|
||||
<div class="wy-side-nav-search" >
|
||||
<a href="../../index.html" class="icon icon-home"> Lorax
|
||||
</a>
|
||||
<div class="version">
|
||||
36.4
|
||||
</div>
|
||||
<div role="search">
|
||||
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
|
||||
<input type="text" name="q" placeholder="Search docs" />
|
||||
<input type="hidden" name="check_keywords" value="yes" />
|
||||
<input type="hidden" name="area" value="default" />
|
||||
</form>
|
||||
</div>
|
||||
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../intro.html">Introduction to Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../intro.html#before-lorax">Before Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../lorax.html">Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../livemedia-creator.html">livemedia-creator</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../mkksiso.html">mkksiso</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../product-images.html">Product and Updates Images</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../modules.html">src</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
|
||||
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
||||
<a href="../../index.html">Lorax</a>
|
||||
</nav>
|
||||
|
||||
<div class="wy-nav-content">
|
||||
<div class="rst-content">
|
||||
<div role="navigation" aria-label="Page navigation">
|
||||
<ul class="wy-breadcrumbs">
|
||||
<li><a href="../../index.html" class="icon icon-home"></a> »</li>
|
||||
<li><a href="../index.html">Module code</a> »</li>
|
||||
<li><a href="../pylorax.html">pylorax</a> »</li>
|
||||
<li>pylorax.creator</li>
|
||||
<li class="wy-breadcrumbs-aside">
|
||||
</li>
|
||||
</ul>
|
||||
<hr/>
|
||||
</div>
|
||||
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
|
||||
<div itemprop="articleBody">
|
||||
|
||||
<h1>Source code for pylorax.creator</h1><div class="highlight"><pre>
|
||||
<span></span><span class="c1">#</span>
|
||||
<span class="c1"># Copyright (C) 2011-2018 Red Hat, Inc.</span>
|
||||
<span class="c1">#</span>
|
||||
<span class="c1"># This program is free software; you can redistribute it and/or modify</span>
|
||||
<span class="c1"># it under the terms of the GNU General Public License as published by</span>
|
||||
<span class="c1"># the Free Software Foundation; either version 2 of the License, or</span>
|
||||
<span class="c1"># (at your option) any later version.</span>
|
||||
<span class="c1">#</span>
|
||||
<span class="c1"># This program is distributed in the hope that it will be useful,</span>
|
||||
<span class="c1"># but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
<span class="c1"># MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
|
||||
<span class="c1"># GNU General Public License for more details.</span>
|
||||
<span class="c1">#</span>
|
||||
<span class="c1"># You should have received a copy of the GNU General Public License</span>
|
||||
<span class="c1"># along with this program. If not, see <http://www.gnu.org/licenses/>.</span>
|
||||
<span class="c1">#</span>
|
||||
<span class="kn">import</span> <span class="nn">logging</span>
|
||||
<span class="n">log</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="s2">"pylorax"</span><span class="p">)</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">os</span>
|
||||
<span class="kn">import</span> <span class="nn">tempfile</span>
|
||||
<span class="kn">import</span> <span class="nn">subprocess</span>
|
||||
<span class="kn">import</span> <span class="nn">shutil</span>
|
||||
<span class="kn">import</span> <span class="nn">hashlib</span>
|
||||
<span class="kn">import</span> <span class="nn">glob</span>
|
||||
|
||||
<span class="c1"># Use Mako templates for appliance builder descriptions</span>
|
||||
<span class="kn">from</span> <span class="nn">mako.template</span> <span class="kn">import</span> <span class="n">Template</span>
|
||||
<span class="kn">from</span> <span class="nn">mako.exceptions</span> <span class="kn">import</span> <span class="n">text_error_template</span>
|
||||
|
||||
<span class="c1"># Use pykickstart to calculate disk image size</span>
|
||||
<span class="kn">from</span> <span class="nn">pykickstart.parser</span> <span class="kn">import</span> <span class="n">KickstartParser</span>
|
||||
<span class="kn">from</span> <span class="nn">pykickstart.constants</span> <span class="kn">import</span> <span class="n">KS_SHUTDOWN</span>
|
||||
<span class="kn">from</span> <span class="nn">pykickstart.version</span> <span class="kn">import</span> <span class="n">makeVersion</span>
|
||||
|
||||
<span class="c1"># Use the Lorax treebuilder branch for iso creation</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax</span> <span class="kn">import</span> <span class="n">DEFAULT_RELEASEVER</span><span class="p">,</span> <span class="n">ArchData</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.base</span> <span class="kn">import</span> <span class="n">DataHolder</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.executils</span> <span class="kn">import</span> <span class="n">execWithRedirect</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.imgutils</span> <span class="kn">import</span> <span class="n">DracutChroot</span><span class="p">,</span> <span class="n">PartitionMount</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.imgutils</span> <span class="kn">import</span> <span class="n">mount</span><span class="p">,</span> <span class="n">umount</span><span class="p">,</span> <span class="n">Mount</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.imgutils</span> <span class="kn">import</span> <span class="n">mksquashfs</span><span class="p">,</span> <span class="n">mkrootfsimg</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.imgutils</span> <span class="kn">import</span> <span class="n">copytree</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.installer</span> <span class="kn">import</span> <span class="n">novirt_install</span><span class="p">,</span> <span class="n">virt_install</span><span class="p">,</span> <span class="n">InstallError</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.treebuilder</span> <span class="kn">import</span> <span class="n">TreeBuilder</span><span class="p">,</span> <span class="n">RuntimeBuilder</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.treebuilder</span> <span class="kn">import</span> <span class="n">findkernels</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.sysutils</span> <span class="kn">import</span> <span class="n">joinpaths</span><span class="p">,</span> <span class="n">remove</span>
|
||||
|
||||
|
||||
<span class="c1"># Default parameters for rebuilding initramfs, override with --dracut-arg or --dracut-conf</span>
|
||||
<span class="n">DRACUT_DEFAULT</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"--xz"</span><span class="p">,</span> <span class="s2">"--add"</span><span class="p">,</span> <span class="s2">"livenet dmsquash-live dmsquash-live-ntfs convertfs pollcdrom qemu qemu-net"</span><span class="p">,</span>
|
||||
<span class="s2">"--omit"</span><span class="p">,</span> <span class="s2">"plymouth"</span><span class="p">,</span> <span class="s2">"--no-hostonly"</span><span class="p">,</span> <span class="s2">"--debug"</span><span class="p">,</span> <span class="s2">"--no-early-microcode"</span><span class="p">]</span>
|
||||
|
||||
<span class="n">RUNTIME</span> <span class="o">=</span> <span class="s2">"images/install.img"</span>
|
||||
|
||||
<div class="viewcode-block" id="FakeDNF"><a class="viewcode-back" href="../../pylorax.html#pylorax.creator.FakeDNF">[docs]</a><span class="k">class</span> <span class="nc">FakeDNF</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> A minimal DNF object suitable for passing to RuntimeBuilder</span>
|
||||
|
||||
<span class="sd"> lmc uses RuntimeBuilder to run the arch specific iso creation</span>
|
||||
<span class="sd"> templates, so the the installroot config value is the important part of</span>
|
||||
<span class="sd"> this. Everything else should be a nop.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">conf</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">conf</span> <span class="o">=</span> <span class="n">conf</span>
|
||||
|
||||
<div class="viewcode-block" id="FakeDNF.reset"><a class="viewcode-back" href="../../pylorax.html#pylorax.creator.FakeDNF.reset">[docs]</a> <span class="k">def</span> <span class="nf">reset</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">pass</span></div></div>
|
||||
|
||||
<div class="viewcode-block" id="is_image_mounted"><a class="viewcode-back" href="../../pylorax.html#pylorax.creator.is_image_mounted">[docs]</a><span class="k">def</span> <span class="nf">is_image_mounted</span><span class="p">(</span><span class="n">disk_img</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Check to see if the disk_img is mounted</span>
|
||||
|
||||
<span class="sd"> :returns: True if disk_img is in /proc/mounts</span>
|
||||
<span class="sd"> :rtype: bool</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="s2">"/proc/mounts"</span><span class="p">)</span> <span class="k">as</span> <span class="n">mounts</span><span class="p">:</span>
|
||||
<span class="k">for</span> <span class="n">mnt</span> <span class="ow">in</span> <span class="n">mounts</span><span class="p">:</span>
|
||||
<span class="n">fields</span> <span class="o">=</span> <span class="n">mnt</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>
|
||||
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">fields</span><span class="p">)</span> <span class="o">></span> <span class="mi">2</span> <span class="ow">and</span> <span class="n">fields</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">==</span> <span class="n">disk_img</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="kc">True</span>
|
||||
<span class="k">return</span> <span class="kc">False</span></div>
|
||||
|
||||
<div class="viewcode-block" id="find_ostree_root"><a class="viewcode-back" href="../../pylorax.html#pylorax.creator.find_ostree_root">[docs]</a><span class="k">def</span> <span class="nf">find_ostree_root</span><span class="p">(</span><span class="n">phys_root</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Find root of ostree deployment</span>
|
||||
|
||||
<span class="sd"> :param str phys_root: Path to physical root</span>
|
||||
<span class="sd"> :returns: Relative path of ostree deployment root</span>
|
||||
<span class="sd"> :rtype: str</span>
|
||||
<span class="sd"> :raise Exception: More than one deployment roots were found</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">ostree_root</span> <span class="o">=</span> <span class="s2">""</span>
|
||||
<span class="n">ostree_sysroots</span> <span class="o">=</span> <span class="n">glob</span><span class="o">.</span><span class="n">glob</span><span class="p">(</span><span class="n">joinpaths</span><span class="p">(</span><span class="n">phys_root</span><span class="p">,</span> <span class="s2">"ostree/boot.?/*/*/0"</span><span class="p">))</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">"ostree_sysroots = </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">ostree_sysroots</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">ostree_sysroots</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">ostree_sysroots</span><span class="p">)</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s2">"Too many deployment roots found: </span><span class="si">%s</span><span class="s2">"</span> <span class="o">%</span> <span class="n">ostree_sysroots</span><span class="p">)</span>
|
||||
<span class="n">ostree_root</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">relpath</span><span class="p">(</span><span class="n">ostree_sysroots</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">phys_root</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">ostree_root</span></div>
|
||||
|
||||
<div class="viewcode-block" id="get_arch"><a class="viewcode-back" href="../../pylorax.html#pylorax.creator.get_arch">[docs]</a><span class="k">def</span> <span class="nf">get_arch</span><span class="p">(</span><span class="n">mount_dir</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Get the kernel arch</span>
|
||||
|
||||
<span class="sd"> :returns: Arch of first kernel found at mount_dir/boot/ or i386</span>
|
||||
<span class="sd"> :rtype: str</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">kernels</span> <span class="o">=</span> <span class="n">findkernels</span><span class="p">(</span><span class="n">mount_dir</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">kernels</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="s2">"i386"</span>
|
||||
<span class="k">return</span> <span class="n">kernels</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">arch</span></div>
|
||||
|
||||
<div class="viewcode-block" id="squashfs_args"><a class="viewcode-back" href="../../pylorax.html#pylorax.creator.squashfs_args">[docs]</a><span class="k">def</span> <span class="nf">squashfs_args</span><span class="p">(</span><span class="n">opts</span><span class="p">):</span>
|
||||
<span class="sd">""" Returns the compression type and args to use when making squashfs</span>
|
||||
|
||||
<span class="sd"> :param opts: ArgumentParser object with compression and compressopts</span>
|
||||
<span class="sd"> :returns: tuple of compression type and args</span>
|
||||
<span class="sd"> :rtype: tuple</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">compression</span> <span class="o">=</span> <span class="n">opts</span><span class="o">.</span><span class="n">compression</span> <span class="ow">or</span> <span class="s2">"xz"</span>
|
||||
<span class="n">arch</span> <span class="o">=</span> <span class="n">ArchData</span><span class="p">(</span><span class="n">opts</span><span class="o">.</span><span class="n">arch</span> <span class="ow">or</span> <span class="n">os</span><span class="o">.</span><span class="n">uname</span><span class="p">()</span><span class="o">.</span><span class="n">machine</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">compression</span> <span class="o">==</span> <span class="s2">"xz"</span> <span class="ow">and</span> <span class="n">arch</span><span class="o">.</span><span class="n">bcj</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">opts</span><span class="o">.</span><span class="n">compress_args</span><span class="p">:</span>
|
||||
<span class="c1"># default to bcj when using xz</span>
|
||||
<span class="n">compressargs</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"-Xbcj"</span><span class="p">,</span> <span class="n">arch</span><span class="o">.</span><span class="n">bcj</span><span class="p">]</span>
|
||||
<span class="k">elif</span> <span class="n">opts</span><span class="o">.</span><span class="n">compress_args</span><span class="p">:</span>
|
||||
<span class="n">compressargs</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">opts</span><span class="o">.</span><span class="n">compress_args</span><span class="p">:</span>
|
||||
<span class="n">compressargs</span> <span class="o">+=</span> <span class="n">arg</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" "</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">compressargs</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">return</span> <span class="p">(</span><span class="n">compression</span><span class="p">,</span> <span class="n">compressargs</span><span class="p">)</span></div>
|
||||
|
||||
<div class="viewcode-block" id="dracut_args"><a class="viewcode-back" href="../../pylorax.html#pylorax.creator.dracut_args">[docs]</a><span class="k">def</span> <span class="nf">dracut_args</span><span class="p">(</span><span class="n">opts</span><span class="p">):</span>
|
||||
<span class="sd">"""Return a list of the args to pass to dracut</span>
|
||||
|
||||
<span class="sd"> Return the default argument list unless one of the dracut cmdline arguments</span>
|
||||
<span class="sd"> has been used.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">if</span> <span class="n">opts</span><span class="o">.</span><span class="n">dracut_conf</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="p">[</span><span class="s2">"--conf"</span><span class="p">,</span> <span class="n">opts</span><span class="o">.</span><span class="n">dracut_conf</span><span class="p">]</span>
|
||||
<span class="k">elif</span> <span class="n">opts</span><span class="o">.</span><span class="n">dracut_args</span><span class="p">:</span>
|
||||
<span class="n">args</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">opts</span><span class="o">.</span><span class="n">dracut_args</span><span class="p">:</span>
|
||||
<span class="n">args</span> <span class="o">+=</span> <span class="n">arg</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" "</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">args</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">DRACUT_DEFAULT</span></div>
|
||||
|
||||
<div class="viewcode-block" id="make_appliance"><a class="viewcode-back" href="../../pylorax.html#pylorax.creator.make_appliance">[docs]</a><span class="k">def</span> <span class="nf">make_appliance</span><span class="p">(</span><span class="n">disk_img</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">template</span><span class="p">,</span> <span class="n">outfile</span><span class="p">,</span> <span class="n">networks</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">ram</span><span class="o">=</span><span class="mi">1024</span><span class="p">,</span>
|
||||
<span class="n">vcpus</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">arch</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">title</span><span class="o">=</span><span class="s2">"Linux"</span><span class="p">,</span> <span class="n">project</span><span class="o">=</span><span class="s2">"Linux"</span><span class="p">,</span>
|
||||
<span class="n">releasever</span><span class="o">=</span><span class="n">DEFAULT_RELEASEVER</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Generate an appliance description file</span>
|
||||
|
||||
<span class="sd"> :param str disk_img: Full path of the disk image</span>
|
||||
<span class="sd"> :param str name: Name of the appliance, passed to the template</span>
|
||||
<span class="sd"> :param str template: Full path of Mako template</span>
|
||||
<span class="sd"> :param str outfile: Full path of file to write, using template</span>
|
||||
<span class="sd"> :param list networks: List of networks(str) from the kickstart</span>
|
||||
<span class="sd"> :param int ram: Ram, in MiB, passed to template. Default is 1024</span>
|
||||
<span class="sd"> :param int vcpus: CPUs, passed to template. Default is 1</span>
|
||||
<span class="sd"> :param str arch: CPU architecture. Default is 'x86_64'</span>
|
||||
<span class="sd"> :param str title: Title, passed to template. Default is 'Linux'</span>
|
||||
<span class="sd"> :param str project: Project, passed to template. Default is 'Linux'</span>
|
||||
<span class="sd"> :param str releasever: Release version, passed to template.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="p">(</span><span class="n">disk_img</span> <span class="ow">and</span> <span class="n">template</span> <span class="ow">and</span> <span class="n">outfile</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="kc">None</span>
|
||||
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"Creating appliance definition using </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">template</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">arch</span><span class="p">:</span>
|
||||
<span class="n">arch</span> <span class="o">=</span> <span class="s2">"x86_64"</span>
|
||||
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"Calculating SHA256 checksum of </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">disk_img</span><span class="p">)</span>
|
||||
<span class="n">sha256</span> <span class="o">=</span> <span class="n">hashlib</span><span class="o">.</span><span class="n">sha256</span><span class="p">()</span>
|
||||
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">disk_img</span><span class="p">,</span> <span class="s2">"rb"</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
|
||||
<span class="k">while</span> <span class="kc">True</span><span class="p">:</span>
|
||||
<span class="n">data</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">read</span><span class="p">(</span><span class="mi">1024</span><span class="o">**</span><span class="mi">2</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">data</span><span class="p">:</span>
|
||||
<span class="k">break</span>
|
||||
<span class="n">sha256</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"SHA256 of </span><span class="si">%s</span><span class="s2"> is </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">disk_img</span><span class="p">,</span> <span class="n">sha256</span><span class="o">.</span><span class="n">hexdigest</span><span class="p">())</span>
|
||||
<span class="n">disk_info</span> <span class="o">=</span> <span class="n">DataHolder</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">basename</span><span class="p">(</span><span class="n">disk_img</span><span class="p">),</span> <span class="nb">format</span><span class="o">=</span><span class="s2">"raw"</span><span class="p">,</span>
|
||||
<span class="n">checksum_type</span><span class="o">=</span><span class="s2">"sha256"</span><span class="p">,</span> <span class="n">checksum</span><span class="o">=</span><span class="n">sha256</span><span class="o">.</span><span class="n">hexdigest</span><span class="p">())</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="n">result</span> <span class="o">=</span> <span class="n">Template</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="n">template</span><span class="p">)</span><span class="o">.</span><span class="n">render</span><span class="p">(</span><span class="n">disks</span><span class="o">=</span><span class="p">[</span><span class="n">disk_info</span><span class="p">],</span> <span class="n">name</span><span class="o">=</span><span class="n">name</span><span class="p">,</span>
|
||||
<span class="n">arch</span><span class="o">=</span><span class="n">arch</span><span class="p">,</span> <span class="n">memory</span><span class="o">=</span><span class="n">ram</span><span class="p">,</span> <span class="n">vcpus</span><span class="o">=</span><span class="n">vcpus</span><span class="p">,</span> <span class="n">networks</span><span class="o">=</span><span class="n">networks</span><span class="p">,</span>
|
||||
<span class="n">title</span><span class="o">=</span><span class="n">title</span><span class="p">,</span> <span class="n">project</span><span class="o">=</span><span class="n">project</span><span class="p">,</span> <span class="n">releasever</span><span class="o">=</span><span class="n">releasever</span><span class="p">)</span>
|
||||
<span class="k">except</span> <span class="ne">Exception</span><span class="p">:</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="n">text_error_template</span><span class="p">()</span><span class="o">.</span><span class="n">render</span><span class="p">())</span>
|
||||
<span class="k">raise</span>
|
||||
|
||||
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">outfile</span><span class="p">,</span> <span class="s2">"w"</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
|
||||
<span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">result</span><span class="p">)</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="make_runtime"><a class="viewcode-back" href="../../pylorax.html#pylorax.creator.make_runtime">[docs]</a><span class="k">def</span> <span class="nf">make_runtime</span><span class="p">(</span><span class="n">opts</span><span class="p">,</span> <span class="n">mount_dir</span><span class="p">,</span> <span class="n">work_dir</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Make the squashfs image from a directory</span>
|
||||
|
||||
<span class="sd"> :param opts: options passed to livemedia-creator</span>
|
||||
<span class="sd"> :type opts: argparse options</span>
|
||||
<span class="sd"> :param str mount_dir: Directory tree to compress</span>
|
||||
<span class="sd"> :param str work_dir: Output compressed image to work_dir+images/install.img</span>
|
||||
<span class="sd"> :param int size: Size of disk image, in GiB</span>
|
||||
<span class="sd"> :returns: rc of squashfs creation</span>
|
||||
<span class="sd"> :rtype: int</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">kernel_arch</span> <span class="o">=</span> <span class="n">get_arch</span><span class="p">(</span><span class="n">mount_dir</span><span class="p">)</span>
|
||||
|
||||
<span class="c1"># Fake dnf object</span>
|
||||
<span class="n">fake_dbo</span> <span class="o">=</span> <span class="n">FakeDNF</span><span class="p">(</span><span class="n">conf</span><span class="o">=</span><span class="n">DataHolder</span><span class="p">(</span><span class="n">installroot</span><span class="o">=</span><span class="n">mount_dir</span><span class="p">))</span>
|
||||
<span class="c1"># Fake arch with only basearch set</span>
|
||||
<span class="n">arch</span> <span class="o">=</span> <span class="n">ArchData</span><span class="p">(</span><span class="n">kernel_arch</span><span class="p">)</span>
|
||||
<span class="c1"># TODO: Need to get release info from someplace...</span>
|
||||
<span class="n">product</span> <span class="o">=</span> <span class="n">DataHolder</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="n">opts</span><span class="o">.</span><span class="n">project</span><span class="p">,</span> <span class="n">version</span><span class="o">=</span><span class="n">opts</span><span class="o">.</span><span class="n">releasever</span><span class="p">,</span> <span class="n">release</span><span class="o">=</span><span class="s2">""</span><span class="p">,</span>
|
||||
<span class="n">variant</span><span class="o">=</span><span class="s2">""</span><span class="p">,</span> <span class="n">bugurl</span><span class="o">=</span><span class="s2">""</span><span class="p">,</span> <span class="n">isfinal</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
|
||||
|
||||
<span class="n">rb</span> <span class="o">=</span> <span class="n">RuntimeBuilder</span><span class="p">(</span><span class="n">product</span><span class="p">,</span> <span class="n">arch</span><span class="p">,</span> <span class="n">fake_dbo</span><span class="p">,</span> <span class="n">skip_branding</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
|
||||
<span class="n">compression</span><span class="p">,</span> <span class="n">compressargs</span> <span class="o">=</span> <span class="n">squashfs_args</span><span class="p">(</span><span class="n">opts</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">opts</span><span class="o">.</span><span class="n">squashfs_only</span><span class="p">:</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"Creating a squashfs only runtime"</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">rb</span><span class="o">.</span><span class="n">create_squashfs_runtime</span><span class="p">(</span><span class="n">joinpaths</span><span class="p">(</span><span class="n">work_dir</span><span class="p">,</span> <span class="n">RUNTIME</span><span class="p">),</span> <span class="n">size</span><span class="o">=</span><span class="n">size</span><span class="p">,</span>
|
||||
<span class="n">compression</span><span class="o">=</span><span class="n">compression</span><span class="p">,</span> <span class="n">compressargs</span><span class="o">=</span><span class="n">compressargs</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"Creating a squashfs+ext4 runtime"</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">rb</span><span class="o">.</span><span class="n">create_ext4_runtime</span><span class="p">(</span><span class="n">joinpaths</span><span class="p">(</span><span class="n">work_dir</span><span class="p">,</span> <span class="n">RUNTIME</span><span class="p">),</span> <span class="n">size</span><span class="o">=</span><span class="n">size</span><span class="p">,</span>
|
||||
<span class="n">compression</span><span class="o">=</span><span class="n">compression</span><span class="p">,</span> <span class="n">compressargs</span><span class="o">=</span><span class="n">compressargs</span><span class="p">)</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="rebuild_initrds_for_live"><a class="viewcode-back" href="../../pylorax.html#pylorax.creator.rebuild_initrds_for_live">[docs]</a><span class="k">def</span> <span class="nf">rebuild_initrds_for_live</span><span class="p">(</span><span class="n">opts</span><span class="p">,</span> <span class="n">sys_root_dir</span><span class="p">,</span> <span class="n">results_dir</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Rebuild intrds for pxe live image (root=live:http://)</span>
|
||||
|
||||
<span class="sd"> :param opts: options passed to livemedia-creator</span>
|
||||
<span class="sd"> :type opts: argparse options</span>
|
||||
<span class="sd"> :param str sys_root_dir: Path to root of the system</span>
|
||||
<span class="sd"> :param str results_dir: Path of directory for storing results</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="c1"># cmdline dracut args override the defaults, but need to be parsed</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"dracut args = </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">dracut_args</span><span class="p">(</span><span class="n">opts</span><span class="p">))</span>
|
||||
|
||||
<span class="n">args</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"--nomdadmconf"</span><span class="p">,</span> <span class="s2">"--nolvmconf"</span><span class="p">]</span> <span class="o">+</span> <span class="n">dracut_args</span><span class="p">(</span><span class="n">opts</span><span class="p">)</span>
|
||||
|
||||
<span class="n">kdir</span> <span class="o">=</span> <span class="s2">"boot"</span>
|
||||
<span class="k">if</span> <span class="n">opts</span><span class="o">.</span><span class="n">ostree</span><span class="p">:</span>
|
||||
<span class="n">kernels_dir</span> <span class="o">=</span> <span class="n">glob</span><span class="o">.</span><span class="n">glob</span><span class="p">(</span><span class="n">joinpaths</span><span class="p">(</span><span class="n">sys_root_dir</span><span class="p">,</span> <span class="s2">"boot/ostree/*"</span><span class="p">))</span>
|
||||
<span class="k">if</span> <span class="n">kernels_dir</span><span class="p">:</span>
|
||||
<span class="n">kdir</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">relpath</span><span class="p">(</span><span class="n">kernels_dir</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">sys_root_dir</span><span class="p">)</span>
|
||||
|
||||
<span class="n">kernels</span> <span class="o">=</span> <span class="p">[</span><span class="n">kernel</span> <span class="k">for</span> <span class="n">kernel</span> <span class="ow">in</span> <span class="n">findkernels</span><span class="p">(</span><span class="n">sys_root_dir</span><span class="p">,</span> <span class="n">kdir</span><span class="p">)]</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">kernels</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s2">"No initrds found, cannot rebuild_initrds"</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">opts</span><span class="o">.</span><span class="n">ostree</span><span class="p">:</span>
|
||||
<span class="c1"># Dracut assumes to have some dirs in disk image</span>
|
||||
<span class="c1"># /var/tmp for temp files</span>
|
||||
<span class="n">vartmp_dir</span> <span class="o">=</span> <span class="n">joinpaths</span><span class="p">(</span><span class="n">sys_root_dir</span><span class="p">,</span> <span class="s2">"var/tmp"</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isdir</span><span class="p">(</span><span class="n">vartmp_dir</span><span class="p">):</span>
|
||||
<span class="n">os</span><span class="o">.</span><span class="n">mkdir</span><span class="p">(</span><span class="n">vartmp_dir</span><span class="p">)</span>
|
||||
<span class="c1"># /root (maybe not fatal)</span>
|
||||
<span class="n">root_dir</span> <span class="o">=</span> <span class="n">joinpaths</span><span class="p">(</span><span class="n">sys_root_dir</span><span class="p">,</span> <span class="s2">"var/roothome"</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isdir</span><span class="p">(</span><span class="n">root_dir</span><span class="p">):</span>
|
||||
<span class="n">os</span><span class="o">.</span><span class="n">mkdir</span><span class="p">(</span><span class="n">root_dir</span><span class="p">)</span>
|
||||
<span class="c1"># /tmp (maybe not fatal)</span>
|
||||
<span class="n">tmp_dir</span> <span class="o">=</span> <span class="n">joinpaths</span><span class="p">(</span><span class="n">sys_root_dir</span><span class="p">,</span> <span class="s2">"sysroot/tmp"</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isdir</span><span class="p">(</span><span class="n">tmp_dir</span><span class="p">):</span>
|
||||
<span class="n">os</span><span class="o">.</span><span class="n">mkdir</span><span class="p">(</span><span class="n">tmp_dir</span><span class="p">)</span>
|
||||
|
||||
<span class="c1"># Write the new initramfs directly to the results directory</span>
|
||||
<span class="n">os</span><span class="o">.</span><span class="n">mkdir</span><span class="p">(</span><span class="n">joinpaths</span><span class="p">(</span><span class="n">sys_root_dir</span><span class="p">,</span> <span class="s2">"results"</span><span class="p">))</span>
|
||||
<span class="k">with</span> <span class="n">DracutChroot</span><span class="p">(</span><span class="n">sys_root_dir</span><span class="p">,</span> <span class="n">bind</span><span class="o">=</span><span class="p">[(</span><span class="n">results_dir</span><span class="p">,</span> <span class="s2">"/results"</span><span class="p">)])</span> <span class="k">as</span> <span class="n">dracut</span><span class="p">:</span>
|
||||
<span class="k">for</span> <span class="n">kernel</span> <span class="ow">in</span> <span class="n">kernels</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">kernel</span><span class="p">,</span> <span class="s2">"initrd"</span><span class="p">):</span>
|
||||
<span class="n">outfile</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">basename</span><span class="p">(</span><span class="n">kernel</span><span class="o">.</span><span class="n">initrd</span><span class="o">.</span><span class="n">path</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="c1"># Construct an initrd from the kernel name</span>
|
||||
<span class="n">outfile</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">basename</span><span class="p">(</span><span class="n">kernel</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">"vmlinuz-"</span><span class="p">,</span> <span class="s2">"initrd-"</span><span class="p">)</span> <span class="o">+</span> <span class="s2">".img"</span><span class="p">)</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"rebuilding </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">outfile</span><span class="p">)</span>
|
||||
|
||||
<span class="n">kver</span> <span class="o">=</span> <span class="n">kernel</span><span class="o">.</span><span class="n">version</span>
|
||||
<span class="n">dracut</span><span class="o">.</span><span class="n">Run</span><span class="p">(</span><span class="n">args</span> <span class="o">+</span> <span class="p">[</span><span class="s2">"/results/"</span><span class="o">+</span><span class="n">outfile</span><span class="p">,</span> <span class="n">kver</span><span class="p">])</span>
|
||||
<span class="n">shutil</span><span class="o">.</span><span class="n">copy2</span><span class="p">(</span><span class="n">joinpaths</span><span class="p">(</span><span class="n">sys_root_dir</span><span class="p">,</span> <span class="n">kernel</span><span class="o">.</span><span class="n">path</span><span class="p">),</span> <span class="n">results_dir</span><span class="p">)</span></div>
|
||||
|
||||
<div class="viewcode-block" id="create_pxe_config"><a class="viewcode-back" href="../../pylorax.html#pylorax.creator.create_pxe_config">[docs]</a><span class="k">def</span> <span class="nf">create_pxe_config</span><span class="p">(</span><span class="n">template</span><span class="p">,</span> <span class="n">images_dir</span><span class="p">,</span> <span class="n">live_image_name</span><span class="p">,</span> <span class="n">add_args</span> <span class="o">=</span> <span class="kc">None</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Create template for pxe to live configuration</span>
|
||||
|
||||
<span class="sd"> :param str images_dir: Path of directory with images to be used</span>
|
||||
<span class="sd"> :param str live_image_name: Name of live rootfs image file</span>
|
||||
<span class="sd"> :param list add_args: Arguments to be added to initrd= pxe config</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="n">add_args</span> <span class="o">=</span> <span class="n">add_args</span> <span class="ow">or</span> <span class="p">[]</span>
|
||||
|
||||
<span class="n">kernels</span> <span class="o">=</span> <span class="p">[</span><span class="n">kernel</span> <span class="k">for</span> <span class="n">kernel</span> <span class="ow">in</span> <span class="n">findkernels</span><span class="p">(</span><span class="n">images_dir</span><span class="p">,</span> <span class="n">kdir</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">kernel</span><span class="p">,</span> <span class="s2">"initrd"</span><span class="p">)]</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">kernels</span><span class="p">:</span>
|
||||
<span class="k">return</span>
|
||||
|
||||
<span class="n">kernel</span> <span class="o">=</span> <span class="n">kernels</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
|
||||
|
||||
<span class="n">add_args_str</span> <span class="o">=</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">add_args</span><span class="p">)</span>
|
||||
|
||||
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="n">result</span> <span class="o">=</span> <span class="n">Template</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="n">template</span><span class="p">)</span><span class="o">.</span><span class="n">render</span><span class="p">(</span><span class="n">kernel</span><span class="o">=</span><span class="n">kernel</span><span class="o">.</span><span class="n">path</span><span class="p">,</span>
|
||||
<span class="n">initrd</span><span class="o">=</span><span class="n">kernel</span><span class="o">.</span><span class="n">initrd</span><span class="o">.</span><span class="n">path</span><span class="p">,</span> <span class="n">liveimg</span><span class="o">=</span><span class="n">live_image_name</span><span class="p">,</span>
|
||||
<span class="n">addargs</span><span class="o">=</span><span class="n">add_args_str</span><span class="p">)</span>
|
||||
<span class="k">except</span> <span class="ne">Exception</span><span class="p">:</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="n">text_error_template</span><span class="p">()</span><span class="o">.</span><span class="n">render</span><span class="p">())</span>
|
||||
<span class="k">raise</span>
|
||||
|
||||
<span class="k">with</span> <span class="nb">open</span> <span class="p">(</span><span class="n">joinpaths</span><span class="p">(</span><span class="n">images_dir</span><span class="p">,</span> <span class="s2">"PXE_CONFIG"</span><span class="p">),</span> <span class="s2">"w"</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
|
||||
<span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">result</span><span class="p">)</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="make_livecd"><a class="viewcode-back" href="../../pylorax.html#pylorax.creator.make_livecd">[docs]</a><span class="k">def</span> <span class="nf">make_livecd</span><span class="p">(</span><span class="n">opts</span><span class="p">,</span> <span class="n">mount_dir</span><span class="p">,</span> <span class="n">work_dir</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Take the content from the disk image and make a livecd out of it</span>
|
||||
|
||||
<span class="sd"> :param opts: options passed to livemedia-creator</span>
|
||||
<span class="sd"> :type opts: argparse options</span>
|
||||
<span class="sd"> :param str mount_dir: Directory tree to compress</span>
|
||||
<span class="sd"> :param str work_dir: Output compressed image to work_dir+images/install.img</span>
|
||||
|
||||
<span class="sd"> This uses wwood's squashfs live initramfs method:</span>
|
||||
<span class="sd"> * put the real / into LiveOS/rootfs.img</span>
|
||||
<span class="sd"> * make a squashfs of the LiveOS/rootfs.img tree</span>
|
||||
<span class="sd"> * This is loaded by dracut when the cmdline is passed to the kernel:</span>
|
||||
<span class="sd"> root=live:CDLABEL=<volid> rd.live.image</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">kernel_arch</span> <span class="o">=</span> <span class="n">get_arch</span><span class="p">(</span><span class="n">mount_dir</span><span class="p">)</span>
|
||||
|
||||
<span class="n">arch</span> <span class="o">=</span> <span class="n">ArchData</span><span class="p">(</span><span class="n">kernel_arch</span><span class="p">)</span>
|
||||
<span class="c1"># TODO: Need to get release info from someplace...</span>
|
||||
<span class="n">product</span> <span class="o">=</span> <span class="n">DataHolder</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="n">opts</span><span class="o">.</span><span class="n">project</span><span class="p">,</span> <span class="n">version</span><span class="o">=</span><span class="n">opts</span><span class="o">.</span><span class="n">releasever</span><span class="p">,</span> <span class="n">release</span><span class="o">=</span><span class="s2">""</span><span class="p">,</span>
|
||||
<span class="n">variant</span><span class="o">=</span><span class="s2">""</span><span class="p">,</span> <span class="n">bugurl</span><span class="o">=</span><span class="s2">""</span><span class="p">,</span> <span class="n">isfinal</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
|
||||
|
||||
<span class="c1"># Link /images to work_dir/images to make the templates happy</span>
|
||||
<span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">islink</span><span class="p">(</span><span class="n">joinpaths</span><span class="p">(</span><span class="n">mount_dir</span><span class="p">,</span> <span class="s2">"images"</span><span class="p">)):</span>
|
||||
<span class="n">os</span><span class="o">.</span><span class="n">unlink</span><span class="p">(</span><span class="n">joinpaths</span><span class="p">(</span><span class="n">mount_dir</span><span class="p">,</span> <span class="s2">"images"</span><span class="p">))</span>
|
||||
<span class="n">rc</span> <span class="o">=</span> <span class="n">execWithRedirect</span><span class="p">(</span><span class="s2">"/bin/ln"</span><span class="p">,</span> <span class="p">[</span><span class="s2">"-s"</span><span class="p">,</span> <span class="n">joinpaths</span><span class="p">(</span><span class="n">work_dir</span><span class="p">,</span> <span class="s2">"images"</span><span class="p">),</span>
|
||||
<span class="n">joinpaths</span><span class="p">(</span><span class="n">mount_dir</span><span class="p">,</span> <span class="s2">"images"</span><span class="p">)])</span>
|
||||
<span class="k">if</span> <span class="n">rc</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span><span class="s2">"Failed to symlink images from mount_dir to work_dir"</span><span class="p">)</span>
|
||||
|
||||
<span class="c1"># The templates expect the config files to be in /tmp/config_files</span>
|
||||
<span class="c1"># I think these should be release specific, not from lorax, but for now</span>
|
||||
<span class="n">configdir</span> <span class="o">=</span> <span class="n">joinpaths</span><span class="p">(</span><span class="n">opts</span><span class="o">.</span><span class="n">lorax_templates</span><span class="p">,</span><span class="s2">"live/config_files/"</span><span class="p">)</span>
|
||||
<span class="n">configdir_path</span> <span class="o">=</span> <span class="s2">"tmp/config_files"</span>
|
||||
<span class="n">fullpath</span> <span class="o">=</span> <span class="n">joinpaths</span><span class="p">(</span><span class="n">mount_dir</span><span class="p">,</span> <span class="n">configdir_path</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="n">fullpath</span><span class="p">):</span>
|
||||
<span class="n">remove</span><span class="p">(</span><span class="n">fullpath</span><span class="p">)</span>
|
||||
<span class="n">copytree</span><span class="p">(</span><span class="n">configdir</span><span class="p">,</span> <span class="n">fullpath</span><span class="p">)</span>
|
||||
|
||||
<span class="n">isolabel</span> <span class="o">=</span> <span class="n">opts</span><span class="o">.</span><span class="n">volid</span> <span class="ow">or</span> <span class="s2">"</span><span class="si">{0.name}</span><span class="s2">-</span><span class="si">{0.version}</span><span class="s2">-</span><span class="si">{1.basearch}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">product</span><span class="p">,</span> <span class="n">arch</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">isolabel</span><span class="p">)</span> <span class="o">></span> <span class="mi">32</span><span class="p">:</span>
|
||||
<span class="n">isolabel</span> <span class="o">=</span> <span class="n">isolabel</span><span class="p">[:</span><span class="mi">32</span><span class="p">]</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">warning</span><span class="p">(</span><span class="s2">"Truncating isolabel to 32 chars: </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">isolabel</span><span class="p">)</span>
|
||||
|
||||
<span class="n">tb</span> <span class="o">=</span> <span class="n">TreeBuilder</span><span class="p">(</span><span class="n">product</span><span class="o">=</span><span class="n">product</span><span class="p">,</span> <span class="n">arch</span><span class="o">=</span><span class="n">arch</span><span class="p">,</span> <span class="n">domacboot</span><span class="o">=</span><span class="n">opts</span><span class="o">.</span><span class="n">domacboot</span><span class="p">,</span>
|
||||
<span class="n">inroot</span><span class="o">=</span><span class="n">mount_dir</span><span class="p">,</span> <span class="n">outroot</span><span class="o">=</span><span class="n">work_dir</span><span class="p">,</span>
|
||||
<span class="n">runtime</span><span class="o">=</span><span class="n">RUNTIME</span><span class="p">,</span> <span class="n">isolabel</span><span class="o">=</span><span class="n">isolabel</span><span class="p">,</span>
|
||||
<span class="n">templatedir</span><span class="o">=</span><span class="n">joinpaths</span><span class="p">(</span><span class="n">opts</span><span class="o">.</span><span class="n">lorax_templates</span><span class="p">,</span><span class="s2">"live/"</span><span class="p">),</span>
|
||||
<span class="n">extra_boot_args</span><span class="o">=</span><span class="n">opts</span><span class="o">.</span><span class="n">extra_boot_args</span><span class="p">)</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"Rebuilding initrds"</span><span class="p">)</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"dracut args = </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">dracut_args</span><span class="p">(</span><span class="n">opts</span><span class="p">))</span>
|
||||
<span class="n">tb</span><span class="o">.</span><span class="n">rebuild_initrds</span><span class="p">(</span><span class="n">add_args</span><span class="o">=</span><span class="n">dracut_args</span><span class="p">(</span><span class="n">opts</span><span class="p">))</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"Building boot.iso"</span><span class="p">)</span>
|
||||
<span class="n">tb</span><span class="o">.</span><span class="n">build</span><span class="p">()</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">work_dir</span></div>
|
||||
|
||||
<div class="viewcode-block" id="mount_boot_part_over_root"><a class="viewcode-back" href="../../pylorax.html#pylorax.creator.mount_boot_part_over_root">[docs]</a><span class="k">def</span> <span class="nf">mount_boot_part_over_root</span><span class="p">(</span><span class="n">img_mount</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Mount boot partition to /boot of root fs mounted in img_mount</span>
|
||||
|
||||
<span class="sd"> Used for OSTree so it finds deployment configurations on live rootfs</span>
|
||||
|
||||
<span class="sd"> param img_mount: object with mounted disk image root partition</span>
|
||||
<span class="sd"> type img_mount: imgutils.PartitionMount</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">root_dir</span> <span class="o">=</span> <span class="n">img_mount</span><span class="o">.</span><span class="n">mount_dir</span>
|
||||
<span class="n">is_boot_part</span> <span class="o">=</span> <span class="k">lambda</span> <span class="nb">dir</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="nb">dir</span><span class="o">+</span><span class="s2">"/loader.0"</span><span class="p">)</span>
|
||||
<span class="n">tmp_mount_dir</span> <span class="o">=</span> <span class="n">tempfile</span><span class="o">.</span><span class="n">mkdtemp</span><span class="p">(</span><span class="n">prefix</span><span class="o">=</span><span class="s2">"lmc-tmpdir-"</span><span class="p">)</span>
|
||||
<span class="n">sysroot_boot_dir</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
<span class="k">for</span> <span class="n">dev</span><span class="p">,</span> <span class="n">_size</span> <span class="ow">in</span> <span class="n">img_mount</span><span class="o">.</span><span class="n">loop_devices</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="n">dev</span> <span class="ow">is</span> <span class="n">img_mount</span><span class="o">.</span><span class="n">mount_dev</span><span class="p">:</span>
|
||||
<span class="k">continue</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="n">mount</span><span class="p">(</span><span class="s2">"/dev/mapper/"</span><span class="o">+</span><span class="n">dev</span><span class="p">,</span> <span class="n">mnt</span><span class="o">=</span><span class="n">tmp_mount_dir</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">is_boot_part</span><span class="p">(</span><span class="n">tmp_mount_dir</span><span class="p">):</span>
|
||||
<span class="n">umount</span><span class="p">(</span><span class="n">tmp_mount_dir</span><span class="p">)</span>
|
||||
<span class="n">sysroot_boot_dir</span> <span class="o">=</span> <span class="n">joinpaths</span><span class="p">(</span><span class="n">root_dir</span><span class="p">,</span> <span class="s2">"boot"</span><span class="p">)</span>
|
||||
<span class="n">mount</span><span class="p">(</span><span class="s2">"/dev/mapper/"</span><span class="o">+</span><span class="n">dev</span><span class="p">,</span> <span class="n">mnt</span><span class="o">=</span><span class="n">sysroot_boot_dir</span><span class="p">)</span>
|
||||
<span class="k">break</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">umount</span><span class="p">(</span><span class="n">tmp_mount_dir</span><span class="p">)</span>
|
||||
<span class="k">except</span> <span class="n">subprocess</span><span class="o">.</span><span class="n">CalledProcessError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">"Looking for boot partition error: </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">e</span><span class="p">)</span>
|
||||
<span class="n">remove</span><span class="p">(</span><span class="n">tmp_mount_dir</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">sysroot_boot_dir</span></div>
|
||||
|
||||
<div class="viewcode-block" id="calculate_disk_size"><a class="viewcode-back" href="../../pylorax.html#pylorax.creator.calculate_disk_size">[docs]</a><span class="k">def</span> <span class="nf">calculate_disk_size</span><span class="p">(</span><span class="n">opts</span><span class="p">,</span> <span class="n">ks</span><span class="p">):</span>
|
||||
<span class="sd">""" Calculate the disk size from the kickstart</span>
|
||||
|
||||
<span class="sd"> :param opts: options passed to livemedia-creator</span>
|
||||
<span class="sd"> :type opts: argparse options</span>
|
||||
<span class="sd"> :param str ks: Path to the kickstart to use for the installation</span>
|
||||
<span class="sd"> :returns: Disk size in MiB</span>
|
||||
<span class="sd"> :rtype: int</span>
|
||||
|
||||
<span class="sd"> Also takes into account the use of reqpart or reqpart --add-boot</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="c1"># Disk size for a filesystem image should only be the size of /</span>
|
||||
<span class="c1"># to prevent surprises when using the same kickstart for different installations.</span>
|
||||
<span class="n">unique_partitions</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">((</span><span class="n">p</span><span class="o">.</span><span class="n">mountpoint</span><span class="p">,</span> <span class="n">p</span><span class="p">)</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">ks</span><span class="o">.</span><span class="n">handler</span><span class="o">.</span><span class="n">partition</span><span class="o">.</span><span class="n">partitions</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">opts</span><span class="o">.</span><span class="n">no_virt</span> <span class="ow">and</span> <span class="p">(</span><span class="n">opts</span><span class="o">.</span><span class="n">make_iso</span> <span class="ow">or</span> <span class="n">opts</span><span class="o">.</span><span class="n">make_fsimage</span><span class="p">):</span>
|
||||
<span class="n">disk_size</span> <span class="o">=</span> <span class="mi">2</span> <span class="o">+</span> <span class="nb">sum</span><span class="p">(</span><span class="n">p</span><span class="o">.</span><span class="n">size</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">unique_partitions</span><span class="o">.</span><span class="n">values</span><span class="p">()</span> <span class="k">if</span> <span class="n">p</span><span class="o">.</span><span class="n">mountpoint</span> <span class="o">==</span> <span class="s2">"/"</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">disk_size</span> <span class="o">=</span> <span class="mi">2</span> <span class="o">+</span> <span class="nb">sum</span><span class="p">(</span><span class="n">p</span><span class="o">.</span><span class="n">size</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">unique_partitions</span><span class="o">.</span><span class="n">values</span><span class="p">())</span>
|
||||
|
||||
<span class="c1"># reqpart can add 1M, 2M, 200M based on platform. Add 500M to be sure</span>
|
||||
<span class="k">if</span> <span class="n">ks</span><span class="o">.</span><span class="n">handler</span><span class="o">.</span><span class="n">reqpart</span><span class="o">.</span><span class="n">seen</span><span class="p">:</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"Adding 500M for reqpart"</span><span class="p">)</span>
|
||||
<span class="n">disk_size</span> <span class="o">+=</span> <span class="mi">500</span>
|
||||
|
||||
<span class="c1"># It can also request adding /boot which is 1G</span>
|
||||
<span class="k">if</span> <span class="n">ks</span><span class="o">.</span><span class="n">handler</span><span class="o">.</span><span class="n">reqpart</span><span class="o">.</span><span class="n">addBoot</span><span class="p">:</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"Adding 1024M for reqpart --addboot"</span><span class="p">)</span>
|
||||
<span class="n">disk_size</span> <span class="o">+=</span> <span class="mi">1024</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">opts</span><span class="o">.</span><span class="n">image_size_align</span><span class="p">:</span>
|
||||
<span class="n">disk_size</span> <span class="o">+=</span> <span class="n">opts</span><span class="o">.</span><span class="n">image_size_align</span> <span class="o">-</span> <span class="p">(</span><span class="n">disk_size</span> <span class="o">%</span> <span class="n">opts</span><span class="o">.</span><span class="n">image_size_align</span><span class="p">)</span>
|
||||
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"Using disk size of </span><span class="si">%s</span><span class="s2">MiB"</span><span class="p">,</span> <span class="n">disk_size</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">disk_size</span></div>
|
||||
|
||||
<div class="viewcode-block" id="make_image"><a class="viewcode-back" href="../../pylorax.html#pylorax.creator.make_image">[docs]</a><span class="k">def</span> <span class="nf">make_image</span><span class="p">(</span><span class="n">opts</span><span class="p">,</span> <span class="n">ks</span><span class="p">,</span> <span class="n">cancel_func</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Install to a disk image</span>
|
||||
|
||||
<span class="sd"> :param opts: options passed to livemedia-creator</span>
|
||||
<span class="sd"> :type opts: argparse options</span>
|
||||
<span class="sd"> :param str ks: Path to the kickstart to use for the installation</span>
|
||||
<span class="sd"> :param cancel_func: Function that returns True to cancel build</span>
|
||||
<span class="sd"> :type cancel_func: function</span>
|
||||
<span class="sd"> :returns: Path of the image created</span>
|
||||
<span class="sd"> :rtype: str</span>
|
||||
|
||||
<span class="sd"> Use qemu+boot.iso or anaconda to install to a disk image.</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="c1"># For make_tar_disk, opts.image_name is the name of the final tarball.</span>
|
||||
<span class="c1"># Use opts.tar_disk_name as the name of the disk image</span>
|
||||
<span class="k">if</span> <span class="n">opts</span><span class="o">.</span><span class="n">make_tar_disk</span><span class="p">:</span>
|
||||
<span class="n">disk_img</span> <span class="o">=</span> <span class="n">joinpaths</span><span class="p">(</span><span class="n">opts</span><span class="o">.</span><span class="n">result_dir</span><span class="p">,</span> <span class="n">opts</span><span class="o">.</span><span class="n">tar_disk_name</span><span class="p">)</span>
|
||||
<span class="k">elif</span> <span class="n">opts</span><span class="o">.</span><span class="n">image_name</span><span class="p">:</span>
|
||||
<span class="n">disk_img</span> <span class="o">=</span> <span class="n">joinpaths</span><span class="p">(</span><span class="n">opts</span><span class="o">.</span><span class="n">result_dir</span><span class="p">,</span> <span class="n">opts</span><span class="o">.</span><span class="n">image_name</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">disk_img</span> <span class="o">=</span> <span class="n">tempfile</span><span class="o">.</span><span class="n">mktemp</span><span class="p">(</span><span class="n">prefix</span><span class="o">=</span><span class="s2">"lmc-disk-"</span><span class="p">,</span> <span class="n">suffix</span><span class="o">=</span><span class="s2">".img"</span><span class="p">,</span> <span class="nb">dir</span><span class="o">=</span><span class="n">opts</span><span class="o">.</span><span class="n">result_dir</span><span class="p">)</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"disk_img = </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">disk_img</span><span class="p">)</span>
|
||||
<span class="n">disk_size</span> <span class="o">=</span> <span class="n">calculate_disk_size</span><span class="p">(</span><span class="n">opts</span><span class="p">,</span> <span class="n">ks</span><span class="p">)</span>
|
||||
|
||||
<span class="c1"># For make_tar_disk, pass a second path parameter for the final tarball</span>
|
||||
<span class="c1"># not the final output file.</span>
|
||||
<span class="k">if</span> <span class="n">opts</span><span class="o">.</span><span class="n">make_tar_disk</span><span class="p">:</span>
|
||||
<span class="n">tar_img</span> <span class="o">=</span> <span class="n">joinpaths</span><span class="p">(</span><span class="n">opts</span><span class="o">.</span><span class="n">result_dir</span><span class="p">,</span> <span class="n">opts</span><span class="o">.</span><span class="n">image_name</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">tar_img</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="n">opts</span><span class="o">.</span><span class="n">no_virt</span><span class="p">:</span>
|
||||
<span class="n">novirt_install</span><span class="p">(</span><span class="n">opts</span><span class="p">,</span> <span class="n">disk_img</span><span class="p">,</span> <span class="n">disk_size</span><span class="p">,</span> <span class="n">cancel_func</span><span class="o">=</span><span class="n">cancel_func</span><span class="p">,</span> <span class="n">tar_img</span><span class="o">=</span><span class="n">tar_img</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">install_log</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">abspath</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">dirname</span><span class="p">(</span><span class="n">opts</span><span class="o">.</span><span class="n">logfile</span><span class="p">))</span><span class="o">+</span><span class="s2">"/virt-install.log"</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"install_log = </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">install_log</span><span class="p">)</span>
|
||||
|
||||
<span class="n">virt_install</span><span class="p">(</span><span class="n">opts</span><span class="p">,</span> <span class="n">install_log</span><span class="p">,</span> <span class="n">disk_img</span><span class="p">,</span> <span class="n">disk_size</span><span class="p">,</span> <span class="n">cancel_func</span><span class="o">=</span><span class="n">cancel_func</span><span class="p">,</span> <span class="n">tar_img</span><span class="o">=</span><span class="n">tar_img</span><span class="p">)</span>
|
||||
<span class="k">except</span> <span class="n">InstallError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="s2">"Install failed: </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">e</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">opts</span><span class="o">.</span><span class="n">keep_image</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="n">disk_img</span><span class="p">):</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"Removing bad disk image"</span><span class="p">)</span>
|
||||
<span class="n">os</span><span class="o">.</span><span class="n">unlink</span><span class="p">(</span><span class="n">disk_img</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">tar_img</span> <span class="ow">and</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="n">tar_img</span><span class="p">):</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"Removing bad tar file"</span><span class="p">)</span>
|
||||
<span class="n">os</span><span class="o">.</span><span class="n">unlink</span><span class="p">(</span><span class="n">tar_img</span><span class="p">)</span>
|
||||
<span class="k">raise</span>
|
||||
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"Disk Image install successful"</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">opts</span><span class="o">.</span><span class="n">make_tar_disk</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">tar_img</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">disk_img</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="make_live_images"><a class="viewcode-back" href="../../pylorax.html#pylorax.creator.make_live_images">[docs]</a><span class="k">def</span> <span class="nf">make_live_images</span><span class="p">(</span><span class="n">opts</span><span class="p">,</span> <span class="n">work_dir</span><span class="p">,</span> <span class="n">disk_img</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Create live images from direcory or rootfs image</span>
|
||||
|
||||
<span class="sd"> :param opts: options passed to livemedia-creator</span>
|
||||
<span class="sd"> :type opts: argparse options</span>
|
||||
<span class="sd"> :param str work_dir: Directory for storing results</span>
|
||||
<span class="sd"> :param str disk_img: Path to disk image (fsimage or partitioned)</span>
|
||||
<span class="sd"> :returns: Path of directory with created images or None</span>
|
||||
<span class="sd"> :rtype: str</span>
|
||||
|
||||
<span class="sd"> fsck.ext4 is run on the rootfs_image to make sure there are no errors and to zero</span>
|
||||
<span class="sd"> out any deleted blocks to make it compress better. If this fails for any reason</span>
|
||||
<span class="sd"> it will return None and log the error.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">sys_root</span> <span class="o">=</span> <span class="s2">""</span>
|
||||
|
||||
<span class="n">squashfs_root_dir</span> <span class="o">=</span> <span class="n">joinpaths</span><span class="p">(</span><span class="n">work_dir</span><span class="p">,</span> <span class="s2">"squashfs_root"</span><span class="p">)</span>
|
||||
<span class="n">liveos_dir</span> <span class="o">=</span> <span class="n">joinpaths</span><span class="p">(</span><span class="n">squashfs_root_dir</span><span class="p">,</span> <span class="s2">"LiveOS"</span><span class="p">)</span>
|
||||
<span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span><span class="n">liveos_dir</span><span class="p">)</span>
|
||||
<span class="n">rootfs_img</span> <span class="o">=</span> <span class="n">joinpaths</span><span class="p">(</span><span class="n">liveos_dir</span><span class="p">,</span> <span class="s2">"rootfs.img"</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">opts</span><span class="o">.</span><span class="n">fs_image</span> <span class="ow">or</span> <span class="n">opts</span><span class="o">.</span><span class="n">no_virt</span><span class="p">:</span>
|
||||
<span class="c1"># Find the ostree root in the fsimage</span>
|
||||
<span class="k">if</span> <span class="n">opts</span><span class="o">.</span><span class="n">ostree</span><span class="p">:</span>
|
||||
<span class="k">with</span> <span class="n">Mount</span><span class="p">(</span><span class="n">disk_img</span><span class="p">,</span> <span class="n">opts</span><span class="o">=</span><span class="s2">"loop"</span><span class="p">)</span> <span class="k">as</span> <span class="n">mnt_dir</span><span class="p">:</span>
|
||||
<span class="n">sys_root</span> <span class="o">=</span> <span class="n">find_ostree_root</span><span class="p">(</span><span class="n">mnt_dir</span><span class="p">)</span>
|
||||
|
||||
<span class="c1"># Try to hardlink the image, if that fails, copy it</span>
|
||||
<span class="n">rc</span> <span class="o">=</span> <span class="n">execWithRedirect</span><span class="p">(</span><span class="s2">"/bin/ln"</span><span class="p">,</span> <span class="p">[</span><span class="n">disk_img</span><span class="p">,</span> <span class="n">rootfs_img</span><span class="p">])</span>
|
||||
<span class="k">if</span> <span class="n">rc</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">:</span>
|
||||
<span class="n">shutil</span><span class="o">.</span><span class="n">copy2</span><span class="p">(</span><span class="n">disk_img</span><span class="p">,</span> <span class="n">rootfs_img</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">is_root_part</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
<span class="k">if</span> <span class="n">opts</span><span class="o">.</span><span class="n">ostree</span><span class="p">:</span>
|
||||
<span class="n">is_root_part</span> <span class="o">=</span> <span class="k">lambda</span> <span class="nb">dir</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="nb">dir</span><span class="o">+</span><span class="s2">"/ostree/deploy"</span><span class="p">)</span>
|
||||
<span class="k">with</span> <span class="n">PartitionMount</span><span class="p">(</span><span class="n">disk_img</span><span class="p">,</span> <span class="n">mount_ok</span><span class="o">=</span><span class="n">is_root_part</span><span class="p">)</span> <span class="k">as</span> <span class="n">img_mount</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="n">img_mount</span> <span class="ow">and</span> <span class="n">img_mount</span><span class="o">.</span><span class="n">mount_dir</span><span class="p">:</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="n">mounted_sysroot_boot_dir</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
<span class="k">if</span> <span class="n">opts</span><span class="o">.</span><span class="n">ostree</span><span class="p">:</span>
|
||||
<span class="n">sys_root</span> <span class="o">=</span> <span class="n">find_ostree_root</span><span class="p">(</span><span class="n">img_mount</span><span class="o">.</span><span class="n">mount_dir</span><span class="p">)</span>
|
||||
<span class="n">mounted_sysroot_boot_dir</span> <span class="o">=</span> <span class="n">mount_boot_part_over_root</span><span class="p">(</span><span class="n">img_mount</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">opts</span><span class="o">.</span><span class="n">live_rootfs_keep_size</span><span class="p">:</span>
|
||||
<span class="n">size</span> <span class="o">=</span> <span class="n">img_mount</span><span class="o">.</span><span class="n">mount_size</span> <span class="o">/</span> <span class="mi">1024</span><span class="o">**</span><span class="mi">3</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">size</span> <span class="o">=</span> <span class="n">opts</span><span class="o">.</span><span class="n">live_rootfs_size</span> <span class="ow">or</span> <span class="kc">None</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"Creating live rootfs image"</span><span class="p">)</span>
|
||||
<span class="n">mkrootfsimg</span><span class="p">(</span><span class="n">img_mount</span><span class="o">.</span><span class="n">mount_dir</span><span class="p">,</span> <span class="n">rootfs_img</span><span class="p">,</span> <span class="s2">"LiveOS"</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="n">size</span><span class="p">,</span> <span class="n">sysroot</span><span class="o">=</span><span class="n">sys_root</span><span class="p">)</span>
|
||||
<span class="k">finally</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="n">mounted_sysroot_boot_dir</span><span class="p">:</span>
|
||||
<span class="n">umount</span><span class="p">(</span><span class="n">mounted_sysroot_boot_dir</span><span class="p">)</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">"sys_root = </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">sys_root</span><span class="p">)</span>
|
||||
|
||||
<span class="c1"># Make sure free blocks are actually zeroed so it will compress</span>
|
||||
<span class="n">rc</span> <span class="o">=</span> <span class="n">execWithRedirect</span><span class="p">(</span><span class="s2">"/usr/sbin/fsck.ext4"</span><span class="p">,</span> <span class="p">[</span><span class="s2">"-y"</span><span class="p">,</span> <span class="s2">"-f"</span><span class="p">,</span> <span class="s2">"-E"</span><span class="p">,</span> <span class="s2">"discard"</span><span class="p">,</span> <span class="n">rootfs_img</span><span class="p">])</span>
|
||||
<span class="k">if</span> <span class="n">rc</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">:</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="s2">"Problem zeroing free blocks of </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">disk_img</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="kc">None</span>
|
||||
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"Packing live rootfs image"</span><span class="p">)</span>
|
||||
<span class="n">add_pxe_args</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="n">live_image_name</span> <span class="o">=</span> <span class="s2">"live-rootfs.squashfs.img"</span>
|
||||
<span class="n">compression</span><span class="p">,</span> <span class="n">compressargs</span> <span class="o">=</span> <span class="n">squashfs_args</span><span class="p">(</span><span class="n">opts</span><span class="p">)</span>
|
||||
<span class="n">rc</span> <span class="o">=</span> <span class="n">mksquashfs</span><span class="p">(</span><span class="n">squashfs_root_dir</span><span class="p">,</span> <span class="n">joinpaths</span><span class="p">(</span><span class="n">work_dir</span><span class="p">,</span> <span class="n">live_image_name</span><span class="p">),</span> <span class="n">compression</span><span class="p">,</span> <span class="n">compressargs</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">rc</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">:</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="s2">"mksquashfs failed to create </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">live_image_name</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="kc">None</span>
|
||||
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"Rebuilding initramfs for live"</span><span class="p">)</span>
|
||||
<span class="k">with</span> <span class="n">Mount</span><span class="p">(</span><span class="n">rootfs_img</span><span class="p">,</span> <span class="n">opts</span><span class="o">=</span><span class="s2">"loop"</span><span class="p">)</span> <span class="k">as</span> <span class="n">mnt_dir</span><span class="p">:</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="n">mount</span><span class="p">(</span><span class="n">joinpaths</span><span class="p">(</span><span class="n">mnt_dir</span><span class="p">,</span> <span class="s2">"boot"</span><span class="p">),</span> <span class="n">opts</span><span class="o">=</span><span class="s2">"bind"</span><span class="p">,</span> <span class="n">mnt</span><span class="o">=</span><span class="n">joinpaths</span><span class="p">(</span><span class="n">mnt_dir</span><span class="p">,</span> <span class="n">sys_root</span><span class="p">,</span> <span class="s2">"boot"</span><span class="p">))</span>
|
||||
<span class="n">rebuild_initrds_for_live</span><span class="p">(</span><span class="n">opts</span><span class="p">,</span> <span class="n">joinpaths</span><span class="p">(</span><span class="n">mnt_dir</span><span class="p">,</span> <span class="n">sys_root</span><span class="p">),</span> <span class="n">work_dir</span><span class="p">)</span>
|
||||
<span class="k">finally</span><span class="p">:</span>
|
||||
<span class="n">umount</span><span class="p">(</span><span class="n">joinpaths</span><span class="p">(</span><span class="n">mnt_dir</span><span class="p">,</span> <span class="n">sys_root</span><span class="p">,</span> <span class="s2">"boot"</span><span class="p">),</span> <span class="n">delete</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
|
||||
|
||||
<span class="n">remove</span><span class="p">(</span><span class="n">squashfs_root_dir</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">opts</span><span class="o">.</span><span class="n">ostree</span><span class="p">:</span>
|
||||
<span class="n">add_pxe_args</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"ostree=/</span><span class="si">%s</span><span class="s2">"</span> <span class="o">%</span> <span class="n">sys_root</span><span class="p">)</span>
|
||||
<span class="n">template</span> <span class="o">=</span> <span class="n">joinpaths</span><span class="p">(</span><span class="n">opts</span><span class="o">.</span><span class="n">lorax_templates</span><span class="p">,</span> <span class="s2">"pxe-live/pxe-config.tmpl"</span><span class="p">)</span>
|
||||
<span class="n">create_pxe_config</span><span class="p">(</span><span class="n">template</span><span class="p">,</span> <span class="n">work_dir</span><span class="p">,</span> <span class="n">live_image_name</span><span class="p">,</span> <span class="n">add_pxe_args</span><span class="p">)</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">work_dir</span></div>
|
||||
|
||||
<div class="viewcode-block" id="check_kickstart"><a class="viewcode-back" href="../../pylorax.html#pylorax.creator.check_kickstart">[docs]</a><span class="k">def</span> <span class="nf">check_kickstart</span><span class="p">(</span><span class="n">ks</span><span class="p">,</span> <span class="n">opts</span><span class="p">):</span>
|
||||
<span class="sd">"""Check the parsed kickstart object for errors</span>
|
||||
|
||||
<span class="sd"> :param ks: Parsed Kickstart object</span>
|
||||
<span class="sd"> :type ks: pykickstart.parser.KickstartParser</span>
|
||||
<span class="sd"> :param opts: Commandline options to control the process</span>
|
||||
<span class="sd"> :type opts: Either a DataHolder or ArgumentParser</span>
|
||||
<span class="sd"> :returns: List of error strings or empty list</span>
|
||||
<span class="sd"> :rtype: list</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">errors</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">if</span> <span class="n">opts</span><span class="o">.</span><span class="n">no_virt</span> <span class="ow">and</span> <span class="n">ks</span><span class="o">.</span><span class="n">handler</span><span class="o">.</span><span class="n">method</span><span class="o">.</span><span class="n">method</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"url"</span><span class="p">,</span> <span class="s2">"nfs"</span><span class="p">)</span> \
|
||||
<span class="ow">and</span> <span class="ow">not</span> <span class="n">ks</span><span class="o">.</span><span class="n">handler</span><span class="o">.</span><span class="n">ostreesetup</span><span class="o">.</span><span class="n">seen</span><span class="p">:</span>
|
||||
<span class="n">errors</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"Only url, nfs and ostreesetup install methods are currently supported."</span>
|
||||
<span class="s2">"Please fix your kickstart file."</span> <span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">ks</span><span class="o">.</span><span class="n">handler</span><span class="o">.</span><span class="n">repo</span><span class="o">.</span><span class="n">seen</span> <span class="ow">and</span> <span class="n">ks</span><span class="o">.</span><span class="n">handler</span><span class="o">.</span><span class="n">method</span><span class="o">.</span><span class="n">method</span> <span class="o">!=</span> <span class="s2">"url"</span><span class="p">:</span>
|
||||
<span class="n">errors</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"repo can only be used with the url install method. Add url to your "</span>
|
||||
<span class="s2">"kickstart file."</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">ks</span><span class="o">.</span><span class="n">handler</span><span class="o">.</span><span class="n">method</span><span class="o">.</span><span class="n">method</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"url"</span><span class="p">,</span> <span class="s2">"nfs"</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">ks</span><span class="o">.</span><span class="n">handler</span><span class="o">.</span><span class="n">network</span><span class="o">.</span><span class="n">seen</span><span class="p">:</span>
|
||||
<span class="n">errors</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"The kickstart must activate networking if "</span>
|
||||
<span class="s2">"the url or nfs install method is used."</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">ks</span><span class="o">.</span><span class="n">handler</span><span class="o">.</span><span class="n">displaymode</span><span class="o">.</span><span class="n">displayMode</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="n">errors</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"The kickstart must not set a display mode (text, cmdline, "</span>
|
||||
<span class="s2">"graphical), this will interfere with livemedia-creator."</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">opts</span><span class="o">.</span><span class="n">make_fsimage</span> <span class="ow">or</span> <span class="p">(</span><span class="n">opts</span><span class="o">.</span><span class="n">make_pxe_live</span> <span class="ow">and</span> <span class="n">opts</span><span class="o">.</span><span class="n">no_virt</span><span class="p">):</span>
|
||||
<span class="c1"># Make sure the kickstart isn't using autopart and only has a / mountpoint</span>
|
||||
<span class="n">part_ok</span> <span class="o">=</span> <span class="ow">not</span> <span class="nb">any</span><span class="p">(</span><span class="n">p</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">ks</span><span class="o">.</span><span class="n">handler</span><span class="o">.</span><span class="n">partition</span><span class="o">.</span><span class="n">partitions</span>
|
||||
<span class="k">if</span> <span class="n">p</span><span class="o">.</span><span class="n">mountpoint</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">"/"</span><span class="p">,</span> <span class="s2">"swap"</span><span class="p">])</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">part_ok</span> <span class="ow">or</span> <span class="n">ks</span><span class="o">.</span><span class="n">handler</span><span class="o">.</span><span class="n">autopart</span><span class="o">.</span><span class="n">seen</span><span class="p">:</span>
|
||||
<span class="n">errors</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"Filesystem images must use a single / part, not autopart or "</span>
|
||||
<span class="s2">"multiple partitions. swap is allowed but not used."</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">opts</span><span class="o">.</span><span class="n">no_virt</span> <span class="ow">and</span> <span class="n">ks</span><span class="o">.</span><span class="n">handler</span><span class="o">.</span><span class="n">reboot</span><span class="o">.</span><span class="n">action</span> <span class="o">!=</span> <span class="n">KS_SHUTDOWN</span><span class="p">:</span>
|
||||
<span class="n">errors</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"The kickstart must include shutdown when using virt installation."</span><span class="p">)</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">errors</span></div>
|
||||
|
||||
<div class="viewcode-block" id="run_creator"><a class="viewcode-back" href="../../pylorax.html#pylorax.creator.run_creator">[docs]</a><span class="k">def</span> <span class="nf">run_creator</span><span class="p">(</span><span class="n">opts</span><span class="p">,</span> <span class="n">cancel_func</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
<span class="sd">"""Run the image creator process</span>
|
||||
|
||||
<span class="sd"> :param opts: Commandline options to control the process</span>
|
||||
<span class="sd"> :type opts: Either a DataHolder or ArgumentParser</span>
|
||||
<span class="sd"> :param cancel_func: Function that returns True to cancel build</span>
|
||||
<span class="sd"> :type cancel_func: function</span>
|
||||
<span class="sd"> :returns: The result directory and the disk image path.</span>
|
||||
<span class="sd"> :rtype: Tuple of str</span>
|
||||
|
||||
<span class="sd"> This function takes the opts arguments and creates the selected output image.</span>
|
||||
<span class="sd"> See the cmdline --help for livemedia-creator for the possible options</span>
|
||||
|
||||
<span class="sd"> (Yes, this is not ideal, but we can fix that later)</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">result_dir</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
|
||||
<span class="c1"># Parse the kickstart</span>
|
||||
<span class="k">if</span> <span class="n">opts</span><span class="o">.</span><span class="n">ks</span><span class="p">:</span>
|
||||
<span class="n">ks_version</span> <span class="o">=</span> <span class="n">makeVersion</span><span class="p">()</span>
|
||||
<span class="n">ks</span> <span class="o">=</span> <span class="n">KickstartParser</span><span class="p">(</span><span class="n">ks_version</span><span class="p">,</span> <span class="n">errorsAreFatal</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">missingIncludeIsFatal</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
|
||||
<span class="n">ks</span><span class="o">.</span><span class="n">readKickstart</span><span class="p">(</span><span class="n">opts</span><span class="o">.</span><span class="n">ks</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
|
||||
|
||||
<span class="c1"># live iso usually needs dracut-live so warn the user if it is missing</span>
|
||||
<span class="k">if</span> <span class="n">opts</span><span class="o">.</span><span class="n">ks</span> <span class="ow">and</span> <span class="n">opts</span><span class="o">.</span><span class="n">make_iso</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="s2">"dracut-live"</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">ks</span><span class="o">.</span><span class="n">handler</span><span class="o">.</span><span class="n">packages</span><span class="o">.</span><span class="n">packageList</span><span class="p">:</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="s2">"dracut-live package is missing from the kickstart."</span><span class="p">)</span>
|
||||
<span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span><span class="s2">"dracut-live package is missing from the kickstart."</span><span class="p">)</span>
|
||||
|
||||
<span class="c1"># Make the disk or filesystem image</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">opts</span><span class="o">.</span><span class="n">disk_image</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">opts</span><span class="o">.</span><span class="n">fs_image</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">opts</span><span class="o">.</span><span class="n">ks</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span><span class="s2">"Image creation requires a kickstart file"</span><span class="p">)</span>
|
||||
|
||||
<span class="c1"># Check the kickstart for problems</span>
|
||||
<span class="n">errors</span> <span class="o">=</span> <span class="n">check_kickstart</span><span class="p">(</span><span class="n">ks</span><span class="p">,</span> <span class="n">opts</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">errors</span><span class="p">:</span>
|
||||
<span class="nb">list</span><span class="p">(</span><span class="n">log</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">errors</span><span class="p">)</span>
|
||||
<span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">errors</span><span class="p">))</span>
|
||||
|
||||
<span class="c1"># Make the image. Output of this is either a partitioned disk image or a fsimage</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="n">disk_img</span> <span class="o">=</span> <span class="n">make_image</span><span class="p">(</span><span class="n">opts</span><span class="p">,</span> <span class="n">ks</span><span class="p">,</span> <span class="n">cancel_func</span><span class="o">=</span><span class="n">cancel_func</span><span class="p">)</span>
|
||||
<span class="k">except</span> <span class="n">InstallError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="s2">"ERROR: Image creation failed: </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">e</span><span class="p">)</span>
|
||||
<span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span><span class="s2">"Image creation failed: </span><span class="si">%s</span><span class="s2">"</span> <span class="o">%</span> <span class="n">e</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">opts</span><span class="o">.</span><span class="n">image_only</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="p">(</span><span class="n">result_dir</span><span class="p">,</span> <span class="n">disk_img</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">opts</span><span class="o">.</span><span class="n">make_iso</span><span class="p">:</span>
|
||||
<span class="n">work_dir</span> <span class="o">=</span> <span class="n">tempfile</span><span class="o">.</span><span class="n">mkdtemp</span><span class="p">(</span><span class="n">prefix</span><span class="o">=</span><span class="s2">"lmc-work-"</span><span class="p">)</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"working dir is </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">work_dir</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="p">(</span><span class="n">opts</span><span class="o">.</span><span class="n">fs_image</span> <span class="ow">or</span> <span class="n">opts</span><span class="o">.</span><span class="n">no_virt</span><span class="p">)</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">opts</span><span class="o">.</span><span class="n">disk_image</span><span class="p">:</span>
|
||||
<span class="c1"># Create iso from a filesystem image</span>
|
||||
<span class="n">disk_img</span> <span class="o">=</span> <span class="n">opts</span><span class="o">.</span><span class="n">fs_image</span> <span class="ow">or</span> <span class="n">disk_img</span>
|
||||
<span class="k">with</span> <span class="n">Mount</span><span class="p">(</span><span class="n">disk_img</span><span class="p">,</span> <span class="n">opts</span><span class="o">=</span><span class="s2">"loop"</span><span class="p">)</span> <span class="k">as</span> <span class="n">mount_dir</span><span class="p">:</span>
|
||||
<span class="n">rc</span> <span class="o">=</span> <span class="n">make_runtime</span><span class="p">(</span><span class="n">opts</span><span class="p">,</span> <span class="n">mount_dir</span><span class="p">,</span> <span class="n">work_dir</span><span class="p">,</span> <span class="n">calculate_disk_size</span><span class="p">(</span><span class="n">opts</span><span class="p">,</span> <span class="n">ks</span><span class="p">)</span><span class="o">/</span><span class="mf">1024.0</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">rc</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">:</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="s2">"make_runtime failed with rc = </span><span class="si">%d</span><span class="s2">. See program.log"</span><span class="p">,</span> <span class="n">rc</span><span class="p">)</span>
|
||||
<span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span><span class="s2">"make_runtime failed with rc = </span><span class="si">%d</span><span class="s2">"</span> <span class="o">%</span> <span class="n">rc</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">cancel_func</span> <span class="ow">and</span> <span class="n">cancel_func</span><span class="p">():</span>
|
||||
<span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span><span class="s2">"ISO creation canceled"</span><span class="p">)</span>
|
||||
|
||||
<span class="n">result_dir</span> <span class="o">=</span> <span class="n">make_livecd</span><span class="p">(</span><span class="n">opts</span><span class="p">,</span> <span class="n">mount_dir</span><span class="p">,</span> <span class="n">work_dir</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="c1"># Create iso from a partitioned disk image</span>
|
||||
<span class="n">disk_img</span> <span class="o">=</span> <span class="n">opts</span><span class="o">.</span><span class="n">disk_image</span> <span class="ow">or</span> <span class="n">disk_img</span>
|
||||
<span class="k">with</span> <span class="n">PartitionMount</span><span class="p">(</span><span class="n">disk_img</span><span class="p">)</span> <span class="k">as</span> <span class="n">img_mount</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="n">img_mount</span> <span class="ow">and</span> <span class="n">img_mount</span><span class="o">.</span><span class="n">mount_dir</span><span class="p">:</span>
|
||||
<span class="n">rc</span> <span class="o">=</span> <span class="n">make_runtime</span><span class="p">(</span><span class="n">opts</span><span class="p">,</span> <span class="n">img_mount</span><span class="o">.</span><span class="n">mount_dir</span><span class="p">,</span> <span class="n">work_dir</span><span class="p">,</span> <span class="n">calculate_disk_size</span><span class="p">(</span><span class="n">opts</span><span class="p">,</span> <span class="n">ks</span><span class="p">)</span><span class="o">/</span><span class="mf">1024.0</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">rc</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">:</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="s2">"make_runtime failed with rc = </span><span class="si">%d</span><span class="s2">. See program.log"</span><span class="p">,</span> <span class="n">rc</span><span class="p">)</span>
|
||||
<span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span><span class="s2">"make_runtime failed with rc = </span><span class="si">%d</span><span class="s2">"</span> <span class="o">%</span> <span class="n">rc</span><span class="p">)</span>
|
||||
<span class="n">result_dir</span> <span class="o">=</span> <span class="n">make_livecd</span><span class="p">(</span><span class="n">opts</span><span class="p">,</span> <span class="n">img_mount</span><span class="o">.</span><span class="n">mount_dir</span><span class="p">,</span> <span class="n">work_dir</span><span class="p">)</span>
|
||||
|
||||
<span class="c1"># --iso-only removes the extra build artifacts, keeping only the boot.iso</span>
|
||||
<span class="k">if</span> <span class="n">opts</span><span class="o">.</span><span class="n">iso_only</span> <span class="ow">and</span> <span class="n">result_dir</span><span class="p">:</span>
|
||||
<span class="n">boot_iso</span> <span class="o">=</span> <span class="n">joinpaths</span><span class="p">(</span><span class="n">result_dir</span><span class="p">,</span> <span class="s2">"images/boot.iso"</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="n">boot_iso</span><span class="p">):</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="s2">"</span><span class="si">%s</span><span class="s2"> is missing, skipping --iso-only."</span><span class="p">,</span> <span class="n">boot_iso</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">iso_dir</span> <span class="o">=</span> <span class="n">tempfile</span><span class="o">.</span><span class="n">mkdtemp</span><span class="p">(</span><span class="n">prefix</span><span class="o">=</span><span class="s2">"lmc-result-"</span><span class="p">)</span>
|
||||
<span class="n">dest_file</span> <span class="o">=</span> <span class="n">joinpaths</span><span class="p">(</span><span class="n">iso_dir</span><span class="p">,</span> <span class="n">opts</span><span class="o">.</span><span class="n">iso_name</span> <span class="ow">or</span> <span class="s2">"boot.iso"</span><span class="p">)</span>
|
||||
<span class="n">shutil</span><span class="o">.</span><span class="n">move</span><span class="p">(</span><span class="n">boot_iso</span><span class="p">,</span> <span class="n">dest_file</span><span class="p">)</span>
|
||||
<span class="n">shutil</span><span class="o">.</span><span class="n">rmtree</span><span class="p">(</span><span class="n">result_dir</span><span class="p">)</span>
|
||||
<span class="n">result_dir</span> <span class="o">=</span> <span class="n">iso_dir</span>
|
||||
|
||||
<span class="c1"># cleanup the mess</span>
|
||||
<span class="c1"># cleanup work_dir?</span>
|
||||
<span class="k">if</span> <span class="n">disk_img</span> <span class="ow">and</span> <span class="ow">not</span> <span class="p">(</span><span class="n">opts</span><span class="o">.</span><span class="n">keep_image</span> <span class="ow">or</span> <span class="n">opts</span><span class="o">.</span><span class="n">disk_image</span> <span class="ow">or</span> <span class="n">opts</span><span class="o">.</span><span class="n">fs_image</span><span class="p">):</span>
|
||||
<span class="n">os</span><span class="o">.</span><span class="n">unlink</span><span class="p">(</span><span class="n">disk_img</span><span class="p">)</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"Disk image erased"</span><span class="p">)</span>
|
||||
<span class="n">disk_img</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
<span class="k">elif</span> <span class="n">opts</span><span class="o">.</span><span class="n">make_appliance</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">opts</span><span class="o">.</span><span class="n">ks</span><span class="p">:</span>
|
||||
<span class="n">networks</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">networks</span> <span class="o">=</span> <span class="n">ks</span><span class="o">.</span><span class="n">handler</span><span class="o">.</span><span class="n">network</span><span class="o">.</span><span class="n">network</span>
|
||||
<span class="n">make_appliance</span><span class="p">(</span><span class="n">opts</span><span class="o">.</span><span class="n">disk_image</span> <span class="ow">or</span> <span class="n">disk_img</span><span class="p">,</span> <span class="n">opts</span><span class="o">.</span><span class="n">app_name</span><span class="p">,</span>
|
||||
<span class="n">opts</span><span class="o">.</span><span class="n">app_template</span><span class="p">,</span> <span class="n">opts</span><span class="o">.</span><span class="n">app_file</span><span class="p">,</span> <span class="n">networks</span><span class="p">,</span> <span class="n">opts</span><span class="o">.</span><span class="n">ram</span><span class="p">,</span>
|
||||
<span class="n">opts</span><span class="o">.</span><span class="n">vcpus</span> <span class="ow">or</span> <span class="mi">1</span><span class="p">,</span> <span class="n">opts</span><span class="o">.</span><span class="n">arch</span><span class="p">,</span> <span class="n">opts</span><span class="o">.</span><span class="n">title</span><span class="p">,</span> <span class="n">opts</span><span class="o">.</span><span class="n">project</span><span class="p">,</span> <span class="n">opts</span><span class="o">.</span><span class="n">releasever</span><span class="p">)</span>
|
||||
<span class="k">elif</span> <span class="n">opts</span><span class="o">.</span><span class="n">make_pxe_live</span><span class="p">:</span>
|
||||
<span class="n">work_dir</span> <span class="o">=</span> <span class="n">tempfile</span><span class="o">.</span><span class="n">mkdtemp</span><span class="p">(</span><span class="n">prefix</span><span class="o">=</span><span class="s2">"lmc-work-"</span><span class="p">)</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"working dir is </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">work_dir</span><span class="p">)</span>
|
||||
<span class="n">disk_img</span> <span class="o">=</span> <span class="n">opts</span><span class="o">.</span><span class="n">fs_image</span> <span class="ow">or</span> <span class="n">opts</span><span class="o">.</span><span class="n">disk_image</span> <span class="ow">or</span> <span class="n">disk_img</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">"disk image is </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">disk_img</span><span class="p">)</span>
|
||||
|
||||
<span class="n">result_dir</span> <span class="o">=</span> <span class="n">make_live_images</span><span class="p">(</span><span class="n">opts</span><span class="p">,</span> <span class="n">work_dir</span><span class="p">,</span> <span class="n">disk_img</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">result_dir</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="s2">"Creating PXE live image failed."</span><span class="p">)</span>
|
||||
<span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span><span class="s2">"Creating PXE live image failed."</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">opts</span><span class="o">.</span><span class="n">result_dir</span> <span class="o">!=</span> <span class="n">opts</span><span class="o">.</span><span class="n">tmp</span> <span class="ow">and</span> <span class="n">result_dir</span><span class="p">:</span>
|
||||
<span class="n">copytree</span><span class="p">(</span><span class="n">result_dir</span><span class="p">,</span> <span class="n">opts</span><span class="o">.</span><span class="n">result_dir</span><span class="p">,</span> <span class="n">preserve</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
|
||||
<span class="n">shutil</span><span class="o">.</span><span class="n">rmtree</span><span class="p">(</span><span class="n">result_dir</span><span class="p">)</span>
|
||||
<span class="n">result_dir</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
|
||||
<span class="k">return</span> <span class="p">(</span><span class="n">result_dir</span><span class="p">,</span> <span class="n">disk_img</span><span class="p">)</span></div>
|
||||
</pre></div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<footer>
|
||||
|
||||
<hr/>
|
||||
|
||||
<div role="contentinfo">
|
||||
<p>© Copyright 2018, Red Hat, Inc..</p>
|
||||
</div>
|
||||
|
||||
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
|
||||
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
|
||||
provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||||
|
||||
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
<script>
|
||||
jQuery(function () {
|
||||
SphinxRtdTheme.Navigation.enable(true);
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,57 +1,50 @@
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
|
||||
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
|
||||
<html class="writer-html5" lang="en" >
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>pylorax.decorators — Lorax 28.2 documentation</title>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<meta charset="utf-8" />
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
|
||||
<title>pylorax.decorators — Lorax 35.1 documentation</title>
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
|
||||
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="index" title="Index"
|
||||
href="../../genindex.html"/>
|
||||
<link rel="search" title="Search" href="../../search.html"/>
|
||||
<link rel="top" title="Lorax 28.2 documentation" href="../../index.html"/>
|
||||
<link rel="up" title="pylorax" href="../pylorax.html"/>
|
||||
|
||||
|
||||
<script src="../../_static/js/modernizr.min.js"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
|
||||
<script src="../../_static/jquery.js"></script>
|
||||
<script src="../../_static/underscore.js"></script>
|
||||
<script src="../../_static/doctools.js"></script>
|
||||
|
||||
<script type="text/javascript" src="../../_static/js/theme.js"></script>
|
||||
|
||||
|
||||
<link rel="index" title="Index" href="../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../search.html" />
|
||||
</head>
|
||||
|
||||
<body class="wy-body-for-nav" role="document">
|
||||
<body class="wy-body-for-nav">
|
||||
|
||||
|
||||
<div class="wy-grid-for-nav">
|
||||
|
||||
|
||||
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
|
||||
<div class="wy-side-scroll">
|
||||
<div class="wy-side-nav-search">
|
||||
<div class="wy-side-nav-search" >
|
||||
|
||||
|
||||
|
||||
@ -65,7 +58,7 @@
|
||||
|
||||
|
||||
<div class="version">
|
||||
28.2
|
||||
35.1
|
||||
</div>
|
||||
|
||||
|
||||
@ -82,6 +75,7 @@
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
|
||||
|
||||
|
||||
@ -94,20 +88,22 @@
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../intro.html#before-lorax">Before Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../lorax.html">Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../livemedia-creator.html">livemedia-creator</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../mkksiso.html">mkksiso</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../product-images.html">Product and Updates Images</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../modules.html">pylorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../modules.html">src</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
|
||||
|
||||
|
||||
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
|
||||
<nav class="wy-nav-top" aria-label="top navigation">
|
||||
|
||||
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
||||
<a href="../../index.html">Lorax</a>
|
||||
@ -115,8 +111,8 @@
|
||||
</nav>
|
||||
|
||||
|
||||
|
||||
<div class="wy-nav-content">
|
||||
|
||||
<div class="rst-content">
|
||||
|
||||
|
||||
@ -134,11 +130,14 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div role="navigation" aria-label="breadcrumbs navigation">
|
||||
|
||||
<ul class="wy-breadcrumbs">
|
||||
|
||||
<li><a href="../../index.html">Docs</a> »</li>
|
||||
<li><a href="../../index.html" class="icon icon-home"></a> »</li>
|
||||
|
||||
<li><a href="../index.html">Module code</a> »</li>
|
||||
|
||||
@ -149,8 +148,6 @@
|
||||
|
||||
<li class="wy-breadcrumbs-aside">
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
@ -195,25 +192,28 @@
|
||||
</pre></div>
|
||||
|
||||
</div>
|
||||
<div class="articleComments">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<footer>
|
||||
|
||||
|
||||
<hr/>
|
||||
|
||||
<div role="contentinfo">
|
||||
<p>
|
||||
© Copyright 2015, Red Hat, Inc..
|
||||
© Copyright 2018, Red Hat, Inc..
|
||||
|
||||
</p>
|
||||
</div>
|
||||
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||||
|
||||
|
||||
|
||||
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
|
||||
|
||||
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
|
||||
|
||||
provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||||
|
||||
</footer>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -222,38 +222,16 @@
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
var DOCUMENTATION_OPTIONS = {
|
||||
URL_ROOT:'../../',
|
||||
VERSION:'28.2',
|
||||
COLLAPSE_INDEX:false,
|
||||
FILE_SUFFIX:'.html',
|
||||
HAS_SOURCE: true,
|
||||
SOURCELINK_SUFFIX: '.txt'
|
||||
};
|
||||
</script>
|
||||
<script type="text/javascript" src="../../_static/jquery.js"></script>
|
||||
<script type="text/javascript" src="../../_static/underscore.js"></script>
|
||||
<script type="text/javascript" src="../../_static/doctools.js"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript" src="../../_static/js/theme.js"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
jQuery(function () {
|
||||
SphinxRtdTheme.StickyNav.enable();
|
||||
SphinxRtdTheme.Navigation.enable(true);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,76 +1,31 @@
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
|
||||
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
|
||||
<html class="writer-html5" lang="en" >
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>pylorax.discinfo — Lorax 28.2 documentation</title>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pylorax.discinfo — Lorax 36.0 documentation</title>
|
||||
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
|
||||
<link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="index" title="Index"
|
||||
href="../../genindex.html"/>
|
||||
<link rel="search" title="Search" href="../../search.html"/>
|
||||
<link rel="top" title="Lorax 28.2 documentation" href="../../index.html"/>
|
||||
<link rel="up" title="pylorax" href="../pylorax.html"/>
|
||||
|
||||
|
||||
<script src="../../_static/js/modernizr.min.js"></script>
|
||||
|
||||
<script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
|
||||
<script src="../../_static/jquery.js"></script>
|
||||
<script src="../../_static/underscore.js"></script>
|
||||
<script src="../../_static/doctools.js"></script>
|
||||
<script src="../../_static/js/theme.js"></script>
|
||||
<link rel="index" title="Index" href="../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../search.html" />
|
||||
</head>
|
||||
|
||||
<body class="wy-body-for-nav" role="document">
|
||||
|
||||
|
||||
<body class="wy-body-for-nav">
|
||||
<div class="wy-grid-for-nav">
|
||||
|
||||
|
||||
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
|
||||
<div class="wy-side-scroll">
|
||||
<div class="wy-side-nav-search">
|
||||
|
||||
|
||||
|
||||
<div class="wy-side-nav-search" >
|
||||
<a href="../../index.html" class="icon icon-home"> Lorax
|
||||
|
||||
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="version">
|
||||
28.2
|
||||
36.0
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div role="search">
|
||||
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
|
||||
<input type="text" name="q" placeholder="Search docs" />
|
||||
@ -78,84 +33,37 @@
|
||||
<input type="hidden" name="area" value="default" />
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../intro.html">Introduction to Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../intro.html#before-lorax">Before Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../lorax.html">Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../livemedia-creator.html">livemedia-creator</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../mkksiso.html">mkksiso</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../product-images.html">Product and Updates Images</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../modules.html">pylorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../modules.html">src</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
|
||||
|
||||
|
||||
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
|
||||
|
||||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
|
||||
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
||||
<a href="../../index.html">Lorax</a>
|
||||
|
||||
</nav>
|
||||
|
||||
|
||||
|
||||
<div class="wy-nav-content">
|
||||
<div class="rst-content">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div role="navigation" aria-label="breadcrumbs navigation">
|
||||
|
||||
<div role="navigation" aria-label="Page navigation">
|
||||
<ul class="wy-breadcrumbs">
|
||||
|
||||
<li><a href="../../index.html">Docs</a> »</li>
|
||||
|
||||
<li><a href="../../index.html" class="icon icon-home"></a> »</li>
|
||||
<li><a href="../index.html">Module code</a> »</li>
|
||||
|
||||
<li><a href="../pylorax.html">pylorax</a> »</li>
|
||||
|
||||
<li>pylorax.discinfo</li>
|
||||
|
||||
|
||||
<li class="wy-breadcrumbs-aside">
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
<hr/>
|
||||
</div>
|
||||
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
|
||||
@ -186,83 +94,54 @@
|
||||
<span class="kn">import</span> <span class="nn">logging</span>
|
||||
<span class="n">logger</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="s2">"pylorax.discinfo"</span><span class="p">)</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">os</span>
|
||||
<span class="kn">import</span> <span class="nn">time</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="DiscInfo"><a class="viewcode-back" href="../../pylorax.html#pylorax.discinfo.DiscInfo">[docs]</a><span class="k">class</span> <span class="nc">DiscInfo</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">release</span><span class="p">,</span> <span class="n">basearch</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">release</span><span class="p">,</span> <span class="n">basearch</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">release</span> <span class="o">=</span> <span class="n">release</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">basearch</span> <span class="o">=</span> <span class="n">basearch</span>
|
||||
|
||||
<div class="viewcode-block" id="DiscInfo.write"><a class="viewcode-back" href="../../pylorax.html#pylorax.discinfo.DiscInfo.write">[docs]</a> <span class="k">def</span> <span class="nf">write</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">outfile</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="s1">'SOURCE_DATE_EPOCH'</span> <span class="ow">in</span> <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">:</span>
|
||||
<span class="n">timestamp</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">[</span><span class="s1">'SOURCE_DATE_EPOCH'</span><span class="p">])</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">timestamp</span> <span class="o">=</span> <span class="n">time</span><span class="o">.</span><span class="n">time</span><span class="p">()</span>
|
||||
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"writing .discinfo file"</span><span class="p">)</span>
|
||||
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">outfile</span><span class="p">,</span> <span class="s2">"w"</span><span class="p">)</span> <span class="k">as</span> <span class="n">fobj</span><span class="p">:</span>
|
||||
<span class="n">fobj</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s2">"</span><span class="si">{0:f}</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">time</span><span class="o">.</span><span class="n">time</span><span class="p">()))</span>
|
||||
<span class="n">fobj</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s2">"</span><span class="si">{0:f}</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">timestamp</span><span class="p">))</span>
|
||||
<span class="n">fobj</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s2">"</span><span class="si">{0.release}</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="p">))</span>
|
||||
<span class="n">fobj</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s2">"</span><span class="si">{0.basearch}</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="p">))</span></div></div>
|
||||
</pre></div>
|
||||
|
||||
</div>
|
||||
<div class="articleComments">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<footer>
|
||||
|
||||
|
||||
<hr/>
|
||||
|
||||
<div role="contentinfo">
|
||||
<p>
|
||||
© Copyright 2015, Red Hat, Inc..
|
||||
|
||||
</p>
|
||||
<p>© Copyright 2018, Red Hat, Inc..</p>
|
||||
</div>
|
||||
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||||
|
||||
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
|
||||
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
|
||||
provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||||
|
||||
|
||||
</footer>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
var DOCUMENTATION_OPTIONS = {
|
||||
URL_ROOT:'../../',
|
||||
VERSION:'28.2',
|
||||
COLLAPSE_INDEX:false,
|
||||
FILE_SUFFIX:'.html',
|
||||
HAS_SOURCE: true,
|
||||
SOURCELINK_SUFFIX: '.txt'
|
||||
};
|
||||
</script>
|
||||
<script type="text/javascript" src="../../_static/jquery.js"></script>
|
||||
<script type="text/javascript" src="../../_static/underscore.js"></script>
|
||||
<script type="text/javascript" src="../../_static/doctools.js"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript" src="../../_static/js/theme.js"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
<script>
|
||||
jQuery(function () {
|
||||
SphinxRtdTheme.StickyNav.enable();
|
||||
SphinxRtdTheme.Navigation.enable(true);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
291
docs/html/_modules/pylorax/dnfbase.html
Normal file
@ -0,0 +1,291 @@
|
||||
<!DOCTYPE html>
|
||||
<html class="writer-html5" lang="en" >
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pylorax.dnfbase — Lorax 36.4 documentation</title>
|
||||
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
|
||||
<link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
|
||||
|
||||
<script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
|
||||
<script src="../../_static/jquery.js"></script>
|
||||
<script src="../../_static/underscore.js"></script>
|
||||
<script src="../../_static/doctools.js"></script>
|
||||
<script src="../../_static/js/theme.js"></script>
|
||||
<link rel="index" title="Index" href="../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../search.html" />
|
||||
</head>
|
||||
|
||||
<body class="wy-body-for-nav">
|
||||
<div class="wy-grid-for-nav">
|
||||
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
|
||||
<div class="wy-side-scroll">
|
||||
<div class="wy-side-nav-search" >
|
||||
<a href="../../index.html" class="icon icon-home"> Lorax
|
||||
</a>
|
||||
<div class="version">
|
||||
36.4
|
||||
</div>
|
||||
<div role="search">
|
||||
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
|
||||
<input type="text" name="q" placeholder="Search docs" />
|
||||
<input type="hidden" name="check_keywords" value="yes" />
|
||||
<input type="hidden" name="area" value="default" />
|
||||
</form>
|
||||
</div>
|
||||
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../intro.html">Introduction to Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../intro.html#before-lorax">Before Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../lorax.html">Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../livemedia-creator.html">livemedia-creator</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../mkksiso.html">mkksiso</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../product-images.html">Product and Updates Images</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../modules.html">src</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
|
||||
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
||||
<a href="../../index.html">Lorax</a>
|
||||
</nav>
|
||||
|
||||
<div class="wy-nav-content">
|
||||
<div class="rst-content">
|
||||
<div role="navigation" aria-label="Page navigation">
|
||||
<ul class="wy-breadcrumbs">
|
||||
<li><a href="../../index.html" class="icon icon-home"></a> »</li>
|
||||
<li><a href="../index.html">Module code</a> »</li>
|
||||
<li><a href="../pylorax.html">pylorax</a> »</li>
|
||||
<li>pylorax.dnfbase</li>
|
||||
<li class="wy-breadcrumbs-aside">
|
||||
</li>
|
||||
</ul>
|
||||
<hr/>
|
||||
</div>
|
||||
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
|
||||
<div itemprop="articleBody">
|
||||
|
||||
<h1>Source code for pylorax.dnfbase</h1><div class="highlight"><pre>
|
||||
<span></span><span class="c1"># Copyright (C) 2018 Red Hat, Inc.</span>
|
||||
<span class="c1">#</span>
|
||||
<span class="c1"># This program is free software; you can redistribute it and/or modify</span>
|
||||
<span class="c1"># it under the terms of the GNU General Public License as published by</span>
|
||||
<span class="c1"># the Free Software Foundation; either version 2 of the License, or</span>
|
||||
<span class="c1"># (at your option) any later version.</span>
|
||||
<span class="c1">#</span>
|
||||
<span class="c1"># This program is distributed in the hope that it will be useful,</span>
|
||||
<span class="c1"># but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
<span class="c1"># MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
|
||||
<span class="c1"># GNU General Public License for more details.</span>
|
||||
<span class="c1">#</span>
|
||||
<span class="c1"># You should have received a copy of the GNU General Public License</span>
|
||||
<span class="c1"># along with this program. If not, see <http://www.gnu.org/licenses/>.</span>
|
||||
<span class="c1">#</span>
|
||||
<span class="kn">import</span> <span class="nn">logging</span>
|
||||
<span class="n">log</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="s2">"pylorax"</span><span class="p">)</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">dnf</span>
|
||||
<span class="kn">import</span> <span class="nn">os</span>
|
||||
<span class="kn">import</span> <span class="nn">shutil</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">pylorax</span> <span class="kn">import</span> <span class="n">DEFAULT_PLATFORM_ID</span><span class="p">,</span> <span class="n">DEFAULT_RELEASEVER</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.sysutils</span> <span class="kn">import</span> <span class="n">flatconfig</span>
|
||||
|
||||
<div class="viewcode-block" id="get_dnf_base_object"><a class="viewcode-back" href="../../pylorax.html#pylorax.dnfbase.get_dnf_base_object">[docs]</a><span class="k">def</span> <span class="nf">get_dnf_base_object</span><span class="p">(</span><span class="n">installroot</span><span class="p">,</span> <span class="n">sources</span><span class="p">,</span> <span class="n">mirrorlists</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">repos</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
|
||||
<span class="n">enablerepos</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">disablerepos</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
|
||||
<span class="n">tempdir</span><span class="o">=</span><span class="s2">"/var/tmp"</span><span class="p">,</span> <span class="n">proxy</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">releasever</span><span class="o">=</span><span class="n">DEFAULT_RELEASEVER</span><span class="p">,</span>
|
||||
<span class="n">cachedir</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">logdir</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">sslverify</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">dnfplugins</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
<span class="sd">""" Create a dnf Base object and setup the repositories and installroot</span>
|
||||
|
||||
<span class="sd"> :param string installroot: Full path to the installroot</span>
|
||||
<span class="sd"> :param list sources: List of source repo urls to use for the installation</span>
|
||||
<span class="sd"> :param list enablerepos: List of repo names to enable</span>
|
||||
<span class="sd"> :param list disablerepos: List of repo names to disable</span>
|
||||
<span class="sd"> :param list mirrorlist: List of mirrors to use</span>
|
||||
<span class="sd"> :param string tempdir: Path of temporary directory</span>
|
||||
<span class="sd"> :param string proxy: http proxy to use when fetching packages</span>
|
||||
<span class="sd"> :param string releasever: Release version to pass to dnf</span>
|
||||
<span class="sd"> :param string cachedir: Directory to use for caching packages</span>
|
||||
<span class="sd"> :param bool noverifyssl: Set to True to ignore the CA of ssl certs. eg. use self-signed ssl for https repos.</span>
|
||||
|
||||
<span class="sd"> If tempdir is not set /var/tmp is used.</span>
|
||||
<span class="sd"> If cachedir is None a dnf.cache directory is created inside tmpdir</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">def</span> <span class="nf">sanitize_repo</span><span class="p">(</span><span class="n">repo</span><span class="p">):</span>
|
||||
<span class="sd">"""Convert bare paths to file:/// URIs, and silently reject protocols unhandled by yum"""</span>
|
||||
<span class="k">if</span> <span class="n">repo</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"/"</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="s2">"file://</span><span class="si">{0}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">repo</span><span class="p">)</span>
|
||||
<span class="k">elif</span> <span class="nb">any</span><span class="p">(</span><span class="n">repo</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="p">(</span><span class="s1">'http://'</span><span class="p">,</span> <span class="s1">'https://'</span><span class="p">,</span> <span class="s1">'ftp://'</span><span class="p">,</span> <span class="s1">'file://'</span><span class="p">)):</span>
|
||||
<span class="k">return</span> <span class="n">repo</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="kc">None</span>
|
||||
|
||||
<span class="n">mirrorlists</span> <span class="o">=</span> <span class="n">mirrorlists</span> <span class="ow">or</span> <span class="p">[]</span>
|
||||
<span class="n">enablerepos</span> <span class="o">=</span> <span class="n">enablerepos</span> <span class="ow">or</span> <span class="p">[]</span>
|
||||
<span class="n">disablerepos</span> <span class="o">=</span> <span class="n">disablerepos</span> <span class="ow">or</span> <span class="p">[]</span>
|
||||
|
||||
<span class="c1"># sanitize the repositories</span>
|
||||
<span class="n">sources</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">sanitize_repo</span><span class="p">(</span><span class="n">r</span><span class="p">)</span> <span class="k">for</span> <span class="n">r</span> <span class="ow">in</span> <span class="n">sources</span><span class="p">)</span>
|
||||
<span class="n">mirrorlists</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">sanitize_repo</span><span class="p">(</span><span class="n">r</span><span class="p">)</span> <span class="k">for</span> <span class="n">r</span> <span class="ow">in</span> <span class="n">mirrorlists</span><span class="p">)</span>
|
||||
|
||||
<span class="c1"># remove invalid repositories</span>
|
||||
<span class="n">sources</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">r</span> <span class="k">for</span> <span class="n">r</span> <span class="ow">in</span> <span class="n">sources</span> <span class="k">if</span> <span class="n">r</span><span class="p">)</span>
|
||||
<span class="n">mirrorlists</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">r</span> <span class="k">for</span> <span class="n">r</span> <span class="ow">in</span> <span class="n">mirrorlists</span> <span class="k">if</span> <span class="n">r</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">cachedir</span><span class="p">:</span>
|
||||
<span class="n">cachedir</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">tempdir</span><span class="p">,</span> <span class="s2">"dnf.cache"</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isdir</span><span class="p">(</span><span class="n">cachedir</span><span class="p">):</span>
|
||||
<span class="n">os</span><span class="o">.</span><span class="n">mkdir</span><span class="p">(</span><span class="n">cachedir</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">logdir</span><span class="p">:</span>
|
||||
<span class="n">logdir</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">tempdir</span><span class="p">,</span> <span class="s2">"dnf.logs"</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isdir</span><span class="p">(</span><span class="n">logdir</span><span class="p">):</span>
|
||||
<span class="n">os</span><span class="o">.</span><span class="n">mkdir</span><span class="p">(</span><span class="n">logdir</span><span class="p">)</span>
|
||||
|
||||
<span class="n">dnfbase</span> <span class="o">=</span> <span class="n">dnf</span><span class="o">.</span><span class="n">Base</span><span class="p">()</span>
|
||||
<span class="c1"># Enable DNF pluings</span>
|
||||
<span class="c1"># NOTE: These come from the HOST system's environment</span>
|
||||
<span class="k">if</span> <span class="n">dnfplugins</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="n">dnfplugins</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"*"</span><span class="p">:</span>
|
||||
<span class="c1"># Enable them all</span>
|
||||
<span class="n">dnfbase</span><span class="o">.</span><span class="n">init_plugins</span><span class="p">()</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="c1"># Only enable the listed plugins</span>
|
||||
<span class="n">dnfbase</span><span class="o">.</span><span class="n">init_plugins</span><span class="p">(</span><span class="n">disabled_glob</span><span class="o">=</span><span class="p">[</span><span class="s2">"*"</span><span class="p">],</span> <span class="n">enable_plugins</span><span class="o">=</span><span class="n">dnfplugins</span><span class="p">)</span>
|
||||
<span class="n">conf</span> <span class="o">=</span> <span class="n">dnfbase</span><span class="o">.</span><span class="n">conf</span>
|
||||
<span class="n">conf</span><span class="o">.</span><span class="n">logdir</span> <span class="o">=</span> <span class="n">logdir</span>
|
||||
<span class="n">conf</span><span class="o">.</span><span class="n">cachedir</span> <span class="o">=</span> <span class="n">cachedir</span>
|
||||
|
||||
<span class="n">conf</span><span class="o">.</span><span class="n">install_weak_deps</span> <span class="o">=</span> <span class="kc">False</span>
|
||||
<span class="n">conf</span><span class="o">.</span><span class="n">releasever</span> <span class="o">=</span> <span class="n">releasever</span>
|
||||
<span class="n">conf</span><span class="o">.</span><span class="n">installroot</span> <span class="o">=</span> <span class="n">installroot</span>
|
||||
<span class="n">conf</span><span class="o">.</span><span class="n">prepend_installroot</span><span class="p">(</span><span class="s1">'persistdir'</span><span class="p">)</span>
|
||||
<span class="c1"># this is a weird 'AppendOption' thing that, when you set it,</span>
|
||||
<span class="c1"># actually appends. Doing this adds 'nodocs' to the existing list</span>
|
||||
<span class="c1"># of values, over in libdnf, it does not replace the existing values.</span>
|
||||
<span class="n">conf</span><span class="o">.</span><span class="n">tsflags</span> <span class="o">=</span> <span class="p">[</span><span class="s1">'nodocs'</span><span class="p">]</span>
|
||||
<span class="c1"># Log details about the solver</span>
|
||||
<span class="n">conf</span><span class="o">.</span><span class="n">debug_solver</span> <span class="o">=</span> <span class="kc">True</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">proxy</span><span class="p">:</span>
|
||||
<span class="n">conf</span><span class="o">.</span><span class="n">proxy</span> <span class="o">=</span> <span class="n">proxy</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">sslverify</span> <span class="o">==</span> <span class="kc">False</span><span class="p">:</span>
|
||||
<span class="n">conf</span><span class="o">.</span><span class="n">sslverify</span> <span class="o">=</span> <span class="kc">False</span>
|
||||
|
||||
<span class="c1"># DNF 3.2 needs to have module_platform_id set, otherwise depsolve won't work correctly</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="s2">"/etc/os-release"</span><span class="p">):</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">warning</span><span class="p">(</span><span class="s2">"/etc/os-release is missing, cannot determine platform id, falling back to </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">DEFAULT_PLATFORM_ID</span><span class="p">)</span>
|
||||
<span class="n">platform_id</span> <span class="o">=</span> <span class="n">DEFAULT_PLATFORM_ID</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">os_release</span> <span class="o">=</span> <span class="n">flatconfig</span><span class="p">(</span><span class="s2">"/etc/os-release"</span><span class="p">)</span>
|
||||
<span class="n">platform_id</span> <span class="o">=</span> <span class="n">os_release</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"PLATFORM_ID"</span><span class="p">,</span> <span class="n">DEFAULT_PLATFORM_ID</span><span class="p">)</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"Using </span><span class="si">%s</span><span class="s2"> for module_platform_id"</span><span class="p">,</span> <span class="n">platform_id</span><span class="p">)</span>
|
||||
<span class="n">conf</span><span class="o">.</span><span class="n">module_platform_id</span> <span class="o">=</span> <span class="n">platform_id</span>
|
||||
|
||||
<span class="c1"># Add .repo files</span>
|
||||
<span class="k">if</span> <span class="n">repos</span><span class="p">:</span>
|
||||
<span class="n">reposdir</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">tempdir</span><span class="p">,</span> <span class="s2">"dnf.repos"</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isdir</span><span class="p">(</span><span class="n">reposdir</span><span class="p">):</span>
|
||||
<span class="n">os</span><span class="o">.</span><span class="n">mkdir</span><span class="p">(</span><span class="n">reposdir</span><span class="p">)</span>
|
||||
<span class="k">for</span> <span class="n">r</span> <span class="ow">in</span> <span class="n">repos</span><span class="p">:</span>
|
||||
<span class="n">shutil</span><span class="o">.</span><span class="n">copy2</span><span class="p">(</span><span class="n">r</span><span class="p">,</span> <span class="n">reposdir</span><span class="p">)</span>
|
||||
<span class="n">conf</span><span class="o">.</span><span class="n">reposdir</span> <span class="o">=</span> <span class="p">[</span><span class="n">reposdir</span><span class="p">]</span>
|
||||
<span class="n">dnfbase</span><span class="o">.</span><span class="n">read_all_repos</span><span class="p">()</span>
|
||||
|
||||
<span class="c1"># add the sources</span>
|
||||
<span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">r</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">sources</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="s2">"SRPM"</span> <span class="ow">in</span> <span class="n">r</span> <span class="ow">or</span> <span class="s2">"srpm"</span> <span class="ow">in</span> <span class="n">r</span><span class="p">:</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"Skipping source repo: </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">r</span><span class="p">)</span>
|
||||
<span class="k">continue</span>
|
||||
<span class="n">repo_name</span> <span class="o">=</span> <span class="s2">"lorax-repo-</span><span class="si">%d</span><span class="s2">"</span> <span class="o">%</span> <span class="n">i</span>
|
||||
<span class="n">repo</span> <span class="o">=</span> <span class="n">dnf</span><span class="o">.</span><span class="n">repo</span><span class="o">.</span><span class="n">Repo</span><span class="p">(</span><span class="n">repo_name</span><span class="p">,</span> <span class="n">conf</span><span class="p">)</span>
|
||||
<span class="n">repo</span><span class="o">.</span><span class="n">baseurl</span> <span class="o">=</span> <span class="p">[</span><span class="n">r</span><span class="p">]</span>
|
||||
<span class="k">if</span> <span class="n">proxy</span><span class="p">:</span>
|
||||
<span class="n">repo</span><span class="o">.</span><span class="n">proxy</span> <span class="o">=</span> <span class="n">proxy</span>
|
||||
<span class="n">repo</span><span class="o">.</span><span class="n">enable</span><span class="p">()</span>
|
||||
<span class="n">dnfbase</span><span class="o">.</span><span class="n">repos</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">repo</span><span class="p">)</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"Added '</span><span class="si">%s</span><span class="s2">': </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">repo_name</span><span class="p">,</span> <span class="n">r</span><span class="p">)</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"Fetching metadata..."</span><span class="p">)</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="n">repo</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>
|
||||
<span class="k">except</span> <span class="n">dnf</span><span class="o">.</span><span class="n">exceptions</span><span class="o">.</span><span class="n">RepoError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="s2">"Error fetching metadata for </span><span class="si">%s</span><span class="s2">: </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">repo_name</span><span class="p">,</span> <span class="n">e</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="kc">None</span>
|
||||
|
||||
<span class="c1"># add the mirrorlists</span>
|
||||
<span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">r</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">mirrorlists</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="s2">"SRPM"</span> <span class="ow">in</span> <span class="n">r</span> <span class="ow">or</span> <span class="s2">"srpm"</span> <span class="ow">in</span> <span class="n">r</span><span class="p">:</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"Skipping source repo: </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">r</span><span class="p">)</span>
|
||||
<span class="k">continue</span>
|
||||
<span class="n">repo_name</span> <span class="o">=</span> <span class="s2">"lorax-mirrorlist-</span><span class="si">%d</span><span class="s2">"</span> <span class="o">%</span> <span class="n">i</span>
|
||||
<span class="n">repo</span> <span class="o">=</span> <span class="n">dnf</span><span class="o">.</span><span class="n">repo</span><span class="o">.</span><span class="n">Repo</span><span class="p">(</span><span class="n">repo_name</span><span class="p">,</span> <span class="n">conf</span><span class="p">)</span>
|
||||
<span class="n">repo</span><span class="o">.</span><span class="n">mirrorlist</span> <span class="o">=</span> <span class="n">r</span>
|
||||
<span class="k">if</span> <span class="n">proxy</span><span class="p">:</span>
|
||||
<span class="n">repo</span><span class="o">.</span><span class="n">proxy</span> <span class="o">=</span> <span class="n">proxy</span>
|
||||
<span class="n">repo</span><span class="o">.</span><span class="n">enable</span><span class="p">()</span>
|
||||
<span class="n">dnfbase</span><span class="o">.</span><span class="n">repos</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">repo</span><span class="p">)</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"Added '</span><span class="si">%s</span><span class="s2">': </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">repo_name</span><span class="p">,</span> <span class="n">r</span><span class="p">)</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"Fetching metadata..."</span><span class="p">)</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="n">repo</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>
|
||||
<span class="k">except</span> <span class="n">dnf</span><span class="o">.</span><span class="n">exceptions</span><span class="o">.</span><span class="n">RepoError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="s2">"Error fetching metadata for </span><span class="si">%s</span><span class="s2">: </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">repo_name</span><span class="p">,</span> <span class="n">e</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="kc">None</span>
|
||||
|
||||
<span class="c1"># Enable repos listed on the cmdline</span>
|
||||
<span class="k">for</span> <span class="n">r</span> <span class="ow">in</span> <span class="n">enablerepos</span><span class="p">:</span>
|
||||
<span class="n">repolist</span> <span class="o">=</span> <span class="n">dnfbase</span><span class="o">.</span><span class="n">repos</span><span class="o">.</span><span class="n">get_matching</span><span class="p">(</span><span class="n">r</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">repolist</span><span class="p">:</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">warning</span><span class="p">(</span><span class="s2">"</span><span class="si">%s</span><span class="s2"> is an unknown repo, not enabling it"</span><span class="p">,</span> <span class="n">r</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">repolist</span><span class="o">.</span><span class="n">enable</span><span class="p">()</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"Enabled repo </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">r</span><span class="p">)</span>
|
||||
|
||||
<span class="c1"># Disable repos listed on the cmdline</span>
|
||||
<span class="k">for</span> <span class="n">r</span> <span class="ow">in</span> <span class="n">disablerepos</span><span class="p">:</span>
|
||||
<span class="n">repolist</span> <span class="o">=</span> <span class="n">dnfbase</span><span class="o">.</span><span class="n">repos</span><span class="o">.</span><span class="n">get_matching</span><span class="p">(</span><span class="n">r</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">repolist</span><span class="p">:</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">warning</span><span class="p">(</span><span class="s2">"</span><span class="si">%s</span><span class="s2"> is an unknown repo, not disabling it"</span><span class="p">,</span> <span class="n">r</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">repolist</span><span class="o">.</span><span class="n">disable</span><span class="p">()</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"Disabled repo </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">r</span><span class="p">)</span>
|
||||
|
||||
<span class="n">dnfbase</span><span class="o">.</span><span class="n">fill_sack</span><span class="p">(</span><span class="n">load_system_repo</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
|
||||
<span class="n">dnfbase</span><span class="o">.</span><span class="n">read_comps</span><span class="p">()</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">dnfbase</span></div>
|
||||
</pre></div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<footer>
|
||||
|
||||
<hr/>
|
||||
|
||||
<div role="contentinfo">
|
||||
<p>© Copyright 2018, Red Hat, Inc..</p>
|
||||
</div>
|
||||
|
||||
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
|
||||
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
|
||||
provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||||
|
||||
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
<script>
|
||||
jQuery(function () {
|
||||
SphinxRtdTheme.Navigation.enable(true);
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,76 +1,31 @@
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
|
||||
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
|
||||
<html class="writer-html5" lang="en" >
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>pylorax.dnfhelper — Lorax 28.2 documentation</title>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pylorax.dnfhelper — Lorax 36.0 documentation</title>
|
||||
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
|
||||
<link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="index" title="Index"
|
||||
href="../../genindex.html"/>
|
||||
<link rel="search" title="Search" href="../../search.html"/>
|
||||
<link rel="top" title="Lorax 28.2 documentation" href="../../index.html"/>
|
||||
<link rel="up" title="pylorax" href="../pylorax.html"/>
|
||||
|
||||
|
||||
<script src="../../_static/js/modernizr.min.js"></script>
|
||||
|
||||
<script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
|
||||
<script src="../../_static/jquery.js"></script>
|
||||
<script src="../../_static/underscore.js"></script>
|
||||
<script src="../../_static/doctools.js"></script>
|
||||
<script src="../../_static/js/theme.js"></script>
|
||||
<link rel="index" title="Index" href="../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../search.html" />
|
||||
</head>
|
||||
|
||||
<body class="wy-body-for-nav" role="document">
|
||||
|
||||
|
||||
<body class="wy-body-for-nav">
|
||||
<div class="wy-grid-for-nav">
|
||||
|
||||
|
||||
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
|
||||
<div class="wy-side-scroll">
|
||||
<div class="wy-side-nav-search">
|
||||
|
||||
|
||||
|
||||
<div class="wy-side-nav-search" >
|
||||
<a href="../../index.html" class="icon icon-home"> Lorax
|
||||
|
||||
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="version">
|
||||
28.2
|
||||
36.0
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div role="search">
|
||||
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
|
||||
<input type="text" name="q" placeholder="Search docs" />
|
||||
@ -78,84 +33,37 @@
|
||||
<input type="hidden" name="area" value="default" />
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../intro.html">Introduction to Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../intro.html#before-lorax">Before Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../lorax.html">Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../livemedia-creator.html">livemedia-creator</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../mkksiso.html">mkksiso</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../product-images.html">Product and Updates Images</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../modules.html">pylorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../modules.html">src</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
|
||||
|
||||
|
||||
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
|
||||
|
||||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
|
||||
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
||||
<a href="../../index.html">Lorax</a>
|
||||
|
||||
</nav>
|
||||
|
||||
|
||||
|
||||
<div class="wy-nav-content">
|
||||
<div class="rst-content">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div role="navigation" aria-label="breadcrumbs navigation">
|
||||
|
||||
<div role="navigation" aria-label="Page navigation">
|
||||
<ul class="wy-breadcrumbs">
|
||||
|
||||
<li><a href="../../index.html">Docs</a> »</li>
|
||||
|
||||
<li><a href="../../index.html" class="icon icon-home"></a> »</li>
|
||||
<li><a href="../index.html">Module code</a> »</li>
|
||||
|
||||
<li><a href="../pylorax.html">pylorax</a> »</li>
|
||||
|
||||
<li>pylorax.dnfhelper</li>
|
||||
|
||||
|
||||
<li class="wy-breadcrumbs-aside">
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
<hr/>
|
||||
</div>
|
||||
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
|
||||
@ -187,6 +95,7 @@
|
||||
<span class="kn">import</span> <span class="nn">logging</span>
|
||||
<span class="n">logger</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="s2">"pylorax.dnfhelper"</span><span class="p">)</span>
|
||||
<span class="kn">import</span> <span class="nn">dnf</span>
|
||||
<span class="kn">import</span> <span class="nn">dnf.transaction</span>
|
||||
<span class="kn">import</span> <span class="nn">collections</span>
|
||||
<span class="kn">import</span> <span class="nn">time</span>
|
||||
<span class="kn">import</span> <span class="nn">pylorax.output</span> <span class="k">as</span> <span class="nn">output</span>
|
||||
@ -205,7 +114,7 @@
|
||||
|
||||
|
||||
<div class="viewcode-block" id="LoraxDownloadCallback"><a class="viewcode-back" href="../../pylorax.html#pylorax.dnfhelper.LoraxDownloadCallback">[docs]</a><span class="k">class</span> <span class="nc">LoraxDownloadCallback</span><span class="p">(</span><span class="n">dnf</span><span class="o">.</span><span class="n">callback</span><span class="o">.</span><span class="n">DownloadProgress</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">downloads</span> <span class="o">=</span> <span class="n">collections</span><span class="o">.</span><span class="n">defaultdict</span><span class="p">(</span><span class="nb">int</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">last_time</span> <span class="o">=</span> <span class="n">time</span><span class="o">.</span><span class="n">time</span><span class="p">()</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">total_files</span> <span class="o">=</span> <span class="mi">0</span>
|
||||
@ -252,12 +161,12 @@
|
||||
|
||||
|
||||
<div class="viewcode-block" id="LoraxRpmCallback"><a class="viewcode-back" href="../../pylorax.html#pylorax.dnfhelper.LoraxRpmCallback">[docs]</a><span class="k">class</span> <span class="nc">LoraxRpmCallback</span><span class="p">(</span><span class="n">dnf</span><span class="o">.</span><span class="n">callback</span><span class="o">.</span><span class="n">TransactionProgress</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">LoraxRpmCallback</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">()</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_last_ts</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
|
||||
<div class="viewcode-block" id="LoraxRpmCallback.progress"><a class="viewcode-back" href="../../pylorax.html#pylorax.dnfhelper.LoraxRpmCallback.progress">[docs]</a> <span class="k">def</span> <span class="nf">progress</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">package</span><span class="p">,</span> <span class="n">action</span><span class="p">,</span> <span class="n">ti_done</span><span class="p">,</span> <span class="n">ti_total</span><span class="p">,</span> <span class="n">ts_done</span><span class="p">,</span> <span class="n">ts_total</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="n">action</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">PKG_INSTALL</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="n">action</span> <span class="o">==</span> <span class="n">dnf</span><span class="o">.</span><span class="n">transaction</span><span class="o">.</span><span class="n">PKG_INSTALL</span><span class="p">:</span>
|
||||
<span class="c1"># do not report same package twice</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_last_ts</span> <span class="o">==</span> <span class="n">ts_done</span><span class="p">:</span>
|
||||
<span class="k">return</span>
|
||||
@ -265,7 +174,7 @@
|
||||
|
||||
<span class="n">msg</span> <span class="o">=</span> <span class="s1">'(</span><span class="si">%d</span><span class="s1">/</span><span class="si">%d</span><span class="s1">) </span><span class="si">%s</span><span class="s1">'</span> <span class="o">%</span> <span class="p">(</span><span class="n">ts_done</span><span class="p">,</span> <span class="n">ts_total</span><span class="p">,</span> <span class="n">package</span><span class="p">)</span>
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span>
|
||||
<span class="k">elif</span> <span class="n">action</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">TRANS_POST</span><span class="p">:</span>
|
||||
<span class="k">elif</span> <span class="n">action</span> <span class="o">==</span> <span class="n">dnf</span><span class="o">.</span><span class="n">transaction</span><span class="o">.</span><span class="n">TRANS_POST</span><span class="p">:</span>
|
||||
<span class="n">msg</span> <span class="o">=</span> <span class="s2">"Performing post-installation setup tasks"</span>
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span></div>
|
||||
|
||||
@ -273,66 +182,31 @@
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">warning</span><span class="p">(</span><span class="n">message</span><span class="p">)</span></div></div>
|
||||
</pre></div>
|
||||
|
||||
</div>
|
||||
<div class="articleComments">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<footer>
|
||||
|
||||
|
||||
<hr/>
|
||||
|
||||
<div role="contentinfo">
|
||||
<p>
|
||||
© Copyright 2015, Red Hat, Inc..
|
||||
|
||||
</p>
|
||||
<p>© Copyright 2018, Red Hat, Inc..</p>
|
||||
</div>
|
||||
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||||
|
||||
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
|
||||
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
|
||||
provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||||
|
||||
|
||||
</footer>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
var DOCUMENTATION_OPTIONS = {
|
||||
URL_ROOT:'../../',
|
||||
VERSION:'28.2',
|
||||
COLLAPSE_INDEX:false,
|
||||
FILE_SUFFIX:'.html',
|
||||
HAS_SOURCE: true,
|
||||
SOURCELINK_SUFFIX: '.txt'
|
||||
};
|
||||
</script>
|
||||
<script type="text/javascript" src="../../_static/jquery.js"></script>
|
||||
<script type="text/javascript" src="../../_static/underscore.js"></script>
|
||||
<script type="text/javascript" src="../../_static/doctools.js"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript" src="../../_static/js/theme.js"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
<script>
|
||||
jQuery(function () {
|
||||
SphinxRtdTheme.StickyNav.enable();
|
||||
SphinxRtdTheme.Navigation.enable(true);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,76 +1,31 @@
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
|
||||
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
|
||||
<html class="writer-html5" lang="en" >
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>pylorax.executils — Lorax 28.2 documentation</title>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pylorax.executils — Lorax 36.0 documentation</title>
|
||||
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
|
||||
<link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="index" title="Index"
|
||||
href="../../genindex.html"/>
|
||||
<link rel="search" title="Search" href="../../search.html"/>
|
||||
<link rel="top" title="Lorax 28.2 documentation" href="../../index.html"/>
|
||||
<link rel="up" title="pylorax" href="../pylorax.html"/>
|
||||
|
||||
|
||||
<script src="../../_static/js/modernizr.min.js"></script>
|
||||
|
||||
<script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
|
||||
<script src="../../_static/jquery.js"></script>
|
||||
<script src="../../_static/underscore.js"></script>
|
||||
<script src="../../_static/doctools.js"></script>
|
||||
<script src="../../_static/js/theme.js"></script>
|
||||
<link rel="index" title="Index" href="../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../search.html" />
|
||||
</head>
|
||||
|
||||
<body class="wy-body-for-nav" role="document">
|
||||
|
||||
|
||||
<body class="wy-body-for-nav">
|
||||
<div class="wy-grid-for-nav">
|
||||
|
||||
|
||||
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
|
||||
<div class="wy-side-scroll">
|
||||
<div class="wy-side-nav-search">
|
||||
|
||||
|
||||
|
||||
<div class="wy-side-nav-search" >
|
||||
<a href="../../index.html" class="icon icon-home"> Lorax
|
||||
|
||||
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="version">
|
||||
28.2
|
||||
36.0
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div role="search">
|
||||
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
|
||||
<input type="text" name="q" placeholder="Search docs" />
|
||||
@ -78,84 +33,37 @@
|
||||
<input type="hidden" name="area" value="default" />
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../intro.html">Introduction to Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../intro.html#before-lorax">Before Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../lorax.html">Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../livemedia-creator.html">livemedia-creator</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../mkksiso.html">mkksiso</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../product-images.html">Product and Updates Images</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../modules.html">pylorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../modules.html">src</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
|
||||
|
||||
|
||||
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
|
||||
|
||||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
|
||||
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
||||
<a href="../../index.html">Lorax</a>
|
||||
|
||||
</nav>
|
||||
|
||||
|
||||
|
||||
<div class="wy-nav-content">
|
||||
<div class="rst-content">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div role="navigation" aria-label="breadcrumbs navigation">
|
||||
|
||||
<div role="navigation" aria-label="Page navigation">
|
||||
<ul class="wy-breadcrumbs">
|
||||
|
||||
<li><a href="../../index.html">Docs</a> »</li>
|
||||
|
||||
<li><a href="../../index.html" class="icon icon-home"></a> »</li>
|
||||
<li><a href="../index.html">Module code</a> »</li>
|
||||
|
||||
<li><a href="../pylorax.html">pylorax</a> »</li>
|
||||
|
||||
<li>pylorax.executils</li>
|
||||
|
||||
|
||||
<li class="wy-breadcrumbs-aside">
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
<hr/>
|
||||
</div>
|
||||
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
|
||||
@ -183,15 +91,18 @@
|
||||
<span class="c1">#</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">os</span>
|
||||
<span class="kn">import</span> <span class="nn">select</span>
|
||||
<span class="kn">import</span> <span class="nn">subprocess</span>
|
||||
<span class="kn">from</span> <span class="nn">subprocess</span> <span class="k">import</span> <span class="n">TimeoutExpired</span>
|
||||
<span class="kn">from</span> <span class="nn">subprocess</span> <span class="kn">import</span> <span class="n">TimeoutExpired</span>
|
||||
<span class="kn">import</span> <span class="nn">signal</span>
|
||||
<span class="kn">import</span> <span class="nn">time</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">logging</span>
|
||||
<span class="n">log</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="s2">"pylorax"</span><span class="p">)</span>
|
||||
<span class="n">program_log</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="s2">"program"</span><span class="p">)</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">threading</span> <span class="k">import</span> <span class="n">Lock</span>
|
||||
<span class="c1"># pylint: disable=not-context-manager</span>
|
||||
<span class="kn">from</span> <span class="nn">threading</span> <span class="kn">import</span> <span class="n">Lock</span>
|
||||
<span class="n">program_log_lock</span> <span class="o">=</span> <span class="n">Lock</span><span class="p">()</span>
|
||||
|
||||
<span class="n">_child_env</span> <span class="o">=</span> <span class="p">{}</span>
|
||||
@ -215,7 +126,7 @@
|
||||
<span class="k">return</span> <span class="n">env</span></div>
|
||||
|
||||
<div class="viewcode-block" id="ExecProduct"><a class="viewcode-back" href="../../pylorax.html#pylorax.executils.ExecProduct">[docs]</a><span class="k">class</span> <span class="nc">ExecProduct</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">rc</span><span class="p">,</span> <span class="n">stdout</span><span class="p">,</span> <span class="n">stderr</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">rc</span><span class="p">,</span> <span class="n">stdout</span><span class="p">,</span> <span class="n">stderr</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">rc</span> <span class="o">=</span> <span class="n">rc</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">stdout</span> <span class="o">=</span> <span class="n">stdout</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">stderr</span> <span class="o">=</span> <span class="n">stderr</span></div>
|
||||
@ -279,6 +190,7 @@
|
||||
<span class="k">if</span> <span class="n">env_add</span><span class="p">:</span>
|
||||
<span class="n">env</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">env_add</span><span class="p">)</span>
|
||||
|
||||
<span class="c1"># pylint: disable=subprocess-popen-preexec-fn</span>
|
||||
<span class="k">return</span> <span class="n">subprocess</span><span class="o">.</span><span class="n">Popen</span><span class="p">(</span><span class="n">argv</span><span class="p">,</span>
|
||||
<span class="n">stdin</span><span class="o">=</span><span class="n">stdin</span><span class="p">,</span>
|
||||
<span class="n">stdout</span><span class="o">=</span><span class="n">stdout</span><span class="p">,</span>
|
||||
@ -446,15 +358,16 @@
|
||||
<span class="sd"> up the process when the output is no longer needed.</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">proc</span><span class="p">,</span> <span class="n">argv</span><span class="p">,</span> <span class="n">callback</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">proc</span><span class="p">,</span> <span class="n">argv</span><span class="p">,</span> <span class="n">callback</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_proc</span> <span class="o">=</span> <span class="n">proc</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_argv</span> <span class="o">=</span> <span class="n">argv</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_callback</span> <span class="o">=</span> <span class="n">callback</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_data</span> <span class="o">=</span> <span class="s2">""</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">__iter__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="fm">__iter__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="bp">self</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">__del__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="fm">__del__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="c1"># See if the process is still running</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_proc</span><span class="o">.</span><span class="n">poll</span><span class="p">()</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="c1"># Stop the process and ignore any problems that might arise</span>
|
||||
@ -463,15 +376,35 @@
|
||||
<span class="k">except</span> <span class="ne">OSError</span><span class="p">:</span>
|
||||
<span class="k">pass</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">__next__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="c1"># Read the next line, blocking if a line is not yet available</span>
|
||||
<span class="n">line</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_proc</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span><span class="s2">"utf-8"</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">line</span> <span class="o">==</span> <span class="s1">''</span> <span class="ow">or</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_callback</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_proc</span><span class="p">):</span>
|
||||
<span class="c1"># Output finished, wait for the process to end</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_proc</span><span class="o">.</span><span class="n">communicate</span><span class="p">()</span>
|
||||
<span class="k">def</span> <span class="fm">__next__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="c1"># Return lines from stdout while also calling _callback</span>
|
||||
<span class="k">while</span> <span class="kc">True</span><span class="p">:</span>
|
||||
<span class="c1"># Check for input without blocking</span>
|
||||
<span class="k">if</span> <span class="n">select</span><span class="o">.</span><span class="n">select</span><span class="p">([</span><span class="bp">self</span><span class="o">.</span><span class="n">_proc</span><span class="o">.</span><span class="n">stdout</span><span class="p">],</span> <span class="p">[],</span> <span class="p">[],</span> <span class="mi">0</span><span class="p">)[</span><span class="mi">0</span><span class="p">]:</span>
|
||||
<span class="n">size</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_proc</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">peek</span><span class="p">(</span><span class="mi">1</span><span class="p">))</span>
|
||||
<span class="k">if</span> <span class="n">size</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_data</span> <span class="o">+=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_proc</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">read</span><span class="p">(</span><span class="n">size</span><span class="p">)</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span><span class="s2">"utf-8"</span><span class="p">)</span>
|
||||
|
||||
<span class="c1"># Check for successful exit</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_proc</span><span class="o">.</span><span class="n">returncode</span> <span class="o"><</span> <span class="mi">0</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span> <span class="o">>=</span> <span class="mi">0</span><span class="p">:</span>
|
||||
<span class="n">line</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_data</span> <span class="o">=</span> <span class="n">line</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
|
||||
<span class="k">return</span> <span class="n">line</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
|
||||
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_proc</span><span class="o">.</span><span class="n">poll</span><span class="p">()</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="ow">or</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_callback</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_proc</span><span class="p">):</span>
|
||||
<span class="c1"># Output finished, wait 60s for the process to end</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_proc</span><span class="o">.</span><span class="n">communicate</span><span class="p">(</span><span class="n">timeout</span><span class="o">=</span><span class="mi">60</span><span class="p">)</span>
|
||||
<span class="k">except</span> <span class="n">subprocess</span><span class="o">.</span><span class="n">TimeoutExpired</span><span class="p">:</span>
|
||||
<span class="c1"># Did not exit in 60s, kill it and wait 30s more</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_proc</span><span class="o">.</span><span class="n">kill</span><span class="p">()</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_proc</span><span class="o">.</span><span class="n">communicate</span><span class="p">(</span><span class="n">timeout</span><span class="o">=</span><span class="mi">30</span><span class="p">)</span>
|
||||
<span class="k">except</span> <span class="n">subprocess</span><span class="o">.</span><span class="n">TimeoutExpired</span><span class="p">:</span>
|
||||
<span class="k">pass</span>
|
||||
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_proc</span><span class="o">.</span><span class="n">returncode</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="ne">OSError</span><span class="p">(</span><span class="s2">"process '</span><span class="si">%s</span><span class="s2">' failed to be killed"</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">_argv</span><span class="p">)</span>
|
||||
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_proc</span><span class="o">.</span><span class="n">returncode</span> <span class="o"><</span> <span class="mi">0</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="ne">OSError</span><span class="p">(</span><span class="s2">"process '</span><span class="si">%s</span><span class="s2">' was killed by signal </span><span class="si">%s</span><span class="s2">"</span> <span class="o">%</span>
|
||||
<span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_argv</span><span class="p">,</span> <span class="o">-</span><span class="bp">self</span><span class="o">.</span><span class="n">_proc</span><span class="o">.</span><span class="n">returncode</span><span class="p">))</span>
|
||||
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_proc</span><span class="o">.</span><span class="n">returncode</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span>
|
||||
@ -479,7 +412,8 @@
|
||||
<span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_argv</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_proc</span><span class="o">.</span><span class="n">returncode</span><span class="p">))</span>
|
||||
<span class="k">raise</span> <span class="ne">StopIteration</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">line</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
|
||||
<span class="c1"># Don't loop too fast with no input to read</span>
|
||||
<span class="n">time</span><span class="o">.</span><span class="n">sleep</span><span class="p">(</span><span class="mf">0.5</span><span class="p">)</span>
|
||||
|
||||
<span class="n">argv</span> <span class="o">=</span> <span class="p">[</span><span class="n">command</span><span class="p">]</span> <span class="o">+</span> <span class="n">argv</span>
|
||||
|
||||
@ -489,7 +423,7 @@
|
||||
<span class="n">stderr</span> <span class="o">=</span> <span class="n">subprocess</span><span class="o">.</span><span class="n">STDOUT</span>
|
||||
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="n">proc</span> <span class="o">=</span> <span class="n">startProgram</span><span class="p">(</span><span class="n">argv</span><span class="p">,</span> <span class="n">root</span><span class="o">=</span><span class="n">root</span><span class="p">,</span> <span class="n">stdin</span><span class="o">=</span><span class="n">stdin</span><span class="p">,</span> <span class="n">stdout</span><span class="o">=</span><span class="n">subprocess</span><span class="o">.</span><span class="n">PIPE</span><span class="p">,</span> <span class="n">stderr</span><span class="o">=</span><span class="n">stderr</span><span class="p">,</span> <span class="n">bufsize</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span>
|
||||
<span class="n">proc</span> <span class="o">=</span> <span class="n">startProgram</span><span class="p">(</span><span class="n">argv</span><span class="p">,</span> <span class="n">root</span><span class="o">=</span><span class="n">root</span><span class="p">,</span> <span class="n">stdin</span><span class="o">=</span><span class="n">stdin</span><span class="p">,</span> <span class="n">stdout</span><span class="o">=</span><span class="n">subprocess</span><span class="o">.</span><span class="n">PIPE</span><span class="p">,</span> <span class="n">stderr</span><span class="o">=</span><span class="n">stderr</span><span class="p">,</span>
|
||||
<span class="n">env_prune</span><span class="o">=</span><span class="n">env_prune</span><span class="p">,</span> <span class="n">env_add</span><span class="o">=</span><span class="n">env_add</span><span class="p">,</span> <span class="n">reset_handlers</span><span class="o">=</span><span class="n">reset_handlers</span><span class="p">,</span> <span class="n">reset_lang</span><span class="o">=</span><span class="n">reset_lang</span><span class="p">)</span>
|
||||
<span class="k">except</span> <span class="ne">OSError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
|
||||
<span class="k">with</span> <span class="n">program_log_lock</span><span class="p">:</span>
|
||||
@ -511,66 +445,31 @@
|
||||
<span class="k">return</span> <span class="n">execWithCapture</span><span class="p">(</span><span class="n">cmd</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">cmd</span><span class="p">[</span><span class="mi">1</span><span class="p">:],</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span></div>
|
||||
</pre></div>
|
||||
|
||||
</div>
|
||||
<div class="articleComments">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<footer>
|
||||
|
||||
|
||||
<hr/>
|
||||
|
||||
<div role="contentinfo">
|
||||
<p>
|
||||
© Copyright 2015, Red Hat, Inc..
|
||||
|
||||
</p>
|
||||
<p>© Copyright 2018, Red Hat, Inc..</p>
|
||||
</div>
|
||||
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||||
|
||||
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
|
||||
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
|
||||
provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||||
|
||||
|
||||
</footer>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
var DOCUMENTATION_OPTIONS = {
|
||||
URL_ROOT:'../../',
|
||||
VERSION:'28.2',
|
||||
COLLAPSE_INDEX:false,
|
||||
FILE_SUFFIX:'.html',
|
||||
HAS_SOURCE: true,
|
||||
SOURCELINK_SUFFIX: '.txt'
|
||||
};
|
||||
</script>
|
||||
<script type="text/javascript" src="../../_static/jquery.js"></script>
|
||||
<script type="text/javascript" src="../../_static/underscore.js"></script>
|
||||
<script type="text/javascript" src="../../_static/doctools.js"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript" src="../../_static/js/theme.js"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
<script>
|
||||
jQuery(function () {
|
||||
SphinxRtdTheme.StickyNav.enable();
|
||||
SphinxRtdTheme.Navigation.enable(true);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,76 +1,31 @@
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
|
||||
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
|
||||
<html class="writer-html5" lang="en" >
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>pylorax.imgutils — Lorax 28.2 documentation</title>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pylorax.imgutils — Lorax 36.4 documentation</title>
|
||||
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
|
||||
<link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="index" title="Index"
|
||||
href="../../genindex.html"/>
|
||||
<link rel="search" title="Search" href="../../search.html"/>
|
||||
<link rel="top" title="Lorax 28.2 documentation" href="../../index.html"/>
|
||||
<link rel="up" title="pylorax" href="../pylorax.html"/>
|
||||
|
||||
|
||||
<script src="../../_static/js/modernizr.min.js"></script>
|
||||
|
||||
<script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
|
||||
<script src="../../_static/jquery.js"></script>
|
||||
<script src="../../_static/underscore.js"></script>
|
||||
<script src="../../_static/doctools.js"></script>
|
||||
<script src="../../_static/js/theme.js"></script>
|
||||
<link rel="index" title="Index" href="../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../search.html" />
|
||||
</head>
|
||||
|
||||
<body class="wy-body-for-nav" role="document">
|
||||
|
||||
|
||||
<body class="wy-body-for-nav">
|
||||
<div class="wy-grid-for-nav">
|
||||
|
||||
|
||||
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
|
||||
<div class="wy-side-scroll">
|
||||
<div class="wy-side-nav-search">
|
||||
|
||||
|
||||
|
||||
<div class="wy-side-nav-search" >
|
||||
<a href="../../index.html" class="icon icon-home"> Lorax
|
||||
|
||||
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="version">
|
||||
28.2
|
||||
36.4
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div role="search">
|
||||
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
|
||||
<input type="text" name="q" placeholder="Search docs" />
|
||||
@ -78,84 +33,37 @@
|
||||
<input type="hidden" name="area" value="default" />
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../intro.html">Introduction to Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../intro.html#before-lorax">Before Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../lorax.html">Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../livemedia-creator.html">livemedia-creator</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../mkksiso.html">mkksiso</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../product-images.html">Product and Updates Images</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../modules.html">pylorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../modules.html">src</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
|
||||
|
||||
|
||||
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
|
||||
|
||||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
|
||||
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
||||
<a href="../../index.html">Lorax</a>
|
||||
|
||||
</nav>
|
||||
|
||||
|
||||
|
||||
<div class="wy-nav-content">
|
||||
<div class="rst-content">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div role="navigation" aria-label="breadcrumbs navigation">
|
||||
|
||||
<div role="navigation" aria-label="Page navigation">
|
||||
<ul class="wy-breadcrumbs">
|
||||
|
||||
<li><a href="../../index.html">Docs</a> »</li>
|
||||
|
||||
<li><a href="../../index.html" class="icon icon-home"></a> »</li>
|
||||
<li><a href="../index.html">Module code</a> »</li>
|
||||
|
||||
<li><a href="../pylorax.html">pylorax</a> »</li>
|
||||
|
||||
<li>pylorax.imgutils</li>
|
||||
|
||||
|
||||
<li class="wy-breadcrumbs-aside">
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
<hr/>
|
||||
</div>
|
||||
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
|
||||
@ -164,7 +72,7 @@
|
||||
<h1>Source code for pylorax.imgutils</h1><div class="highlight"><pre>
|
||||
<span></span><span class="c1"># imgutils.py - utility functions/classes for building disk images</span>
|
||||
<span class="c1">#</span>
|
||||
<span class="c1"># Copyright (C) 2011-2015 Red Hat, Inc.</span>
|
||||
<span class="c1"># Copyright (C) 2011-2018 Red Hat, Inc.</span>
|
||||
<span class="c1">#</span>
|
||||
<span class="c1"># This program is free software; you can redistribute it and/or modify</span>
|
||||
<span class="c1"># it under the terms of the GNU General Public License as published by</span>
|
||||
@ -185,23 +93,23 @@
|
||||
<span class="n">logger</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="s2">"pylorax.imgutils"</span><span class="p">)</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">os</span><span class="o">,</span> <span class="nn">tempfile</span>
|
||||
<span class="kn">from</span> <span class="nn">os.path</span> <span class="k">import</span> <span class="n">join</span><span class="p">,</span> <span class="n">dirname</span>
|
||||
<span class="kn">from</span> <span class="nn">subprocess</span> <span class="k">import</span> <span class="n">Popen</span><span class="p">,</span> <span class="n">PIPE</span><span class="p">,</span> <span class="n">CalledProcessError</span>
|
||||
<span class="kn">from</span> <span class="nn">os.path</span> <span class="kn">import</span> <span class="n">join</span><span class="p">,</span> <span class="n">dirname</span>
|
||||
<span class="kn">from</span> <span class="nn">subprocess</span> <span class="kn">import</span> <span class="n">Popen</span><span class="p">,</span> <span class="n">PIPE</span><span class="p">,</span> <span class="n">CalledProcessError</span>
|
||||
<span class="kn">import</span> <span class="nn">sys</span>
|
||||
<span class="kn">import</span> <span class="nn">time</span>
|
||||
<span class="kn">import</span> <span class="nn">traceback</span>
|
||||
<span class="kn">import</span> <span class="nn">multiprocessing</span>
|
||||
<span class="kn">from</span> <span class="nn">time</span> <span class="k">import</span> <span class="n">sleep</span>
|
||||
<span class="kn">from</span> <span class="nn">time</span> <span class="kn">import</span> <span class="n">sleep</span>
|
||||
<span class="kn">import</span> <span class="nn">shutil</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">pylorax.sysutils</span> <span class="k">import</span> <span class="n">cpfile</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.executils</span> <span class="k">import</span> <span class="n">execWithRedirect</span><span class="p">,</span> <span class="n">execWithCapture</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.executils</span> <span class="k">import</span> <span class="n">runcmd</span><span class="p">,</span> <span class="n">runcmd_output</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.sysutils</span> <span class="kn">import</span> <span class="n">cpfile</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.executils</span> <span class="kn">import</span> <span class="n">execWithRedirect</span><span class="p">,</span> <span class="n">execWithCapture</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.executils</span> <span class="kn">import</span> <span class="n">runcmd</span><span class="p">,</span> <span class="n">runcmd_output</span>
|
||||
|
||||
<span class="c1">######## Functions for making container images (cpio, tar, squashfs) ##########</span>
|
||||
|
||||
<div class="viewcode-block" id="compress"><a class="viewcode-back" href="../../pylorax.html#pylorax.imgutils.compress">[docs]</a><span class="k">def</span> <span class="nf">compress</span><span class="p">(</span><span class="n">command</span><span class="p">,</span> <span class="n">rootdir</span><span class="p">,</span> <span class="n">outfile</span><span class="p">,</span> <span class="n">compression</span><span class="o">=</span><span class="s2">"xz"</span><span class="p">,</span> <span class="n">compressargs</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
<span class="sd">'''Make a compressed archive of the given rootdir.</span>
|
||||
<div class="viewcode-block" id="compress"><a class="viewcode-back" href="../../pylorax.html#pylorax.imgutils.compress">[docs]</a><span class="k">def</span> <span class="nf">compress</span><span class="p">(</span><span class="n">command</span><span class="p">,</span> <span class="n">root</span><span class="p">,</span> <span class="n">outfile</span><span class="p">,</span> <span class="n">compression</span><span class="o">=</span><span class="s2">"xz"</span><span class="p">,</span> <span class="n">compressargs</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
<span class="sd">'''Make a compressed archive of the given rootdir or file.</span>
|
||||
<span class="sd"> command is a list of the archiver commands to run</span>
|
||||
<span class="sd"> compression should be "xz", "gzip", "lzma", "bzip2", or None.</span>
|
||||
<span class="sd"> compressargs will be used on the compression commandline.'''</span>
|
||||
@ -224,15 +132,37 @@
|
||||
<span class="n">compression</span> <span class="o">=</span> <span class="s2">"pbzip2"</span>
|
||||
<span class="n">compressargs</span><span class="o">.</span><span class="n">insert</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="s2">"-p</span><span class="si">%d</span><span class="s2">"</span> <span class="o">%</span> <span class="n">multiprocessing</span><span class="o">.</span><span class="n">cpu_count</span><span class="p">())</span>
|
||||
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">"find </span><span class="si">%s</span><span class="s2"> -print0 |</span><span class="si">%s</span><span class="s2"> | </span><span class="si">%s</span><span class="s2"> </span><span class="si">%s</span><span class="s2"> > </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">rootdir</span><span class="p">,</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">command</span><span class="p">),</span>
|
||||
<span class="n">compression</span><span class="p">,</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">compressargs</span><span class="p">),</span> <span class="n">outfile</span><span class="p">)</span>
|
||||
<span class="n">find</span><span class="p">,</span> <span class="n">archive</span><span class="p">,</span> <span class="n">comp</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">,</span> <span class="kc">None</span>
|
||||
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="n">find</span> <span class="o">=</span> <span class="n">Popen</span><span class="p">([</span><span class="s2">"find"</span><span class="p">,</span> <span class="s2">"."</span><span class="p">,</span> <span class="s2">"-print0"</span><span class="p">],</span> <span class="n">stdout</span><span class="o">=</span><span class="n">PIPE</span><span class="p">,</span> <span class="n">cwd</span><span class="o">=</span><span class="n">rootdir</span><span class="p">)</span>
|
||||
<span class="n">archive</span> <span class="o">=</span> <span class="n">Popen</span><span class="p">(</span><span class="n">command</span><span class="p">,</span> <span class="n">stdin</span><span class="o">=</span><span class="n">find</span><span class="o">.</span><span class="n">stdout</span><span class="p">,</span> <span class="n">stdout</span><span class="o">=</span><span class="n">PIPE</span><span class="p">,</span> <span class="n">cwd</span><span class="o">=</span><span class="n">rootdir</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isdir</span><span class="p">(</span><span class="n">root</span><span class="p">):</span>
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">"find </span><span class="si">%s</span><span class="s2"> -print0 |</span><span class="si">%s</span><span class="s2"> | </span><span class="si">%s</span><span class="s2"> </span><span class="si">%s</span><span class="s2"> > </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">root</span><span class="p">,</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">command</span><span class="p">),</span>
|
||||
<span class="n">compression</span><span class="p">,</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">compressargs</span><span class="p">),</span> <span class="n">outfile</span><span class="p">)</span>
|
||||
|
||||
<span class="n">find</span> <span class="o">=</span> <span class="n">Popen</span><span class="p">([</span><span class="s2">"find"</span><span class="p">,</span> <span class="s2">"."</span><span class="p">,</span> <span class="s2">"-print0"</span><span class="p">],</span> <span class="n">stdout</span><span class="o">=</span><span class="n">PIPE</span><span class="p">,</span> <span class="n">cwd</span><span class="o">=</span><span class="n">root</span><span class="p">)</span>
|
||||
<span class="n">archive</span> <span class="o">=</span> <span class="n">Popen</span><span class="p">(</span><span class="n">command</span><span class="p">,</span> <span class="n">stdin</span><span class="o">=</span><span class="n">find</span><span class="o">.</span><span class="n">stdout</span><span class="p">,</span> <span class="n">stdout</span><span class="o">=</span><span class="n">PIPE</span><span class="p">,</span> <span class="n">cwd</span><span class="o">=</span><span class="n">root</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">"echo </span><span class="si">%s</span><span class="s2"> |</span><span class="si">%s</span><span class="s2"> | </span><span class="si">%s</span><span class="s2"> </span><span class="si">%s</span><span class="s2"> > </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">root</span><span class="p">,</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">command</span><span class="p">),</span>
|
||||
<span class="n">compression</span><span class="p">,</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">compressargs</span><span class="p">),</span> <span class="n">outfile</span><span class="p">)</span>
|
||||
|
||||
<span class="n">archive</span> <span class="o">=</span> <span class="n">Popen</span><span class="p">(</span><span class="n">command</span><span class="p">,</span> <span class="n">stdin</span><span class="o">=</span><span class="n">PIPE</span><span class="p">,</span> <span class="n">stdout</span><span class="o">=</span><span class="n">PIPE</span><span class="p">,</span> <span class="n">cwd</span><span class="o">=</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">dirname</span><span class="p">(</span><span class="n">root</span><span class="p">))</span>
|
||||
<span class="n">archive</span><span class="o">.</span><span class="n">stdin</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">basename</span><span class="p">(</span><span class="n">root</span><span class="p">)</span><span class="o">.</span><span class="n">encode</span><span class="p">(</span><span class="s2">"utf-8"</span><span class="p">)</span> <span class="o">+</span> <span class="sa">b</span><span class="s2">"</span><span class="se">\0</span><span class="s2">"</span><span class="p">)</span>
|
||||
<span class="n">archive</span><span class="o">.</span><span class="n">stdin</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
|
||||
|
||||
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">outfile</span><span class="p">,</span> <span class="s2">"wb"</span><span class="p">)</span> <span class="k">as</span> <span class="n">fout</span><span class="p">:</span>
|
||||
<span class="n">comp</span> <span class="o">=</span> <span class="n">Popen</span><span class="p">([</span><span class="n">compression</span><span class="p">]</span> <span class="o">+</span> <span class="n">compressargs</span><span class="p">,</span>
|
||||
<span class="n">stdin</span><span class="o">=</span><span class="n">archive</span><span class="o">.</span><span class="n">stdout</span><span class="p">,</span> <span class="n">stdout</span><span class="o">=</span><span class="nb">open</span><span class="p">(</span><span class="n">outfile</span><span class="p">,</span> <span class="s2">"wb"</span><span class="p">))</span>
|
||||
<span class="n">stdin</span><span class="o">=</span><span class="n">archive</span><span class="o">.</span><span class="n">stdout</span><span class="p">,</span> <span class="n">stdout</span><span class="o">=</span><span class="n">fout</span><span class="p">)</span>
|
||||
<span class="n">comp</span><span class="o">.</span><span class="n">wait</span><span class="p">()</span>
|
||||
|
||||
<span class="c1"># Clean up the open fds and processes</span>
|
||||
<span class="k">if</span> <span class="n">find</span><span class="p">:</span>
|
||||
<span class="n">find</span><span class="o">.</span><span class="n">wait</span><span class="p">()</span>
|
||||
<span class="n">find</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
|
||||
<span class="n">archive</span><span class="o">.</span><span class="n">wait</span><span class="p">()</span>
|
||||
<span class="k">if</span> <span class="n">archive</span><span class="o">.</span><span class="n">stdin</span><span class="p">:</span>
|
||||
<span class="n">archive</span><span class="o">.</span><span class="n">stdin</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
|
||||
<span class="k">if</span> <span class="n">archive</span><span class="o">.</span><span class="n">stdout</span><span class="p">:</span>
|
||||
<span class="n">archive</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
|
||||
<span class="k">return</span> <span class="n">comp</span><span class="o">.</span><span class="n">returncode</span>
|
||||
<span class="k">except</span> <span class="ne">OSError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="n">e</span><span class="p">)</span>
|
||||
@ -240,18 +170,18 @@
|
||||
<span class="nb">list</span><span class="p">(</span><span class="n">p</span><span class="o">.</span><span class="n">kill</span><span class="p">()</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="p">(</span><span class="n">find</span><span class="p">,</span> <span class="n">archive</span><span class="p">,</span> <span class="n">comp</span><span class="p">)</span> <span class="k">if</span> <span class="n">p</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="mi">1</span></div>
|
||||
|
||||
<div class="viewcode-block" id="mkcpio"><a class="viewcode-back" href="../../pylorax.html#pylorax.imgutils.mkcpio">[docs]</a><span class="k">def</span> <span class="nf">mkcpio</span><span class="p">(</span><span class="n">rootdir</span><span class="p">,</span> <span class="n">outfile</span><span class="p">,</span> <span class="n">compression</span><span class="o">=</span><span class="s2">"xz"</span><span class="p">,</span> <span class="n">compressargs</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
<div class="viewcode-block" id="mkcpio"><a class="viewcode-back" href="../../pylorax.html#pylorax.imgutils.mkcpio">[docs]</a><span class="k">def</span> <span class="nf">mkcpio</span><span class="p">(</span><span class="n">root</span><span class="p">,</span> <span class="n">outfile</span><span class="p">,</span> <span class="n">compression</span><span class="o">=</span><span class="s2">"xz"</span><span class="p">,</span> <span class="n">compressargs</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
<span class="n">compressargs</span> <span class="o">=</span> <span class="n">compressargs</span> <span class="ow">or</span> <span class="p">[</span><span class="s2">"-9"</span><span class="p">]</span>
|
||||
<span class="k">return</span> <span class="n">compress</span><span class="p">([</span><span class="s2">"cpio"</span><span class="p">,</span> <span class="s2">"--null"</span><span class="p">,</span> <span class="s2">"--quiet"</span><span class="p">,</span> <span class="s2">"-H"</span><span class="p">,</span> <span class="s2">"newc"</span><span class="p">,</span> <span class="s2">"-o"</span><span class="p">],</span>
|
||||
<span class="n">rootdir</span><span class="p">,</span> <span class="n">outfile</span><span class="p">,</span> <span class="n">compression</span><span class="p">,</span> <span class="n">compressargs</span><span class="p">)</span></div>
|
||||
<span class="n">root</span><span class="p">,</span> <span class="n">outfile</span><span class="p">,</span> <span class="n">compression</span><span class="p">,</span> <span class="n">compressargs</span><span class="p">)</span></div>
|
||||
|
||||
<div class="viewcode-block" id="mktar"><a class="viewcode-back" href="../../pylorax.html#pylorax.imgutils.mktar">[docs]</a><span class="k">def</span> <span class="nf">mktar</span><span class="p">(</span><span class="n">rootdir</span><span class="p">,</span> <span class="n">outfile</span><span class="p">,</span> <span class="n">compression</span><span class="o">=</span><span class="s2">"xz"</span><span class="p">,</span> <span class="n">compressargs</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">selinux</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span>
|
||||
<div class="viewcode-block" id="mktar"><a class="viewcode-back" href="../../pylorax.html#pylorax.imgutils.mktar">[docs]</a><span class="k">def</span> <span class="nf">mktar</span><span class="p">(</span><span class="n">root</span><span class="p">,</span> <span class="n">outfile</span><span class="p">,</span> <span class="n">compression</span><span class="o">=</span><span class="s2">"xz"</span><span class="p">,</span> <span class="n">compressargs</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">selinux</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span>
|
||||
<span class="n">compressargs</span> <span class="o">=</span> <span class="n">compressargs</span> <span class="ow">or</span> <span class="p">[</span><span class="s2">"-9"</span><span class="p">]</span>
|
||||
<span class="n">tar_cmd</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"tar"</span><span class="p">,</span> <span class="s2">"--no-recursion"</span><span class="p">]</span>
|
||||
<span class="k">if</span> <span class="n">selinux</span><span class="p">:</span>
|
||||
<span class="n">tar_cmd</span> <span class="o">+=</span> <span class="p">[</span><span class="s2">"--selinux"</span><span class="p">,</span> <span class="s2">"--acls"</span><span class="p">,</span> <span class="s2">"--xattrs"</span><span class="p">]</span>
|
||||
<span class="n">tar_cmd</span> <span class="o">+=</span> <span class="p">[</span><span class="s2">"-cf-"</span><span class="p">,</span> <span class="s2">"--null"</span><span class="p">,</span> <span class="s2">"-T-"</span><span class="p">]</span>
|
||||
<span class="k">return</span> <span class="n">compress</span><span class="p">(</span><span class="n">tar_cmd</span><span class="p">,</span> <span class="n">rootdir</span><span class="p">,</span> <span class="n">outfile</span><span class="p">,</span> <span class="n">compression</span><span class="p">,</span> <span class="n">compressargs</span><span class="p">)</span></div>
|
||||
<span class="k">return</span> <span class="n">compress</span><span class="p">(</span><span class="n">tar_cmd</span><span class="p">,</span> <span class="n">root</span><span class="p">,</span> <span class="n">outfile</span><span class="p">,</span> <span class="n">compression</span><span class="p">,</span> <span class="n">compressargs</span><span class="p">)</span></div>
|
||||
|
||||
<div class="viewcode-block" id="mksquashfs"><a class="viewcode-back" href="../../pylorax.html#pylorax.imgutils.mksquashfs">[docs]</a><span class="k">def</span> <span class="nf">mksquashfs</span><span class="p">(</span><span class="n">rootdir</span><span class="p">,</span> <span class="n">outfile</span><span class="p">,</span> <span class="n">compression</span><span class="o">=</span><span class="s2">"default"</span><span class="p">,</span> <span class="n">compressargs</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
<span class="sd">'''Make a squashfs image containing the given rootdir.'''</span>
|
||||
@ -275,28 +205,15 @@
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">fssize</span> <span class="o">=</span> <span class="kc">None</span> <span class="c1"># Let mkext4img figure out the needed size</span>
|
||||
|
||||
<span class="n">mkext4img</span><span class="p">(</span><span class="n">rootdir</span><span class="p">,</span> <span class="n">outfile</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="n">label</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="n">fssize</span><span class="p">)</span>
|
||||
<span class="c1"># Reset selinux context on new rootfs</span>
|
||||
<span class="k">with</span> <span class="n">LoopDev</span><span class="p">(</span><span class="n">outfile</span><span class="p">)</span> <span class="k">as</span> <span class="n">loopdev</span><span class="p">:</span>
|
||||
<span class="k">with</span> <span class="n">Mount</span><span class="p">(</span><span class="n">loopdev</span><span class="p">)</span> <span class="k">as</span> <span class="n">mnt</span><span class="p">:</span>
|
||||
<span class="n">cmd</span> <span class="o">=</span> <span class="p">[</span> <span class="s2">"setfiles"</span><span class="p">,</span> <span class="s2">"-e"</span><span class="p">,</span> <span class="s2">"/proc"</span><span class="p">,</span> <span class="s2">"-e"</span><span class="p">,</span> <span class="s2">"/sys"</span><span class="p">,</span> <span class="s2">"-e"</span><span class="p">,</span> <span class="s2">"/dev"</span><span class="p">,</span>
|
||||
<span class="s2">"-e"</span><span class="p">,</span> <span class="s2">"/install"</span><span class="p">,</span> <span class="s2">"-e"</span><span class="p">,</span> <span class="s2">"/ostree"</span><span class="p">,</span>
|
||||
<span class="s2">"/etc/selinux/targeted/contexts/files/file_contexts"</span><span class="p">,</span> <span class="s2">"/"</span><span class="p">]</span>
|
||||
<span class="n">root</span> <span class="o">=</span> <span class="n">join</span><span class="p">(</span><span class="n">mnt</span><span class="p">,</span> <span class="n">sysroot</span><span class="o">.</span><span class="n">lstrip</span><span class="p">(</span><span class="s2">"/"</span><span class="p">))</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="n">runcmd</span><span class="p">(</span><span class="n">cmd</span><span class="p">,</span> <span class="n">root</span><span class="o">=</span><span class="n">root</span><span class="p">)</span>
|
||||
<span class="k">except</span> <span class="n">CalledProcessError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="s2">"setfiles exited with a non-zero return code (</span><span class="si">%d</span><span class="s2">) which may "</span>
|
||||
<span class="s2">"be caused by running without SELinux in Permissive mode."</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">returncode</span><span class="p">)</span>
|
||||
<span class="k">raise</span></div>
|
||||
<span class="n">mkext4img</span><span class="p">(</span><span class="n">rootdir</span><span class="p">,</span> <span class="n">outfile</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="n">label</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="n">fssize</span><span class="p">)</span></div>
|
||||
|
||||
|
||||
<span class="c1">######## Utility functions ###############################################</span>
|
||||
|
||||
<div class="viewcode-block" id="mksparse"><a class="viewcode-back" href="../../pylorax.html#pylorax.imgutils.mksparse">[docs]</a><span class="k">def</span> <span class="nf">mksparse</span><span class="p">(</span><span class="n">outfile</span><span class="p">,</span> <span class="n">size</span><span class="p">):</span>
|
||||
<span class="sd">'''use os.ftruncate to create a sparse file of the given size.'''</span>
|
||||
<span class="n">fobj</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="n">outfile</span><span class="p">,</span> <span class="s2">"w"</span><span class="p">)</span>
|
||||
<span class="n">os</span><span class="o">.</span><span class="n">ftruncate</span><span class="p">(</span><span class="n">fobj</span><span class="o">.</span><span class="n">fileno</span><span class="p">(),</span> <span class="n">size</span><span class="p">)</span></div>
|
||||
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">outfile</span><span class="p">,</span> <span class="s2">"w"</span><span class="p">)</span> <span class="k">as</span> <span class="n">fobj</span><span class="p">:</span>
|
||||
<span class="n">os</span><span class="o">.</span><span class="n">ftruncate</span><span class="p">(</span><span class="n">fobj</span><span class="o">.</span><span class="n">fileno</span><span class="p">(),</span> <span class="nb">int</span><span class="p">(</span><span class="n">size</span><span class="p">))</span></div>
|
||||
|
||||
<div class="viewcode-block" id="mkqcow2"><a class="viewcode-back" href="../../pylorax.html#pylorax.imgutils.mkqcow2">[docs]</a><span class="k">def</span> <span class="nf">mkqcow2</span><span class="p">(</span><span class="n">outfile</span><span class="p">,</span> <span class="n">size</span><span class="p">,</span> <span class="n">options</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
<span class="sd">'''use qemu-img to create a file of the given size.</span>
|
||||
@ -343,13 +260,31 @@
|
||||
<span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span><span class="s2">"Unable to setup </span><span class="si">%s</span><span class="s2"> on </span><span class="si">%s</span><span class="s2">"</span> <span class="o">%</span> <span class="p">(</span><span class="n">loop_dev</span><span class="p">,</span> <span class="n">outfile</span><span class="p">))</span></div>
|
||||
|
||||
<div class="viewcode-block" id="loop_attach"><a class="viewcode-back" href="../../pylorax.html#pylorax.imgutils.loop_attach">[docs]</a><span class="k">def</span> <span class="nf">loop_attach</span><span class="p">(</span><span class="n">outfile</span><span class="p">):</span>
|
||||
<span class="sd">'''Attach a loop device to the given file. Return the loop device name.</span>
|
||||
<span class="sd"> Raises CalledProcessError if losetup fails.'''</span>
|
||||
<span class="n">dev</span> <span class="o">=</span> <span class="n">runcmd_output</span><span class="p">([</span><span class="s2">"losetup"</span><span class="p">,</span> <span class="s2">"--find"</span><span class="p">,</span> <span class="s2">"--show"</span><span class="p">,</span> <span class="n">outfile</span><span class="p">])</span>
|
||||
<span class="sd">"""Attach a loop device to the given file. Return the loop device name.</span>
|
||||
|
||||
<span class="sd"> On rare occasions it appears that the device never shows up, some experiments</span>
|
||||
<span class="sd"> seem to indicate that it may be a race with another process using /dev/loop* devices.</span>
|
||||
|
||||
<span class="sd"> So we now try 3 times before actually failing.</span>
|
||||
|
||||
<span class="sd"> Raises CalledProcessError if losetup fails.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">retries</span> <span class="o">=</span> <span class="mi">0</span>
|
||||
<span class="k">while</span> <span class="kc">True</span><span class="p">:</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="n">retries</span> <span class="o">+=</span> <span class="mi">1</span>
|
||||
<span class="n">dev</span> <span class="o">=</span> <span class="n">runcmd_output</span><span class="p">([</span><span class="s2">"losetup"</span><span class="p">,</span> <span class="s2">"--find"</span><span class="p">,</span> <span class="s2">"--show"</span><span class="p">,</span> <span class="n">outfile</span><span class="p">])</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
|
||||
|
||||
<span class="c1"># Sometimes the loop device isn't ready yet, make extra sure before returning</span>
|
||||
<span class="n">loop_waitfor</span><span class="p">(</span><span class="n">dev</span><span class="o">.</span><span class="n">strip</span><span class="p">(),</span> <span class="n">outfile</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">dev</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span></div>
|
||||
<span class="n">loop_waitfor</span><span class="p">(</span><span class="n">dev</span><span class="p">,</span> <span class="n">outfile</span><span class="p">)</span>
|
||||
<span class="k">except</span> <span class="ne">RuntimeError</span><span class="p">:</span>
|
||||
<span class="c1"># Try to setup the loop device 3 times</span>
|
||||
<span class="k">if</span> <span class="n">retries</span> <span class="o">==</span> <span class="mi">3</span><span class="p">:</span>
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="s2">"loop_attach failed, retries exhausted."</span><span class="p">)</span>
|
||||
<span class="k">raise</span>
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">"Try </span><span class="si">%d</span><span class="s2"> failed, </span><span class="si">%s</span><span class="s2"> did not appear."</span><span class="p">,</span> <span class="n">retries</span><span class="p">,</span> <span class="n">dev</span><span class="p">)</span>
|
||||
<span class="k">break</span>
|
||||
<span class="k">return</span> <span class="n">dev</span></div>
|
||||
|
||||
<div class="viewcode-block" id="loop_detach"><a class="viewcode-back" href="../../pylorax.html#pylorax.imgutils.loop_detach">[docs]</a><span class="k">def</span> <span class="nf">loop_detach</span><span class="p">(</span><span class="n">loopdev</span><span class="p">):</span>
|
||||
<span class="sd">'''Detach the given loop device. Return False on failure.'''</span>
|
||||
@ -430,7 +365,7 @@
|
||||
<span class="sd"> If preserve is False, uses cp -R (useful for modeless filesystems)</span>
|
||||
<span class="sd"> raises CalledProcessError if copy fails.'''</span>
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">"copytree </span><span class="si">%s</span><span class="s2"> </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">src</span><span class="p">,</span> <span class="n">dest</span><span class="p">)</span>
|
||||
<span class="n">cp</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"cp"</span><span class="p">,</span> <span class="s2">"-a"</span><span class="p">]</span> <span class="k">if</span> <span class="n">preserve</span> <span class="k">else</span> <span class="p">[</span><span class="s2">"cp"</span><span class="p">,</span> <span class="s2">"-R"</span><span class="p">,</span> <span class="s2">"-L"</span><span class="p">]</span>
|
||||
<span class="n">cp</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"cp"</span><span class="p">,</span> <span class="s2">"-a"</span><span class="p">]</span> <span class="k">if</span> <span class="n">preserve</span> <span class="k">else</span> <span class="p">[</span><span class="s2">"cp"</span><span class="p">,</span> <span class="s2">"-R"</span><span class="p">,</span> <span class="s2">"-L"</span><span class="p">,</span> <span class="s2">"--preserve=timestamps"</span><span class="p">]</span>
|
||||
<span class="n">cp</span> <span class="o">+=</span> <span class="p">[</span><span class="n">join</span><span class="p">(</span><span class="n">src</span><span class="p">,</span> <span class="s2">"."</span><span class="p">),</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">abspath</span><span class="p">(</span><span class="n">dest</span><span class="p">)]</span>
|
||||
<span class="n">runcmd</span><span class="p">(</span><span class="n">cp</span><span class="p">)</span></div>
|
||||
|
||||
@ -485,39 +420,64 @@
|
||||
<span class="c1">######## Execution contexts - use with the 'with' statement ##############</span>
|
||||
|
||||
<div class="viewcode-block" id="LoopDev"><a class="viewcode-back" href="../../pylorax.html#pylorax.imgutils.LoopDev">[docs]</a><span class="k">class</span> <span class="nc">LoopDev</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">filename</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">filename</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">loopdev</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">filename</span> <span class="o">=</span> <span class="n">filename</span>
|
||||
<span class="k">if</span> <span class="n">size</span><span class="p">:</span>
|
||||
<span class="n">mksparse</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">filename</span><span class="p">,</span> <span class="n">size</span><span class="p">)</span>
|
||||
<span class="k">def</span> <span class="nf">__enter__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="fm">__enter__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">loopdev</span> <span class="o">=</span> <span class="n">loop_attach</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">filename</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">loopdev</span>
|
||||
<span class="k">def</span> <span class="nf">__exit__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exc_type</span><span class="p">,</span> <span class="n">exc_value</span><span class="p">,</span> <span class="n">tracebk</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="fm">__exit__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exc_type</span><span class="p">,</span> <span class="n">exc_value</span><span class="p">,</span> <span class="n">tracebk</span><span class="p">):</span>
|
||||
<span class="n">loop_detach</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">loopdev</span><span class="p">)</span></div>
|
||||
|
||||
<div class="viewcode-block" id="DMDev"><a class="viewcode-back" href="../../pylorax.html#pylorax.imgutils.DMDev">[docs]</a><span class="k">class</span> <span class="nc">DMDev</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dev</span><span class="p">,</span> <span class="n">size</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dev</span><span class="p">,</span> <span class="n">size</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">mapperdev</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
<span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">dev</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">size</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> <span class="o">=</span> <span class="p">(</span><span class="n">dev</span><span class="p">,</span> <span class="n">size</span><span class="p">,</span> <span class="n">name</span><span class="p">)</span>
|
||||
<span class="k">def</span> <span class="nf">__enter__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="fm">__enter__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">mapperdev</span> <span class="o">=</span> <span class="n">dm_attach</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">dev</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">size</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">mapperdev</span>
|
||||
<span class="k">def</span> <span class="nf">__exit__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exc_type</span><span class="p">,</span> <span class="n">exc_value</span><span class="p">,</span> <span class="n">tracebk</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="fm">__exit__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exc_type</span><span class="p">,</span> <span class="n">exc_value</span><span class="p">,</span> <span class="n">tracebk</span><span class="p">):</span>
|
||||
<span class="n">dm_detach</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">mapperdev</span><span class="p">)</span></div>
|
||||
|
||||
<div class="viewcode-block" id="Mount"><a class="viewcode-back" href="../../pylorax.html#pylorax.imgutils.Mount">[docs]</a><span class="k">class</span> <span class="nc">Mount</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dev</span><span class="p">,</span> <span class="n">opts</span><span class="o">=</span><span class="s2">""</span><span class="p">,</span> <span class="n">mnt</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dev</span><span class="p">,</span> <span class="n">opts</span><span class="o">=</span><span class="s2">""</span><span class="p">,</span> <span class="n">mnt</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
<span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">dev</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">opts</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">mnt</span><span class="p">)</span> <span class="o">=</span> <span class="p">(</span><span class="n">dev</span><span class="p">,</span> <span class="n">opts</span><span class="p">,</span> <span class="n">mnt</span><span class="p">)</span>
|
||||
<span class="k">def</span> <span class="nf">__enter__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="fm">__enter__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">mnt</span> <span class="o">=</span> <span class="n">mount</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">dev</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">opts</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">mnt</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">mnt</span>
|
||||
<span class="k">def</span> <span class="nf">__exit__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exc_type</span><span class="p">,</span> <span class="n">exc_value</span><span class="p">,</span> <span class="n">tracebk</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="fm">__exit__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exc_type</span><span class="p">,</span> <span class="n">exc_value</span><span class="p">,</span> <span class="n">tracebk</span><span class="p">):</span>
|
||||
<span class="n">umount</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">mnt</span><span class="p">)</span></div>
|
||||
|
||||
<div class="viewcode-block" id="kpartx_disk_img"><a class="viewcode-back" href="../../pylorax.html#pylorax.imgutils.kpartx_disk_img">[docs]</a><span class="k">def</span> <span class="nf">kpartx_disk_img</span><span class="p">(</span><span class="n">disk_img</span><span class="p">):</span>
|
||||
<span class="sd">"""Attach a disk image's partitions to /dev/loopX using kpartx</span>
|
||||
|
||||
<span class="sd"> :param disk_img: The full path to a partitioned disk image</span>
|
||||
<span class="sd"> :type disk_img: str</span>
|
||||
<span class="sd"> :returns: list of (loopXpN, size)</span>
|
||||
<span class="sd"> :rtype: list of tuples</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="c1"># Example kpartx output</span>
|
||||
<span class="c1"># kpartx -p p -v -a /tmp/diskV2DiCW.im</span>
|
||||
<span class="c1"># add map loop2p1 (253:2): 0 3481600 linear /dev/loop2 2048</span>
|
||||
<span class="c1"># add map loop2p2 (253:3): 0 614400 linear /dev/loop2 3483648</span>
|
||||
<span class="n">kpartx_output</span> <span class="o">=</span> <span class="n">runcmd_output</span><span class="p">([</span><span class="s2">"kpartx"</span><span class="p">,</span> <span class="s2">"-v"</span><span class="p">,</span> <span class="s2">"-a"</span><span class="p">,</span> <span class="s2">"-s"</span><span class="p">,</span> <span class="n">disk_img</span><span class="p">])</span>
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="n">kpartx_output</span><span class="p">)</span>
|
||||
|
||||
<span class="c1"># list of (deviceName, sizeInBytes)</span>
|
||||
<span class="n">loop_devices</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="n">kpartx_output</span><span class="o">.</span><span class="n">splitlines</span><span class="p">():</span>
|
||||
<span class="c1"># add map loop2p3 (253:4): 0 7139328 linear /dev/loop2 528384</span>
|
||||
<span class="c1"># 3rd element is size in 512 byte blocks</span>
|
||||
<span class="k">if</span> <span class="n">line</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"add map "</span><span class="p">):</span>
|
||||
<span class="n">fields</span> <span class="o">=</span> <span class="n">line</span><span class="p">[</span><span class="mi">8</span><span class="p">:]</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>
|
||||
<span class="n">loop_devices</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> <span class="p">(</span><span class="n">fields</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="nb">int</span><span class="p">(</span><span class="n">fields</span><span class="p">[</span><span class="mi">3</span><span class="p">])</span><span class="o">*</span><span class="mi">512</span><span class="p">)</span> <span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">loop_devices</span></div>
|
||||
|
||||
<div class="viewcode-block" id="PartitionMount"><a class="viewcode-back" href="../../pylorax.html#pylorax.imgutils.PartitionMount">[docs]</a><span class="k">class</span> <span class="nc">PartitionMount</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
|
||||
<span class="sd">""" Mount a partitioned image file using kpartx """</span>
|
||||
<span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">disk_img</span><span class="p">,</span> <span class="n">mount_ok</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">submount</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">disk_img</span><span class="p">,</span> <span class="n">mount_ok</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">submount</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> :param str disk_img: The full path to a partitioned disk image</span>
|
||||
<span class="sd"> :param mount_ok: A function that is passed the mount point and</span>
|
||||
@ -546,23 +506,10 @@
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">mount_ok</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">mount_ok</span> <span class="o">=</span> <span class="k">lambda</span> <span class="n">mount_dir</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">mount_dir</span><span class="o">+</span><span class="s2">"/etc/passwd"</span><span class="p">)</span>
|
||||
|
||||
<span class="c1"># Example kpartx output</span>
|
||||
<span class="c1"># kpartx -p p -v -a /tmp/diskV2DiCW.im</span>
|
||||
<span class="c1"># add map loop2p1 (253:2): 0 3481600 linear /dev/loop2 2048</span>
|
||||
<span class="c1"># add map loop2p2 (253:3): 0 614400 linear /dev/loop2 3483648</span>
|
||||
<span class="n">kpartx_output</span> <span class="o">=</span> <span class="n">runcmd_output</span><span class="p">([</span><span class="s2">"kpartx"</span><span class="p">,</span> <span class="s2">"-v"</span><span class="p">,</span> <span class="s2">"-a"</span><span class="p">,</span> <span class="s2">"-s"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">disk_img</span><span class="p">])</span>
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="n">kpartx_output</span><span class="p">)</span>
|
||||
|
||||
<span class="c1"># list of (deviceName, sizeInBytes)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">loop_devices</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="n">kpartx_output</span><span class="o">.</span><span class="n">splitlines</span><span class="p">():</span>
|
||||
<span class="c1"># add map loop2p3 (253:4): 0 7139328 linear /dev/loop2 528384</span>
|
||||
<span class="c1"># 3rd element is size in 512 byte blocks</span>
|
||||
<span class="k">if</span> <span class="n">line</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"add map "</span><span class="p">):</span>
|
||||
<span class="n">fields</span> <span class="o">=</span> <span class="n">line</span><span class="p">[</span><span class="mi">8</span><span class="p">:]</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">loop_devices</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> <span class="p">(</span><span class="n">fields</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="nb">int</span><span class="p">(</span><span class="n">fields</span><span class="p">[</span><span class="mi">3</span><span class="p">])</span><span class="o">*</span><span class="mi">512</span><span class="p">)</span> <span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">loop_devices</span> <span class="o">=</span> <span class="n">kpartx_disk_img</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">disk_img</span><span class="p">)</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">__enter__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="fm">__enter__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="c1"># Mount the device selected by mount_ok, if possible</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">temp_dir</span> <span class="o">=</span> <span class="n">tempfile</span><span class="o">.</span><span class="n">mkdtemp</span><span class="p">()</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">submount</span><span class="p">:</span>
|
||||
@ -589,7 +536,7 @@
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">temp_dir</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
<span class="k">return</span> <span class="bp">self</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">__exit__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exc_type</span><span class="p">,</span> <span class="n">exc_value</span><span class="p">,</span> <span class="n">tracebk</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="fm">__exit__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exc_type</span><span class="p">,</span> <span class="n">exc_value</span><span class="p">,</span> <span class="n">tracebk</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">temp_dir</span><span class="p">:</span>
|
||||
<span class="n">umount</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">mount_dir</span><span class="p">)</span>
|
||||
<span class="n">shutil</span><span class="o">.</span><span class="n">rmtree</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">temp_dir</span><span class="p">)</span>
|
||||
@ -598,6 +545,42 @@
|
||||
<span class="n">execWithRedirect</span><span class="p">(</span><span class="s2">"kpartx"</span><span class="p">,</span> <span class="p">[</span><span class="s2">"-d"</span><span class="p">,</span> <span class="s2">"-s"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">disk_img</span><span class="p">])</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="DracutChroot"><a class="viewcode-back" href="../../pylorax.html#pylorax.imgutils.DracutChroot">[docs]</a><span class="k">class</span> <span class="nc">DracutChroot</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
|
||||
<span class="sd">"""Setup the chroot for running dracut inside it, cleanup when done</span>
|
||||
|
||||
<span class="sd"> This mount /proc, /dev, and /var/tmp plus optional bind mounted directories</span>
|
||||
<span class="sd"> as a list of (source, destination) tuples where destination is relative to the chroot.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">root</span><span class="p">,</span> <span class="n">bind</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">root</span> <span class="o">=</span> <span class="n">root</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">bind</span> <span class="o">=</span> <span class="p">[(</span><span class="s2">"/var/tmp"</span><span class="p">,</span> <span class="s2">"/var/tmp"</span><span class="p">)]</span> <span class="o">+</span> <span class="p">(</span><span class="n">bind</span> <span class="k">if</span> <span class="n">bind</span> <span class="k">else</span> <span class="p">[])</span>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__enter__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">for</span> <span class="n">d</span> <span class="ow">in</span> <span class="p">[</span><span class="n">d</span> <span class="k">for</span> <span class="n">_</span><span class="p">,</span> <span class="n">d</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">bind</span><span class="p">]</span> <span class="o">+</span> <span class="p">[</span><span class="s2">"/proc"</span><span class="p">,</span> <span class="s2">"/dev"</span><span class="p">]:</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">root</span> <span class="o">+</span> <span class="n">d</span><span class="p">):</span>
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">warning</span><span class="p">(</span><span class="s2">"Making missing dracut chroot directory: </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">d</span><span class="p">)</span>
|
||||
<span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">root</span> <span class="o">+</span> <span class="n">d</span><span class="p">)</span>
|
||||
|
||||
<span class="n">runcmd</span><span class="p">([</span><span class="s2">"mount"</span><span class="p">,</span> <span class="s2">"-t"</span><span class="p">,</span> <span class="s2">"proc"</span><span class="p">,</span> <span class="s2">"-o"</span><span class="p">,</span> <span class="s2">"nosuid,noexec,nodev"</span><span class="p">,</span> <span class="s2">"proc"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">root</span> <span class="o">+</span> <span class="s2">"/proc"</span> <span class="p">])</span>
|
||||
<span class="n">runcmd</span><span class="p">([</span><span class="s2">"mount"</span><span class="p">,</span> <span class="s2">"-t"</span><span class="p">,</span> <span class="s2">"devtmpfs"</span><span class="p">,</span> <span class="s2">"-o"</span><span class="p">,</span> <span class="s2">"mode=0755,noexec,nosuid,strictatime"</span><span class="p">,</span> <span class="s2">"devtmpfs"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">root</span> <span class="o">+</span> <span class="s2">"/dev"</span> <span class="p">])</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">s</span><span class="p">,</span> <span class="n">d</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">bind</span><span class="p">:</span>
|
||||
<span class="n">runcmd</span><span class="p">([</span><span class="s2">"mount"</span><span class="p">,</span> <span class="s2">"-o"</span><span class="p">,</span> <span class="s2">"bind"</span><span class="p">,</span> <span class="n">s</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">root</span> <span class="o">+</span> <span class="n">d</span><span class="p">])</span>
|
||||
|
||||
<span class="k">return</span> <span class="bp">self</span>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__exit__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">exc_type</span><span class="p">,</span> <span class="n">exc_value</span><span class="p">,</span> <span class="n">tracebk</span><span class="p">):</span>
|
||||
<span class="n">runcmd</span><span class="p">([</span><span class="s2">"umount"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">root</span> <span class="o">+</span> <span class="s2">"/proc"</span> <span class="p">])</span>
|
||||
<span class="n">runcmd</span><span class="p">([</span><span class="s2">"umount"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">root</span> <span class="o">+</span> <span class="s2">"/dev"</span> <span class="p">])</span>
|
||||
|
||||
<span class="c1"># cleanup bind mounts</span>
|
||||
<span class="k">for</span> <span class="n">_</span><span class="p">,</span> <span class="n">d</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">bind</span><span class="p">:</span>
|
||||
<span class="n">runcmd</span><span class="p">([</span><span class="s2">"umount"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">root</span> <span class="o">+</span> <span class="n">d</span> <span class="p">])</span>
|
||||
|
||||
<div class="viewcode-block" id="DracutChroot.Run"><a class="viewcode-back" href="../../pylorax.html#pylorax.imgutils.DracutChroot.Run">[docs]</a> <span class="k">def</span> <span class="nf">Run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">args</span><span class="p">):</span>
|
||||
<span class="n">runcmd</span><span class="p">([</span><span class="s2">"dracut"</span><span class="p">]</span> <span class="o">+</span> <span class="n">args</span><span class="p">,</span> <span class="n">root</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">root</span><span class="p">)</span></div></div>
|
||||
|
||||
|
||||
<span class="c1">######## Functions for making filesystem images ##########################</span>
|
||||
|
||||
<div class="viewcode-block" id="mkfsimage"><a class="viewcode-back" href="../../pylorax.html#pylorax.imgutils.mkfsimage">[docs]</a><span class="k">def</span> <span class="nf">mkfsimage</span><span class="p">(</span><span class="n">fstype</span><span class="p">,</span> <span class="n">rootdir</span><span class="p">,</span> <span class="n">outfile</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">mkfsargs</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">mountargs</span><span class="o">=</span><span class="s2">""</span><span class="p">,</span> <span class="n">graft</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
@ -624,14 +607,21 @@
|
||||
<span class="n">copytree</span><span class="p">(</span><span class="n">rootdir</span><span class="p">,</span> <span class="n">mnt</span><span class="p">,</span> <span class="n">preserve</span><span class="p">)</span>
|
||||
<span class="n">do_grafts</span><span class="p">(</span><span class="n">graft</span><span class="p">,</span> <span class="n">mnt</span><span class="p">,</span> <span class="n">preserve</span><span class="p">)</span>
|
||||
|
||||
<span class="c1"># Save information about filesystem usage</span>
|
||||
<span class="n">execWithRedirect</span><span class="p">(</span><span class="s2">"df"</span><span class="p">,</span> <span class="p">[</span><span class="n">mnt</span><span class="p">])</span>
|
||||
|
||||
<span class="c1"># Make absolutely sure that the data has been written</span>
|
||||
<span class="n">runcmd</span><span class="p">([</span><span class="s2">"sync"</span><span class="p">])</span></div>
|
||||
|
||||
<span class="c1"># convenience functions with useful defaults</span>
|
||||
<div class="viewcode-block" id="mkdosimg"><a class="viewcode-back" href="../../pylorax.html#pylorax.imgutils.mkdosimg">[docs]</a><span class="k">def</span> <span class="nf">mkdosimg</span><span class="p">(</span><span class="n">rootdir</span><span class="p">,</span> <span class="n">outfile</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="s2">""</span><span class="p">,</span> <span class="n">mountargs</span><span class="o">=</span><span class="s2">"shortname=winnt,umask=0077"</span><span class="p">,</span> <span class="n">graft</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
<span class="n">graft</span> <span class="o">=</span> <span class="n">graft</span> <span class="ow">or</span> <span class="p">{}</span>
|
||||
<span class="n">mkfsargs</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"-n"</span><span class="p">,</span> <span class="n">label</span><span class="p">]</span>
|
||||
<span class="k">if</span> <span class="s1">'SOURCE_DATE_EPOCH'</span> <span class="ow">in</span> <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">:</span>
|
||||
<span class="n">mkfsargs</span><span class="o">.</span><span class="n">extend</span><span class="p">([</span><span class="s2">"-i"</span><span class="p">,</span>
|
||||
<span class="s2">"</span><span class="si">{:x}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">int</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">[</span><span class="s1">'SOURCE_DATE_EPOCH'</span><span class="p">]))])</span>
|
||||
<span class="n">mkfsimage</span><span class="p">(</span><span class="s2">"msdos"</span><span class="p">,</span> <span class="n">rootdir</span><span class="p">,</span> <span class="n">outfile</span><span class="p">,</span> <span class="n">size</span><span class="p">,</span> <span class="n">mountargs</span><span class="o">=</span><span class="n">mountargs</span><span class="p">,</span>
|
||||
<span class="n">mkfsargs</span><span class="o">=</span><span class="p">[</span><span class="s2">"-n"</span><span class="p">,</span> <span class="n">label</span><span class="p">],</span> <span class="n">graft</span><span class="o">=</span><span class="n">graft</span><span class="p">)</span></div>
|
||||
<span class="n">mkfsargs</span><span class="o">=</span><span class="n">mkfsargs</span><span class="p">,</span> <span class="n">graft</span><span class="o">=</span><span class="n">graft</span><span class="p">)</span></div>
|
||||
|
||||
<div class="viewcode-block" id="mkext4img"><a class="viewcode-back" href="../../pylorax.html#pylorax.imgutils.mkext4img">[docs]</a><span class="k">def</span> <span class="nf">mkext4img</span><span class="p">(</span><span class="n">rootdir</span><span class="p">,</span> <span class="n">outfile</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="s2">""</span><span class="p">,</span> <span class="n">mountargs</span><span class="o">=</span><span class="s2">""</span><span class="p">,</span> <span class="n">graft</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
<span class="n">graft</span> <span class="o">=</span> <span class="n">graft</span> <span class="ow">or</span> <span class="p">{}</span>
|
||||
@ -647,68 +637,67 @@
|
||||
<span class="n">graft</span> <span class="o">=</span> <span class="n">graft</span> <span class="ow">or</span> <span class="p">{}</span>
|
||||
<span class="n">mkfsimage</span><span class="p">(</span><span class="s2">"hfsplus"</span><span class="p">,</span> <span class="n">rootdir</span><span class="p">,</span> <span class="n">outfile</span><span class="p">,</span> <span class="n">size</span><span class="p">,</span> <span class="n">mountargs</span><span class="o">=</span><span class="n">mountargs</span><span class="p">,</span>
|
||||
<span class="n">mkfsargs</span><span class="o">=</span><span class="p">[</span><span class="s2">"-v"</span><span class="p">,</span> <span class="n">label</span><span class="p">],</span> <span class="n">graft</span><span class="o">=</span><span class="n">graft</span><span class="p">)</span></div>
|
||||
</pre></div>
|
||||
|
||||
</div>
|
||||
<div class="articleComments">
|
||||
<div class="viewcode-block" id="mkfsimage_from_disk"><a class="viewcode-back" href="../../pylorax.html#pylorax.imgutils.mkfsimage_from_disk">[docs]</a><span class="k">def</span> <span class="nf">mkfsimage_from_disk</span><span class="p">(</span><span class="n">diskimage</span><span class="p">,</span> <span class="n">fsimage</span><span class="p">,</span> <span class="n">img_size</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="s2">"Anaconda"</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Copy the / partition of a partitioned disk image to an un-partitioned</span>
|
||||
<span class="sd"> disk image.</span>
|
||||
|
||||
<span class="sd"> :param str diskimage: The full path to partitioned disk image with a /</span>
|
||||
<span class="sd"> :param str fsimage: The full path of the output fs image file</span>
|
||||
<span class="sd"> :param int img_size: Optional size of the fsimage in MiB or None to make</span>
|
||||
<span class="sd"> it as small as possible</span>
|
||||
<span class="sd"> :param str label: The label to apply to the image. Defaults to "Anaconda"</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">with</span> <span class="n">PartitionMount</span><span class="p">(</span><span class="n">diskimage</span><span class="p">)</span> <span class="k">as</span> <span class="n">img_mount</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">img_mount</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">img_mount</span><span class="o">.</span><span class="n">mount_dir</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="kc">None</span>
|
||||
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"Creating fsimage </span><span class="si">%s</span><span class="s2"> (</span><span class="si">%s</span><span class="s2">)"</span><span class="p">,</span> <span class="n">fsimage</span><span class="p">,</span> <span class="n">img_size</span> <span class="ow">or</span> <span class="s2">"minimized"</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">img_size</span><span class="p">:</span>
|
||||
<span class="c1"># convert to Bytes</span>
|
||||
<span class="n">img_size</span> <span class="o">*=</span> <span class="mi">1024</span><span class="o">**</span><span class="mi">2</span>
|
||||
|
||||
<span class="n">mkext4img</span><span class="p">(</span><span class="n">img_mount</span><span class="o">.</span><span class="n">mount_dir</span><span class="p">,</span> <span class="n">fsimage</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="n">img_size</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="n">label</span><span class="p">)</span></div>
|
||||
|
||||
<div class="viewcode-block" id="default_image_name"><a class="viewcode-back" href="../../pylorax.html#pylorax.imgutils.default_image_name">[docs]</a><span class="k">def</span> <span class="nf">default_image_name</span><span class="p">(</span><span class="n">compression</span><span class="p">,</span> <span class="n">basename</span><span class="p">):</span>
|
||||
<span class="sd">""" Return a default image name with the correct suffix for the compression type.</span>
|
||||
|
||||
<span class="sd"> :param str compression: Compression type</span>
|
||||
<span class="sd"> :param str basename: Base filename</span>
|
||||
<span class="sd"> :returns: basename with compression suffix</span>
|
||||
|
||||
<span class="sd"> If the compression is unknown it defaults to xz</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">SUFFIXES</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"xz"</span><span class="p">:</span> <span class="s2">".xz"</span><span class="p">,</span> <span class="s2">"gzip"</span><span class="p">:</span> <span class="s2">".gz"</span><span class="p">,</span> <span class="s2">"bzip2"</span><span class="p">:</span> <span class="s2">".bz2"</span><span class="p">,</span> <span class="s2">"lzma"</span><span class="p">:</span> <span class="s2">".lzma"</span><span class="p">}</span>
|
||||
<span class="k">return</span> <span class="n">basename</span> <span class="o">+</span> <span class="n">SUFFIXES</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">compression</span><span class="p">,</span> <span class="s2">".xz"</span><span class="p">)</span></div>
|
||||
</pre></div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<footer>
|
||||
|
||||
|
||||
<hr/>
|
||||
|
||||
<div role="contentinfo">
|
||||
<p>
|
||||
© Copyright 2015, Red Hat, Inc..
|
||||
|
||||
</p>
|
||||
<p>© Copyright 2018, Red Hat, Inc..</p>
|
||||
</div>
|
||||
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||||
|
||||
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
|
||||
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
|
||||
provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||||
|
||||
|
||||
</footer>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
var DOCUMENTATION_OPTIONS = {
|
||||
URL_ROOT:'../../',
|
||||
VERSION:'28.2',
|
||||
COLLAPSE_INDEX:false,
|
||||
FILE_SUFFIX:'.html',
|
||||
HAS_SOURCE: true,
|
||||
SOURCELINK_SUFFIX: '.txt'
|
||||
};
|
||||
</script>
|
||||
<script type="text/javascript" src="../../_static/jquery.js"></script>
|
||||
<script type="text/javascript" src="../../_static/underscore.js"></script>
|
||||
<script type="text/javascript" src="../../_static/doctools.js"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript" src="../../_static/js/theme.js"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
<script>
|
||||
jQuery(function () {
|
||||
SphinxRtdTheme.StickyNav.enable();
|
||||
SphinxRtdTheme.Navigation.enable(true);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
793
docs/html/_modules/pylorax/installer.html
Normal file
@ -0,0 +1,793 @@
|
||||
<!DOCTYPE html>
|
||||
<html class="writer-html5" lang="en" >
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pylorax.installer — Lorax 36.4 documentation</title>
|
||||
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
|
||||
<link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
|
||||
|
||||
<script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
|
||||
<script src="../../_static/jquery.js"></script>
|
||||
<script src="../../_static/underscore.js"></script>
|
||||
<script src="../../_static/doctools.js"></script>
|
||||
<script src="../../_static/js/theme.js"></script>
|
||||
<link rel="index" title="Index" href="../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../search.html" />
|
||||
</head>
|
||||
|
||||
<body class="wy-body-for-nav">
|
||||
<div class="wy-grid-for-nav">
|
||||
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
|
||||
<div class="wy-side-scroll">
|
||||
<div class="wy-side-nav-search" >
|
||||
<a href="../../index.html" class="icon icon-home"> Lorax
|
||||
</a>
|
||||
<div class="version">
|
||||
36.4
|
||||
</div>
|
||||
<div role="search">
|
||||
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
|
||||
<input type="text" name="q" placeholder="Search docs" />
|
||||
<input type="hidden" name="check_keywords" value="yes" />
|
||||
<input type="hidden" name="area" value="default" />
|
||||
</form>
|
||||
</div>
|
||||
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../intro.html">Introduction to Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../intro.html#before-lorax">Before Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../lorax.html">Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../livemedia-creator.html">livemedia-creator</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../mkksiso.html">mkksiso</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../product-images.html">Product and Updates Images</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../modules.html">src</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
|
||||
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
||||
<a href="../../index.html">Lorax</a>
|
||||
</nav>
|
||||
|
||||
<div class="wy-nav-content">
|
||||
<div class="rst-content">
|
||||
<div role="navigation" aria-label="Page navigation">
|
||||
<ul class="wy-breadcrumbs">
|
||||
<li><a href="../../index.html" class="icon icon-home"></a> »</li>
|
||||
<li><a href="../index.html">Module code</a> »</li>
|
||||
<li><a href="../pylorax.html">pylorax</a> »</li>
|
||||
<li>pylorax.installer</li>
|
||||
<li class="wy-breadcrumbs-aside">
|
||||
</li>
|
||||
</ul>
|
||||
<hr/>
|
||||
</div>
|
||||
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
|
||||
<div itemprop="articleBody">
|
||||
|
||||
<h1>Source code for pylorax.installer</h1><div class="highlight"><pre>
|
||||
<span></span><span class="c1">#</span>
|
||||
<span class="c1"># Copyright (C) 2011-2018 Red Hat, Inc.</span>
|
||||
<span class="c1">#</span>
|
||||
<span class="c1"># This program is free software; you can redistribute it and/or modify</span>
|
||||
<span class="c1"># it under the terms of the GNU General Public License as published by</span>
|
||||
<span class="c1"># the Free Software Foundation; either version 2 of the License, or</span>
|
||||
<span class="c1"># (at your option) any later version.</span>
|
||||
<span class="c1">#</span>
|
||||
<span class="c1"># This program is distributed in the hope that it will be useful,</span>
|
||||
<span class="c1"># but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
<span class="c1"># MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
|
||||
<span class="c1"># GNU General Public License for more details.</span>
|
||||
<span class="c1">#</span>
|
||||
<span class="c1"># You should have received a copy of the GNU General Public License</span>
|
||||
<span class="c1"># along with this program. If not, see <http://www.gnu.org/licenses/>.</span>
|
||||
<span class="c1">#</span>
|
||||
<span class="kn">import</span> <span class="nn">logging</span>
|
||||
<span class="n">log</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="s2">"pylorax"</span><span class="p">)</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">glob</span>
|
||||
<span class="kn">import</span> <span class="nn">json</span>
|
||||
<span class="kn">from</span> <span class="nn">math</span> <span class="kn">import</span> <span class="n">ceil</span>
|
||||
<span class="kn">import</span> <span class="nn">os</span>
|
||||
<span class="kn">import</span> <span class="nn">subprocess</span>
|
||||
<span class="kn">import</span> <span class="nn">shutil</span>
|
||||
<span class="kn">import</span> <span class="nn">socket</span>
|
||||
<span class="kn">import</span> <span class="nn">tempfile</span>
|
||||
|
||||
<span class="c1"># Use the Lorax treebuilder branch for iso creation</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.executils</span> <span class="kn">import</span> <span class="n">execWithRedirect</span><span class="p">,</span> <span class="n">execReadlines</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.imgutils</span> <span class="kn">import</span> <span class="n">PartitionMount</span><span class="p">,</span> <span class="n">mksparse</span><span class="p">,</span> <span class="n">mkext4img</span><span class="p">,</span> <span class="n">loop_detach</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.imgutils</span> <span class="kn">import</span> <span class="n">get_loop_name</span><span class="p">,</span> <span class="n">dm_detach</span><span class="p">,</span> <span class="n">mount</span><span class="p">,</span> <span class="n">umount</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.imgutils</span> <span class="kn">import</span> <span class="n">mkqemu_img</span><span class="p">,</span> <span class="n">mktar</span><span class="p">,</span> <span class="n">mkcpio</span><span class="p">,</span> <span class="n">mkfsimage_from_disk</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.monitor</span> <span class="kn">import</span> <span class="n">LogMonitor</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.mount</span> <span class="kn">import</span> <span class="n">IsoMountpoint</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.sysutils</span> <span class="kn">import</span> <span class="n">joinpaths</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.treebuilder</span> <span class="kn">import</span> <span class="n">udev_escape</span>
|
||||
|
||||
|
||||
<span class="n">ROOT_PATH</span> <span class="o">=</span> <span class="s2">"/mnt/sysimage/"</span>
|
||||
|
||||
<div class="viewcode-block" id="InstallError"><a class="viewcode-back" href="../../pylorax.html#pylorax.installer.InstallError">[docs]</a><span class="k">class</span> <span class="nc">InstallError</span><span class="p">(</span><span class="ne">Exception</span><span class="p">):</span>
|
||||
<span class="k">pass</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="create_vagrant_metadata"><a class="viewcode-back" href="../../pylorax.html#pylorax.installer.create_vagrant_metadata">[docs]</a><span class="k">def</span> <span class="nf">create_vagrant_metadata</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span>
|
||||
<span class="sd">""" Create a default Vagrant metadata.json file</span>
|
||||
|
||||
<span class="sd"> :param str path: Path to metadata.json file</span>
|
||||
<span class="sd"> :param int size: Disk size in MiB</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">metadata</span> <span class="o">=</span> <span class="p">{</span> <span class="s2">"provider"</span><span class="p">:</span><span class="s2">"libvirt"</span><span class="p">,</span> <span class="s2">"format"</span><span class="p">:</span><span class="s2">"qcow2"</span><span class="p">,</span> <span class="s2">"virtual_size"</span><span class="p">:</span> <span class="n">ceil</span><span class="p">(</span><span class="n">size</span> <span class="o">/</span> <span class="mi">1024</span><span class="p">)</span> <span class="p">}</span>
|
||||
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="s2">"wt"</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
|
||||
<span class="n">json</span><span class="o">.</span><span class="n">dump</span><span class="p">(</span><span class="n">metadata</span><span class="p">,</span> <span class="n">f</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="mi">4</span><span class="p">)</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="update_vagrant_metadata"><a class="viewcode-back" href="../../pylorax.html#pylorax.installer.update_vagrant_metadata">[docs]</a><span class="k">def</span> <span class="nf">update_vagrant_metadata</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="n">size</span><span class="p">):</span>
|
||||
<span class="sd">""" Update the Vagrant metadata.json file</span>
|
||||
|
||||
<span class="sd"> :param str path: Path to metadata.json file</span>
|
||||
<span class="sd"> :param int size: Disk size in MiB</span>
|
||||
|
||||
<span class="sd"> This function makes sure that the provider, format and virtual size of the</span>
|
||||
<span class="sd"> metadata file are set correctly. All other values are left untouched.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="s2">"rt"</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="n">metadata</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
|
||||
<span class="k">except</span> <span class="ne">ValueError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="s2">"Problem reading metadata file </span><span class="si">%s</span><span class="s2">: </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">path</span><span class="p">,</span> <span class="n">e</span><span class="p">)</span>
|
||||
<span class="k">return</span>
|
||||
|
||||
<span class="n">metadata</span><span class="p">[</span><span class="s2">"provider"</span><span class="p">]</span> <span class="o">=</span> <span class="s2">"libvirt"</span>
|
||||
<span class="n">metadata</span><span class="p">[</span><span class="s2">"format"</span><span class="p">]</span> <span class="o">=</span> <span class="s2">"qcow2"</span>
|
||||
<span class="n">metadata</span><span class="p">[</span><span class="s2">"virtual_size"</span><span class="p">]</span> <span class="o">=</span> <span class="n">ceil</span><span class="p">(</span><span class="n">size</span> <span class="o">/</span> <span class="mi">1024</span><span class="p">)</span>
|
||||
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="s2">"wt"</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
|
||||
<span class="n">json</span><span class="o">.</span><span class="n">dump</span><span class="p">(</span><span class="n">metadata</span><span class="p">,</span> <span class="n">f</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="mi">4</span><span class="p">)</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="find_free_port"><a class="viewcode-back" href="../../pylorax.html#pylorax.installer.find_free_port">[docs]</a><span class="k">def</span> <span class="nf">find_free_port</span><span class="p">(</span><span class="n">start</span><span class="o">=</span><span class="mi">5900</span><span class="p">,</span> <span class="n">end</span><span class="o">=</span><span class="mi">5999</span><span class="p">,</span> <span class="n">host</span><span class="o">=</span><span class="s2">"127.0.0.1"</span><span class="p">):</span>
|
||||
<span class="sd">""" Return first free port in range.</span>
|
||||
|
||||
<span class="sd"> :param int start: Starting port number</span>
|
||||
<span class="sd"> :param int end: Ending port number</span>
|
||||
<span class="sd"> :param str host: Host IP to search</span>
|
||||
<span class="sd"> :returns: First free port or -1 if none found</span>
|
||||
<span class="sd"> :rtype: int</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">s</span> <span class="o">=</span> <span class="n">socket</span><span class="o">.</span><span class="n">socket</span><span class="p">(</span><span class="n">socket</span><span class="o">.</span><span class="n">AF_INET</span><span class="p">,</span> <span class="n">socket</span><span class="o">.</span><span class="n">SOCK_STREAM</span><span class="p">)</span>
|
||||
<span class="k">for</span> <span class="n">port</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">start</span><span class="p">,</span> <span class="n">end</span><span class="o">+</span><span class="mi">1</span><span class="p">):</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="n">s</span><span class="o">.</span><span class="n">bind</span><span class="p">((</span><span class="n">host</span><span class="p">,</span> <span class="n">port</span><span class="p">))</span>
|
||||
<span class="n">s</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
|
||||
<span class="k">return</span> <span class="n">port</span>
|
||||
<span class="k">except</span> <span class="ne">OSError</span><span class="p">:</span>
|
||||
<span class="k">pass</span>
|
||||
|
||||
<span class="k">return</span> <span class="o">-</span><span class="mi">1</span></div>
|
||||
|
||||
<div class="viewcode-block" id="append_initrd"><a class="viewcode-back" href="../../pylorax.html#pylorax.installer.append_initrd">[docs]</a><span class="k">def</span> <span class="nf">append_initrd</span><span class="p">(</span><span class="n">initrd</span><span class="p">,</span> <span class="n">files</span><span class="p">):</span>
|
||||
<span class="sd">""" Append files to an initrd.</span>
|
||||
|
||||
<span class="sd"> :param str initrd: Path to initrd</span>
|
||||
<span class="sd"> :param list files: list of file paths to add</span>
|
||||
<span class="sd"> :returns: Path to a new initrd</span>
|
||||
<span class="sd"> :rtype: str</span>
|
||||
|
||||
<span class="sd"> The files are added to the initrd by creating a cpio image</span>
|
||||
<span class="sd"> of the files (stored at /) and writing the cpio to the end of a</span>
|
||||
<span class="sd"> copy of the initrd.</span>
|
||||
|
||||
<span class="sd"> The initrd is not changed, a copy is made before appending the</span>
|
||||
<span class="sd"> cpio archive.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">qemu_initrd</span> <span class="o">=</span> <span class="n">tempfile</span><span class="o">.</span><span class="n">mktemp</span><span class="p">(</span><span class="n">prefix</span><span class="o">=</span><span class="s2">"lmc-initrd-"</span><span class="p">,</span> <span class="n">suffix</span><span class="o">=</span><span class="s2">".img"</span><span class="p">)</span>
|
||||
<span class="n">shutil</span><span class="o">.</span><span class="n">copy2</span><span class="p">(</span><span class="n">initrd</span><span class="p">,</span> <span class="n">qemu_initrd</span><span class="p">)</span>
|
||||
<span class="n">ks_dir</span> <span class="o">=</span> <span class="n">tempfile</span><span class="o">.</span><span class="n">mkdtemp</span><span class="p">(</span><span class="n">prefix</span><span class="o">=</span><span class="s2">"lmc-ksdir-"</span><span class="p">)</span>
|
||||
<span class="k">for</span> <span class="n">ks</span> <span class="ow">in</span> <span class="n">files</span><span class="p">:</span>
|
||||
<span class="n">shutil</span><span class="o">.</span><span class="n">copy2</span><span class="p">(</span><span class="n">ks</span><span class="p">,</span> <span class="n">ks_dir</span><span class="p">)</span>
|
||||
<span class="n">ks_initrd</span> <span class="o">=</span> <span class="n">tempfile</span><span class="o">.</span><span class="n">mktemp</span><span class="p">(</span><span class="n">prefix</span><span class="o">=</span><span class="s2">"lmc-ks-"</span><span class="p">,</span> <span class="n">suffix</span><span class="o">=</span><span class="s2">".img"</span><span class="p">)</span>
|
||||
<span class="n">mkcpio</span><span class="p">(</span><span class="n">ks_dir</span><span class="p">,</span> <span class="n">ks_initrd</span><span class="p">)</span>
|
||||
<span class="n">shutil</span><span class="o">.</span><span class="n">rmtree</span><span class="p">(</span><span class="n">ks_dir</span><span class="p">)</span>
|
||||
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">qemu_initrd</span><span class="p">,</span> <span class="s2">"ab"</span><span class="p">)</span> <span class="k">as</span> <span class="n">initrd_fp</span><span class="p">:</span>
|
||||
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">ks_initrd</span><span class="p">,</span> <span class="s2">"rb"</span><span class="p">)</span> <span class="k">as</span> <span class="n">ks_fp</span><span class="p">:</span>
|
||||
<span class="k">while</span> <span class="kc">True</span><span class="p">:</span>
|
||||
<span class="n">data</span> <span class="o">=</span> <span class="n">ks_fp</span><span class="o">.</span><span class="n">read</span><span class="p">(</span><span class="mi">1024</span><span class="o">**</span><span class="mi">2</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">data</span><span class="p">:</span>
|
||||
<span class="k">break</span>
|
||||
<span class="n">initrd_fp</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
|
||||
<span class="n">os</span><span class="o">.</span><span class="n">unlink</span><span class="p">(</span><span class="n">ks_initrd</span><span class="p">)</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">qemu_initrd</span></div>
|
||||
|
||||
<div class="viewcode-block" id="QEMUInstall"><a class="viewcode-back" href="../../pylorax.html#pylorax.installer.QEMUInstall">[docs]</a><span class="k">class</span> <span class="nc">QEMUInstall</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Run qemu using an iso and a kickstart</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="c1"># Mapping of arch to qemu command</span>
|
||||
<span class="n">QEMU_CMDS</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"x86_64"</span><span class="p">:</span> <span class="s2">"qemu-system-x86_64"</span><span class="p">,</span>
|
||||
<span class="s2">"i386"</span><span class="p">:</span> <span class="s2">"qemu-system-i386"</span><span class="p">,</span>
|
||||
<span class="s2">"arm"</span><span class="p">:</span> <span class="s2">"qemu-system-arm"</span><span class="p">,</span>
|
||||
<span class="s2">"aarch64"</span><span class="p">:</span> <span class="s2">"qemu-system-aarch64"</span><span class="p">,</span>
|
||||
<span class="s2">"ppc64le"</span><span class="p">:</span> <span class="s2">"qemu-system-ppc64"</span>
|
||||
<span class="p">}</span>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">opts</span><span class="p">,</span> <span class="n">iso</span><span class="p">,</span> <span class="n">ks_paths</span><span class="p">,</span> <span class="n">disk_img</span><span class="p">,</span> <span class="n">img_size</span><span class="o">=</span><span class="mi">2048</span><span class="p">,</span>
|
||||
<span class="n">kernel_args</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">memory</span><span class="o">=</span><span class="mi">1024</span><span class="p">,</span> <span class="n">vcpus</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">vnc</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">arch</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
|
||||
<span class="n">cancel_func</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">virtio_host</span><span class="o">=</span><span class="s2">"127.0.0.1"</span><span class="p">,</span> <span class="n">virtio_port</span><span class="o">=</span><span class="mi">6080</span><span class="p">,</span>
|
||||
<span class="n">image_type</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">boot_uefi</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">ovmf_path</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Start the installation</span>
|
||||
|
||||
<span class="sd"> :param iso: Information about the iso to use for the installation</span>
|
||||
<span class="sd"> :type iso: IsoMountpoint</span>
|
||||
<span class="sd"> :param list ks_paths: Paths to kickstart files. All are injected, the</span>
|
||||
<span class="sd"> first one is the one executed.</span>
|
||||
<span class="sd"> :param str disk_img: Path to a disk image, created it it doesn't exist</span>
|
||||
<span class="sd"> :param int img_size: The image size, in MiB, to create if it doesn't exist</span>
|
||||
<span class="sd"> :param str kernel_args: Extra kernel arguments to pass on the kernel cmdline</span>
|
||||
<span class="sd"> :param int memory: Amount of RAM to assign to the virt, in MiB</span>
|
||||
<span class="sd"> :param int vcpus: Number of virtual cpus</span>
|
||||
<span class="sd"> :param str vnc: Arguments to pass to qemu -display</span>
|
||||
<span class="sd"> :param str arch: Optional architecture to use in the virt</span>
|
||||
<span class="sd"> :param cancel_func: Function that returns True if the installation fails</span>
|
||||
<span class="sd"> :type cancel_func: function</span>
|
||||
<span class="sd"> :param str virtio_host: Hostname to connect virtio log to</span>
|
||||
<span class="sd"> :param int virtio_port: Port to connect virtio log to</span>
|
||||
<span class="sd"> :param str image_type: Type of qemu-img disk to create, or None.</span>
|
||||
<span class="sd"> :param bool boot_uefi: Use OVMF to boot the VM in UEFI mode</span>
|
||||
<span class="sd"> :param str ovmf_path: Path to the OVMF firmware</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="c1"># Lookup qemu-system- for arch if passed, or try to guess using host arch</span>
|
||||
<span class="n">qemu_cmd</span> <span class="o">=</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">QEMU_CMDS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">arch</span> <span class="ow">or</span> <span class="n">os</span><span class="o">.</span><span class="n">uname</span><span class="p">()</span><span class="o">.</span><span class="n">machine</span><span class="p">,</span> <span class="s2">"qemu-system-"</span><span class="o">+</span><span class="n">os</span><span class="o">.</span><span class="n">uname</span><span class="p">()</span><span class="o">.</span><span class="n">machine</span><span class="p">)]</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="s2">"/usr/bin/"</span><span class="o">+</span><span class="n">qemu_cmd</span><span class="p">[</span><span class="mi">0</span><span class="p">]):</span>
|
||||
<span class="k">raise</span> <span class="n">InstallError</span><span class="p">(</span><span class="s2">"</span><span class="si">%s</span><span class="s2"> does not exist, cannot run qemu"</span> <span class="o">%</span> <span class="n">qemu_cmd</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
|
||||
|
||||
<span class="n">qemu_cmd</span> <span class="o">+=</span> <span class="p">[</span><span class="s2">"-no-user-config"</span><span class="p">]</span>
|
||||
<span class="n">qemu_cmd</span> <span class="o">+=</span> <span class="p">[</span><span class="s2">"-m"</span><span class="p">,</span> <span class="nb">str</span><span class="p">(</span><span class="n">memory</span><span class="p">)]</span>
|
||||
<span class="k">if</span> <span class="n">vcpus</span><span class="p">:</span>
|
||||
<span class="n">qemu_cmd</span> <span class="o">+=</span> <span class="p">[</span><span class="s2">"-smp"</span><span class="p">,</span> <span class="nb">str</span><span class="p">(</span><span class="n">vcpus</span><span class="p">)]</span>
|
||||
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">opts</span><span class="o">.</span><span class="n">no_kvm</span> <span class="ow">and</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="s2">"/dev/kvm"</span><span class="p">):</span>
|
||||
<span class="n">qemu_cmd</span> <span class="o">+=</span> <span class="p">[</span><span class="s2">"-machine"</span><span class="p">,</span> <span class="s2">"accel=kvm"</span><span class="p">]</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">boot_uefi</span><span class="p">:</span>
|
||||
<span class="n">qemu_cmd</span> <span class="o">+=</span> <span class="p">[</span><span class="s2">"-machine"</span><span class="p">,</span> <span class="s2">"q35,smm=on"</span><span class="p">]</span>
|
||||
<span class="n">qemu_cmd</span> <span class="o">+=</span> <span class="p">[</span><span class="s2">"-global"</span><span class="p">,</span> <span class="s2">"driver=cfi.pflash01,property=secure,value=on"</span><span class="p">]</span>
|
||||
|
||||
<span class="c1"># Copy the initrd from the iso, create a cpio archive of the kickstart files</span>
|
||||
<span class="c1"># and append it to the temporary initrd.</span>
|
||||
<span class="n">qemu_initrd</span> <span class="o">=</span> <span class="n">append_initrd</span><span class="p">(</span><span class="n">iso</span><span class="o">.</span><span class="n">initrd</span><span class="p">,</span> <span class="n">ks_paths</span><span class="p">)</span>
|
||||
<span class="n">qemu_cmd</span> <span class="o">+=</span> <span class="p">[</span><span class="s2">"-kernel"</span><span class="p">,</span> <span class="n">iso</span><span class="o">.</span><span class="n">kernel</span><span class="p">]</span>
|
||||
<span class="n">qemu_cmd</span> <span class="o">+=</span> <span class="p">[</span><span class="s2">"-initrd"</span><span class="p">,</span> <span class="n">qemu_initrd</span><span class="p">]</span>
|
||||
|
||||
<span class="c1"># Add the disk and cdrom</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">disk_img</span><span class="p">):</span>
|
||||
<span class="n">mksparse</span><span class="p">(</span><span class="n">disk_img</span><span class="p">,</span> <span class="n">img_size</span> <span class="o">*</span> <span class="mi">1024</span><span class="o">**</span><span class="mi">2</span><span class="p">)</span>
|
||||
<span class="n">drive_args</span> <span class="o">=</span> <span class="s2">"file=</span><span class="si">%s</span><span class="s2">"</span> <span class="o">%</span> <span class="n">disk_img</span>
|
||||
<span class="n">drive_args</span> <span class="o">+=</span> <span class="s2">",cache=unsafe,discard=unmap"</span>
|
||||
<span class="k">if</span> <span class="n">image_type</span><span class="p">:</span>
|
||||
<span class="n">drive_args</span> <span class="o">+=</span> <span class="s2">",format=</span><span class="si">%s</span><span class="s2">"</span> <span class="o">%</span> <span class="n">image_type</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">drive_args</span> <span class="o">+=</span> <span class="s2">",format=raw"</span>
|
||||
<span class="n">qemu_cmd</span> <span class="o">+=</span> <span class="p">[</span><span class="s2">"-drive"</span><span class="p">,</span> <span class="n">drive_args</span><span class="p">]</span>
|
||||
|
||||
<span class="n">drive_args</span> <span class="o">=</span> <span class="s2">"file=</span><span class="si">%s</span><span class="s2">,media=cdrom,readonly=on"</span> <span class="o">%</span> <span class="n">iso</span><span class="o">.</span><span class="n">iso_path</span>
|
||||
<span class="n">qemu_cmd</span> <span class="o">+=</span> <span class="p">[</span><span class="s2">"-drive"</span><span class="p">,</span> <span class="n">drive_args</span><span class="p">]</span>
|
||||
|
||||
<span class="c1"># Setup the cmdline args</span>
|
||||
<span class="c1"># ======================</span>
|
||||
<span class="n">cmdline_args</span> <span class="o">=</span> <span class="s2">"inst.ks=file:/</span><span class="si">%s</span><span class="s2">"</span> <span class="o">%</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">basename</span><span class="p">(</span><span class="n">ks_paths</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
|
||||
<span class="n">cmdline_args</span> <span class="o">+=</span> <span class="s2">" inst.stage2=hd:LABEL=</span><span class="si">%s</span><span class="s2">"</span> <span class="o">%</span> <span class="n">udev_escape</span><span class="p">(</span><span class="n">iso</span><span class="o">.</span><span class="n">label</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">opts</span><span class="o">.</span><span class="n">proxy</span><span class="p">:</span>
|
||||
<span class="n">cmdline_args</span> <span class="o">+=</span> <span class="s2">" inst.proxy=</span><span class="si">%s</span><span class="s2">"</span> <span class="o">%</span> <span class="n">opts</span><span class="o">.</span><span class="n">proxy</span>
|
||||
<span class="k">if</span> <span class="n">kernel_args</span><span class="p">:</span>
|
||||
<span class="n">cmdline_args</span> <span class="o">+=</span> <span class="s2">" "</span><span class="o">+</span><span class="n">kernel_args</span>
|
||||
<span class="n">cmdline_args</span> <span class="o">+=</span> <span class="s2">" inst.text inst.cmdline"</span>
|
||||
|
||||
<span class="n">qemu_cmd</span> <span class="o">+=</span> <span class="p">[</span><span class="s2">"-append"</span><span class="p">,</span> <span class="n">cmdline_args</span><span class="p">]</span>
|
||||
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">opts</span><span class="o">.</span><span class="n">vnc</span><span class="p">:</span>
|
||||
<span class="n">vnc_port</span> <span class="o">=</span> <span class="n">find_free_port</span><span class="p">()</span>
|
||||
<span class="k">if</span> <span class="n">vnc_port</span> <span class="o">==</span> <span class="o">-</span><span class="mi">1</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="n">InstallError</span><span class="p">(</span><span class="s2">"No free VNC ports"</span><span class="p">)</span>
|
||||
<span class="n">display_args</span> <span class="o">=</span> <span class="s2">"vnc=127.0.0.1:</span><span class="si">%d</span><span class="s2">"</span> <span class="o">%</span> <span class="p">(</span><span class="n">vnc_port</span> <span class="o">-</span> <span class="mi">5900</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">display_args</span> <span class="o">=</span> <span class="n">opts</span><span class="o">.</span><span class="n">vnc</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"qemu </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">display_args</span><span class="p">)</span>
|
||||
<span class="n">qemu_cmd</span> <span class="o">+=</span> <span class="p">[</span><span class="s2">"-nographic"</span><span class="p">,</span> <span class="s2">"-monitor"</span><span class="p">,</span> <span class="s2">"none"</span><span class="p">,</span> <span class="s2">"-serial"</span><span class="p">,</span> <span class="s2">"null"</span><span class="p">,</span> <span class="s2">"-display"</span><span class="p">,</span> <span class="n">display_args</span> <span class="p">]</span>
|
||||
|
||||
<span class="c1"># Setup the virtio log port</span>
|
||||
<span class="n">qemu_cmd</span> <span class="o">+=</span> <span class="p">[</span><span class="s2">"-device"</span><span class="p">,</span> <span class="s2">"virtio-serial-pci,id=virtio-serial0"</span><span class="p">]</span>
|
||||
<span class="n">qemu_cmd</span> <span class="o">+=</span> <span class="p">[</span><span class="s2">"-device"</span><span class="p">,</span> <span class="s2">"virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0"</span>
|
||||
<span class="s2">",id=channel0,name=org.fedoraproject.anaconda.log.0"</span><span class="p">]</span>
|
||||
<span class="n">qemu_cmd</span> <span class="o">+=</span> <span class="p">[</span><span class="s2">"-chardev"</span><span class="p">,</span> <span class="s2">"socket,id=charchannel0,host=</span><span class="si">%s</span><span class="s2">,port=</span><span class="si">%s</span><span class="s2">"</span> <span class="o">%</span> <span class="p">(</span><span class="n">virtio_host</span><span class="p">,</span> <span class="n">virtio_port</span><span class="p">)]</span>
|
||||
|
||||
<span class="c1"># Pass through rng from host</span>
|
||||
<span class="k">if</span> <span class="n">opts</span><span class="o">.</span><span class="n">with_rng</span> <span class="o">!=</span> <span class="s2">"none"</span><span class="p">:</span>
|
||||
<span class="n">qemu_cmd</span> <span class="o">+=</span> <span class="p">[</span><span class="s2">"-object"</span><span class="p">,</span> <span class="s2">"rng-random,id=virtio-rng0,filename=</span><span class="si">%s</span><span class="s2">"</span> <span class="o">%</span> <span class="n">opts</span><span class="o">.</span><span class="n">with_rng</span><span class="p">]</span>
|
||||
<span class="k">if</span> <span class="n">boot_uefi</span><span class="p">:</span>
|
||||
<span class="n">qemu_cmd</span> <span class="o">+=</span> <span class="p">[</span><span class="s2">"-device"</span><span class="p">,</span> <span class="s2">"virtio-rng-pci,rng=virtio-rng0,id=rng0,bus=pcie.0,addr=0x9"</span><span class="p">]</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">qemu_cmd</span> <span class="o">+=</span> <span class="p">[</span><span class="s2">"-device"</span><span class="p">,</span> <span class="s2">"virtio-rng-pci,rng=virtio-rng0,id=rng0,bus=pci.0,addr=0x9"</span><span class="p">]</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">boot_uefi</span> <span class="ow">and</span> <span class="n">ovmf_path</span><span class="p">:</span>
|
||||
<span class="n">qemu_cmd</span> <span class="o">+=</span> <span class="p">[</span><span class="s2">"-drive"</span><span class="p">,</span> <span class="s2">"file=</span><span class="si">%s</span><span class="s2">/OVMF_CODE.secboot.fd,if=pflash,format=raw,unit=0,readonly=on"</span> <span class="o">%</span> <span class="n">ovmf_path</span><span class="p">]</span>
|
||||
|
||||
<span class="c1"># Make a copy of the OVMF_VARS.secboot.fd for this run</span>
|
||||
<span class="n">ovmf_vars</span> <span class="o">=</span> <span class="n">tempfile</span><span class="o">.</span><span class="n">mktemp</span><span class="p">(</span><span class="n">prefix</span><span class="o">=</span><span class="s2">"lmc-OVMF_VARS-"</span><span class="p">,</span> <span class="n">suffix</span><span class="o">=</span><span class="s2">".fd"</span><span class="p">)</span>
|
||||
<span class="n">shutil</span><span class="o">.</span><span class="n">copy2</span><span class="p">(</span><span class="n">joinpaths</span><span class="p">(</span><span class="n">ovmf_path</span><span class="p">,</span> <span class="s2">"/OVMF_VARS.secboot.fd"</span><span class="p">),</span> <span class="n">ovmf_vars</span><span class="p">)</span>
|
||||
|
||||
<span class="n">qemu_cmd</span> <span class="o">+=</span> <span class="p">[</span><span class="s2">"-drive"</span><span class="p">,</span> <span class="s2">"file=</span><span class="si">%s</span><span class="s2">,if=pflash,format=raw,unit=1"</span> <span class="o">%</span> <span class="n">ovmf_vars</span><span class="p">]</span>
|
||||
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"Running qemu"</span><span class="p">)</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="n">qemu_cmd</span><span class="p">)</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="n">execWithRedirect</span><span class="p">(</span><span class="n">qemu_cmd</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">qemu_cmd</span><span class="p">[</span><span class="mi">1</span><span class="p">:],</span> <span class="n">reset_lang</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">raise_err</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
|
||||
<span class="n">callback</span><span class="o">=</span><span class="k">lambda</span> <span class="n">p</span><span class="p">:</span> <span class="ow">not</span> <span class="p">(</span><span class="n">cancel_func</span> <span class="ow">and</span> <span class="n">cancel_func</span><span class="p">()))</span>
|
||||
<span class="k">except</span> <span class="n">subprocess</span><span class="o">.</span><span class="n">CalledProcessError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="s2">"Running qemu failed:"</span><span class="p">)</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="s2">"cmd: </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="s2">" "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">cmd</span><span class="p">))</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="s2">"output: </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">output</span> <span class="ow">or</span> <span class="s2">""</span><span class="p">)</span>
|
||||
<span class="k">raise</span> <span class="n">InstallError</span><span class="p">(</span><span class="s2">"QEMUInstall failed"</span><span class="p">)</span>
|
||||
<span class="k">except</span> <span class="p">(</span><span class="ne">OSError</span><span class="p">,</span> <span class="ne">KeyboardInterrupt</span><span class="p">)</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="s2">"Running qemu failed: </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="p">))</span>
|
||||
<span class="k">raise</span> <span class="n">InstallError</span><span class="p">(</span><span class="s2">"QEMUInstall failed"</span><span class="p">)</span>
|
||||
<span class="k">finally</span><span class="p">:</span>
|
||||
<span class="n">os</span><span class="o">.</span><span class="n">unlink</span><span class="p">(</span><span class="n">qemu_initrd</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">boot_uefi</span> <span class="ow">and</span> <span class="n">ovmf_path</span><span class="p">:</span>
|
||||
<span class="n">os</span><span class="o">.</span><span class="n">unlink</span><span class="p">(</span><span class="n">ovmf_vars</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">cancel_func</span> <span class="ow">and</span> <span class="n">cancel_func</span><span class="p">():</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="s2">"Installation error detected. See logfile for details."</span><span class="p">)</span>
|
||||
<span class="k">raise</span> <span class="n">InstallError</span><span class="p">(</span><span class="s2">"QEMUInstall failed"</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"Installation finished without errors."</span><span class="p">)</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="novirt_cancel_check"><a class="viewcode-back" href="../../pylorax.html#pylorax.installer.novirt_cancel_check">[docs]</a><span class="k">def</span> <span class="nf">novirt_cancel_check</span><span class="p">(</span><span class="n">cancel_funcs</span><span class="p">,</span> <span class="n">proc</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Check to see if there has been an error in the logs</span>
|
||||
|
||||
<span class="sd"> :param cancel_funcs: list of functions to call, True from any one cancels the build</span>
|
||||
<span class="sd"> :type cancel_funcs: list</span>
|
||||
<span class="sd"> :param proc: Popen object for the anaconda process</span>
|
||||
<span class="sd"> :type proc: subprocess.Popen</span>
|
||||
<span class="sd"> :returns: True if the process has been terminated</span>
|
||||
|
||||
<span class="sd"> The cancel_funcs functions should return a True if an error has been detected.</span>
|
||||
<span class="sd"> When an error is detected the process is terminated and this returns True</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">cancel_funcs</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="n">f</span><span class="p">():</span>
|
||||
<span class="c1"># Anaconda runs from unshare, anaconda doesn't exit correctly so try to</span>
|
||||
<span class="c1"># send TERM to all of them directly</span>
|
||||
<span class="kn">import</span> <span class="nn">psutil</span>
|
||||
<span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">psutil</span><span class="o">.</span><span class="n">Process</span><span class="p">(</span><span class="n">proc</span><span class="o">.</span><span class="n">pid</span><span class="p">)</span><span class="o">.</span><span class="n">children</span><span class="p">(</span><span class="n">recursive</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span>
|
||||
<span class="n">p</span><span class="o">.</span><span class="n">terminate</span><span class="p">()</span>
|
||||
<span class="n">psutil</span><span class="o">.</span><span class="n">Process</span><span class="p">(</span><span class="n">proc</span><span class="o">.</span><span class="n">pid</span><span class="p">)</span><span class="o">.</span><span class="n">terminate</span><span class="p">()</span>
|
||||
<span class="k">return</span> <span class="kc">True</span>
|
||||
<span class="k">return</span> <span class="kc">False</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="anaconda_cleanup"><a class="viewcode-back" href="../../pylorax.html#pylorax.installer.anaconda_cleanup">[docs]</a><span class="k">def</span> <span class="nf">anaconda_cleanup</span><span class="p">(</span><span class="n">dirinstall_path</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Cleanup any leftover mounts from anaconda</span>
|
||||
|
||||
<span class="sd"> :param str dirinstall_path: Path where anaconda mounts things</span>
|
||||
<span class="sd"> :returns: True if cleanups were successful. False if any of them failed.</span>
|
||||
|
||||
<span class="sd"> If anaconda crashes it may leave things mounted under this path. It will</span>
|
||||
<span class="sd"> typically be set to /mnt/sysimage/</span>
|
||||
|
||||
<span class="sd"> Attempts to cleanup may also fail. Catch these and continue trying the</span>
|
||||
<span class="sd"> other mountpoints.</span>
|
||||
|
||||
<span class="sd"> Anaconda may also leave /run/anaconda.pid behind, clean that up as well.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="c1"># Anaconda may not clean up its /var/run/anaconda.pid file</span>
|
||||
<span class="c1"># Make sure the process is really finished (it should be, since it was started from a subprocess call)</span>
|
||||
<span class="c1"># and then remove the pid file.</span>
|
||||
<span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="s2">"/var/run/anaconda.pid"</span><span class="p">):</span>
|
||||
<span class="c1"># anaconda may be started using unshare so the pid is always 1</span>
|
||||
<span class="k">if</span> <span class="nb">open</span><span class="p">(</span><span class="s2">"/var/run/anaconda.pid"</span><span class="p">)</span><span class="o">.</span><span class="n">read</span><span class="p">()</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="o">==</span> <span class="s2">"1"</span><span class="p">:</span>
|
||||
<span class="n">os</span><span class="o">.</span><span class="n">unlink</span><span class="p">(</span><span class="s2">"/var/run/anaconda.pid"</span><span class="p">)</span>
|
||||
|
||||
<span class="n">rc</span> <span class="o">=</span> <span class="kc">True</span>
|
||||
<span class="n">dirinstall_path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">abspath</span><span class="p">(</span><span class="n">dirinstall_path</span><span class="p">)</span>
|
||||
<span class="c1"># unmount filesystems</span>
|
||||
<span class="k">for</span> <span class="n">mounted</span> <span class="ow">in</span> <span class="nb">reversed</span><span class="p">(</span><span class="nb">open</span><span class="p">(</span><span class="s2">"/proc/mounts"</span><span class="p">)</span><span class="o">.</span><span class="n">readlines</span><span class="p">()):</span>
|
||||
<span class="p">(</span><span class="n">_device</span><span class="p">,</span> <span class="n">mountpoint</span><span class="p">,</span> <span class="n">_rest</span><span class="p">)</span> <span class="o">=</span> <span class="n">mounted</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" "</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">mountpoint</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="n">dirinstall_path</span><span class="p">)</span> <span class="ow">and</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">ismount</span><span class="p">(</span><span class="n">mountpoint</span><span class="p">):</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="n">umount</span><span class="p">(</span><span class="n">mountpoint</span><span class="p">)</span>
|
||||
<span class="k">except</span> <span class="n">subprocess</span><span class="o">.</span><span class="n">CalledProcessError</span><span class="p">:</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="s2">"Cleanup of </span><span class="si">%s</span><span class="s2"> failed. See program.log for details"</span><span class="p">,</span> <span class="n">mountpoint</span><span class="p">)</span>
|
||||
<span class="n">rc</span> <span class="o">=</span> <span class="kc">False</span>
|
||||
<span class="k">return</span> <span class="n">rc</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="novirt_install"><a class="viewcode-back" href="../../pylorax.html#pylorax.installer.novirt_install">[docs]</a><span class="k">def</span> <span class="nf">novirt_install</span><span class="p">(</span><span class="n">opts</span><span class="p">,</span> <span class="n">disk_img</span><span class="p">,</span> <span class="n">disk_size</span><span class="p">,</span> <span class="n">cancel_func</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">tar_img</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Use Anaconda to install to a disk image</span>
|
||||
|
||||
<span class="sd"> :param opts: options passed to livemedia-creator</span>
|
||||
<span class="sd"> :type opts: argparse options</span>
|
||||
<span class="sd"> :param str disk_img: The full path to the disk image to be created</span>
|
||||
<span class="sd"> :param int disk_size: The size of the disk_img in MiB</span>
|
||||
<span class="sd"> :param cancel_func: Function that returns True to cancel build</span>
|
||||
<span class="sd"> :type cancel_func: function</span>
|
||||
<span class="sd"> :param str tar_img: For make_tar_disk, the path to final tarball to be created</span>
|
||||
|
||||
<span class="sd"> This method runs anaconda to create the image and then based on the opts</span>
|
||||
<span class="sd"> passed creates a qemu disk image or tarfile.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">dirinstall_path</span> <span class="o">=</span> <span class="n">ROOT_PATH</span>
|
||||
|
||||
<span class="c1"># Clean up /tmp/ from previous runs to prevent stale info from being used</span>
|
||||
<span class="k">for</span> <span class="n">path</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">"/tmp/yum.repos.d/"</span><span class="p">,</span> <span class="s2">"/tmp/yum.cache/"</span><span class="p">]:</span>
|
||||
<span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isdir</span><span class="p">(</span><span class="n">path</span><span class="p">):</span>
|
||||
<span class="n">shutil</span><span class="o">.</span><span class="n">rmtree</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
|
||||
|
||||
<span class="n">args</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"--kickstart"</span><span class="p">,</span> <span class="n">opts</span><span class="o">.</span><span class="n">ks</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="s2">"--cmdline"</span><span class="p">]</span>
|
||||
<span class="k">if</span> <span class="n">opts</span><span class="o">.</span><span class="n">anaconda_args</span><span class="p">:</span>
|
||||
<span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">opts</span><span class="o">.</span><span class="n">anaconda_args</span><span class="p">:</span>
|
||||
<span class="n">args</span> <span class="o">+=</span> <span class="n">arg</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" "</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">opts</span><span class="o">.</span><span class="n">proxy</span><span class="p">:</span>
|
||||
<span class="n">args</span> <span class="o">+=</span> <span class="p">[</span><span class="s2">"--proxy"</span><span class="p">,</span> <span class="n">opts</span><span class="o">.</span><span class="n">proxy</span><span class="p">]</span>
|
||||
<span class="k">if</span> <span class="n">opts</span><span class="o">.</span><span class="n">armplatform</span><span class="p">:</span>
|
||||
<span class="n">args</span> <span class="o">+=</span> <span class="p">[</span><span class="s2">"--armplatform"</span><span class="p">,</span> <span class="n">opts</span><span class="o">.</span><span class="n">armplatform</span><span class="p">]</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">opts</span><span class="o">.</span><span class="n">make_iso</span> <span class="ow">or</span> <span class="n">opts</span><span class="o">.</span><span class="n">make_fsimage</span> <span class="ow">or</span> <span class="n">opts</span><span class="o">.</span><span class="n">make_pxe_live</span><span class="p">:</span>
|
||||
<span class="c1"># Make a blank fs image</span>
|
||||
<span class="n">args</span> <span class="o">+=</span> <span class="p">[</span><span class="s2">"--dirinstall"</span><span class="p">]</span>
|
||||
|
||||
<span class="n">mkext4img</span><span class="p">(</span><span class="kc">None</span><span class="p">,</span> <span class="n">disk_img</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="n">opts</span><span class="o">.</span><span class="n">fs_label</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="n">disk_size</span> <span class="o">*</span> <span class="mi">1024</span><span class="o">**</span><span class="mi">2</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isdir</span><span class="p">(</span><span class="n">dirinstall_path</span><span class="p">):</span>
|
||||
<span class="n">os</span><span class="o">.</span><span class="n">mkdir</span><span class="p">(</span><span class="n">dirinstall_path</span><span class="p">)</span>
|
||||
<span class="n">mount</span><span class="p">(</span><span class="n">disk_img</span><span class="p">,</span> <span class="n">opts</span><span class="o">=</span><span class="s2">"loop"</span><span class="p">,</span> <span class="n">mnt</span><span class="o">=</span><span class="n">dirinstall_path</span><span class="p">)</span>
|
||||
<span class="k">elif</span> <span class="n">opts</span><span class="o">.</span><span class="n">make_tar</span> <span class="ow">or</span> <span class="n">opts</span><span class="o">.</span><span class="n">make_oci</span><span class="p">:</span>
|
||||
<span class="c1"># Install under dirinstall_path, make sure it starts clean</span>
|
||||
<span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="n">dirinstall_path</span><span class="p">):</span>
|
||||
<span class="n">shutil</span><span class="o">.</span><span class="n">rmtree</span><span class="p">(</span><span class="n">dirinstall_path</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">opts</span><span class="o">.</span><span class="n">make_oci</span><span class="p">:</span>
|
||||
<span class="c1"># OCI installs under /rootfs/</span>
|
||||
<span class="n">dirinstall_path</span> <span class="o">=</span> <span class="n">joinpaths</span><span class="p">(</span><span class="n">dirinstall_path</span><span class="p">,</span> <span class="s2">"rootfs"</span><span class="p">)</span>
|
||||
<span class="n">args</span> <span class="o">+=</span> <span class="p">[</span><span class="s2">"--dirinstall"</span><span class="p">,</span> <span class="n">dirinstall_path</span><span class="p">]</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">args</span> <span class="o">+=</span> <span class="p">[</span><span class="s2">"--dirinstall"</span><span class="p">]</span>
|
||||
|
||||
<span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span><span class="n">dirinstall_path</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">args</span> <span class="o">+=</span> <span class="p">[</span><span class="s2">"--image"</span><span class="p">,</span> <span class="n">disk_img</span><span class="p">]</span>
|
||||
|
||||
<span class="c1"># Create the sparse image</span>
|
||||
<span class="n">mksparse</span><span class="p">(</span><span class="n">disk_img</span><span class="p">,</span> <span class="n">disk_size</span> <span class="o">*</span> <span class="mi">1024</span><span class="o">**</span><span class="mi">2</span><span class="p">)</span>
|
||||
|
||||
<span class="n">log_monitor</span> <span class="o">=</span> <span class="n">LogMonitor</span><span class="p">(</span><span class="n">timeout</span><span class="o">=</span><span class="n">opts</span><span class="o">.</span><span class="n">timeout</span><span class="p">)</span>
|
||||
<span class="n">args</span> <span class="o">+=</span> <span class="p">[</span><span class="s2">"--remotelog"</span><span class="p">,</span> <span class="s2">"</span><span class="si">%s</span><span class="s2">:</span><span class="si">%s</span><span class="s2">"</span> <span class="o">%</span> <span class="p">(</span><span class="n">log_monitor</span><span class="o">.</span><span class="n">host</span><span class="p">,</span> <span class="n">log_monitor</span><span class="o">.</span><span class="n">port</span><span class="p">)]</span>
|
||||
<span class="n">cancel_funcs</span> <span class="o">=</span> <span class="p">[</span><span class="n">log_monitor</span><span class="o">.</span><span class="n">server</span><span class="o">.</span><span class="n">log_check</span><span class="p">]</span>
|
||||
<span class="k">if</span> <span class="n">cancel_func</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="n">cancel_funcs</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">cancel_func</span><span class="p">)</span>
|
||||
|
||||
<span class="c1"># Make sure anaconda has the right product and release</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"Running anaconda."</span><span class="p">)</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="n">unshare_args</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"--pid"</span><span class="p">,</span> <span class="s2">"--kill-child"</span><span class="p">,</span> <span class="s2">"--mount"</span><span class="p">,</span> <span class="s2">"--propagation"</span><span class="p">,</span> <span class="s2">"unchanged"</span><span class="p">,</span> <span class="s2">"anaconda"</span><span class="p">]</span> <span class="o">+</span> <span class="n">args</span>
|
||||
<span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="n">execReadlines</span><span class="p">(</span><span class="s2">"unshare"</span><span class="p">,</span> <span class="n">unshare_args</span><span class="p">,</span> <span class="n">reset_lang</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
|
||||
<span class="n">env_add</span><span class="o">=</span><span class="p">{</span><span class="s2">"ANACONDA_PRODUCTNAME"</span><span class="p">:</span> <span class="n">opts</span><span class="o">.</span><span class="n">project</span><span class="p">,</span>
|
||||
<span class="s2">"ANACONDA_PRODUCTVERSION"</span><span class="p">:</span> <span class="n">opts</span><span class="o">.</span><span class="n">releasever</span><span class="p">},</span>
|
||||
<span class="n">callback</span><span class="o">=</span><span class="k">lambda</span> <span class="n">p</span><span class="p">:</span> <span class="ow">not</span> <span class="n">novirt_cancel_check</span><span class="p">(</span><span class="n">cancel_funcs</span><span class="p">,</span> <span class="n">p</span><span class="p">)):</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="n">line</span><span class="p">)</span>
|
||||
|
||||
<span class="c1"># Make sure the new filesystem is correctly labeled</span>
|
||||
<span class="n">setfiles_args</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"-e"</span><span class="p">,</span> <span class="s2">"/proc"</span><span class="p">,</span> <span class="s2">"-e"</span><span class="p">,</span> <span class="s2">"/sys"</span><span class="p">,</span>
|
||||
<span class="s2">"/etc/selinux/targeted/contexts/files/file_contexts"</span><span class="p">,</span> <span class="s2">"/"</span><span class="p">]</span>
|
||||
|
||||
<span class="n">execWithRedirect</span><span class="p">(</span><span class="s2">"sync"</span><span class="p">,</span> <span class="p">[</span><span class="s2">"-f"</span><span class="p">,</span> <span class="n">dirinstall_path</span><span class="p">])</span>
|
||||
<span class="k">if</span> <span class="s2">"--dirinstall"</span> <span class="ow">in</span> <span class="n">args</span><span class="p">:</span>
|
||||
<span class="c1"># setfiles may not be available, warn instead of fail</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="n">execWithRedirect</span><span class="p">(</span><span class="s2">"setfiles"</span><span class="p">,</span> <span class="n">setfiles_args</span><span class="p">,</span> <span class="n">root</span><span class="o">=</span><span class="n">dirinstall_path</span><span class="p">)</span>
|
||||
<span class="k">except</span> <span class="p">(</span><span class="n">subprocess</span><span class="o">.</span><span class="n">CalledProcessError</span><span class="p">,</span> <span class="ne">OSError</span><span class="p">)</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">warning</span><span class="p">(</span><span class="s2">"Running setfiles on install tree failed: </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="p">))</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="n">disk_img</span><span class="p">):</span>
|
||||
<span class="n">execWithRedirect</span><span class="p">(</span><span class="s2">"du"</span><span class="p">,</span> <span class="p">[</span><span class="s2">"-B"</span><span class="p">,</span> <span class="s2">"1"</span><span class="p">,</span> <span class="n">disk_img</span><span class="p">])</span>
|
||||
<span class="n">execWithRedirect</span><span class="p">(</span><span class="s2">"fstrim"</span><span class="p">,</span> <span class="p">[</span><span class="s2">"-v"</span><span class="p">,</span> <span class="n">dirinstall_path</span><span class="p">])</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="k">with</span> <span class="n">PartitionMount</span><span class="p">(</span><span class="n">disk_img</span><span class="p">)</span> <span class="k">as</span> <span class="n">img_mount</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="n">img_mount</span> <span class="ow">and</span> <span class="n">img_mount</span><span class="o">.</span><span class="n">mount_dir</span><span class="p">:</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="n">execWithRedirect</span><span class="p">(</span><span class="s2">"setfiles"</span><span class="p">,</span> <span class="n">setfiles_args</span><span class="p">,</span> <span class="n">root</span><span class="o">=</span><span class="n">img_mount</span><span class="o">.</span><span class="n">mount_dir</span><span class="p">)</span>
|
||||
<span class="k">except</span> <span class="p">(</span><span class="n">subprocess</span><span class="o">.</span><span class="n">CalledProcessError</span><span class="p">,</span> <span class="ne">OSError</span><span class="p">)</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">warning</span><span class="p">(</span><span class="s2">"Running setfiles on install tree failed: </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="p">))</span>
|
||||
|
||||
<span class="c1"># For image installs, run fstrim to discard unused blocks. This way</span>
|
||||
<span class="c1"># unused blocks do not need to be allocated for sparse image types</span>
|
||||
<span class="n">execWithRedirect</span><span class="p">(</span><span class="s2">"du"</span><span class="p">,</span> <span class="p">[</span><span class="s2">"-B"</span><span class="p">,</span> <span class="s2">"1"</span><span class="p">,</span> <span class="n">disk_img</span><span class="p">])</span>
|
||||
<span class="n">execWithRedirect</span><span class="p">(</span><span class="s2">"fstrim"</span><span class="p">,</span> <span class="p">[</span><span class="s2">"-v"</span><span class="p">,</span> <span class="n">img_mount</span><span class="o">.</span><span class="n">mount_dir</span><span class="p">])</span>
|
||||
<span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="n">disk_img</span><span class="p">):</span>
|
||||
<span class="n">execWithRedirect</span><span class="p">(</span><span class="s2">"du"</span><span class="p">,</span> <span class="p">[</span><span class="s2">"-B"</span><span class="p">,</span> <span class="s2">"1"</span><span class="p">,</span> <span class="n">disk_img</span><span class="p">])</span>
|
||||
|
||||
<span class="k">except</span> <span class="p">(</span><span class="n">subprocess</span><span class="o">.</span><span class="n">CalledProcessError</span><span class="p">,</span> <span class="ne">OSError</span><span class="p">)</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="s2">"Running anaconda failed: </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">e</span><span class="p">)</span>
|
||||
<span class="k">raise</span> <span class="n">InstallError</span><span class="p">(</span><span class="s2">"novirt_install failed"</span><span class="p">)</span>
|
||||
<span class="k">finally</span><span class="p">:</span>
|
||||
<span class="n">log_monitor</span><span class="o">.</span><span class="n">shutdown</span><span class="p">()</span>
|
||||
|
||||
<span class="c1"># Move the anaconda logs over to a log directory</span>
|
||||
<span class="n">log_dir</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">abspath</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">dirname</span><span class="p">(</span><span class="n">opts</span><span class="o">.</span><span class="n">logfile</span><span class="p">))</span>
|
||||
<span class="n">log_anaconda</span> <span class="o">=</span> <span class="n">joinpaths</span><span class="p">(</span><span class="n">log_dir</span><span class="p">,</span> <span class="s2">"anaconda"</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isdir</span><span class="p">(</span><span class="n">log_anaconda</span><span class="p">):</span>
|
||||
<span class="n">os</span><span class="o">.</span><span class="n">mkdir</span><span class="p">(</span><span class="n">log_anaconda</span><span class="p">)</span>
|
||||
<span class="k">for</span> <span class="n">l</span> <span class="ow">in</span> <span class="n">glob</span><span class="o">.</span><span class="n">glob</span><span class="p">(</span><span class="s2">"/tmp/*log"</span><span class="p">)</span><span class="o">+</span><span class="n">glob</span><span class="o">.</span><span class="n">glob</span><span class="p">(</span><span class="s2">"/tmp/anaconda-tb-*"</span><span class="p">):</span>
|
||||
<span class="n">shutil</span><span class="o">.</span><span class="n">copy2</span><span class="p">(</span><span class="n">l</span><span class="p">,</span> <span class="n">log_anaconda</span><span class="p">)</span>
|
||||
<span class="n">os</span><span class="o">.</span><span class="n">unlink</span><span class="p">(</span><span class="n">l</span><span class="p">)</span>
|
||||
|
||||
<span class="c1"># Make sure any leftover anaconda mounts have been cleaned up</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">anaconda_cleanup</span><span class="p">(</span><span class="n">dirinstall_path</span><span class="p">):</span>
|
||||
<span class="k">raise</span> <span class="n">InstallError</span><span class="p">(</span><span class="s2">"novirt_install cleanup of anaconda mounts failed."</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">opts</span><span class="o">.</span><span class="n">make_iso</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">opts</span><span class="o">.</span><span class="n">make_fsimage</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">opts</span><span class="o">.</span><span class="n">make_pxe_live</span><span class="p">:</span>
|
||||
<span class="n">dm_name</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">splitext</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">basename</span><span class="p">(</span><span class="n">disk_img</span><span class="p">))[</span><span class="mi">0</span><span class="p">]</span>
|
||||
|
||||
<span class="c1"># Remove device-mapper for partitions and disk</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">"Removing device-mapper setup on </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">dm_name</span><span class="p">)</span>
|
||||
<span class="k">for</span> <span class="n">d</span> <span class="ow">in</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">glob</span><span class="o">.</span><span class="n">glob</span><span class="p">(</span><span class="s2">"/dev/mapper/"</span><span class="o">+</span><span class="n">dm_name</span><span class="o">+</span><span class="s2">"*"</span><span class="p">),</span> <span class="n">reverse</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span>
|
||||
<span class="n">dm_detach</span><span class="p">(</span><span class="n">d</span><span class="p">)</span>
|
||||
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">"Removing loop device for </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">disk_img</span><span class="p">)</span>
|
||||
<span class="n">loop_detach</span><span class="p">(</span><span class="s2">"/dev/"</span><span class="o">+</span><span class="n">get_loop_name</span><span class="p">(</span><span class="n">disk_img</span><span class="p">))</span>
|
||||
|
||||
<span class="c1"># qemu disk image is used by bare qcow2 images and by Vagrant</span>
|
||||
<span class="k">if</span> <span class="n">opts</span><span class="o">.</span><span class="n">image_type</span><span class="p">:</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"Converting </span><span class="si">%s</span><span class="s2"> to </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">disk_img</span><span class="p">,</span> <span class="n">opts</span><span class="o">.</span><span class="n">image_type</span><span class="p">)</span>
|
||||
<span class="n">qemu_args</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">opts</span><span class="o">.</span><span class="n">qemu_args</span><span class="p">:</span>
|
||||
<span class="n">qemu_args</span> <span class="o">+=</span> <span class="n">arg</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" "</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
|
||||
|
||||
<span class="c1"># convert the image to the selected format</span>
|
||||
<span class="k">if</span> <span class="s2">"-O"</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">qemu_args</span><span class="p">:</span>
|
||||
<span class="n">qemu_args</span><span class="o">.</span><span class="n">extend</span><span class="p">([</span><span class="s2">"-O"</span><span class="p">,</span> <span class="n">opts</span><span class="o">.</span><span class="n">image_type</span><span class="p">])</span>
|
||||
<span class="n">qemu_img</span> <span class="o">=</span> <span class="n">tempfile</span><span class="o">.</span><span class="n">mktemp</span><span class="p">(</span><span class="n">prefix</span><span class="o">=</span><span class="s2">"lmc-disk-"</span><span class="p">,</span> <span class="n">suffix</span><span class="o">=</span><span class="s2">".img"</span><span class="p">)</span>
|
||||
<span class="n">execWithRedirect</span><span class="p">(</span><span class="s2">"qemu-img"</span><span class="p">,</span> <span class="p">[</span><span class="s2">"convert"</span><span class="p">]</span> <span class="o">+</span> <span class="n">qemu_args</span> <span class="o">+</span> <span class="p">[</span><span class="n">disk_img</span><span class="p">,</span> <span class="n">qemu_img</span><span class="p">],</span> <span class="n">raise_err</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">opts</span><span class="o">.</span><span class="n">make_vagrant</span><span class="p">:</span>
|
||||
<span class="n">execWithRedirect</span><span class="p">(</span><span class="s2">"mv"</span><span class="p">,</span> <span class="p">[</span><span class="s2">"-f"</span><span class="p">,</span> <span class="n">qemu_img</span><span class="p">,</span> <span class="n">disk_img</span><span class="p">],</span> <span class="n">raise_err</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="c1"># Take the new qcow2 image and package it up for Vagrant</span>
|
||||
<span class="n">compress_args</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">opts</span><span class="o">.</span><span class="n">compress_args</span><span class="p">:</span>
|
||||
<span class="n">compress_args</span> <span class="o">+=</span> <span class="n">arg</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" "</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
|
||||
|
||||
<span class="n">vagrant_dir</span> <span class="o">=</span> <span class="n">tempfile</span><span class="o">.</span><span class="n">mkdtemp</span><span class="p">(</span><span class="n">prefix</span><span class="o">=</span><span class="s2">"lmc-tmpdir-"</span><span class="p">)</span>
|
||||
<span class="n">metadata_path</span> <span class="o">=</span> <span class="n">joinpaths</span><span class="p">(</span><span class="n">vagrant_dir</span><span class="p">,</span> <span class="s2">"metadata.json"</span><span class="p">)</span>
|
||||
<span class="n">execWithRedirect</span><span class="p">(</span><span class="s2">"mv"</span><span class="p">,</span> <span class="p">[</span><span class="s2">"-f"</span><span class="p">,</span> <span class="n">qemu_img</span><span class="p">,</span> <span class="n">joinpaths</span><span class="p">(</span><span class="n">vagrant_dir</span><span class="p">,</span> <span class="s2">"box.img"</span><span class="p">)],</span> <span class="n">raise_err</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">opts</span><span class="o">.</span><span class="n">vagrant_metadata</span><span class="p">:</span>
|
||||
<span class="n">shutil</span><span class="o">.</span><span class="n">copy2</span><span class="p">(</span><span class="n">opts</span><span class="o">.</span><span class="n">vagrant_metadata</span><span class="p">,</span> <span class="n">metadata_path</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">create_vagrant_metadata</span><span class="p">(</span><span class="n">metadata_path</span><span class="p">)</span>
|
||||
<span class="n">update_vagrant_metadata</span><span class="p">(</span><span class="n">metadata_path</span><span class="p">,</span> <span class="n">disk_size</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">opts</span><span class="o">.</span><span class="n">vagrantfile</span><span class="p">:</span>
|
||||
<span class="n">shutil</span><span class="o">.</span><span class="n">copy2</span><span class="p">(</span><span class="n">opts</span><span class="o">.</span><span class="n">vagrantfile</span><span class="p">,</span> <span class="n">joinpaths</span><span class="p">(</span><span class="n">vagrant_dir</span><span class="p">,</span> <span class="s2">"vagrantfile"</span><span class="p">))</span>
|
||||
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"Creating Vagrant image"</span><span class="p">)</span>
|
||||
<span class="n">rc</span> <span class="o">=</span> <span class="n">mktar</span><span class="p">(</span><span class="n">vagrant_dir</span><span class="p">,</span> <span class="n">disk_img</span><span class="p">,</span> <span class="n">opts</span><span class="o">.</span><span class="n">compression</span><span class="p">,</span> <span class="n">compress_args</span><span class="p">,</span> <span class="n">selinux</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">rc</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="n">InstallError</span><span class="p">(</span><span class="s2">"novirt_install mktar failed: rc=</span><span class="si">%s</span><span class="s2">"</span> <span class="o">%</span> <span class="n">rc</span><span class="p">)</span>
|
||||
<span class="n">shutil</span><span class="o">.</span><span class="n">rmtree</span><span class="p">(</span><span class="n">vagrant_dir</span><span class="p">)</span>
|
||||
<span class="k">elif</span> <span class="n">opts</span><span class="o">.</span><span class="n">make_tar</span><span class="p">:</span>
|
||||
<span class="n">compress_args</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">opts</span><span class="o">.</span><span class="n">compress_args</span><span class="p">:</span>
|
||||
<span class="n">compress_args</span> <span class="o">+=</span> <span class="n">arg</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" "</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
|
||||
|
||||
<span class="n">rc</span> <span class="o">=</span> <span class="n">mktar</span><span class="p">(</span><span class="n">dirinstall_path</span><span class="p">,</span> <span class="n">disk_img</span><span class="p">,</span> <span class="n">opts</span><span class="o">.</span><span class="n">compression</span><span class="p">,</span> <span class="n">compress_args</span><span class="p">)</span>
|
||||
<span class="n">shutil</span><span class="o">.</span><span class="n">rmtree</span><span class="p">(</span><span class="n">dirinstall_path</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">rc</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="n">InstallError</span><span class="p">(</span><span class="s2">"novirt_install mktar failed: rc=</span><span class="si">%s</span><span class="s2">"</span> <span class="o">%</span> <span class="n">rc</span><span class="p">)</span>
|
||||
<span class="k">elif</span> <span class="n">opts</span><span class="o">.</span><span class="n">make_oci</span><span class="p">:</span>
|
||||
<span class="c1"># An OCI image places the filesystem under /rootfs/ and adds the json files at the top</span>
|
||||
<span class="c1"># And then creates a tar of the whole thing.</span>
|
||||
<span class="n">compress_args</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">opts</span><span class="o">.</span><span class="n">compress_args</span><span class="p">:</span>
|
||||
<span class="n">compress_args</span> <span class="o">+=</span> <span class="n">arg</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" "</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
|
||||
|
||||
<span class="n">shutil</span><span class="o">.</span><span class="n">copy2</span><span class="p">(</span><span class="n">opts</span><span class="o">.</span><span class="n">oci_config</span><span class="p">,</span> <span class="n">ROOT_PATH</span><span class="p">)</span>
|
||||
<span class="n">shutil</span><span class="o">.</span><span class="n">copy2</span><span class="p">(</span><span class="n">opts</span><span class="o">.</span><span class="n">oci_runtime</span><span class="p">,</span> <span class="n">ROOT_PATH</span><span class="p">)</span>
|
||||
<span class="n">rc</span> <span class="o">=</span> <span class="n">mktar</span><span class="p">(</span><span class="n">ROOT_PATH</span><span class="p">,</span> <span class="n">disk_img</span><span class="p">,</span> <span class="n">opts</span><span class="o">.</span><span class="n">compression</span><span class="p">,</span> <span class="n">compress_args</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">rc</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="n">InstallError</span><span class="p">(</span><span class="s2">"novirt_install mktar failed: rc=</span><span class="si">%s</span><span class="s2">"</span> <span class="o">%</span> <span class="n">rc</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="c1"># Examine the image for sections that can be made sparse</span>
|
||||
<span class="n">execWithRedirect</span><span class="p">(</span><span class="s2">"du"</span><span class="p">,</span> <span class="p">[</span><span class="s2">"-B"</span><span class="p">,</span> <span class="s2">"1"</span><span class="p">,</span> <span class="n">disk_img</span><span class="p">])</span>
|
||||
<span class="n">execWithRedirect</span><span class="p">(</span><span class="s2">"fallocate"</span><span class="p">,</span> <span class="p">[</span><span class="s2">"--dig-holes"</span><span class="p">,</span> <span class="s2">"-v"</span><span class="p">,</span> <span class="n">disk_img</span><span class="p">],</span> <span class="n">raise_err</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
|
||||
<span class="n">execWithRedirect</span><span class="p">(</span><span class="s2">"du"</span><span class="p">,</span> <span class="p">[</span><span class="s2">"-B"</span><span class="p">,</span> <span class="s2">"1"</span><span class="p">,</span> <span class="n">disk_img</span><span class="p">])</span>
|
||||
|
||||
<span class="c1"># For make_tar_disk, wrap the result in a tar file, and remove the original disk image.</span>
|
||||
<span class="k">if</span> <span class="n">opts</span><span class="o">.</span><span class="n">make_tar_disk</span><span class="p">:</span>
|
||||
<span class="n">compress_args</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">opts</span><span class="o">.</span><span class="n">compress_args</span><span class="p">:</span>
|
||||
<span class="n">compress_args</span> <span class="o">+=</span> <span class="n">arg</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" "</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
|
||||
|
||||
<span class="n">rc</span> <span class="o">=</span> <span class="n">mktar</span><span class="p">(</span><span class="n">disk_img</span><span class="p">,</span> <span class="n">tar_img</span><span class="p">,</span> <span class="n">opts</span><span class="o">.</span><span class="n">compression</span><span class="p">,</span> <span class="n">compress_args</span><span class="p">,</span> <span class="n">selinux</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">rc</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="n">InstallError</span><span class="p">(</span><span class="s2">"novirt_install mktar failed: rc=</span><span class="si">%s</span><span class="s2">"</span> <span class="o">%</span> <span class="n">rc</span><span class="p">)</span>
|
||||
|
||||
<span class="n">os</span><span class="o">.</span><span class="n">unlink</span><span class="p">(</span><span class="n">disk_img</span><span class="p">)</span></div>
|
||||
|
||||
<div class="viewcode-block" id="virt_install"><a class="viewcode-back" href="../../pylorax.html#pylorax.installer.virt_install">[docs]</a><span class="k">def</span> <span class="nf">virt_install</span><span class="p">(</span><span class="n">opts</span><span class="p">,</span> <span class="n">install_log</span><span class="p">,</span> <span class="n">disk_img</span><span class="p">,</span> <span class="n">disk_size</span><span class="p">,</span> <span class="n">cancel_func</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">tar_img</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Use qemu to install to a disk image</span>
|
||||
|
||||
<span class="sd"> :param opts: options passed to livemedia-creator</span>
|
||||
<span class="sd"> :type opts: argparse options</span>
|
||||
<span class="sd"> :param str install_log: The path to write the log from qemu</span>
|
||||
<span class="sd"> :param str disk_img: The full path to the disk image to be created</span>
|
||||
<span class="sd"> :param int disk_size: The size of the disk_img in MiB</span>
|
||||
<span class="sd"> :param cancel_func: Function that returns True to cancel build</span>
|
||||
<span class="sd"> :type cancel_func: function</span>
|
||||
<span class="sd"> :param str tar_img: For make_tar_disk, the path to final tarball to be created</span>
|
||||
|
||||
<span class="sd"> This uses qemu with a boot.iso and a kickstart to create a disk</span>
|
||||
<span class="sd"> image and then optionally, based on the opts passed, creates tarfile.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">iso_mount</span> <span class="o">=</span> <span class="n">IsoMountpoint</span><span class="p">(</span><span class="n">opts</span><span class="o">.</span><span class="n">iso</span><span class="p">,</span> <span class="n">opts</span><span class="o">.</span><span class="n">location</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">iso_mount</span><span class="o">.</span><span class="n">stage2</span><span class="p">:</span>
|
||||
<span class="n">iso_mount</span><span class="o">.</span><span class="n">umount</span><span class="p">()</span>
|
||||
<span class="k">raise</span> <span class="n">InstallError</span><span class="p">(</span><span class="s2">"ISO is missing stage2, cannot continue"</span><span class="p">)</span>
|
||||
|
||||
<span class="n">log_monitor</span> <span class="o">=</span> <span class="n">LogMonitor</span><span class="p">(</span><span class="n">install_log</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="n">opts</span><span class="o">.</span><span class="n">timeout</span><span class="p">)</span>
|
||||
<span class="n">cancel_funcs</span> <span class="o">=</span> <span class="p">[</span><span class="n">log_monitor</span><span class="o">.</span><span class="n">server</span><span class="o">.</span><span class="n">log_check</span><span class="p">]</span>
|
||||
<span class="k">if</span> <span class="n">cancel_func</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="n">cancel_funcs</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">cancel_func</span><span class="p">)</span>
|
||||
|
||||
<span class="n">kernel_args</span> <span class="o">=</span> <span class="s2">""</span>
|
||||
<span class="k">if</span> <span class="n">opts</span><span class="o">.</span><span class="n">kernel_args</span><span class="p">:</span>
|
||||
<span class="n">kernel_args</span> <span class="o">+=</span> <span class="n">opts</span><span class="o">.</span><span class="n">kernel_args</span>
|
||||
<span class="k">if</span> <span class="n">opts</span><span class="o">.</span><span class="n">proxy</span><span class="p">:</span>
|
||||
<span class="n">kernel_args</span> <span class="o">+=</span> <span class="s2">" proxy="</span><span class="o">+</span><span class="n">opts</span><span class="o">.</span><span class="n">proxy</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">opts</span><span class="o">.</span><span class="n">image_type</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">opts</span><span class="o">.</span><span class="n">make_fsimage</span><span class="p">:</span>
|
||||
<span class="n">qemu_args</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">opts</span><span class="o">.</span><span class="n">qemu_args</span><span class="p">:</span>
|
||||
<span class="n">qemu_args</span> <span class="o">+=</span> <span class="n">arg</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" "</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="s2">"-f"</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">qemu_args</span><span class="p">:</span>
|
||||
<span class="n">qemu_args</span> <span class="o">+=</span> <span class="p">[</span><span class="s2">"-f"</span><span class="p">,</span> <span class="n">opts</span><span class="o">.</span><span class="n">image_type</span><span class="p">]</span>
|
||||
|
||||
<span class="n">mkqemu_img</span><span class="p">(</span><span class="n">disk_img</span><span class="p">,</span> <span class="n">disk_size</span><span class="o">*</span><span class="mi">1024</span><span class="o">**</span><span class="mi">2</span><span class="p">,</span> <span class="n">qemu_args</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">opts</span><span class="o">.</span><span class="n">make_fsimage</span> <span class="ow">or</span> <span class="n">opts</span><span class="o">.</span><span class="n">make_tar</span> <span class="ow">or</span> <span class="n">opts</span><span class="o">.</span><span class="n">make_oci</span><span class="p">:</span>
|
||||
<span class="n">diskimg_path</span> <span class="o">=</span> <span class="n">tempfile</span><span class="o">.</span><span class="n">mktemp</span><span class="p">(</span><span class="n">prefix</span><span class="o">=</span><span class="s2">"lmc-disk-"</span><span class="p">,</span> <span class="n">suffix</span><span class="o">=</span><span class="s2">".img"</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">diskimg_path</span> <span class="o">=</span> <span class="n">disk_img</span>
|
||||
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="n">QEMUInstall</span><span class="p">(</span><span class="n">opts</span><span class="p">,</span> <span class="n">iso_mount</span><span class="p">,</span> <span class="n">opts</span><span class="o">.</span><span class="n">ks</span><span class="p">,</span> <span class="n">diskimg_path</span><span class="p">,</span> <span class="n">disk_size</span><span class="p">,</span>
|
||||
<span class="n">kernel_args</span><span class="p">,</span> <span class="n">opts</span><span class="o">.</span><span class="n">ram</span><span class="p">,</span> <span class="n">opts</span><span class="o">.</span><span class="n">vcpus</span><span class="p">,</span> <span class="n">opts</span><span class="o">.</span><span class="n">vnc</span><span class="p">,</span> <span class="n">opts</span><span class="o">.</span><span class="n">arch</span><span class="p">,</span>
|
||||
<span class="n">cancel_func</span> <span class="o">=</span> <span class="k">lambda</span> <span class="p">:</span> <span class="nb">any</span><span class="p">(</span><span class="n">f</span><span class="p">()</span> <span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">cancel_funcs</span><span class="p">),</span>
|
||||
<span class="n">virtio_host</span> <span class="o">=</span> <span class="n">log_monitor</span><span class="o">.</span><span class="n">host</span><span class="p">,</span>
|
||||
<span class="n">virtio_port</span> <span class="o">=</span> <span class="n">log_monitor</span><span class="o">.</span><span class="n">port</span><span class="p">,</span>
|
||||
<span class="n">image_type</span><span class="o">=</span><span class="n">opts</span><span class="o">.</span><span class="n">image_type</span><span class="p">,</span> <span class="n">boot_uefi</span><span class="o">=</span><span class="n">opts</span><span class="o">.</span><span class="n">virt_uefi</span><span class="p">,</span>
|
||||
<span class="n">ovmf_path</span><span class="o">=</span><span class="n">opts</span><span class="o">.</span><span class="n">ovmf_path</span><span class="p">)</span>
|
||||
<span class="n">log_monitor</span><span class="o">.</span><span class="n">shutdown</span><span class="p">()</span>
|
||||
<span class="k">except</span> <span class="n">InstallError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="s2">"VirtualInstall failed: </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">e</span><span class="p">)</span>
|
||||
<span class="k">raise</span>
|
||||
<span class="k">finally</span><span class="p">:</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"unmounting the iso"</span><span class="p">)</span>
|
||||
<span class="n">iso_mount</span><span class="o">.</span><span class="n">umount</span><span class="p">()</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">log_monitor</span><span class="o">.</span><span class="n">server</span><span class="o">.</span><span class="n">log_check</span><span class="p">():</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">log_monitor</span><span class="o">.</span><span class="n">server</span><span class="o">.</span><span class="n">error_line</span> <span class="ow">and</span> <span class="n">opts</span><span class="o">.</span><span class="n">timeout</span><span class="p">:</span>
|
||||
<span class="n">msg</span> <span class="o">=</span> <span class="s2">"virt_install failed due to timeout"</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">msg</span> <span class="o">=</span> <span class="s2">"virt_install failed on line: </span><span class="si">%s</span><span class="s2">"</span> <span class="o">%</span> <span class="n">log_monitor</span><span class="o">.</span><span class="n">server</span><span class="o">.</span><span class="n">error_line</span>
|
||||
<span class="k">raise</span> <span class="n">InstallError</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span>
|
||||
<span class="k">elif</span> <span class="n">cancel_func</span> <span class="ow">and</span> <span class="n">cancel_func</span><span class="p">():</span>
|
||||
<span class="k">raise</span> <span class="n">InstallError</span><span class="p">(</span><span class="s2">"virt_install canceled by cancel_func"</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">opts</span><span class="o">.</span><span class="n">make_fsimage</span><span class="p">:</span>
|
||||
<span class="n">mkfsimage_from_disk</span><span class="p">(</span><span class="n">diskimg_path</span><span class="p">,</span> <span class="n">disk_img</span><span class="p">,</span> <span class="n">disk_size</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="n">opts</span><span class="o">.</span><span class="n">fs_label</span><span class="p">)</span>
|
||||
<span class="n">os</span><span class="o">.</span><span class="n">unlink</span><span class="p">(</span><span class="n">diskimg_path</span><span class="p">)</span>
|
||||
<span class="k">elif</span> <span class="n">opts</span><span class="o">.</span><span class="n">make_tar</span><span class="p">:</span>
|
||||
<span class="n">compress_args</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">opts</span><span class="o">.</span><span class="n">compress_args</span><span class="p">:</span>
|
||||
<span class="n">compress_args</span> <span class="o">+=</span> <span class="n">arg</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" "</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
|
||||
|
||||
<span class="k">with</span> <span class="n">PartitionMount</span><span class="p">(</span><span class="n">diskimg_path</span><span class="p">)</span> <span class="k">as</span> <span class="n">img_mount</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="n">img_mount</span> <span class="ow">and</span> <span class="n">img_mount</span><span class="o">.</span><span class="n">mount_dir</span><span class="p">:</span>
|
||||
<span class="n">rc</span> <span class="o">=</span> <span class="n">mktar</span><span class="p">(</span><span class="n">img_mount</span><span class="o">.</span><span class="n">mount_dir</span><span class="p">,</span> <span class="n">disk_img</span><span class="p">,</span> <span class="n">opts</span><span class="o">.</span><span class="n">compression</span><span class="p">,</span> <span class="n">compress_args</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">rc</span> <span class="o">=</span> <span class="mi">1</span>
|
||||
<span class="n">os</span><span class="o">.</span><span class="n">unlink</span><span class="p">(</span><span class="n">diskimg_path</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">rc</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="n">InstallError</span><span class="p">(</span><span class="s2">"virt_install failed"</span><span class="p">)</span>
|
||||
<span class="k">elif</span> <span class="n">opts</span><span class="o">.</span><span class="n">make_oci</span><span class="p">:</span>
|
||||
<span class="c1"># An OCI image places the filesystem under /rootfs/ and adds the json files at the top</span>
|
||||
<span class="c1"># And then creates a tar of the whole thing.</span>
|
||||
<span class="n">compress_args</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">opts</span><span class="o">.</span><span class="n">compress_args</span><span class="p">:</span>
|
||||
<span class="n">compress_args</span> <span class="o">+=</span> <span class="n">arg</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" "</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
|
||||
|
||||
<span class="k">with</span> <span class="n">PartitionMount</span><span class="p">(</span><span class="n">diskimg_path</span><span class="p">,</span> <span class="n">submount</span><span class="o">=</span><span class="s2">"rootfs"</span><span class="p">)</span> <span class="k">as</span> <span class="n">img_mount</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="n">img_mount</span> <span class="ow">and</span> <span class="n">img_mount</span><span class="o">.</span><span class="n">temp_dir</span><span class="p">:</span>
|
||||
<span class="n">shutil</span><span class="o">.</span><span class="n">copy2</span><span class="p">(</span><span class="n">opts</span><span class="o">.</span><span class="n">oci_config</span><span class="p">,</span> <span class="n">img_mount</span><span class="o">.</span><span class="n">temp_dir</span><span class="p">)</span>
|
||||
<span class="n">shutil</span><span class="o">.</span><span class="n">copy2</span><span class="p">(</span><span class="n">opts</span><span class="o">.</span><span class="n">oci_runtime</span><span class="p">,</span> <span class="n">img_mount</span><span class="o">.</span><span class="n">temp_dir</span><span class="p">)</span>
|
||||
<span class="n">rc</span> <span class="o">=</span> <span class="n">mktar</span><span class="p">(</span><span class="n">img_mount</span><span class="o">.</span><span class="n">temp_dir</span><span class="p">,</span> <span class="n">disk_img</span><span class="p">,</span> <span class="n">opts</span><span class="o">.</span><span class="n">compression</span><span class="p">,</span> <span class="n">compress_args</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">rc</span> <span class="o">=</span> <span class="mi">1</span>
|
||||
<span class="n">os</span><span class="o">.</span><span class="n">unlink</span><span class="p">(</span><span class="n">diskimg_path</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">rc</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="n">InstallError</span><span class="p">(</span><span class="s2">"virt_install failed"</span><span class="p">)</span>
|
||||
<span class="k">elif</span> <span class="n">opts</span><span class="o">.</span><span class="n">make_vagrant</span><span class="p">:</span>
|
||||
<span class="n">compress_args</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">opts</span><span class="o">.</span><span class="n">compress_args</span><span class="p">:</span>
|
||||
<span class="n">compress_args</span> <span class="o">+=</span> <span class="n">arg</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" "</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
|
||||
|
||||
<span class="n">vagrant_dir</span> <span class="o">=</span> <span class="n">tempfile</span><span class="o">.</span><span class="n">mkdtemp</span><span class="p">(</span><span class="n">prefix</span><span class="o">=</span><span class="s2">"lmc-tmpdir-"</span><span class="p">)</span>
|
||||
<span class="n">metadata_path</span> <span class="o">=</span> <span class="n">joinpaths</span><span class="p">(</span><span class="n">vagrant_dir</span><span class="p">,</span> <span class="s2">"metadata.json"</span><span class="p">)</span>
|
||||
<span class="n">execWithRedirect</span><span class="p">(</span><span class="s2">"mv"</span><span class="p">,</span> <span class="p">[</span><span class="s2">"-f"</span><span class="p">,</span> <span class="n">disk_img</span><span class="p">,</span> <span class="n">joinpaths</span><span class="p">(</span><span class="n">vagrant_dir</span><span class="p">,</span> <span class="s2">"box.img"</span><span class="p">)],</span> <span class="n">raise_err</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">opts</span><span class="o">.</span><span class="n">vagrant_metadata</span><span class="p">:</span>
|
||||
<span class="n">shutil</span><span class="o">.</span><span class="n">copy2</span><span class="p">(</span><span class="n">opts</span><span class="o">.</span><span class="n">vagrant_metadata</span><span class="p">,</span> <span class="n">metadata_path</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">create_vagrant_metadata</span><span class="p">(</span><span class="n">metadata_path</span><span class="p">)</span>
|
||||
<span class="n">update_vagrant_metadata</span><span class="p">(</span><span class="n">metadata_path</span><span class="p">,</span> <span class="n">disk_size</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">opts</span><span class="o">.</span><span class="n">vagrantfile</span><span class="p">:</span>
|
||||
<span class="n">shutil</span><span class="o">.</span><span class="n">copy2</span><span class="p">(</span><span class="n">opts</span><span class="o">.</span><span class="n">vagrantfile</span><span class="p">,</span> <span class="n">joinpaths</span><span class="p">(</span><span class="n">vagrant_dir</span><span class="p">,</span> <span class="s2">"vagrantfile"</span><span class="p">))</span>
|
||||
|
||||
<span class="n">rc</span> <span class="o">=</span> <span class="n">mktar</span><span class="p">(</span><span class="n">vagrant_dir</span><span class="p">,</span> <span class="n">disk_img</span><span class="p">,</span> <span class="n">opts</span><span class="o">.</span><span class="n">compression</span><span class="p">,</span> <span class="n">compress_args</span><span class="p">,</span> <span class="n">selinux</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">rc</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="n">InstallError</span><span class="p">(</span><span class="s2">"virt_install failed"</span><span class="p">)</span>
|
||||
<span class="n">shutil</span><span class="o">.</span><span class="n">rmtree</span><span class="p">(</span><span class="n">vagrant_dir</span><span class="p">)</span>
|
||||
|
||||
<span class="c1"># For make_tar_disk, wrap the result in a tar file, and remove the original disk image.</span>
|
||||
<span class="k">if</span> <span class="n">opts</span><span class="o">.</span><span class="n">make_tar_disk</span><span class="p">:</span>
|
||||
<span class="n">compress_args</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">opts</span><span class="o">.</span><span class="n">compress_args</span><span class="p">:</span>
|
||||
<span class="n">compress_args</span> <span class="o">+=</span> <span class="n">arg</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" "</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
|
||||
|
||||
<span class="n">rc</span> <span class="o">=</span> <span class="n">mktar</span><span class="p">(</span><span class="n">disk_img</span><span class="p">,</span> <span class="n">tar_img</span><span class="p">,</span> <span class="n">opts</span><span class="o">.</span><span class="n">compression</span><span class="p">,</span> <span class="n">compress_args</span><span class="p">,</span> <span class="n">selinux</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">rc</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="n">InstallError</span><span class="p">(</span><span class="s2">"virt_install mktar failed: rc=</span><span class="si">%s</span><span class="s2">"</span> <span class="o">%</span> <span class="n">rc</span><span class="p">)</span>
|
||||
|
||||
<span class="n">os</span><span class="o">.</span><span class="n">unlink</span><span class="p">(</span><span class="n">disk_img</span><span class="p">)</span></div>
|
||||
</pre></div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<footer>
|
||||
|
||||
<hr/>
|
||||
|
||||
<div role="contentinfo">
|
||||
<p>© Copyright 2018, Red Hat, Inc..</p>
|
||||
</div>
|
||||
|
||||
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
|
||||
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
|
||||
provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||||
|
||||
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
<script>
|
||||
jQuery(function () {
|
||||
SphinxRtdTheme.Navigation.enable(true);
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,76 +1,31 @@
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
|
||||
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
|
||||
<html class="writer-html5" lang="en" >
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>pylorax.ltmpl — Lorax 28.2 documentation</title>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pylorax.ltmpl — Lorax 36.4 documentation</title>
|
||||
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
|
||||
<link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="index" title="Index"
|
||||
href="../../genindex.html"/>
|
||||
<link rel="search" title="Search" href="../../search.html"/>
|
||||
<link rel="top" title="Lorax 28.2 documentation" href="../../index.html"/>
|
||||
<link rel="up" title="pylorax" href="../pylorax.html"/>
|
||||
|
||||
|
||||
<script src="../../_static/js/modernizr.min.js"></script>
|
||||
|
||||
<script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
|
||||
<script src="../../_static/jquery.js"></script>
|
||||
<script src="../../_static/underscore.js"></script>
|
||||
<script src="../../_static/doctools.js"></script>
|
||||
<script src="../../_static/js/theme.js"></script>
|
||||
<link rel="index" title="Index" href="../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../search.html" />
|
||||
</head>
|
||||
|
||||
<body class="wy-body-for-nav" role="document">
|
||||
|
||||
|
||||
<body class="wy-body-for-nav">
|
||||
<div class="wy-grid-for-nav">
|
||||
|
||||
|
||||
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
|
||||
<div class="wy-side-scroll">
|
||||
<div class="wy-side-nav-search">
|
||||
|
||||
|
||||
|
||||
<div class="wy-side-nav-search" >
|
||||
<a href="../../index.html" class="icon icon-home"> Lorax
|
||||
|
||||
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="version">
|
||||
28.2
|
||||
36.4
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div role="search">
|
||||
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
|
||||
<input type="text" name="q" placeholder="Search docs" />
|
||||
@ -78,84 +33,37 @@
|
||||
<input type="hidden" name="area" value="default" />
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../intro.html">Introduction to Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../intro.html#before-lorax">Before Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../lorax.html">Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../livemedia-creator.html">livemedia-creator</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../mkksiso.html">mkksiso</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../product-images.html">Product and Updates Images</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../modules.html">pylorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../modules.html">src</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
|
||||
|
||||
|
||||
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
|
||||
|
||||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
|
||||
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
||||
<a href="../../index.html">Lorax</a>
|
||||
|
||||
</nav>
|
||||
|
||||
|
||||
|
||||
<div class="wy-nav-content">
|
||||
<div class="rst-content">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div role="navigation" aria-label="breadcrumbs navigation">
|
||||
|
||||
<div role="navigation" aria-label="Page navigation">
|
||||
<ul class="wy-breadcrumbs">
|
||||
|
||||
<li><a href="../../index.html">Docs</a> »</li>
|
||||
|
||||
<li><a href="../../index.html" class="icon icon-home"></a> »</li>
|
||||
<li><a href="../index.html">Module code</a> »</li>
|
||||
|
||||
<li><a href="../pylorax.html">pylorax</a> »</li>
|
||||
|
||||
<li>pylorax.ltmpl</li>
|
||||
|
||||
|
||||
<li class="wy-breadcrumbs-aside">
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
<hr/>
|
||||
</div>
|
||||
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
|
||||
@ -165,7 +73,7 @@
|
||||
<span></span><span class="c1">#</span>
|
||||
<span class="c1"># ltmpl.py</span>
|
||||
<span class="c1">#</span>
|
||||
<span class="c1"># Copyright (C) 2009-2015 Red Hat, Inc.</span>
|
||||
<span class="c1"># Copyright (C) 2009-2018 Red Hat, Inc.</span>
|
||||
<span class="c1">#</span>
|
||||
<span class="c1"># This program is free software; you can redistribute it and/or modify</span>
|
||||
<span class="c1"># it under the terms of the GNU General Public License as published by</span>
|
||||
@ -188,25 +96,25 @@
|
||||
<span class="n">logger</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="s2">"pylorax.ltmpl"</span><span class="p">)</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">os</span><span class="o">,</span> <span class="nn">re</span><span class="o">,</span> <span class="nn">glob</span><span class="o">,</span> <span class="nn">shlex</span><span class="o">,</span> <span class="nn">fnmatch</span>
|
||||
<span class="kn">from</span> <span class="nn">os.path</span> <span class="k">import</span> <span class="n">basename</span><span class="p">,</span> <span class="n">isdir</span>
|
||||
<span class="kn">from</span> <span class="nn">subprocess</span> <span class="k">import</span> <span class="n">CalledProcessError</span>
|
||||
<span class="kn">from</span> <span class="nn">os.path</span> <span class="kn">import</span> <span class="n">basename</span><span class="p">,</span> <span class="n">isdir</span>
|
||||
<span class="kn">from</span> <span class="nn">subprocess</span> <span class="kn">import</span> <span class="n">CalledProcessError</span>
|
||||
<span class="kn">import</span> <span class="nn">shutil</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">pylorax.sysutils</span> <span class="k">import</span> <span class="n">joinpaths</span><span class="p">,</span> <span class="n">cpfile</span><span class="p">,</span> <span class="n">mvfile</span><span class="p">,</span> <span class="n">replace</span><span class="p">,</span> <span class="n">remove</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.dnfhelper</span> <span class="k">import</span> <span class="n">LoraxDownloadCallback</span><span class="p">,</span> <span class="n">LoraxRpmCallback</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.base</span> <span class="k">import</span> <span class="n">DataHolder</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.executils</span> <span class="k">import</span> <span class="n">runcmd</span><span class="p">,</span> <span class="n">runcmd_output</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.imgutils</span> <span class="k">import</span> <span class="n">mkcpio</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.sysutils</span> <span class="kn">import</span> <span class="n">joinpaths</span><span class="p">,</span> <span class="n">cpfile</span><span class="p">,</span> <span class="n">mvfile</span><span class="p">,</span> <span class="n">replace</span><span class="p">,</span> <span class="n">remove</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.dnfhelper</span> <span class="kn">import</span> <span class="n">LoraxDownloadCallback</span><span class="p">,</span> <span class="n">LoraxRpmCallback</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.base</span> <span class="kn">import</span> <span class="n">DataHolder</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.executils</span> <span class="kn">import</span> <span class="n">runcmd</span><span class="p">,</span> <span class="n">runcmd_output</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.imgutils</span> <span class="kn">import</span> <span class="n">mkcpio</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">mako.lookup</span> <span class="k">import</span> <span class="n">TemplateLookup</span>
|
||||
<span class="kn">from</span> <span class="nn">mako.exceptions</span> <span class="k">import</span> <span class="n">text_error_template</span>
|
||||
<span class="kn">from</span> <span class="nn">mako.lookup</span> <span class="kn">import</span> <span class="n">TemplateLookup</span>
|
||||
<span class="kn">from</span> <span class="nn">mako.exceptions</span> <span class="kn">import</span> <span class="n">text_error_template</span>
|
||||
<span class="kn">import</span> <span class="nn">sys</span><span class="o">,</span> <span class="nn">traceback</span>
|
||||
<span class="kn">import</span> <span class="nn">struct</span>
|
||||
<span class="kn">import</span> <span class="nn">dnf</span>
|
||||
<span class="kn">import</span> <span class="nn">collections</span>
|
||||
<span class="kn">import</span> <span class="nn">collections.abc</span>
|
||||
|
||||
<div class="viewcode-block" id="LoraxTemplate"><a class="viewcode-back" href="../../pylorax.html#pylorax.ltmpl.LoraxTemplate">[docs]</a><span class="k">class</span> <span class="nc">LoraxTemplate</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">directories</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">directories</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
<span class="n">directories</span> <span class="o">=</span> <span class="n">directories</span> <span class="ow">or</span> <span class="p">[</span><span class="s2">"/usr/share/lorax"</span><span class="p">]</span>
|
||||
<span class="c1"># we have to add ["/"] to the template lookup directories or the</span>
|
||||
<span class="c1"># file includes won't work properly for absolute paths</span>
|
||||
@ -231,10 +139,16 @@
|
||||
<span class="c1"># remove comments</span>
|
||||
<span class="n">lines</span> <span class="o">=</span> <span class="p">[</span><span class="n">line</span> <span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="n">lines</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">line</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"#"</span><span class="p">)]</span>
|
||||
|
||||
<span class="c1"># split with shlex and perform brace expansion</span>
|
||||
<span class="n">lines</span> <span class="o">=</span> <span class="p">[</span><span class="n">split_and_expand</span><span class="p">(</span><span class="n">line</span><span class="p">)</span> <span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="n">lines</span><span class="p">]</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">lines</span></div></div>
|
||||
<span class="c1"># split with shlex and perform brace expansion. This can fail, so we unroll the loop</span>
|
||||
<span class="c1"># for better error reporting.</span>
|
||||
<span class="n">expanded_lines</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="n">lines</span><span class="p">:</span>
|
||||
<span class="n">expanded_lines</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">split_and_expand</span><span class="p">(</span><span class="n">line</span><span class="p">))</span>
|
||||
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="s1">'shlex error processing "</span><span class="si">%s</span><span class="s1">": </span><span class="si">%s</span><span class="s1">'</span><span class="p">,</span> <span class="n">line</span><span class="p">,</span> <span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="p">))</span>
|
||||
<span class="k">raise</span>
|
||||
<span class="k">return</span> <span class="n">expanded_lines</span></div></div>
|
||||
|
||||
<div class="viewcode-block" id="split_and_expand"><a class="viewcode-back" href="../../pylorax.html#pylorax.ltmpl.split_and_expand">[docs]</a><span class="k">def</span> <span class="nf">split_and_expand</span><span class="p">(</span><span class="n">line</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="p">[</span><span class="n">exp</span> <span class="k">for</span> <span class="n">word</span> <span class="ow">in</span> <span class="n">shlex</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="n">line</span><span class="p">)</span> <span class="k">for</span> <span class="n">exp</span> <span class="ow">in</span> <span class="n">brace_expand</span><span class="p">(</span><span class="n">word</span><span class="p">)]</span></div>
|
||||
@ -267,8 +181,7 @@
|
||||
<span class="k">return</span> <span class="kc">True</span>
|
||||
<span class="k">return</span> <span class="kc">False</span></div>
|
||||
|
||||
<span class="c1"># TODO: operate inside an actual chroot for safety? Not that RPM bothers..</span>
|
||||
<div class="viewcode-block" id="LoraxTemplateRunner"><a class="viewcode-back" href="../../pylorax.html#pylorax.ltmpl.LoraxTemplateRunner">[docs]</a><span class="k">class</span> <span class="nc">LoraxTemplateRunner</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
|
||||
<div class="viewcode-block" id="TemplateRunner"><a class="viewcode-back" href="../../pylorax.html#pylorax.ltmpl.TemplateRunner">[docs]</a><span class="k">class</span> <span class="nc">TemplateRunner</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
|
||||
<span class="sd">'''</span>
|
||||
<span class="sd"> This class parses and executes Lorax templates. Sample usage:</span>
|
||||
|
||||
@ -276,15 +189,12 @@
|
||||
<span class="sd"> runner = LoraxTemplateRunner(inroot=rundir, outroot=rundir, dbo=dnf_obj)</span>
|
||||
<span class="sd"> runner.run("install-packages.ltmpl")</span>
|
||||
|
||||
<span class="sd"> # modify a runtime dir</span>
|
||||
<span class="sd"> runner = LoraxTemplateRunner(inroot=rundir, outroot=newrun)</span>
|
||||
<span class="sd"> runner.run("runtime-transmogrify.ltmpl")</span>
|
||||
|
||||
<span class="sd"> NOTES:</span>
|
||||
|
||||
<span class="sd"> * Parsing procedure is roughly:</span>
|
||||
<span class="sd"> 1. Mako template expansion (on the whole file)</span>
|
||||
<span class="sd"> 2. For each line of the result,</span>
|
||||
|
||||
<span class="sd"> a. Whitespace splitting (using shlex.split())</span>
|
||||
<span class="sd"> b. Brace expansion (using brace_expand())</span>
|
||||
<span class="sd"> c. If the first token is the name of a function, call that function</span>
|
||||
@ -292,89 +202,16 @@
|
||||
|
||||
<span class="sd"> * Parsing and execution are *separate* passes - so you can't use the result</span>
|
||||
<span class="sd"> of a command in an %if statement (or any other control statements)!</span>
|
||||
|
||||
<span class="sd"> * Commands that run external programs (systemctl, gconfset) currently use</span>
|
||||
<span class="sd"> the *host*'s copy of that program, which may cause problems if there's a</span>
|
||||
<span class="sd"> big enough difference between the host and the image you're modifying.</span>
|
||||
|
||||
<span class="sd"> * The commands are not executed under a real chroot, so absolute symlinks</span>
|
||||
<span class="sd"> will point *outside* the inroot/outroot. Be careful with symlinks!</span>
|
||||
|
||||
<span class="sd"> ADDING NEW COMMANDS:</span>
|
||||
|
||||
<span class="sd"> * Each template command is just a method of the LoraxTemplateRunner</span>
|
||||
<span class="sd"> object - so adding a new command is as easy as adding a new function.</span>
|
||||
|
||||
<span class="sd"> * Each function gets arguments that correspond to the rest of the tokens</span>
|
||||
<span class="sd"> on that line (after word splitting and brace expansion)</span>
|
||||
|
||||
<span class="sd"> * Commands should raise exceptions for errors - don't use sys.exit()</span>
|
||||
<span class="sd"> '''</span>
|
||||
<span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">inroot</span><span class="p">,</span> <span class="n">outroot</span><span class="p">,</span> <span class="n">dbo</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">fatalerrors</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
|
||||
<span class="n">templatedir</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">defaults</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">inroot</span> <span class="o">=</span> <span class="n">inroot</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">outroot</span> <span class="o">=</span> <span class="n">outroot</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">dbo</span> <span class="o">=</span> <span class="n">dbo</span>
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fatalerrors</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">templatedir</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">defaults</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">builtins</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">fatalerrors</span> <span class="o">=</span> <span class="n">fatalerrors</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">templatedir</span> <span class="o">=</span> <span class="n">templatedir</span> <span class="ow">or</span> <span class="s2">"/usr/share/lorax"</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">templatefile</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
<span class="c1"># some builtin methods</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">builtins</span> <span class="o">=</span> <span class="n">DataHolder</span><span class="p">(</span><span class="n">exists</span><span class="o">=</span><span class="k">lambda</span> <span class="n">p</span><span class="p">:</span> <span class="n">rexists</span><span class="p">(</span><span class="n">p</span><span class="p">,</span> <span class="n">root</span><span class="o">=</span><span class="n">inroot</span><span class="p">),</span>
|
||||
<span class="n">glob</span><span class="o">=</span><span class="k">lambda</span> <span class="n">g</span><span class="p">:</span> <span class="nb">list</span><span class="p">(</span><span class="n">rglob</span><span class="p">(</span><span class="n">g</span><span class="p">,</span> <span class="n">root</span><span class="o">=</span><span class="n">inroot</span><span class="p">)))</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">builtins</span> <span class="o">=</span> <span class="n">builtins</span> <span class="ow">or</span> <span class="p">{}</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">defaults</span> <span class="o">=</span> <span class="n">defaults</span> <span class="ow">or</span> <span class="p">{}</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">results</span> <span class="o">=</span> <span class="n">DataHolder</span><span class="p">(</span><span class="n">treeinfo</span><span class="o">=</span><span class="nb">dict</span><span class="p">())</span> <span class="c1"># just treeinfo for now</span>
|
||||
<span class="c1"># TODO: set up custom logger with a filter to add line info</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_out</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">path</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="n">joinpaths</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">outroot</span><span class="p">,</span> <span class="n">path</span><span class="p">)</span>
|
||||
<span class="k">def</span> <span class="nf">_in</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">path</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="n">joinpaths</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">inroot</span><span class="p">,</span> <span class="n">path</span><span class="p">)</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_filelist</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">pkgs</span><span class="p">):</span>
|
||||
<span class="sd">""" Return the list of files in the packages """</span>
|
||||
<span class="n">pkglist</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">pkg_glob</span> <span class="ow">in</span> <span class="n">pkgs</span><span class="p">:</span>
|
||||
<span class="n">pkglist</span> <span class="o">+=</span> <span class="nb">list</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">dbo</span><span class="o">.</span><span class="n">sack</span><span class="o">.</span><span class="n">query</span><span class="p">()</span><span class="o">.</span><span class="n">installed</span><span class="p">()</span><span class="o">.</span><span class="n">filter</span><span class="p">(</span><span class="n">name__glob</span><span class="o">=</span><span class="n">pkg_glob</span><span class="p">))</span>
|
||||
|
||||
<span class="c1"># dnf/hawkey doesn't make any distinction between file, dir or ghost like yum did</span>
|
||||
<span class="c1"># so only return the files.</span>
|
||||
<span class="k">return</span> <span class="nb">set</span><span class="p">(</span><span class="n">f</span> <span class="k">for</span> <span class="n">pkg</span> <span class="ow">in</span> <span class="n">pkglist</span> <span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">pkg</span><span class="o">.</span><span class="n">files</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isdir</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_out</span><span class="p">(</span><span class="n">f</span><span class="p">)))</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_getsize</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">files</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="nb">sum</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">getsize</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_out</span><span class="p">(</span><span class="n">f</span><span class="p">))</span> <span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">files</span> <span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_out</span><span class="p">(</span><span class="n">f</span><span class="p">)))</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_write_debuginfo_log</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Write a list of debuginfo packages to /root/debug-pkgs.log</span>
|
||||
|
||||
<span class="sd"> If lorax is called with a debug repo find the corresponding debuginfo package</span>
|
||||
<span class="sd"> names and write them to /root/debubg-pkgs.log on the boot.iso</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">for</span> <span class="n">repo</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">dbo</span><span class="o">.</span><span class="n">repos</span><span class="p">:</span>
|
||||
<span class="n">repo</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">dbo</span><span class="o">.</span><span class="n">repos</span><span class="p">[</span><span class="n">repo</span><span class="p">]</span>
|
||||
<span class="k">if</span> <span class="nb">any</span><span class="p">(</span><span class="kc">True</span> <span class="k">for</span> <span class="n">url</span> <span class="ow">in</span> <span class="n">repo</span><span class="o">.</span><span class="n">baseurl</span> <span class="k">if</span> <span class="s2">"debug"</span> <span class="ow">in</span> <span class="n">url</span><span class="p">):</span>
|
||||
<span class="k">break</span>
|
||||
<span class="k">if</span> <span class="n">repo</span><span class="o">.</span><span class="n">metalink</span> <span class="ow">and</span> <span class="s2">"debug"</span> <span class="ow">in</span> <span class="n">repo</span><span class="o">.</span><span class="n">metalink</span><span class="p">:</span>
|
||||
<span class="k">break</span>
|
||||
<span class="k">if</span> <span class="n">repo</span><span class="o">.</span><span class="n">mirrorlist</span> <span class="ow">and</span> <span class="s2">"debug"</span> <span class="ow">in</span> <span class="n">repo</span><span class="o">.</span><span class="n">mirrorlist</span><span class="p">:</span>
|
||||
<span class="k">break</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="c1"># No debug repos</span>
|
||||
<span class="k">return</span>
|
||||
|
||||
<span class="n">available</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">dbo</span><span class="o">.</span><span class="n">sack</span><span class="o">.</span><span class="n">query</span><span class="p">()</span><span class="o">.</span><span class="n">available</span><span class="p">()</span>
|
||||
<span class="n">debug_pkgs</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="nb">list</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">dbo</span><span class="o">.</span><span class="n">transaction</span><span class="o">.</span><span class="n">install_set</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="n">available</span><span class="o">.</span><span class="n">filter</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="n">p</span><span class="o">.</span><span class="n">name</span><span class="o">+</span><span class="s2">"-debuginfo"</span><span class="p">):</span>
|
||||
<span class="n">debug_pkgs</span> <span class="o">+=</span> <span class="p">[</span><span class="s2">"</span><span class="si">{0.name}</span><span class="s2">-debuginfo-</span><span class="si">{0.epoch}</span><span class="s2">:</span><span class="si">{0.version}</span><span class="s2">-</span><span class="si">{0.release}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">p</span><span class="p">)]</span>
|
||||
|
||||
<span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_out</span><span class="p">(</span><span class="s2">"root/"</span><span class="p">),</span> <span class="n">exist_ok</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
|
||||
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_out</span><span class="p">(</span><span class="s2">"root/debug-pkgs.log"</span><span class="p">),</span> <span class="s2">"w"</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
|
||||
<span class="k">for</span> <span class="n">pkg</span> <span class="ow">in</span> <span class="n">debug_pkgs</span><span class="p">:</span>
|
||||
<span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s2">"</span><span class="si">%s</span><span class="se">\n</span><span class="s2">"</span> <span class="o">%</span> <span class="n">pkg</span><span class="p">)</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="LoraxTemplateRunner.run"><a class="viewcode-back" href="../../pylorax.html#pylorax.ltmpl.LoraxTemplateRunner.run">[docs]</a> <span class="k">def</span> <span class="nf">run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">templatefile</span><span class="p">,</span> <span class="o">**</span><span class="n">variables</span><span class="p">):</span>
|
||||
<div class="viewcode-block" id="TemplateRunner.run"><a class="viewcode-back" href="../../pylorax.html#pylorax.ltmpl.TemplateRunner.run">[docs]</a> <span class="k">def</span> <span class="nf">run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">templatefile</span><span class="p">,</span> <span class="o">**</span><span class="n">variables</span><span class="p">):</span>
|
||||
<span class="k">for</span> <span class="n">k</span><span class="p">,</span><span class="n">v</span> <span class="ow">in</span> <span class="nb">list</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">defaults</span><span class="o">.</span><span class="n">items</span><span class="p">())</span> <span class="o">+</span> <span class="nb">list</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">builtins</span><span class="o">.</span><span class="n">items</span><span class="p">()):</span>
|
||||
<span class="n">variables</span><span class="o">.</span><span class="n">setdefault</span><span class="p">(</span><span class="n">k</span><span class="p">,</span><span class="n">v</span><span class="p">)</span>
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">"executing </span><span class="si">%s</span><span class="s2"> with variables=</span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">templatefile</span><span class="p">,</span> <span class="n">variables</span><span class="p">)</span>
|
||||
@ -398,7 +235,7 @@
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="c1"># grab the method named in cmd and pass it the given arguments</span>
|
||||
<span class="n">f</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">cmd</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">cmd</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s1">'_'</span> <span class="ow">or</span> <span class="n">cmd</span> <span class="o">==</span> <span class="s1">'run'</span> <span class="ow">or</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">collections</span><span class="o">.</span><span class="n">Callable</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="n">cmd</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s1">'_'</span> <span class="ow">or</span> <span class="n">cmd</span> <span class="o">==</span> <span class="s1">'run'</span> <span class="ow">or</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">collections</span><span class="o">.</span><span class="n">abc</span><span class="o">.</span><span class="n">Callable</span><span class="p">):</span>
|
||||
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"unknown command </span><span class="si">%s</span><span class="s2">"</span> <span class="o">%</span> <span class="n">cmd</span><span class="p">)</span>
|
||||
<span class="n">f</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">)</span>
|
||||
<span class="k">except</span> <span class="ne">Exception</span><span class="p">:</span> <span class="c1"># pylint: disable=broad-except</span>
|
||||
@ -412,12 +249,242 @@
|
||||
<span class="c1"># skip the bit about "ltmpl.py, in _run()" - we know that</span>
|
||||
<span class="n">exclines</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
|
||||
<span class="c1"># log the "ErrorType: this is what happened" line</span>
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="s2">" "</span> <span class="o">+</span> <span class="n">exclines</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">())</span>
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="s2">" </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">exclines</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">())</span>
|
||||
<span class="c1"># and log the entire traceback to the debug log</span>
|
||||
<span class="k">for</span> <span class="n">_line</span> <span class="ow">in</span> <span class="s1">''</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">exclines</span><span class="p">)</span><span class="o">.</span><span class="n">splitlines</span><span class="p">():</span>
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">" "</span> <span class="o">+</span> <span class="n">_line</span><span class="p">)</span>
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">" </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">_line</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">fatalerrors</span><span class="p">:</span>
|
||||
<span class="k">raise</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="InstallpkgMixin"><a class="viewcode-back" href="../../pylorax.html#pylorax.ltmpl.InstallpkgMixin">[docs]</a><span class="k">class</span> <span class="nc">InstallpkgMixin</span><span class="p">:</span>
|
||||
<span class="sd">"""Helper class used with *Runner classes"""</span>
|
||||
<span class="k">def</span> <span class="nf">_pkgver</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">pkg_spec</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Helper to parse package version compare operators</span>
|
||||
|
||||
<span class="sd"> Returns a list of matching package objects or an empty list</span>
|
||||
|
||||
<span class="sd"> Examples:</span>
|
||||
<span class="sd"> "bash>4.01"</span>
|
||||
<span class="sd"> "tmux>=3.1.4-5"</span>
|
||||
<span class="sd"> "grub2<2.06"</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="c1"># Always return the highest of the filtered results</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="nb">any</span><span class="p">(</span><span class="n">g</span> <span class="k">for</span> <span class="n">g</span> <span class="ow">in</span> <span class="p">[</span><span class="s1">'='</span><span class="p">,</span> <span class="s1">'<'</span><span class="p">,</span> <span class="s1">'>'</span><span class="p">,</span> <span class="s1">'!'</span><span class="p">]</span> <span class="k">if</span> <span class="n">g</span> <span class="ow">in</span> <span class="n">pkg_spec</span><span class="p">):</span>
|
||||
<span class="n">query</span> <span class="o">=</span> <span class="n">dnf</span><span class="o">.</span><span class="n">subject</span><span class="o">.</span><span class="n">Subject</span><span class="p">(</span><span class="n">pkg_spec</span><span class="p">)</span><span class="o">.</span><span class="n">get_best_query</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">dbo</span><span class="o">.</span><span class="n">sack</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">pcv</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="sa">r</span><span class="s1">'([!<>=]+)'</span><span class="p">,</span> <span class="n">pkg_spec</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">pcv</span><span class="p">[</span><span class="mi">0</span><span class="p">]:</span>
|
||||
<span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span><span class="s2">"Missing package name"</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">pcv</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]:</span>
|
||||
<span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span><span class="s2">"Missing version"</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">pcv</span><span class="p">)</span> <span class="o">!=</span> <span class="mi">3</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span><span class="s2">"Too many comparisons"</span><span class="p">)</span>
|
||||
|
||||
<span class="n">query</span> <span class="o">=</span> <span class="n">dnf</span><span class="o">.</span><span class="n">subject</span><span class="o">.</span><span class="n">Subject</span><span class="p">(</span><span class="n">pcv</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span><span class="o">.</span><span class="n">get_best_query</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">dbo</span><span class="o">.</span><span class="n">sack</span><span class="p">)</span>
|
||||
|
||||
<span class="c1"># Parse the comparison operators</span>
|
||||
<span class="k">if</span> <span class="n">pcv</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"="</span> <span class="ow">or</span> <span class="n">pcv</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"=="</span><span class="p">:</span>
|
||||
<span class="n">query</span><span class="o">.</span><span class="n">filterm</span><span class="p">(</span><span class="n">evr__eq</span> <span class="o">=</span> <span class="n">pcv</span><span class="p">[</span><span class="mi">2</span><span class="p">])</span>
|
||||
<span class="k">elif</span> <span class="n">pcv</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"!="</span> <span class="ow">or</span> <span class="n">pcv</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"<>"</span><span class="p">:</span>
|
||||
<span class="n">query</span><span class="o">.</span><span class="n">filterm</span><span class="p">(</span><span class="n">evr__neq</span> <span class="o">=</span> <span class="n">pcv</span><span class="p">[</span><span class="mi">2</span><span class="p">])</span>
|
||||
<span class="k">elif</span> <span class="n">pcv</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">==</span> <span class="s2">">"</span><span class="p">:</span>
|
||||
<span class="n">query</span><span class="o">.</span><span class="n">filterm</span><span class="p">(</span><span class="n">evr__gt</span> <span class="o">=</span> <span class="n">pcv</span><span class="p">[</span><span class="mi">2</span><span class="p">])</span>
|
||||
<span class="k">elif</span> <span class="n">pcv</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">==</span> <span class="s2">">="</span> <span class="ow">or</span> <span class="n">pcv</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"=>"</span><span class="p">:</span>
|
||||
<span class="n">query</span><span class="o">.</span><span class="n">filterm</span><span class="p">(</span><span class="n">evr__gte</span> <span class="o">=</span> <span class="n">pcv</span><span class="p">[</span><span class="mi">2</span><span class="p">])</span>
|
||||
<span class="k">elif</span> <span class="n">pcv</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"<"</span><span class="p">:</span>
|
||||
<span class="n">query</span><span class="o">.</span><span class="n">filterm</span><span class="p">(</span><span class="n">evr__lt</span> <span class="o">=</span> <span class="n">pcv</span><span class="p">[</span><span class="mi">2</span><span class="p">])</span>
|
||||
<span class="k">elif</span> <span class="n">pcv</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"<="</span> <span class="ow">or</span> <span class="n">pcv</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"=<"</span><span class="p">:</span>
|
||||
<span class="n">query</span><span class="o">.</span><span class="n">filterm</span><span class="p">(</span><span class="n">evr__lte</span> <span class="o">=</span> <span class="n">pcv</span><span class="p">[</span><span class="mi">2</span><span class="p">])</span>
|
||||
|
||||
<span class="c1"># MUST be added last. Otherwise it will only return the latest, not the latest of the</span>
|
||||
<span class="c1"># filtered results.</span>
|
||||
<span class="n">query</span><span class="o">.</span><span class="n">filterm</span><span class="p">(</span><span class="n">latest</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="p">[</span><span class="n">pkg</span> <span class="k">for</span> <span class="n">pkg</span> <span class="ow">in</span> <span class="n">query</span><span class="o">.</span><span class="n">apply</span><span class="p">()]</span>
|
||||
|
||||
<div class="viewcode-block" id="InstallpkgMixin.installpkg"><a class="viewcode-back" href="../../pylorax.html#pylorax.ltmpl.InstallpkgMixin.installpkg">[docs]</a> <span class="k">def</span> <span class="nf">installpkg</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">pkgs</span><span class="p">):</span>
|
||||
<span class="sd">'''</span>
|
||||
<span class="sd"> installpkg [--required|--optional] [--except PKGGLOB [--except PKGGLOB ...]] PKGGLOB [PKGGLOB ...]</span>
|
||||
<span class="sd"> Request installation of all packages matching the given globs.</span>
|
||||
<span class="sd"> Note that this is just a *request* - nothing is *actually* installed</span>
|
||||
<span class="sd"> until the 'run_pkg_transaction' command is given.</span>
|
||||
|
||||
<span class="sd"> The non-except PKGGLOB can contain a version comparison. This should</span>
|
||||
<span class="sd"> not be used as a substitute for package dependencies, it should be</span>
|
||||
<span class="sd"> used to enforce installation of tools required by the templates. eg.</span>
|
||||
<span class="sd"> grub2 changed the font location in 2.06-2 so the current templates</span>
|
||||
<span class="sd"> require grub2 to be 2.06-2 or later.</span>
|
||||
|
||||
<span class="sd"> installpkg tmux>=2.8 bash=5.0.0-1</span>
|
||||
|
||||
<span class="sd"> It supports the =,!=,>,>=,<,<= operators. == is an alias for =, and</span>
|
||||
<span class="sd"> <> is an alias for !=</span>
|
||||
|
||||
<span class="sd"> There should be no spaces between the package name, the compare</span>
|
||||
<span class="sd"> operator, and the version.</span>
|
||||
|
||||
<span class="sd"> NOTE: When testing for equality you must include the version AND</span>
|
||||
<span class="sd"> release, otherwise it won't match anything.</span>
|
||||
|
||||
<span class="sd"> --required is now the default. If the PKGGLOB can be missing pass --optional</span>
|
||||
<span class="sd"> '''</span>
|
||||
<span class="k">if</span> <span class="n">pkgs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s1">'--optional'</span><span class="p">:</span>
|
||||
<span class="n">pkgs</span> <span class="o">=</span> <span class="n">pkgs</span><span class="p">[</span><span class="mi">1</span><span class="p">:]</span>
|
||||
<span class="n">required</span> <span class="o">=</span> <span class="kc">False</span>
|
||||
<span class="k">elif</span> <span class="n">pkgs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s1">'--required'</span><span class="p">:</span>
|
||||
<span class="n">pkgs</span> <span class="o">=</span> <span class="n">pkgs</span><span class="p">[</span><span class="mi">1</span><span class="p">:]</span>
|
||||
<span class="n">required</span> <span class="o">=</span> <span class="kc">True</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">required</span> <span class="o">=</span> <span class="kc">True</span>
|
||||
|
||||
<span class="n">excludes</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">while</span> <span class="s1">'--except'</span> <span class="ow">in</span> <span class="n">pkgs</span><span class="p">:</span>
|
||||
<span class="n">idx</span> <span class="o">=</span> <span class="n">pkgs</span><span class="o">.</span><span class="n">index</span><span class="p">(</span><span class="s1">'--except'</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">pkgs</span><span class="p">)</span> <span class="o">==</span> <span class="n">idx</span><span class="o">+</span><span class="mi">1</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"installpkg needs an argument after --except"</span><span class="p">)</span>
|
||||
|
||||
<span class="c1"># TODO: Check for bare version compare operators</span>
|
||||
<span class="n">excludes</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">pkgs</span><span class="p">[</span><span class="n">idx</span><span class="o">+</span><span class="mi">1</span><span class="p">])</span>
|
||||
<span class="n">pkgs</span> <span class="o">=</span> <span class="n">pkgs</span><span class="p">[:</span><span class="n">idx</span><span class="p">]</span> <span class="o">+</span> <span class="n">pkgs</span><span class="p">[</span><span class="n">idx</span><span class="o">+</span><span class="mi">2</span><span class="p">:]</span>
|
||||
|
||||
<span class="n">errors</span> <span class="o">=</span> <span class="kc">False</span>
|
||||
<span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">pkgs</span><span class="p">:</span>
|
||||
<span class="c1"># Did a version compare operatore end up in the list?</span>
|
||||
<span class="k">if</span> <span class="n">p</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="ow">in</span> <span class="p">[</span><span class="s1">'='</span><span class="p">,</span> <span class="s1">'<'</span><span class="p">,</span> <span class="s1">'>'</span><span class="p">,</span> <span class="s1">'!'</span><span class="p">]:</span>
|
||||
<span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span><span class="s2">"Version compare operators cannot be surrounded by spaces"</span><span class="p">)</span>
|
||||
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="c1"># Start by using Subject to generate a package query, which will</span>
|
||||
<span class="c1"># give us a query object similar to what dbo.install would select,</span>
|
||||
<span class="c1"># minus the handling for multilib. This query may contain</span>
|
||||
<span class="c1"># multiple arches. Pull the package names out of that, filter any</span>
|
||||
<span class="c1"># that match the excludes patterns, and pass those names back to</span>
|
||||
<span class="c1"># dbo.install to do the actual, arch and version and multilib</span>
|
||||
<span class="c1"># aware, package selction.</span>
|
||||
|
||||
<span class="c1"># dnf queries don't have a concept of negative globs which is why</span>
|
||||
<span class="c1"># the filtering is done the hard way.</span>
|
||||
|
||||
<span class="c1"># Get the latest package, or package matching the selected version</span>
|
||||
<span class="n">pkgnames</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_pkgver</span><span class="p">(</span><span class="n">p</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">pkgnames</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="n">dnf</span><span class="o">.</span><span class="n">exceptions</span><span class="o">.</span><span class="n">PackageNotFoundError</span><span class="p">(</span><span class="s2">"no package matched"</span><span class="p">,</span> <span class="n">p</span><span class="p">)</span>
|
||||
|
||||
<span class="c1"># Apply excludes to the name only</span>
|
||||
<span class="k">for</span> <span class="n">exclude</span> <span class="ow">in</span> <span class="n">excludes</span><span class="p">:</span>
|
||||
<span class="n">pkgnames</span> <span class="o">=</span> <span class="p">[</span><span class="n">pkg</span> <span class="k">for</span> <span class="n">pkg</span> <span class="ow">in</span> <span class="n">pkgnames</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">fnmatch</span><span class="o">.</span><span class="n">fnmatch</span><span class="p">(</span><span class="n">pkg</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">exclude</span><span class="p">)]</span>
|
||||
|
||||
<span class="c1"># Convert to a sorted NVR list for installation</span>
|
||||
<span class="n">pkgnvrs</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">([</span><span class="s2">"</span><span class="si">{}</span><span class="s2">-</span><span class="si">{}</span><span class="s2">-</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">pkg</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">pkg</span><span class="o">.</span><span class="n">version</span><span class="p">,</span> <span class="n">pkg</span><span class="o">.</span><span class="n">release</span><span class="p">)</span> <span class="k">for</span> <span class="n">pkg</span> <span class="ow">in</span> <span class="n">pkgnames</span><span class="p">])</span>
|
||||
|
||||
<span class="c1"># If the request is a glob, expand it in the log</span>
|
||||
<span class="k">if</span> <span class="nb">any</span><span class="p">(</span><span class="n">g</span> <span class="k">for</span> <span class="n">g</span> <span class="ow">in</span> <span class="p">[</span><span class="s1">'*'</span><span class="p">,</span><span class="s1">'?'</span><span class="p">,</span><span class="s1">'.'</span><span class="p">]</span> <span class="k">if</span> <span class="n">g</span> <span class="ow">in</span> <span class="n">p</span><span class="p">):</span>
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"installpkg: </span><span class="si">%s</span><span class="s2"> expands to </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">p</span><span class="p">,</span> <span class="s2">","</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">pkgnvrs</span><span class="p">))</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">pkgnvr</span> <span class="ow">in</span> <span class="n">pkgnvrs</span><span class="p">:</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">dbo</span><span class="o">.</span><span class="n">install</span><span class="p">(</span><span class="n">pkgnvr</span><span class="p">)</span>
|
||||
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span> <span class="c1"># pylint: disable=broad-except</span>
|
||||
<span class="k">if</span> <span class="n">required</span><span class="p">:</span>
|
||||
<span class="k">raise</span>
|
||||
<span class="c1"># Not required, log it and continue processing pkgs</span>
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="s2">"installpkg </span><span class="si">%s</span><span class="s2"> failed: </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">pkgnvr</span><span class="p">,</span> <span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="p">))</span>
|
||||
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span> <span class="c1"># pylint: disable=broad-except</span>
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="s2">"installpkg </span><span class="si">%s</span><span class="s2"> failed: </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">p</span><span class="p">,</span> <span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="p">))</span>
|
||||
<span class="n">errors</span> <span class="o">=</span> <span class="kc">True</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">errors</span> <span class="ow">and</span> <span class="n">required</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s2">"Required installpkg failed."</span><span class="p">)</span></div></div>
|
||||
|
||||
|
||||
<span class="c1"># TODO: operate inside an actual chroot for safety? Not that RPM bothers..</span>
|
||||
<div class="viewcode-block" id="LoraxTemplateRunner"><a class="viewcode-back" href="../../pylorax.html#pylorax.ltmpl.LoraxTemplateRunner">[docs]</a><span class="k">class</span> <span class="nc">LoraxTemplateRunner</span><span class="p">(</span><span class="n">TemplateRunner</span><span class="p">,</span> <span class="n">InstallpkgMixin</span><span class="p">):</span>
|
||||
<span class="sd">'''</span>
|
||||
<span class="sd"> This class parses and executes Lorax templates. Sample usage:</span>
|
||||
|
||||
<span class="sd"> # install a bunch of packages</span>
|
||||
<span class="sd"> runner = LoraxTemplateRunner(inroot=rundir, outroot=rundir, dbo=dnf_obj)</span>
|
||||
<span class="sd"> runner.run("install-packages.ltmpl")</span>
|
||||
|
||||
<span class="sd"> # modify a runtime dir</span>
|
||||
<span class="sd"> runner = LoraxTemplateRunner(inroot=rundir, outroot=newrun)</span>
|
||||
<span class="sd"> runner.run("runtime-transmogrify.ltmpl")</span>
|
||||
|
||||
<span class="sd"> NOTES:</span>
|
||||
|
||||
<span class="sd"> * Commands that run external programs (e.g. systemctl) currently use</span>
|
||||
<span class="sd"> the *host*'s copy of that program, which may cause problems if there's a</span>
|
||||
<span class="sd"> big enough difference between the host and the image you're modifying.</span>
|
||||
|
||||
<span class="sd"> * The commands are not executed under a real chroot, so absolute symlinks</span>
|
||||
<span class="sd"> will point *outside* the inroot/outroot. Be careful with symlinks!</span>
|
||||
|
||||
<span class="sd"> ADDING NEW COMMANDS:</span>
|
||||
|
||||
<span class="sd"> * Each template command is just a method of the LoraxTemplateRunner</span>
|
||||
<span class="sd"> object - so adding a new command is as easy as adding a new function.</span>
|
||||
|
||||
<span class="sd"> * Each function gets arguments that correspond to the rest of the tokens</span>
|
||||
<span class="sd"> on that line (after word splitting and brace expansion)</span>
|
||||
|
||||
<span class="sd"> * Commands should raise exceptions for errors - don't use sys.exit()</span>
|
||||
<span class="sd"> '''</span>
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">inroot</span><span class="p">,</span> <span class="n">outroot</span><span class="p">,</span> <span class="n">dbo</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">fatalerrors</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
|
||||
<span class="n">templatedir</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">defaults</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">inroot</span> <span class="o">=</span> <span class="n">inroot</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">outroot</span> <span class="o">=</span> <span class="n">outroot</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">dbo</span> <span class="o">=</span> <span class="n">dbo</span>
|
||||
<span class="n">builtins</span> <span class="o">=</span> <span class="n">DataHolder</span><span class="p">(</span><span class="n">exists</span><span class="o">=</span><span class="k">lambda</span> <span class="n">p</span><span class="p">:</span> <span class="n">rexists</span><span class="p">(</span><span class="n">p</span><span class="p">,</span> <span class="n">root</span><span class="o">=</span><span class="n">inroot</span><span class="p">),</span>
|
||||
<span class="n">glob</span><span class="o">=</span><span class="k">lambda</span> <span class="n">g</span><span class="p">:</span> <span class="nb">list</span><span class="p">(</span><span class="n">rglob</span><span class="p">(</span><span class="n">g</span><span class="p">,</span> <span class="n">root</span><span class="o">=</span><span class="n">inroot</span><span class="p">)))</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">results</span> <span class="o">=</span> <span class="n">DataHolder</span><span class="p">(</span><span class="n">treeinfo</span><span class="o">=</span><span class="nb">dict</span><span class="p">())</span> <span class="c1"># just treeinfo for now</span>
|
||||
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">LoraxTemplateRunner</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">fatalerrors</span><span class="p">,</span> <span class="n">templatedir</span><span class="p">,</span> <span class="n">defaults</span><span class="p">,</span> <span class="n">builtins</span><span class="p">)</span>
|
||||
<span class="c1"># TODO: set up custom logger with a filter to add line info</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_out</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">path</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="n">joinpaths</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">outroot</span><span class="p">,</span> <span class="n">path</span><span class="p">)</span>
|
||||
<span class="k">def</span> <span class="nf">_in</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">path</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="n">joinpaths</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">inroot</span><span class="p">,</span> <span class="n">path</span><span class="p">)</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_filelist</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">pkgs</span><span class="p">):</span>
|
||||
<span class="sd">""" Return the list of files in the packages """</span>
|
||||
<span class="n">pkglist</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">pkg_glob</span> <span class="ow">in</span> <span class="n">pkgs</span><span class="p">:</span>
|
||||
<span class="n">pkglist</span> <span class="o">+=</span> <span class="nb">list</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">dbo</span><span class="o">.</span><span class="n">sack</span><span class="o">.</span><span class="n">query</span><span class="p">()</span><span class="o">.</span><span class="n">installed</span><span class="p">()</span><span class="o">.</span><span class="n">filter</span><span class="p">(</span><span class="n">name__glob</span><span class="o">=</span><span class="n">pkg_glob</span><span class="p">))</span>
|
||||
|
||||
<span class="c1"># dnf/hawkey doesn't make any distinction between file, dir or ghost like yum did</span>
|
||||
<span class="c1"># so only return the files.</span>
|
||||
<span class="k">return</span> <span class="nb">set</span><span class="p">(</span><span class="n">f</span> <span class="k">for</span> <span class="n">pkg</span> <span class="ow">in</span> <span class="n">pkglist</span> <span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">pkg</span><span class="o">.</span><span class="n">files</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isdir</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_out</span><span class="p">(</span><span class="n">f</span><span class="p">)))</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_getsize</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">files</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="nb">sum</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">getsize</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_out</span><span class="p">(</span><span class="n">f</span><span class="p">))</span> <span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">files</span> <span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_out</span><span class="p">(</span><span class="n">f</span><span class="p">)))</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_write_package_log</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Write the list of installed packages to /root/ on the boot.iso</span>
|
||||
|
||||
<span class="sd"> If lorax is called with a debug repo find the corresponding debuginfo package</span>
|
||||
<span class="sd"> names and write them to /root/debubg-pkgs.log on the boot.iso</span>
|
||||
<span class="sd"> The non-debuginfo packages are written to /root/lorax-packages.log</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_out</span><span class="p">(</span><span class="s2">"root/"</span><span class="p">),</span> <span class="n">exist_ok</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
|
||||
<span class="n">available</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">dbo</span><span class="o">.</span><span class="n">sack</span><span class="o">.</span><span class="n">query</span><span class="p">()</span><span class="o">.</span><span class="n">available</span><span class="p">()</span>
|
||||
<span class="n">pkgs</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="n">debug_pkgs</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="nb">list</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">dbo</span><span class="o">.</span><span class="n">transaction</span><span class="o">.</span><span class="n">install_set</span><span class="p">):</span>
|
||||
<span class="n">pkgs</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">p</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">-</span><span class="si">{</span><span class="n">p</span><span class="o">.</span><span class="n">version</span><span class="si">}</span><span class="s2">-</span><span class="si">{</span><span class="n">p</span><span class="o">.</span><span class="n">release</span><span class="si">}</span><span class="s2">.</span><span class="si">{</span><span class="n">p</span><span class="o">.</span><span class="n">arch</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">available</span><span class="o">.</span><span class="n">filter</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="n">p</span><span class="o">.</span><span class="n">name</span><span class="o">+</span><span class="s2">"-debuginfo"</span><span class="p">):</span>
|
||||
<span class="n">debug_pkgs</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">p</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">-debuginfo-</span><span class="si">{</span><span class="n">p</span><span class="o">.</span><span class="n">epoch</span><span class="si">}</span><span class="s2">:</span><span class="si">{</span><span class="n">p</span><span class="o">.</span><span class="n">version</span><span class="si">}</span><span class="s2">-</span><span class="si">{</span><span class="n">p</span><span class="o">.</span><span class="n">release</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span>
|
||||
|
||||
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_out</span><span class="p">(</span><span class="s2">"root/lorax-packages.log"</span><span class="p">),</span> <span class="s2">"w"</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
|
||||
<span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="nb">sorted</span><span class="p">(</span><span class="n">pkgs</span><span class="p">)))</span>
|
||||
<span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">debug_pkgs</span><span class="p">:</span>
|
||||
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_out</span><span class="p">(</span><span class="s2">"root/debug-pkgs.log"</span><span class="p">),</span> <span class="s2">"w"</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
|
||||
<span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="nb">sorted</span><span class="p">(</span><span class="n">debug_pkgs</span><span class="p">)))</span>
|
||||
<span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span>
|
||||
|
||||
<div class="viewcode-block" id="LoraxTemplateRunner.install"><a class="viewcode-back" href="../../pylorax.html#pylorax.ltmpl.LoraxTemplateRunner.install">[docs]</a> <span class="k">def</span> <span class="nf">install</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">srcglob</span><span class="p">,</span> <span class="n">dest</span><span class="p">):</span>
|
||||
<span class="sd">'''</span>
|
||||
@ -429,6 +496,7 @@
|
||||
<span class="sd"> If DEST doesn't exist, SRC will be copied to a file with that name,</span>
|
||||
<span class="sd"> assuming the rest of the path exists.</span>
|
||||
<span class="sd"> This is pretty much like how the 'cp' command works.</span>
|
||||
|
||||
<span class="sd"> Examples:</span>
|
||||
<span class="sd"> install usr/share/myconfig/grub.conf /boot</span>
|
||||
<span class="sd"> install /usr/share/myconfig/grub.conf.in /boot/grub.conf</span>
|
||||
@ -484,6 +552,7 @@
|
||||
<span class="sd">'''</span>
|
||||
<span class="sd"> mkdir DIR [DIR ...]</span>
|
||||
<span class="sd"> Create the named DIR(s). Will create leading directories as needed.</span>
|
||||
|
||||
<span class="sd"> Example:</span>
|
||||
<span class="sd"> mkdir /images</span>
|
||||
<span class="sd"> '''</span>
|
||||
@ -497,6 +566,7 @@
|
||||
<span class="sd"> replace PATTERN REPLACEMENT FILEGLOB [FILEGLOB ...]</span>
|
||||
<span class="sd"> Find-and-replace the given PATTERN (Python-style regex) with the given</span>
|
||||
<span class="sd"> REPLACEMENT string for each of the files listed.</span>
|
||||
|
||||
<span class="sd"> Example:</span>
|
||||
<span class="sd"> replace @VERSION@ ${product.version} /boot/grub.conf /boot/isolinux.cfg</span>
|
||||
<span class="sd"> '''</span>
|
||||
@ -514,7 +584,9 @@
|
||||
<span class="sd"> Append STRING (followed by a newline character) to FILE.</span>
|
||||
<span class="sd"> Python character escape sequences ('\\n', '\\t', etc.) will be</span>
|
||||
<span class="sd"> converted to the appropriate characters.</span>
|
||||
|
||||
<span class="sd"> Examples:</span>
|
||||
|
||||
<span class="sd"> append /etc/depmod.d/dd.conf "search updates built-in"</span>
|
||||
<span class="sd"> append /etc/resolv.conf ""</span>
|
||||
<span class="sd"> '''</span>
|
||||
@ -527,6 +599,7 @@
|
||||
<span class="sd"> Add an item to the treeinfo data store.</span>
|
||||
<span class="sd"> The given SECTION will have a new item added where</span>
|
||||
<span class="sd"> KEY = ARG ARG ...</span>
|
||||
|
||||
<span class="sd"> Example:</span>
|
||||
<span class="sd"> treeinfo images-${kernel.arch} boot.iso images/boot.iso</span>
|
||||
<span class="sd"> '''</span>
|
||||
@ -623,26 +696,11 @@
|
||||
<span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">rglob</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_out</span><span class="p">(</span><span class="n">fileglob</span><span class="p">),</span> <span class="n">fatal</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span>
|
||||
<span class="n">os</span><span class="o">.</span><span class="n">chmod</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="nb">int</span><span class="p">(</span><span class="n">mode</span><span class="p">,</span><span class="mi">8</span><span class="p">))</span></div>
|
||||
|
||||
<span class="c1"># TODO: do we need a new command for gsettings?</span>
|
||||
<div class="viewcode-block" id="LoraxTemplateRunner.gconfset"><a class="viewcode-back" href="../../pylorax.html#pylorax.ltmpl.LoraxTemplateRunner.gconfset">[docs]</a> <span class="k">def</span> <span class="nf">gconfset</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">path</span><span class="p">,</span> <span class="n">keytype</span><span class="p">,</span> <span class="n">value</span><span class="p">,</span> <span class="n">outfile</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
<span class="sd">'''</span>
|
||||
<span class="sd"> gconfset PATH KEYTYPE VALUE [OUTFILE]</span>
|
||||
<span class="sd"> Set the given gconf PATH, with type KEYTYPE, to the given value.</span>
|
||||
<span class="sd"> OUTFILE defaults to /etc/gconf/gconf.xml.defaults if not given.</span>
|
||||
<span class="sd"> Example:</span>
|
||||
<span class="sd"> gconfset /apps/metacity/general/num_workspaces int 1</span>
|
||||
<span class="sd"> '''</span>
|
||||
<span class="k">if</span> <span class="n">outfile</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="n">outfile</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_out</span><span class="p">(</span><span class="s2">"etc/gconf/gconf.xml.defaults"</span><span class="p">)</span>
|
||||
<span class="n">cmd</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"gconftool-2"</span><span class="p">,</span> <span class="s2">"--direct"</span><span class="p">,</span>
|
||||
<span class="s2">"--config-source=xml:readwrite:</span><span class="si">%s</span><span class="s2">"</span> <span class="o">%</span> <span class="n">outfile</span><span class="p">,</span>
|
||||
<span class="s2">"--set"</span><span class="p">,</span> <span class="s2">"--type"</span><span class="p">,</span> <span class="n">keytype</span><span class="p">,</span> <span class="n">path</span><span class="p">,</span> <span class="n">value</span><span class="p">]</span>
|
||||
<span class="n">runcmd</span><span class="p">(</span><span class="n">cmd</span><span class="p">)</span></div>
|
||||
|
||||
<div class="viewcode-block" id="LoraxTemplateRunner.log"><a class="viewcode-back" href="../../pylorax.html#pylorax.ltmpl.LoraxTemplateRunner.log">[docs]</a> <span class="k">def</span> <span class="nf">log</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">msg</span><span class="p">):</span>
|
||||
<span class="sd">'''</span>
|
||||
<span class="sd"> log MESSAGE</span>
|
||||
<span class="sd"> Emit the given log message. Be sure to put it in quotes!</span>
|
||||
|
||||
<span class="sd"> Example:</span>
|
||||
<span class="sd"> log "Reticulating splines, please wait..."</span>
|
||||
<span class="sd"> '''</span>
|
||||
@ -686,80 +744,11 @@
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="s1">'command returned failure (</span><span class="si">%d</span><span class="s1">)'</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">returncode</span><span class="p">)</span>
|
||||
<span class="k">raise</span></div>
|
||||
|
||||
<div class="viewcode-block" id="LoraxTemplateRunner.installpkg"><a class="viewcode-back" href="../../pylorax.html#pylorax.ltmpl.LoraxTemplateRunner.installpkg">[docs]</a> <span class="k">def</span> <span class="nf">installpkg</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">pkgs</span><span class="p">):</span>
|
||||
<span class="sd">'''</span>
|
||||
<span class="sd"> installpkg [--required|--optional] [--except PKGGLOB [--except PKGGLOB ...]] PKGGLOB [PKGGLOB ...]</span>
|
||||
<span class="sd"> Request installation of all packages matching the given globs.</span>
|
||||
<span class="sd"> Note that this is just a *request* - nothing is *actually* installed</span>
|
||||
<span class="sd"> until the 'run_pkg_transaction' command is given.</span>
|
||||
|
||||
<span class="sd"> --required is now the default. If the PKGGLOB can be missing pass --optional</span>
|
||||
<span class="sd"> '''</span>
|
||||
<span class="k">if</span> <span class="n">pkgs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s1">'--optional'</span><span class="p">:</span>
|
||||
<span class="n">pkgs</span> <span class="o">=</span> <span class="n">pkgs</span><span class="p">[</span><span class="mi">1</span><span class="p">:]</span>
|
||||
<span class="n">required</span> <span class="o">=</span> <span class="kc">False</span>
|
||||
<span class="k">elif</span> <span class="n">pkgs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s1">'--required'</span><span class="p">:</span>
|
||||
<span class="n">pkgs</span> <span class="o">=</span> <span class="n">pkgs</span><span class="p">[</span><span class="mi">1</span><span class="p">:]</span>
|
||||
<span class="n">required</span> <span class="o">=</span> <span class="kc">True</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">required</span> <span class="o">=</span> <span class="kc">True</span>
|
||||
|
||||
<span class="n">excludes</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">while</span> <span class="s1">'--except'</span> <span class="ow">in</span> <span class="n">pkgs</span><span class="p">:</span>
|
||||
<span class="n">idx</span> <span class="o">=</span> <span class="n">pkgs</span><span class="o">.</span><span class="n">index</span><span class="p">(</span><span class="s1">'--except'</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">pkgs</span><span class="p">)</span> <span class="o">==</span> <span class="n">idx</span><span class="o">+</span><span class="mi">1</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"installpkg needs an argument after --except"</span><span class="p">)</span>
|
||||
|
||||
<span class="n">excludes</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">pkgs</span><span class="p">[</span><span class="n">idx</span><span class="o">+</span><span class="mi">1</span><span class="p">])</span>
|
||||
<span class="n">pkgs</span> <span class="o">=</span> <span class="n">pkgs</span><span class="p">[:</span><span class="n">idx</span><span class="p">]</span> <span class="o">+</span> <span class="n">pkgs</span><span class="p">[</span><span class="n">idx</span><span class="o">+</span><span class="mi">2</span><span class="p">:]</span>
|
||||
|
||||
<span class="n">errors</span> <span class="o">=</span> <span class="kc">False</span>
|
||||
<span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">pkgs</span><span class="p">:</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="c1"># Start by using Subject to generate a package query, which will</span>
|
||||
<span class="c1"># give us a query object similar to what dbo.install would select,</span>
|
||||
<span class="c1"># minus the handling for multilib. This query may contain</span>
|
||||
<span class="c1"># multiple arches. Pull the package names out of that, filter any</span>
|
||||
<span class="c1"># that match the excludes patterns, and pass those names back to</span>
|
||||
<span class="c1"># dbo.install to do the actual, arch and version and multilib</span>
|
||||
<span class="c1"># aware, package selction.</span>
|
||||
|
||||
<span class="c1"># dnf queries don't have a concept of negative globs which is why</span>
|
||||
<span class="c1"># the filtering is done the hard way.</span>
|
||||
|
||||
<span class="n">pkgnames</span> <span class="o">=</span> <span class="p">[</span><span class="n">pkg</span> <span class="k">for</span> <span class="n">pkg</span> <span class="ow">in</span> <span class="n">dnf</span><span class="o">.</span><span class="n">subject</span><span class="o">.</span><span class="n">Subject</span><span class="p">(</span><span class="n">p</span><span class="p">)</span><span class="o">.</span><span class="n">get_best_query</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">dbo</span><span class="o">.</span><span class="n">sack</span><span class="p">)</span><span class="o">.</span><span class="n">filter</span><span class="p">(</span><span class="n">latest</span><span class="o">=</span><span class="kc">True</span><span class="p">)]</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">pkgnames</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="n">dnf</span><span class="o">.</span><span class="n">exceptions</span><span class="o">.</span><span class="n">PackageNotFoundError</span><span class="p">(</span><span class="s2">"no package matched"</span><span class="p">,</span> <span class="n">p</span><span class="p">)</span>
|
||||
|
||||
<span class="c1"># Sort the results so that we have consistent results</span>
|
||||
<span class="n">pkgnames</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">([</span><span class="s2">"</span><span class="si">{}</span><span class="s2">-</span><span class="si">{}</span><span class="s2">-</span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">pkg</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">pkg</span><span class="o">.</span><span class="n">version</span><span class="p">,</span> <span class="n">pkg</span><span class="o">.</span><span class="n">release</span><span class="p">)</span> <span class="k">for</span> <span class="n">pkg</span> <span class="ow">in</span> <span class="n">pkgnames</span><span class="p">])</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">exclude</span> <span class="ow">in</span> <span class="n">excludes</span><span class="p">:</span>
|
||||
<span class="n">pkgnames</span> <span class="o">=</span> <span class="p">[</span><span class="n">pkg</span> <span class="k">for</span> <span class="n">pkg</span> <span class="ow">in</span> <span class="n">pkgnames</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">fnmatch</span><span class="o">.</span><span class="n">fnmatch</span><span class="p">(</span><span class="n">pkg</span><span class="p">,</span> <span class="n">exclude</span><span class="p">)]</span>
|
||||
|
||||
<span class="c1"># If the request is a glob, expand it in the log</span>
|
||||
<span class="k">if</span> <span class="nb">any</span><span class="p">(</span><span class="n">g</span> <span class="k">for</span> <span class="n">g</span> <span class="ow">in</span> <span class="p">[</span><span class="s1">'*'</span><span class="p">,</span><span class="s1">'?'</span><span class="p">,</span><span class="s1">'.'</span><span class="p">]</span> <span class="k">if</span> <span class="n">g</span> <span class="ow">in</span> <span class="n">p</span><span class="p">):</span>
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"installpkg: </span><span class="si">%s</span><span class="s2"> expands to </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">p</span><span class="p">,</span> <span class="s2">","</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">pkgnames</span><span class="p">))</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">pkgname</span> <span class="ow">in</span> <span class="n">pkgnames</span><span class="p">:</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">dbo</span><span class="o">.</span><span class="n">install</span><span class="p">(</span><span class="n">pkgname</span><span class="p">)</span>
|
||||
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span> <span class="c1"># pylint: disable=broad-except</span>
|
||||
<span class="k">if</span> <span class="n">required</span><span class="p">:</span>
|
||||
<span class="k">raise</span>
|
||||
<span class="c1"># Not required, log it and continue processing pkgs</span>
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="s2">"installpkg </span><span class="si">%s</span><span class="s2"> failed: </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">pkgname</span><span class="p">,</span> <span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="p">))</span>
|
||||
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span> <span class="c1"># pylint: disable=broad-except</span>
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="s2">"installpkg </span><span class="si">%s</span><span class="s2"> failed: </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">p</span><span class="p">,</span> <span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="p">))</span>
|
||||
<span class="n">errors</span> <span class="o">=</span> <span class="kc">True</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">errors</span> <span class="ow">and</span> <span class="n">required</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s2">"Required installpkg failed."</span><span class="p">)</span></div>
|
||||
|
||||
<div class="viewcode-block" id="LoraxTemplateRunner.removepkg"><a class="viewcode-back" href="../../pylorax.html#pylorax.ltmpl.LoraxTemplateRunner.removepkg">[docs]</a> <span class="k">def</span> <span class="nf">removepkg</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">pkgs</span><span class="p">):</span>
|
||||
<span class="sd">'''</span>
|
||||
<span class="sd"> removepkg PKGGLOB [PKGGLOB...]</span>
|
||||
<span class="sd"> Delete the named package(s).</span>
|
||||
|
||||
<span class="sd"> IMPLEMENTATION NOTES:</span>
|
||||
<span class="sd"> RPM scriptlets (%preun/%postun) are *not* run.</span>
|
||||
<span class="sd"> Files are deleted, but directories are left behind.</span>
|
||||
@ -789,8 +778,8 @@
|
||||
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">dbo</span><span class="o">.</span><span class="n">transaction</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s2">"No packages in transaction"</span><span class="p">)</span>
|
||||
|
||||
<span class="c1"># If a debug repo has been included, write out a list of debuginfo packages</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_write_debuginfo_log</span><span class="p">()</span>
|
||||
<span class="c1"># Write out the packages installed, including debuginfo packages</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_write_package_log</span><span class="p">()</span>
|
||||
|
||||
<span class="n">pkgs_to_download</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">dbo</span><span class="o">.</span><span class="n">transaction</span><span class="o">.</span><span class="n">install_set</span>
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"Downloading packages"</span><span class="p">)</span>
|
||||
@ -824,6 +813,7 @@
|
||||
<span class="sd"> (or packages) named.</span>
|
||||
<span class="sd"> If '--allbut' is used, all the files from the given package(s) will</span>
|
||||
<span class="sd"> be removed *except* the ones which match the file globs.</span>
|
||||
|
||||
<span class="sd"> Examples:</span>
|
||||
<span class="sd"> removefrom usbutils /usr/bin/*</span>
|
||||
<span class="sd"> removefrom xfsprogs --allbut /sbin/*</span>
|
||||
@ -857,6 +847,7 @@
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">"removefrom </span><span class="si">%s</span><span class="s2">: no files to remove!"</span><span class="p">,</span> <span class="n">cmd</span><span class="p">)</span></div>
|
||||
|
||||
<span class="c1"># pylint: disable=anomalous-backslash-in-string</span>
|
||||
<div class="viewcode-block" id="LoraxTemplateRunner.removekmod"><a class="viewcode-back" href="../../pylorax.html#pylorax.ltmpl.LoraxTemplateRunner.removekmod">[docs]</a> <span class="k">def</span> <span class="nf">removekmod</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">globs</span><span class="p">):</span>
|
||||
<span class="sd">'''</span>
|
||||
<span class="sd"> removekmod GLOB [GLOB...] [--allbut] KEEPGLOB [KEEPGLOB...]</span>
|
||||
@ -868,7 +859,7 @@
|
||||
<span class="sd"> to search and one KEEPGLOB to keep. The KEEPGLOB is expanded to be *KEEPGLOB*</span>
|
||||
<span class="sd"> so that it will match anywhere in the path.</span>
|
||||
|
||||
<span class="sd"> This only removes files from under /lib/modules/*/kernel/</span>
|
||||
<span class="sd"> This only removes files from under /lib/modules/\\*/kernel/</span>
|
||||
|
||||
<span class="sd"> Examples:</span>
|
||||
<span class="sd"> removekmod sound drivers/media drivers/hwmon drivers/video</span>
|
||||
@ -917,6 +908,7 @@
|
||||
<span class="sd">'''</span>
|
||||
<span class="sd"> createaddrsize INITRD_ADDRESS INITRD ADDRSIZE</span>
|
||||
<span class="sd"> Create the initrd.addrsize file required in LPAR boot process.</span>
|
||||
|
||||
<span class="sd"> Examples:</span>
|
||||
<span class="sd"> createaddrsize ${INITRD_ADDRESS} ${outroot}/${BOOTDIR}/initrd.img ${outroot}/${BOOTDIR}/initrd.addrsize</span>
|
||||
<span class="sd"> '''</span>
|
||||
@ -929,6 +921,7 @@
|
||||
<span class="sd">'''</span>
|
||||
<span class="sd"> systemctl [enable|disable|mask] UNIT [UNIT...]</span>
|
||||
<span class="sd"> Enable, disable, or mask the given systemd units.</span>
|
||||
|
||||
<span class="sd"> Examples:</span>
|
||||
<span class="sd"> systemctl disable lvm2-monitor.service</span>
|
||||
<span class="sd"> systemctl mask fedora-storage-init.service fedora-configure.service</span>
|
||||
@ -948,68 +941,51 @@
|
||||
<span class="n">runcmd</span><span class="p">(</span><span class="n">cmd</span><span class="p">)</span>
|
||||
<span class="k">except</span> <span class="n">CalledProcessError</span><span class="p">:</span>
|
||||
<span class="k">pass</span></div></div>
|
||||
</pre></div>
|
||||
|
||||
</div>
|
||||
<div class="articleComments">
|
||||
<div class="viewcode-block" id="LiveTemplateRunner"><a class="viewcode-back" href="../../pylorax.html#pylorax.ltmpl.LiveTemplateRunner">[docs]</a><span class="k">class</span> <span class="nc">LiveTemplateRunner</span><span class="p">(</span><span class="n">TemplateRunner</span><span class="p">,</span> <span class="n">InstallpkgMixin</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> This class parses and executes a limited Lorax template. Sample usage:</span>
|
||||
|
||||
<span class="sd"> # install a bunch of packages</span>
|
||||
<span class="sd"> runner = LiveTemplateRunner(dbo, templatedir, defaults)</span>
|
||||
<span class="sd"> runner.run("live-install.tmpl")</span>
|
||||
|
||||
<span class="sd"> It is meant to be used with the live-install.tmpl which lists the per-arch</span>
|
||||
<span class="sd"> pacages needed to build the live-iso output.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dbo</span><span class="p">,</span> <span class="n">fatalerrors</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">templatedir</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">defaults</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">dbo</span> <span class="o">=</span> <span class="n">dbo</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">pkgs</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">pkgnames</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">LiveTemplateRunner</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">fatalerrors</span><span class="p">,</span> <span class="n">templatedir</span><span class="p">,</span> <span class="n">defaults</span><span class="p">)</span></div>
|
||||
</pre></div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<footer>
|
||||
|
||||
|
||||
<hr/>
|
||||
|
||||
<div role="contentinfo">
|
||||
<p>
|
||||
© Copyright 2015, Red Hat, Inc..
|
||||
|
||||
</p>
|
||||
<p>© Copyright 2018, Red Hat, Inc..</p>
|
||||
</div>
|
||||
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||||
|
||||
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
|
||||
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
|
||||
provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||||
|
||||
|
||||
</footer>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
var DOCUMENTATION_OPTIONS = {
|
||||
URL_ROOT:'../../',
|
||||
VERSION:'28.2',
|
||||
COLLAPSE_INDEX:false,
|
||||
FILE_SUFFIX:'.html',
|
||||
HAS_SOURCE: true,
|
||||
SOURCELINK_SUFFIX: '.txt'
|
||||
};
|
||||
</script>
|
||||
<script type="text/javascript" src="../../_static/jquery.js"></script>
|
||||
<script type="text/javascript" src="../../_static/underscore.js"></script>
|
||||
<script type="text/javascript" src="../../_static/doctools.js"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript" src="../../_static/js/theme.js"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
<script>
|
||||
jQuery(function () {
|
||||
SphinxRtdTheme.StickyNav.enable();
|
||||
SphinxRtdTheme.Navigation.enable(true);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,76 +1,31 @@
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
|
||||
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
|
||||
<html class="writer-html5" lang="en" >
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>pylorax.monitor — Lorax 28.2 documentation</title>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pylorax.monitor — Lorax 36.4 documentation</title>
|
||||
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
|
||||
<link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="index" title="Index"
|
||||
href="../../genindex.html"/>
|
||||
<link rel="search" title="Search" href="../../search.html"/>
|
||||
<link rel="top" title="Lorax 28.2 documentation" href="../../index.html"/>
|
||||
<link rel="up" title="pylorax" href="../pylorax.html"/>
|
||||
|
||||
|
||||
<script src="../../_static/js/modernizr.min.js"></script>
|
||||
|
||||
<script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
|
||||
<script src="../../_static/jquery.js"></script>
|
||||
<script src="../../_static/underscore.js"></script>
|
||||
<script src="../../_static/doctools.js"></script>
|
||||
<script src="../../_static/js/theme.js"></script>
|
||||
<link rel="index" title="Index" href="../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../search.html" />
|
||||
</head>
|
||||
|
||||
<body class="wy-body-for-nav" role="document">
|
||||
|
||||
|
||||
<body class="wy-body-for-nav">
|
||||
<div class="wy-grid-for-nav">
|
||||
|
||||
|
||||
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
|
||||
<div class="wy-side-scroll">
|
||||
<div class="wy-side-nav-search">
|
||||
|
||||
|
||||
|
||||
<div class="wy-side-nav-search" >
|
||||
<a href="../../index.html" class="icon icon-home"> Lorax
|
||||
|
||||
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="version">
|
||||
28.2
|
||||
36.4
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div role="search">
|
||||
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
|
||||
<input type="text" name="q" placeholder="Search docs" />
|
||||
@ -78,84 +33,37 @@
|
||||
<input type="hidden" name="area" value="default" />
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../intro.html">Introduction to Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../intro.html#before-lorax">Before Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../lorax.html">Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../livemedia-creator.html">livemedia-creator</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../mkksiso.html">mkksiso</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../product-images.html">Product and Updates Images</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../modules.html">pylorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../modules.html">src</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
|
||||
|
||||
|
||||
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
|
||||
|
||||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
|
||||
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
||||
<a href="../../index.html">Lorax</a>
|
||||
|
||||
</nav>
|
||||
|
||||
|
||||
|
||||
<div class="wy-nav-content">
|
||||
<div class="rst-content">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div role="navigation" aria-label="breadcrumbs navigation">
|
||||
|
||||
<div role="navigation" aria-label="Page navigation">
|
||||
<ul class="wy-breadcrumbs">
|
||||
|
||||
<li><a href="../../index.html">Docs</a> »</li>
|
||||
|
||||
<li><a href="../../index.html" class="icon icon-home"></a> »</li>
|
||||
<li><a href="../index.html">Module code</a> »</li>
|
||||
|
||||
<li><a href="../pylorax.html">pylorax</a> »</li>
|
||||
|
||||
<li>pylorax.monitor</li>
|
||||
|
||||
|
||||
<li class="wy-breadcrumbs-aside">
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
<hr/>
|
||||
</div>
|
||||
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
|
||||
@ -198,6 +106,27 @@
|
||||
<span class="sd"> for patterns that would indicate that the installation failed.</span>
|
||||
<span class="sd"> self.server.log_error is set True when this happens.</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="n">simple_tests</span> <span class="o">=</span> <span class="p">[</span>
|
||||
<span class="s2">"Traceback ("</span><span class="p">,</span>
|
||||
<span class="s2">"traceback script(s) have been run"</span><span class="p">,</span>
|
||||
<span class="s2">"Out of memory:"</span><span class="p">,</span>
|
||||
<span class="s2">"Call Trace:"</span><span class="p">,</span>
|
||||
<span class="s2">"insufficient disk space:"</span><span class="p">,</span>
|
||||
<span class="s2">"Not enough disk space to download the packages"</span><span class="p">,</span>
|
||||
<span class="s2">"error populating transaction after"</span><span class="p">,</span>
|
||||
<span class="s2">"crashed on signal"</span><span class="p">,</span>
|
||||
<span class="s2">"packaging: Missed: NoSuchPackage"</span><span class="p">,</span>
|
||||
<span class="s2">"packaging: Installation failed"</span><span class="p">,</span>
|
||||
<span class="s2">"The following error occurred while installing. This is a fatal error"</span><span class="p">,</span>
|
||||
<span class="s2">"Error in POSTIN scriptlet in rpm package"</span>
|
||||
<span class="p">]</span>
|
||||
|
||||
<span class="n">re_tests</span> <span class="o">=</span> <span class="p">[</span>
|
||||
<span class="sa">r</span><span class="s2">"packaging: base repo .* not valid"</span><span class="p">,</span>
|
||||
<span class="sa">r</span><span class="s2">"packaging: .* requires .*"</span>
|
||||
<span class="p">]</span>
|
||||
|
||||
<div class="viewcode-block" id="LogRequestHandler.setup"><a class="viewcode-back" href="../../pylorax.html#pylorax.monitor.LogRequestHandler.setup">[docs]</a> <span class="k">def</span> <span class="nf">setup</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""Start writing to self.server.log_path"""</span>
|
||||
|
||||
@ -217,30 +146,25 @@
|
||||
<span class="sd"> Loops until self.server.kill is True</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"Processing logs from </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">client_address</span><span class="p">)</span>
|
||||
<span class="n">line</span> <span class="o">=</span> <span class="s2">""</span>
|
||||
<span class="n">data</span> <span class="o">=</span> <span class="sa">b</span><span class="s2">""</span>
|
||||
<span class="k">while</span> <span class="kc">True</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">server</span><span class="o">.</span><span class="n">kill</span><span class="p">:</span>
|
||||
<span class="k">break</span>
|
||||
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="n">data</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">request</span><span class="o">.</span><span class="n">recv</span><span class="p">(</span><span class="mi">4096</span><span class="p">),</span> <span class="s2">"utf8"</span><span class="p">)</span>
|
||||
<span class="n">data</span> <span class="o">+=</span> <span class="bp">self</span><span class="o">.</span><span class="n">request</span><span class="o">.</span><span class="n">recv</span><span class="p">(</span><span class="mi">4096</span><span class="p">)</span>
|
||||
<span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="n">data</span><span class="o">.</span><span class="n">splitlines</span><span class="p">(</span><span class="n">keepends</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="n">line</span><span class="o">.</span><span class="n">endswith</span><span class="p">(</span><span class="sa">b</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">):</span>
|
||||
<span class="c1"># Ignore invalid UTF8 inside lines</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">iserror</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">line</span><span class="p">[:</span><span class="o">-</span><span class="mi">1</span><span class="p">],</span> <span class="s2">"utf8"</span><span class="p">,</span> <span class="s2">"ignore"</span><span class="p">))</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">fp</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">fp</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">fp</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">line</span><span class="p">,</span> <span class="s2">"utf8"</span><span class="p">,</span> <span class="s2">"ignore"</span><span class="p">))</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">fp</span><span class="o">.</span><span class="n">flush</span><span class="p">()</span>
|
||||
|
||||
<span class="c1"># check the data for errors and set error flag</span>
|
||||
<span class="c1"># need to assemble it into lines so we can test for the error</span>
|
||||
<span class="c1"># string.</span>
|
||||
<span class="k">while</span> <span class="n">data</span><span class="p">:</span>
|
||||
<span class="n">more</span> <span class="o">=</span> <span class="n">data</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
|
||||
<span class="n">line</span> <span class="o">+=</span> <span class="n">more</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
|
||||
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">more</span><span class="p">)</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">iserror</span><span class="p">(</span><span class="n">line</span><span class="p">)</span>
|
||||
<span class="n">line</span> <span class="o">=</span> <span class="s2">""</span>
|
||||
<span class="n">data</span> <span class="o">=</span> <span class="n">more</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
|
||||
<span class="n">data</span> <span class="o">=</span> <span class="sa">b</span><span class="s2">""</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">data</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
|
||||
<span class="c1"># Not the end of the line, keep for later</span>
|
||||
<span class="n">data</span> <span class="o">=</span> <span class="n">line</span>
|
||||
<span class="k">break</span>
|
||||
<span class="k">except</span> <span class="n">socket</span><span class="o">.</span><span class="n">timeout</span><span class="p">:</span>
|
||||
<span class="k">pass</span>
|
||||
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span> <span class="c1"># pylint: disable=broad-except</span>
|
||||
@ -249,7 +173,6 @@
|
||||
|
||||
<div class="viewcode-block" id="LogRequestHandler.finish"><a class="viewcode-back" href="../../pylorax.html#pylorax.monitor.LogRequestHandler.finish">[docs]</a> <span class="k">def</span> <span class="nf">finish</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"Shutting down log processing"</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">request</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">fp</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">fp</span><span class="o">.</span><span class="n">close</span><span class="p">()</span></div>
|
||||
|
||||
@ -263,25 +186,13 @@
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">if</span> <span class="s2">"IGNORED"</span> <span class="ow">in</span> <span class="n">line</span><span class="p">:</span>
|
||||
<span class="k">return</span>
|
||||
<span class="n">simple_tests</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"Traceback ("</span><span class="p">,</span>
|
||||
<span class="s2">"Out of memory:"</span><span class="p">,</span>
|
||||
<span class="s2">"Call Trace:"</span><span class="p">,</span>
|
||||
<span class="s2">"insufficient disk space:"</span><span class="p">,</span>
|
||||
<span class="s2">"Not enough disk space to download the packages"</span><span class="p">,</span>
|
||||
<span class="s2">"error populating transaction after"</span><span class="p">,</span>
|
||||
<span class="s2">"traceback script(s) have been run"</span><span class="p">,</span>
|
||||
<span class="s2">"crashed on signal"</span><span class="p">,</span>
|
||||
<span class="s2">"packaging: Missed: NoSuchPackage"</span><span class="p">,</span>
|
||||
<span class="s2">"packaging: Installation failed"</span><span class="p">,</span>
|
||||
<span class="s2">"The following error occurred while installing. This is a fatal error"</span><span class="p">]</span>
|
||||
<span class="n">re_tests</span> <span class="o">=</span> <span class="p">[</span><span class="sa">r</span><span class="s2">"packaging: base repo .* not valid"</span><span class="p">,</span>
|
||||
<span class="sa">r</span><span class="s2">"packaging: .* requires .*"</span><span class="p">]</span>
|
||||
<span class="k">for</span> <span class="n">t</span> <span class="ow">in</span> <span class="n">simple_tests</span><span class="p">:</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">t</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">simple_tests</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="n">t</span> <span class="ow">in</span> <span class="n">line</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">server</span><span class="o">.</span><span class="n">log_error</span> <span class="o">=</span> <span class="kc">True</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">server</span><span class="o">.</span><span class="n">error_line</span> <span class="o">=</span> <span class="n">line</span>
|
||||
<span class="k">return</span>
|
||||
<span class="k">for</span> <span class="n">t</span> <span class="ow">in</span> <span class="n">re_tests</span><span class="p">:</span>
|
||||
<span class="k">for</span> <span class="n">t</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">re_tests</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="n">re</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">line</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">server</span><span class="o">.</span><span class="n">log_error</span> <span class="o">=</span> <span class="kc">True</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">server</span><span class="o">.</span><span class="n">error_line</span> <span class="o">=</span> <span class="n">line</span>
|
||||
@ -294,7 +205,7 @@
|
||||
<span class="c1"># Number of seconds to wait for a connection after startup</span>
|
||||
<span class="n">timeout</span> <span class="o">=</span> <span class="mi">60</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">log_path</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">log_path</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Setup the log server</span>
|
||||
|
||||
@ -332,7 +243,7 @@
|
||||
<span class="sd"> This needs to be running before the virt-install runs, it expects</span>
|
||||
<span class="sd"> there to be a listener on the port used for the virtio log port.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">log_path</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">host</span><span class="o">=</span><span class="s2">"localhost"</span><span class="p">,</span> <span class="n">port</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">log_path</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">host</span><span class="o">=</span><span class="s2">"localhost"</span><span class="p">,</span> <span class="n">port</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">log_request_handler_class</span><span class="o">=</span><span class="n">LogRequestHandler</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Start a thread to monitor the logs.</span>
|
||||
|
||||
@ -346,7 +257,7 @@
|
||||
<span class="sd"> If log_path isn't set then it only monitors the logs, instead of</span>
|
||||
<span class="sd"> also writing them to disk.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">server</span> <span class="o">=</span> <span class="n">LogServer</span><span class="p">(</span><span class="n">log_path</span><span class="p">,</span> <span class="p">(</span><span class="n">host</span><span class="p">,</span> <span class="n">port</span><span class="p">),</span> <span class="n">LogRequestHandler</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="n">timeout</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">server</span> <span class="o">=</span> <span class="n">LogServer</span><span class="p">(</span><span class="n">log_path</span><span class="p">,</span> <span class="p">(</span><span class="n">host</span><span class="p">,</span> <span class="n">port</span><span class="p">),</span> <span class="n">log_request_handler_class</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="n">timeout</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">host</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">port</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">server</span><span class="o">.</span><span class="n">server_address</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">log_path</span> <span class="o">=</span> <span class="n">log_path</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">server_thread</span> <span class="o">=</span> <span class="n">threading</span><span class="o">.</span><span class="n">Thread</span><span class="p">(</span><span class="n">target</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">server</span><span class="o">.</span><span class="n">handle_request</span><span class="p">)</span>
|
||||
@ -356,69 +267,35 @@
|
||||
<div class="viewcode-block" id="LogMonitor.shutdown"><a class="viewcode-back" href="../../pylorax.html#pylorax.monitor.LogMonitor.shutdown">[docs]</a> <span class="k">def</span> <span class="nf">shutdown</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""Force shutdown of the monitoring thread"""</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">server</span><span class="o">.</span><span class="n">kill</span> <span class="o">=</span> <span class="kc">True</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">server_thread</span><span class="o">.</span><span class="n">join</span><span class="p">()</span></div></div>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">server_thread</span><span class="o">.</span><span class="n">join</span><span class="p">()</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">server</span><span class="o">.</span><span class="n">server_close</span><span class="p">()</span></div></div>
|
||||
</pre></div>
|
||||
|
||||
</div>
|
||||
<div class="articleComments">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<footer>
|
||||
|
||||
|
||||
<hr/>
|
||||
|
||||
<div role="contentinfo">
|
||||
<p>
|
||||
© Copyright 2015, Red Hat, Inc..
|
||||
|
||||
</p>
|
||||
<p>© Copyright 2018, Red Hat, Inc..</p>
|
||||
</div>
|
||||
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||||
|
||||
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
|
||||
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
|
||||
provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||||
|
||||
|
||||
</footer>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
var DOCUMENTATION_OPTIONS = {
|
||||
URL_ROOT:'../../',
|
||||
VERSION:'28.2',
|
||||
COLLAPSE_INDEX:false,
|
||||
FILE_SUFFIX:'.html',
|
||||
HAS_SOURCE: true,
|
||||
SOURCELINK_SUFFIX: '.txt'
|
||||
};
|
||||
</script>
|
||||
<script type="text/javascript" src="../../_static/jquery.js"></script>
|
||||
<script type="text/javascript" src="../../_static/underscore.js"></script>
|
||||
<script type="text/javascript" src="../../_static/doctools.js"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript" src="../../_static/js/theme.js"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
<script>
|
||||
jQuery(function () {
|
||||
SphinxRtdTheme.StickyNav.enable();
|
||||
SphinxRtdTheme.Navigation.enable(true);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,76 +1,31 @@
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
|
||||
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
|
||||
<html class="writer-html5" lang="en" >
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>pylorax.mount — Lorax 28.2 documentation</title>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pylorax.mount — Lorax 36.4 documentation</title>
|
||||
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
|
||||
<link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="index" title="Index"
|
||||
href="../../genindex.html"/>
|
||||
<link rel="search" title="Search" href="../../search.html"/>
|
||||
<link rel="top" title="Lorax 28.2 documentation" href="../../index.html"/>
|
||||
<link rel="up" title="pylorax" href="../pylorax.html"/>
|
||||
|
||||
|
||||
<script src="../../_static/js/modernizr.min.js"></script>
|
||||
|
||||
<script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
|
||||
<script src="../../_static/jquery.js"></script>
|
||||
<script src="../../_static/underscore.js"></script>
|
||||
<script src="../../_static/doctools.js"></script>
|
||||
<script src="../../_static/js/theme.js"></script>
|
||||
<link rel="index" title="Index" href="../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../search.html" />
|
||||
</head>
|
||||
|
||||
<body class="wy-body-for-nav" role="document">
|
||||
|
||||
|
||||
<body class="wy-body-for-nav">
|
||||
<div class="wy-grid-for-nav">
|
||||
|
||||
|
||||
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
|
||||
<div class="wy-side-scroll">
|
||||
<div class="wy-side-nav-search">
|
||||
|
||||
|
||||
|
||||
<div class="wy-side-nav-search" >
|
||||
<a href="../../index.html" class="icon icon-home"> Lorax
|
||||
|
||||
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="version">
|
||||
28.2
|
||||
36.4
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div role="search">
|
||||
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
|
||||
<input type="text" name="q" placeholder="Search docs" />
|
||||
@ -78,84 +33,37 @@
|
||||
<input type="hidden" name="area" value="default" />
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../intro.html">Introduction to Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../intro.html#before-lorax">Before Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../lorax.html">Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../livemedia-creator.html">livemedia-creator</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../mkksiso.html">mkksiso</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../product-images.html">Product and Updates Images</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../modules.html">pylorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../modules.html">src</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
|
||||
|
||||
|
||||
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
|
||||
|
||||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
|
||||
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
||||
<a href="../../index.html">Lorax</a>
|
||||
|
||||
</nav>
|
||||
|
||||
|
||||
|
||||
<div class="wy-nav-content">
|
||||
<div class="rst-content">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div role="navigation" aria-label="breadcrumbs navigation">
|
||||
|
||||
<div role="navigation" aria-label="Page navigation">
|
||||
<ul class="wy-breadcrumbs">
|
||||
|
||||
<li><a href="../../index.html">Docs</a> »</li>
|
||||
|
||||
<li><a href="../../index.html" class="icon icon-home"></a> »</li>
|
||||
<li><a href="../index.html">Module code</a> »</li>
|
||||
|
||||
<li><a href="../pylorax.html">pylorax</a> »</li>
|
||||
|
||||
<li>pylorax.mount</li>
|
||||
|
||||
|
||||
<li class="wy-breadcrumbs-aside">
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
<hr/>
|
||||
</div>
|
||||
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
|
||||
@ -185,9 +93,9 @@
|
||||
<span class="n">log</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="s2">"livemedia-creator"</span><span class="p">)</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">os</span>
|
||||
<span class="kn">import</span> <span class="nn">iso9660</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">pylorax.imgutils</span> <span class="k">import</span> <span class="n">mount</span><span class="p">,</span> <span class="n">umount</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.executils</span> <span class="k">import</span> <span class="n">execWithCapture</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.imgutils</span> <span class="kn">import</span> <span class="n">mount</span><span class="p">,</span> <span class="n">umount</span>
|
||||
|
||||
<div class="viewcode-block" id="IsoMountpoint"><a class="viewcode-back" href="../../pylorax.html#pylorax.mount.IsoMountpoint">[docs]</a><span class="k">class</span> <span class="nc">IsoMountpoint</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
@ -198,7 +106,7 @@
|
||||
|
||||
<span class="sd"> stage2 can be either LiveOS/squashfs.img or images/install.img</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">iso_path</span><span class="p">,</span> <span class="n">initrd_path</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">iso_path</span><span class="p">,</span> <span class="n">initrd_path</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Mount the iso</span>
|
||||
|
||||
@ -222,7 +130,9 @@
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">mount_dir</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">initrd_path</span>
|
||||
|
||||
<span class="n">kernel_list</span> <span class="o">=</span> <span class="p">[(</span><span class="s2">"/isolinux/vmlinuz"</span><span class="p">,</span> <span class="s2">"/isolinux/initrd.img"</span><span class="p">),</span>
|
||||
<span class="p">(</span><span class="s2">"/ppc/ppc64/vmlinuz"</span><span class="p">,</span> <span class="s2">"/ppc/ppc64/initrd.img"</span><span class="p">)]</span>
|
||||
<span class="p">(</span><span class="s2">"/ppc/ppc64/vmlinuz"</span><span class="p">,</span> <span class="s2">"/ppc/ppc64/initrd.img"</span><span class="p">),</span>
|
||||
<span class="p">(</span><span class="s2">"/images/pxeboot/vmlinuz"</span><span class="p">,</span> <span class="s2">"/images/pxeboot/initrd.img"</span><span class="p">),</span>
|
||||
<span class="p">(</span><span class="s2">"/images/kernel.img"</span><span class="p">,</span> <span class="s2">"/images/initrd.img"</span><span class="p">)]</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isdir</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">mount_dir</span><span class="o">+</span><span class="s2">"/repodata"</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">repo</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">mount_dir</span>
|
||||
@ -254,78 +164,48 @@
|
||||
|
||||
<div class="viewcode-block" id="IsoMountpoint.get_iso_label"><a class="viewcode-back" href="../../pylorax.html#pylorax.mount.IsoMountpoint.get_iso_label">[docs]</a> <span class="k">def</span> <span class="nf">get_iso_label</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Get the iso's label using isoinfo</span>
|
||||
<span class="sd"> Get the iso's label using pycdio</span>
|
||||
|
||||
<span class="sd"> Sets self.label if one is found</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">isoinfo_output</span> <span class="o">=</span> <span class="n">execWithCapture</span><span class="p">(</span><span class="s2">"isoinfo"</span><span class="p">,</span> <span class="p">[</span><span class="s2">"-d"</span><span class="p">,</span> <span class="s2">"-i"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">iso_path</span><span class="p">])</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="n">isoinfo_output</span><span class="p">)</span>
|
||||
<span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="n">isoinfo_output</span><span class="o">.</span><span class="n">splitlines</span><span class="p">():</span>
|
||||
<span class="k">if</span> <span class="n">line</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"Volume id: "</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">label</span> <span class="o">=</span> <span class="n">line</span><span class="p">[</span><span class="mi">11</span><span class="p">:]</span>
|
||||
<span class="k">return</span></div></div>
|
||||
</pre></div>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="n">iso</span> <span class="o">=</span> <span class="n">iso9660</span><span class="o">.</span><span class="n">ISO9660</span><span class="o">.</span><span class="n">IFS</span><span class="p">(</span><span class="n">source</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">iso_path</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">iso</span><span class="o">.</span><span class="n">is_open</span><span class="p">():</span>
|
||||
<span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span><span class="s2">"error opening file"</span><span class="p">)</span>
|
||||
|
||||
</div>
|
||||
<div class="articleComments">
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">label</span> <span class="o">=</span> <span class="n">iso</span><span class="o">.</span><span class="n">get_volume_id</span><span class="p">()</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">label</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">label</span> <span class="o">=</span> <span class="s2">""</span>
|
||||
<span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span><span class="s2">"error reading volume id"</span><span class="p">)</span>
|
||||
<span class="k">except</span> <span class="ne">RuntimeError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
|
||||
<span class="n">log</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="s2">"Problem reading label from </span><span class="si">%s</span><span class="s2">: </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">iso_path</span><span class="p">,</span> <span class="n">e</span><span class="p">)</span></div></div>
|
||||
</pre></div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<footer>
|
||||
|
||||
|
||||
<hr/>
|
||||
|
||||
<div role="contentinfo">
|
||||
<p>
|
||||
© Copyright 2015, Red Hat, Inc..
|
||||
|
||||
</p>
|
||||
<p>© Copyright 2018, Red Hat, Inc..</p>
|
||||
</div>
|
||||
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||||
|
||||
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
|
||||
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
|
||||
provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||||
|
||||
|
||||
</footer>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
var DOCUMENTATION_OPTIONS = {
|
||||
URL_ROOT:'../../',
|
||||
VERSION:'28.2',
|
||||
COLLAPSE_INDEX:false,
|
||||
FILE_SUFFIX:'.html',
|
||||
HAS_SOURCE: true,
|
||||
SOURCELINK_SUFFIX: '.txt'
|
||||
};
|
||||
</script>
|
||||
<script type="text/javascript" src="../../_static/jquery.js"></script>
|
||||
<script type="text/javascript" src="../../_static/underscore.js"></script>
|
||||
<script type="text/javascript" src="../../_static/doctools.js"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript" src="../../_static/js/theme.js"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
<script>
|
||||
jQuery(function () {
|
||||
SphinxRtdTheme.StickyNav.enable();
|
||||
SphinxRtdTheme.Navigation.enable(true);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,76 +1,31 @@
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
|
||||
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
|
||||
<html class="writer-html5" lang="en" >
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>pylorax.sysutils — Lorax 28.2 documentation</title>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pylorax.sysutils — Lorax 36.0 documentation</title>
|
||||
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
|
||||
<link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="index" title="Index"
|
||||
href="../../genindex.html"/>
|
||||
<link rel="search" title="Search" href="../../search.html"/>
|
||||
<link rel="top" title="Lorax 28.2 documentation" href="../../index.html"/>
|
||||
<link rel="up" title="pylorax" href="../pylorax.html"/>
|
||||
|
||||
|
||||
<script src="../../_static/js/modernizr.min.js"></script>
|
||||
|
||||
<script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
|
||||
<script src="../../_static/jquery.js"></script>
|
||||
<script src="../../_static/underscore.js"></script>
|
||||
<script src="../../_static/doctools.js"></script>
|
||||
<script src="../../_static/js/theme.js"></script>
|
||||
<link rel="index" title="Index" href="../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../search.html" />
|
||||
</head>
|
||||
|
||||
<body class="wy-body-for-nav" role="document">
|
||||
|
||||
|
||||
<body class="wy-body-for-nav">
|
||||
<div class="wy-grid-for-nav">
|
||||
|
||||
|
||||
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
|
||||
<div class="wy-side-scroll">
|
||||
<div class="wy-side-nav-search">
|
||||
|
||||
|
||||
|
||||
<div class="wy-side-nav-search" >
|
||||
<a href="../../index.html" class="icon icon-home"> Lorax
|
||||
|
||||
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="version">
|
||||
28.2
|
||||
36.0
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div role="search">
|
||||
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
|
||||
<input type="text" name="q" placeholder="Search docs" />
|
||||
@ -78,84 +33,37 @@
|
||||
<input type="hidden" name="area" value="default" />
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../intro.html">Introduction to Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../intro.html#before-lorax">Before Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../lorax.html">Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../livemedia-creator.html">livemedia-creator</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../mkksiso.html">mkksiso</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../product-images.html">Product and Updates Images</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../modules.html">pylorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../modules.html">src</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
|
||||
|
||||
|
||||
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
|
||||
|
||||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
|
||||
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
||||
<a href="../../index.html">Lorax</a>
|
||||
|
||||
</nav>
|
||||
|
||||
|
||||
|
||||
<div class="wy-nav-content">
|
||||
<div class="rst-content">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div role="navigation" aria-label="breadcrumbs navigation">
|
||||
|
||||
<div role="navigation" aria-label="Page navigation">
|
||||
<ul class="wy-breadcrumbs">
|
||||
|
||||
<li><a href="../../index.html">Docs</a> »</li>
|
||||
|
||||
<li><a href="../../index.html" class="icon icon-home"></a> »</li>
|
||||
<li><a href="../index.html">Module code</a> »</li>
|
||||
|
||||
<li><a href="../pylorax.html">pylorax</a> »</li>
|
||||
|
||||
<li>pylorax.sysutils</li>
|
||||
|
||||
|
||||
<li class="wy-breadcrumbs-aside">
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
<hr/>
|
||||
</div>
|
||||
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
|
||||
@ -165,7 +73,7 @@
|
||||
<span></span><span class="c1">#</span>
|
||||
<span class="c1"># sysutils.py</span>
|
||||
<span class="c1">#</span>
|
||||
<span class="c1"># Copyright (C) 2009-2015 Red Hat, Inc.</span>
|
||||
<span class="c1"># Copyright (C) 2009-2019 Red Hat, Inc.</span>
|
||||
<span class="c1">#</span>
|
||||
<span class="c1"># This program is free software; you can redistribute it and/or modify</span>
|
||||
<span class="c1"># it under the terms of the GNU General Public License as published by</span>
|
||||
@ -194,8 +102,10 @@
|
||||
<span class="kn">import</span> <span class="nn">grp</span>
|
||||
<span class="kn">import</span> <span class="nn">glob</span>
|
||||
<span class="kn">import</span> <span class="nn">shutil</span>
|
||||
<span class="kn">import</span> <span class="nn">shlex</span>
|
||||
<span class="kn">from</span> <span class="nn">configparser</span> <span class="kn">import</span> <span class="n">ConfigParser</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">pylorax.executils</span> <span class="k">import</span> <span class="n">runcmd</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.executils</span> <span class="kn">import</span> <span class="n">runcmd</span>
|
||||
|
||||
<div class="viewcode-block" id="joinpaths"><a class="viewcode-back" href="../../pylorax.html#pylorax.sysutils.joinpaths">[docs]</a><span class="k">def</span> <span class="nf">joinpaths</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="n">path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">sep</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">args</span><span class="p">)</span>
|
||||
@ -207,8 +117,8 @@
|
||||
|
||||
|
||||
<div class="viewcode-block" id="touch"><a class="viewcode-back" href="../../pylorax.html#pylorax.sysutils.touch">[docs]</a><span class="k">def</span> <span class="nf">touch</span><span class="p">(</span><span class="n">fname</span><span class="p">):</span>
|
||||
<span class="c1"># python closes the file when it goes out of scope</span>
|
||||
<span class="nb">open</span><span class="p">(</span><span class="n">fname</span><span class="p">,</span> <span class="s2">"w"</span><span class="p">)</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s2">""</span><span class="p">)</span></div>
|
||||
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">fname</span><span class="p">,</span> <span class="s2">"w"</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
|
||||
<span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s2">""</span><span class="p">)</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="replace"><a class="viewcode-back" href="../../pylorax.html#pylorax.sysutils.replace">[docs]</a><span class="k">def</span> <span class="nf">replace</span><span class="p">(</span><span class="n">fname</span><span class="p">,</span> <span class="n">find</span><span class="p">,</span> <span class="n">sub</span><span class="p">):</span>
|
||||
@ -270,68 +180,83 @@
|
||||
|
||||
<div class="viewcode-block" id="linktree"><a class="viewcode-back" href="../../pylorax.html#pylorax.sysutils.linktree">[docs]</a><span class="k">def</span> <span class="nf">linktree</span><span class="p">(</span><span class="n">src</span><span class="p">,</span> <span class="n">dst</span><span class="p">):</span>
|
||||
<span class="n">runcmd</span><span class="p">([</span><span class="s2">"/bin/cp"</span><span class="p">,</span> <span class="s2">"-alx"</span><span class="p">,</span> <span class="n">src</span><span class="p">,</span> <span class="n">dst</span><span class="p">])</span></div>
|
||||
</pre></div>
|
||||
|
||||
</div>
|
||||
<div class="articleComments">
|
||||
<span class="k">def</span> <span class="nf">unquote</span><span class="p">(</span><span class="n">s</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="s1">' '</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">shlex</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="n">s</span><span class="p">))</span>
|
||||
|
||||
<span class="k">class</span> <span class="nc">UnquotingConfigParser</span><span class="p">(</span><span class="n">ConfigParser</span><span class="p">):</span>
|
||||
<span class="sd">"""A ConfigParser, only with unquoting of the values."""</span>
|
||||
<span class="c1"># pylint: disable=arguments-differ</span>
|
||||
<span class="k">def</span> <span class="nf">get</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="n">ret</span> <span class="o">=</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">ret</span><span class="p">:</span>
|
||||
<span class="n">ret</span> <span class="o">=</span> <span class="n">unquote</span><span class="p">(</span><span class="n">ret</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">ret</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">flatconfig</span><span class="p">(</span><span class="n">filename</span><span class="p">):</span>
|
||||
<span class="sd">"""Use UnquotingConfigParser to read a flat config file (without</span>
|
||||
<span class="sd"> section headers) by adding a section header.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">with</span> <span class="nb">open</span> <span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="s1">'r'</span><span class="p">)</span> <span class="k">as</span> <span class="n">conffh</span><span class="p">:</span>
|
||||
<span class="n">conftext</span> <span class="o">=</span> <span class="s2">"[main]</span><span class="se">\n</span><span class="s2">"</span> <span class="o">+</span> <span class="n">conffh</span><span class="o">.</span><span class="n">read</span><span class="p">()</span>
|
||||
<span class="n">config</span> <span class="o">=</span> <span class="n">UnquotingConfigParser</span><span class="p">()</span>
|
||||
<span class="n">config</span><span class="o">.</span><span class="n">read_string</span><span class="p">(</span><span class="n">conftext</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">config</span><span class="p">[</span><span class="s1">'main'</span><span class="p">]</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">read_tail</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="n">size</span><span class="p">):</span>
|
||||
<span class="sd">"""Read up to `size` kibibytes from the end of a file"""</span>
|
||||
|
||||
<span class="c1"># NOTE: In py3 text files are unicode, not bytes so we have to open it as bytes</span>
|
||||
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="s2">"rb"</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">_read_file_end</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">size</span><span class="p">)</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_read_file_end</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">size</span><span class="p">):</span>
|
||||
<span class="sd">"""Read the end of a file</span>
|
||||
|
||||
<span class="sd"> This skips to the next line to avoid starting in the middle of a unicode character.</span>
|
||||
<span class="sd"> And returns "" in the case of a UnicodeDecodeError</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">f</span><span class="o">.</span><span class="n">seek</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
|
||||
<span class="n">end</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">tell</span><span class="p">()</span>
|
||||
<span class="k">if</span> <span class="n">end</span> <span class="o"><</span> <span class="mi">1024</span> <span class="o">*</span> <span class="n">size</span><span class="p">:</span>
|
||||
<span class="n">f</span><span class="o">.</span><span class="n">seek</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">f</span><span class="o">.</span><span class="n">seek</span><span class="p">(</span><span class="n">end</span> <span class="o">-</span> <span class="p">(</span><span class="mi">1024</span> <span class="o">*</span> <span class="n">size</span><span class="p">))</span>
|
||||
<span class="n">data</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">read</span><span class="p">()</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="c1"># Find the first newline in the block</span>
|
||||
<span class="n">newline</span> <span class="o">=</span> <span class="nb">min</span><span class="p">(</span><span class="mi">1</span><span class="o">+</span><span class="n">data</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="sa">b</span><span class="s1">'</span><span class="se">\n</span><span class="s1">'</span><span class="p">),</span> <span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">))</span>
|
||||
<span class="n">text</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="n">newline</span><span class="p">:]</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span><span class="s2">"UTF-8"</span><span class="p">)</span>
|
||||
<span class="k">except</span> <span class="ne">UnicodeDecodeError</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="s2">""</span>
|
||||
<span class="k">return</span> <span class="n">text</span>
|
||||
</pre></div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<footer>
|
||||
|
||||
|
||||
<hr/>
|
||||
|
||||
<div role="contentinfo">
|
||||
<p>
|
||||
© Copyright 2015, Red Hat, Inc..
|
||||
|
||||
</p>
|
||||
<p>© Copyright 2018, Red Hat, Inc..</p>
|
||||
</div>
|
||||
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||||
|
||||
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
|
||||
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
|
||||
provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||||
|
||||
|
||||
</footer>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
var DOCUMENTATION_OPTIONS = {
|
||||
URL_ROOT:'../../',
|
||||
VERSION:'28.2',
|
||||
COLLAPSE_INDEX:false,
|
||||
FILE_SUFFIX:'.html',
|
||||
HAS_SOURCE: true,
|
||||
SOURCELINK_SUFFIX: '.txt'
|
||||
};
|
||||
</script>
|
||||
<script type="text/javascript" src="../../_static/jquery.js"></script>
|
||||
<script type="text/javascript" src="../../_static/underscore.js"></script>
|
||||
<script type="text/javascript" src="../../_static/doctools.js"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript" src="../../_static/js/theme.js"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
<script>
|
||||
jQuery(function () {
|
||||
SphinxRtdTheme.StickyNav.enable();
|
||||
SphinxRtdTheme.Navigation.enable(true);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,76 +1,31 @@
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
|
||||
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
|
||||
<html class="writer-html5" lang="en" >
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>pylorax.treebuilder — Lorax 28.2 documentation</title>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pylorax.treebuilder — Lorax 36.0 documentation</title>
|
||||
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
|
||||
<link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="index" title="Index"
|
||||
href="../../genindex.html"/>
|
||||
<link rel="search" title="Search" href="../../search.html"/>
|
||||
<link rel="top" title="Lorax 28.2 documentation" href="../../index.html"/>
|
||||
<link rel="up" title="pylorax" href="../pylorax.html"/>
|
||||
|
||||
|
||||
<script src="../../_static/js/modernizr.min.js"></script>
|
||||
|
||||
<script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
|
||||
<script src="../../_static/jquery.js"></script>
|
||||
<script src="../../_static/underscore.js"></script>
|
||||
<script src="../../_static/doctools.js"></script>
|
||||
<script src="../../_static/js/theme.js"></script>
|
||||
<link rel="index" title="Index" href="../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../search.html" />
|
||||
</head>
|
||||
|
||||
<body class="wy-body-for-nav" role="document">
|
||||
|
||||
|
||||
<body class="wy-body-for-nav">
|
||||
<div class="wy-grid-for-nav">
|
||||
|
||||
|
||||
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
|
||||
<div class="wy-side-scroll">
|
||||
<div class="wy-side-nav-search">
|
||||
|
||||
|
||||
|
||||
<div class="wy-side-nav-search" >
|
||||
<a href="../../index.html" class="icon icon-home"> Lorax
|
||||
|
||||
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="version">
|
||||
28.2
|
||||
36.0
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div role="search">
|
||||
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
|
||||
<input type="text" name="q" placeholder="Search docs" />
|
||||
@ -78,84 +33,37 @@
|
||||
<input type="hidden" name="area" value="default" />
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../intro.html">Introduction to Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../intro.html#before-lorax">Before Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../lorax.html">Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../livemedia-creator.html">livemedia-creator</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../mkksiso.html">mkksiso</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../product-images.html">Product and Updates Images</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../modules.html">pylorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../modules.html">src</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
|
||||
|
||||
|
||||
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
|
||||
|
||||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
|
||||
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
||||
<a href="../../index.html">Lorax</a>
|
||||
|
||||
</nav>
|
||||
|
||||
|
||||
|
||||
<div class="wy-nav-content">
|
||||
<div class="rst-content">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div role="navigation" aria-label="breadcrumbs navigation">
|
||||
|
||||
<div role="navigation" aria-label="Page navigation">
|
||||
<ul class="wy-breadcrumbs">
|
||||
|
||||
<li><a href="../../index.html">Docs</a> »</li>
|
||||
|
||||
<li><a href="../../index.html" class="icon icon-home"></a> »</li>
|
||||
<li><a href="../index.html">Module code</a> »</li>
|
||||
|
||||
<li><a href="../pylorax.html">pylorax</a> »</li>
|
||||
|
||||
<li>pylorax.treebuilder</li>
|
||||
|
||||
|
||||
<li class="wy-breadcrumbs-aside">
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
<hr/>
|
||||
</div>
|
||||
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
|
||||
@ -185,22 +93,22 @@
|
||||
<span class="n">logger</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="s2">"pylorax.treebuilder"</span><span class="p">)</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">os</span><span class="o">,</span> <span class="nn">re</span>
|
||||
<span class="kn">from</span> <span class="nn">os.path</span> <span class="k">import</span> <span class="n">basename</span>
|
||||
<span class="kn">from</span> <span class="nn">shutil</span> <span class="k">import</span> <span class="n">copytree</span><span class="p">,</span> <span class="n">copy2</span>
|
||||
<span class="kn">from</span> <span class="nn">pathlib</span> <span class="k">import</span> <span class="n">Path</span>
|
||||
<span class="kn">from</span> <span class="nn">os.path</span> <span class="kn">import</span> <span class="n">basename</span>
|
||||
<span class="kn">from</span> <span class="nn">shutil</span> <span class="kn">import</span> <span class="n">copytree</span><span class="p">,</span> <span class="n">copy2</span>
|
||||
<span class="kn">from</span> <span class="nn">subprocess</span> <span class="kn">import</span> <span class="n">CalledProcessError</span>
|
||||
<span class="kn">from</span> <span class="nn">pathlib</span> <span class="kn">import</span> <span class="n">Path</span>
|
||||
<span class="kn">import</span> <span class="nn">itertools</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">pylorax.sysutils</span> <span class="k">import</span> <span class="n">joinpaths</span><span class="p">,</span> <span class="n">remove</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.base</span> <span class="k">import</span> <span class="n">DataHolder</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.ltmpl</span> <span class="k">import</span> <span class="n">LoraxTemplateRunner</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.sysutils</span> <span class="kn">import</span> <span class="n">joinpaths</span><span class="p">,</span> <span class="n">remove</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.base</span> <span class="kn">import</span> <span class="n">DataHolder</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.ltmpl</span> <span class="kn">import</span> <span class="n">LoraxTemplateRunner</span>
|
||||
<span class="kn">import</span> <span class="nn">pylorax.imgutils</span> <span class="k">as</span> <span class="nn">imgutils</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.executils</span> <span class="k">import</span> <span class="n">runcmd</span><span class="p">,</span> <span class="n">runcmd_output</span><span class="p">,</span> <span class="n">execWithCapture</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.imgutils</span> <span class="kn">import</span> <span class="n">DracutChroot</span>
|
||||
<span class="kn">from</span> <span class="nn">pylorax.executils</span> <span class="kn">import</span> <span class="n">runcmd</span><span class="p">,</span> <span class="n">runcmd_output</span><span class="p">,</span> <span class="n">execWithCapture</span>
|
||||
|
||||
<span class="n">templatemap</span> <span class="o">=</span> <span class="p">{</span>
|
||||
<span class="s1">'i386'</span><span class="p">:</span> <span class="s1">'x86.tmpl'</span><span class="p">,</span>
|
||||
<span class="s1">'x86_64'</span><span class="p">:</span> <span class="s1">'x86.tmpl'</span><span class="p">,</span>
|
||||
<span class="s1">'ppc'</span><span class="p">:</span> <span class="s1">'ppc.tmpl'</span><span class="p">,</span>
|
||||
<span class="s1">'ppc64'</span><span class="p">:</span> <span class="s1">'ppc.tmpl'</span><span class="p">,</span>
|
||||
<span class="s1">'ppc64le'</span><span class="p">:</span> <span class="s1">'ppc64le.tmpl'</span><span class="p">,</span>
|
||||
<span class="s1">'s390'</span><span class="p">:</span> <span class="s1">'s390.tmpl'</span><span class="p">,</span>
|
||||
<span class="s1">'s390x'</span><span class="p">:</span> <span class="s1">'s390.tmpl'</span><span class="p">,</span>
|
||||
@ -233,16 +141,12 @@
|
||||
|
||||
<div class="viewcode-block" id="RuntimeBuilder"><a class="viewcode-back" href="../../pylorax.html#pylorax.treebuilder.RuntimeBuilder">[docs]</a><span class="k">class</span> <span class="nc">RuntimeBuilder</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
|
||||
<span class="sd">'''Builds the anaconda runtime image.'''</span>
|
||||
<span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">product</span><span class="p">,</span> <span class="n">arch</span><span class="p">,</span> <span class="n">dbo</span><span class="p">,</span> <span class="n">templatedir</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">product</span><span class="p">,</span> <span class="n">arch</span><span class="p">,</span> <span class="n">dbo</span><span class="p">,</span> <span class="n">templatedir</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
|
||||
<span class="n">installpkgs</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">excludepkgs</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
|
||||
<span class="n">add_templates</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
|
||||
<span class="n">add_template_vars</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
<span class="n">add_template_vars</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
|
||||
<span class="n">skip_branding</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
|
||||
<span class="n">root</span> <span class="o">=</span> <span class="n">dbo</span><span class="o">.</span><span class="n">conf</span><span class="o">.</span><span class="n">installroot</span>
|
||||
<span class="c1"># use a copy of product so we can modify it locally</span>
|
||||
<span class="n">product</span> <span class="o">=</span> <span class="n">product</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span>
|
||||
<span class="n">product</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="n">product</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">vars</span> <span class="o">=</span> <span class="n">DataHolder</span><span class="p">(</span><span class="n">arch</span><span class="o">=</span><span class="n">arch</span><span class="p">,</span> <span class="n">product</span><span class="o">=</span><span class="n">product</span><span class="p">,</span> <span class="n">dbo</span><span class="o">=</span><span class="n">dbo</span><span class="p">,</span> <span class="n">root</span><span class="o">=</span><span class="n">root</span><span class="p">,</span>
|
||||
<span class="n">basearch</span><span class="o">=</span><span class="n">arch</span><span class="o">.</span><span class="n">basearch</span><span class="p">,</span> <span class="n">libdir</span><span class="o">=</span><span class="n">arch</span><span class="o">.</span><span class="n">libdir</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">dbo</span> <span class="o">=</span> <span class="n">dbo</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_runner</span> <span class="o">=</span> <span class="n">LoraxTemplateRunner</span><span class="p">(</span><span class="n">inroot</span><span class="o">=</span><span class="n">root</span><span class="p">,</span> <span class="n">outroot</span><span class="o">=</span><span class="n">root</span><span class="p">,</span>
|
||||
<span class="n">dbo</span><span class="o">=</span><span class="n">dbo</span><span class="p">,</span> <span class="n">templatedir</span><span class="o">=</span><span class="n">templatedir</span><span class="p">)</span>
|
||||
@ -250,40 +154,68 @@
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">add_template_vars</span> <span class="o">=</span> <span class="n">add_template_vars</span> <span class="ow">or</span> <span class="p">{}</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_installpkgs</span> <span class="o">=</span> <span class="n">installpkgs</span> <span class="ow">or</span> <span class="p">[]</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_excludepkgs</span> <span class="o">=</span> <span class="n">excludepkgs</span> <span class="ow">or</span> <span class="p">[]</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_runner</span><span class="o">.</span><span class="n">defaults</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">vars</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">dbo</span><span class="o">.</span><span class="n">reset</span><span class="p">()</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_install_branding</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="c1"># use a copy of product so we can modify it locally</span>
|
||||
<span class="n">product</span> <span class="o">=</span> <span class="n">product</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span>
|
||||
<span class="n">product</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="n">product</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_branding</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_branding</span><span class="p">(</span><span class="n">skip_branding</span><span class="p">,</span> <span class="n">product</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">vars</span> <span class="o">=</span> <span class="n">DataHolder</span><span class="p">(</span><span class="n">arch</span><span class="o">=</span><span class="n">arch</span><span class="p">,</span> <span class="n">product</span><span class="o">=</span><span class="n">product</span><span class="p">,</span> <span class="n">dbo</span><span class="o">=</span><span class="n">dbo</span><span class="p">,</span> <span class="n">root</span><span class="o">=</span><span class="n">root</span><span class="p">,</span>
|
||||
<span class="n">basearch</span><span class="o">=</span><span class="n">arch</span><span class="o">.</span><span class="n">basearch</span><span class="p">,</span> <span class="n">libdir</span><span class="o">=</span><span class="n">arch</span><span class="o">.</span><span class="n">libdir</span><span class="p">,</span>
|
||||
<span class="n">branding</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_branding</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_runner</span><span class="o">.</span><span class="n">defaults</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">vars</span>
|
||||
|
||||
<div class="viewcode-block" id="RuntimeBuilder.get_branding"><a class="viewcode-back" href="../../pylorax.html#pylorax.treebuilder.RuntimeBuilder.get_branding">[docs]</a> <span class="k">def</span> <span class="nf">get_branding</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">skip</span><span class="p">,</span> <span class="n">product</span><span class="p">):</span>
|
||||
<span class="sd">"""Select the branding from the available 'system-release' packages</span>
|
||||
<span class="sd"> The *best* way to control this is to have a single package in the repo provide 'system-release'</span>
|
||||
<span class="sd"> When there are more than 1 package it will:</span>
|
||||
<span class="sd"> - Make a list of the available packages</span>
|
||||
<span class="sd"> - If variant is set look for a package ending with lower(variant) and use that</span>
|
||||
<span class="sd"> - If there are one or more non-generic packages, use the first one after sorting</span>
|
||||
|
||||
<span class="sd"> Returns the package names of the system-release and release logos package</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">if</span> <span class="n">skip</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">DataHolder</span><span class="p">(</span><span class="n">release</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">logos</span><span class="o">=</span><span class="kc">None</span><span class="p">)</span>
|
||||
|
||||
<span class="n">release</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
<span class="n">q</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">dbo</span><span class="o">.</span><span class="n">sack</span><span class="o">.</span><span class="n">query</span><span class="p">()</span>
|
||||
<span class="n">a</span> <span class="o">=</span> <span class="n">q</span><span class="o">.</span><span class="n">available</span><span class="p">()</span>
|
||||
<span class="k">for</span> <span class="n">pkg</span> <span class="ow">in</span> <span class="n">a</span><span class="o">.</span><span class="n">filter</span><span class="p">(</span><span class="n">provides</span><span class="o">=</span><span class="s1">'/etc/system-release'</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="n">pkg</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s1">'generic'</span><span class="p">):</span>
|
||||
<span class="k">continue</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">release</span> <span class="o">=</span> <span class="n">pkg</span><span class="o">.</span><span class="n">name</span>
|
||||
<span class="k">break</span>
|
||||
<span class="n">pkgs</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">([</span><span class="n">p</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">a</span><span class="o">.</span><span class="n">filter</span><span class="p">(</span><span class="n">provides</span><span class="o">=</span><span class="s1">'system-release'</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">p</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">"generic"</span><span class="p">)])</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">pkgs</span><span class="p">:</span>
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="s2">"No system-release packages found, could not get the release"</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">DataHolder</span><span class="p">(</span><span class="n">release</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">logos</span><span class="o">=</span><span class="kc">None</span><span class="p">)</span>
|
||||
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">"system-release packages: </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">pkgs</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">product</span><span class="o">.</span><span class="n">variant</span><span class="p">:</span>
|
||||
<span class="n">variant</span> <span class="o">=</span> <span class="p">[</span><span class="n">p</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">pkgs</span> <span class="k">if</span> <span class="n">p</span><span class="o">.</span><span class="n">endswith</span><span class="p">(</span><span class="s2">"-"</span><span class="o">+</span><span class="n">product</span><span class="o">.</span><span class="n">variant</span><span class="o">.</span><span class="n">lower</span><span class="p">())]</span>
|
||||
<span class="k">if</span> <span class="n">variant</span><span class="p">:</span>
|
||||
<span class="n">release</span> <span class="o">=</span> <span class="n">variant</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">release</span><span class="p">:</span>
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="s1">'could not get the release'</span><span class="p">)</span>
|
||||
<span class="k">return</span>
|
||||
<span class="n">release</span> <span class="o">=</span> <span class="n">pkgs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
|
||||
|
||||
<span class="c1"># release</span>
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s1">'got release: </span><span class="si">%s</span><span class="s1">'</span><span class="p">,</span> <span class="n">release</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_runner</span><span class="o">.</span><span class="n">installpkg</span><span class="p">(</span><span class="n">release</span><span class="p">)</span>
|
||||
|
||||
<span class="c1"># logos</span>
|
||||
<span class="n">release</span><span class="p">,</span> <span class="n">_suffix</span> <span class="o">=</span> <span class="n">release</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">'-'</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_runner</span><span class="o">.</span><span class="n">installpkg</span><span class="p">(</span><span class="s1">'</span><span class="si">%s</span><span class="s1">-logos'</span> <span class="o">%</span> <span class="n">release</span><span class="p">)</span>
|
||||
<span class="c1"># logos uses the basename from release (fedora, redhat, centos, ...)</span>
|
||||
<span class="n">logos</span><span class="p">,</span> <span class="n">_suffix</span> <span class="o">=</span> <span class="n">release</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">'-'</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">DataHolder</span><span class="p">(</span><span class="n">release</span><span class="o">=</span><span class="n">release</span><span class="p">,</span> <span class="n">logos</span><span class="o">=</span><span class="n">logos</span><span class="o">+</span><span class="s2">"-logos"</span><span class="p">)</span></div>
|
||||
|
||||
<div class="viewcode-block" id="RuntimeBuilder.install"><a class="viewcode-back" href="../../pylorax.html#pylorax.treebuilder.RuntimeBuilder.install">[docs]</a> <span class="k">def</span> <span class="nf">install</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">'''Install packages and do initial setup with runtime-install.tmpl'''</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_install_branding</span><span class="p">()</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_branding</span><span class="o">.</span><span class="n">release</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_runner</span><span class="o">.</span><span class="n">installpkg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_branding</span><span class="o">.</span><span class="n">release</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_branding</span><span class="o">.</span><span class="n">logos</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_runner</span><span class="o">.</span><span class="n">installpkg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_branding</span><span class="o">.</span><span class="n">logos</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_installpkgs</span><span class="p">)</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_runner</span><span class="o">.</span><span class="n">installpkg</span><span class="p">(</span><span class="o">*</span><span class="bp">self</span><span class="o">.</span><span class="n">_installpkgs</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_excludepkgs</span><span class="p">)</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_runner</span><span class="o">.</span><span class="n">removepkg</span><span class="p">(</span><span class="o">*</span><span class="bp">self</span><span class="o">.</span><span class="n">_excludepkgs</span><span class="p">)</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_runner</span><span class="o">.</span><span class="n">run</span><span class="p">(</span><span class="s2">"runtime-install.tmpl"</span><span class="p">)</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">tmpl</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">add_templates</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_runner</span><span class="o">.</span><span class="n">run</span><span class="p">(</span><span class="n">tmpl</span><span class="p">,</span> <span class="o">**</span><span class="bp">self</span><span class="o">.</span><span class="n">add_template_vars</span><span class="p">)</span></div>
|
||||
|
||||
@ -372,24 +304,40 @@
|
||||
<div class="viewcode-block" id="RuntimeBuilder.generate_module_data"><a class="viewcode-back" href="../../pylorax.html#pylorax.treebuilder.RuntimeBuilder.generate_module_data">[docs]</a> <span class="k">def</span> <span class="nf">generate_module_data</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="n">root</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">vars</span><span class="o">.</span><span class="n">root</span>
|
||||
<span class="n">moddir</span> <span class="o">=</span> <span class="n">joinpaths</span><span class="p">(</span><span class="n">root</span><span class="p">,</span> <span class="s2">"lib/modules/"</span><span class="p">)</span>
|
||||
<span class="k">for</span> <span class="n">kver</span> <span class="ow">in</span> <span class="n">os</span><span class="o">.</span><span class="n">listdir</span><span class="p">(</span><span class="n">moddir</span><span class="p">):</span>
|
||||
<span class="n">ksyms</span> <span class="o">=</span> <span class="n">joinpaths</span><span class="p">(</span><span class="n">root</span><span class="p">,</span> <span class="s2">"boot/System.map-</span><span class="si">%s</span><span class="s2">"</span> <span class="o">%</span> <span class="n">kver</span><span class="p">)</span>
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"doing depmod and module-info for </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">kver</span><span class="p">)</span>
|
||||
<span class="n">runcmd</span><span class="p">([</span><span class="s2">"depmod"</span><span class="p">,</span> <span class="s2">"-a"</span><span class="p">,</span> <span class="s2">"-F"</span><span class="p">,</span> <span class="n">ksyms</span><span class="p">,</span> <span class="s2">"-b"</span><span class="p">,</span> <span class="n">root</span><span class="p">,</span> <span class="n">kver</span><span class="p">])</span>
|
||||
<span class="n">generate_module_info</span><span class="p">(</span><span class="n">moddir</span><span class="o">+</span><span class="n">kver</span><span class="p">,</span> <span class="n">outfile</span><span class="o">=</span><span class="n">moddir</span><span class="o">+</span><span class="s2">"module-info"</span><span class="p">)</span></div>
|
||||
<span class="k">for</span> <span class="n">kernel</span> <span class="ow">in</span> <span class="n">findkernels</span><span class="p">(</span><span class="n">root</span><span class="o">=</span><span class="n">root</span><span class="p">):</span>
|
||||
<span class="n">ksyms</span> <span class="o">=</span> <span class="n">joinpaths</span><span class="p">(</span><span class="n">root</span><span class="p">,</span> <span class="s2">"boot/System.map-</span><span class="si">%s</span><span class="s2">"</span> <span class="o">%</span> <span class="n">kernel</span><span class="o">.</span><span class="n">version</span><span class="p">)</span>
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"doing depmod and module-info for </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">kernel</span><span class="o">.</span><span class="n">version</span><span class="p">)</span>
|
||||
<span class="n">runcmd</span><span class="p">([</span><span class="s2">"depmod"</span><span class="p">,</span> <span class="s2">"-a"</span><span class="p">,</span> <span class="s2">"-F"</span><span class="p">,</span> <span class="n">ksyms</span><span class="p">,</span> <span class="s2">"-b"</span><span class="p">,</span> <span class="n">root</span><span class="p">,</span> <span class="n">kernel</span><span class="o">.</span><span class="n">version</span><span class="p">])</span>
|
||||
<span class="n">generate_module_info</span><span class="p">(</span><span class="n">moddir</span><span class="o">+</span><span class="n">kernel</span><span class="o">.</span><span class="n">version</span><span class="p">,</span> <span class="n">outfile</span><span class="o">=</span><span class="n">moddir</span><span class="o">+</span><span class="s2">"module-info"</span><span class="p">)</span></div>
|
||||
|
||||
<div class="viewcode-block" id="RuntimeBuilder.create_runtime"><a class="viewcode-back" href="../../pylorax.html#pylorax.treebuilder.RuntimeBuilder.create_runtime">[docs]</a> <span class="k">def</span> <span class="nf">create_runtime</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">outfile</span><span class="o">=</span><span class="s2">"/var/tmp/squashfs.img"</span><span class="p">,</span> <span class="n">compression</span><span class="o">=</span><span class="s2">"xz"</span><span class="p">,</span> <span class="n">compressargs</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="mi">2</span><span class="p">):</span>
|
||||
<div class="viewcode-block" id="RuntimeBuilder.create_squashfs_runtime"><a class="viewcode-back" href="../../pylorax.html#pylorax.treebuilder.RuntimeBuilder.create_squashfs_runtime">[docs]</a> <span class="k">def</span> <span class="nf">create_squashfs_runtime</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">outfile</span><span class="o">=</span><span class="s2">"/var/tmp/squashfs.img"</span><span class="p">,</span> <span class="n">compression</span><span class="o">=</span><span class="s2">"xz"</span><span class="p">,</span> <span class="n">compressargs</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="mi">2</span><span class="p">):</span>
|
||||
<span class="sd">"""Create a plain squashfs runtime"""</span>
|
||||
<span class="n">compressargs</span> <span class="o">=</span> <span class="n">compressargs</span> <span class="ow">or</span> <span class="p">[]</span>
|
||||
<span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">dirname</span><span class="p">(</span><span class="n">outfile</span><span class="p">))</span>
|
||||
|
||||
<span class="c1"># squash the rootfs</span>
|
||||
<span class="k">return</span> <span class="n">imgutils</span><span class="o">.</span><span class="n">mksquashfs</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">vars</span><span class="o">.</span><span class="n">root</span><span class="p">,</span> <span class="n">outfile</span><span class="p">,</span> <span class="n">compression</span><span class="p">,</span> <span class="n">compressargs</span><span class="p">)</span></div>
|
||||
|
||||
<div class="viewcode-block" id="RuntimeBuilder.create_ext4_runtime"><a class="viewcode-back" href="../../pylorax.html#pylorax.treebuilder.RuntimeBuilder.create_ext4_runtime">[docs]</a> <span class="k">def</span> <span class="nf">create_ext4_runtime</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">outfile</span><span class="o">=</span><span class="s2">"/var/tmp/squashfs.img"</span><span class="p">,</span> <span class="n">compression</span><span class="o">=</span><span class="s2">"xz"</span><span class="p">,</span> <span class="n">compressargs</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="mi">2</span><span class="p">):</span>
|
||||
<span class="sd">"""Create a squashfs compressed ext4 runtime"""</span>
|
||||
<span class="c1"># make live rootfs image - must be named "LiveOS/rootfs.img" for dracut</span>
|
||||
<span class="n">compressargs</span> <span class="o">=</span> <span class="n">compressargs</span> <span class="ow">or</span> <span class="p">[]</span>
|
||||
<span class="n">workdir</span> <span class="o">=</span> <span class="n">joinpaths</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">dirname</span><span class="p">(</span><span class="n">outfile</span><span class="p">),</span> <span class="s2">"runtime-workdir"</span><span class="p">)</span>
|
||||
<span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span><span class="n">joinpaths</span><span class="p">(</span><span class="n">workdir</span><span class="p">,</span> <span class="s2">"LiveOS"</span><span class="p">))</span>
|
||||
|
||||
<span class="c1"># Catch problems with the rootfs being too small and clearly log them</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="n">imgutils</span><span class="o">.</span><span class="n">mkrootfsimg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">vars</span><span class="o">.</span><span class="n">root</span><span class="p">,</span> <span class="n">joinpaths</span><span class="p">(</span><span class="n">workdir</span><span class="p">,</span> <span class="s2">"LiveOS/rootfs.img"</span><span class="p">),</span>
|
||||
<span class="s2">"Anaconda"</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="n">size</span><span class="p">)</span>
|
||||
<span class="k">except</span> <span class="n">CalledProcessError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="n">e</span><span class="o">.</span><span class="n">stdout</span> <span class="ow">and</span> <span class="s2">"No space left on device"</span> <span class="ow">in</span> <span class="n">e</span><span class="o">.</span><span class="n">stdout</span><span class="p">:</span>
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="s2">"The rootfs ran out of space with size=</span><span class="si">%d</span><span class="s2">"</span><span class="p">,</span> <span class="n">size</span><span class="p">)</span>
|
||||
<span class="k">raise</span>
|
||||
|
||||
<span class="c1"># squash the live rootfs and clean up workdir</span>
|
||||
<span class="n">imgutils</span><span class="o">.</span><span class="n">mksquashfs</span><span class="p">(</span><span class="n">workdir</span><span class="p">,</span> <span class="n">outfile</span><span class="p">,</span> <span class="n">compression</span><span class="p">,</span> <span class="n">compressargs</span><span class="p">)</span>
|
||||
<span class="n">remove</span><span class="p">(</span><span class="n">workdir</span><span class="p">)</span></div>
|
||||
<span class="n">rc</span> <span class="o">=</span> <span class="n">imgutils</span><span class="o">.</span><span class="n">mksquashfs</span><span class="p">(</span><span class="n">workdir</span><span class="p">,</span> <span class="n">outfile</span><span class="p">,</span> <span class="n">compression</span><span class="p">,</span> <span class="n">compressargs</span><span class="p">)</span>
|
||||
<span class="n">remove</span><span class="p">(</span><span class="n">workdir</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">rc</span></div>
|
||||
|
||||
<div class="viewcode-block" id="RuntimeBuilder.finished"><a class="viewcode-back" href="../../pylorax.html#pylorax.treebuilder.RuntimeBuilder.finished">[docs]</a> <span class="k">def</span> <span class="nf">finished</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">""" Done using RuntimeBuilder</span>
|
||||
@ -401,7 +349,8 @@
|
||||
<div class="viewcode-block" id="TreeBuilder"><a class="viewcode-back" href="../../pylorax.html#pylorax.treebuilder.TreeBuilder">[docs]</a><span class="k">class</span> <span class="nc">TreeBuilder</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
|
||||
<span class="sd">'''Builds the arch-specific boot images.</span>
|
||||
<span class="sd"> inroot should be the installtree root (the newly-built runtime dir)'''</span>
|
||||
<span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">product</span><span class="p">,</span> <span class="n">arch</span><span class="p">,</span> <span class="n">inroot</span><span class="p">,</span> <span class="n">outroot</span><span class="p">,</span> <span class="n">runtime</span><span class="p">,</span> <span class="n">isolabel</span><span class="p">,</span> <span class="n">domacboot</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">doupgrade</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">templatedir</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">add_templates</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">add_template_vars</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">workdir</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">product</span><span class="p">,</span> <span class="n">arch</span><span class="p">,</span> <span class="n">inroot</span><span class="p">,</span> <span class="n">outroot</span><span class="p">,</span> <span class="n">runtime</span><span class="p">,</span> <span class="n">isolabel</span><span class="p">,</span> <span class="n">domacboot</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">doupgrade</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
|
||||
<span class="n">templatedir</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">add_templates</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">add_template_vars</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">workdir</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">extra_boot_args</span><span class="o">=</span><span class="s2">""</span><span class="p">):</span>
|
||||
|
||||
<span class="c1"># NOTE: if you pass an arg named "runtime" to a mako template it'll</span>
|
||||
<span class="c1"># clobber some mako internal variables - hence "runtime_img".</span>
|
||||
@ -410,7 +359,8 @@
|
||||
<span class="n">inroot</span><span class="o">=</span><span class="n">inroot</span><span class="p">,</span> <span class="n">outroot</span><span class="o">=</span><span class="n">outroot</span><span class="p">,</span>
|
||||
<span class="n">basearch</span><span class="o">=</span><span class="n">arch</span><span class="o">.</span><span class="n">basearch</span><span class="p">,</span> <span class="n">libdir</span><span class="o">=</span><span class="n">arch</span><span class="o">.</span><span class="n">libdir</span><span class="p">,</span>
|
||||
<span class="n">isolabel</span><span class="o">=</span><span class="n">isolabel</span><span class="p">,</span> <span class="n">udev</span><span class="o">=</span><span class="n">udev_escape</span><span class="p">,</span> <span class="n">domacboot</span><span class="o">=</span><span class="n">domacboot</span><span class="p">,</span> <span class="n">doupgrade</span><span class="o">=</span><span class="n">doupgrade</span><span class="p">,</span>
|
||||
<span class="n">workdir</span><span class="o">=</span><span class="n">workdir</span><span class="p">,</span> <span class="n">lower</span><span class="o">=</span><span class="n">string_lower</span><span class="p">)</span>
|
||||
<span class="n">workdir</span><span class="o">=</span><span class="n">workdir</span><span class="p">,</span> <span class="n">lower</span><span class="o">=</span><span class="n">string_lower</span><span class="p">,</span>
|
||||
<span class="n">extra_boot_args</span><span class="o">=</span><span class="n">extra_boot_args</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_runner</span> <span class="o">=</span> <span class="n">LoraxTemplateRunner</span><span class="p">(</span><span class="n">inroot</span><span class="p">,</span> <span class="n">outroot</span><span class="p">,</span> <span class="n">templatedir</span><span class="o">=</span><span class="n">templatedir</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_runner</span><span class="o">.</span><span class="n">defaults</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">vars</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">add_templates</span> <span class="o">=</span> <span class="n">add_templates</span> <span class="ow">or</span> <span class="p">[]</span>
|
||||
@ -433,15 +383,14 @@
|
||||
<span class="sd"> name of the kernel.</span>
|
||||
<span class="sd"> '''</span>
|
||||
<span class="n">add_args</span> <span class="o">=</span> <span class="n">add_args</span> <span class="ow">or</span> <span class="p">[]</span>
|
||||
<span class="n">dracut</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"dracut"</span><span class="p">,</span> <span class="s2">"--nomdadmconf"</span><span class="p">,</span> <span class="s2">"--nolvmconf"</span><span class="p">]</span> <span class="o">+</span> <span class="n">add_args</span>
|
||||
<span class="n">args</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"--nomdadmconf"</span><span class="p">,</span> <span class="s2">"--nolvmconf"</span><span class="p">]</span> <span class="o">+</span> <span class="n">add_args</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">backup</span><span class="p">:</span>
|
||||
<span class="n">dracut</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"--force"</span><span class="p">)</span>
|
||||
<span class="n">args</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"--force"</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">kernels</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s2">"No kernels found, cannot rebuild_initrds"</span><span class="p">)</span>
|
||||
|
||||
<span class="c1"># Hush some dracut warnings. TODO: bind-mount proc in place?</span>
|
||||
<span class="nb">open</span><span class="p">(</span><span class="n">joinpaths</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">vars</span><span class="o">.</span><span class="n">inroot</span><span class="p">,</span><span class="s2">"/proc/modules"</span><span class="p">),</span><span class="s2">"w"</span><span class="p">)</span>
|
||||
<span class="k">with</span> <span class="n">DracutChroot</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">vars</span><span class="o">.</span><span class="n">inroot</span><span class="p">)</span> <span class="k">as</span> <span class="n">dracut</span><span class="p">:</span>
|
||||
<span class="k">for</span> <span class="n">kernel</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">kernels</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="n">prefix</span><span class="p">:</span>
|
||||
<span class="n">idir</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">dirname</span><span class="p">(</span><span class="n">kernel</span><span class="o">.</span><span class="n">path</span><span class="p">)</span>
|
||||
@ -453,20 +402,12 @@
|
||||
<span class="c1"># Construct an initrd from the kernel name</span>
|
||||
<span class="n">outfile</span> <span class="o">=</span> <span class="n">kernel</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">"vmlinuz-"</span><span class="p">,</span> <span class="s2">"initrd-"</span><span class="p">)</span> <span class="o">+</span> <span class="s2">".img"</span>
|
||||
<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">"rebuilding </span><span class="si">%s</span><span class="s2">"</span><span class="p">,</span> <span class="n">outfile</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">backup</span><span class="p">:</span>
|
||||
<span class="n">initrd</span> <span class="o">=</span> <span class="n">joinpaths</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">vars</span><span class="o">.</span><span class="n">inroot</span><span class="p">,</span> <span class="n">outfile</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="n">initrd</span><span class="p">):</span>
|
||||
<span class="n">os</span><span class="o">.</span><span class="n">rename</span><span class="p">(</span><span class="n">initrd</span><span class="p">,</span> <span class="n">initrd</span> <span class="o">+</span> <span class="n">backup</span><span class="p">)</span>
|
||||
<span class="n">cmd</span> <span class="o">=</span> <span class="n">dracut</span> <span class="o">+</span> <span class="p">[</span><span class="n">outfile</span><span class="p">,</span> <span class="n">kernel</span><span class="o">.</span><span class="n">version</span><span class="p">]</span>
|
||||
<span class="n">runcmd</span><span class="p">(</span><span class="n">cmd</span><span class="p">,</span> <span class="n">root</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">vars</span><span class="o">.</span><span class="n">inroot</span><span class="p">)</span>
|
||||
|
||||
<span class="c1"># ppc64 cannot boot images > 32MiB, check size and warn</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">vars</span><span class="o">.</span><span class="n">arch</span><span class="o">.</span><span class="n">basearch</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"ppc64"</span><span class="p">,</span> <span class="s2">"ppc64le"</span><span class="p">)</span> <span class="ow">and</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="n">outfile</span><span class="p">):</span>
|
||||
<span class="n">st</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">stat</span><span class="p">(</span><span class="n">outfile</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">st</span><span class="o">.</span><span class="n">st_size</span> <span class="o">></span> <span class="mi">32</span> <span class="o">*</span> <span class="mi">1024</span> <span class="o">*</span> <span class="mi">1024</span><span class="p">:</span>
|
||||
<span class="n">logging</span><span class="o">.</span><span class="n">warning</span><span class="p">(</span><span class="s2">"ppc64 initrd </span><span class="si">%s</span><span class="s2"> is > 32MiB"</span><span class="p">,</span> <span class="n">outfile</span><span class="p">)</span>
|
||||
|
||||
<span class="n">os</span><span class="o">.</span><span class="n">unlink</span><span class="p">(</span><span class="n">joinpaths</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">vars</span><span class="o">.</span><span class="n">inroot</span><span class="p">,</span><span class="s2">"/proc/modules"</span><span class="p">))</span></div>
|
||||
<span class="n">dracut</span><span class="o">.</span><span class="n">Run</span><span class="p">(</span><span class="n">args</span> <span class="o">+</span> <span class="p">[</span><span class="n">outfile</span><span class="p">,</span> <span class="n">kernel</span><span class="o">.</span><span class="n">version</span><span class="p">])</span></div>
|
||||
|
||||
<div class="viewcode-block" id="TreeBuilder.build"><a class="viewcode-back" href="../../pylorax.html#pylorax.treebuilder.TreeBuilder.build">[docs]</a> <span class="k">def</span> <span class="nf">build</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="n">templatefile</span> <span class="o">=</span> <span class="n">templatemap</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">vars</span><span class="o">.</span><span class="n">arch</span><span class="o">.</span><span class="n">basearch</span><span class="p">]</span>
|
||||
@ -563,66 +504,31 @@
|
||||
<span class="k">return</span> <span class="n">string</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span></div>
|
||||
</pre></div>
|
||||
|
||||
</div>
|
||||
<div class="articleComments">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<footer>
|
||||
|
||||
|
||||
<hr/>
|
||||
|
||||
<div role="contentinfo">
|
||||
<p>
|
||||
© Copyright 2015, Red Hat, Inc..
|
||||
|
||||
</p>
|
||||
<p>© Copyright 2018, Red Hat, Inc..</p>
|
||||
</div>
|
||||
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||||
|
||||
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
|
||||
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
|
||||
provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||||
|
||||
|
||||
</footer>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
var DOCUMENTATION_OPTIONS = {
|
||||
URL_ROOT:'../../',
|
||||
VERSION:'28.2',
|
||||
COLLAPSE_INDEX:false,
|
||||
FILE_SUFFIX:'.html',
|
||||
HAS_SOURCE: true,
|
||||
SOURCELINK_SUFFIX: '.txt'
|
||||
};
|
||||
</script>
|
||||
<script type="text/javascript" src="../../_static/jquery.js"></script>
|
||||
<script type="text/javascript" src="../../_static/underscore.js"></script>
|
||||
<script type="text/javascript" src="../../_static/doctools.js"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript" src="../../_static/js/theme.js"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
<script>
|
||||
jQuery(function () {
|
||||
SphinxRtdTheme.StickyNav.enable();
|
||||
SphinxRtdTheme.Navigation.enable(true);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,76 +1,31 @@
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
|
||||
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
|
||||
<html class="writer-html5" lang="en" >
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>pylorax.treeinfo — Lorax 28.2 documentation</title>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pylorax.treeinfo — Lorax 36.0 documentation</title>
|
||||
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
|
||||
<link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="index" title="Index"
|
||||
href="../../genindex.html"/>
|
||||
<link rel="search" title="Search" href="../../search.html"/>
|
||||
<link rel="top" title="Lorax 28.2 documentation" href="../../index.html"/>
|
||||
<link rel="up" title="pylorax" href="../pylorax.html"/>
|
||||
|
||||
|
||||
<script src="../../_static/js/modernizr.min.js"></script>
|
||||
|
||||
<script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
|
||||
<script src="../../_static/jquery.js"></script>
|
||||
<script src="../../_static/underscore.js"></script>
|
||||
<script src="../../_static/doctools.js"></script>
|
||||
<script src="../../_static/js/theme.js"></script>
|
||||
<link rel="index" title="Index" href="../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../search.html" />
|
||||
</head>
|
||||
|
||||
<body class="wy-body-for-nav" role="document">
|
||||
|
||||
|
||||
<body class="wy-body-for-nav">
|
||||
<div class="wy-grid-for-nav">
|
||||
|
||||
|
||||
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
|
||||
<div class="wy-side-scroll">
|
||||
<div class="wy-side-nav-search">
|
||||
|
||||
|
||||
|
||||
<div class="wy-side-nav-search" >
|
||||
<a href="../../index.html" class="icon icon-home"> Lorax
|
||||
|
||||
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="version">
|
||||
28.2
|
||||
36.0
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div role="search">
|
||||
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
|
||||
<input type="text" name="q" placeholder="Search docs" />
|
||||
@ -78,84 +33,37 @@
|
||||
<input type="hidden" name="area" value="default" />
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../intro.html">Introduction to Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../intro.html#before-lorax">Before Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../lorax.html">Lorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../livemedia-creator.html">livemedia-creator</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../mkksiso.html">mkksiso</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../product-images.html">Product and Updates Images</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../modules.html">pylorax</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="../../modules.html">src</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
|
||||
|
||||
|
||||
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
|
||||
|
||||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
|
||||
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
||||
<a href="../../index.html">Lorax</a>
|
||||
|
||||
</nav>
|
||||
|
||||
|
||||
|
||||
<div class="wy-nav-content">
|
||||
<div class="rst-content">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div role="navigation" aria-label="breadcrumbs navigation">
|
||||
|
||||
<div role="navigation" aria-label="Page navigation">
|
||||
<ul class="wy-breadcrumbs">
|
||||
|
||||
<li><a href="../../index.html">Docs</a> »</li>
|
||||
|
||||
<li><a href="../../index.html" class="icon icon-home"></a> »</li>
|
||||
<li><a href="../index.html">Module code</a> »</li>
|
||||
|
||||
<li><a href="../pylorax.html">pylorax</a> »</li>
|
||||
|
||||
<li>pylorax.treeinfo</li>
|
||||
|
||||
|
||||
<li class="wy-breadcrumbs-aside">
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
<hr/>
|
||||
</div>
|
||||
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
|
||||
@ -187,18 +95,24 @@
|
||||
<span class="n">logger</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="s2">"pylorax.treeinfo"</span><span class="p">)</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">configparser</span>
|
||||
<span class="kn">import</span> <span class="nn">os</span>
|
||||
<span class="kn">import</span> <span class="nn">time</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="TreeInfo"><a class="viewcode-back" href="../../pylorax.html#pylorax.treeinfo.TreeInfo">[docs]</a><span class="k">class</span> <span class="nc">TreeInfo</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">product</span><span class="p">,</span> <span class="n">version</span><span class="p">,</span> <span class="n">variant</span><span class="p">,</span> <span class="n">basearch</span><span class="p">,</span>
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">product</span><span class="p">,</span> <span class="n">version</span><span class="p">,</span> <span class="n">variant</span><span class="p">,</span> <span class="n">basearch</span><span class="p">,</span>
|
||||
<span class="n">packagedir</span><span class="o">=</span><span class="s2">""</span><span class="p">):</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">c</span> <span class="o">=</span> <span class="n">configparser</span><span class="o">.</span><span class="n">ConfigParser</span><span class="p">()</span>
|
||||
|
||||
<span class="k">if</span> <span class="s1">'SOURCE_DATE_EPOCH'</span> <span class="ow">in</span> <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">:</span>
|
||||
<span class="n">timestamp</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">[</span><span class="s1">'SOURCE_DATE_EPOCH'</span><span class="p">]</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">timestamp</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">time</span><span class="o">.</span><span class="n">time</span><span class="p">())</span>
|
||||
|
||||
<span class="n">section</span> <span class="o">=</span> <span class="s2">"general"</span>
|
||||
<span class="n">data</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"timestamp"</span><span class="p">:</span> <span class="nb">str</span><span class="p">(</span><span class="n">time</span><span class="o">.</span><span class="n">time</span><span class="p">()),</span>
|
||||
<span class="n">data</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"timestamp"</span><span class="p">:</span> <span class="n">timestamp</span><span class="p">,</span>
|
||||
<span class="s2">"family"</span><span class="p">:</span> <span class="n">product</span><span class="p">,</span>
|
||||
<span class="s2">"version"</span><span class="p">:</span> <span class="n">version</span><span class="p">,</span>
|
||||
<span class="s2">"name"</span><span class="p">:</span> <span class="s2">"</span><span class="si">%s</span><span class="s2">-</span><span class="si">%s</span><span class="s2">"</span> <span class="o">%</span> <span class="p">(</span><span class="n">product</span><span class="p">,</span> <span class="n">version</span><span class="p">),</span>
|
||||
@ -221,66 +135,31 @@
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">fobj</span><span class="p">)</span></div></div>
|
||||
</pre></div>
|
||||
|
||||
</div>
|
||||
<div class="articleComments">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<footer>
|
||||
|
||||
|
||||
<hr/>
|
||||
|
||||
<div role="contentinfo">
|
||||
<p>
|
||||
© Copyright 2015, Red Hat, Inc..
|
||||
|
||||
</p>
|
||||
<p>© Copyright 2018, Red Hat, Inc..</p>
|
||||
</div>
|
||||
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||||
|
||||
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
|
||||
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
|
||||
provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
||||
|
||||
|
||||
</footer>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
var DOCUMENTATION_OPTIONS = {
|
||||
URL_ROOT:'../../',
|
||||
VERSION:'28.2',
|
||||
COLLAPSE_INDEX:false,
|
||||
FILE_SUFFIX:'.html',
|
||||
HAS_SOURCE: true,
|
||||
SOURCELINK_SUFFIX: '.txt'
|
||||
};
|
||||
</script>
|
||||
<script type="text/javascript" src="../../_static/jquery.js"></script>
|
||||
<script type="text/javascript" src="../../_static/underscore.js"></script>
|
||||
<script type="text/javascript" src="../../_static/doctools.js"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript" src="../../_static/js/theme.js"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
<script>
|
||||
jQuery(function () {
|
||||
SphinxRtdTheme.StickyNav.enable();
|
||||
SphinxRtdTheme.Navigation.enable(true);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
99
docs/html/_sources/image-minimizer.rst.txt
Normal file
@ -0,0 +1,99 @@
|
||||
image-minimizer
|
||||
===============
|
||||
|
||||
:Authors:
|
||||
Brian C. Lane <bcl@redhat.com>
|
||||
|
||||
`image-minimizer` is a script used as an interpreter for kickstart `%post`
|
||||
sections. It is used to remove rpm packages and individual files from the
|
||||
system that Anaconda has just installed.
|
||||
|
||||
It processes a list of commands that tell it which files or rpms to remove, and
|
||||
which to keep.
|
||||
|
||||
|
||||
image-minimizer cmdline arguments
|
||||
---------------------------------
|
||||
|
||||
`usage: image-minimizer [-h] [-i STRING] [--dryrun] [-v] STRING`
|
||||
|
||||
Optional arguments
|
||||
^^^^^^^^^^^^^^^^^^
|
||||
|
||||
-h, --help show this help message and exit
|
||||
-i STRING, --installroot STRING
|
||||
Root path to prepend to all file patterns and
|
||||
installation root for RPM operations. Defaults to
|
||||
INSTALL_ROOT or /mnt/sysimage/
|
||||
--dryrun If set, no filesystem changes are made.
|
||||
-v, --verbose Display every action as it is performed.
|
||||
|
||||
Positional arguments
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
:STRING: Filename to process
|
||||
|
||||
|
||||
NOTES
|
||||
-----
|
||||
|
||||
You cannot pass any arguments to `image-minimizer` when using it from the
|
||||
kickstart `%post`.
|
||||
|
||||
When using this from a kickstart the image-minimizer package needs to be available.
|
||||
It is not included on the standard boot.iso, so you will need to include `lorax` in
|
||||
the `%package` section. You can use `image-minimizer` to remove lorax from the install.
|
||||
|
||||
If you are using this with `livemedia-creator` it can be installed on the host
|
||||
system so that `lorax` isn't needed in the `%package` list, and it doesn't need
|
||||
to be removed.
|
||||
|
||||
|
||||
commands
|
||||
--------
|
||||
|
||||
Commands are listed one per line, followed by a space, and then by the
|
||||
package, file, or glob. The globs used are Unix style pathname patterns using
|
||||
`*`, `?`, and `[]` character ranges. globbing is implemented using the python
|
||||
glob module.
|
||||
|
||||
|
||||
* drop <PATTERN>
|
||||
This will remove files from the installation.
|
||||
|
||||
* keep <PATTERN>
|
||||
This will keep files, and should follow any `drop` commands including globs.
|
||||
|
||||
* droprpm <PATTERN>
|
||||
Remove matching rpm packages. Dependencies are not remove, just individual
|
||||
packages matching the glob.
|
||||
|
||||
* keeprpm <PATTERN>
|
||||
Do not remove matching rpm packages, it should follow any `droprpm` commands
|
||||
that include globs.
|
||||
|
||||
|
||||
example
|
||||
-------
|
||||
|
||||
Example Anaconda `%post` usage::
|
||||
|
||||
%post --interpreter=image-minimizer --nochroot
|
||||
|
||||
drop /lib/modules/*/kernel/fs
|
||||
keep /lib/modules/*/kernel/fs/ext*
|
||||
keep /lib/modules/*/kernel/fs/mbcache*
|
||||
keep /lib/modules/*/kernel/fs/squashfs
|
||||
|
||||
droprpm make
|
||||
droprpm mtools
|
||||
droprpm mysql-libs
|
||||
droprpm perl
|
||||
droprpm perl-Pod-*
|
||||
droprpm syslinux
|
||||
keeprpm perl-Pod-Simple
|
||||
|
||||
# Not needed after image-minimizer is done
|
||||
droprpm lorax
|
||||
|
||||
%end
|
@ -14,9 +14,19 @@ Contents:
|
||||
intro
|
||||
lorax
|
||||
livemedia-creator
|
||||
mkksiso
|
||||
product-images
|
||||
image-minimizer
|
||||
modules
|
||||
|
||||
Documentation for other Lorax Branches
|
||||
======================================
|
||||
|
||||
* `Fedora 35 <f35-branch/>`_
|
||||
* `Fedora 34 <f34-branch/>`_
|
||||
* `Fedora 33 <f33-branch/>`_
|
||||
* `RHEL8 lorax-composer <rhel8-branch/>`_
|
||||
* `RHEL7 lorax-composer <lorax-composer/>`_
|
||||
|
||||
Indices and tables
|
||||
==================
|
||||
|
@ -1,27 +0,0 @@
|
||||
.. Lorax documentation master file, created by
|
||||
sphinx-quickstart on Wed Apr 8 13:46:00 2015.
|
||||
You can adapt this file completely to your liking, but it should at least
|
||||
contain the root `toctree` directive.
|
||||
|
||||
Welcome to Lorax's documentation!
|
||||
=================================
|
||||
|
||||
Contents:
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
intro
|
||||
lorax
|
||||
livemedia-creator
|
||||
product-images
|
||||
modules
|
||||
|
||||
|
||||
Indices and tables
|
||||
==================
|
||||
|
||||
* :ref:`genindex`
|
||||
* :ref:`modindex`
|
||||
* :ref:`search`
|
||||
|
@ -1,67 +0,0 @@
|
||||
Introduction to Lorax
|
||||
=====================
|
||||
|
||||
I am the Lorax. I speak for the trees [and images].
|
||||
|
||||
Lorax is used to build the Anaconda Installer boot.iso, it consists of a
|
||||
library, pylorax, a set of templates, and the lorax script. Its operation
|
||||
is driven by a customized set of Mako templates that lists the packages
|
||||
to be installed, steps to execute to remove unneeded files, and creation
|
||||
of the iso for all of the supported architectures.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Before Lorax
|
||||
============
|
||||
|
||||
Tree building tools such as pungi and revisor rely on 'buildinstall' in
|
||||
anaconda/scripts/ to produce the boot images and other such control files
|
||||
in the final tree. The existing buildinstall scripts written in a mix of
|
||||
bash and Python are unmaintainable. Lorax is an attempt to replace them
|
||||
with something more flexible.
|
||||
|
||||
|
||||
EXISTING WORKFLOW:
|
||||
|
||||
pungi and other tools call scripts/buildinstall, which in turn call other
|
||||
scripts to do the image building and data generation. Here's how it
|
||||
currently looks:
|
||||
|
||||
-> buildinstall
|
||||
* process command line options
|
||||
* write temporary yum.conf to point to correct repo
|
||||
* find anaconda release RPM
|
||||
* unpack RPM, pull in those versions of upd-instroot, mk-images,
|
||||
maketreeinfo.py, makestamp.py, and buildinstall
|
||||
|
||||
-> call upd-instroot
|
||||
|
||||
-> call maketreeinfo.py
|
||||
|
||||
-> call mk-images (which figures out which mk-images.ARCH to call)
|
||||
|
||||
-> call makestamp.py
|
||||
|
||||
* clean up
|
||||
|
||||
|
||||
PROBLEMS:
|
||||
|
||||
The existing workflow presents some problems with maintaining the scripts.
|
||||
First, almost all knowledge of what goes in to the stage 1 and stage 2
|
||||
images lives in upd-instroot. The mk-images* scripts copy things from the
|
||||
root created by upd-instroot in order to build the stage 1 image, though
|
||||
it's not completely clear from reading the scripts.
|
||||
|
||||
|
||||
NEW IDEAS:
|
||||
|
||||
Create a new central driver with all information living in Python modules.
|
||||
Configuration files will provide the knowledge previously contained in the
|
||||
upd-instroot and mk-images* scripts.
|
||||
|
||||
|
||||
|
@ -46,6 +46,16 @@ livemedia-creator cmdline arguments
|
||||
:ref: pylorax.cmdline.lmc_parser
|
||||
:prog: livemedia-creator
|
||||
|
||||
--macboot : @replace
|
||||
Make the iso bootable on UEFI based Mac systems
|
||||
|
||||
Default: True
|
||||
|
||||
--nomacboot : @replace
|
||||
Do not create a Mac bootable iso
|
||||
|
||||
Default: False
|
||||
|
||||
|
||||
Quickstart
|
||||
----------
|
||||
@ -160,10 +170,19 @@ changes. Here are the steps I used to convert the Fedora XFCE spin.
|
||||
dracut-config-generic
|
||||
dracut-live
|
||||
-dracut-config-rescue
|
||||
grub-efi
|
||||
memtest86+
|
||||
grub2-efi
|
||||
syslinux
|
||||
|
||||
User created repositories
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
If you are using your own repositories and installing groups (eg. @core) make
|
||||
sure you create the repodata with groups like this ``createrepo -g
|
||||
/path/to/groups.xml /path/to/rpms``
|
||||
|
||||
Using a Proxy with repos
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
One drawback to using qemu is that it pulls the packages from the repo each
|
||||
time you run it. To speed things up you either need a local mirror of the
|
||||
packages, or you can use a caching proxy. When using a proxy you pass it to
|
||||
@ -177,7 +196,13 @@ packages will get cached, so your kickstart url would look like:
|
||||
``url --url="http://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/x86_64/os/"``
|
||||
|
||||
You can also add an update repo, but don't name it updates. Add --proxy to it
|
||||
as well.
|
||||
as well. You can use all of the `kickstart commands <https://pykickstart.readthedocs.io/en/latest/kickstart-docs.html#chapter-2-kickstart-commands-in-fedora>`_ in your kickstart. Make sure there
|
||||
is only one ``url`` command, other repos have to use the ``repo`` command and cannot be
|
||||
named ``updates`` which is reserved for Anaconda's use. eg.::
|
||||
|
||||
url --url=PRIMARY-REPO-URL --proxy=PROXY-URL
|
||||
repo --name="repo1" --baseurl=FIRST-REPO-URL --proxy=PROXY-URL
|
||||
repo --name="repo2" --baseurl=SECOND-REPO_URL --proxy=PROXY-URL
|
||||
|
||||
|
||||
Anaconda image install (no-virt)
|
||||
@ -192,10 +217,7 @@ install. There are a couple of things to keep in mind when doing this:
|
||||
running under you may encounter strange bugs if you try to build newer or
|
||||
older releases.
|
||||
|
||||
2. Make sure selinux is set to permissive or disabled. It won't install
|
||||
correctly with selinux set to enforcing yet.
|
||||
|
||||
3. It may totally trash your host. So far I haven't had this happen, but the
|
||||
2. It may totally trash your host. So far I haven't had this happen, but the
|
||||
possibility exists that a bug in Anaconda could result in it operating on
|
||||
real devices. I recommend running it in a virt or on a system that you can
|
||||
afford to lose all data from.
|
||||
@ -213,6 +235,10 @@ Example cmdline:
|
||||
or UEFI). You can create BIOS partitioned disk images on UEFI by using
|
||||
virt.
|
||||
|
||||
.. note::
|
||||
As of version 30.7 SELinux can be set to Enforcing. The current state is
|
||||
logged for debugging purposes and if there are SELinux denials they should
|
||||
be reported as a bug.
|
||||
|
||||
AMI Images
|
||||
----------
|
||||
@ -281,9 +307,6 @@ The following variables are passed to the template:
|
||||
``networks``
|
||||
list of networks from the kickstart or []
|
||||
|
||||
``title``
|
||||
from ``--title``
|
||||
|
||||
``project``
|
||||
from ``--project``
|
||||
|
||||
@ -359,9 +382,15 @@ As of lorax version 22.2 you can use livemedia-creator and anaconda version
|
||||
22.15 inside of a mock chroot with --make-iso and --make-fsimage.
|
||||
|
||||
.. note::
|
||||
As of mock 1.3.4 you need to use ``--old-chroot`` with mock. Mock now defaults to using systemd-nspawn
|
||||
which cannot create the needed loop device nodes. Passing ``--old-chroot`` will use the old system
|
||||
where ``/dev/loop*`` is setup for you.
|
||||
As of mock version 2.0 you no longer need to pass ``--old-chroot``. You will,
|
||||
however, need to pass ``--enable-network`` so that the mock container can download
|
||||
packages.
|
||||
|
||||
Older versions of mock, between 1.3.4 and 2.0, will need to pass
|
||||
``--old-chroot`` with mock. These versions of mock now default to using
|
||||
systemd-nspawn which cannot create the needed loop device nodes. Passing
|
||||
``--old-chroot`` will use the old system where ``/dev/loop*`` is setup for
|
||||
you.
|
||||
|
||||
On the host system:
|
||||
|
||||
@ -400,7 +429,7 @@ group.
|
||||
|
||||
9. Make a minimal iso::
|
||||
|
||||
mock -r fedora-rawhide-x86_64 --chroot -- livemedia-creator --no-virt \
|
||||
mock -r fedora-rawhide-x86_64 --enable-network --chroot -- livemedia-creator --no-virt \
|
||||
--resultdir=/results/try-1 --logfile=/results/logs/try-1/try-1.log \
|
||||
--make-iso --ks /root/fedora-minimal.ks
|
||||
|
||||
@ -457,7 +486,7 @@ group.
|
||||
|
||||
10. Make a minimal iso::
|
||||
|
||||
mock -r fedora-rawhide-x86_64 --chroot -- livemedia-creator \
|
||||
mock -r fedora-rawhide-x86_64 --enable-network --chroot -- livemedia-creator \
|
||||
--resultdir=/results/try-1 --logfile=/results/logs/try-1/try-1.log \
|
||||
--make-iso --ks /root/fedora-minimal.ks --iso /root/boot.iso
|
||||
|
||||
@ -562,18 +591,10 @@ Creating UEFI disk images with virt
|
||||
|
||||
Partitioned disk images can only be created for the same platform as the host system (BIOS or
|
||||
UEFI). You can use virt to create BIOS images on UEFI systems, and it is also possible
|
||||
to create UEFI images on BIOS systems using OVMF. You first need to setup your system with
|
||||
the OVMF firmware. The details can be `found here linux-kvm OVMF page <http://www.linux-kvm.org/page/OVMF>`_
|
||||
but it amounts to:
|
||||
to create UEFI images on BIOS systems using OVMF firmware and qemu.
|
||||
|
||||
1. Download the firmware.repo from `Gerd Hoffmann <https://www.kraxel.org/repos/>`_ and install it
|
||||
in /etc/yum.repos.d/
|
||||
|
||||
2. Install the edk2.git-ovmf-x64 package
|
||||
|
||||
3. Copy /usr/share/edk2.git/ovmf-x64/OVMF_CODE-pure-efi.fd to /usr/share/OVMF/OVMF_CODE.fd
|
||||
|
||||
4. Copy /usr/share/edk2.git/ovmf-x64/OVMF_VARS-pure-efi.fd to /usr/share/OVMF/OVMF_VARS.fd
|
||||
Install the lorax-lmc-virt package, this will install qemu and the OVMF
|
||||
firmware files.
|
||||
|
||||
Now you can run livemedia-creator with ``--virt-uefi`` to boot and install using UEFI::
|
||||
|
||||
@ -584,11 +605,10 @@ Make sure that the kickstart you are using creates a /boot/efi partition by incl
|
||||
|
||||
part /boot/efi --fstype="efi" --size=500
|
||||
|
||||
Or use ``reqpart`` in the kickstart and Anaconda will create the required partitions.
|
||||
|
||||
.. note::
|
||||
When using the resulting image with the current version of OVMF (edk2.git-ovmf-x64-0-20151103.b1295.ge5cffca)
|
||||
it will not boot automatically because there is a problem with the fallback path.
|
||||
You can boot it by entering the UEFI shell and running EFI/fedora/shim.efi and
|
||||
then using efibootmgr to setup the correct boot entry.
|
||||
The --virt-uefi method is currently only supported on the x86_64 architecture.
|
||||
|
||||
|
||||
Debugging problems
|
||||
@ -602,6 +622,16 @@ When creating a new kickstart it is helpful to use vnc so that you can monitor
|
||||
the installation as it happens, and if it gets stuck without lmc detecting the
|
||||
problem you can switch to tty1 and examine the system directly.
|
||||
|
||||
If you suspect problems with %pre or %post sections you can redirect the output
|
||||
to the terminal and examine it by logging into the VM. eg.::
|
||||
|
||||
%pre
|
||||
chvt
|
||||
exec < /dev/tty3 > /dev/tty3 2>/dev/tty3
|
||||
#do stuff
|
||||
echo hello world
|
||||
%end
|
||||
|
||||
If it does get stuck the best way to cancel is to use kill -9 on the qemu pid,
|
||||
lmc will detect that the process died and cleanup.
|
||||
|
||||
|
@ -1,638 +0,0 @@
|
||||
livemedia-creator
|
||||
=================
|
||||
|
||||
:Authors:
|
||||
Brian C. Lane <bcl@redhat.com>
|
||||
|
||||
livemedia-creator uses `Anaconda <https://github.com/rhinstaller/anaconda>`_,
|
||||
`kickstart <https://github.com/rhinstaller/pykickstart>`_ and `Lorax
|
||||
<https://github.com/rhinstaller/lorax>`_ to create bootable media that use the
|
||||
same install path as a normal system installation. It can be used to make live
|
||||
isos, bootable (partitioned) disk images, tarfiles, and filesystem images for
|
||||
use with virtualization and container solutions like libvirt, docker, and
|
||||
OpenStack.
|
||||
|
||||
The general idea is to use qemu with kickstart and an Anaconda boot.iso to
|
||||
install into a disk image and then use the disk image to create the bootable
|
||||
media.
|
||||
|
||||
livemedia-creator --help will describe all of the options available. At the
|
||||
minimum you need:
|
||||
|
||||
``--make-iso`` to create a final bootable .iso or one of the other ``--make-*`` options.
|
||||
|
||||
``--iso`` to specify the Anaconda install media to use with qemu.
|
||||
|
||||
``--ks`` to select the kickstart file describing what to install.
|
||||
|
||||
To use livemedia-creator with virtualization you will need to have qemu installed.
|
||||
|
||||
If you are going to be using Anaconda directly, with ``--no-virt`` mode, make sure
|
||||
you have the anaconda-tui package installed.
|
||||
|
||||
Conventions used in this document:
|
||||
|
||||
``lmc`` is an abbreviation for livemedia-creator.
|
||||
|
||||
``builder`` is the system where livemedia-creator is being run
|
||||
|
||||
``image`` is the disk image being created by running livemedia-creator
|
||||
|
||||
|
||||
livemedia-creator cmdline arguments
|
||||
-----------------------------------
|
||||
|
||||
.. argparse::
|
||||
:ref: pylorax.cmdline.lmc_parser
|
||||
:prog: livemedia-creator
|
||||
|
||||
|
||||
Quickstart
|
||||
----------
|
||||
|
||||
Run this to create a bootable live iso::
|
||||
|
||||
sudo livemedia-creator --make-iso \
|
||||
--iso=/extra/iso/boot.iso --ks=./docs/fedora-livemedia.ks
|
||||
|
||||
You can run it directly from the lorax git repo like this::
|
||||
|
||||
sudo PATH=./src/sbin/:$PATH PYTHONPATH=./src/ ./src/sbin/livemedia-creator \
|
||||
--make-iso --iso=/extra/iso/boot.iso \
|
||||
--ks=./docs/fedora-livemedia.ks --lorax-templates=./share/
|
||||
|
||||
You can observe the installation using vnc. The logs will show what port was
|
||||
chosen, or you can use a specific port by passing it. eg. ``--vnc vnc:127.0.0.1:5``
|
||||
|
||||
This is usually a good idea when testing changes to the kickstart. lmc tries
|
||||
to monitor the logs for fatal errors, but may not catch everything.
|
||||
|
||||
|
||||
How ISO creation works
|
||||
----------------------
|
||||
|
||||
There are 2 stages, the install stage which produces a disk or filesystem image
|
||||
as its output, and the boot media creation which uses the image as its input.
|
||||
Normally you would run both stages, but it is possible to stop after the
|
||||
install stage, by using ``--image-only``, or to skip the install stage and use
|
||||
a previously created disk image by passing ``--disk-image`` or ``--fs-image``
|
||||
|
||||
When creating an iso qemu boots using the passed Anaconda installer iso
|
||||
and installs the system based on the kickstart. The ``%post`` section of the
|
||||
kickstart is used to customize the installed system in the same way that
|
||||
current spin-kickstarts do.
|
||||
|
||||
livemedia-creator monitors the install process for problems by watching the
|
||||
install logs. They are written to the current directory or to the base
|
||||
directory specified by the --logfile command. You can also monitor the install
|
||||
by using a vnc client. This is recommended when first modifying a kickstart,
|
||||
since there are still places where Anaconda may get stuck without the log
|
||||
monitor catching it.
|
||||
|
||||
The output from this process is a partitioned disk image. kpartx can be used
|
||||
to mount and examine it when there is a problem with the install. It can also
|
||||
be booted using kvm.
|
||||
|
||||
When creating an iso the disk image's / partition is copied into a formatted
|
||||
filesystem image which is then used as the input to lorax for creation of the
|
||||
final media.
|
||||
|
||||
The final image is created by lorax, using the templates in /usr/share/lorax/live/
|
||||
or the live directory below the directory specified by ``--lorax-templates``. The
|
||||
templates are written using the Mako template system with some extra commands
|
||||
added by lorax.
|
||||
|
||||
.. note::
|
||||
The output from --make-iso includes the artifacts used to create the boot.iso;
|
||||
the kernel, initrd, the squashfs filesystem, etc. If you only want the
|
||||
boot.iso you can pass ``--iso-only`` and the other files will be removed. You
|
||||
can also name the iso by using ``--iso-name my-live.iso``.
|
||||
|
||||
|
||||
Kickstarts
|
||||
----------
|
||||
|
||||
The docs/ directory includes several example kickstarts, one to create a live
|
||||
desktop iso using GNOME, and another to create a minimal disk image. When
|
||||
creating your own kickstarts you should start with the minimal example, it
|
||||
includes several needed packages that are not always included by dependencies.
|
||||
|
||||
Or you can use existing spin kickstarts to create live media with a few
|
||||
changes. Here are the steps I used to convert the Fedora XFCE spin.
|
||||
|
||||
1. Flatten the xfce kickstart using ksflatten
|
||||
2. Add zerombr so you don't get the disk init dialog
|
||||
3. Add clearpart --all
|
||||
4. Add swap partition
|
||||
5. bootloader target
|
||||
6. Add shutdown to the kickstart
|
||||
7. Add network --bootproto=dhcp --activate to activate the network
|
||||
This works for F16 builds but for F15 and before you need to pass
|
||||
something on the cmdline that activate the network, like sshd:
|
||||
|
||||
``livemedia-creator --kernel-args="sshd"``
|
||||
|
||||
8. Add a root password::
|
||||
|
||||
rootpw rootme
|
||||
network --bootproto=dhcp --activate
|
||||
zerombr
|
||||
clearpart --all
|
||||
bootloader --location=mbr
|
||||
part swap --size=512
|
||||
shutdown
|
||||
|
||||
9. In the livesys script section of the %post remove the root password. This
|
||||
really depends on how the spin wants to work. You could add the live user
|
||||
that you create to the %wheel group so that sudo works if you wanted to.
|
||||
|
||||
``passwd -d root > /dev/null``
|
||||
|
||||
10. Remove /etc/fstab in %post, dracut handles mounting the rootfs
|
||||
|
||||
``cat /dev/null > /dev/fstab``
|
||||
|
||||
Do this only for live iso's, the filesystem will be mounted read only if
|
||||
there is no /etc/fstab
|
||||
|
||||
11. Don't delete initramfs files from /boot in %post
|
||||
12. When creating live iso's you need to have, at least, these packages in the %package section::
|
||||
dracut-config-generic
|
||||
dracut-live
|
||||
-dracut-config-rescue
|
||||
grub-efi
|
||||
memtest86+
|
||||
syslinux
|
||||
|
||||
One drawback to using qemu is that it pulls the packages from the repo each
|
||||
time you run it. To speed things up you either need a local mirror of the
|
||||
packages, or you can use a caching proxy. When using a proxy you pass it to
|
||||
livemedia-creator like this:
|
||||
|
||||
``--proxy=http://proxy.yourdomain.com:3128``
|
||||
|
||||
You also need to use a specific mirror instead of mirrormanager so that the
|
||||
packages will get cached, so your kickstart url would look like:
|
||||
|
||||
``url --url="http://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/x86_64/os/"``
|
||||
|
||||
You can also add an update repo, but don't name it updates. Add --proxy to it
|
||||
as well.
|
||||
|
||||
|
||||
Anaconda image install (no-virt)
|
||||
--------------------------------
|
||||
|
||||
You can create images without using qemu by passing ``--no-virt`` on the
|
||||
cmdline. This will use Anaconda's directory install feature to handle the
|
||||
install. There are a couple of things to keep in mind when doing this:
|
||||
|
||||
1. It will be most reliable when building images for the same release that the
|
||||
host is running. Because Anaconda has expectations about the system it is
|
||||
running under you may encounter strange bugs if you try to build newer or
|
||||
older releases.
|
||||
|
||||
2. Make sure selinux is set to permissive or disabled. It won't install
|
||||
correctly with selinux set to enforcing yet.
|
||||
|
||||
3. It may totally trash your host. So far I haven't had this happen, but the
|
||||
possibility exists that a bug in Anaconda could result in it operating on
|
||||
real devices. I recommend running it in a virt or on a system that you can
|
||||
afford to lose all data from.
|
||||
|
||||
The logs from anaconda will be placed in an ./anaconda/ directory in either
|
||||
the current directory or in the directory used for --logfile
|
||||
|
||||
Example cmdline:
|
||||
|
||||
``sudo livemedia-creator --make-iso --no-virt --ks=./fedora-livemedia.ks``
|
||||
|
||||
.. note::
|
||||
Using no-virt to create a partitioned disk image (eg. --make-disk or
|
||||
--make-vagrant) will only create disks usable on the host platform (BIOS
|
||||
or UEFI). You can create BIOS partitioned disk images on UEFI by using
|
||||
virt.
|
||||
|
||||
|
||||
AMI Images
|
||||
----------
|
||||
|
||||
Amazon EC2 images can be created by using the --make-ami switch and an appropriate
|
||||
kickstart file. All of the work to customize the image is handled by the kickstart.
|
||||
The example currently included was modified from the cloud-kickstarts version so
|
||||
that it would work with livemedia-creator.
|
||||
|
||||
Example cmdline:
|
||||
|
||||
``sudo livemedia-creator --make-ami --iso=/path/to/boot.iso --ks=./docs/fedora-livemedia-ec2.ks``
|
||||
|
||||
This will produce an ami-root.img file in the working directory.
|
||||
|
||||
At this time I have not tested the image with EC2. Feedback would be welcome.
|
||||
|
||||
|
||||
Appliance Creation
|
||||
------------------
|
||||
|
||||
livemedia-creator can now replace appliance-tools by using the --make-appliance
|
||||
switch. This will create the partitioned disk image and an XML file that can be
|
||||
used with virt-image to setup a virtual system.
|
||||
|
||||
The XML is generated using the Mako template from
|
||||
/usr/share/lorax/appliance/libvirt.xml You can use a different template by
|
||||
passing ``--app-template <template path>``
|
||||
|
||||
Documentation on the Mako template system can be found at the `Mako site
|
||||
<http://docs.makotemplates.org/en/latest/index.html>`_
|
||||
|
||||
The name of the final output XML is appliance.xml, this can be changed with
|
||||
``--app-file <file path>``
|
||||
|
||||
The following variables are passed to the template:
|
||||
|
||||
``disks``
|
||||
A list of disk_info about each disk.
|
||||
Each entry has the following attributes:
|
||||
|
||||
``name``
|
||||
base name of the disk image file
|
||||
|
||||
``format``
|
||||
"raw"
|
||||
|
||||
``checksum_type``
|
||||
"sha256"
|
||||
|
||||
``checksum``
|
||||
sha256 checksum of the disk image
|
||||
|
||||
``name``
|
||||
Name of appliance, from --app-name argument
|
||||
|
||||
``arch``
|
||||
Architecture
|
||||
|
||||
``memory``
|
||||
Memory in KB (from ``--ram``)
|
||||
|
||||
``vcpus``
|
||||
from ``--vcpus``
|
||||
|
||||
``networks``
|
||||
list of networks from the kickstart or []
|
||||
|
||||
``title``
|
||||
from ``--title``
|
||||
|
||||
``project``
|
||||
from ``--project``
|
||||
|
||||
``releasever``
|
||||
from ``--releasever``
|
||||
|
||||
The created image can be imported into libvirt using:
|
||||
|
||||
``virt-image appliance.xml``
|
||||
|
||||
You can also create qcow2 appliance images using ``--image-type=qcow2``, for example::
|
||||
|
||||
sudo livemedia-creator --make-appliance --iso=/path/to/boot.iso --ks=./docs/fedora-minimal.ks \
|
||||
--image-type=qcow2 --app-file=minimal-test.xml --image-name=minimal-test.img
|
||||
|
||||
|
||||
Filesystem Image Creation
|
||||
-------------------------
|
||||
|
||||
livemedia-creator can be used to create un-partitined filesystem images using
|
||||
the ``--make-fsimage`` option. As of version 21.8 this works with both qemu and
|
||||
no-virt modes of operation. Previously it was only available with no-virt.
|
||||
|
||||
Kickstarts should have a single / partition with no extra mountpoints.
|
||||
|
||||
``livemedia-creator --make-fsimage --iso=/path/to/boot.iso --ks=./docs/fedora-minimal.ks``
|
||||
|
||||
You can name the output image with ``--image-name`` and set a label on the filesystem with ``--fs-label``
|
||||
|
||||
|
||||
TAR File Creation
|
||||
-----------------
|
||||
|
||||
The ``--make-tar`` command can be used to create a tar of the root filesystem. By
|
||||
default it is compressed using xz, but this can be changed using the
|
||||
``--compression`` and ``--compress-arg`` options. This option works with both virt and
|
||||
no-virt install methods.
|
||||
|
||||
As with ``--make-fsimage`` the kickstart should be limited to a single / partition.
|
||||
|
||||
For example::
|
||||
|
||||
livemedia-creator --make-tar --iso=/path/to/boot.iso --ks=./docs/fedora-minimal.ks \
|
||||
--image-name=fedora-root.tar.xz
|
||||
|
||||
|
||||
Live Image for PXE Boot
|
||||
-----------------------
|
||||
|
||||
The ``--make-pxe-live`` command will produce squashfs image containing live root
|
||||
filesystem that can be used for pxe boot. Directory with results will contain
|
||||
the live image, kernel image, initrd image and template of pxe configuration
|
||||
for the images.
|
||||
|
||||
|
||||
Atomic Live Image for PXE Boot
|
||||
------------------------------
|
||||
|
||||
The ``--make-ostree-live`` command will produce the same result as ``--make-pxe-live``
|
||||
for installations of Atomic Host. Example kickstart for such an installation
|
||||
using Atomic installer iso with local repo included in the image can be found
|
||||
in docs/rhel-atomic-pxe-live.ks.
|
||||
|
||||
The PXE images can also be created with ``--no-virt`` by using the example
|
||||
kickstart in docs/fedora-atomic-pxe-live-novirt.ks. This also works inside the
|
||||
mock environment.
|
||||
|
||||
|
||||
Using Mock and --no-virt to Create Images
|
||||
-----------------------------------------
|
||||
|
||||
As of lorax version 22.2 you can use livemedia-creator and anaconda version
|
||||
22.15 inside of a mock chroot with --make-iso and --make-fsimage.
|
||||
|
||||
.. note::
|
||||
As of mock 1.2.12 you no longer need to bind mount ``/dev/``, loop devices are setup
|
||||
as part of the standard mock ``/dev/`` creation.
|
||||
|
||||
On the host system:
|
||||
|
||||
1. yum install -y mock
|
||||
|
||||
2. Add a user to the mock group to use for running mock. eg. builder
|
||||
|
||||
3. Create a new /etc/mock/ config file based on the rawhide one, or modify the
|
||||
existing one so that the following options are setup::
|
||||
|
||||
config_opts['chroot_setup_cmd'] = 'install @buildsys-build anaconda-tui lorax'
|
||||
|
||||
# build results go into /home/builder/results/
|
||||
config_opts['plugin_conf']['bind_mount_opts']['dirs'].append(('/home/builder/results','/results/'))
|
||||
|
||||
If you are creating images for a branched release of Fedora you should also enable
|
||||
the updates-testing repository so that you get the latest builds in your mock chroot.
|
||||
|
||||
The following steps are run as the builder user who is a member of the mock
|
||||
group.
|
||||
|
||||
4. Make a directory for results matching the bind mount above
|
||||
``mkdir ~/results/``
|
||||
|
||||
5. Copy the example kickstarts
|
||||
``cp /usr/share/docs/lorax/*ks .``
|
||||
|
||||
6. Make sure tar and dracut-network are in the %packages section and that the
|
||||
``url points to the correct repo``
|
||||
|
||||
7. Init the mock
|
||||
``mock -r fedora-rawhide-x86_64 --init``
|
||||
|
||||
8. Copy the kickstart inside the mock
|
||||
``mock -r fedora-rawhide-x86_64 --copyin ./fedora-minimal.ks /root/``
|
||||
|
||||
9. Make a minimal iso::
|
||||
|
||||
mock -r fedora-rawhide-x86_64 --chroot -- livemedia-creator --no-virt \
|
||||
--resultdir=/results/try-1 --logfile=/results/logs/try-1/try-1.log \
|
||||
--make-iso --ks /root/fedora-minimal.ks
|
||||
|
||||
Results will be in ./results/try-1 and logs under /results/logs/try-1/
|
||||
including anaconda logs and livemedia-creator logs. The new iso will be
|
||||
located at ~/results/try-1/images/boot.iso, and the ~/results/try-1/
|
||||
directory tree will also contain the vmlinuz, initrd, etc.
|
||||
|
||||
|
||||
Using Mock and qemu to Create Images
|
||||
------------------------------------
|
||||
|
||||
Version 25.0 of livemedia-creator switches to using qemu for virtualization.
|
||||
This allows creation of all image types, and use of the KVM on the host if
|
||||
/dev/kvm is present in the mock environment.
|
||||
|
||||
On the host system:
|
||||
|
||||
1. yum install -y mock
|
||||
|
||||
2. Add a user to the mock group to use for running mock. eg. builder
|
||||
|
||||
3. Create a new /etc/mock/ config file based on the rawhide one, or modify the
|
||||
existing one so that the following options are setup::
|
||||
|
||||
config_opts['chroot_setup_cmd'] = 'install @buildsys-build lorax qemu'
|
||||
|
||||
# build results go into /home/builder/results/
|
||||
config_opts['plugin_conf']['bind_mount_opts']['dirs'].append(('/home/builder/results','/results/'))
|
||||
|
||||
If you are creating images for a branched release of Fedora you should also enable
|
||||
the updates-testing repository so that you get the latest builds in your mock chroot.
|
||||
|
||||
The following steps are run as the builder user who is a member of the mock
|
||||
group.
|
||||
|
||||
4. Make a directory for results matching the bind mount above
|
||||
``mkdir ~/results/``
|
||||
|
||||
5. Copy the example kickstarts
|
||||
``cp /usr/share/docs/lorax/*ks .``
|
||||
|
||||
6. Make sure tar and dracut-network are in the %packages section and that the
|
||||
``url points to the correct repo``
|
||||
|
||||
7. Init the mock
|
||||
``mock -r fedora-rawhide-x86_64 --init``
|
||||
|
||||
8. Copy the kickstart inside the mock
|
||||
``mock -r fedora-rawhide-x86_64 --copyin ./fedora-minimal.ks /root/``
|
||||
|
||||
9. Copy the Anaconda boot.iso inside the mock
|
||||
``mock -r fedora-rawhide-x86_64 --copyin ./boot.iso /root/``
|
||||
|
||||
10. Make a minimal iso::
|
||||
|
||||
mock -r fedora-rawhide-x86_64 --chroot -- livemedia-creator \
|
||||
--resultdir=/results/try-1 --logfile=/results/logs/try-1/try-1.log \
|
||||
--make-iso --ks /root/fedora-minimal.ks --iso /root/boot.iso
|
||||
|
||||
Results will be in ./results/try-1 and logs under /results/logs/try-1/
|
||||
including anaconda logs and livemedia-creator logs. The new iso will be
|
||||
located at ~/results/try-1/images/boot.iso, and the ~/results/try-1/
|
||||
directory tree will also contain the vmlinuz, initrd, etc.
|
||||
|
||||
This will run qemu without kvm support, which is going to be very slow. You can
|
||||
add ``mknod /dev/kvm c 10 232;`` to create the device node before running lmc.
|
||||
|
||||
|
||||
OpenStack Image Creation
|
||||
------------------------
|
||||
|
||||
OpenStack supports partitioned disk images so ``--make-disk`` can be used to
|
||||
create images for importing into glance, OpenStack's image storage component.
|
||||
You need to have access to an OpenStack provider that allows image uploads, or
|
||||
setup your own using the instructions from the `RDO Project
|
||||
<https://www.rdoproject.org/Quickstart>`_.
|
||||
|
||||
The example kickstart, fedora-openstack.ks, is only slightly different than the
|
||||
fedora-minimal.ks one. It adds the cloud-init and cloud-utils-growpart
|
||||
packages. OpenStack supports setting up the image using cloud-init, and
|
||||
cloud-utils-growpart will grow the image to fit the instance's disk size.
|
||||
|
||||
Create a qcow2 image using the kickstart like this:
|
||||
|
||||
``sudo livemedia-creator --make-disk --iso=/path/to/boot.iso --ks=/path/to/fedora-openstack.ks --image-type=qcow2``
|
||||
|
||||
.. note::
|
||||
On the RHEL7 version of lmc ``--image-type`` isn't supported. You can only create a bare partitioned disk image.
|
||||
|
||||
Import the resulting disk image into the OpenStack system, either via the web UI, or glance on the cmdline::
|
||||
|
||||
glance image-create --name "fedora-openstack" --is-public true --disk-format qcow2 \
|
||||
--container-format bare --file ./fedora-openstack.qcow2
|
||||
|
||||
If qcow2 wasn't used then ``--disk-format`` should be set to raw.
|
||||
|
||||
|
||||
Docker Image Creation
|
||||
---------------------
|
||||
|
||||
Use lmc to create a tarfile as described in the `TAR File Creation`_ section, but substitute the
|
||||
fedora-docker.ks example kickstart which removes the requirement for core files and the kernel.
|
||||
|
||||
You can then import the tarfile into docker like this (as root):
|
||||
|
||||
``cat /var/tmp/fedora-root.tar.xz | docker import - fedora-root``
|
||||
|
||||
And then run bash inside of it:
|
||||
|
||||
``sudo docker run -i -t fedora-root /bin/bash``
|
||||
|
||||
|
||||
Open Container Initiative Image Creation
|
||||
----------------------------------------
|
||||
|
||||
The OCI is a new specification that is still being worked on. You can read more about it at
|
||||
`the Open Container Initiative website <https://www.opencontainers.org/>`_. You can create
|
||||
OCI images using the following command::
|
||||
|
||||
sudo livemedia-creator --make-oci --oci-config /path/to/config.json --oci-runtime /path/to/runtime.json \
|
||||
--iso=/path/to/boot.iso --ks=/path/to/fedora-minimal.ks
|
||||
|
||||
You must provide the config.json and runtime.json files to be included in the bundle,
|
||||
their specifications can be found `on the OCI github project <https://github.com/opencontainers/specs>`_
|
||||
output will be in the results directory with a default name of bundle.tar.xz
|
||||
|
||||
This will work with ``--no-virt`` and inside a mock since it doesn't use any
|
||||
partitioned disk images.
|
||||
|
||||
|
||||
Vagrant Image Creation
|
||||
----------------------
|
||||
|
||||
`Vagrant <https://www.vagrantup.com/>`_ images can be created using the following command::
|
||||
|
||||
sudo livemedia-creator --make-vagrant --vagrant-metadata /path/to/metadata.json \
|
||||
--iso=/path/to/boot.iso --ks=/path/to/fedora-vagrant.ks
|
||||
|
||||
The image created is a `vagrant-libvirt
|
||||
<https://github.com/pradels/vagrant-libvirt>`_ provider image and needs to have
|
||||
vagrant setup with libvirt before you can use it.
|
||||
|
||||
The ``--vagrant-metadata`` file is optional, it will create a minimal one by
|
||||
default, and if one is passed it will make sure the disk size is setup
|
||||
correctly. If you pass a ``--vagrant-vagrantfile`` it will be included in the
|
||||
image verbatim. By default no vagrantfile is created.
|
||||
|
||||
There is an example Vagrant kickstart file in the docs directory that sets up
|
||||
the vagrant user with the default insecure SSH pubkey and a few useful
|
||||
utilities.
|
||||
|
||||
This also works with ``--no-virt``, but will not work inside a mock due to its
|
||||
use of partitioned disk images and qcow2.
|
||||
|
||||
|
||||
Creating UEFI disk images with virt
|
||||
-----------------------------------
|
||||
|
||||
Partitioned disk images can only be created for the same platform as the host system (BIOS or
|
||||
UEFI). You can use virt to create BIOS images on UEFI systems, and it is also possible
|
||||
to create UEFI images on BIOS systems using OVMF. You first need to setup your system with
|
||||
the OVMF firmware. The details can be `found here linux-kvm OVMF page <http://www.linux-kvm.org/page/OVMF>`_
|
||||
but it amounts to:
|
||||
|
||||
1. Download the firmware.repo from `Gerd Hoffmann <https://www.kraxel.org/repos/>`_ and install it
|
||||
in /etc/yum.repos.d/
|
||||
|
||||
2. Install the edk2.git-ovmf-x64 package
|
||||
|
||||
3. Copy /usr/share/edk2.git/ovmf-x64/OVMF_CODE-pure-efi.fd to /usr/share/OVMF/OVMF_CODE.fd
|
||||
|
||||
4. Copy /usr/share/edk2.git/ovmf-x64/OVMF_VARS-pure-efi.fd to /usr/share/OVMF/OVMF_VARS.fd
|
||||
|
||||
Now you can run livemedia-creator with ``--virt-uefi`` to boot and install using UEFI::
|
||||
|
||||
sudo livemedia-creator --make-disk --virt-uefi --iso=/path/to/boot.iso \
|
||||
--ks=/path/to/fedora-minimal.ks
|
||||
|
||||
Make sure that the kickstart you are using creates a /boot/efi partition by including this::
|
||||
|
||||
part /boot/efi --fstype="efi" --size=500
|
||||
|
||||
.. note::
|
||||
When using the resulting image with the current version of OVMF (edk2.git-ovmf-x64-0-20151103.b1295.ge5cffca)
|
||||
it will not boot automatically because there is a problem with the fallback path.
|
||||
You can boot it by entering the UEFI shell and running EFI/fedora/shim.efi and
|
||||
then using efibootmgr to setup the correct boot entry.
|
||||
|
||||
|
||||
Debugging problems
|
||||
------------------
|
||||
|
||||
Sometimes an installation will get stuck. When using qemu the logs will
|
||||
be written to ./virt-install.log and most of the time any problems that happen
|
||||
will be near the end of the file. lmc tries to detect common errors and will
|
||||
cancel the installation when they happen. But not everything can be caught.
|
||||
When creating a new kickstart it is helpful to use vnc so that you can monitor
|
||||
the installation as it happens, and if it gets stuck without lmc detecting the
|
||||
problem you can switch to tty1 and examine the system directly.
|
||||
|
||||
If it does get stuck the best way to cancel is to use kill -9 on the qemu pid,
|
||||
lmc will detect that the process died and cleanup.
|
||||
|
||||
If lmc didn't handle the cleanup for some reason you can do this:
|
||||
1. ``sudo umount /tmp/lmc-XXXX`` to unmount the iso from its mountpoint.
|
||||
2. ``sudo rm -rf /tmp/lmc-XXXX``
|
||||
3. ``sudo rm /var/tmp/lmc-disk-XXXXX`` to remove the disk image.
|
||||
|
||||
Note that lmc uses the lmc- prefix for all of its temporary files and
|
||||
directories to make it easier to find and clean up leftovers.
|
||||
|
||||
The logs from the qemu run are stored in virt-install.log, logs from
|
||||
livemedia-creator are in livemedia.log and program.log
|
||||
|
||||
You can add ``--image-only`` to skip the .iso creation and examine the resulting
|
||||
disk image. Or you can pass ``--keep-image`` to keep it around after the iso has
|
||||
been created.
|
||||
|
||||
Cleaning up aborted ``--no-virt`` installs can sometimes be accomplished by
|
||||
running the ``anaconda-cleanup`` script. As of Fedora 18 anaconda is
|
||||
multi-threaded and it can sometimes become stuck and refuse to exit. When this
|
||||
happens you can usually clean up by first killing the anaconda process then
|
||||
running ``anaconda-cleanup``.
|
||||
|
||||
|
||||
Hacking
|
||||
-------
|
||||
|
||||
Development on this will take place as part of the lorax project, and on the
|
||||
anaconda-devel-list mailing list, and `on github <https://github.com/rhinstaller/lorax>`_
|
||||
|
||||
Feedback, enhancements and bugs are welcome. You can use `bugzilla
|
||||
<https://bugzilla.redhat.com/enter_bug.cgi?product=Fedora&component=lorax>`_ to
|
||||
report bugs against the lorax component.
|
||||
|
@ -23,6 +23,16 @@ lorax cmdline arguments
|
||||
:ref: pylorax.cmdline.lorax_parser
|
||||
:prog: lorax
|
||||
|
||||
--macboot : @replace
|
||||
Make the iso bootable on UEFI based Mac systems
|
||||
|
||||
Default: True
|
||||
|
||||
--nomacboot : @replace
|
||||
Do not create a Mac bootable iso
|
||||
|
||||
Default: False
|
||||
|
||||
|
||||
Quickstart
|
||||
----------
|
||||
@ -41,14 +51,52 @@ You can add your own repos with ``-s`` and packages with higher NVRs will
|
||||
override the ones in the distribution repositories.
|
||||
|
||||
Under ``./results/`` will be the release tree files: .discinfo, .treeinfo, everything that
|
||||
goes onto the boot.iso, the pxeboot directory, and the boot.iso under ``./images/``.
|
||||
goes onto the boot.iso, the pxeboot directory, and the boot.iso under ``./results/images/``.
|
||||
|
||||
|
||||
Branding
|
||||
--------
|
||||
|
||||
By default lorax will search for the first package that provides ``system-release``
|
||||
that doesn't start with ``generic-`` and will install it. It then selects a
|
||||
corresponding logo package by using the first part of the system-release package and
|
||||
appending ``-logos`` to it. eg. fedora-release and fedora-logos.
|
||||
|
||||
Variants
|
||||
~~~~~~~~
|
||||
|
||||
If a ``variant`` is passed to lorax it will select a ``system-release`` package that
|
||||
ends with the variant name. eg. Passing ``--variant workstation`` will select the
|
||||
``fedora-release-workstation`` package if it exists. It will select a logo package
|
||||
the same way it does for non-variants. eg. ``fedora-logos``.
|
||||
|
||||
If there is no package ending with the variant name it will fall back to using the
|
||||
first non-generic package providing ``system-release``.
|
||||
|
||||
Custom Branding
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
If ``--skip-branding`` is passed to lorax it will skip selecting the
|
||||
``system-release``, and logos packages and leave it up to the user to pass any
|
||||
branding related packages to lorax using ``--installpkgs``. When using
|
||||
``skip-branding`` you must make sure that you provide all of the expected files,
|
||||
otherwise Anaconda may not work as expected. See the contents of ``fedora-release``
|
||||
and ``fedora-logos`` for examples of what to include.
|
||||
|
||||
Note that this does not prevent something else in the dependency tree from
|
||||
causing these packages to be included. Using ``--excludepkgs`` may help if they
|
||||
are unexpectedly included.
|
||||
|
||||
|
||||
Running inside of mock
|
||||
----------------------
|
||||
|
||||
If you are using lorax with mock v1.3.4 or later you will need to pass
|
||||
``--old-chroot`` to mock. Mock now defaults to using systemd-nspawn which cannot
|
||||
As of mock version 2.0 you no longer need to pass ``--old-chroot``. You will,
|
||||
however, need to pass ``--enable-network`` so that the mock container can download
|
||||
packages.
|
||||
|
||||
Older versions of mock, between 1.3.4 and 2.0, will need to pass ``--old-chroot``
|
||||
to mock. These versions of mock default to using systemd-nspawn which cannot
|
||||
create the needed loop device nodes. Passing ``--old-chroot`` will use the old
|
||||
system where ``/dev/loop*`` is setup for you.
|
||||
|
||||
@ -92,7 +140,6 @@ installation. A number of template commands are used here:
|
||||
|
||||
* :func:`append <pylorax.ltmpl.LoraxTemplateRunner.append>` to add text to a file.
|
||||
* :func:`chmod <pylorax.ltmpl.LoraxTemplateRunner.chmod>` changes the file's mode.
|
||||
* :func:`gconfset <pylorax.ltmpl.LoraxTemplateRunner.gconfset>` runs gconfset.
|
||||
* :func:`install <pylorax.ltmpl.LoraxTemplateRunner.install>` to install a file into the installroot.
|
||||
* :func:`mkdir <pylorax.ltmpl.LoraxTemplateRunner.mkdir>` makes a new directory.
|
||||
* :func:`move <pylorax.ltmpl.LoraxTemplateRunner.move>` to move a file into the installroot
|
||||
@ -138,7 +185,7 @@ on the architecture that the iso is being created for. They are also stored in
|
||||
configuration template files, configuration variable substitution, treeinfo
|
||||
metadata (via the :func:`treeinfo <pylorax.ltmpl.LoraxTemplateRunner.treeinfo>`
|
||||
template command). Kernel and initrd are copied from the installroot to their
|
||||
final locations and then mkisofs is run to create the boot.iso
|
||||
final locations and then xorrisofs is run to create the boot.iso
|
||||
|
||||
|
||||
Custom Templates
|
||||
|
@ -1,144 +0,0 @@
|
||||
Lorax
|
||||
=====
|
||||
|
||||
:Authors:
|
||||
Brian C. Lane <bcl@redhat.com>
|
||||
|
||||
"I am the Lorax. I speak for the trees [and images]."
|
||||
|
||||
The `lorax <https://github.com/rhinstaller/lorax>`_ tool is used to create the
|
||||
`Anaconda <https://github.com/rhinstaller/anaconda>`_ installer boot.iso as
|
||||
well as the basic release tree, and .treeinfo metadata file. Its dependencies
|
||||
are fairly light-weight because it needs to be able to run in a mock chroot
|
||||
environment. It is best to run lorax from the same release as is being targeted
|
||||
because the templates may have release specific logic in them. eg. Use the
|
||||
rawhide version to build the boot.iso for rawhide, along with the rawhide
|
||||
repositories.
|
||||
|
||||
|
||||
lorax cmdline arguments
|
||||
-----------------------
|
||||
|
||||
.. argparse::
|
||||
:ref: pylorax.cmdline.lorax_parser
|
||||
:prog: lorax
|
||||
|
||||
|
||||
Quickstart
|
||||
----------
|
||||
|
||||
Run this as root to create a boot.iso in ``./results/``::
|
||||
|
||||
dnf install lorax
|
||||
setenforce 0
|
||||
lorax -p Fedora -v 23 -r 23 \
|
||||
-s http://dl.fedoraproject.org/pub/fedora/linux/releases/23/Everything/x86_64/os/ \
|
||||
-s http://dl.fedoraproject.org/pub/fedora/linux/updates/23/x86_64/ \
|
||||
./results/
|
||||
setenforce 1
|
||||
|
||||
You can add your own repos with ``-s`` and packages with higher NVRs will
|
||||
override the ones in the distribution repositories.
|
||||
|
||||
Under ``./results/`` will be the release tree files: .discinfo, .treeinfo, everything that
|
||||
goes onto the boot.iso, the pxeboot directory, and the boot.iso under ``./images/``.
|
||||
|
||||
|
||||
How it works
|
||||
------------
|
||||
|
||||
Lorax uses `dnf <https://github.com/rpm-software-management/dnf>`_ to install
|
||||
packages into a temporary directory, sets up configuration files, it then
|
||||
removes unneeded files to save space, and creates a squashfs filesystem of the
|
||||
files. The iso is then built using a generic initramfs and the kernel from the
|
||||
selected repositories.
|
||||
|
||||
To drive these processes Lorax uses a custom template system, based on `Mako
|
||||
templates <http://www.makotemplates.org/>`_ with the addition of custom
|
||||
commands (documented in :class:`pylorax.ltmpl.LoraxTemplateRunner`). Mako
|
||||
supports ``%if/%endif`` blocks as well as free-form python code inside ``<%
|
||||
%>`` tags and variable substitution with ``${}``. The default templates are
|
||||
shipped with lorax in ``/usr/share/lorax/templates.d/99-generic/`` and use the
|
||||
``.tmpl`` extension.
|
||||
|
||||
|
||||
runtime-install.tmpl
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The ``runtime-install.tmpl`` template lists packages to be installed using the
|
||||
``installpkg`` command. This template is fairly simple, installing common packages and
|
||||
architecture specific packages. It must end with the ``run_pkg_transaction``
|
||||
command which tells dnf to download and install the packages.
|
||||
|
||||
|
||||
runtime-postinstall.tmpl
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The ``runtime-postinstall.tmpl`` template is where the system configuration
|
||||
happens. The installer environment is similar to a normal running system, but
|
||||
needs some special handling. Configuration files are setup, systemd is told to
|
||||
start the anaconda.target instead of a default system target, and a number of
|
||||
unneeded services are disabled, some of which can interfere with the
|
||||
installation. A number of template commands are used here:
|
||||
|
||||
* :func:`append <pylorax.ltmpl.LoraxTemplateRunner.append>` to add text to a file.
|
||||
* :func:`chmod <pylorax.ltmpl.LoraxTemplateRunner.chmod>` changes the file's mode.
|
||||
* :func:`gconfset <pylorax.ltmpl.LoraxTemplateRunner.gconfset>` runs gconfset.
|
||||
* :func:`install <pylorax.ltmpl.LoraxTemplateRunner.install>` to install a file into the installroot.
|
||||
* :func:`mkdir <pylorax.ltmpl.LoraxTemplateRunner.mkdir>` makes a new directory.
|
||||
* :func:`move <pylorax.ltmpl.LoraxTemplateRunner.move>` to move a file into the installroot
|
||||
* :func:`replace <pylorax.ltmpl.LoraxTemplateRunner.replace>` does text substitution in a file
|
||||
* :func:`remove <pylorax.ltmpl.LoraxTemplateRunner.remove>` deletes a file
|
||||
* :func:`runcmd <pylorax.ltmpl.LoraxTemplateRunner.runcmd>` run arbitrary commands.
|
||||
* :func:`symlink <pylorax.ltmpl.LoraxTemplateRunner.symlink>` creates a symlink
|
||||
* :func:`systemctl <pylorax.ltmpl.LoraxTemplateRunner.systemctl>` runs systemctl in the installroot
|
||||
|
||||
|
||||
runtime-cleanup.tmpl
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The ``runtime-cleanup.tmpl`` template is used to remove files that aren't strictly needed
|
||||
by the installation environment. In addition to the ``remove`` template command it uses:
|
||||
|
||||
* :func:`removepkg <pylorax.ltmpl.LoraxTemplateRunner.removepkg>`
|
||||
remove all of a specific package's contents. A package may be pulled in as a dependency, but
|
||||
not really used. eg. sound support.
|
||||
* :func:`removefrom <pylorax.ltmpl.LoraxTemplateRunner.removefrom>`
|
||||
Removes some files from a package. A file glob can be used, or the --allbut option to
|
||||
remove everything except a select few.
|
||||
* :func:`removekmod <pylorax.ltmpl.LoraxTemplateRunner.removekmod>`
|
||||
Removes kernel modules
|
||||
|
||||
|
||||
The squashfs filesystem
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
After ``runtime-*.tmpl`` templates have finished their work lorax creates an
|
||||
empty ext4 filesystem, copies the remaining files to it, and makes a squashfs
|
||||
filesystem of it. This file is the / of the boot.iso's installer environment
|
||||
and is what is in the LiveOS/squashfs.img file on the iso.
|
||||
|
||||
|
||||
iso creation
|
||||
~~~~~~~~~~~~
|
||||
|
||||
The iso creation is handled by another set of templates. The one used depends
|
||||
on the architecture that the iso is being created for. They are also stored in
|
||||
``/usr/share/lorax/templates.d/99-generic`` and are named after the arch, like
|
||||
``x86.tmpl`` and ``aarch64.tmpl``. They handle creation of the tree, copying
|
||||
configuration template files, configuration variable substitution, treeinfo
|
||||
metadata (via the :func:`treeinfo <pylorax.ltmpl.LoraxTemplateRunner.treeinfo>`
|
||||
template command). Kernel and initrd are copied from the installroot to their
|
||||
final locations and then mkisofs is run to create the boot.iso
|
||||
|
||||
|
||||
Custom Templates
|
||||
----------------
|
||||
|
||||
The default set of templates and configuration files from the lorax-generic-templates package
|
||||
are shipped in the ``/usr/share/lorax/templates.d/99-generic/`` directory. You can
|
||||
make a copy of them and place them into another directory under ``templates.d``
|
||||
and they will be used instead if their sort order is below all other directories. This
|
||||
allows multiple packages to ship lorax templates without conflict. You can (and probably
|
||||
should) select the specific template directory by passing ``--sharedir`` to lorax.
|
||||
|
131
docs/html/_sources/mkksiso.rst.txt
Normal file
@ -0,0 +1,131 @@
|
||||
mkksiso
|
||||
=======
|
||||
|
||||
:Authors:
|
||||
Brian C. Lane <bcl@redhat.com>
|
||||
|
||||
``mkksiso`` is a tool for creating kickstart boot isos. In it's simplest form
|
||||
you can add a kickstart to a boot.iso and the kickstart will be executed when
|
||||
the iso is booted. If the original iso was created with EFI and Mac support the
|
||||
kickstart boot.iso will include this support as well.
|
||||
|
||||
``mkksiso`` needs to be run as root, it depends on mounting the original iso
|
||||
and you need to be root to be able to do that. The host system architecture
|
||||
needs to match that of the iso. ``mkksiso`` will raise an error if it finds a
|
||||
.discinfo on the iso with a mismatched arch.
|
||||
|
||||
|
||||
mkksiso cmdline arguments
|
||||
-------------------------
|
||||
|
||||
Add a kickstart and files to an iso
|
||||
|
||||
``usage: mkksiso [-h] [-a ADD_PATHS] [-c CMDLINE] [--debug] ks input_iso output_iso``
|
||||
|
||||
Optional arguments
|
||||
^^^^^^^^^^^^^^^^^^
|
||||
|
||||
-h, --help show this help message and exit
|
||||
-a ADD_PATHS, --add ADD_PATHS
|
||||
File or directory to add to ISO (may be used multiple
|
||||
times)
|
||||
-c CMDLINE, --cmdline CMDLINE
|
||||
Arguments to add to kernel cmdline
|
||||
--debug print debugging info
|
||||
-V VOLID, --volid VOLID
|
||||
Set the ISO volume id, defaults to input's
|
||||
|
||||
Positional arguments
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
:ks: Kickstart to add to the ISO
|
||||
|
||||
:input_iso: ISO to modify
|
||||
|
||||
:output_iso: Full pathname of iso to be created
|
||||
|
||||
|
||||
Create a kickstart boot.iso or DVD
|
||||
----------------------------------
|
||||
|
||||
Create a kickstart like you normally would, kickstart documentation can be
|
||||
`found here <https://pykickstart.readthedocs.io/en/latest/>`_, including the
|
||||
``url`` and ``repo`` commands. If you are creating a DVD and only need the
|
||||
content on the DVD you can use the ``cdrom`` command to install without a
|
||||
network connection. Then run ``mkksiso`` like this::
|
||||
|
||||
mkksiso /PATH/TO/KICKSTART /PATH/TO/ISO /PATH/TO/NEW-ISO
|
||||
|
||||
This will create a new iso with the kickstart in the root directory, and the
|
||||
kernel cmdline will have ``inst.ks=...`` added to it so that it will be
|
||||
executed when the iso is booted (be careful not to boot on a system you don't
|
||||
want to wipe out! There will be no prompting).
|
||||
|
||||
By default the volume id of the iso is preserved. You can set a custom volid
|
||||
by passing ``-V`` and the string to set. The kernel cmdline will be changes, and the iso will have th custom volume id.
|
||||
eg.::
|
||||
|
||||
mkksiso -V "Test Only" /PATH/TO/KICKSTART /PATH/TO/ISO /PATH/TO/NEW-ISO
|
||||
|
||||
|
||||
Adding package repos to a boot.iso
|
||||
----------------------------------
|
||||
|
||||
You can add repo directories to the iso using ``--add /PATH/TO/REPO/``, make
|
||||
sure it contains the ``repodata`` directory by running ``createrepo_c`` on it
|
||||
first. In the kickstart you can refer to the directories (and files) on the iso
|
||||
using ``file:///run/install/repo/DIRECTORY/``. You can then use these repos in
|
||||
the kickstart like this::
|
||||
|
||||
repo --name=extra-repo --baseurl=file:///run/install/repo/extra-repo/
|
||||
|
||||
Run ``mkksiso`` like so::
|
||||
|
||||
mkksiso --add /PATH/TO/REPO/ /PATH/TO/KICKSTART /PATH/TO/ISO /PATH/TO/NEW-ISO
|
||||
|
||||
|
||||
Create a liveimg boot.iso
|
||||
-------------------------
|
||||
|
||||
You can use the kickstart `liveimg command
|
||||
<https://pykickstart.readthedocs.io/en/latest/kickstart-docs.html#liveimg>`_,
|
||||
to install a pre-generated disk image or tar to the system the iso is booting
|
||||
on.
|
||||
|
||||
Create a disk image or tar with ``osbuild-composer`` or ``livemedia-creator``,
|
||||
make sure the image includes tools expected by ``anaconda``, as well as the
|
||||
kernel and bootloader support. In ``osbuild-composer`` use the ``tar`` image
|
||||
type and make sure to include the ``kernel``, ``grub2``, and ``grub2-tools``
|
||||
packages. If you plan to install it to a UEFI machine make sure to include
|
||||
``grub2-efi`` and ``efibootmgr`` in the blueprint.
|
||||
|
||||
Add the ``root.tar.xz`` file to the iso using ``--add /PATH/TO/ROOT.TAR.XZ``,
|
||||
and in the kickstart reference it with the ``liveimg`` command like this::
|
||||
|
||||
liveimg --url=file:///run/install/repo/root.tar.xz
|
||||
|
||||
It is also a good idea to use the ``--checksum`` argument to ``liveimg`` to be
|
||||
sure the file hasn't been corrupted::
|
||||
|
||||
mkksiso --add /PATH/TO/root.tar.xz /PATH/TO/KICKSTART /PATH/TO/ISO /PATH/TO/NEW-ISO
|
||||
|
||||
When this iso is booted it will execute the kickstart and install the liveimg
|
||||
contents to the system without any prompting.
|
||||
|
||||
|
||||
How it works
|
||||
------------
|
||||
|
||||
``mkksiso`` first examines the system to make sure the tools it needs are installed,
|
||||
it will work with ``xorrisofs`` or ``mkisofs`` installed. It mounts the source iso,
|
||||
and copies the directories that need to be modified to a temporary directory.
|
||||
|
||||
It then modifies the boot configuration files to include the ``inst.ks`` command,
|
||||
and checks to see if the original iso supports EFI. If it does it regenerates the
|
||||
EFI boot images with the new configuration, and then runs the available iso creation
|
||||
tool to add the new files and directories to the new iso. If the architecture is
|
||||
``x86_64`` it will also make sure the iso can be booted as an iso or from a USB
|
||||
stick (hybridiso).
|
||||
|
||||
The last step is to update the iso checksums so that booting with test enabled
|
||||
will pass.
|
@ -1,5 +1,5 @@
|
||||
pylorax
|
||||
=======
|
||||
src
|
||||
===
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 4
|
||||
|
@ -1,7 +0,0 @@
|
||||
pylorax
|
||||
=======
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 4
|
||||
|
||||
pylorax
|
@ -1,27 +0,0 @@
|
||||
Product and Updates Images
|
||||
==========================
|
||||
|
||||
Lorax now supports creation of product.img and updates.img as part of the build
|
||||
process. This is implemented using the installimg template command which will
|
||||
take the contents of a directory and create a compressed archive from it. The
|
||||
directory must be created by one of the packages installed by
|
||||
runtime-install.tmpl or by passing ``--installpkgs <pkgname>`` to lorax at
|
||||
runtime. The x86, ppc, ppc64le and aarch64 templates all look for
|
||||
/usr/share/lorax/product/ and /usr/share/lorax/updates/ directories in the
|
||||
install chroot while creating the final install tree. If there are files in
|
||||
those directories lorax will create images/product.img and/or
|
||||
images/updates.img
|
||||
|
||||
These archives are just like an anaconda updates image -- their contents are
|
||||
copied over the top of the filesystem at boot time so that you can drop in
|
||||
files to add to or replace anything on the filesystem.
|
||||
|
||||
Anaconda has several places that it looks for updates, the one for product.img
|
||||
is in /run/install/product. So for example, to add an installclass to Anaconda
|
||||
you would put your custom class here:
|
||||
|
||||
``/usr/share/lorax/product/run/install/product/pyanaconda/installclasses/custom.py``
|
||||
|
||||
If the packages containing the product/updates files are not included as part
|
||||
of normal dependencies you can add specific packages with the ``--installpkgs``
|
||||
command or the installpkgs paramater of :class:`pylorax.treebuilder.RuntimeBuilder`
|
@ -4,127 +4,150 @@ pylorax package
|
||||
Submodules
|
||||
----------
|
||||
|
||||
pylorax\.base module
|
||||
--------------------
|
||||
pylorax.base module
|
||||
-------------------
|
||||
|
||||
.. automodule:: pylorax.base
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
pylorax\.buildstamp module
|
||||
--------------------------
|
||||
pylorax.buildstamp module
|
||||
-------------------------
|
||||
|
||||
.. automodule:: pylorax.buildstamp
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
pylorax\.cmdline module
|
||||
-----------------------
|
||||
pylorax.cmdline module
|
||||
----------------------
|
||||
|
||||
.. automodule:: pylorax.cmdline
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
pylorax\.decorators module
|
||||
--------------------------
|
||||
pylorax.creator module
|
||||
----------------------
|
||||
|
||||
.. automodule:: pylorax.creator
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
pylorax.decorators module
|
||||
-------------------------
|
||||
|
||||
.. automodule:: pylorax.decorators
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
pylorax\.discinfo module
|
||||
------------------------
|
||||
pylorax.discinfo module
|
||||
-----------------------
|
||||
|
||||
.. automodule:: pylorax.discinfo
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
pylorax\.dnfhelper module
|
||||
-------------------------
|
||||
pylorax.dnfbase module
|
||||
----------------------
|
||||
|
||||
.. automodule:: pylorax.dnfbase
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
pylorax.dnfhelper module
|
||||
------------------------
|
||||
|
||||
.. automodule:: pylorax.dnfhelper
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
pylorax\.executils module
|
||||
-------------------------
|
||||
pylorax.executils module
|
||||
------------------------
|
||||
|
||||
.. automodule:: pylorax.executils
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
pylorax\.imgutils module
|
||||
------------------------
|
||||
pylorax.imgutils module
|
||||
-----------------------
|
||||
|
||||
.. automodule:: pylorax.imgutils
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
pylorax\.ltmpl module
|
||||
---------------------
|
||||
pylorax.installer module
|
||||
------------------------
|
||||
|
||||
.. automodule:: pylorax.installer
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
pylorax.ltmpl module
|
||||
--------------------
|
||||
|
||||
.. automodule:: pylorax.ltmpl
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
pylorax\.monitor module
|
||||
-----------------------
|
||||
pylorax.monitor module
|
||||
----------------------
|
||||
|
||||
.. automodule:: pylorax.monitor
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
pylorax\.mount module
|
||||
---------------------
|
||||
pylorax.mount module
|
||||
--------------------
|
||||
|
||||
.. automodule:: pylorax.mount
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
pylorax\.output module
|
||||
----------------------
|
||||
pylorax.output module
|
||||
---------------------
|
||||
|
||||
.. automodule:: pylorax.output
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
pylorax\.sysutils module
|
||||
------------------------
|
||||
pylorax.sysutils module
|
||||
-----------------------
|
||||
|
||||
.. automodule:: pylorax.sysutils
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
pylorax\.treebuilder module
|
||||
---------------------------
|
||||
pylorax.treebuilder module
|
||||
--------------------------
|
||||
|
||||
.. automodule:: pylorax.treebuilder
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
pylorax\.treeinfo module
|
||||
------------------------
|
||||
pylorax.treeinfo module
|
||||
-----------------------
|
||||
|
||||
.. automodule:: pylorax.treeinfo
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
|
||||
Module contents
|
||||
---------------
|
||||
|
||||
|
@ -1,134 +0,0 @@
|
||||
pylorax package
|
||||
===============
|
||||
|
||||
Submodules
|
||||
----------
|
||||
|
||||
pylorax.base module
|
||||
-------------------
|
||||
|
||||
.. automodule:: pylorax.base
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
pylorax.buildstamp module
|
||||
-------------------------
|
||||
|
||||
.. automodule:: pylorax.buildstamp
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
pylorax.cmdline module
|
||||
----------------------
|
||||
|
||||
.. automodule:: pylorax.cmdline
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
pylorax.decorators module
|
||||
-------------------------
|
||||
|
||||
.. automodule:: pylorax.decorators
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
pylorax.discinfo module
|
||||
-----------------------
|
||||
|
||||
.. automodule:: pylorax.discinfo
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
pylorax.dnfhelper module
|
||||
------------------------
|
||||
|
||||
.. automodule:: pylorax.dnfhelper
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
pylorax.executils module
|
||||
------------------------
|
||||
|
||||
.. automodule:: pylorax.executils
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
pylorax.imgutils module
|
||||
-----------------------
|
||||
|
||||
.. automodule:: pylorax.imgutils
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
pylorax.ltmpl module
|
||||
--------------------
|
||||
|
||||
.. automodule:: pylorax.ltmpl
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
pylorax.monitor module
|
||||
----------------------
|
||||
|
||||
.. automodule:: pylorax.monitor
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
pylorax.mount module
|
||||
--------------------
|
||||
|
||||
.. automodule:: pylorax.mount
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
pylorax.output module
|
||||
---------------------
|
||||
|
||||
.. automodule:: pylorax.output
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
pylorax.sysutils module
|
||||
-----------------------
|
||||
|
||||
.. automodule:: pylorax.sysutils
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
pylorax.treebuilder module
|
||||
--------------------------
|
||||
|
||||
.. automodule:: pylorax.treebuilder
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
pylorax.treeinfo module
|
||||
-----------------------
|
||||
|
||||
.. automodule:: pylorax.treeinfo
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
|
||||
Module contents
|
||||
---------------
|
||||
|
||||
.. automodule:: pylorax
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
@ -1,22 +0,0 @@
|
||||
.. lorax documentation master file, created by
|
||||
sphinx-quickstart on Mon May 11 15:06:14 2015.
|
||||
You can adapt this file completely to your liking, but it should at least
|
||||
contain the root `toctree` directive.
|
||||
|
||||
Welcome to lorax's documentation!
|
||||
=================================
|
||||
|
||||
Contents:
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
|
||||
|
||||
Indices and tables
|
||||
==================
|
||||
|
||||
* :ref:`genindex`
|
||||
* :ref:`modindex`
|
||||
* :ref:`search`
|
||||
|
Before Width: | Height: | Size: 673 B |
@ -4,7 +4,7 @@
|
||||
*
|
||||
* Sphinx stylesheet -- basic theme.
|
||||
*
|
||||
* :copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS.
|
||||
* :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
* :license: BSD, see LICENSE for details.
|
||||
*
|
||||
*/
|
||||
@ -15,6 +15,12 @@ div.clearer {
|
||||
clear: both;
|
||||
}
|
||||
|
||||
div.section::after {
|
||||
display: block;
|
||||
content: '';
|
||||
clear: left;
|
||||
}
|
||||
|
||||
/* -- relbar ---------------------------------------------------------------- */
|
||||
|
||||
div.related {
|
||||
@ -81,10 +87,26 @@ div.sphinxsidebar input {
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
div.sphinxsidebar #searchbox input[type="text"] {
|
||||
width: 170px;
|
||||
div.sphinxsidebar #searchbox form.search {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
div.sphinxsidebar #searchbox input[type="text"] {
|
||||
float: left;
|
||||
width: 80%;
|
||||
padding: 0.25em;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
div.sphinxsidebar #searchbox input[type="submit"] {
|
||||
float: left;
|
||||
width: 20%;
|
||||
border-left: none;
|
||||
padding: 0.25em;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
|
||||
img {
|
||||
border: 0;
|
||||
max-width: 100%;
|
||||
@ -108,7 +130,7 @@ ul.search li a {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
ul.search li div.context {
|
||||
ul.search li p.context {
|
||||
color: #888;
|
||||
margin: 2px 0 0 30px;
|
||||
text-align: left;
|
||||
@ -199,6 +221,11 @@ table.modindextable td {
|
||||
|
||||
/* -- general body styles --------------------------------------------------- */
|
||||
|
||||
div.body {
|
||||
min-width: 450px;
|
||||
max-width: 800px;
|
||||
}
|
||||
|
||||
div.body p, div.body dd, div.body li, div.body blockquote {
|
||||
-moz-hyphens: auto;
|
||||
-ms-hyphens: auto;
|
||||
@ -210,6 +237,16 @@ a.headerlink {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
a.brackets:before,
|
||||
span.brackets > a:before{
|
||||
content: "[";
|
||||
}
|
||||
|
||||
a.brackets:after,
|
||||
span.brackets > a:after {
|
||||
content: "]";
|
||||
}
|
||||
|
||||
h1:hover > a.headerlink,
|
||||
h2:hover > a.headerlink,
|
||||
h3:hover > a.headerlink,
|
||||
@ -240,19 +277,25 @@ p.rubric {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
img.align-left, .figure.align-left, object.align-left {
|
||||
img.align-left, figure.align-left, .figure.align-left, object.align-left {
|
||||
clear: left;
|
||||
float: left;
|
||||
margin-right: 1em;
|
||||
}
|
||||
|
||||
img.align-right, .figure.align-right, object.align-right {
|
||||
img.align-right, figure.align-right, .figure.align-right, object.align-right {
|
||||
clear: right;
|
||||
float: right;
|
||||
margin-left: 1em;
|
||||
}
|
||||
|
||||
img.align-center, .figure.align-center, object.align-center {
|
||||
img.align-center, figure.align-center, .figure.align-center, object.align-center {
|
||||
display: block;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
img.align-default, figure.align-default, .figure.align-default {
|
||||
display: block;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
@ -266,30 +309,41 @@ img.align-center, .figure.align-center, object.align-center {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.align-default {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.align-right {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
/* -- sidebars -------------------------------------------------------------- */
|
||||
|
||||
div.sidebar {
|
||||
div.sidebar,
|
||||
aside.sidebar {
|
||||
margin: 0 0 0.5em 1em;
|
||||
border: 1px solid #ddb;
|
||||
padding: 7px 7px 0 7px;
|
||||
padding: 7px;
|
||||
background-color: #ffe;
|
||||
width: 40%;
|
||||
float: right;
|
||||
clear: right;
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
p.sidebar-title {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
div.admonition, div.topic, blockquote {
|
||||
clear: left;
|
||||
}
|
||||
|
||||
/* -- topics ---------------------------------------------------------------- */
|
||||
|
||||
div.topic {
|
||||
border: 1px solid #ccc;
|
||||
padding: 7px 7px 0 7px;
|
||||
padding: 7px;
|
||||
margin: 10px 0 10px 0;
|
||||
}
|
||||
|
||||
@ -311,10 +365,6 @@ div.admonition dt {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
div.admonition dl {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
p.admonition-title {
|
||||
margin: 0px 10px 5px 0px;
|
||||
font-weight: bold;
|
||||
@ -325,13 +375,44 @@ div.body p.centered {
|
||||
margin-top: 25px;
|
||||
}
|
||||
|
||||
/* -- content of sidebars/topics/admonitions -------------------------------- */
|
||||
|
||||
div.sidebar > :last-child,
|
||||
aside.sidebar > :last-child,
|
||||
div.topic > :last-child,
|
||||
div.admonition > :last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
div.sidebar::after,
|
||||
aside.sidebar::after,
|
||||
div.topic::after,
|
||||
div.admonition::after,
|
||||
blockquote::after {
|
||||
display: block;
|
||||
content: '';
|
||||
clear: both;
|
||||
}
|
||||
|
||||
/* -- tables ---------------------------------------------------------------- */
|
||||
|
||||
table.docutils {
|
||||
margin-top: 10px;
|
||||
margin-bottom: 10px;
|
||||
border: 0;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
table.align-center {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
table.align-default {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
table caption span.caption-number {
|
||||
font-style: italic;
|
||||
}
|
||||
@ -365,22 +446,34 @@ table.citation td {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
th > :first-child,
|
||||
td > :first-child {
|
||||
margin-top: 0px;
|
||||
}
|
||||
|
||||
th > :last-child,
|
||||
td > :last-child {
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
|
||||
/* -- figures --------------------------------------------------------------- */
|
||||
|
||||
div.figure {
|
||||
div.figure, figure {
|
||||
margin: 0.5em;
|
||||
padding: 0.5em;
|
||||
}
|
||||
|
||||
div.figure p.caption {
|
||||
div.figure p.caption, figcaption {
|
||||
padding: 0.3em;
|
||||
}
|
||||
|
||||
div.figure p.caption span.caption-number {
|
||||
div.figure p.caption span.caption-number,
|
||||
figcaption span.caption-number {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
div.figure p.caption span.caption-text {
|
||||
div.figure p.caption span.caption-text,
|
||||
figcaption span.caption-text {
|
||||
}
|
||||
|
||||
/* -- field list styles ----------------------------------------------------- */
|
||||
@ -398,6 +491,81 @@ table.field-list td, table.field-list th {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.field-name {
|
||||
-moz-hyphens: manual;
|
||||
-ms-hyphens: manual;
|
||||
-webkit-hyphens: manual;
|
||||
hyphens: manual;
|
||||
}
|
||||
|
||||
/* -- hlist styles ---------------------------------------------------------- */
|
||||
|
||||
table.hlist {
|
||||
margin: 1em 0;
|
||||
}
|
||||
|
||||
table.hlist td {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
/* -- object description styles --------------------------------------------- */
|
||||
|
||||
.sig {
|
||||
font-family: 'Consolas', 'Menlo', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace;
|
||||
}
|
||||
|
||||
.sig-name, code.descname {
|
||||
background-color: transparent;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.sig-name {
|
||||
font-size: 1.1em;
|
||||
}
|
||||
|
||||
code.descname {
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
.sig-prename, code.descclassname {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.optional {
|
||||
font-size: 1.3em;
|
||||
}
|
||||
|
||||
.sig-paren {
|
||||
font-size: larger;
|
||||
}
|
||||
|
||||
.sig-param.n {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
/* C++ specific styling */
|
||||
|
||||
.sig-inline.c-texpr,
|
||||
.sig-inline.cpp-texpr {
|
||||
font-family: unset;
|
||||
}
|
||||
|
||||
.sig.c .k, .sig.c .kt,
|
||||
.sig.cpp .k, .sig.cpp .kt {
|
||||
color: #0033B3;
|
||||
}
|
||||
|
||||
.sig.c .m,
|
||||
.sig.cpp .m {
|
||||
color: #1750EB;
|
||||
}
|
||||
|
||||
.sig.c .s, .sig.c .sc,
|
||||
.sig.cpp .s, .sig.cpp .sc {
|
||||
color: #067D17;
|
||||
}
|
||||
|
||||
|
||||
/* -- other body styles ----------------------------------------------------- */
|
||||
|
||||
ol.arabic {
|
||||
@ -420,11 +588,78 @@ ol.upperroman {
|
||||
list-style: upper-roman;
|
||||
}
|
||||
|
||||
:not(li) > ol > li:first-child > :first-child,
|
||||
:not(li) > ul > li:first-child > :first-child {
|
||||
margin-top: 0px;
|
||||
}
|
||||
|
||||
:not(li) > ol > li:last-child > :last-child,
|
||||
:not(li) > ul > li:last-child > :last-child {
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
|
||||
ol.simple ol p,
|
||||
ol.simple ul p,
|
||||
ul.simple ol p,
|
||||
ul.simple ul p {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
ol.simple > li:not(:first-child) > p,
|
||||
ul.simple > li:not(:first-child) > p {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
ol.simple p,
|
||||
ul.simple p {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
dl.footnote > dt,
|
||||
dl.citation > dt {
|
||||
float: left;
|
||||
margin-right: 0.5em;
|
||||
}
|
||||
|
||||
dl.footnote > dd,
|
||||
dl.citation > dd {
|
||||
margin-bottom: 0em;
|
||||
}
|
||||
|
||||
dl.footnote > dd:after,
|
||||
dl.citation > dd:after {
|
||||
content: "";
|
||||
clear: both;
|
||||
}
|
||||
|
||||
dl.field-list {
|
||||
display: grid;
|
||||
grid-template-columns: fit-content(30%) auto;
|
||||
}
|
||||
|
||||
dl.field-list > dt {
|
||||
font-weight: bold;
|
||||
word-break: break-word;
|
||||
padding-left: 0.5em;
|
||||
padding-right: 5px;
|
||||
}
|
||||
|
||||
dl.field-list > dt:after {
|
||||
content: ":";
|
||||
}
|
||||
|
||||
dl.field-list > dd {
|
||||
padding-left: 0.5em;
|
||||
margin-top: 0em;
|
||||
margin-left: 0em;
|
||||
margin-bottom: 0em;
|
||||
}
|
||||
|
||||
dl {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
dd p {
|
||||
dd > :first-child {
|
||||
margin-top: 0px;
|
||||
}
|
||||
|
||||
@ -438,23 +673,24 @@ dd {
|
||||
margin-left: 30px;
|
||||
}
|
||||
|
||||
dt:target, .highlighted {
|
||||
dl > dd:last-child,
|
||||
dl > dd:last-child > :last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
dt:target, span.highlighted {
|
||||
background-color: #fbe54e;
|
||||
}
|
||||
|
||||
rect.highlighted {
|
||||
fill: #fbe54e;
|
||||
}
|
||||
|
||||
dl.glossary dt {
|
||||
font-weight: bold;
|
||||
font-size: 1.1em;
|
||||
}
|
||||
|
||||
.optional {
|
||||
font-size: 1.3em;
|
||||
}
|
||||
|
||||
.sig-paren {
|
||||
font-size: larger;
|
||||
}
|
||||
|
||||
.versionmodified {
|
||||
font-style: italic;
|
||||
}
|
||||
@ -493,6 +729,12 @@ dl.glossary dt {
|
||||
font-style: oblique;
|
||||
}
|
||||
|
||||
.classifier:before {
|
||||
font-style: normal;
|
||||
margin: 0.5em;
|
||||
content: ":";
|
||||
}
|
||||
|
||||
abbr, acronym {
|
||||
border-bottom: dotted 1px;
|
||||
cursor: help;
|
||||
@ -505,6 +747,10 @@ pre {
|
||||
overflow-y: hidden; /* fixes display issues on Chrome browsers */
|
||||
}
|
||||
|
||||
pre, div[class*="highlight-"] {
|
||||
clear: both;
|
||||
}
|
||||
|
||||
span.pre {
|
||||
-moz-hyphens: none;
|
||||
-ms-hyphens: none;
|
||||
@ -512,22 +758,57 @@ span.pre {
|
||||
hyphens: none;
|
||||
}
|
||||
|
||||
div[class*="highlight-"] {
|
||||
margin: 1em 0;
|
||||
}
|
||||
|
||||
td.linenos pre {
|
||||
padding: 5px 0px;
|
||||
border: 0;
|
||||
background-color: transparent;
|
||||
color: #aaa;
|
||||
}
|
||||
|
||||
table.highlighttable {
|
||||
margin-left: 0.5em;
|
||||
display: block;
|
||||
}
|
||||
|
||||
table.highlighttable tbody {
|
||||
display: block;
|
||||
}
|
||||
|
||||
table.highlighttable tr {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
table.highlighttable td {
|
||||
padding: 0 0.5em 0 0.5em;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
table.highlighttable td.linenos {
|
||||
padding-right: 0.5em;
|
||||
}
|
||||
|
||||
table.highlighttable td.code {
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.highlight .hll {
|
||||
display: block;
|
||||
}
|
||||
|
||||
div.highlight pre,
|
||||
table.highlighttable pre {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
div.code-block-caption + div {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
div.code-block-caption {
|
||||
margin-top: 1em;
|
||||
padding: 2px 5px;
|
||||
font-size: small;
|
||||
}
|
||||
@ -536,8 +817,14 @@ div.code-block-caption code {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
div.code-block-caption + div > div.highlight > pre {
|
||||
margin-top: 0;
|
||||
table.highlighttable td.linenos,
|
||||
span.linenos,
|
||||
div.highlight span.gp { /* gp: Generic.Prompt */
|
||||
user-select: none;
|
||||
-webkit-user-select: text; /* Safari fallback only */
|
||||
-webkit-user-select: none; /* Chrome/Safari */
|
||||
-moz-user-select: none; /* Firefox */
|
||||
-ms-user-select: none; /* IE10+ */
|
||||
}
|
||||
|
||||
div.code-block-caption span.caption-number {
|
||||
@ -549,21 +836,7 @@ div.code-block-caption span.caption-text {
|
||||
}
|
||||
|
||||
div.literal-block-wrapper {
|
||||
padding: 1em 1em 0;
|
||||
}
|
||||
|
||||
div.literal-block-wrapper div.highlight {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
code.descname {
|
||||
background-color: transparent;
|
||||
font-weight: bold;
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
code.descclassname {
|
||||
background-color: transparent;
|
||||
margin: 1em 0;
|
||||
}
|
||||
|
||||
code.xref, a code {
|
||||
@ -604,8 +877,7 @@ span.eqno {
|
||||
}
|
||||
|
||||
span.eqno a.headerlink {
|
||||
position: relative;
|
||||
left: 0px;
|
||||
position: absolute;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 756 B |
Before Width: | Height: | Size: 829 B |
Before Width: | Height: | Size: 641 B |
@ -1,2 +1 @@
|
||||
.fa:before{-webkit-font-smoothing:antialiased}.clearfix{*zoom:1}.clearfix:before,.clearfix:after{display:table;content:""}.clearfix:after{clear:both}@font-face{font-family:FontAwesome;font-weight:normal;font-style:normal;src:url("../font/fontawesome_webfont.eot");src:url("../font/fontawesome_webfont.eot?#iefix") format("embedded-opentype"),url("../font/fontawesome_webfont.woff") format("woff"),url("../font/fontawesome_webfont.ttf") format("truetype"),url("../font/fontawesome_webfont.svg#FontAwesome") format("svg")}.fa:before{display:inline-block;font-family:FontAwesome;font-style:normal;font-weight:normal;line-height:1;text-decoration:inherit}a .fa{display:inline-block;text-decoration:inherit}li .fa{display:inline-block}li .fa-large:before,li .fa-large:before{width:1.875em}ul.fas{list-style-type:none;margin-left:2em;text-indent:-0.8em}ul.fas li .fa{width:0.8em}ul.fas li .fa-large:before,ul.fas li .fa-large:before{vertical-align:baseline}.fa-book:before{content:""}.icon-book:before{content:""}.fa-caret-down:before{content:""}.icon-caret-down:before{content:""}.fa-caret-up:before{content:""}.icon-caret-up:before{content:""}.fa-caret-left:before{content:""}.icon-caret-left:before{content:""}.fa-caret-right:before{content:""}.icon-caret-right:before{content:""}.rst-versions{position:fixed;bottom:0;left:0;width:300px;color:#fcfcfc;background:#1f1d1d;border-top:solid 10px #343131;font-family:"Lato","proxima-nova","Helvetica Neue",Arial,sans-serif;z-index:400}.rst-versions a{color:#2980B9;text-decoration:none}.rst-versions .rst-badge-small{display:none}.rst-versions .rst-current-version{padding:12px;background-color:#272525;display:block;text-align:right;font-size:90%;cursor:pointer;color:#27AE60;*zoom:1}.rst-versions .rst-current-version:before,.rst-versions .rst-current-version:after{display:table;content:""}.rst-versions .rst-current-version:after{clear:both}.rst-versions .rst-current-version .fa{color:#fcfcfc}.rst-versions .rst-current-version .fa-book{float:left}.rst-versions .rst-current-version .icon-book{float:left}.rst-versions .rst-current-version.rst-out-of-date{background-color:#E74C3C;color:#fff}.rst-versions .rst-current-version.rst-active-old-version{background-color:#F1C40F;color:#000}.rst-versions.shift-up .rst-other-versions{display:block}.rst-versions .rst-other-versions{font-size:90%;padding:12px;color:gray;display:none}.rst-versions .rst-other-versions hr{display:block;height:1px;border:0;margin:20px 0;padding:0;border-top:solid 1px #413d3d}.rst-versions .rst-other-versions dd{display:inline-block;margin:0}.rst-versions .rst-other-versions dd a{display:inline-block;padding:6px;color:#fcfcfc}.rst-versions.rst-badge{width:auto;bottom:20px;right:20px;left:auto;border:none;max-width:300px}.rst-versions.rst-badge .icon-book{float:none}.rst-versions.rst-badge .fa-book{float:none}.rst-versions.rst-badge.shift-up .rst-current-version{text-align:right}.rst-versions.rst-badge.shift-up .rst-current-version .fa-book{float:left}.rst-versions.rst-badge.shift-up .rst-current-version .icon-book{float:left}.rst-versions.rst-badge .rst-current-version{width:auto;height:30px;line-height:30px;padding:0 6px;display:block;text-align:center}@media screen and (max-width: 768px){.rst-versions{width:85%;display:none}.rst-versions.shift{display:block}}
|
||||
/*# sourceMappingURL=badge_only.css.map */
|
||||
.fa:before{-webkit-font-smoothing:antialiased}.clearfix{*zoom:1}.clearfix:after,.clearfix:before{display:table;content:""}.clearfix:after{clear:both}@font-face{font-family:FontAwesome;font-style:normal;font-weight:400;src:local("fontawesome/FontAwesome") format("truetype")}.fa:before{font-family:FontAwesome;font-style:normal;font-weight:400;line-height:1}.fa:before,a .fa{text-decoration:inherit}.fa:before,a .fa,li .fa{display:inline-block}li .fa-large:before{width:1.875em}ul.fas{list-style-type:none;margin-left:2em;text-indent:-.8em}ul.fas li .fa{width:.8em}ul.fas li .fa-large:before{vertical-align:baseline}.fa-book:before,.icon-book:before{content:"\f02d"}.fa-caret-down:before,.icon-caret-down:before{content:"\f0d7"}.fa-caret-up:before,.icon-caret-up:before{content:"\f0d8"}.fa-caret-left:before,.icon-caret-left:before{content:"\f0d9"}.fa-caret-right:before,.icon-caret-right:before{content:"\f0da"}.rst-versions{position:fixed;bottom:0;left:0;width:300px;color:#fcfcfc;background:#1f1d1d;font-family:Lato,proxima-nova,Helvetica Neue,Arial,sans-serif;z-index:400}.rst-versions a{color:#2980b9;text-decoration:none}.rst-versions .rst-badge-small{display:none}.rst-versions .rst-current-version{padding:12px;background-color:#272525;display:block;text-align:right;font-size:90%;cursor:pointer;color:#27ae60}.rst-versions .rst-current-version:after{clear:both;content:"";display:block}.rst-versions .rst-current-version .fa{color:#fcfcfc}.rst-versions .rst-current-version .fa-book,.rst-versions .rst-current-version .icon-book{float:left}.rst-versions .rst-current-version.rst-out-of-date{background-color:#e74c3c;color:#fff}.rst-versions .rst-current-version.rst-active-old-version{background-color:#f1c40f;color:#000}.rst-versions.shift-up{height:auto;max-height:100%;overflow-y:scroll}.rst-versions.shift-up .rst-other-versions{display:block}.rst-versions .rst-other-versions{font-size:90%;padding:12px;color:grey;display:none}.rst-versions .rst-other-versions hr{display:block;height:1px;border:0;margin:20px 0;padding:0;border-top:1px solid #413d3d}.rst-versions .rst-other-versions dd{display:inline-block;margin:0}.rst-versions .rst-other-versions dd a{display:inline-block;padding:6px;color:#fcfcfc}.rst-versions.rst-badge{width:auto;bottom:20px;right:20px;left:auto;border:none;max-width:300px;max-height:90%}.rst-versions.rst-badge .fa-book,.rst-versions.rst-badge .icon-book{float:none;line-height:30px}.rst-versions.rst-badge.shift-up .rst-current-version{text-align:right}.rst-versions.rst-badge.shift-up .rst-current-version .fa-book,.rst-versions.rst-badge.shift-up .rst-current-version .icon-book{float:left}.rst-versions.rst-badge>.rst-current-version{width:auto;height:30px;line-height:30px;padding:0 6px;display:block;text-align:center}@media screen and (max-width:768px){.rst-versions{width:85%;display:none}.rst-versions.shift{display:block}}
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* Sphinx JavaScript utilities for all documentation.
|
||||
*
|
||||
* :copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS.
|
||||
* :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
* :license: BSD, see LICENSE for details.
|
||||
*
|
||||
*/
|
||||
@ -29,9 +29,14 @@ if (!window.console || !console.firebug) {
|
||||
|
||||
/**
|
||||
* small helper function to urldecode strings
|
||||
*
|
||||
* See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent#Decoding_query_parameters_from_a_URL
|
||||
*/
|
||||
jQuery.urldecode = function(x) {
|
||||
return decodeURIComponent(x).replace(/\+/g, ' ');
|
||||
if (!x) {
|
||||
return x
|
||||
}
|
||||
return decodeURIComponent(x.replace(/\+/g, ' '));
|
||||
};
|
||||
|
||||
/**
|
||||
@ -45,7 +50,7 @@ jQuery.urlencode = encodeURIComponent;
|
||||
* it will always return arrays of strings for the value parts.
|
||||
*/
|
||||
jQuery.getQueryParameters = function(s) {
|
||||
if (typeof s == 'undefined')
|
||||
if (typeof s === 'undefined')
|
||||
s = document.location.search;
|
||||
var parts = s.substr(s.indexOf('?') + 1).split('&');
|
||||
var result = {};
|
||||
@ -66,29 +71,54 @@ jQuery.getQueryParameters = function(s) {
|
||||
* span elements with the given class name.
|
||||
*/
|
||||
jQuery.fn.highlightText = function(text, className) {
|
||||
function highlight(node) {
|
||||
if (node.nodeType == 3) {
|
||||
function highlight(node, addItems) {
|
||||
if (node.nodeType === 3) {
|
||||
var val = node.nodeValue;
|
||||
var pos = val.toLowerCase().indexOf(text);
|
||||
if (pos >= 0 && !jQuery(node.parentNode).hasClass(className)) {
|
||||
var span = document.createElement("span");
|
||||
if (pos >= 0 &&
|
||||
!jQuery(node.parentNode).hasClass(className) &&
|
||||
!jQuery(node.parentNode).hasClass("nohighlight")) {
|
||||
var span;
|
||||
var isInSVG = jQuery(node).closest("body, svg, foreignObject").is("svg");
|
||||
if (isInSVG) {
|
||||
span = document.createElementNS("http://www.w3.org/2000/svg", "tspan");
|
||||
} else {
|
||||
span = document.createElement("span");
|
||||
span.className = className;
|
||||
}
|
||||
span.appendChild(document.createTextNode(val.substr(pos, text.length)));
|
||||
node.parentNode.insertBefore(span, node.parentNode.insertBefore(
|
||||
document.createTextNode(val.substr(pos + text.length)),
|
||||
node.nextSibling));
|
||||
node.nodeValue = val.substr(0, pos);
|
||||
if (isInSVG) {
|
||||
var rect = document.createElementNS("http://www.w3.org/2000/svg", "rect");
|
||||
var bbox = node.parentElement.getBBox();
|
||||
rect.x.baseVal.value = bbox.x;
|
||||
rect.y.baseVal.value = bbox.y;
|
||||
rect.width.baseVal.value = bbox.width;
|
||||
rect.height.baseVal.value = bbox.height;
|
||||
rect.setAttribute('class', className);
|
||||
addItems.push({
|
||||
"parent": node.parentNode,
|
||||
"target": rect});
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!jQuery(node).is("button, select, textarea")) {
|
||||
jQuery.each(node.childNodes, function() {
|
||||
highlight(this);
|
||||
highlight(this, addItems);
|
||||
});
|
||||
}
|
||||
}
|
||||
return this.each(function() {
|
||||
highlight(this);
|
||||
var addItems = [];
|
||||
var result = this.each(function() {
|
||||
highlight(this, addItems);
|
||||
});
|
||||
for (var i = 0; i < addItems.length; ++i) {
|
||||
jQuery(addItems[i].parent).before(addItems[i].target);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
/*
|
||||
@ -124,28 +154,30 @@ var Documentation = {
|
||||
this.fixFirefoxAnchorBug();
|
||||
this.highlightSearchWords();
|
||||
this.initIndexTable();
|
||||
|
||||
if (DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS) {
|
||||
this.initOnKeyListeners();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* i18n support
|
||||
*/
|
||||
TRANSLATIONS : {},
|
||||
PLURAL_EXPR : function(n) { return n == 1 ? 0 : 1; },
|
||||
PLURAL_EXPR : function(n) { return n === 1 ? 0 : 1; },
|
||||
LOCALE : 'unknown',
|
||||
|
||||
// gettext and ngettext don't access this so that the functions
|
||||
// can safely bound to a different name (_ = Documentation.gettext)
|
||||
gettext : function(string) {
|
||||
var translated = Documentation.TRANSLATIONS[string];
|
||||
if (typeof translated == 'undefined')
|
||||
if (typeof translated === 'undefined')
|
||||
return string;
|
||||
return (typeof translated == 'string') ? translated : translated[0];
|
||||
return (typeof translated === 'string') ? translated : translated[0];
|
||||
},
|
||||
|
||||
ngettext : function(singular, plural, n) {
|
||||
var translated = Documentation.TRANSLATIONS[singular];
|
||||
if (typeof translated == 'undefined')
|
||||
if (typeof translated === 'undefined')
|
||||
return (n == 1) ? singular : plural;
|
||||
return translated[Documentation.PLURALEXPR(n)];
|
||||
},
|
||||
@ -180,7 +212,7 @@ var Documentation = {
|
||||
* see: https://bugzilla.mozilla.org/show_bug.cgi?id=645075
|
||||
*/
|
||||
fixFirefoxAnchorBug : function() {
|
||||
if (document.location.hash)
|
||||
if (document.location.hash && $.browser.mozilla)
|
||||
window.setTimeout(function() {
|
||||
document.location.href += '';
|
||||
}, 10);
|
||||
@ -216,7 +248,7 @@ var Documentation = {
|
||||
var src = $(this).attr('src');
|
||||
var idnum = $(this).attr('id').substr(7);
|
||||
$('tr.cg-' + idnum).toggle();
|
||||
if (src.substr(-9) == 'minus.png')
|
||||
if (src.substr(-9) === 'minus.png')
|
||||
$(this).attr('src', src.substr(0, src.length-9) + 'plus.png');
|
||||
else
|
||||
$(this).attr('src', src.substr(0, src.length-8) + 'minus.png');
|
||||
@ -248,7 +280,7 @@ var Documentation = {
|
||||
var path = document.location.pathname;
|
||||
var parts = path.split(/\//);
|
||||
$.each(DOCUMENTATION_OPTIONS.URL_ROOT.split(/\//), function() {
|
||||
if (this == '..')
|
||||
if (this === '..')
|
||||
parts.pop();
|
||||
});
|
||||
var url = parts.join('/');
|
||||
@ -256,10 +288,12 @@ var Documentation = {
|
||||
},
|
||||
|
||||
initOnKeyListeners: function() {
|
||||
$(document).keyup(function(event) {
|
||||
$(document).keydown(function(event) {
|
||||
var activeElementType = document.activeElement.tagName;
|
||||
// don't navigate when in search box or textarea
|
||||
if (activeElementType !== 'TEXTAREA' && activeElementType !== 'INPUT' && activeElementType !== 'SELECT') {
|
||||
// don't navigate when in search box, textarea, dropdown or button
|
||||
if (activeElementType !== 'TEXTAREA' && activeElementType !== 'INPUT' && activeElementType !== 'SELECT'
|
||||
&& activeElementType !== 'BUTTON' && !event.altKey && !event.ctrlKey && !event.metaKey
|
||||
&& !event.shiftKey) {
|
||||
switch (event.keyCode) {
|
||||
case 37: // left
|
||||
var prevHref = $('link[rel="prev"]').prop('href');
|
||||
@ -267,12 +301,14 @@ var Documentation = {
|
||||
window.location.href = prevHref;
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case 39: // right
|
||||
var nextHref = $('link[rel="next"]').prop('href');
|
||||
if (nextHref) {
|
||||
window.location.href = nextHref;
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
12
docs/html/_static/documentation_options.js
Normal file
@ -0,0 +1,12 @@
|
||||
var DOCUMENTATION_OPTIONS = {
|
||||
URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'),
|
||||
VERSION: '36.5',
|
||||
LANGUAGE: 'None',
|
||||
COLLAPSE_INDEX: false,
|
||||
BUILDER: 'html',
|
||||
FILE_SUFFIX: '.html',
|
||||
LINK_SUFFIX: '.html',
|
||||
HAS_SOURCE: true,
|
||||
SOURCELINK_SUFFIX: '.txt',
|
||||
NAVIGATION_WITH_KEYS: false
|
||||
};
|
Before Width: | Height: | Size: 222 B |
Before Width: | Height: | Size: 202 B |
Before Width: | Height: | Size: 434 KiB |
10308
docs/html/_static/jquery-1.11.1.js
vendored
6
docs/html/_static/jquery.js
vendored
1
docs/html/_static/js/badge_only.js
Normal file
@ -0,0 +1 @@
|
||||
!function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=4)}({4:function(e,t,r){}});
|
4
docs/html/_static/js/modernizr.min.js
vendored
297
docs/html/_static/language_data.js
Normal file
@ -0,0 +1,297 @@
|
||||
/*
|
||||
* language_data.js
|
||||
* ~~~~~~~~~~~~~~~~
|
||||
*
|
||||
* This script contains the language-specific data used by searchtools.js,
|
||||
* namely the list of stopwords, stemmer, scorer and splitter.
|
||||
*
|
||||
* :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
* :license: BSD, see LICENSE for details.
|
||||
*
|
||||
*/
|
||||
|
||||
var stopwords = ["a","and","are","as","at","be","but","by","for","if","in","into","is","it","near","no","not","of","on","or","such","that","the","their","then","there","these","they","this","to","was","will","with"];
|
||||
|
||||
|
||||
/* Non-minified version is copied as a separate JS file, is available */
|
||||
|
||||
/**
|
||||
* Porter Stemmer
|
||||
*/
|
||||
var Stemmer = function() {
|
||||
|
||||
var step2list = {
|
||||
ational: 'ate',
|
||||
tional: 'tion',
|
||||
enci: 'ence',
|
||||
anci: 'ance',
|
||||
izer: 'ize',
|
||||
bli: 'ble',
|
||||
alli: 'al',
|
||||
entli: 'ent',
|
||||
eli: 'e',
|
||||
ousli: 'ous',
|
||||
ization: 'ize',
|
||||
ation: 'ate',
|
||||
ator: 'ate',
|
||||
alism: 'al',
|
||||
iveness: 'ive',
|
||||
fulness: 'ful',
|
||||
ousness: 'ous',
|
||||
aliti: 'al',
|
||||
iviti: 'ive',
|
||||
biliti: 'ble',
|
||||
logi: 'log'
|
||||
};
|
||||
|
||||
var step3list = {
|
||||
icate: 'ic',
|
||||
ative: '',
|
||||
alize: 'al',
|
||||
iciti: 'ic',
|
||||
ical: 'ic',
|
||||
ful: '',
|
||||
ness: ''
|
||||
};
|
||||
|
||||
var c = "[^aeiou]"; // consonant
|
||||
var v = "[aeiouy]"; // vowel
|
||||
var C = c + "[^aeiouy]*"; // consonant sequence
|
||||
var V = v + "[aeiou]*"; // vowel sequence
|
||||
|
||||
var mgr0 = "^(" + C + ")?" + V + C; // [C]VC... is m>0
|
||||
var meq1 = "^(" + C + ")?" + V + C + "(" + V + ")?$"; // [C]VC[V] is m=1
|
||||
var mgr1 = "^(" + C + ")?" + V + C + V + C; // [C]VCVC... is m>1
|
||||
var s_v = "^(" + C + ")?" + v; // vowel in stem
|
||||
|
||||
this.stemWord = function (w) {
|
||||
var stem;
|
||||
var suffix;
|
||||
var firstch;
|
||||
var origword = w;
|
||||
|
||||
if (w.length < 3)
|
||||
return w;
|
||||
|
||||
var re;
|
||||
var re2;
|
||||
var re3;
|
||||
var re4;
|
||||
|
||||
firstch = w.substr(0,1);
|
||||
if (firstch == "y")
|
||||
w = firstch.toUpperCase() + w.substr(1);
|
||||
|
||||
// Step 1a
|
||||
re = /^(.+?)(ss|i)es$/;
|
||||
re2 = /^(.+?)([^s])s$/;
|
||||
|
||||
if (re.test(w))
|
||||
w = w.replace(re,"$1$2");
|
||||
else if (re2.test(w))
|
||||
w = w.replace(re2,"$1$2");
|
||||
|
||||
// Step 1b
|
||||
re = /^(.+?)eed$/;
|
||||
re2 = /^(.+?)(ed|ing)$/;
|
||||
if (re.test(w)) {
|
||||
var fp = re.exec(w);
|
||||
re = new RegExp(mgr0);
|
||||
if (re.test(fp[1])) {
|
||||
re = /.$/;
|
||||
w = w.replace(re,"");
|
||||
}
|
||||
}
|
||||
else if (re2.test(w)) {
|
||||
var fp = re2.exec(w);
|
||||
stem = fp[1];
|
||||
re2 = new RegExp(s_v);
|
||||
if (re2.test(stem)) {
|
||||
w = stem;
|
||||
re2 = /(at|bl|iz)$/;
|
||||
re3 = new RegExp("([^aeiouylsz])\\1$");
|
||||
re4 = new RegExp("^" + C + v + "[^aeiouwxy]$");
|
||||
if (re2.test(w))
|
||||
w = w + "e";
|
||||
else if (re3.test(w)) {
|
||||
re = /.$/;
|
||||
w = w.replace(re,"");
|
||||
}
|
||||
else if (re4.test(w))
|
||||
w = w + "e";
|
||||
}
|
||||
}
|
||||
|
||||
// Step 1c
|
||||
re = /^(.+?)y$/;
|
||||
if (re.test(w)) {
|
||||
var fp = re.exec(w);
|
||||
stem = fp[1];
|
||||
re = new RegExp(s_v);
|
||||
if (re.test(stem))
|
||||
w = stem + "i";
|
||||
}
|
||||
|
||||
// Step 2
|
||||
re = /^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/;
|
||||
if (re.test(w)) {
|
||||
var fp = re.exec(w);
|
||||
stem = fp[1];
|
||||
suffix = fp[2];
|
||||
re = new RegExp(mgr0);
|
||||
if (re.test(stem))
|
||||
w = stem + step2list[suffix];
|
||||
}
|
||||
|
||||
// Step 3
|
||||
re = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/;
|
||||
if (re.test(w)) {
|
||||
var fp = re.exec(w);
|
||||
stem = fp[1];
|
||||
suffix = fp[2];
|
||||
re = new RegExp(mgr0);
|
||||
if (re.test(stem))
|
||||
w = stem + step3list[suffix];
|
||||
}
|
||||
|
||||
// Step 4
|
||||
re = /^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/;
|
||||
re2 = /^(.+?)(s|t)(ion)$/;
|
||||
if (re.test(w)) {
|
||||
var fp = re.exec(w);
|
||||
stem = fp[1];
|
||||
re = new RegExp(mgr1);
|
||||
if (re.test(stem))
|
||||
w = stem;
|
||||
}
|
||||
else if (re2.test(w)) {
|
||||
var fp = re2.exec(w);
|
||||
stem = fp[1] + fp[2];
|
||||
re2 = new RegExp(mgr1);
|
||||
if (re2.test(stem))
|
||||
w = stem;
|
||||
}
|
||||
|
||||
// Step 5
|
||||
re = /^(.+?)e$/;
|
||||
if (re.test(w)) {
|
||||
var fp = re.exec(w);
|
||||
stem = fp[1];
|
||||
re = new RegExp(mgr1);
|
||||
re2 = new RegExp(meq1);
|
||||
re3 = new RegExp("^" + C + v + "[^aeiouwxy]$");
|
||||
if (re.test(stem) || (re2.test(stem) && !(re3.test(stem))))
|
||||
w = stem;
|
||||
}
|
||||
re = /ll$/;
|
||||
re2 = new RegExp(mgr1);
|
||||
if (re.test(w) && re2.test(w)) {
|
||||
re = /.$/;
|
||||
w = w.replace(re,"");
|
||||
}
|
||||
|
||||
// and turn initial Y back to y
|
||||
if (firstch == "y")
|
||||
w = firstch.toLowerCase() + w.substr(1);
|
||||
return w;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
var splitChars = (function() {
|
||||
var result = {};
|
||||
var singles = [96, 180, 187, 191, 215, 247, 749, 885, 903, 907, 909, 930, 1014, 1648,
|
||||
1748, 1809, 2416, 2473, 2481, 2526, 2601, 2609, 2612, 2615, 2653, 2702,
|
||||
2706, 2729, 2737, 2740, 2857, 2865, 2868, 2910, 2928, 2948, 2961, 2971,
|
||||
2973, 3085, 3089, 3113, 3124, 3213, 3217, 3241, 3252, 3295, 3341, 3345,
|
||||
3369, 3506, 3516, 3633, 3715, 3721, 3736, 3744, 3748, 3750, 3756, 3761,
|
||||
3781, 3912, 4239, 4347, 4681, 4695, 4697, 4745, 4785, 4799, 4801, 4823,
|
||||
4881, 5760, 5901, 5997, 6313, 7405, 8024, 8026, 8028, 8030, 8117, 8125,
|
||||
8133, 8181, 8468, 8485, 8487, 8489, 8494, 8527, 11311, 11359, 11687, 11695,
|
||||
11703, 11711, 11719, 11727, 11735, 12448, 12539, 43010, 43014, 43019, 43587,
|
||||
43696, 43713, 64286, 64297, 64311, 64317, 64319, 64322, 64325, 65141];
|
||||
var i, j, start, end;
|
||||
for (i = 0; i < singles.length; i++) {
|
||||
result[singles[i]] = true;
|
||||
}
|
||||
var ranges = [[0, 47], [58, 64], [91, 94], [123, 169], [171, 177], [182, 184], [706, 709],
|
||||
[722, 735], [741, 747], [751, 879], [888, 889], [894, 901], [1154, 1161],
|
||||
[1318, 1328], [1367, 1368], [1370, 1376], [1416, 1487], [1515, 1519], [1523, 1568],
|
||||
[1611, 1631], [1642, 1645], [1750, 1764], [1767, 1773], [1789, 1790], [1792, 1807],
|
||||
[1840, 1868], [1958, 1968], [1970, 1983], [2027, 2035], [2038, 2041], [2043, 2047],
|
||||
[2070, 2073], [2075, 2083], [2085, 2087], [2089, 2307], [2362, 2364], [2366, 2383],
|
||||
[2385, 2391], [2402, 2405], [2419, 2424], [2432, 2436], [2445, 2446], [2449, 2450],
|
||||
[2483, 2485], [2490, 2492], [2494, 2509], [2511, 2523], [2530, 2533], [2546, 2547],
|
||||
[2554, 2564], [2571, 2574], [2577, 2578], [2618, 2648], [2655, 2661], [2672, 2673],
|
||||
[2677, 2692], [2746, 2748], [2750, 2767], [2769, 2783], [2786, 2789], [2800, 2820],
|
||||
[2829, 2830], [2833, 2834], [2874, 2876], [2878, 2907], [2914, 2917], [2930, 2946],
|
||||
[2955, 2957], [2966, 2968], [2976, 2978], [2981, 2983], [2987, 2989], [3002, 3023],
|
||||
[3025, 3045], [3059, 3076], [3130, 3132], [3134, 3159], [3162, 3167], [3170, 3173],
|
||||
[3184, 3191], [3199, 3204], [3258, 3260], [3262, 3293], [3298, 3301], [3312, 3332],
|
||||
[3386, 3388], [3390, 3423], [3426, 3429], [3446, 3449], [3456, 3460], [3479, 3481],
|
||||
[3518, 3519], [3527, 3584], [3636, 3647], [3655, 3663], [3674, 3712], [3717, 3718],
|
||||
[3723, 3724], [3726, 3731], [3752, 3753], [3764, 3772], [3774, 3775], [3783, 3791],
|
||||
[3802, 3803], [3806, 3839], [3841, 3871], [3892, 3903], [3949, 3975], [3980, 4095],
|
||||
[4139, 4158], [4170, 4175], [4182, 4185], [4190, 4192], [4194, 4196], [4199, 4205],
|
||||
[4209, 4212], [4226, 4237], [4250, 4255], [4294, 4303], [4349, 4351], [4686, 4687],
|
||||
[4702, 4703], [4750, 4751], [4790, 4791], [4806, 4807], [4886, 4887], [4955, 4968],
|
||||
[4989, 4991], [5008, 5023], [5109, 5120], [5741, 5742], [5787, 5791], [5867, 5869],
|
||||
[5873, 5887], [5906, 5919], [5938, 5951], [5970, 5983], [6001, 6015], [6068, 6102],
|
||||
[6104, 6107], [6109, 6111], [6122, 6127], [6138, 6159], [6170, 6175], [6264, 6271],
|
||||
[6315, 6319], [6390, 6399], [6429, 6469], [6510, 6511], [6517, 6527], [6572, 6592],
|
||||
[6600, 6607], [6619, 6655], [6679, 6687], [6741, 6783], [6794, 6799], [6810, 6822],
|
||||
[6824, 6916], [6964, 6980], [6988, 6991], [7002, 7042], [7073, 7085], [7098, 7167],
|
||||
[7204, 7231], [7242, 7244], [7294, 7400], [7410, 7423], [7616, 7679], [7958, 7959],
|
||||
[7966, 7967], [8006, 8007], [8014, 8015], [8062, 8063], [8127, 8129], [8141, 8143],
|
||||
[8148, 8149], [8156, 8159], [8173, 8177], [8189, 8303], [8306, 8307], [8314, 8318],
|
||||
[8330, 8335], [8341, 8449], [8451, 8454], [8456, 8457], [8470, 8472], [8478, 8483],
|
||||
[8506, 8507], [8512, 8516], [8522, 8525], [8586, 9311], [9372, 9449], [9472, 10101],
|
||||
[10132, 11263], [11493, 11498], [11503, 11516], [11518, 11519], [11558, 11567],
|
||||
[11622, 11630], [11632, 11647], [11671, 11679], [11743, 11822], [11824, 12292],
|
||||
[12296, 12320], [12330, 12336], [12342, 12343], [12349, 12352], [12439, 12444],
|
||||
[12544, 12548], [12590, 12592], [12687, 12689], [12694, 12703], [12728, 12783],
|
||||
[12800, 12831], [12842, 12880], [12896, 12927], [12938, 12976], [12992, 13311],
|
||||
[19894, 19967], [40908, 40959], [42125, 42191], [42238, 42239], [42509, 42511],
|
||||
[42540, 42559], [42592, 42593], [42607, 42622], [42648, 42655], [42736, 42774],
|
||||
[42784, 42785], [42889, 42890], [42893, 43002], [43043, 43055], [43062, 43071],
|
||||
[43124, 43137], [43188, 43215], [43226, 43249], [43256, 43258], [43260, 43263],
|
||||
[43302, 43311], [43335, 43359], [43389, 43395], [43443, 43470], [43482, 43519],
|
||||
[43561, 43583], [43596, 43599], [43610, 43615], [43639, 43641], [43643, 43647],
|
||||
[43698, 43700], [43703, 43704], [43710, 43711], [43715, 43738], [43742, 43967],
|
||||
[44003, 44015], [44026, 44031], [55204, 55215], [55239, 55242], [55292, 55295],
|
||||
[57344, 63743], [64046, 64047], [64110, 64111], [64218, 64255], [64263, 64274],
|
||||
[64280, 64284], [64434, 64466], [64830, 64847], [64912, 64913], [64968, 65007],
|
||||
[65020, 65135], [65277, 65295], [65306, 65312], [65339, 65344], [65371, 65381],
|
||||
[65471, 65473], [65480, 65481], [65488, 65489], [65496, 65497]];
|
||||
for (i = 0; i < ranges.length; i++) {
|
||||
start = ranges[i][0];
|
||||
end = ranges[i][1];
|
||||
for (j = start; j <= end; j++) {
|
||||
result[j] = true;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
})();
|
||||
|
||||
function splitQuery(query) {
|
||||
var result = [];
|
||||
var start = -1;
|
||||
for (var i = 0; i < query.length; i++) {
|
||||
if (splitChars[query.charCodeAt(i)]) {
|
||||
if (start !== -1) {
|
||||
result.push(query.slice(start, i));
|
||||
start = -1;
|
||||
}
|
||||
} else if (start === -1) {
|
||||
start = i;
|
||||
}
|
||||
}
|
||||
if (start !== -1) {
|
||||
result.push(query.slice(start));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,8 @@
|
||||
pre { line-height: 125%; }
|
||||
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
|
||||
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
|
||||
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
|
||||
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
|
||||
.highlight .hll { background-color: #ffffcc }
|
||||
.highlight { background: #eeffcc; }
|
||||
.highlight .c { color: #408090; font-style: italic } /* Comment */
|
||||
|
@ -1,204 +1,19 @@
|
||||
/*
|
||||
* searchtools.js_t
|
||||
* searchtools.js
|
||||
* ~~~~~~~~~~~~~~~~
|
||||
*
|
||||
* Sphinx JavaScript utilities for the full-text search.
|
||||
*
|
||||
* :copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS.
|
||||
* :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
* :license: BSD, see LICENSE for details.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/* Non-minified version JS is _stemmer.js if file is provided */
|
||||
/**
|
||||
* Porter Stemmer
|
||||
*/
|
||||
var Stemmer = function() {
|
||||
|
||||
var step2list = {
|
||||
ational: 'ate',
|
||||
tional: 'tion',
|
||||
enci: 'ence',
|
||||
anci: 'ance',
|
||||
izer: 'ize',
|
||||
bli: 'ble',
|
||||
alli: 'al',
|
||||
entli: 'ent',
|
||||
eli: 'e',
|
||||
ousli: 'ous',
|
||||
ization: 'ize',
|
||||
ation: 'ate',
|
||||
ator: 'ate',
|
||||
alism: 'al',
|
||||
iveness: 'ive',
|
||||
fulness: 'ful',
|
||||
ousness: 'ous',
|
||||
aliti: 'al',
|
||||
iviti: 'ive',
|
||||
biliti: 'ble',
|
||||
logi: 'log'
|
||||
};
|
||||
|
||||
var step3list = {
|
||||
icate: 'ic',
|
||||
ative: '',
|
||||
alize: 'al',
|
||||
iciti: 'ic',
|
||||
ical: 'ic',
|
||||
ful: '',
|
||||
ness: ''
|
||||
};
|
||||
|
||||
var c = "[^aeiou]"; // consonant
|
||||
var v = "[aeiouy]"; // vowel
|
||||
var C = c + "[^aeiouy]*"; // consonant sequence
|
||||
var V = v + "[aeiou]*"; // vowel sequence
|
||||
|
||||
var mgr0 = "^(" + C + ")?" + V + C; // [C]VC... is m>0
|
||||
var meq1 = "^(" + C + ")?" + V + C + "(" + V + ")?$"; // [C]VC[V] is m=1
|
||||
var mgr1 = "^(" + C + ")?" + V + C + V + C; // [C]VCVC... is m>1
|
||||
var s_v = "^(" + C + ")?" + v; // vowel in stem
|
||||
|
||||
this.stemWord = function (w) {
|
||||
var stem;
|
||||
var suffix;
|
||||
var firstch;
|
||||
var origword = w;
|
||||
|
||||
if (w.length < 3)
|
||||
return w;
|
||||
|
||||
var re;
|
||||
var re2;
|
||||
var re3;
|
||||
var re4;
|
||||
|
||||
firstch = w.substr(0,1);
|
||||
if (firstch == "y")
|
||||
w = firstch.toUpperCase() + w.substr(1);
|
||||
|
||||
// Step 1a
|
||||
re = /^(.+?)(ss|i)es$/;
|
||||
re2 = /^(.+?)([^s])s$/;
|
||||
|
||||
if (re.test(w))
|
||||
w = w.replace(re,"$1$2");
|
||||
else if (re2.test(w))
|
||||
w = w.replace(re2,"$1$2");
|
||||
|
||||
// Step 1b
|
||||
re = /^(.+?)eed$/;
|
||||
re2 = /^(.+?)(ed|ing)$/;
|
||||
if (re.test(w)) {
|
||||
var fp = re.exec(w);
|
||||
re = new RegExp(mgr0);
|
||||
if (re.test(fp[1])) {
|
||||
re = /.$/;
|
||||
w = w.replace(re,"");
|
||||
}
|
||||
}
|
||||
else if (re2.test(w)) {
|
||||
var fp = re2.exec(w);
|
||||
stem = fp[1];
|
||||
re2 = new RegExp(s_v);
|
||||
if (re2.test(stem)) {
|
||||
w = stem;
|
||||
re2 = /(at|bl|iz)$/;
|
||||
re3 = new RegExp("([^aeiouylsz])\\1$");
|
||||
re4 = new RegExp("^" + C + v + "[^aeiouwxy]$");
|
||||
if (re2.test(w))
|
||||
w = w + "e";
|
||||
else if (re3.test(w)) {
|
||||
re = /.$/;
|
||||
w = w.replace(re,"");
|
||||
}
|
||||
else if (re4.test(w))
|
||||
w = w + "e";
|
||||
}
|
||||
}
|
||||
|
||||
// Step 1c
|
||||
re = /^(.+?)y$/;
|
||||
if (re.test(w)) {
|
||||
var fp = re.exec(w);
|
||||
stem = fp[1];
|
||||
re = new RegExp(s_v);
|
||||
if (re.test(stem))
|
||||
w = stem + "i";
|
||||
}
|
||||
|
||||
// Step 2
|
||||
re = /^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/;
|
||||
if (re.test(w)) {
|
||||
var fp = re.exec(w);
|
||||
stem = fp[1];
|
||||
suffix = fp[2];
|
||||
re = new RegExp(mgr0);
|
||||
if (re.test(stem))
|
||||
w = stem + step2list[suffix];
|
||||
}
|
||||
|
||||
// Step 3
|
||||
re = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/;
|
||||
if (re.test(w)) {
|
||||
var fp = re.exec(w);
|
||||
stem = fp[1];
|
||||
suffix = fp[2];
|
||||
re = new RegExp(mgr0);
|
||||
if (re.test(stem))
|
||||
w = stem + step3list[suffix];
|
||||
}
|
||||
|
||||
// Step 4
|
||||
re = /^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/;
|
||||
re2 = /^(.+?)(s|t)(ion)$/;
|
||||
if (re.test(w)) {
|
||||
var fp = re.exec(w);
|
||||
stem = fp[1];
|
||||
re = new RegExp(mgr1);
|
||||
if (re.test(stem))
|
||||
w = stem;
|
||||
}
|
||||
else if (re2.test(w)) {
|
||||
var fp = re2.exec(w);
|
||||
stem = fp[1] + fp[2];
|
||||
re2 = new RegExp(mgr1);
|
||||
if (re2.test(stem))
|
||||
w = stem;
|
||||
}
|
||||
|
||||
// Step 5
|
||||
re = /^(.+?)e$/;
|
||||
if (re.test(w)) {
|
||||
var fp = re.exec(w);
|
||||
stem = fp[1];
|
||||
re = new RegExp(mgr1);
|
||||
re2 = new RegExp(meq1);
|
||||
re3 = new RegExp("^" + C + v + "[^aeiouwxy]$");
|
||||
if (re.test(stem) || (re2.test(stem) && !(re3.test(stem))))
|
||||
w = stem;
|
||||
}
|
||||
re = /ll$/;
|
||||
re2 = new RegExp(mgr1);
|
||||
if (re.test(w) && re2.test(w)) {
|
||||
re = /.$/;
|
||||
w = w.replace(re,"");
|
||||
}
|
||||
|
||||
// and turn initial Y back to y
|
||||
if (firstch == "y")
|
||||
w = firstch.toLowerCase() + w.substr(1);
|
||||
return w;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
if (!Scorer) {
|
||||
/**
|
||||
* Simple result scoring code.
|
||||
*/
|
||||
var Scorer = {
|
||||
var Scorer = {
|
||||
// Implement the following function to further tweak the score for each result
|
||||
// The function takes a result array [filename, title, anchor, descr, score]
|
||||
// and returns the new score.
|
||||
@ -221,110 +36,18 @@ var Scorer = {
|
||||
|
||||
// query found in title
|
||||
title: 15,
|
||||
partialTitle: 7,
|
||||
// query found in terms
|
||||
term: 5
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var splitChars = (function() {
|
||||
var result = {};
|
||||
var singles = [96, 180, 187, 191, 215, 247, 749, 885, 903, 907, 909, 930, 1014, 1648,
|
||||
1748, 1809, 2416, 2473, 2481, 2526, 2601, 2609, 2612, 2615, 2653, 2702,
|
||||
2706, 2729, 2737, 2740, 2857, 2865, 2868, 2910, 2928, 2948, 2961, 2971,
|
||||
2973, 3085, 3089, 3113, 3124, 3213, 3217, 3241, 3252, 3295, 3341, 3345,
|
||||
3369, 3506, 3516, 3633, 3715, 3721, 3736, 3744, 3748, 3750, 3756, 3761,
|
||||
3781, 3912, 4239, 4347, 4681, 4695, 4697, 4745, 4785, 4799, 4801, 4823,
|
||||
4881, 5760, 5901, 5997, 6313, 7405, 8024, 8026, 8028, 8030, 8117, 8125,
|
||||
8133, 8181, 8468, 8485, 8487, 8489, 8494, 8527, 11311, 11359, 11687, 11695,
|
||||
11703, 11711, 11719, 11727, 11735, 12448, 12539, 43010, 43014, 43019, 43587,
|
||||
43696, 43713, 64286, 64297, 64311, 64317, 64319, 64322, 64325, 65141];
|
||||
var i, j, start, end;
|
||||
for (i = 0; i < singles.length; i++) {
|
||||
result[singles[i]] = true;
|
||||
}
|
||||
var ranges = [[0, 47], [58, 64], [91, 94], [123, 169], [171, 177], [182, 184], [706, 709],
|
||||
[722, 735], [741, 747], [751, 879], [888, 889], [894, 901], [1154, 1161],
|
||||
[1318, 1328], [1367, 1368], [1370, 1376], [1416, 1487], [1515, 1519], [1523, 1568],
|
||||
[1611, 1631], [1642, 1645], [1750, 1764], [1767, 1773], [1789, 1790], [1792, 1807],
|
||||
[1840, 1868], [1958, 1968], [1970, 1983], [2027, 2035], [2038, 2041], [2043, 2047],
|
||||
[2070, 2073], [2075, 2083], [2085, 2087], [2089, 2307], [2362, 2364], [2366, 2383],
|
||||
[2385, 2391], [2402, 2405], [2419, 2424], [2432, 2436], [2445, 2446], [2449, 2450],
|
||||
[2483, 2485], [2490, 2492], [2494, 2509], [2511, 2523], [2530, 2533], [2546, 2547],
|
||||
[2554, 2564], [2571, 2574], [2577, 2578], [2618, 2648], [2655, 2661], [2672, 2673],
|
||||
[2677, 2692], [2746, 2748], [2750, 2767], [2769, 2783], [2786, 2789], [2800, 2820],
|
||||
[2829, 2830], [2833, 2834], [2874, 2876], [2878, 2907], [2914, 2917], [2930, 2946],
|
||||
[2955, 2957], [2966, 2968], [2976, 2978], [2981, 2983], [2987, 2989], [3002, 3023],
|
||||
[3025, 3045], [3059, 3076], [3130, 3132], [3134, 3159], [3162, 3167], [3170, 3173],
|
||||
[3184, 3191], [3199, 3204], [3258, 3260], [3262, 3293], [3298, 3301], [3312, 3332],
|
||||
[3386, 3388], [3390, 3423], [3426, 3429], [3446, 3449], [3456, 3460], [3479, 3481],
|
||||
[3518, 3519], [3527, 3584], [3636, 3647], [3655, 3663], [3674, 3712], [3717, 3718],
|
||||
[3723, 3724], [3726, 3731], [3752, 3753], [3764, 3772], [3774, 3775], [3783, 3791],
|
||||
[3802, 3803], [3806, 3839], [3841, 3871], [3892, 3903], [3949, 3975], [3980, 4095],
|
||||
[4139, 4158], [4170, 4175], [4182, 4185], [4190, 4192], [4194, 4196], [4199, 4205],
|
||||
[4209, 4212], [4226, 4237], [4250, 4255], [4294, 4303], [4349, 4351], [4686, 4687],
|
||||
[4702, 4703], [4750, 4751], [4790, 4791], [4806, 4807], [4886, 4887], [4955, 4968],
|
||||
[4989, 4991], [5008, 5023], [5109, 5120], [5741, 5742], [5787, 5791], [5867, 5869],
|
||||
[5873, 5887], [5906, 5919], [5938, 5951], [5970, 5983], [6001, 6015], [6068, 6102],
|
||||
[6104, 6107], [6109, 6111], [6122, 6127], [6138, 6159], [6170, 6175], [6264, 6271],
|
||||
[6315, 6319], [6390, 6399], [6429, 6469], [6510, 6511], [6517, 6527], [6572, 6592],
|
||||
[6600, 6607], [6619, 6655], [6679, 6687], [6741, 6783], [6794, 6799], [6810, 6822],
|
||||
[6824, 6916], [6964, 6980], [6988, 6991], [7002, 7042], [7073, 7085], [7098, 7167],
|
||||
[7204, 7231], [7242, 7244], [7294, 7400], [7410, 7423], [7616, 7679], [7958, 7959],
|
||||
[7966, 7967], [8006, 8007], [8014, 8015], [8062, 8063], [8127, 8129], [8141, 8143],
|
||||
[8148, 8149], [8156, 8159], [8173, 8177], [8189, 8303], [8306, 8307], [8314, 8318],
|
||||
[8330, 8335], [8341, 8449], [8451, 8454], [8456, 8457], [8470, 8472], [8478, 8483],
|
||||
[8506, 8507], [8512, 8516], [8522, 8525], [8586, 9311], [9372, 9449], [9472, 10101],
|
||||
[10132, 11263], [11493, 11498], [11503, 11516], [11518, 11519], [11558, 11567],
|
||||
[11622, 11630], [11632, 11647], [11671, 11679], [11743, 11822], [11824, 12292],
|
||||
[12296, 12320], [12330, 12336], [12342, 12343], [12349, 12352], [12439, 12444],
|
||||
[12544, 12548], [12590, 12592], [12687, 12689], [12694, 12703], [12728, 12783],
|
||||
[12800, 12831], [12842, 12880], [12896, 12927], [12938, 12976], [12992, 13311],
|
||||
[19894, 19967], [40908, 40959], [42125, 42191], [42238, 42239], [42509, 42511],
|
||||
[42540, 42559], [42592, 42593], [42607, 42622], [42648, 42655], [42736, 42774],
|
||||
[42784, 42785], [42889, 42890], [42893, 43002], [43043, 43055], [43062, 43071],
|
||||
[43124, 43137], [43188, 43215], [43226, 43249], [43256, 43258], [43260, 43263],
|
||||
[43302, 43311], [43335, 43359], [43389, 43395], [43443, 43470], [43482, 43519],
|
||||
[43561, 43583], [43596, 43599], [43610, 43615], [43639, 43641], [43643, 43647],
|
||||
[43698, 43700], [43703, 43704], [43710, 43711], [43715, 43738], [43742, 43967],
|
||||
[44003, 44015], [44026, 44031], [55204, 55215], [55239, 55242], [55292, 55295],
|
||||
[57344, 63743], [64046, 64047], [64110, 64111], [64218, 64255], [64263, 64274],
|
||||
[64280, 64284], [64434, 64466], [64830, 64847], [64912, 64913], [64968, 65007],
|
||||
[65020, 65135], [65277, 65295], [65306, 65312], [65339, 65344], [65371, 65381],
|
||||
[65471, 65473], [65480, 65481], [65488, 65489], [65496, 65497]];
|
||||
for (i = 0; i < ranges.length; i++) {
|
||||
start = ranges[i][0];
|
||||
end = ranges[i][1];
|
||||
for (j = start; j <= end; j++) {
|
||||
result[j] = true;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
})();
|
||||
|
||||
function splitQuery(query) {
|
||||
var result = [];
|
||||
var start = -1;
|
||||
for (var i = 0; i < query.length; i++) {
|
||||
if (splitChars[query.charCodeAt(i)]) {
|
||||
if (start !== -1) {
|
||||
result.push(query.slice(start, i));
|
||||
start = -1;
|
||||
}
|
||||
} else if (start === -1) {
|
||||
start = i;
|
||||
}
|
||||
}
|
||||
if (start !== -1) {
|
||||
result.push(query.slice(start));
|
||||
}
|
||||
return result;
|
||||
term: 5,
|
||||
partialTerm: 2
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!splitQuery) {
|
||||
function splitQuery(query) {
|
||||
return query.split(/\s+/);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Search Module
|
||||
@ -335,6 +58,19 @@ var Search = {
|
||||
_queued_query : null,
|
||||
_pulse_status : -1,
|
||||
|
||||
htmlToText : function(htmlString) {
|
||||
var virtualDocument = document.implementation.createHTMLDocument('virtual');
|
||||
var htmlElement = $(htmlString, virtualDocument);
|
||||
htmlElement.find('.headerlink').remove();
|
||||
docContent = htmlElement.find('[role=main]')[0];
|
||||
if(docContent === undefined) {
|
||||
console.warn("Content block not found. Sphinx search tries to obtain it " +
|
||||
"via '[role=main]'. Could you check your theme or template.");
|
||||
return "";
|
||||
}
|
||||
return docContent.textContent || docContent.innerText;
|
||||
},
|
||||
|
||||
init : function() {
|
||||
var params = $.getQueryParameters();
|
||||
if (params.q) {
|
||||
@ -399,7 +135,7 @@ var Search = {
|
||||
this.out = $('#search-results');
|
||||
this.title = $('<h2>' + _('Searching') + '</h2>').appendTo(this.out);
|
||||
this.dots = $('<span></span>').appendTo(this.title);
|
||||
this.status = $('<p style="display: none"></p>').appendTo(this.out);
|
||||
this.status = $('<p class="search-summary"> </p>').appendTo(this.out);
|
||||
this.output = $('<ul class="search"/>').appendTo(this.out);
|
||||
|
||||
$('#search-progress').text(_('Preparing search...'));
|
||||
@ -417,7 +153,6 @@ var Search = {
|
||||
*/
|
||||
query : function(query) {
|
||||
var i;
|
||||
var stopwords = ["a","and","are","as","at","be","but","by","for","if","in","into","is","it","near","no","not","of","on","or","such","that","the","their","then","there","these","they","this","to","was","will","with"];
|
||||
|
||||
// stem the searchterms and add them to the correct list
|
||||
var stemmer = new Stemmer();
|
||||
@ -431,8 +166,7 @@ var Search = {
|
||||
objectterms.push(tmp[i].toLowerCase());
|
||||
}
|
||||
|
||||
if ($u.indexOf(stopwords, tmp[i].toLowerCase()) != -1 || tmp[i].match(/^\d+$/) ||
|
||||
tmp[i] === "") {
|
||||
if ($u.indexOf(stopwords, tmp[i].toLowerCase()) != -1 || tmp[i] === "") {
|
||||
// skip this "word"
|
||||
continue;
|
||||
}
|
||||
@ -514,8 +248,10 @@ var Search = {
|
||||
// results left, load the summary and display it
|
||||
if (results.length) {
|
||||
var item = results.pop();
|
||||
var listItem = $('<li style="display:none"></li>');
|
||||
if (DOCUMENTATION_OPTIONS.FILE_SUFFIX === '') {
|
||||
var listItem = $('<li></li>');
|
||||
var requestUrl = "";
|
||||
var linkUrl = "";
|
||||
if (DOCUMENTATION_OPTIONS.BUILDER === 'dirhtml') {
|
||||
// dirhtml builder
|
||||
var dirname = item[0] + '/';
|
||||
if (dirname.match(/\/index\/$/)) {
|
||||
@ -523,41 +259,45 @@ var Search = {
|
||||
} else if (dirname == 'index/') {
|
||||
dirname = '';
|
||||
}
|
||||
listItem.append($('<a/>').attr('href',
|
||||
DOCUMENTATION_OPTIONS.URL_ROOT + dirname +
|
||||
highlightstring + item[2]).html(item[1]));
|
||||
requestUrl = DOCUMENTATION_OPTIONS.URL_ROOT + dirname;
|
||||
linkUrl = requestUrl;
|
||||
|
||||
} else {
|
||||
// normal html builders
|
||||
listItem.append($('<a/>').attr('href',
|
||||
item[0] + DOCUMENTATION_OPTIONS.FILE_SUFFIX +
|
||||
highlightstring + item[2]).html(item[1]));
|
||||
requestUrl = DOCUMENTATION_OPTIONS.URL_ROOT + item[0] + DOCUMENTATION_OPTIONS.FILE_SUFFIX;
|
||||
linkUrl = item[0] + DOCUMENTATION_OPTIONS.LINK_SUFFIX;
|
||||
}
|
||||
listItem.append($('<a/>').attr('href',
|
||||
linkUrl +
|
||||
highlightstring + item[2]).html(item[1]));
|
||||
if (item[3]) {
|
||||
listItem.append($('<span> (' + item[3] + ')</span>'));
|
||||
Search.output.append(listItem);
|
||||
listItem.slideDown(5, function() {
|
||||
setTimeout(function() {
|
||||
displayNextItem();
|
||||
});
|
||||
}, 5);
|
||||
} else if (DOCUMENTATION_OPTIONS.HAS_SOURCE) {
|
||||
var suffix = DOCUMENTATION_OPTIONS.SOURCELINK_SUFFIX;
|
||||
$.ajax({url: DOCUMENTATION_OPTIONS.URL_ROOT + '_sources/' + item[5] + (item[5].slice(-suffix.length) === suffix ? '' : suffix),
|
||||
$.ajax({url: requestUrl,
|
||||
dataType: "text",
|
||||
complete: function(jqxhr, textstatus) {
|
||||
var data = jqxhr.responseText;
|
||||
if (data !== '' && data !== undefined) {
|
||||
listItem.append(Search.makeSearchSummary(data, searchterms, hlterms));
|
||||
var summary = Search.makeSearchSummary(data, searchterms, hlterms);
|
||||
if (summary) {
|
||||
listItem.append(summary);
|
||||
}
|
||||
}
|
||||
Search.output.append(listItem);
|
||||
listItem.slideDown(5, function() {
|
||||
setTimeout(function() {
|
||||
displayNextItem();
|
||||
});
|
||||
}, 5);
|
||||
}});
|
||||
} else {
|
||||
// no source available, just display title
|
||||
Search.output.append(listItem);
|
||||
listItem.slideDown(5, function() {
|
||||
setTimeout(function() {
|
||||
displayNextItem();
|
||||
});
|
||||
}, 5);
|
||||
}
|
||||
}
|
||||
// search finished, update title and status message
|
||||
@ -590,12 +330,13 @@ var Search = {
|
||||
for (var prefix in objects) {
|
||||
for (var name in objects[prefix]) {
|
||||
var fullname = (prefix ? prefix + '.' : '') + name;
|
||||
if (fullname.toLowerCase().indexOf(object) > -1) {
|
||||
var fullnameLower = fullname.toLowerCase()
|
||||
if (fullnameLower.indexOf(object) > -1) {
|
||||
var score = 0;
|
||||
var parts = fullname.split('.');
|
||||
var parts = fullnameLower.split('.');
|
||||
// check for different match types: exact matches of full name or
|
||||
// "last name" (i.e. last dotted part)
|
||||
if (fullname == object || parts[parts.length - 1] == object) {
|
||||
if (fullnameLower == object || parts[parts.length - 1] == object) {
|
||||
score += Scorer.objNameMatch;
|
||||
// matches in last name
|
||||
} else if (parts[parts.length - 1].indexOf(object) > -1) {
|
||||
@ -641,6 +382,13 @@ var Search = {
|
||||
return results;
|
||||
},
|
||||
|
||||
/**
|
||||
* See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
|
||||
*/
|
||||
escapeRegExp : function(string) {
|
||||
return string.replace(/[.*+\-?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
|
||||
},
|
||||
|
||||
/**
|
||||
* search for full-text terms in the index
|
||||
*/
|
||||
@ -662,6 +410,20 @@ var Search = {
|
||||
{files: terms[word], score: Scorer.term},
|
||||
{files: titleterms[word], score: Scorer.title}
|
||||
];
|
||||
// add support for partial matches
|
||||
if (word.length > 2) {
|
||||
var word_regex = this.escapeRegExp(word);
|
||||
for (var w in terms) {
|
||||
if (w.match(word_regex) && !terms[word]) {
|
||||
_o.push({files: terms[w], score: Scorer.partialTerm})
|
||||
}
|
||||
}
|
||||
for (var w in titleterms) {
|
||||
if (w.match(word_regex) && !titleterms[word]) {
|
||||
_o.push({files: titleterms[w], score: Scorer.partialTitle})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// no match but word was a required one
|
||||
if ($u.every(_o, function(o){return o.files === undefined;})) {
|
||||
@ -681,7 +443,7 @@ var Search = {
|
||||
for (j = 0; j < _files.length; j++) {
|
||||
file = _files[j];
|
||||
if (!(file in scoreMap))
|
||||
scoreMap[file] = {}
|
||||
scoreMap[file] = {};
|
||||
scoreMap[file][word] = o.score;
|
||||
}
|
||||
});
|
||||
@ -689,7 +451,7 @@ var Search = {
|
||||
// create the mapping
|
||||
for (j = 0; j < files.length; j++) {
|
||||
file = files[j];
|
||||
if (file in fileMap)
|
||||
if (file in fileMap && fileMap[file].indexOf(word) === -1)
|
||||
fileMap[file].push(word);
|
||||
else
|
||||
fileMap[file] = [word];
|
||||
@ -701,8 +463,12 @@ var Search = {
|
||||
var valid = true;
|
||||
|
||||
// check if all requirements are matched
|
||||
if (fileMap[file].length != searchterms.length)
|
||||
continue;
|
||||
var filteredTermCount = // as search terms with length < 3 are discarded: ignore
|
||||
searchterms.filter(function(term){return term.length > 2}).length
|
||||
if (
|
||||
fileMap[file].length != searchterms.length &&
|
||||
fileMap[file].length != filteredTermCount
|
||||
) continue;
|
||||
|
||||
// ensure that none of the excluded terms is in the search result
|
||||
for (i = 0; i < excluded.length; i++) {
|
||||
@ -733,7 +499,11 @@ var Search = {
|
||||
* words. the first one is used to find the occurrence, the
|
||||
* latter for highlighting it.
|
||||
*/
|
||||
makeSearchSummary : function(text, keywords, hlwords) {
|
||||
makeSearchSummary : function(htmlText, keywords, hlwords) {
|
||||
var text = Search.htmlToText(htmlText);
|
||||
if (text == "") {
|
||||
return null;
|
||||
}
|
||||
var textLower = text.toLowerCase();
|
||||
var start = 0;
|
||||
$.each(keywords, function() {
|
||||
@ -745,7 +515,7 @@ var Search = {
|
||||
var excerpt = ((start > 0) ? '...' : '') +
|
||||
$.trim(text.substr(start, 240)) +
|
||||
((start + 240 - text.length) ? '...' : '');
|
||||
var rv = $('<div class="context"></div>').text(excerpt);
|
||||
var rv = $('<p class="context"></p>').text(excerpt);
|
||||
$.each(hlwords, function() {
|
||||
rv = rv.highlightText(this, 'highlighted');
|
||||
});
|
||||
|
2027
docs/html/_static/underscore-1.12.0.js
Normal file
2042
docs/html/_static/underscore-1.13.1.js
Normal file
@ -1,999 +0,0 @@
|
||||
// Underscore.js 1.3.1
|
||||
// (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc.
|
||||
// Underscore is freely distributable under the MIT license.
|
||||
// Portions of Underscore are inspired or borrowed from Prototype,
|
||||
// Oliver Steele's Functional, and John Resig's Micro-Templating.
|
||||
// For all details and documentation:
|
||||
// http://documentcloud.github.com/underscore
|
||||
|
||||
(function() {
|
||||
|
||||
// Baseline setup
|
||||
// --------------
|
||||
|
||||
// Establish the root object, `window` in the browser, or `global` on the server.
|
||||
var root = this;
|
||||
|
||||
// Save the previous value of the `_` variable.
|
||||
var previousUnderscore = root._;
|
||||
|
||||
// Establish the object that gets returned to break out of a loop iteration.
|
||||
var breaker = {};
|
||||
|
||||
// Save bytes in the minified (but not gzipped) version:
|
||||
var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype;
|
||||
|
||||
// Create quick reference variables for speed access to core prototypes.
|
||||
var slice = ArrayProto.slice,
|
||||
unshift = ArrayProto.unshift,
|
||||
toString = ObjProto.toString,
|
||||
hasOwnProperty = ObjProto.hasOwnProperty;
|
||||
|
||||
// All **ECMAScript 5** native function implementations that we hope to use
|
||||
// are declared here.
|
||||
var
|
||||
nativeForEach = ArrayProto.forEach,
|
||||
nativeMap = ArrayProto.map,
|
||||
nativeReduce = ArrayProto.reduce,
|
||||
nativeReduceRight = ArrayProto.reduceRight,
|
||||
nativeFilter = ArrayProto.filter,
|
||||
nativeEvery = ArrayProto.every,
|
||||
nativeSome = ArrayProto.some,
|
||||
nativeIndexOf = ArrayProto.indexOf,
|
||||
nativeLastIndexOf = ArrayProto.lastIndexOf,
|
||||
nativeIsArray = Array.isArray,
|
||||
nativeKeys = Object.keys,
|
||||
nativeBind = FuncProto.bind;
|
||||
|
||||
// Create a safe reference to the Underscore object for use below.
|
||||
var _ = function(obj) { return new wrapper(obj); };
|
||||
|
||||
// Export the Underscore object for **Node.js**, with
|
||||
// backwards-compatibility for the old `require()` API. If we're in
|
||||
// the browser, add `_` as a global object via a string identifier,
|
||||
// for Closure Compiler "advanced" mode.
|
||||
if (typeof exports !== 'undefined') {
|
||||
if (typeof module !== 'undefined' && module.exports) {
|
||||
exports = module.exports = _;
|
||||
}
|
||||
exports._ = _;
|
||||
} else {
|
||||
root['_'] = _;
|
||||
}
|
||||
|
||||
// Current version.
|
||||
_.VERSION = '1.3.1';
|
||||
|
||||
// Collection Functions
|
||||
// --------------------
|
||||
|
||||
// The cornerstone, an `each` implementation, aka `forEach`.
|
||||
// Handles objects with the built-in `forEach`, arrays, and raw objects.
|
||||
// Delegates to **ECMAScript 5**'s native `forEach` if available.
|
||||
var each = _.each = _.forEach = function(obj, iterator, context) {
|
||||
if (obj == null) return;
|
||||
if (nativeForEach && obj.forEach === nativeForEach) {
|
||||
obj.forEach(iterator, context);
|
||||
} else if (obj.length === +obj.length) {
|
||||
for (var i = 0, l = obj.length; i < l; i++) {
|
||||
if (i in obj && iterator.call(context, obj[i], i, obj) === breaker) return;
|
||||
}
|
||||
} else {
|
||||
for (var key in obj) {
|
||||
if (_.has(obj, key)) {
|
||||
if (iterator.call(context, obj[key], key, obj) === breaker) return;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Return the results of applying the iterator to each element.
|
||||
// Delegates to **ECMAScript 5**'s native `map` if available.
|
||||
_.map = _.collect = function(obj, iterator, context) {
|
||||
var results = [];
|
||||
if (obj == null) return results;
|
||||
if (nativeMap && obj.map === nativeMap) return obj.map(iterator, context);
|
||||
each(obj, function(value, index, list) {
|
||||
results[results.length] = iterator.call(context, value, index, list);
|
||||
});
|
||||
if (obj.length === +obj.length) results.length = obj.length;
|
||||
return results;
|
||||
};
|
||||
|
||||
// **Reduce** builds up a single result from a list of values, aka `inject`,
|
||||
// or `foldl`. Delegates to **ECMAScript 5**'s native `reduce` if available.
|
||||
_.reduce = _.foldl = _.inject = function(obj, iterator, memo, context) {
|
||||
var initial = arguments.length > 2;
|
||||
if (obj == null) obj = [];
|
||||
if (nativeReduce && obj.reduce === nativeReduce) {
|
||||
if (context) iterator = _.bind(iterator, context);
|
||||
return initial ? obj.reduce(iterator, memo) : obj.reduce(iterator);
|
||||
}
|
||||
each(obj, function(value, index, list) {
|
||||
if (!initial) {
|
||||
memo = value;
|
||||
initial = true;
|
||||
} else {
|
||||
memo = iterator.call(context, memo, value, index, list);
|
||||
}
|
||||
});
|
||||
if (!initial) throw new TypeError('Reduce of empty array with no initial value');
|
||||
return memo;
|
||||
};
|
||||
|
||||
// The right-associative version of reduce, also known as `foldr`.
|
||||
// Delegates to **ECMAScript 5**'s native `reduceRight` if available.
|
||||
_.reduceRight = _.foldr = function(obj, iterator, memo, context) {
|
||||
var initial = arguments.length > 2;
|
||||
if (obj == null) obj = [];
|
||||
if (nativeReduceRight && obj.reduceRight === nativeReduceRight) {
|
||||
if (context) iterator = _.bind(iterator, context);
|
||||
return initial ? obj.reduceRight(iterator, memo) : obj.reduceRight(iterator);
|
||||
}
|
||||
var reversed = _.toArray(obj).reverse();
|
||||
if (context && !initial) iterator = _.bind(iterator, context);
|
||||
return initial ? _.reduce(reversed, iterator, memo, context) : _.reduce(reversed, iterator);
|
||||
};
|
||||
|
||||
// Return the first value which passes a truth test. Aliased as `detect`.
|
||||
_.find = _.detect = function(obj, iterator, context) {
|
||||
var result;
|
||||
any(obj, function(value, index, list) {
|
||||
if (iterator.call(context, value, index, list)) {
|
||||
result = value;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
return result;
|
||||
};
|
||||
|
||||
// Return all the elements that pass a truth test.
|
||||
// Delegates to **ECMAScript 5**'s native `filter` if available.
|
||||
// Aliased as `select`.
|
||||
_.filter = _.select = function(obj, iterator, context) {
|
||||
var results = [];
|
||||
if (obj == null) return results;
|
||||
if (nativeFilter && obj.filter === nativeFilter) return obj.filter(iterator, context);
|
||||
each(obj, function(value, index, list) {
|
||||
if (iterator.call(context, value, index, list)) results[results.length] = value;
|
||||
});
|
||||
return results;
|
||||
};
|
||||
|
||||
// Return all the elements for which a truth test fails.
|
||||
_.reject = function(obj, iterator, context) {
|
||||
var results = [];
|
||||
if (obj == null) return results;
|
||||
each(obj, function(value, index, list) {
|
||||
if (!iterator.call(context, value, index, list)) results[results.length] = value;
|
||||
});
|
||||
return results;
|
||||
};
|
||||
|
||||
// Determine whether all of the elements match a truth test.
|
||||
// Delegates to **ECMAScript 5**'s native `every` if available.
|
||||
// Aliased as `all`.
|
||||
_.every = _.all = function(obj, iterator, context) {
|
||||
var result = true;
|
||||
if (obj == null) return result;
|
||||
if (nativeEvery && obj.every === nativeEvery) return obj.every(iterator, context);
|
||||
each(obj, function(value, index, list) {
|
||||
if (!(result = result && iterator.call(context, value, index, list))) return breaker;
|
||||
});
|
||||
return result;
|
||||
};
|
||||
|
||||
// Determine if at least one element in the object matches a truth test.
|
||||
// Delegates to **ECMAScript 5**'s native `some` if available.
|
||||
// Aliased as `any`.
|
||||
var any = _.some = _.any = function(obj, iterator, context) {
|
||||
iterator || (iterator = _.identity);
|
||||
var result = false;
|
||||
if (obj == null) return result;
|
||||
if (nativeSome && obj.some === nativeSome) return obj.some(iterator, context);
|
||||
each(obj, function(value, index, list) {
|
||||
if (result || (result = iterator.call(context, value, index, list))) return breaker;
|
||||
});
|
||||
return !!result;
|
||||
};
|
||||
|
||||
// Determine if a given value is included in the array or object using `===`.
|
||||
// Aliased as `contains`.
|
||||
_.include = _.contains = function(obj, target) {
|
||||
var found = false;
|
||||
if (obj == null) return found;
|
||||
if (nativeIndexOf && obj.indexOf === nativeIndexOf) return obj.indexOf(target) != -1;
|
||||
found = any(obj, function(value) {
|
||||
return value === target;
|
||||
});
|
||||
return found;
|
||||
};
|
||||
|
||||
// Invoke a method (with arguments) on every item in a collection.
|
||||
_.invoke = function(obj, method) {
|
||||
var args = slice.call(arguments, 2);
|
||||
return _.map(obj, function(value) {
|
||||
return (_.isFunction(method) ? method || value : value[method]).apply(value, args);
|
||||
});
|
||||
};
|
||||
|
||||
// Convenience version of a common use case of `map`: fetching a property.
|
||||
_.pluck = function(obj, key) {
|
||||
return _.map(obj, function(value){ return value[key]; });
|
||||
};
|
||||
|
||||
// Return the maximum element or (element-based computation).
|
||||
_.max = function(obj, iterator, context) {
|
||||
if (!iterator && _.isArray(obj)) return Math.max.apply(Math, obj);
|
||||
if (!iterator && _.isEmpty(obj)) return -Infinity;
|
||||
var result = {computed : -Infinity};
|
||||
each(obj, function(value, index, list) {
|
||||
var computed = iterator ? iterator.call(context, value, index, list) : value;
|
||||
computed >= result.computed && (result = {value : value, computed : computed});
|
||||
});
|
||||
return result.value;
|
||||
};
|
||||
|
||||
// Return the minimum element (or element-based computation).
|
||||
_.min = function(obj, iterator, context) {
|
||||
if (!iterator && _.isArray(obj)) return Math.min.apply(Math, obj);
|
||||
if (!iterator && _.isEmpty(obj)) return Infinity;
|
||||
var result = {computed : Infinity};
|
||||
each(obj, function(value, index, list) {
|
||||
var computed = iterator ? iterator.call(context, value, index, list) : value;
|
||||
computed < result.computed && (result = {value : value, computed : computed});
|
||||
});
|
||||
return result.value;
|
||||
};
|
||||
|
||||
// Shuffle an array.
|
||||
_.shuffle = function(obj) {
|
||||
var shuffled = [], rand;
|
||||
each(obj, function(value, index, list) {
|
||||
if (index == 0) {
|
||||
shuffled[0] = value;
|
||||
} else {
|
||||
rand = Math.floor(Math.random() * (index + 1));
|
||||
shuffled[index] = shuffled[rand];
|
||||
shuffled[rand] = value;
|
||||
}
|
||||
});
|
||||
return shuffled;
|
||||
};
|
||||
|
||||
// Sort the object's values by a criterion produced by an iterator.
|
||||
_.sortBy = function(obj, iterator, context) {
|
||||
return _.pluck(_.map(obj, function(value, index, list) {
|
||||
return {
|
||||
value : value,
|
||||
criteria : iterator.call(context, value, index, list)
|
||||
};
|
||||
}).sort(function(left, right) {
|
||||
var a = left.criteria, b = right.criteria;
|
||||
return a < b ? -1 : a > b ? 1 : 0;
|
||||
}), 'value');
|
||||
};
|
||||
|
||||
// Groups the object's values by a criterion. Pass either a string attribute
|
||||
// to group by, or a function that returns the criterion.
|
||||
_.groupBy = function(obj, val) {
|
||||
var result = {};
|
||||
var iterator = _.isFunction(val) ? val : function(obj) { return obj[val]; };
|
||||
each(obj, function(value, index) {
|
||||
var key = iterator(value, index);
|
||||
(result[key] || (result[key] = [])).push(value);
|
||||
});
|
||||
return result;
|
||||
};
|
||||
|
||||
// Use a comparator function to figure out at what index an object should
|
||||
// be inserted so as to maintain order. Uses binary search.
|
||||
_.sortedIndex = function(array, obj, iterator) {
|
||||
iterator || (iterator = _.identity);
|
||||
var low = 0, high = array.length;
|
||||
while (low < high) {
|
||||
var mid = (low + high) >> 1;
|
||||
iterator(array[mid]) < iterator(obj) ? low = mid + 1 : high = mid;
|
||||
}
|
||||
return low;
|
||||
};
|
||||
|
||||
// Safely convert anything iterable into a real, live array.
|
||||
_.toArray = function(iterable) {
|
||||
if (!iterable) return [];
|
||||
if (iterable.toArray) return iterable.toArray();
|
||||
if (_.isArray(iterable)) return slice.call(iterable);
|
||||
if (_.isArguments(iterable)) return slice.call(iterable);
|
||||
return _.values(iterable);
|
||||
};
|
||||
|
||||
// Return the number of elements in an object.
|
||||
_.size = function(obj) {
|
||||
return _.toArray(obj).length;
|
||||
};
|
||||
|
||||
// Array Functions
|
||||
// ---------------
|
||||
|
||||
// Get the first element of an array. Passing **n** will return the first N
|
||||
// values in the array. Aliased as `head`. The **guard** check allows it to work
|
||||
// with `_.map`.
|
||||
_.first = _.head = function(array, n, guard) {
|
||||
return (n != null) && !guard ? slice.call(array, 0, n) : array[0];
|
||||
};
|
||||
|
||||
// Returns everything but the last entry of the array. Especcialy useful on
|
||||
// the arguments object. Passing **n** will return all the values in
|
||||
// the array, excluding the last N. The **guard** check allows it to work with
|
||||
// `_.map`.
|
||||
_.initial = function(array, n, guard) {
|
||||
return slice.call(array, 0, array.length - ((n == null) || guard ? 1 : n));
|
||||
};
|
||||
|
||||
// Get the last element of an array. Passing **n** will return the last N
|
||||
// values in the array. The **guard** check allows it to work with `_.map`.
|
||||
_.last = function(array, n, guard) {
|
||||
if ((n != null) && !guard) {
|
||||
return slice.call(array, Math.max(array.length - n, 0));
|
||||
} else {
|
||||
return array[array.length - 1];
|
||||
}
|
||||
};
|
||||
|
||||
// Returns everything but the first entry of the array. Aliased as `tail`.
|
||||
// Especially useful on the arguments object. Passing an **index** will return
|
||||
// the rest of the values in the array from that index onward. The **guard**
|
||||
// check allows it to work with `_.map`.
|
||||
_.rest = _.tail = function(array, index, guard) {
|
||||
return slice.call(array, (index == null) || guard ? 1 : index);
|
||||
};
|
||||
|
||||
// Trim out all falsy values from an array.
|
||||
_.compact = function(array) {
|
||||
return _.filter(array, function(value){ return !!value; });
|
||||
};
|
||||
|
||||
// Return a completely flattened version of an array.
|
||||
_.flatten = function(array, shallow) {
|
||||
return _.reduce(array, function(memo, value) {
|
||||
if (_.isArray(value)) return memo.concat(shallow ? value : _.flatten(value));
|
||||
memo[memo.length] = value;
|
||||
return memo;
|
||||
}, []);
|
||||
};
|
||||
|
||||
// Return a version of the array that does not contain the specified value(s).
|
||||
_.without = function(array) {
|
||||
return _.difference(array, slice.call(arguments, 1));
|
||||
};
|
||||
|
||||
// Produce a duplicate-free version of the array. If the array has already
|
||||
// been sorted, you have the option of using a faster algorithm.
|
||||
// Aliased as `unique`.
|
||||
_.uniq = _.unique = function(array, isSorted, iterator) {
|
||||
var initial = iterator ? _.map(array, iterator) : array;
|
||||
var result = [];
|
||||
_.reduce(initial, function(memo, el, i) {
|
||||
if (0 == i || (isSorted === true ? _.last(memo) != el : !_.include(memo, el))) {
|
||||
memo[memo.length] = el;
|
||||
result[result.length] = array[i];
|
||||
}
|
||||
return memo;
|
||||
}, []);
|
||||
return result;
|
||||
};
|
||||
|
||||
// Produce an array that contains the union: each distinct element from all of
|
||||
// the passed-in arrays.
|
||||
_.union = function() {
|
||||
return _.uniq(_.flatten(arguments, true));
|
||||
};
|
||||
|
||||
// Produce an array that contains every item shared between all the
|
||||
// passed-in arrays. (Aliased as "intersect" for back-compat.)
|
||||
_.intersection = _.intersect = function(array) {
|
||||
var rest = slice.call(arguments, 1);
|
||||
return _.filter(_.uniq(array), function(item) {
|
||||
return _.every(rest, function(other) {
|
||||
return _.indexOf(other, item) >= 0;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// Take the difference between one array and a number of other arrays.
|
||||
// Only the elements present in just the first array will remain.
|
||||
_.difference = function(array) {
|
||||
var rest = _.flatten(slice.call(arguments, 1));
|
||||
return _.filter(array, function(value){ return !_.include(rest, value); });
|
||||
};
|
||||
|
||||
// Zip together multiple lists into a single array -- elements that share
|
||||
// an index go together.
|
||||
_.zip = function() {
|
||||
var args = slice.call(arguments);
|
||||
var length = _.max(_.pluck(args, 'length'));
|
||||
var results = new Array(length);
|
||||
for (var i = 0; i < length; i++) results[i] = _.pluck(args, "" + i);
|
||||
return results;
|
||||
};
|
||||
|
||||
// If the browser doesn't supply us with indexOf (I'm looking at you, **MSIE**),
|
||||
// we need this function. Return the position of the first occurrence of an
|
||||
// item in an array, or -1 if the item is not included in the array.
|
||||
// Delegates to **ECMAScript 5**'s native `indexOf` if available.
|
||||
// If the array is large and already in sort order, pass `true`
|
||||
// for **isSorted** to use binary search.
|
||||
_.indexOf = function(array, item, isSorted) {
|
||||
if (array == null) return -1;
|
||||
var i, l;
|
||||
if (isSorted) {
|
||||
i = _.sortedIndex(array, item);
|
||||
return array[i] === item ? i : -1;
|
||||
}
|
||||
if (nativeIndexOf && array.indexOf === nativeIndexOf) return array.indexOf(item);
|
||||
for (i = 0, l = array.length; i < l; i++) if (i in array && array[i] === item) return i;
|
||||
return -1;
|
||||
};
|
||||
|
||||
// Delegates to **ECMAScript 5**'s native `lastIndexOf` if available.
|
||||
_.lastIndexOf = function(array, item) {
|
||||
if (array == null) return -1;
|
||||
if (nativeLastIndexOf && array.lastIndexOf === nativeLastIndexOf) return array.lastIndexOf(item);
|
||||
var i = array.length;
|
||||
while (i--) if (i in array && array[i] === item) return i;
|
||||
return -1;
|
||||
};
|
||||
|
||||
// Generate an integer Array containing an arithmetic progression. A port of
|
||||
// the native Python `range()` function. See
|
||||
// [the Python documentation](http://docs.python.org/library/functions.html#range).
|
||||
_.range = function(start, stop, step) {
|
||||
if (arguments.length <= 1) {
|
||||
stop = start || 0;
|
||||
start = 0;
|
||||
}
|
||||
step = arguments[2] || 1;
|
||||
|
||||
var len = Math.max(Math.ceil((stop - start) / step), 0);
|
||||
var idx = 0;
|
||||
var range = new Array(len);
|
||||
|
||||
while(idx < len) {
|
||||
range[idx++] = start;
|
||||
start += step;
|
||||
}
|
||||
|
||||
return range;
|
||||
};
|
||||
|
||||
// Function (ahem) Functions
|
||||
// ------------------
|
||||
|
||||
// Reusable constructor function for prototype setting.
|
||||
var ctor = function(){};
|
||||
|
||||
// Create a function bound to a given object (assigning `this`, and arguments,
|
||||
// optionally). Binding with arguments is also known as `curry`.
|
||||
// Delegates to **ECMAScript 5**'s native `Function.bind` if available.
|
||||
// We check for `func.bind` first, to fail fast when `func` is undefined.
|
||||
_.bind = function bind(func, context) {
|
||||
var bound, args;
|
||||
if (func.bind === nativeBind && nativeBind) return nativeBind.apply(func, slice.call(arguments, 1));
|
||||
if (!_.isFunction(func)) throw new TypeError;
|
||||
args = slice.call(arguments, 2);
|
||||
return bound = function() {
|
||||
if (!(this instanceof bound)) return func.apply(context, args.concat(slice.call(arguments)));
|
||||
ctor.prototype = func.prototype;
|
||||
var self = new ctor;
|
||||
var result = func.apply(self, args.concat(slice.call(arguments)));
|
||||
if (Object(result) === result) return result;
|
||||
return self;
|
||||
};
|
||||
};
|
||||
|
||||
// Bind all of an object's methods to that object. Useful for ensuring that
|
||||
// all callbacks defined on an object belong to it.
|
||||
_.bindAll = function(obj) {
|
||||
var funcs = slice.call(arguments, 1);
|
||||
if (funcs.length == 0) funcs = _.functions(obj);
|
||||
each(funcs, function(f) { obj[f] = _.bind(obj[f], obj); });
|
||||
return obj;
|
||||
};
|
||||
|
||||
// Memoize an expensive function by storing its results.
|
||||
_.memoize = function(func, hasher) {
|
||||
var memo = {};
|
||||
hasher || (hasher = _.identity);
|
||||
return function() {
|
||||
var key = hasher.apply(this, arguments);
|
||||
return _.has(memo, key) ? memo[key] : (memo[key] = func.apply(this, arguments));
|
||||
};
|
||||
};
|
||||
|
||||
// Delays a function for the given number of milliseconds, and then calls
|
||||
// it with the arguments supplied.
|
||||
_.delay = function(func, wait) {
|
||||
var args = slice.call(arguments, 2);
|
||||
return setTimeout(function(){ return func.apply(func, args); }, wait);
|
||||
};
|
||||
|
||||
// Defers a function, scheduling it to run after the current call stack has
|
||||
// cleared.
|
||||
_.defer = function(func) {
|
||||
return _.delay.apply(_, [func, 1].concat(slice.call(arguments, 1)));
|
||||
};
|
||||
|
||||
// Returns a function, that, when invoked, will only be triggered at most once
|
||||
// during a given window of time.
|
||||
_.throttle = function(func, wait) {
|
||||
var context, args, timeout, throttling, more;
|
||||
var whenDone = _.debounce(function(){ more = throttling = false; }, wait);
|
||||
return function() {
|
||||
context = this; args = arguments;
|
||||
var later = function() {
|
||||
timeout = null;
|
||||
if (more) func.apply(context, args);
|
||||
whenDone();
|
||||
};
|
||||
if (!timeout) timeout = setTimeout(later, wait);
|
||||
if (throttling) {
|
||||
more = true;
|
||||
} else {
|
||||
func.apply(context, args);
|
||||
}
|
||||
whenDone();
|
||||
throttling = true;
|
||||
};
|
||||
};
|
||||
|
||||
// Returns a function, that, as long as it continues to be invoked, will not
|
||||
// be triggered. The function will be called after it stops being called for
|
||||
// N milliseconds.
|
||||
_.debounce = function(func, wait) {
|
||||
var timeout;
|
||||
return function() {
|
||||
var context = this, args = arguments;
|
||||
var later = function() {
|
||||
timeout = null;
|
||||
func.apply(context, args);
|
||||
};
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(later, wait);
|
||||
};
|
||||
};
|
||||
|
||||
// Returns a function that will be executed at most one time, no matter how
|
||||
// often you call it. Useful for lazy initialization.
|
||||
_.once = function(func) {
|
||||
var ran = false, memo;
|
||||
return function() {
|
||||
if (ran) return memo;
|
||||
ran = true;
|
||||
return memo = func.apply(this, arguments);
|
||||
};
|
||||
};
|
||||
|
||||
// Returns the first function passed as an argument to the second,
|
||||
// allowing you to adjust arguments, run code before and after, and
|
||||
// conditionally execute the original function.
|
||||
_.wrap = function(func, wrapper) {
|
||||
return function() {
|
||||
var args = [func].concat(slice.call(arguments, 0));
|
||||
return wrapper.apply(this, args);
|
||||
};
|
||||
};
|
||||
|
||||
// Returns a function that is the composition of a list of functions, each
|
||||
// consuming the return value of the function that follows.
|
||||
_.compose = function() {
|
||||
var funcs = arguments;
|
||||
return function() {
|
||||
var args = arguments;
|
||||
for (var i = funcs.length - 1; i >= 0; i--) {
|
||||
args = [funcs[i].apply(this, args)];
|
||||
}
|
||||
return args[0];
|
||||
};
|
||||
};
|
||||
|
||||
// Returns a function that will only be executed after being called N times.
|
||||
_.after = function(times, func) {
|
||||
if (times <= 0) return func();
|
||||
return function() {
|
||||
if (--times < 1) { return func.apply(this, arguments); }
|
||||
};
|
||||
};
|
||||
|
||||
// Object Functions
|
||||
// ----------------
|
||||
|
||||
// Retrieve the names of an object's properties.
|
||||
// Delegates to **ECMAScript 5**'s native `Object.keys`
|
||||
_.keys = nativeKeys || function(obj) {
|
||||
if (obj !== Object(obj)) throw new TypeError('Invalid object');
|
||||
var keys = [];
|
||||
for (var key in obj) if (_.has(obj, key)) keys[keys.length] = key;
|
||||
return keys;
|
||||
};
|
||||
|
||||
// Retrieve the values of an object's properties.
|
||||
_.values = function(obj) {
|
||||
return _.map(obj, _.identity);
|
||||
};
|
||||
|
||||
// Return a sorted list of the function names available on the object.
|
||||
// Aliased as `methods`
|
||||
_.functions = _.methods = function(obj) {
|
||||
var names = [];
|
||||
for (var key in obj) {
|
||||
if (_.isFunction(obj[key])) names.push(key);
|
||||
}
|
||||
return names.sort();
|
||||
};
|
||||
|
||||
// Extend a given object with all the properties in passed-in object(s).
|
||||
_.extend = function(obj) {
|
||||
each(slice.call(arguments, 1), function(source) {
|
||||
for (var prop in source) {
|
||||
obj[prop] = source[prop];
|
||||
}
|
||||
});
|
||||
return obj;
|
||||
};
|
||||
|
||||
// Fill in a given object with default properties.
|
||||
_.defaults = function(obj) {
|
||||
each(slice.call(arguments, 1), function(source) {
|
||||
for (var prop in source) {
|
||||
if (obj[prop] == null) obj[prop] = source[prop];
|
||||
}
|
||||
});
|
||||
return obj;
|
||||
};
|
||||
|
||||
// Create a (shallow-cloned) duplicate of an object.
|
||||
_.clone = function(obj) {
|
||||
if (!_.isObject(obj)) return obj;
|
||||
return _.isArray(obj) ? obj.slice() : _.extend({}, obj);
|
||||
};
|
||||
|
||||
// Invokes interceptor with the obj, and then returns obj.
|
||||
// The primary purpose of this method is to "tap into" a method chain, in
|
||||
// order to perform operations on intermediate results within the chain.
|
||||
_.tap = function(obj, interceptor) {
|
||||
interceptor(obj);
|
||||
return obj;
|
||||
};
|
||||
|
||||
// Internal recursive comparison function.
|
||||
function eq(a, b, stack) {
|
||||
// Identical objects are equal. `0 === -0`, but they aren't identical.
|
||||
// See the Harmony `egal` proposal: http://wiki.ecmascript.org/doku.php?id=harmony:egal.
|
||||
if (a === b) return a !== 0 || 1 / a == 1 / b;
|
||||
// A strict comparison is necessary because `null == undefined`.
|
||||
if (a == null || b == null) return a === b;
|
||||
// Unwrap any wrapped objects.
|
||||
if (a._chain) a = a._wrapped;
|
||||
if (b._chain) b = b._wrapped;
|
||||
// Invoke a custom `isEqual` method if one is provided.
|
||||
if (a.isEqual && _.isFunction(a.isEqual)) return a.isEqual(b);
|
||||
if (b.isEqual && _.isFunction(b.isEqual)) return b.isEqual(a);
|
||||
// Compare `[[Class]]` names.
|
||||
var className = toString.call(a);
|
||||
if (className != toString.call(b)) return false;
|
||||
switch (className) {
|
||||
// Strings, numbers, dates, and booleans are compared by value.
|
||||
case '[object String]':
|
||||
// Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is
|
||||
// equivalent to `new String("5")`.
|
||||
return a == String(b);
|
||||
case '[object Number]':
|
||||
// `NaN`s are equivalent, but non-reflexive. An `egal` comparison is performed for
|
||||
// other numeric values.
|
||||
return a != +a ? b != +b : (a == 0 ? 1 / a == 1 / b : a == +b);
|
||||
case '[object Date]':
|
||||
case '[object Boolean]':
|
||||
// Coerce dates and booleans to numeric primitive values. Dates are compared by their
|
||||
// millisecond representations. Note that invalid dates with millisecond representations
|
||||
// of `NaN` are not equivalent.
|
||||
return +a == +b;
|
||||
// RegExps are compared by their source patterns and flags.
|
||||
case '[object RegExp]':
|
||||
return a.source == b.source &&
|
||||
a.global == b.global &&
|
||||
a.multiline == b.multiline &&
|
||||
a.ignoreCase == b.ignoreCase;
|
||||
}
|
||||
if (typeof a != 'object' || typeof b != 'object') return false;
|
||||
// Assume equality for cyclic structures. The algorithm for detecting cyclic
|
||||
// structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.
|
||||
var length = stack.length;
|
||||
while (length--) {
|
||||
// Linear search. Performance is inversely proportional to the number of
|
||||
// unique nested structures.
|
||||
if (stack[length] == a) return true;
|
||||
}
|
||||
// Add the first object to the stack of traversed objects.
|
||||
stack.push(a);
|
||||
var size = 0, result = true;
|
||||
// Recursively compare objects and arrays.
|
||||
if (className == '[object Array]') {
|
||||
// Compare array lengths to determine if a deep comparison is necessary.
|
||||
size = a.length;
|
||||
result = size == b.length;
|
||||
if (result) {
|
||||
// Deep compare the contents, ignoring non-numeric properties.
|
||||
while (size--) {
|
||||
// Ensure commutative equality for sparse arrays.
|
||||
if (!(result = size in a == size in b && eq(a[size], b[size], stack))) break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Objects with different constructors are not equivalent.
|
||||
if ('constructor' in a != 'constructor' in b || a.constructor != b.constructor) return false;
|
||||
// Deep compare objects.
|
||||
for (var key in a) {
|
||||
if (_.has(a, key)) {
|
||||
// Count the expected number of properties.
|
||||
size++;
|
||||
// Deep compare each member.
|
||||
if (!(result = _.has(b, key) && eq(a[key], b[key], stack))) break;
|
||||
}
|
||||
}
|
||||
// Ensure that both objects contain the same number of properties.
|
||||
if (result) {
|
||||
for (key in b) {
|
||||
if (_.has(b, key) && !(size--)) break;
|
||||
}
|
||||
result = !size;
|
||||
}
|
||||
}
|
||||
// Remove the first object from the stack of traversed objects.
|
||||
stack.pop();
|
||||
return result;
|
||||
}
|
||||
|
||||
// Perform a deep comparison to check if two objects are equal.
|
||||
_.isEqual = function(a, b) {
|
||||
return eq(a, b, []);
|
||||
};
|
||||
|
||||
// Is a given array, string, or object empty?
|
||||
// An "empty" object has no enumerable own-properties.
|
||||
_.isEmpty = function(obj) {
|
||||
if (_.isArray(obj) || _.isString(obj)) return obj.length === 0;
|
||||
for (var key in obj) if (_.has(obj, key)) return false;
|
||||
return true;
|
||||
};
|
||||
|
||||
// Is a given value a DOM element?
|
||||
_.isElement = function(obj) {
|
||||
return !!(obj && obj.nodeType == 1);
|
||||
};
|
||||
|
||||
// Is a given value an array?
|
||||
// Delegates to ECMA5's native Array.isArray
|
||||
_.isArray = nativeIsArray || function(obj) {
|
||||
return toString.call(obj) == '[object Array]';
|
||||
};
|
||||
|
||||
// Is a given variable an object?
|
||||
_.isObject = function(obj) {
|
||||
return obj === Object(obj);
|
||||
};
|
||||
|
||||
// Is a given variable an arguments object?
|
||||
_.isArguments = function(obj) {
|
||||
return toString.call(obj) == '[object Arguments]';
|
||||
};
|
||||
if (!_.isArguments(arguments)) {
|
||||
_.isArguments = function(obj) {
|
||||
return !!(obj && _.has(obj, 'callee'));
|
||||
};
|
||||
}
|
||||
|
||||
// Is a given value a function?
|
||||
_.isFunction = function(obj) {
|
||||
return toString.call(obj) == '[object Function]';
|
||||
};
|
||||
|
||||
// Is a given value a string?
|
||||
_.isString = function(obj) {
|
||||
return toString.call(obj) == '[object String]';
|
||||
};
|
||||
|
||||
// Is a given value a number?
|
||||
_.isNumber = function(obj) {
|
||||
return toString.call(obj) == '[object Number]';
|
||||
};
|
||||
|
||||
// Is the given value `NaN`?
|
||||
_.isNaN = function(obj) {
|
||||
// `NaN` is the only value for which `===` is not reflexive.
|
||||
return obj !== obj;
|
||||
};
|
||||
|
||||
// Is a given value a boolean?
|
||||
_.isBoolean = function(obj) {
|
||||
return obj === true || obj === false || toString.call(obj) == '[object Boolean]';
|
||||
};
|
||||
|
||||
// Is a given value a date?
|
||||
_.isDate = function(obj) {
|
||||
return toString.call(obj) == '[object Date]';
|
||||
};
|
||||
|
||||
// Is the given value a regular expression?
|
||||
_.isRegExp = function(obj) {
|
||||
return toString.call(obj) == '[object RegExp]';
|
||||
};
|
||||
|
||||
// Is a given value equal to null?
|
||||
_.isNull = function(obj) {
|
||||
return obj === null;
|
||||
};
|
||||
|
||||
// Is a given variable undefined?
|
||||
_.isUndefined = function(obj) {
|
||||
return obj === void 0;
|
||||
};
|
||||
|
||||
// Has own property?
|
||||
_.has = function(obj, key) {
|
||||
return hasOwnProperty.call(obj, key);
|
||||
};
|
||||
|
||||
// Utility Functions
|
||||
// -----------------
|
||||
|
||||
// Run Underscore.js in *noConflict* mode, returning the `_` variable to its
|
||||
// previous owner. Returns a reference to the Underscore object.
|
||||
_.noConflict = function() {
|
||||
root._ = previousUnderscore;
|
||||
return this;
|
||||
};
|
||||
|
||||
// Keep the identity function around for default iterators.
|
||||
_.identity = function(value) {
|
||||
return value;
|
||||
};
|
||||
|
||||
// Run a function **n** times.
|
||||
_.times = function (n, iterator, context) {
|
||||
for (var i = 0; i < n; i++) iterator.call(context, i);
|
||||
};
|
||||
|
||||
// Escape a string for HTML interpolation.
|
||||
_.escape = function(string) {
|
||||
return (''+string).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''').replace(/\//g,'/');
|
||||
};
|
||||
|
||||
// Add your own custom functions to the Underscore object, ensuring that
|
||||
// they're correctly added to the OOP wrapper as well.
|
||||
_.mixin = function(obj) {
|
||||
each(_.functions(obj), function(name){
|
||||
addToWrapper(name, _[name] = obj[name]);
|
||||
});
|
||||
};
|
||||
|
||||
// Generate a unique integer id (unique within the entire client session).
|
||||
// Useful for temporary DOM ids.
|
||||
var idCounter = 0;
|
||||
_.uniqueId = function(prefix) {
|
||||
var id = idCounter++;
|
||||
return prefix ? prefix + id : id;
|
||||
};
|
||||
|
||||
// By default, Underscore uses ERB-style template delimiters, change the
|
||||
// following template settings to use alternative delimiters.
|
||||
_.templateSettings = {
|
||||
evaluate : /<%([\s\S]+?)%>/g,
|
||||
interpolate : /<%=([\s\S]+?)%>/g,
|
||||
escape : /<%-([\s\S]+?)%>/g
|
||||
};
|
||||
|
||||
// When customizing `templateSettings`, if you don't want to define an
|
||||
// interpolation, evaluation or escaping regex, we need one that is
|
||||
// guaranteed not to match.
|
||||
var noMatch = /.^/;
|
||||
|
||||
// Within an interpolation, evaluation, or escaping, remove HTML escaping
|
||||
// that had been previously added.
|
||||
var unescape = function(code) {
|
||||
return code.replace(/\\\\/g, '\\').replace(/\\'/g, "'");
|
||||
};
|
||||
|
||||
// JavaScript micro-templating, similar to John Resig's implementation.
|
||||
// Underscore templating handles arbitrary delimiters, preserves whitespace,
|
||||
// and correctly escapes quotes within interpolated code.
|
||||
_.template = function(str, data) {
|
||||
var c = _.templateSettings;
|
||||
var tmpl = 'var __p=[],print=function(){__p.push.apply(__p,arguments);};' +
|
||||
'with(obj||{}){__p.push(\'' +
|
||||
str.replace(/\\/g, '\\\\')
|
||||
.replace(/'/g, "\\'")
|
||||
.replace(c.escape || noMatch, function(match, code) {
|
||||
return "',_.escape(" + unescape(code) + "),'";
|
||||
})
|
||||
.replace(c.interpolate || noMatch, function(match, code) {
|
||||
return "'," + unescape(code) + ",'";
|
||||
})
|
||||
.replace(c.evaluate || noMatch, function(match, code) {
|
||||
return "');" + unescape(code).replace(/[\r\n\t]/g, ' ') + ";__p.push('";
|
||||
})
|
||||
.replace(/\r/g, '\\r')
|
||||
.replace(/\n/g, '\\n')
|
||||
.replace(/\t/g, '\\t')
|
||||
+ "');}return __p.join('');";
|
||||
var func = new Function('obj', '_', tmpl);
|
||||
if (data) return func(data, _);
|
||||
return function(data) {
|
||||
return func.call(this, data, _);
|
||||
};
|
||||
};
|
||||
|
||||
// Add a "chain" function, which will delegate to the wrapper.
|
||||
_.chain = function(obj) {
|
||||
return _(obj).chain();
|
||||
};
|
||||
|
||||
// The OOP Wrapper
|
||||
// ---------------
|
||||
|
||||
// If Underscore is called as a function, it returns a wrapped object that
|
||||
// can be used OO-style. This wrapper holds altered versions of all the
|
||||
// underscore functions. Wrapped objects may be chained.
|
||||
var wrapper = function(obj) { this._wrapped = obj; };
|
||||
|
||||
// Expose `wrapper.prototype` as `_.prototype`
|
||||
_.prototype = wrapper.prototype;
|
||||
|
||||
// Helper function to continue chaining intermediate results.
|
||||
var result = function(obj, chain) {
|
||||
return chain ? _(obj).chain() : obj;
|
||||
};
|
||||
|
||||
// A method to easily add functions to the OOP wrapper.
|
||||
var addToWrapper = function(name, func) {
|
||||
wrapper.prototype[name] = function() {
|
||||
var args = slice.call(arguments);
|
||||
unshift.call(args, this._wrapped);
|
||||
return result(func.apply(_, args), this._chain);
|
||||
};
|
||||
};
|
||||
|
||||
// Add all of the Underscore functions to the wrapper object.
|
||||
_.mixin(_);
|
||||
|
||||
// Add all mutator Array functions to the wrapper.
|
||||
each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) {
|
||||
var method = ArrayProto[name];
|
||||
wrapper.prototype[name] = function() {
|
||||
var wrapped = this._wrapped;
|
||||
method.apply(wrapped, arguments);
|
||||
var length = wrapped.length;
|
||||
if ((name == 'shift' || name == 'splice') && length === 0) delete wrapped[0];
|
||||
return result(wrapped, this._chain);
|
||||
};
|
||||
});
|
||||
|
||||
// Add all accessor Array functions to the wrapper.
|
||||
each(['concat', 'join', 'slice'], function(name) {
|
||||
var method = ArrayProto[name];
|
||||
wrapper.prototype[name] = function() {
|
||||
return result(method.apply(this._wrapped, arguments), this._chain);
|
||||
};
|
||||
});
|
||||
|
||||
// Start chaining a wrapped Underscore object.
|
||||
wrapper.prototype.chain = function() {
|
||||
this._chain = true;
|
||||
return this;
|
||||
};
|
||||
|
||||
// Extracts the result from a wrapped and chained object.
|
||||
wrapper.prototype.value = function() {
|
||||
return this._wrapped;
|
||||
};
|
||||
|
||||
}).call(this);
|
Before Width: | Height: | Size: 214 B |