openpkg/release.sh

Thu, 04 Oct 2012 20:30:05 +0200

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 04 Oct 2012 20:30:05 +0200
changeset 715
c10fb90893b9
parent 13
cb59d6afeb61
permissions
-rw-r--r--

Correct out of date build configuration, porting to Solaris 11 network
link infrastructure and new libpcap logic. This additionally allows for
device drivers in subdirectories of /dev. Correct packaged nmap
personalities and signatures to work out of the box. Finally, hack
arpd logic to properly close sockets and quit on TERM by repeating
signaling in the run command script. Sadly, all this fails to correct
the run time behaviour of honeyd which fails to bind to the IP layer.

michael@13 1 #!@l_prefix@/lib/openpkg/bash
michael@13 2 ##
michael@13 3 ## release -- OpenPKG Release Determination Utility
michael@428 4 ## Copyright (c) 2000-2012 OpenPKG GmbH <http://openpkg.com/>
michael@13 5 ##
michael@428 6 ## This software is property of the OpenPKG GmbH, DE MUC HRB 160208.
michael@428 7 ## All rights reserved. Licenses which grant limited permission to use,
michael@428 8 ## copy, modify and distribute this software are available from the
michael@428 9 ## OpenPKG GmbH.
michael@13 10 ##
michael@428 11 ## THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
michael@13 12 ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
michael@13 13 ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
michael@13 14 ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
michael@13 15 ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
michael@13 16 ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
michael@13 17 ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
michael@13 18 ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
michael@13 19 ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
michael@13 20 ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
michael@13 21 ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
michael@13 22 ## SUCH DAMAGE.
michael@13 23 ##
michael@13 24
michael@13 25 # configuration
michael@13 26 prefix="@l_prefix@"
michael@13 27
michael@13 28 # minimum command line parsing
michael@13 29 opt_F="OpenPKG-%t %u"
michael@13 30 opt_r=""
michael@13 31 while [ $# -gt 0 ]; do
michael@13 32 case "$1" in
michael@13 33 -F ) opt_F="$2"; shift; shift ;;
michael@13 34 --fmt ) opt_F="$2"; shift; shift ;;
michael@13 35 -F* ) opt_F="`expr ".$1" : '.-F\(.*\)'`"; shift ;;
michael@13 36 --fmt=* ) opt_F="`expr ".$1" : '.--fmt=\(.*\)'`"; shift ;;
michael@13 37 -r ) opt_r="$2"; shift; shift ;;
michael@13 38 --release ) opt_r="$2"; shift; shift ;;
michael@13 39 -r* ) opt_r="`expr ".$1" : '.-r\(.*\)'`"; shift ;;
michael@13 40 --release=* ) opt_r="`expr ".$1" : '.--release=\(.*\)'`"; shift ;;
michael@13 41 * ) break ;;
michael@13 42 esac
michael@13 43 done
michael@13 44
michael@13 45 # translate a release number to a release tag
michael@13 46 number_to_tag () {
michael@13 47 sed -e 's;^;X;' \
michael@13 48 -e 's;^X\([^.-][^.-]*\.[^.-][^.-]*\)\.[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*$;\1-SOLID;' \
michael@13 49 -e 's;^X\([^.-][^.-]*\.[^.-][^.-]*\)\.[^.-][^.-]*.*$;\1-RELEASE;' \
michael@13 50 -e 's;^X\([^.-][^.-]*\)\.[^.-][^.-]*.*$;\1-STABLE;' \
michael@13 51 -e 's;^X[^.-][^.-]*.*$;CURRENT;' \
michael@13 52 -e 's;^X.*$;UNKNOWN;'
michael@13 53 }
michael@13 54
michael@13 55 # sanity check a release tag
michael@13 56 tag_sanity () {
michael@13 57 sed -e 's;^;X;' \
michael@13 58 -e 's;^X[^.-][^.-]*\.[^.-][^.-]*-RELEASE$;OK;' \
michael@13 59 -e 's;^X[^.-][^.-]*\.[^.-][^.-]*-SOLID-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$;OK;' \
michael@13 60 -e 's;^X[^.-][^.-]*\.[^.-][^.-]*-SOLID$;OK;' \
michael@13 61 -e 's;^X[^.-][^.-]*-STABLE-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$;OK;' \
michael@13 62 -e 's;^X[^.-][^.-]*-STABLE$;OK;' \
michael@13 63 -e 's;^XCURRENT-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$;OK;' \
michael@13 64 -e 's;^XCURRENT$;OK;' \
michael@13 65 -e 's;^X.*$;ERROR;'
michael@13 66 }
michael@13 67
michael@13 68 # determine release
michael@13 69 tag=""
michael@13 70 if [ ".$opt_r" != . ]; then
michael@13 71 tag=`echo ".$opt_r" | sed -e 's;^\.;;' | number_to_tag`
michael@13 72 elif [ -f "$prefix/etc/openpkg/release" ]; then
michael@13 73 tag=`(cat $prefix/etc/openpkg/release; echo "") | sed \
michael@13 74 -e 's;^;X;' \
michael@13 75 -e 's;^X *TAG *= *\([^ ][^ ]*\).*;\1;' \
michael@13 76 -e '/^X/d' | \
michael@13 77 sed -n -e '$p'`
michael@428 78 fi
michael@428 79 if [ ".$tag" = . ]; then
michael@13 80 tag=`$prefix/bin/openpkg rpm \
michael@428 81 -q --qf '%{RELEASE}\n' openpkg | number_to_tag`
michael@13 82 fi
michael@13 83 if [ .`echo ".$tag" | sed -e 's;^\.;;' | tag_sanity` = .ERROR ]; then
michael@13 84 echo "openpkg:release: WARNING: unable to determine OpenPKG release tag" 1>&2
michael@13 85 tag="UNKNOWN"
michael@13 86 fi
michael@13 87
michael@13 88 # determine distribution URL
michael@13 89 url=""
michael@13 90 if [ -f "$prefix/etc/openpkg/release" ]; then
michael@13 91 url=`(cat $prefix/etc/openpkg/release; echo "") | sed \
michael@13 92 -e 's;^;X;' \
michael@13 93 -e 's;^X *URL *= *\([^ ][^ ]*\).*;\1;' \
michael@13 94 -e '/^X/d' | \
michael@13 95 sed -n -e '$p'`
michael@13 96 fi
michael@13 97 if [ ".$url" = . ]; then
michael@428 98 url="http://download.openpkg.org/stacks/*"
michael@13 99 fi
michael@13 100 case ".$url" in
michael@13 101 */\* )
michael@13 102 url=`echo ".$url" | sed -e 's;^\.;;' -e 's;/\*$;;'`
michael@13 103 case "$tag" in
michael@13 104 CURRENT )
michael@428 105 url="$url/current/"
michael@13 106 ;;
michael@13 107 CURRENT-* )
michael@13 108 version=`echo "$tag" | sed -e 's;^CURRENT-;;'`
michael@13 109 url="$url/current/$version/"
michael@13 110 ;;
michael@13 111 *-STABLE )
michael@13 112 version=`echo "$tag" | sed -e 's;^\(.*\)-STABLE$;\1;'`
michael@13 113 url="$url/stable/$version/"
michael@13 114 ;;
michael@13 115 *-STABLE-* )
michael@13 116 version=`echo "$tag" | sed -e 's;^\(.*\)-STABLE-\(.*\)$;\1.\2;'`
michael@13 117 url="$url/stable/$version/"
michael@13 118 ;;
michael@13 119 *-SOLID )
michael@13 120 version=`echo "$tag" | sed -e 's;^\(.*\)-SOLID$;\1;'`
michael@13 121 url="$url/solid/$version/"
michael@13 122 ;;
michael@13 123 *-SOLID-* )
michael@13 124 version=`echo "$tag" | sed -e 's;^\(.*\)-SOLID-\(.*\)$;\1.\2;'`
michael@13 125 url="$url/solid/$version/"
michael@13 126 ;;
michael@13 127 *-RELEASE )
michael@13 128 version=`echo "$tag" | sed -e 's;^\(.*\)-RELEASE$;\1;'`
michael@13 129 url="$url/release/$version/"
michael@13 130 ;;
michael@428 131 * )
michael@428 132 subdir=`echo "$tag" | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
michael@428 133 url="$url/$subdir/"
michael@428 134 ;;
michael@13 135 esac
michael@13 136 ;;
michael@13 137 esac
michael@13 138
michael@13 139 # read uuid
michael@13 140 [ -f "$prefix/etc/openpkg/uuid" ] && . "$prefix/etc/openpkg/uuid"
michael@13 141
michael@13 142 # generate output
michael@13 143 echo "X$opt_F" |\
michael@13 144 sed -e 's/^X//' \
michael@13 145 -e "s;%t;${tag};g" \
michael@13 146 -e "s;%u;${url};g" \
michael@13 147 -e "s;%r;${UUID_REGISTRY};g" \
michael@13 148 -e "s;%i;${UUID_INSTANCE};g" \
michael@13 149 -e "s;%p;${UUID_PLATFORM};g" \
michael@13 150 -e 's/\\n/^/g' | tr '^' '\012'
michael@13 151

mercurial