Mon, 28 Jan 2013 17:37:18 +0100
Correct socket error reporting improvement with IPv6 portable code,
after helpful recommendation by Saúl Ibarra Corretgé on OSips devlist.
michael@428 | 1 | ## |
michael@428 | 2 | ## OpenPKG Software Stack Generation Utility |
michael@428 | 3 | ## Copyright (c) 2012 OpenPKG GmbH <http://openpkg.com/> |
michael@428 | 4 | ## |
michael@428 | 5 | ## This software is property of the OpenPKG GmbH, DE MUC HRB 160208. |
michael@428 | 6 | ## All rights reserved. Licenses which grant limited permission to use, |
michael@428 | 7 | ## copy, modify and distribute this software are available from the |
michael@428 | 8 | ## OpenPKG GmbH. |
michael@428 | 9 | ## |
michael@428 | 10 | ## THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED |
michael@428 | 11 | ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
michael@428 | 12 | ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
michael@428 | 13 | ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR |
michael@428 | 14 | ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
michael@428 | 15 | ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
michael@428 | 16 | ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
michael@428 | 17 | ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
michael@428 | 18 | ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
michael@428 | 19 | ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
michael@428 | 20 | ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
michael@428 | 21 | ## SUCH DAMAGE. |
michael@428 | 22 | ## |
michael@428 | 23 | |
michael@428 | 24 | =pod |
michael@428 | 25 | |
michael@428 | 26 | =head1 NAME |
michael@428 | 27 | |
michael@428 | 28 | B<openpkg stack> - B<OpenPKG Software Stack Generation> |
michael@428 | 29 | |
michael@428 | 30 | =head1 SYNOPSIS |
michael@428 | 31 | |
michael@428 | 32 | B<openpkg stack> |
michael@428 | 33 | [B<-h>|B<--help>] |
michael@428 | 34 | [B<-v>|B<--verbose> I<level>] |
michael@428 | 35 | [B<-o>|B<--output> I<dir>] |
michael@428 | 36 | [B<-D>|B<--define> I<name>=I<value> ...] |
michael@428 | 37 | [B<-u>|B<--unversioned>] |
michael@428 | 38 | [B<-q>|B<--query>] |
michael@428 | 39 | F<I<name>.stk> |
michael@428 | 40 | |
michael@428 | 41 | =head1 DESCRIPTION |
michael@428 | 42 | |
michael@428 | 43 | The B<openpkg stack> command reads a OpenPKG software stack definition |
michael@428 | 44 | F<I<name>.stk>, generates a OpenPKG software stack deployment script |
michael@428 | 45 | F<I<name>[-I<version>-I<release>].sh>, determines, downloads and |
michael@428 | 46 | stores all required corresponding OpenPKG source packages under |
michael@428 | 47 | F<I<name>[-I<version>-I<release>].src.d/*.src.{sh,rpm}>. |
michael@428 | 48 | |
michael@428 | 49 | On executing the generated OpenPKG software stack deployment |
michael@428 | 50 | script F<I<name>[-I<version>-I<release>].sh>, an OpenPKG |
michael@428 | 51 | instance is created (or reused if existing), all packages |
michael@428 | 52 | built and installed in topologically correct dependency order |
michael@428 | 53 | and the resulting OpenPKG binary packages stored as |
michael@428 | 54 | F<I<name>[-I<version>-I<release>].I<platform>-I<tag>.d/*.{sh,rpm}>. |
michael@428 | 55 | |
michael@428 | 56 | The main design decisions and intentions of OpenPKG software stacks are: |
michael@428 | 57 | |
michael@428 | 58 | =over 4 |
michael@428 | 59 | |
michael@428 | 60 | =item 1. |
michael@428 | 61 | |
michael@428 | 62 | OpenPKG software stacks can be centrally defined in a single file |
michael@428 | 63 | F<I<name>.stk>, similar to the definition of OpenPKG software packages in |
michael@428 | 64 | F<I<name>.spec> files. This definition includes both OpenPKG framework |
michael@428 | 65 | bootstrap parameters, OpenPKG package build parameters and OpenPKG |
michael@428 | 66 | software stack specific deployment-time prolog and epilog scripts. |
michael@428 | 67 | |
michael@428 | 68 | =item 2. |
michael@428 | 69 | |
michael@428 | 70 | OpenPKG software stacks depend on particular OpenPKG software packages |
michael@428 | 71 | (and perhaps even their particular versions) and by downloading and |
michael@428 | 72 | locally storing all relevant OpenPKG software packages an OpenPKG |
michael@428 | 73 | software stack remains stable and self-contained -- even if new versions |
michael@428 | 74 | of OpenPKG software packages are released. |
michael@428 | 75 | |
michael@428 | 76 | =item 3. |
michael@428 | 77 | |
michael@428 | 78 | For generating the OpenPKG software stack files, an OpenPKG instance |
michael@428 | 79 | and its B<openpkg stack> command is required, but executing the OpenPKG |
michael@428 | 80 | software stack deployment script does NOT require any pre-existing |
michael@428 | 81 | OpenPKG instances. |
michael@428 | 82 | |
michael@428 | 83 | =item 4. |
michael@428 | 84 | |
michael@428 | 85 | By wrapping F<I<name>[-I<version>-I<release>].sh> and |
michael@428 | 86 | F<I<name>[-I<version>-I<release>].src.d/> into a I<Shell Execution |
michael@428 | 87 | Archive> F<I<name>[-I<version>-I<release>].src.sh> with the B<openpkg |
michael@428 | 88 | sea> command, you can provide a single self-contained file for building |
michael@428 | 89 | and installing an OpenPKG software stack from OpenPKG source packages. |
michael@428 | 90 | |
michael@428 | 91 | =item 5. |
michael@428 | 92 | |
michael@428 | 93 | By wrapping F<I<name>[-I<version>-I<release>].sh> and |
michael@428 | 94 | F<I<name>[-I<version>-I<release>].I<platform>-I<tag>.d/> |
michael@428 | 95 | into a I<Shell Execution Archive> |
michael@428 | 96 | F<I<name>[-I<version>-I<release>].I<platform>-I<tag>.sh> with the |
michael@428 | 97 | B<openpkg sea> command, you can provide a single self-contained file for |
michael@428 | 98 | installing an OpenPKG software stack from OpenPKG binary packages. |
michael@428 | 99 | |
michael@428 | 100 | =back |
michael@428 | 101 | |
michael@428 | 102 | =head1 COMMAND-LINE OPTIONS AND ARGUMENTS |
michael@428 | 103 | |
michael@428 | 104 | =over 4 |
michael@428 | 105 | |
michael@428 | 106 | =item B<-h>|B<--help> |
michael@428 | 107 | |
michael@428 | 108 | Just shows a short usage information for the B<openpkg stack> command. |
michael@428 | 109 | |
michael@428 | 110 | =item B<-v>|B<--verbose> I<level> |
michael@428 | 111 | |
michael@428 | 112 | Sets the verbosity level for outputs, from C<0> (no output at all) to 4 |
michael@428 | 113 | (all possible outputs). The default is C<4>. |
michael@428 | 114 | |
michael@428 | 115 | =item B<-o>|B<--output> I<dir> |
michael@428 | 116 | |
michael@428 | 117 | The output directory for the OpenPKG software stack files. |
michael@428 | 118 | The default is the current directory (F<.>). |
michael@428 | 119 | |
michael@428 | 120 | =item [B<-D>|B<--define> I<name>=I<value> ...] |
michael@428 | 121 | |
michael@428 | 122 | On-the-fly overrides the value of option macro C<%{I<name>}> with |
michael@428 | 123 | I<value>. Use this to generate a variant of an OpenPKG software stack |
michael@428 | 124 | without modifying the software stack definition file. |
michael@428 | 125 | |
michael@428 | 126 | =item [B<-u>|B<--unversioned>] |
michael@428 | 127 | |
michael@428 | 128 | By default B<openpkg stack> creates the file |
michael@428 | 129 | C<I<name>-I<version>-I<release>.sh> (deployment script) and the |
michael@428 | 130 | directory C<I<name>-I<version>-I<release>.src.d/> (source packages). |
michael@428 | 131 | With this option the names are C<I<name>.sh> and C<I<name>.src.d/> only. |
michael@428 | 132 | |
michael@428 | 133 | =item [B<-q>|B<--query>] |
michael@428 | 134 | |
michael@428 | 135 | Forces a different operation mode where a shell script is output |
michael@428 | 136 | on F<stdout> containing variable definitions in the format |
michael@428 | 137 | C<I<name>="I<value>";> with information about the software stack |
michael@428 | 138 | definition. The provided variable names are C<name>, C<summary>, |
michael@428 | 139 | C<packager>, C<version> and C<release> for the corresponding headers, |
michael@428 | 140 | plus variables for all defined software stack options (see C<%option> |
michael@428 | 141 | section below). |
michael@428 | 142 | |
michael@428 | 143 | =item I<name>F<.stk> |
michael@428 | 144 | |
michael@428 | 145 | The mandatory OpenPKG software stack definition file. |
michael@428 | 146 | See below under B<SOFTWARE STACK DEFINITION> for details. |
michael@428 | 147 | |
michael@428 | 148 | =back |
michael@428 | 149 | |
michael@428 | 150 | =head1 SOFTWARE STACK DEFINITION |
michael@428 | 151 | |
michael@428 | 152 | An OpenPKG software stack is defined by a configuration file |
michael@428 | 153 | containing headers (C<Foo:>) and sections (<%foo>). |
michael@428 | 154 | |
michael@428 | 155 | =head2 Configuration Headers |
michael@428 | 156 | |
michael@428 | 157 | =over 4 |
michael@428 | 158 | |
michael@428 | 159 | =item B<Name> |
michael@428 | 160 | |
michael@428 | 161 | The name of the OpenPKG software stack. Also used as a prefix for many |
michael@428 | 162 | files. Should match the regular expression C<^[a-z][a-zA-Z0-9]+>, |
michael@428 | 163 | although this is not enforced. Example: C<Name: example>. |
michael@428 | 164 | |
michael@428 | 165 | =item B<Summary> |
michael@428 | 166 | |
michael@428 | 167 | A single line, shortly summarizing the purpose of the OpenPKG software |
michael@428 | 168 | stack. Example: C<Summary: Example Stack>. |
michael@428 | 169 | |
michael@428 | 170 | =item B<Packager> |
michael@428 | 171 | |
michael@428 | 172 | Name of the packager of the OpenPKG software software stack. |
michael@428 | 173 | Example: C<Packager: OpenPKG GmbH>. |
michael@428 | 174 | |
michael@428 | 175 | =item B<Version> |
michael@428 | 176 | |
michael@428 | 177 | Version identifier of the OpenPKG software stack. Describes the |
michael@428 | 178 | I<logical> revision of the software stack definition. Should match the |
michael@428 | 179 | regular expression C<^[0-9]+\.[0-9]\.[0-9]+$>, although this is not |
michael@428 | 180 | enforced. Example: C<Version: 1.0.0>. |
michael@428 | 181 | |
michael@428 | 182 | =item B<Release> |
michael@428 | 183 | |
michael@428 | 184 | Release identifier of the OpenPKG software stack. Describes the |
michael@428 | 185 | I<physical> revision of the stack definition. Should be in the format |
michael@428 | 186 | C<YYYYMMDD> and hence match the regular expression C<^[0-9]{8}$>, |
michael@428 | 187 | although this is not enforced. Example: C<Release: 20120101>. |
michael@428 | 188 | |
michael@428 | 189 | =back |
michael@428 | 190 | |
michael@428 | 191 | =head2 Configuration Sections |
michael@428 | 192 | |
michael@428 | 193 | =over 4 |
michael@428 | 194 | |
michael@428 | 195 | =item B<%options> |
michael@428 | 196 | |
michael@428 | 197 | Zero or more options for the OpenPKG software stack, one per line, in |
michael@428 | 198 | the format "I<name> I<default-value>". Options can be overridden on |
michael@428 | 199 | the command-line with B<-D>I<name>=I<value>. Example: C<with_ssl yes>. |
michael@428 | 200 | Option values can be expanded in all headers and sections through the |
michael@428 | 201 | following constructs: |
michael@428 | 202 | |
michael@428 | 203 | =over 4 |
michael@428 | 204 | |
michael@428 | 205 | =item C<%{I<name>}> |
michael@428 | 206 | |
michael@428 | 207 | Expand to the value of option I<name>. |
michael@428 | 208 | |
michael@428 | 209 | =item C<%{?I<name>:I<value>}> |
michael@428 | 210 | |
michael@428 | 211 | Expand to I<value> if option I<name> is defined. |
michael@428 | 212 | |
michael@428 | 213 | =item C<%{!?I<name>:I<value>}> |
michael@428 | 214 | |
michael@428 | 215 | Expand to I<value> if option I<name> is NOT defined. |
michael@428 | 216 | |
michael@428 | 217 | =back |
michael@428 | 218 | |
michael@428 | 219 | =item B<%description> |
michael@428 | 220 | |
michael@428 | 221 | A single textual paragraph describing the purpose of the OpenPKG |
michael@428 | 222 | software stack in more detail than header C<Summary>. |
michael@428 | 223 | |
michael@428 | 224 | =item B<%framework> |
michael@428 | 225 | |
michael@428 | 226 | The command-line parameters passed to the OpenPKG framework |
michael@428 | 227 | bootstrap source shell package F<openpkg-*.src.sh>. Usually at |
michael@428 | 228 | least the parameters B<--prefix=>I<path>, B<--user=>I<username>, |
michael@428 | 229 | B<--group=>I<groupname> and B<--tag=>I<tagname> are given here. In order |
michael@428 | 230 | to allow an OpenPKG software stack to be easily reused one creates |
michael@428 | 231 | the options (see C<%option> above) named C<prefix>, C<user>, C<group> |
michael@428 | 232 | and C<tag> and then use C<--prefix=%{prefix}>, C<--user=%{user}>, |
michael@428 | 233 | C<--group=%{group}> and C<--tag=%{tag}> in this C<%framework> section. |
michael@428 | 234 | |
michael@428 | 235 | =item B<%packages> |
michael@428 | 236 | |
michael@428 | 237 | The packages to build and install for the OpenPKG software stack, in |
michael@428 | 238 | the format of "B<-DI<package>::I<option>=I<value>>" and "I<package>" |
michael@428 | 239 | specifications as understood by the C<openpkg build> tool. Example: |
michael@428 | 240 | C<-Dapache::with_mod_ssl=yes -Dapache-php::with_json=yes apache |
michael@428 | 241 | apache-php>. |
michael@428 | 242 | |
michael@428 | 243 | =item B<%prolog> |
michael@428 | 244 | |
michael@428 | 245 | A shell script executed before installation of all packages. |
michael@428 | 246 | The variable C<$prefix> is available to access the |
michael@428 | 247 | OpenPKG software stack without having to hard-code a path. |
michael@428 | 248 | |
michael@428 | 249 | =item B<%epilog> |
michael@428 | 250 | |
michael@428 | 251 | A shell script executed after installation of all packages. This |
michael@428 | 252 | is usually used for applying OpenPKG software stack specific |
michael@428 | 253 | configurations. The variable C<$prefix> is available to access the |
michael@428 | 254 | OpenPKG software stack without having to hard-code a path. Example: |
michael@428 | 255 | C<echo "openldap_enable=no" E<gt>E<gt>$prefix/etc/rc.conf>. |
michael@428 | 256 | |
michael@428 | 257 | =back |
michael@428 | 258 | |
michael@428 | 259 | =head1 EXAMPLES |
michael@428 | 260 | |
michael@428 | 261 | $ cat xamp.stk |
michael@428 | 262 | |
michael@428 | 263 | Name: xamp |
michael@428 | 264 | Summary: Apache-MySQL-PHP Server |
michael@428 | 265 | Packager: OpenPKG GmbH |
michael@428 | 266 | Version: 1.0.0 |
michael@428 | 267 | Release: 20120407 |
michael@428 | 268 | |
michael@428 | 269 | %description |
michael@428 | 270 | This software stack contains a so-called xAMP web stack, consisting |
michael@428 | 271 | of the major components Apache, MySQL and PHP. |
michael@428 | 272 | |
michael@428 | 273 | %options |
michael@428 | 274 | repo http://download.openpkg.org/stacks/current/source/ |
michael@428 | 275 | prefix /xamp |
michael@428 | 276 | user xamp |
michael@428 | 277 | group xamp |
michael@428 | 278 | tag xamp |
michael@428 | 279 | with_ldap no |
michael@428 | 280 | with_ssl no |
michael@428 | 281 | addr 127.0.0.1 |
michael@428 | 282 | |
michael@428 | 283 | %repository |
michael@428 | 284 | %{repo} |
michael@428 | 285 | |
michael@428 | 286 | %framework |
michael@428 | 287 | --prefix=%{prefix} |
michael@428 | 288 | --user=%{user} |
michael@428 | 289 | --group=%{group} |
michael@428 | 290 | --tag=%{tag} |
michael@428 | 291 | |
michael@428 | 292 | %packages |
michael@428 | 293 | -D apache::with_mod_dav=yes |
michael@428 | 294 | -D apache::with_mod_deflate=yes |
michael@428 | 295 | -D apache::with_mod_ldap=%{with_ldap} |
michael@428 | 296 | -D apache::with_mod_proxy=yes |
michael@428 | 297 | -D apache::with_mod_ssl=%{with_ssl} |
michael@428 | 298 | -D apache-php::with_curl=yes |
michael@428 | 299 | -D apache-php::with_freetype=yes |
michael@428 | 300 | -D apache-php::with_gd=yes |
michael@428 | 301 | -D apache-php::with_iconv=yes |
michael@428 | 302 | -D apache-php::with_json=yes |
michael@428 | 303 | -D apache-php::with_mbregex=yes |
michael@428 | 304 | -D apache-php::with_mbstring=yes |
michael@428 | 305 | -D apache-php::with_mysql=yes |
michael@428 | 306 | -D apache-php::with_openldap=%{with_ldap} |
michael@428 | 307 | -D apache-php::with_session=yes |
michael@428 | 308 | -D apache-php::with_simplexml=yes |
michael@428 | 309 | -D apache-php::with_sqlite=yes |
michael@428 | 310 | -D apache-php::with_ssl=%{with_ssl} |
michael@428 | 311 | -D apache-php::with_xml=yes |
michael@428 | 312 | -D apache-php::with_zlib=yes |
michael@428 | 313 | apache |
michael@428 | 314 | apache-php |
michael@428 | 315 | mysql |
michael@428 | 316 | |
michael@428 | 317 | %epilog |
michael@428 | 318 | shtool subst \ |
michael@428 | 319 | -e 's;127\.0\.0\.1:%{addr};g' \ |
michael@428 | 320 | %{prefix}/etc/apache/apache.conf |
michael@428 | 321 | if [ ".%{with_ldap}" = .yes ]; then |
michael@428 | 322 | echo "openldap_enable=\"no\"" >>%{prefix}/etc/rc.conf |
michael@428 | 323 | fi |
michael@428 | 324 | |
michael@428 | 325 | $ openpkg stack -v4 \ |
michael@428 | 326 | -Dprefix=/v/xamp -Duser=xamp-sw -Dgroup=xamp-sw \ |
michael@428 | 327 | --unversioned xamp.stk |
michael@428 | 328 | |
michael@428 | 329 | $ openpkg sea -o xamp.src.sh xamp.sh xamp.src.d/ |
michael@428 | 330 | |
michael@428 | 331 | $ sh xamp.src.sh -v4 -S sudo |
michael@428 | 332 | |
michael@428 | 333 | $ openpkg sea -o xamp.bin.sh xamp.sh xamp.*-*.d/ |
michael@428 | 334 | |
michael@428 | 335 | =head1 HISTORY |
michael@428 | 336 | |
michael@428 | 337 | The B<openpkg stack> command was implemented in April 2012 by I<Ralf S. Engelschall> |
michael@428 | 338 | E<lt>rse@engelschall.comE<gt> for the OpenPKG Framework of the OpenPKG GmbH. |
michael@428 | 339 | |
michael@428 | 340 | =cut |
michael@428 | 341 |