Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add templates to debian package definitions #16

Open
wants to merge 11 commits into
base: trunk
Choose a base branch
from
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#IDE
/.project
/.cproject
/.idea

# Targets build by the configure phase
/Makefile
Expand All @@ -17,6 +18,7 @@
/doc/mantohtml

# Actual targets build for distribution
/build
/epm
/epm.list
/epminstall
Expand Down
70 changes: 70 additions & 0 deletions deb.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,72 @@ make_subpackage(const char *prodname, /* I - Product short name */

fclose(fp);

/*
* Write the config file for DPKG...
*/

for (i = dist->num_commands, c = dist->commands; i > 0; i--, c++)
if (c->type == COMMAND_LITERAL && c->subpackage == subpackage &&
!strcmp(c->section, "config"))
break;

if (i) {
if (Verbosity)
puts("Creating config file...");

snprintf(filename, sizeof(filename), "%s/%s/DEBIAN/config", directory, name);

if ((fp = fopen(filename, "w")) == NULL) {
fprintf(stderr, "epm: Unable to create config file \"%s\": %s\n", filename,
strerror(errno));
return (1);
}

fchmod(fileno(fp), 0755);

fputs("#!/bin/sh\n", fp);
fputs("# " EPM_VERSION "\n", fp);
fputs("set -e\n", fp);

for (; i > 0; i--, c++)
if (c->type == COMMAND_LITERAL && c->subpackage == subpackage &&
!strcmp(c->section, "config"))
fprintf(fp, "%s\n", c->command);

fclose(fp);
}

/*
* Write the templates file for DPKG...
*/

for (i = dist->num_commands, c = dist->commands; i > 0; i--, c++)
if (c->type == COMMAND_LITERAL && c->subpackage == subpackage &&
!strcmp(c->section, "templates"))
break;

if (i) {
if (Verbosity)
puts("Creating templates file...");

snprintf(filename, sizeof(filename), "%s/%s/DEBIAN/templates", directory, name);

if ((fp = fopen(filename, "w")) == NULL) {
fprintf(stderr, "epm: Unable to create template file \"%s\": %s\n", filename,
strerror(errno));
return (1);
}

fchmod(fileno(fp), 0644);

for (; i > 0; i--, c++)
if (c->type == COMMAND_LITERAL && c->subpackage == subpackage &&
!strcmp(c->section, "templates"))
fprintf(fp, "%s\n", c->command);

fclose(fp);
}

/*
* Write the preinst file for DPKG...
*/
Expand All @@ -360,6 +426,7 @@ make_subpackage(const char *prodname, /* I - Product short name */

fputs("#!/bin/sh\n", fp);
fputs("# " EPM_VERSION "\n", fp);
fputs("set -e\n", fp);

for (; i > 0; i--, c++)
if (c->type == COMMAND_PRE_INSTALL && c->subpackage == subpackage)
Expand Down Expand Up @@ -397,6 +464,7 @@ make_subpackage(const char *prodname, /* I - Product short name */

fputs("#!/bin/sh\n", fp);
fputs("# " EPM_VERSION "\n", fp);
fputs("set -e\n", fp);

for (i = dist->num_commands, c = dist->commands; i > 0; i--, c++)
if (c->type == COMMAND_POST_INSTALL && c->subpackage == subpackage)
Expand Down Expand Up @@ -445,6 +513,7 @@ make_subpackage(const char *prodname, /* I - Product short name */

fputs("#!/bin/sh\n", fp);
fputs("# " EPM_VERSION "\n", fp);
fputs("set -e\n", fp);

for (i = dist->num_commands, c = dist->commands; i > 0; i--, c++)
if (c->type == COMMAND_PRE_REMOVE && c->subpackage == subpackage)
Expand Down Expand Up @@ -486,6 +555,7 @@ make_subpackage(const char *prodname, /* I - Product short name */

fputs("#!/bin/sh\n", fp);
fputs("# " EPM_VERSION "\n", fp);
fputs("set -e\n", fp);

for (i = dist->num_commands, c = dist->commands; i > 0; i--, c++)
if (c->type == COMMAND_POST_REMOVE && c->subpackage == subpackage)
Expand Down
23 changes: 21 additions & 2 deletions doc/4-advanced.html
Original file line number Diff line number Diff line change
Expand Up @@ -571,11 +571,13 @@ <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>
data is currently only supported for DEB, RPM and PKG packages.</P>

<H3>Debian Literal Data</H3>

<p>Debian packages have control files that provide metadata for each package. The <CODE>%literal(control)</CODE> directive can be used to provide this metadata:</P>
<p>Debian packages have control files that provide metadata for each package.
The <CODE>%literal(control)</CODE> directive can be used to provide this
metadata:</P>

<PRE>
%literal(control) &lt;&lt;EOF
Expand All @@ -584,6 +586,23 @@ <H3>Debian Literal Data</H3>
EOF
</PRE>

<p>Debian packages support template files to define the metadata associated with
configuration variables. The <CODE>%literal(templates)</CODE> directive can be
used to provide this metadata:</p>

<PRE>
%literal(templates) &lt;&lt;EOF
Template: canpi-server/reboot
Type: boolean
Description: Would you like to reboot to complete the package installation ?
The package installation updates the device table overlay definition.
For these changes to take effect the system must be restarted.
The canpi daemon is not started by the package installation as the lack of /dev/can0
will cause it to fail immediately.

EOF
</PRE>

<H3>PKG Literal Data</H3>

<P>PKG packages support request files that are used to do batch
Expand Down
2 changes: 1 addition & 1 deletion doc/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ install:
done
echo Installing EPM documentation in $(BUILDROOT)$(docdir)
$(INSTALL) -d -m 755 $(BUILDROOT)$(docdir)
for file in $(srcdir)/COPYING $(srcdir)/README.md $(BOOKS); do \
for file in $(srcdir)/../LICENSE $(srcdir)/../README.md $(BOOKS); do \
$(INSTALL) -c -m 644 $$file $(BUILDROOT)$(docdir); \
done

Expand Down
18 changes: 17 additions & 1 deletion doc/epm-book.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<HEAD>
<TITLE>Software Distribution with ESP Package Manager</TITLE>
<META NAME="author" CONTENT="Michael R Sweet, Jim Jagielski">
<META NAME="copyright" CONTENT="Copyright � 1999-2020 by Michael R Sweet">
<META NAME="copyright" CONTENT="Copyright � 1999-2020 by Michael R Sweet">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-8859-1">
<STYLE TYPE="text/css"><!--
BODY { font-family: sans-serif; }
Expand Down Expand Up @@ -1282,6 +1282,22 @@ <h3>Debian Literal Data</h3>
Priority: extra
EOF
</pre>
<p>Debian packages support template files to define the metadata associated with
configuration variables. The <CODE>%literal(templates)</CODE> directive can be
used to provide this metadata:</p>

<PRE>
%literal(templates) &lt;&lt;EOF
Template: canpi-server/reboot
Type: boolean
Description: Would you like to reboot to complete the package installation ?
The package installation updates the device table overlay definition.
For these changes to take effect the system must be restarted.
The canpi daemon is not started by the package installation as the lack of /dev/can0
will cause it to fail immediately.

EOF
</PRE>
<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>
Expand Down
6 changes: 3 additions & 3 deletions epm.list.in
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ $srcdir=@srcdir@

# Product information
%product ESP Package Manager (EPM)
%copyright 1999-2020 by Michael R Sweet, All Rights Reserved.
%copyright 2020 by Jim Jagielski, All Rights Reserved.
%copyright 1999-2020 by Michael R Sweet, All Rights Reserved.
%vendor Michael R Sweet, Jim Jagielski
%license ${srcdir}/COPYING
%license ${srcdir}/LICENSE
%readme ${srcdir}/README.md
%description Universal software packaging tool for UNIX.
%version @VERSION@ @VERNUMBER@
Expand All @@ -48,7 +48,7 @@ f 0555 root sys ${bindir}/mkepmlist mkepmlist
%subpackage documentation
%description Documentation
f 0444 root sys ${docdir}/README $srcdir/README.md
f 0444 root sys ${docdir}/COPYING $srcdir/COPYING
f 0444 root sys ${docdir}/LICENSE $srcdir/LICENSE
f 0444 root sys ${docdir}/epm-book.html $srcdir/doc/epm-book.html

# Man pages
Expand Down