1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615
|
<HTML>
<BODY>
<H1 ALIGN="RIGHT"><A NAME="ADVANCED">4 - Advanced Packaging with EPM</A></H1>
<P>This chapter describes the advanced packaging features of EPM.</P>
<H2>Including Other List Files</H2>
<P>The <CODE>%include</CODE> directive includes another list
file:</P>
<PRE>
%include filename
</PRE>
<P>Includes can usually be nested up to 250 levels depending on
the host operating system and libraries.</P>
<H2>Dependencies</H2>
<P>EPM supports four types of dependencies in list files:
<CODE>%incompat</CODE>, <CODE>%provides</CODE>,
<CODE>%replaces</CODE>, and <CODE>%requires</CODE>. <A
HREF="#TABLE_4_1">Table 4.1</A> shows the level of support for
each package format.</P>
<!-- NEED 5in -->
<CENTER><TABLE BORDER CELLPADDING="2">
<CAPTION><A NAME="TABLE_4_1">Table 4.1: Dependency Support</A></CAPTION>
<TR>
<TH>Format</TH>
<TH>%incompat</TH>
<TH>%provides</TH>
<TH>%replaces</TH>
<TH>%requires</TH>
</TR>
<TR>
<TD ALIGN="CENTER">aix</TD>
<TD ALIGN="CENTER">No</TD>
<TD ALIGN="CENTER">No</TD>
<TD ALIGN="CENTER">Yes</TD>
<TD ALIGN="CENTER">Yes</TD>
</TR>
<TR>
<TD ALIGN="CENTER">bsd</TD>
<TD ALIGN="CENTER">Yes</TD>
<TD ALIGN="CENTER">No</TD>
<TD ALIGN="CENTER">No</TD>
<TD ALIGN="CENTER">Yes</TD>
</TR>
<TR>
<TD ALIGN="CENTER">deb</TD>
<TD ALIGN="CENTER">Yes</TD>
<TD ALIGN="CENTER">Yes<SUP>1</SUP></TD>
<TD ALIGN="CENTER">Yes</TD>
<TD ALIGN="CENTER">Yes</TD>
</TR>
<TR>
<TD ALIGN="CENTER">inst</TD>
<TD ALIGN="CENTER">Yes</TD>
<TD ALIGN="CENTER">No</TD>
<TD ALIGN="CENTER">Yes</TD>
<TD ALIGN="CENTER">Yes</TD>
</TR>
<TR>
<TD ALIGN="CENTER">osx</TD>
<TD ALIGN="CENTER">No</TD>
<TD ALIGN="CENTER">No</TD>
<TD ALIGN="CENTER">No</TD>
<TD ALIGN="CENTER">No</TD>
</TR>
<TR>
<TD ALIGN="CENTER">pkg</TD>
<TD ALIGN="CENTER">Yes</TD>
<TD ALIGN="CENTER">No</TD>
<TD ALIGN="CENTER">No</TD>
<TD ALIGN="CENTER">Yes</TD>
</TR>
<TR>
<TD ALIGN="CENTER">portable</TD>
<TD ALIGN="CENTER">Yes</TD>
<TD ALIGN="CENTER">Yes</TD>
<TD ALIGN="CENTER">Yes</TD>
<TD ALIGN="CENTER">Yes</TD>
</TR>
<TR>
<TD ALIGN="CENTER">rpm</TD>
<TD ALIGN="CENTER">Yes</TD>
<TD ALIGN="CENTER">Yes</TD>
<TD ALIGN="CENTER">No</TD>
<TD ALIGN="CENTER">Yes</TD>
</TR>
<TR>
<TD ALIGN="CENTER">setld</TD>
<TD ALIGN="CENTER">No</TD>
<TD ALIGN="CENTER">No</TD>
<TD ALIGN="CENTER">No</TD>
<TD ALIGN="CENTER">No</TD>
</TR>
<TR>
<TD ALIGN="CENTER">slackware</TD>
<TD ALIGN="CENTER">No</TD>
<TD ALIGN="CENTER">No</TD>
<TD ALIGN="CENTER">No</TD>
<TD ALIGN="CENTER">No</TD>
</TR>
<TR>
<TD ALIGN="CENTER">swinstall</TD>
<TD ALIGN="CENTER">No</TD>
<TD ALIGN="CENTER">No</TD>
<TD ALIGN="CENTER">Yes</TD>
<TD ALIGN="CENTER">Yes</TD>
</TR>
</TABLE></CENTER>
<OL>
<LI>Debian's package format does not currently support
version numbers for <CODE>%provides</CODE>
dependencies.</LI>
</OL>
<P> </P>
<P>Software conflicts and requirements are specified using the
<CODE>%incompat</CODE> and <CODE>%requires</CODE> directives.</P>
<P>If your software replaces another package, you can specify
that using the <CODE>%replaces</CODE> directive.
<CODE>%replaces</CODE> is silently mapped to
<CODE>%incompat</CODE> when the package format does not support
package replacement.</P>
<P>If your package provides certain functionality associated with
a standard name, the <CODE>%provides</CODE> directive can be
used.</P>
<!-- NEED 1in -->
<P>Dependencies are specified using the package name and optionally the
lower and upper version numbers:
<PRE>
%requires foobar
%requires foobar 1.0
%incompat foobar 0.9
%replaces foobar
%replaces foobar 1.2 3.4
%provides foobar
</PRE>
<P>or the filename:</P>
<PRE>
%requires /usr/lib/libfoobar.so
%incompat /usr/lib/libfoobar.so.1.2
</PRE>
<P>Package dependencies are currently enforced only for the same
package format, so a portable distribution that requires package
"foobar" will only look for an installed "foobar" package in
portable format.</P>
<P>Filename dependencies are only supported by the Debian,
portable, and RPM distribution formats.
<H2>Scripts</H2>
<P>Bourne shell script commands can be executed before or after
installation, patching, or removal of the software. <A
HREF="#TABLE_4_2">Table 4.2</A> shows the support for scripts in
each package format.</P>
<P>The <CODE>%preinstall</CODE> and <CODE>%postinstall</CODE>
directives specify commands to be run before and after
installation, respectively:</P>
<PRE>
%preinstall echo Command before installing
%postinstall echo Command after installing
</PRE>
<P>Similarly, the <CODE>%prepatch</CODE> and <CODE>%postpatch</CODE>
directives specify commands to be executed before and after patching
the software:</P>
<PRE>
%prepatch echo Command before patching
%postpatch echo Command after patching
</PRE>
<P>Finally, the <CODE>%preremove</CODE> and <CODE>%postremove</CODE>
directives specify commands that are run before and after removal
of the software:</P>
<PRE>
%preremove echo Command before removing
%postremove echo Command after removing
</PRE>
<!-- NEED 3in -->
<CENTER><TABLE ALIGN="CENTER" BORDER="1">
<CAPTION><A NAME="TABLE_4_2">Table 4.2: Scripts Support</A></CAPTION>
<TR>
<TH><SMALL>Format</SMALL></TH>
<TH><SMALL>%preinstall</SMALL></TH>
<TH><SMALL>%postinstall</SMALL></TH>
<TH><SMALL>%prepatch</SMALL></TH>
<TH><SMALL>%postpatch</SMALL></TH>
<TH><SMALL>%preremove</SMALL></TH>
<TH><SMALL>%postremove</SMALL></TH>
</TR>
<TR>
<TD ALIGN="CENTER">aix</TD>
<TD ALIGN="CENTER">Yes</TD>
<TD ALIGN="CENTER">Yes</TD>
<TD ALIGN="CENTER">No</TD>
<TD ALIGN="CENTER">No</TD>
<TD ALIGN="CENTER">Yes</TD>
<TD ALIGN="CENTER">Yes</TD>
</TR>
<TR>
<TD ALIGN="CENTER">bsd</TD>
<TD ALIGN="CENTER">No</TD>
<TD ALIGN="CENTER">Yes</TD>
<TD ALIGN="CENTER">No</TD>
<TD ALIGN="CENTER">No</TD>
<TD ALIGN="CENTER">Yes</TD>
<TD ALIGN="CENTER">No</TD>
</TR>
<TR>
<TD ALIGN="CENTER">deb</TD>
<TD ALIGN="CENTER">Yes</TD>
<TD ALIGN="CENTER">Yes</TD>
<TD ALIGN="CENTER">No</TD>
<TD ALIGN="CENTER">No</TD>
<TD ALIGN="CENTER">Yes</TD>
<TD ALIGN="CENTER">Yes</TD>
</TR>
<TR>
<TD ALIGN="CENTER">inst</TD>
<TD ALIGN="CENTER">Yes</TD>
<TD ALIGN="CENTER">Yes</TD>
<TD ALIGN="CENTER">No</TD>
<TD ALIGN="CENTER">No</TD>
<TD ALIGN="CENTER">Yes</TD>
<TD ALIGN="CENTER">Yes</TD>
</TR>
<TR>
<TD ALIGN="CENTER">osx</TD>
<TD ALIGN="CENTER">Yes</TD>
<TD ALIGN="CENTER">Yes</TD>
<TD ALIGN="CENTER">No</TD>
<TD ALIGN="CENTER">No</TD>
<TD ALIGN="CENTER">No</TD>
<TD ALIGN="CENTER">No</TD>
</TR>
<TR>
<TD ALIGN="CENTER">pkg</TD>
<TD ALIGN="CENTER">Yes</TD>
<TD ALIGN="CENTER">Yes</TD>
<TD ALIGN="CENTER">No</TD>
<TD ALIGN="CENTER">No</TD>
<TD ALIGN="CENTER">Yes</TD>
<TD ALIGN="CENTER">Yes</TD>
</TR>
<TR>
<TD ALIGN="CENTER">portable</TD>
<TD ALIGN="CENTER">Yes</TD>
<TD ALIGN="CENTER">Yes</TD>
<TD ALIGN="CENTER">Yes</TD>
<TD ALIGN="CENTER">Yes</TD>
<TD ALIGN="CENTER">Yes</TD>
<TD ALIGN="CENTER">Yes</TD>
</TR>
<TR>
<TD ALIGN="CENTER">rpm</TD>
<TD ALIGN="CENTER">Yes</TD>
<TD ALIGN="CENTER">Yes</TD>
<TD ALIGN="CENTER">No</TD>
<TD ALIGN="CENTER">No</TD>
<TD ALIGN="CENTER">Yes</TD>
<TD ALIGN="CENTER">Yes</TD>
</TR>
<TR>
<TD ALIGN="CENTER">setld</TD>
<TD ALIGN="CENTER">Yes</TD>
<TD ALIGN="CENTER">Yes</TD>
<TD ALIGN="CENTER">No</TD>
<TD ALIGN="CENTER">No</TD>
<TD ALIGN="CENTER">Yes</TD>
<TD ALIGN="CENTER">Yes</TD>
</TR>
<TR>
<TD ALIGN="CENTER">slackware</TD>
<TD ALIGN="CENTER">No</TD>
<TD ALIGN="CENTER">Yes</TD>
<TD ALIGN="CENTER">No</TD>
<TD ALIGN="CENTER">No</TD>
<TD ALIGN="CENTER">No</TD>
<TD ALIGN="CENTER">No</TD>
</TR>
<TR>
<TD ALIGN="CENTER">swinstall</TD>
<TD ALIGN="CENTER">Yes</TD>
<TD ALIGN="CENTER">Yes</TD>
<TD ALIGN="CENTER">No</TD>
<TD ALIGN="CENTER">No</TD>
<TD ALIGN="CENTER">Yes</TD>
<TD ALIGN="CENTER">Yes</TD>
</TR>
</TABLE></CENTER>
<P> </P>
<P>To include an external script file, use the
<CODE><filename</CODE> notation:</P>
<PRE>
%postinstall <filename
</PRE>
<P>To include multiple lines directly, use the
<CODE><<string</CODE> notation (a.k.a. a "here" document):</P>
<PRE>
%postinstall <<EOF
echo Command before installing
/usr/bin/foo
EOF
</PRE>
<P>Note that all commands specified in the list file will use
the variable expansion provided by EPM, so be sure to quote any
dollar sign (<CODE>$</CODE>) characters in your commands. For
example, "$foo" is replaced by the value of "foo", but "$$foo"
becomes "$foo".</P>
<!-- NEED 4in -->
<H2>Conditional Directives</H2>
<P>The <CODE>%system</CODE> directive can match or not match
specific operating system names or versions. The operating
system name is the name reported by <CODE>uname</CODE> in
lowercase, while the operating system version is the major and
minor version number reported by <CODE>uname -r</CODE>:
<DL><DD><DL>
<DT><CODE>%system irix</CODE>
<BR> </DT>
<DD>Only include the following files when building a distribution
for the IRIX operating system.
<BR> </DD>
<DT><CODE>%system linux-2.0</CODE>
<BR> </DT>
<DD>Only include the following files when building a distribution
for Linux 2.0.x.
<BR> </DD>
<DT><CODE>%system !irix !linux-2.0</CODE>
<BR> </DT>
<DD>Only include the following files when building a distribution
for operating systems other than IRIX and Linux 2.0.x.
<BR> </DD>
</DL></DD></DL>
<P>The special name <CODE>all</CODE> is used to match all
operating systems:</P>
<PRE>
%system all
</PRE>
<P>For format-specific files, the <CODE>%format</CODE> directive
can be used:</P>
<DL><DD><DL>
<DT><CODE>%format rpm</CODE>
<BR> </DT>
<DD>Only include the following files when building an RPM distribution.
<BR> </DD>
<DT><CODE>%format !rpm</CODE>
<BR> </DT>
<DD>Only include the following files when not building an RPM
distribution.x.
<BR> </DD>
<DT><CODE>%format all</CODE>
<BR> </DT>
<DD>Include the following files for all types of distributions.
<BR> </DD>
</DL></DD></DL>
<P>The <CODE>%arch</CODE> directive can match or not match specific
architectures. The architecture name is the name reported by
<CODE>uname -m</CODE>; "arm" is a synonym for "armv6", "armv7", and "armv8",
"intel" is a synonym for "i386", "i486", "i586", and "i686", and "powerpc" is a
synonym for "ppc":</P>
<DL><DD><DL>
<DT><CODE>%arch intel</CODE>
<BR> </DT>
<DD>Only include the following files when building a package for 32-bit
Intel processors.
<BR> </DD>
<DT><CODE>%arch armv6</CODE>
<BR> </DT>
<DD>Only include the following files when building a package for ARMv6
processors.
<BR> </DD>
<DT><CODE>%system !powerpc</CODE>
<BR> </DT>
<DD>Only include the following files when building a package for
processors other than PowerPC.
<BR> </DD>
</DL></DD></DL>
<P>The special name <CODE>all</CODE> is used to match all architectures:</P>
<PRE>
%arch all
</PRE>
<P>Finally, EPM can conditionally include lines using the
<CODE>%if</CODE>, <CODE>%elseif</CODE>, <CODE>%ifdef</CODE>,
<CODE>%elseifdef</CODE>, <CODE>%else</CODE>, and
<CODE>%endif</CODE> directives.</P>
<P><CODE>%if</CODE> directives include the text that follows if
the named variable(s) are defined to a non-empty string:</P>
<PRE>
%if FOO
f 755 root sys /usr/bin/foo foo
%elseif BAR
f 755 root sys /usr/bin/bar bar
%endif
</PRE>
<P><CODE>%ifdef</CODE> directives only include the text if the
named variable(s) are defined to any value:</P>
<PRE>
%ifdef OSTYPE
f 755 root sys /usr/bin/program program-$OSTYPE
%else
f 755 root sys /usr/bin/program program.sh
%endif
</PRE>
<H2>Protecting Object Files from Stripping</H2>
<P>The <CODE>nostrip()</CODE> option can be included at the end
of a file line to prevent EPM from stripping the symbols and
debugging information from a file:</P>
<PRE>
f 755 root sys /usr/lib/libfoo.so libfoo.so nostrip()
</PRE>
<H2>Software Patches</H2>
<P>EPM supports portable software patch distributions which
contain only the differences between the original and patch
release. Patch files are specified using uppercase letters for
the affected files. In the following example, the files
<VAR>/usr/bin/bar</VAR> and <VAR>/etc/foo.conf</VAR> are
marked</P>
<!-- NEED 2in -->
<P>as changed since the original release:</P>
<PRE>
f 755 root sys /usr/bin/foo foo
F 755 root sys /usr/bin/bar bar
f 755 root sys /usr/share/man/man1/foo.1 foo.man
f 755 root sys /usr/share/man/man1/bar.1 bar.man
C 644 root sys /etc/foo.conf foo.conf
</PRE>
<H2>Variables</H2>
<P>EPM imports the current environment variables for use in your
list file. You can also define new variable in the list file or
on the command-line when running EPM.</P>
<P>Variables are defined by starting the line with the dollar
sign (<CODE>$</CODE>) followed by the name and value:</P>
<PRE>
$name=value
$prefix=/usr
$exec_prefix=${prefix}
$bindir=$exec_prefix/bin
</PRE>
<P>Variable substitution is performed when the variable is
defined, so be careful with the ordering of your variable
definitions.</P>
<P>Also, any variables you specify in your list file will be
overridden by variables defined on the command-line or in your
environment, just like with <CODE>make</CODE>. This can be a
useful feature or a curse, depending on your choice of variable
names.</P>
<P>As you can see, variables are referenced using the dollar
sign (<CODE>$</CODE>). As with most shells, variable names can
be surrounded by curly braces (<CODE>${variable}</CODE>) to
explicitly delimit the name.</P>
<!-- NEED 1in -->
<P>If you need to insert a <CODE>$</CODE> in a filename or a
script, use <CODE>$$</CODE>:</P>
<PRE>
%install echo Enter your name:
%install read $$name
%install echo Your name is $$name.
</PRE>
<H2>Init Scripts</H2>
<P>Initialization scripts are generally portable between
platforms, however the location of initialization scripts varies
greatly.</P>
<P>The <CODE>i</CODE> file type can be used to specify and init
script that is to be installed on the system. EPM will then
determine the appropriate init file directories to use and create
any required symbolic links to support the init script:</P>
<PRE>
i 755 root sys foo foo.sh
</PRE>
<P>The previous example creates an init script named
<VAR>foo</VAR> on the end-user system and will create symbolic
links to run levels 0, 2, 3, and 5 as needed, using a sequence
number of 00 (or 000) for the shutdown script and 99 (or 999) for
the startup script.</P>
<P>To specify run levels and sequence numbers, use the
<CODE>runlevel()</CODE>, <CODE>start()</CODE>, and
<CODE>stop()</CODE> options:</P>
<PRE>
i 755 root sys foo foo.sh "runlevel(02) start(50) stop(30)"
</PRE>
<H2>Literal Package Data</H2>
<P>Sometimes you need to include format-specific package data such as
keywords, signing keys, and response data. The <CODE>%literal(section)</CODE>
directive adds format-specific data to the packages you create. Literal
data is currently only supported for RPM and PKG packages.</P>
<H3>PKG Literal Data</H3>
<P>PKG packages support request files that are used to do batch
installations when installation commands require user input. The
<CODE>%literal(request)</CODE> directive can be used to provide this user
input:</P>
<PRE>
%literal(request) <<EOF
John Doe
1 Any Lane
Forest Lawn, OH 12345
EOF
</PRE>
<H3>RPM Literal Data</H3>
<P>RPM packages support numerous attributes in the "spec" file that control
how the package is created and what metadata is included with the package. The
<CODE>%literal(spec)</CODE> directive can be used to provide attributes for
the spec file:</P>
<PRE>
%literal(spec) <<EOF
%changelog
* Tue Aug 26 2008 John Doe <johndoe@domain.com>
- Added new feature "bar"
* Fri Aug 1 2008 John Doe <johndoe@domain.com>
- Added new feature "foo"
EOF
</PRE>
</BODY>
</HTML>
|