Diff for /embedaddon/sudo/pp between versions 1.1.1.1 and 1.1.1.2

version 1.1.1.1, 2012/02/21 16:23:02 version 1.1.1.2, 2012/05/29 12:26:49
Line 1 Line 1
 #!/bin/sh  #!/bin/sh
# (c) 2011 Quest Software, Inc. All rights reserved# Copyright 2012 Quest Software, Inc. ALL RIGHTS RESERVED
pp_revision="305"pp_revision="355"
 # Copyright 2010 Quest Software, Inc.  All rights reserved. # Copyright 2012 Quest Software, Inc.  ALL RIGHTS RESERVED.
  #   #
  # Redistribution and use in source and binary forms, with or without   # Redistribution and use in source and binary forms, with or without
  # modification, are permitted provided that the following conditions   # modification, are permitted provided that the following conditions
Line 31  pp_revision="305" Line 31  pp_revision="305"
  # Please see <http://rc.quest.com/topics/polypkg/> for more information   # Please see <http://rc.quest.com/topics/polypkg/> for more information
   
 pp_version="1.0.0.$pp_revision"  pp_version="1.0.0.$pp_revision"
pp_copyright="Copyright 2010, Quest Software, Inc. All rights reserved."pp_copyright="Copyright 2012, Quest Software, Inc. ALL RIGHTS RESERVED."
   
 pp_opt_debug=false  pp_opt_debug=false
 pp_opt_destdir="$DESTDIR"  pp_opt_destdir="$DESTDIR"
Line 802  pp_frontend_init () { Line 802  pp_frontend_init () {
     version=      version=
     summary="no summary"      summary="no summary"
     description="No description"      description="No description"
    copyright="Copyright 2010 Quest Software, Inc. All rights reserved."    copyright="Copyright 2012 Quest Software, Inc. ALL RIGHTS RESERVED."
   
     #-- if the user supplied extra arguments on the command line      #-- if the user supplied extra arguments on the command line
     #   then load them now.      #   then load them now.
Line 961  pp_frontend () { Line 961  pp_frontend () {
              fi               fi
              test $# -eq 0 || pp_warn "ignoring extra arguments: $line"               test $# -eq 0 || pp_warn "ignoring extra arguments: $line"
              continue;;               continue;;
          %pre|%post|%preun|%postup|%postun|%files|%depend|%check)          %pre|%post|%preun|%postup|%postun|%files|%depend|%check|%conflict)
              pp_debug "processing new component section $*"               pp_debug "processing new component section $*"
              s="$1"; shift               s="$1"; shift
              if test $# -eq 0 || pp_is_qualifier "$1"; then               if test $# -eq 0 || pp_is_qualifier "$1"; then
Line 1056  pp_frontend () { Line 1056  pp_frontend () {
                 . $pp_wrkdir/tmp                  . $pp_wrkdir/tmp
                 : > $pp_wrkdir/tmp                  : > $pp_wrkdir/tmp
                 ;;                  ;;
        %pre.*|%preun.*|%post.*|%postup.*|%postun.*|%depend.*|%check.*|%service.*|%fixup)        %pre.*|%preun.*|%post.*|%postup.*|%postun.*|%depend.*|%check.*|%conflict.*|%service.*|%fixup)
                 pp_debug "leaving $section: substituting $pp_wrkdir/tmp"                  pp_debug "leaving $section: substituting $pp_wrkdir/tmp"
                 # cat $pp_wrkdir/tmp >&2    # debugging                  # cat $pp_wrkdir/tmp >&2    # debugging
                 $pp_opt_debug && pp_substitute < $pp_wrkdir/tmp >&2                  $pp_opt_debug && pp_substitute < $pp_wrkdir/tmp >&2
Line 1092  pp_frontend () { Line 1092  pp_frontend () {
                 pp_debug "Adding explicit dependency $@ to $cpt"                  pp_debug "Adding explicit dependency $@ to $cpt"
                 echo "$@" >> $pp_wrkdir/%depend.$cpt                  echo "$@" >> $pp_wrkdir/%depend.$cpt
                 ;;                  ;;
           %conflict.*)
                   pp_debug "Adding explicit conflict $@ to $cpt"
                   echo "$@" >> $pp_wrkdir/%conflict.$cpt
                   ;;
      esac       esac
   done    done
   exec <&-    exec <&-
Line 1591  pp_aix_detect_os () { Line 1595  pp_aix_detect_os () {
   
 pp_aix_version_fix () {  pp_aix_version_fix () {
     typeset v      typeset v
    v=`echo $1 | tr -c -d '[0-9].\012'`    v=`echo $1 | sed 's/[-+]/./' | tr -c -d '[0-9].\012' | awk -F"." '{ printf "%d.%d.%d.%.4s\n", $1, $2, $3, $4 }' | sed 's/[.]*$//g'`
     if test x"$v" != x"$1"; then      if test x"$v" != x"$1"; then
         pp_warn "stripped version '$1' to '$v'"          pp_warn "stripped version '$1' to '$v'"
     fi      fi
Line 1757  pp_aix_add_service () { Line 1761  pp_aix_add_service () {
   
         set -- $cmd          set -- $cmd
         cmd_cmd="$1"; shift          cmd_cmd="$1"; shift
        cmd_arg="$pp_aix_mkssys_cmd_args";        cmd_arg="${pp_aix_mkssys_cmd_args:-$*}";
   
         case "$stop_signal" in          case "$stop_signal" in
                 HUP) stop_signal=1;;                  HUP) stop_signal=1;;
Line 1787  pp_aix_add_service () { Line 1791  pp_aix_add_service () {
         cat <<-. >> $pp_wrkdir/%post.$svc          cat <<-. >> $pp_wrkdir/%post.$svc
 svc=$svc  svc=$svc
 uid=0  uid=0
cmd_cmd=$daemoncmd_cmd="$cmd_cmd"
 cmd_arg="$cmd_arg"  cmd_arg="$cmd_arg"
 stop_signal=$stop_signal  stop_signal=$stop_signal
 force_signal=9  force_signal=9
 srcgroup="$pp_aix_mkssys_group"  srcgroup="$pp_aix_mkssys_group"
   instances_allowed=${pp_aix_mkssys_instances_allowed:--Q}
   
 lssrc -s \$svc > /dev/null 2>&1  lssrc -s \$svc > /dev/null 2>&1
 if [ \$? -eq 0 ]; then  if [ \$? -eq 0 ]; then
Line 1802  if [ \$? -eq 0 ]; then Line 1807  if [ \$? -eq 0 ]; then
   rmsys -s \$svc > /dev/null 2>&1    rmsys -s \$svc > /dev/null 2>&1
 fi  fi
   
mkssys -s \$svc -u \$uid -p "\$cmd_cmd" \${cmd_arg:+-a "\$cmd_arg"} -S -n \$stop_signal -f 9 ${pp_aix_mkssys_args} \${srcgroup:+-G \$srcgroup}mkssys -s \$svc -u \$uid -p "\$cmd_cmd" \${cmd_arg:+-a "\$cmd_arg"} -S -n \$stop_signal -f 9 ${pp_aix_mkssys_args} \${srcgroup:+-G \$srcgroup} \$instances_allowed
 .  .
   
         #-- add code to start the service on reboot          #-- add code to start the service on reboot
         ${pp_aix_init_services_after_install} &&          ${pp_aix_init_services_after_install} &&
           cat <<-. >> $pp_wrkdir/%post.$svc            cat <<-. >> $pp_wrkdir/%post.$svc
mkitab "\$svc:2:once:/usr/bin/startsrc -s \$svc" > /dev/null 2>&1id=\`echo "\$svc" | cut -c1-14\`
 mkitab "\$id:2:once:/usr/bin/startsrc -s \$svc" > /dev/null 2>&1
 .  .
   
         ${pp_aix_start_services_after_install} &&          ${pp_aix_start_services_after_install} &&
Line 1824  mv $pp_wrkdir/%post.$svc $pp_wrkdir/%post.run Line 1830  mv $pp_wrkdir/%post.$svc $pp_wrkdir/%post.run
   
         ${pp_aix_init_services_after_install} &&          ${pp_aix_init_services_after_install} &&
            pp_prepend $pp_wrkdir/%preun.$svc <<-.             pp_prepend $pp_wrkdir/%preun.$svc <<-.
rmitab $svcrmitab `echo "$svc" | cut -c1-14` > /dev/null 2>&1
 .  .
         pp_prepend $pp_wrkdir/%preun.$svc <<-.          pp_prepend $pp_wrkdir/%preun.$svc <<-.
 stopsrc -s $svc >/dev/null 2>&1  stopsrc -s $svc >/dev/null 2>&1
Line 1891  pp_backend_aix () { Line 1897  pp_backend_aix () {
                     -o -s $pp_wrkdir/%pre.$cmp \                      -o -s $pp_wrkdir/%pre.$cmp \
                     -o -s $pp_wrkdir/%post.$cmp \                      -o -s $pp_wrkdir/%post.$cmp \
                     -o -s $pp_wrkdir/%preun.$cmp \                      -o -s $pp_wrkdir/%preun.$cmp \
                       -o -s $pp_wrkdir/%postun.$cmp \
                     -o -s $pp_wrkdir/%check.$cmp                      -o -s $pp_wrkdir/%check.$cmp
             then              then
                 content=B                  content=B
Line 1906  pp_backend_aix () { Line 1913  pp_backend_aix () {
             bosboot=N; pp_contains_any "$pp_aix_bosboot" $cmp && bosboot=b              bosboot=N; pp_contains_any "$pp_aix_bosboot" $cmp && bosboot=b
   
             echo $pp_aix_bff_name.$ex \              echo $pp_aix_bff_name.$ex \
                 ${pp_aix_version:-`pp_aix_version_fix "$version"`} \             `[ $pp_aix_version ] && pp_aix_version_fix $pp_aix_version || pp_aix_version_fix "$version"` \
                  1 $bosboot $content \                   1 $bosboot $content \
                  $pp_aix_lang "$summary $briefex"                   $pp_aix_lang "$summary $briefex"
             echo "["              echo "["
Line 1965  pp_backend_aix () { Line 1972  pp_backend_aix () {
                         < $pp_wrkdir/%preun.$cmp                          < $pp_wrkdir/%preun.$cmp
             fi              fi
   
               if test -r $pp_wrkdir/%postun.$cmp; then
                   pp_aix_make_script $root_wrkdir/$pp_aix_bff_name.$ex.unpre_i \
                           < $pp_wrkdir/%postun.$cmp
               fi
   
             # remove empty files              # remove empty files
             for f in $user_wrkdir/$pp_aix_bff_name.$ex.* $root_wrkdir/$pp_aix_bff_name.$ex.*; do              for f in $user_wrkdir/$pp_aix_bff_name.$ex.* $root_wrkdir/$pp_aix_bff_name.$ex.*; do
               if test ! -s "$f"; then                if test ! -s "$f"; then
Line 2051  pp_backend_aix_cleanup () { Line 2063  pp_backend_aix_cleanup () {
 }  }
   
 pp_backend_aix_names () {  pp_backend_aix_names () {
        echo "$name.${pp_aix_version:-`pp_aix_version_fix "$version"`}.bff"    echo "$name.`[ $pp_aix_version ] && pp_aix_version_fix $pp_aix_version || pp_aix_version_fix "$version"`.bff"
 }  }
   
 pp_backend_aix_install_script () {  pp_backend_aix_install_script () {
Line 2170  pp_backend_aix_vas_platforms () { Line 2182  pp_backend_aix_vas_platforms () {
     esac      esac
 }  }
 pp_backend_aix_function () {  pp_backend_aix_function () {
    case $1 in    case "$1" in
     pp_mkgroup) cat <<'.';;      pp_mkgroup) cat <<'.';;
             /usr/sbin/lsgroup "$1" >/dev/null &&              /usr/sbin/lsgroup "$1" >/dev/null &&
                 return 0                  return 0
Line 2271  pp_sd_write_files () { Line 2283  pp_sd_write_files () {
         test x"$m" = x"-" && m=$dm          test x"$m" = x"-" && m=$dm
   
         case $t in          case $t in
            s) echo "$line $st $p";;            s)
            *) echo "$line -o $o -g $g -m $m $pp_destdir$p $p";;                # swpackage will make unqualified links relative to the
                 # current working (source) directory, not the destination;
                 # we need to qualify them to prevent this.
                 case "$st" in
                     /*) echo "$line $st $p";;
                     *) echo "$line `dirname $p`/$st $p";;
                 esac
                 ;;
             *)
                 echo "$line -o $o -g $g -m $m $pp_destdir$p $p"
                 ;;
         esac          esac
   
     done      done
Line 2294  pp_sd_service_group_script () { Line 2316  pp_sd_service_group_script () {
 .  .
   
     cat <<-'.' >> $out      cat <<-'.' >> $out
        #-- starts services in order.. stops them all if any break        #-- starts services in order.. stops them all if any break
        pp_start () {        pp_start () {
            undo=            undo=
            for svc in $svcs; do            for svc in \$svcs; do
                /sbin/init.d/$svc start                /sbin/init.d/\$svc start
                case $? in                case \$? in
                  0|4)                  0|4)
                    undo="$svc $undo"                    undo="\$svc \$undo"
                    ;;                    ;;
                  *)                  *)
                    if test -n "$undo"; then                    if test -n "\$undo"; then
                        for svc in $undo; do                        for svc in \$undo; do
                           /sbin/init.d/$svc stop                            /sbin/init.d/\$svc stop
                        done                        done
                        return 1                        return 1
                    fi                    fi
                    ;;                    ;;
                esac                esac
            done            done
            return 0            return 0
        }        }
   
        #-- stops services in reverse        #-- stops services in reverse
        pp_stop () {        pp_stop () {
            reverse=            reverse=
            for svc in $svcs; do            for svc in \$svcs; do
                reverse="$svc $reverse"                reverse="\$svc \$reverse"
            done            done
            rc=0            rc=0
            for svc in $reverse; do            for svc in \$reverse; do
                /sbin/init.d/$svc stop || rc=$?                /sbin/init.d/\$svc stop || rc=\$?
            done            done
            return $rc            return \$rc
         }          }
   
        case $1 in        case \$1 in
            start_msg) echo "Starting $svcs";;            start_msg) echo "Starting \$svcs";;
            stop_msg)  echo "Stopping $svcs";;            stop_msg)  echo "Stopping \$svcs";;
             start)     pp_start;;              start)     pp_start;;
             stop)      pp_stop;;              stop)      pp_stop;;
            *)         echo "usage: $0 {start|stop|start_msg|stop_msg}"            *)         echo "usage: \$0 {start|stop|start_msg|stop_msg}"
                       exit 1;;                       exit 1;;
        esac        esac
 .  .
 }  }
   
Line 2387  pp_sd_service_script () { Line 2409  pp_sd_service_script () {
         }          }
   
         pp_stop () {          pp_stop () {
            if test ! -s "$pidfile"; then            if test ! -s "\$pidfile"; then
                echo "Unable to stop $svc (no pid file)"                echo "Unable to stop \$svc (no pid file)"
                return 1                return 1
             else              else
                read pid < "$pidfile"                read pid < "\$pidfile"
                if kill -0 "$pid" 2>/dev/null; then                if kill -0 "\$pid" 2>/dev/null; then
                    if kill -${stop_signal:-TERM} "$pid"; then                    if kill -${stop_signal:-TERM} "\$pid"; then
                        rm -f "$pidfile"                        rm -f "\$pidfile"
                        return 0                        return 0
                    else                    else
                        echo "Unable to stop $svc"                        echo "Unable to stop \$svc"
                        return 1                        return 1
                    fi                    fi
                else                else
                    rm -f "$pidfile"                    rm -f "\$pidfile"
                    return 0                    return 0
                fi                fi
             fi              fi
         }          }
   
         pp_running () {          pp_running () {
            if test ! -s "$pidfile"; then            if test ! -s "\$pidfile"; then
                return 1                return 1
             else              else
                read pid < "$pidfile"                read pid < "\$pidfile"
                kill -0 "$pid" 2>/dev/null                kill -0 "\$pid" 2>/dev/null
             fi              fi
         }          }
   
        case $1 in        case \$1 in
            start_msg) echo "Starting the $svc service";;            start_msg) echo "Starting the \$svc service";;
            stop_msg)  echo "Stopping the $svc service";;            stop_msg)  echo "Stopping the \$svc service";;
             start)              start)
                    if test -f "$config_file"; then                    if test -f "\$config_file"; then
                        . $config_file                        . \$config_file
                    fi                    fi
                    if pp_disabled; then                    if pp_disabled; then
                        exit 2                        exit 2
                    elif pp_running; then                    elif pp_running; then
                        echo "$svc already running";                        echo "\$svc already running";
                        exit 0                        exit 0
                    elif pp_start; then                    elif pp_start; then
                        echo "$svc started";                        echo "\$svc started";
                        # rc(1M) says we should exit 4, but nobody expects it!                        # rc(1M) says we should exit 4, but nobody expects it!
                        exit 0                        exit 0
                    else                    else
                        exit 1                        exit 1
                    fi;;                    fi;;
             stop)   if pp_stop; then              stop)   if pp_stop; then
                        echo "$svc stopped";                        echo "\$svc stopped";
                        exit 0                        exit 0
                    else                    else
                        exit 1                        exit 1
                    fi;;                    fi;;
            *) echo "usage: $0 {start|stop|start_msg|stop_msg}"            *) echo "usage: \$0 {start|stop|start_msg|stop_msg}"
                exit 1;;                 exit 1;;
         esac          esac
 .  .
Line 2529  pp_sd_control () { Line 2551  pp_sd_control () {
     echo "                $ctrl $script"      echo "                $ctrl $script"
 }  }
   
   pp_sd_depend () {
       typeset _name _vers
       while read _name _vers; do
           case "$_name" in ""| "#"*) continue ;; esac
           echo "                prerequisites $_name ${_vers:+r>= $_vers}"
       done
   }
   
   pp_sd_conflict () {
       typeset _name _vers
       while read _name _vers; do
           case "$_name" in ""| "#"*) continue ;; esac
           echo "                exrequisites $_name ${_vers:+r>= $_vers}"
       done
   }
   
 pp_backend_sd () {  pp_backend_sd () {
     typeset psf cpt svc outfile release swp_flags      typeset psf cpt svc outfile release swp_flags
   
Line 2580  pp_backend_sd () { Line 2618  pp_backend_sd () {
                 title           "${summary:-cpt}"                  title           "${summary:-cpt}"
                 revision        $version                  revision        $version
 .  .
           test -s $pp_wrkdir/%depend.$cpt &&
                 pp_sd_depend < $pp_wrkdir/%depend.$cpt >> $psf
           test -s $pp_wrkdir/%conflict.$cpt &&
                 pp_sd_conflict < $pp_wrkdir/%conflict.$cpt >> $psf
   
         #-- make sure services are shut down during uninstall          #-- make sure services are shut down during uninstall
         if test $cpt = run -a -n "$pp_services"; then          if test $cpt = run -a -n "$pp_services"; then
Line 2741  pp_backend_sd_init_svc_vars () { Line 2783  pp_backend_sd_init_svc_vars () {
     :      :
 }  }
 pp_backend_sd_function () {  pp_backend_sd_function () {
    case $1 in    case "$1" in
         pp_mkgroup) cat <<'.';;          pp_mkgroup) cat <<'.';;
             /usr/sbin/groupmod "$1" 2>/dev/null ||              /usr/sbin/groupmod "$1" 2>/dev/null ||
                 /usr/sbin/groupadd "$1"                  /usr/sbin/groupadd "$1"
Line 2911  pp_solaris_depend () { Line 2953  pp_solaris_depend () {
     done      done
 }  }
   
   pp_solaris_conflict () {
       typeset _name _vers
       while read _name _vers; do
           if test -n "$_name"; then
               echo "I $_name $_name"
               test -n "$_vers" && echo " $_vers"
           fi
       done
   }
   
 pp_solaris_space() {  pp_solaris_space() {
     echo "$2:$3:$1" >> $pp_wrkdir/space.cumulative      echo "$2:$3:$1" >> $pp_wrkdir/space.cumulative
 }  }
Line 2927  pp_solaris_proto () { Line 2979  pp_solaris_proto () {
         typeset abi          typeset abi
   
         while read t m o g f p st; do          while read t m o g f p st; do
          if test x"$o" = x"-"; then          # Use Solaris default mode, owner and group if all unspecified
            o="root"          if test x"$m$o$g" = x"---"; then
          fi            m="?"; o="?"; g="?"
          if test x"$g" = x"-"; then          fi
            g="bin"          test x"$o" = x"-" && o="root"
          fi 
           case "$t" in            case "$t" in
            f) test x"$m" = x"-" && m=444            f) test x"$g" = x"-" && g="bin"
                test x"$m" = x"-" && m=444
                case "$f" in                 case "$f" in
                 *v*) echo "v $1 $p=$pp_destdir$p $m $o $g";;                  *v*) echo "v $1 $p=$pp_destdir$p $m $o $g";;
                 *)   echo "f $1 $p=$pp_destdir$p $m $o $g";;                  *)   echo "f $1 $p=$pp_destdir$p $m $o $g";;
Line 2953  pp_solaris_proto () { Line 3005  pp_solaris_proto () {
                   fi                    fi
                fi                 fi
                ;;                 ;;
            d) test x"$m" = x"-" && m=555            d) test x"$g" = x"-" && g="sys"
                test x"$m" = x"-" && m=555
                echo "d $1 $p $m $o $g"                 echo "d $1 $p $m $o $g"
                ;;                 ;;
            s) test x"$m" = x"-" && m=777            s) test x"$g" = x"-" && g="bin"
               test x"$m" = x"777" ||               test x"$m" = x"-" && m=777
                if test x"$m" != x"777" -a x"$m" != x"?"; then
                   pp_warn "$p: invalid mode $m for symlink, should be 777 or -"                    pp_warn "$p: invalid mode $m for symlink, should be 777 or -"
                  fi
                echo "s $1 $p=$st $m $o $g"                 echo "s $1 $p=$st $m $o $g"
                ;;                 ;;
           esac            esac
Line 3021  pp_backend_solaris () { Line 3076  pp_backend_solaris () {
         #-- scripts to run before and after install          #-- scripts to run before and after install
         : > $pp_wrkdir/postinstall          : > $pp_wrkdir/postinstall
         : > $pp_wrkdir/preremove          : > $pp_wrkdir/preremove
           : > $pp_wrkdir/postremove
         for _cmp in $pp_components; do          for _cmp in $pp_components; do
         #-- add the preinstall scripts in definition order          #-- add the preinstall scripts in definition order
         if test -s $pp_wrkdir/%pre.$_cmp; then          if test -s $pp_wrkdir/%pre.$_cmp; then
Line 3037  pp_backend_solaris () { Line 3093  pp_backend_solaris () {
             pp_solaris_procedure $_cmp preremove < $pp_wrkdir/%preun.$_cmp |              pp_solaris_procedure $_cmp preremove < $pp_wrkdir/%preun.$_cmp |
                     pp_prepend $pp_wrkdir/preremove                      pp_prepend $pp_wrkdir/preremove
         fi          fi
           #-- add the postremove scripts in definition order
           if test -s $pp_wrkdir/%postun.$_cmp; then
               pp_solaris_procedure $_cmp postremove < $pp_wrkdir/%postun.$_cmp \
                   >> $pp_wrkdir/postremove
           fi
         #-- Add the check script in definition order          #-- Add the check script in definition order
         if test -s $pp_wrkdir/%check.$_cmp; then          if test -s $pp_wrkdir/%check.$_cmp; then
             pp_solaris_procedure $_cmp checkinstall \              pp_solaris_procedure $_cmp checkinstall \
                         < $pp_wrkdir/%check.$_cmp \                          < $pp_wrkdir/%check.$_cmp \
                         >> $pp_wrkdir/checkinstall                          >> $pp_wrkdir/checkinstall
         fi          fi
        #-- All dependencies are merged together for Solaris pkgs        #-- All dependencies and conflicts are merged together for Solaris pkgs
         test -s $pp_wrkdir/%depend.$_cmp &&          test -s $pp_wrkdir/%depend.$_cmp &&
              pp_solaris_depend < $pp_wrkdir/%depend.$_cmp > $pp_wrkdir/depend              pp_solaris_depend < $pp_wrkdir/%depend.$_cmp >> $pp_wrkdir/depend
         test -s $pp_wrkdir/%conflict.$_cmp &&
               pp_solaris_conflict < $pp_wrkdir/%conflict.$_cmp >> $pp_wrkdir/depend
         done          done
   
   
Line 3060  pp_backend_solaris () { Line 3123  pp_backend_solaris () {
                 pp_solaris_make_service $_svc                  pp_solaris_make_service $_svc
                 pp_solaris_install_service $_svc | pp_prepend $pp_wrkdir/postinstall                  pp_solaris_install_service $_svc | pp_prepend $pp_wrkdir/postinstall
                 pp_solaris_remove_service $_svc | pp_prepend $pp_wrkdir/preremove                  pp_solaris_remove_service $_svc | pp_prepend $pp_wrkdir/preremove
                   pp_solaris_remove_service $_svc | pp_prepend $pp_wrkdir/postremove
                 unset pp_svc_xml_file                  unset pp_svc_xml_file
             done              done
   
Line 3140  fi >&2 Line 3204  fi >&2
   
         pkgmk -d $pp_wrkdir/pkg -f $prototype \          pkgmk -d $pp_wrkdir/pkg -f $prototype \
                 || { error "pkgmk failed"; return; }                  || { error "pkgmk failed"; return; }
        pkgtrans -s $pp_wrkdir/pkg \        pkgtrans -s $pp_wrkdir/pkg \
                 $pp_wrkdir/`pp_backend_solaris_names` \                  $pp_wrkdir/`pp_backend_solaris_names` \
                 ${pp_solaris_name:-$name} \                  ${pp_solaris_name:-$name} \
                 || { error "pkgtrans failed"; return; }                  || { error "pkgtrans failed"; return; }
Line 3292  pp_backend_solaris_vas_platforms () { Line 3356  pp_backend_solaris_vas_platforms () {
     esac      esac
 }  }
 pp_backend_solaris_function() {  pp_backend_solaris_function() {
    case $1 in    case "$1" in
         pp_mkgroup) cat<<'.';;          pp_mkgroup) cat<<'.';;
             /usr/sbin/groupmod "$1" 2>/dev/null && return 0              /usr/sbin/groupmod "$1" 2>/dev/null && return 0
             /usr/sbin/groupadd "$1"              /usr/sbin/groupadd "$1"
Line 3339  pp_solaris_smf () { Line 3403  pp_solaris_smf () {
   
     pp_solaris_name=${pp_solaris_name:-$name}      pp_solaris_name=${pp_solaris_name:-$name}
     pp_solaris_manpath=${pp_solaris_manpath:-"/usr/share/man"}      pp_solaris_manpath=${pp_solaris_manpath:-"/usr/share/man"}
       pp_solaris_mansect=${pp_solaris_mansect:-1}
     smf_start_timeout=${smf_start_timeout:-60}      smf_start_timeout=${smf_start_timeout:-60}
     smf_stop_timeout=${smf_stop_timeout:-60}      smf_stop_timeout=${smf_stop_timeout:-60}
     smf_restart_timeout=${smf_restart_timeout:-60}      smf_restart_timeout=${smf_restart_timeout:-60}
   
     svc=${pp_solaris_smf_service_name:-$1}      svc=${pp_solaris_smf_service_name:-$1}
     _pp_solaris_service_script=${pp_solaris_service_script:-"/etc/init.d/${pp_solaris_service_script_name:-$svc}"}      _pp_solaris_service_script=${pp_solaris_service_script:-"/etc/init.d/${pp_solaris_service_script_name:-$svc}"}
    _pp_solaris_manpage=${pp_solaris_manpage:-$pp_solaris_smf_service_name}    _pp_solaris_manpage=${pp_solaris_manpage:-$svc}
   
     if [ -z $pp_svc_xml_file ]; then      if [ -z $pp_svc_xml_file ]; then
         pp_svc_xml_file="/var/svc/manifest/$_smf_category/$svc.xml"          pp_svc_xml_file="/var/svc/manifest/$_smf_category/$svc.xml"
Line 3377  pp_solaris_smf () { Line 3442  pp_solaris_smf () {
     f=$pp_svc_xml_file      f=$pp_svc_xml_file
     pp_add_file_if_missing $f ||      pp_add_file_if_missing $f ||
         return 0          return 0
       pp_solaris_add_parent_dirs "$f"
   
     _pp_solaris_smf_dependencies="      _pp_solaris_smf_dependencies="
           <dependency name='pp_local_filesystems'            <dependency name='pp_local_filesystems'
Line 3440  pp_solaris_smf () { Line 3506  pp_solaris_smf () {
                   <loctext xml:lang='C'>$description</loctext>                    <loctext xml:lang='C'>$description</loctext>
               </common_name>                </common_name>
               <documentation>                <documentation>
                  <manpage title='$pp_solaris_manpage' section='1' manpath='$pp_solaris_manpath'/>                  <manpage title='$pp_solaris_manpage' section='$pp_solaris_mansect' manpath='$pp_solaris_manpath'/>
               </documentation>                </documentation>
           </template>            </template>
         </service>          </service>
Line 3456  pp_solaris_make_service_group () { Line 3522  pp_solaris_make_service_group () {
     file="/etc/init.d/$group"      file="/etc/init.d/$group"
     out="$pp_destdir$file"      out="$pp_destdir$file"
   
    #-- return if the script is supplued already    #-- return if the script is supplied already
     pp_add_file_if_missing "$file" run 755 || return 0      pp_add_file_if_missing "$file" run 755 || return 0
       pp_solaris_add_parent_dirs "$file"
   
     echo "#! /sbin/sh" > $out      echo "#! /sbin/sh" > $out
     echo "# polypkg service group script for these services:" >> $out      echo "# polypkg service group script for these services:" >> $out
Line 3525  pp_solaris_make_service () { Line 3592  pp_solaris_make_service () {
     #-- return if we don't need to create the init script      #-- return if we don't need to create the init script
     pp_add_file_if_missing "$file" run 755 ||      pp_add_file_if_missing "$file" run 755 ||
         return 0          return 0
       pp_solaris_add_parent_dirs "$file"
   
     echo "#! /sbin/sh" >$out      echo "#! /sbin/sh" >$out
     echo "#-- This service init file generated by polypkg" >>$out      echo "#-- This service init file generated by polypkg" >>$out
Line 3540  if [ -x /usr/sbin/svcadm ] && [ "x\$1" != "xstatus" ]  Line 3608  if [ -x /usr/sbin/svcadm ] && [ "x\$1" != "xstatus" ] 
             /usr/sbin/svcadm enable -s $_smf_category/$svc              /usr/sbin/svcadm enable -s $_smf_category/$svc
             RESULT=\$?              RESULT=\$?
             if [ "\$RESULT" -ne 0 ] ; then              if [ "\$RESULT" -ne 0 ] ; then
                echo "Error \$RESULT starting $svc"                echo "Error \$RESULT starting $svc" >&2
                fi            fi
             ;;              ;;
         stop)          stop)
             echo "stopping $svc"              echo "stopping $svc"
             /usr/sbin/svcadm disable -ts $_smf_category/$svc              /usr/sbin/svcadm disable -ts $_smf_category/$svc
               RESULT=0
             ;;              ;;
         restart)          restart)
             echo "restarting $svc"              echo "restarting $svc"
Line 3554  if [ -x /usr/sbin/svcadm ] && [ "x\$1" != "xstatus" ]  Line 3623  if [ -x /usr/sbin/svcadm ] && [ "x\$1" != "xstatus" ] 
             /usr/sbin/svcadm enable -s $_smf_category/$svc              /usr/sbin/svcadm enable -s $_smf_category/$svc
             RESULT=\$?              RESULT=\$?
             if [ "\$RESULT" -ne 0 ] ; then              if [ "\$RESULT" -ne 0 ] ; then
                echo "Error \$RESULT starting $svc"                echo "Error \$RESULT starting $svc" >&2
                    fi            fi
                    ;;            ;;
         *)          *)
            echo "Usage: $file {start|stop|restart|status}"            echo "Usage: $file {start|stop|restart|status}" >&2
            exit 1            RESULT=1
     esac      esac
    exit 0    exit $RESULT
 fi  fi
 _EOF  _EOF
     fi      fi
Line 3604  _EOF Line 3673  _EOF
   
         # returns true if $svc is running          # returns true if $svc is running
         pp_running () {          pp_running () {
            test -r "$pidfile" &&            test -s "$pidfile" || return 1
            read pid junk < "$pidfile" &&            read pid junk < "$pidfile" 2>/dev/null
             test ${pid:-0} -gt 1 &&              test ${pid:-0} -gt 1 &&
             kill -0 "$pid" 2>/dev/null              kill -0 "$pid" 2>/dev/null
         }          }
Line 3741  else Line 3810  else
 fi'  fi'
 }  }
   
   pp_solaris_add_parent_dirs () {
       typeset dir
   
       dir=${1%/*}
       while test -n "$dir"; do
           if awk "\$6 == \"$dir/\" {exit 1}" < $pp_wrkdir/%files.run; then
               echo "d - - - - $dir/" >> $pp_wrkdir/%files.run
           fi
           dir=${dir%/*}
       done
   }
   
 pp_platforms="$pp_platforms deb"  pp_platforms="$pp_platforms deb"
   
 pp_backend_deb_detect () {  pp_backend_deb_detect () {
Line 3839  pp_deb_version_final() { Line 3920  pp_deb_version_final() {
     fi      fi
 }  }
   
   pp_deb_conflict () {
       local _name _vers _conflicts
   
       _conflicts="Conflicts:"
       while read _name _vers; do
           case "$_name" in ""| "#"*) continue ;; esac
           _conflicts="$_conflicts $_name"
           test -n "$_vers" && _conflicts="$_conflicts $_name (>= $vers)"
           _conflicts="${_conflicts},"
       done
       echo "${_conflicts%,}"
   }
   
 pp_deb_make_control() {  pp_deb_make_control() {
     package_name=`pp_deb_cmp_full_name "$1"`      package_name=`pp_deb_cmp_full_name "$1"`
     cat <<-.      cat <<-.
Line 3855  pp_deb_make_control() { Line 3949  pp_deb_make_control() {
         sed -ne '/^[    ]*$/!s/^[       ]*/Depends: /p' \          sed -ne '/^[    ]*$/!s/^[       ]*/Depends: /p' \
             < $pp_wrkdir/%depend."$1"              < $pp_wrkdir/%depend."$1"
     fi      fi
       if test -s $pp_wrkdir/%conflict."$1"; then
           pp_deb_conflict < $pp_wrkdir/%conflict."$1"
       fi
 }  }
   
 pp_deb_make_md5sums() {  pp_deb_make_md5sums() {
Line 3964  pp_deb_make_DEBIAN() { Line 4061  pp_deb_make_DEBIAN() {
         "$pp_wrkdir/%preun.$cmp" "Pre-uninstall script for $cmp_full_name"\          "$pp_wrkdir/%preun.$cmp" "Pre-uninstall script for $cmp_full_name"\
         || exit $?          || exit $?
   
       # Create postrm
       pp_deb_make_package_maintainer_script "$data/DEBIAN/postrm" \
           "$pp_wrkdir/%postun.$cmp" "Post-uninstall script for $cmp_full_name"\
           || exit $?
   
     umask $old_umask      umask $old_umask
 }  }
   
Line 3973  pp_deb_make_data() { Line 4075  pp_deb_make_data() {
     cmp=$1      cmp=$1
     data=$pp_wrkdir/`pp_deb_cmp_full_name $cmp`      data=$pp_wrkdir/`pp_deb_cmp_full_name $cmp`
     cat $pp_wrkdir/%files.${cmp} | while read t m o g f p st; do      cat $pp_wrkdir/%files.${cmp} | while read t m o g f p st; do
           if test x"$m" = x"-"; then
               case "$t" in
                   d) m=755;;
                   f) m=644;;
               esac
           fi
         test x"$o" = x"-" && o=root          test x"$o" = x"-" && o=root
         test x"$g" = x"-" && g=root          test x"$g" = x"-" && g=root
         case "$t" in          case "$t" in
Line 4246  pp_backend_deb_vas_platforms () { Line 4354  pp_backend_deb_vas_platforms () {
     esac      esac
 }  }
 pp_backend_deb_init_svc_vars () {  pp_backend_deb_init_svc_vars () {
     # Default multi-user runlevel on Debian is 2; 3-5 are also multi-user  
     pp_deb_default_start_runlevels="2 3 4 5"  
     pp_deb_default_svc_description="No description"  
 }  
   
 pp_backend_deb_init_svc_vars () {  
   
     reload_signal=      reload_signal=
    start_runlevels=${pp_deb_default_start_runlevels}   # == lsb default-start    start_runlevels=${pp_deb_default_start_runlevels-"2 3 4 5"} # == lsb default-start
    stop_runlevels="0 1 6"                              # == lsb default-stop    stop_runlevels=${pp_deb_default_stop_runlevels-"0 1 6"}     # == lsb default-stop
     svc_description="${pp_deb_default_svc_description}" # == lsb short descr      svc_description="${pp_deb_default_svc_description}" # == lsb short descr
     svc_process=      svc_process=
   
Line 4286  pp_deb_service_make_init_script () { Line 4388  pp_deb_service_make_init_script () {
     #_process=${svc_process:-"$1"} --? WTF      #_process=${svc_process:-"$1"} --? WTF
   
     #-- construct a start command that builds a pid file if needed      #-- construct a start command that builds a pid file if needed
       #-- the command name in /proc/[pid]/stat is limited to 15 characters 
     _cmd="$cmd";      _cmd="$cmd";
     _cmd_path=`echo $cmd | cut -d" " -f1`      _cmd_path=`echo $cmd | cut -d" " -f1`
    _cmd_name=`basename $_cmd_path`    _cmd_name=`basename $_cmd_path | cut -c1-15`
     _cmd_args=`echo $cmd | cut -d" " -f2-`      _cmd_args=`echo $cmd | cut -d" " -f2-`
     test x"$_cmd_path" != x"$_cmd_args" || _cmd_args=      test x"$_cmd_path" != x"$_cmd_args" || _cmd_args=
   
Line 4301  pp_deb_service_make_init_script () { Line 4404  pp_deb_service_make_init_script () {
         # Required-Stop: ${lsb_required_stop}          # Required-Stop: ${lsb_required_stop}
         # Default-Start: ${start_runlevels}          # Default-Start: ${start_runlevels}
         # Default-Stop: ${stop_runlevels}          # Default-Stop: ${stop_runlevels}
        # Short-Description: ${svc_description}        # Short-Description: ${svc_description:-no description}
         ### END INIT INFO          ### END INIT INFO
         # Generated by PolyPackage ${pp_version}          # Generated by PolyPackage ${pp_version}
         # ${copyright}          # ${copyright}
Line 4499  esac Line 4602  esac
     chmod 755 $out      chmod 755 $out
 }  }
 pp_backend_deb_function() {  pp_backend_deb_function() {
    case $1 in    case "$1" in
         pp_mkgroup) cat<<'.';;          pp_mkgroup) cat<<'.';;
             /usr/sbin/groupmod "$1" 2>/dev/null && return 0              /usr/sbin/groupmod "$1" 2>/dev/null && return 0
             /usr/sbin/groupadd "$1"              /usr/sbin/groupadd "$1"
Line 4850  cat <<-'.' >> $out Line 4953  cat <<-'.' >> $out
                 return $rc                  return $rc
         }          }
   
        case $1 in        case "$1" in
             start_msg) echo "Starting $svcs";;              start_msg) echo "Starting $svcs";;
         stop_msg)  echo "Stopping $svcs";;          stop_msg)  echo "Stopping $svcs";;
         start)     pp_start;;          start)     pp_start;;
Line 4916  pp_kit_service_script () { Line 5019  pp_kit_service_script () {
                     kill -0 "$pid" 2>/dev/null                      kill -0 "$pid" 2>/dev/null
                 fi                  fi
             }              }
            case $1 in            case "$1" in
                 start_msg) echo "Starting the $svc service";;                  start_msg) echo "Starting the $svc service";;
                 stop_msg)  echo "Stopping the $svc service";;                  stop_msg)  echo "Stopping the $svc service";;
                 start)                  start)
Line 5322  pp_rpm_detect_distro () { Line 5425  pp_rpm_detect_distro () {
        pp_rpm_distro=`awk '         pp_rpm_distro=`awk '
           /^Red Hat Enterprise Linux/ { print "rhel" $7; exit; }            /^Red Hat Enterprise Linux/ { print "rhel" $7; exit; }
           /^CentOS release/           { print "centos" $3; exit; }            /^CentOS release/           { print "centos" $3; exit; }
             /^CentOS Linux release/     { print "centos" $4; exit; }
           /^Red Hat Linux release/    { print "rh" $5; exit; }            /^Red Hat Linux release/    { print "rh" $5; exit; }
        ' /etc/redhat-release`         ' /etc/redhat-release`
     elif test -f /etc/SuSE-release; then      elif test -f /etc/SuSE-release; then
Line 5399  pp_rpm_writefiles () { Line 5503  pp_rpm_writefiles () {
                     farch=x86_64;;                      farch=x86_64;;
                 *": ELF 32-bit MSB "*", PowerPC"*)                  *": ELF 32-bit MSB "*", PowerPC"*)
                     farch=ppc;;                      farch=ppc;;
                   *": ELF 64-bit MSB "*", 64-bit PowerPC"*)
                       farch=ppc64;;
                 *": ELF 64-bit LSB "*", IA-64"*)                  *": ELF 64-bit LSB "*", IA-64"*)
                     farch=ia64;;                      farch=ia64;;
                 *": ELF 32-bit MSB "*", IBM S/390"*)                  *": ELF 32-bit MSB "*", IBM S/390"*)
Line 5424  pp_rpm_writefiles () { Line 5530  pp_rpm_writefiles () {
                         farch=x86_64;;                          farch=x86_64;;
                     "ELF32 PowerPC")                      "ELF32 PowerPC")
                         farch=ppc;;                          farch=ppc;;
                    "ELF64 PowerPC")                    "ELF64 PowerPC"*)
                         farch=ppc64;;                          farch=ppc64;;
                     "ELF64 IA-64")                      "ELF64 IA-64")
                         farch=ia64;;                          farch=ia64;;
Line 5457  pp_rpm_subname () { Line 5563  pp_rpm_subname () {
 }  }
   
 pp_rpm_depend () {  pp_rpm_depend () {
       local _name _vers
     while read _name _vers; do      while read _name _vers; do
         case "$_name" in ""| "#"*) continue ;; esac          case "$_name" in ""| "#"*) continue ;; esac
         echo "Requires: $_name ${_vers:+>= $_vers}"          echo "Requires: $_name ${_vers:+>= $_vers}"
     done      done
 }  }
   
   pp_rpm_conflict () {
       local _name _vers
       while read _name _vers; do
           case "$_name" in ""| "#"*) continue ;; esac
           echo "Conflicts: $_name ${_vers:+>= $_vers}"
       done
   }
   
 pp_rpm_override_requires () {  pp_rpm_override_requires () {
     local orig_find_requires      local orig_find_requires
   
Line 5528  pp_backend_rpm () { Line 5643  pp_backend_rpm () {
         elif test -s $pp_wrkdir/%depend.run; then          elif test -s $pp_wrkdir/%depend.run; then
             pp_rpm_depend < $pp_wrkdir/%depend.run >> $specfile              pp_rpm_depend < $pp_wrkdir/%depend.run >> $specfile
         fi          fi
           if test -s $pp_wrkdir/%conflict.run; then
               pp_rpm_conflict < $pp_wrkdir/%conflict.run >> $specfile
           fi
   
         pp_rpm_override_requires >> $specfile          pp_rpm_override_requires >> $specfile
   
Line 5567  pp_backend_rpm () { Line 5685  pp_backend_rpm () {
                 elif test -s $pp_wrkdir/%depend.$cmp; then                  elif test -s $pp_wrkdir/%depend.$cmp; then
                     pp_rpm_depend < $pp_wrkdir/%depend.$cmp >> $specfile                      pp_rpm_depend < $pp_wrkdir/%depend.$cmp >> $specfile
                 fi                  fi
                   if test -s $pp_wrkdir/%conflict.$cmp; then
                       pp_rpm_conflict < $pp_wrkdir/%conflict.$cmp >> $specfile
                   fi
   
                 eval '_pkg="$pp_rpm_'$cmp'_provides"'                  eval '_pkg="$pp_rpm_'$cmp'_provides"'
                 eval pp_rpm_label Provides $_pkg                  eval pp_rpm_label Provides $_pkg
Line 5653  pp_backend_rpm () { Line 5774  pp_backend_rpm () {
                 cat $pp_wrkdir/%preun.$cmp                  cat $pp_wrkdir/%preun.$cmp
                 echo :   # causes script to exit true                  echo :   # causes script to exit true
             fi              fi
   
               if test -s $pp_wrkdir/%postun.$cmp; then
                   echo ""
                   echo "%postun $_subname"
                   cat $pp_wrkdir/%postun.$cmp
                   echo :   # causes script to exit true
               fi
         done >>$specfile          done >>$specfile
   
         #-- create a suitable work area for rpmbuild          #-- create a suitable work area for rpmbuild
Line 5886  pp_backend_rpm_vas_platforms () { Line 6014  pp_backend_rpm_vas_platforms () {
     esac      esac
 }  }
   
 pp_backend_rpm_init_svc_vars () {  
     pp_rpm_default_start_runlevels="2 3 4 5"  
     pp_rpm_default_svc_description="No description"  
 }  
   
 pp_rpm_service_install_common () {  pp_rpm_service_install_common () {
     cat <<-'.'      cat <<-'.'
   
Line 5997  pp_rpm_service_remove () { Line 6120  pp_rpm_service_remove () {
 pp_backend_rpm_init_svc_vars () {  pp_backend_rpm_init_svc_vars () {
   
     reload_signal=      reload_signal=
    start_runlevels=${pp_rpm_default_start_runlevels}   # == lsb default-start    start_runlevels=${pp_rpm_default_start_runlevels-"2 3 4 5"} # == lsb default-start
    stop_runlevels="0 1 6"                              # == lsb default-stop    stop_runlevels=${pp_rpm_default_stop_runlevels-"0 1 6"} # == lsb default-stop
     svc_description="${pp_rpm_default_svc_description}" # == lsb short descr      svc_description="${pp_rpm_default_svc_description}" # == lsb short descr
     svc_process=      svc_process=
   
Line 6295  pp_rpm_service_make_init_script () { Line 6418  pp_rpm_service_make_init_script () {
     chmod 755 $out      chmod 755 $out
 }  }
 pp_backend_rpm_function () {  pp_backend_rpm_function () {
    case $1 in    case "$1" in
         pp_mkgroup) cat<<'.';;          pp_mkgroup) cat<<'.';;
             /usr/sbin/groupadd -f -r "$1"              /usr/sbin/groupadd -f -r "$1"
 .  .
Line 6406  pp_backend_rpm_function () { Line 6529  pp_backend_rpm_function () {
     Examples found in /System/Library/LaunchDaemons/      Examples found in /System/Library/LaunchDaemons/
     See manual page launchd.plist(5) for details:      See manual page launchd.plist(5) for details:
   
    { Label: "com.quest.vintela.foo",                        # required    { Label: "com.quest.rc.foo",                        # required
       Program: "/sbin/program",        Program: "/sbin/program",
       ProgramArguments: [ "/sbin/program", "arg1", "arg2" ], # required        ProgramArguments: [ "/sbin/program", "arg1", "arg2" ], # required
       RunAtLoad: true,        RunAtLoad: true,
Line 6452  pp_backend_macos_init () { Line 6575  pp_backend_macos_init () {
     pp_macos_bundle_vendor=      pp_macos_bundle_vendor=
     pp_macos_bundle_version=      pp_macos_bundle_version=
     pp_macos_bundle_info_string=      pp_macos_bundle_info_string=
    pp_macos_prog_packagemaker=/Developer/usr/bin/packagemaker    pp_macos_pkg_type=bundle
    pp_macos_pkg_domain=anywhere    pp_macos_pkg_license=
    pp_macos_pkg_extra_flags=    pp_macos_pkg_readme=
    pp_macos_sudo=    pp_macos_pkg_welcome=
     pp_macos_sudo=sudo
     # OS X puts the library version *before* the .dylib extension      # OS X puts the library version *before* the .dylib extension
     pp_shlib_suffix='*.dylib'      pp_shlib_suffix='*.dylib'
 }  }
Line 6496  pp_macos_plist () { Line 6620  pp_macos_plist () {
 pp_macos_rewrite_cpio () {  pp_macos_rewrite_cpio () {
     typeset script      typeset script
     script=$pp_wrkdir/cpio-rewrite.pl      script=$pp_wrkdir/cpio-rewrite.pl
     # rely on the fact that OS X comes with perl. It is a little easier to  
     # re-write a binary stream with perl than it is with posix :)  
     #  
     # A CPIO header block has octal fields at the following offset/lengths:  
     #   0  6 magic  
     #   6  6 dev  
     #  12  6 ino  
     #  18  6 mode  
     #  24  6 uid  
     #  30  6 gid  
     #  36  6 nlink  
     #  42  6 rdev  
     #  48 11 mtime  
     #  59  6 namesize  
     #  65 11 filesize  
     #  76    --  
     cat <<-'.' >$script      cat <<-'.' >$script
           #!/usr/bin/perl
           #
           # Filter a cpio file, applying the user/group/mode specified in %files
           #
           # A CPIO header block has octal fields at the following offset/lengths:
           #   0  6 magic
           #   6  6 dev
           #  12  6 ino
           #  18  6 mode
           #  24  6 uid
           #  30  6 gid
           #  36  6 nlink
           #  42  6 rdev
           #  48 11 mtime
           #  59  6 namesize (including NUL terminator)
           #  65 11 filesize
           #  76    --
           #
           use strict;
           use warnings;
           no strict 'subs';
   
           # set %uid, %gid, %mode based on %files
           my (%uid, %gid, %mode, %users, %groups);
           my %type_map = ( d => 0040000, f => 0100000, s => 0120000 );
         while (<DATA>) {          while (<DATA>) {
                my ($type,$mode,$uid,$gid,$flags,$name) =            my ($type,$mode,$uid,$gid,$flags,$name) =
                    m/^(.) (\d+) (\S+) (\S+) (\S+) (.*)/;                m/^(.) (\S+) (\S+) (\S+) (\S+) (\S+)/;
                $uid = 0 if $uid eq "-";            $mode = $type eq "f" ? "0644" : "0755" if $mode eq "-";
                $gid = 0 if $gid eq "-";            $uid = 0 if $uid eq "-";
                if ($uid ne "=" and $uid =~ m/\D/) {            $gid = 0 if $gid eq "-";
                        my @pw = getpwnam($uid) or die "bad username '$uid'";            if ($uid ne "=" and $uid =~ m/\D/) {
                        $uid = $pw[2];                unless (exists $users{$uid}) {
                }                    my @pw = getpwnam($uid) or die "bad username '$uid'";
                if ($gid ne "=" and $gid =~ m/\D/) {                    $users{$uid} = $pw[2];
                        my @gr = getgrnam($gid) or die "bad group '$gid'";                }
                        $gid = $gr[2];                $uid = $users{$uid};
                }            }
                $name = ".".$name."\0";            if ($gid ne "=" and $gid =~ m/\D/) {
                $ok{$name} = 1;                unless (exists $groups{$gid}) {
                $uid{$name} = sprintf("%06o",int($uid)) unless $uid eq "=";                    my @gr = getgrnam($gid) or die "bad group'$gid'";
                $gid{$name} = sprintf("%06o",int($gid)) unless $gid eq "=";                    $groups{$gid} = $gr[2];
                $mode{$name} = sprintf("%06o",oct($mode)) unless $mode eq "=";                }
                 $gid = $groups{$gid};
             }
             $name =~ s:/$:: if $type eq "d";
             $name = ".".$name."\0";
             $uid{$name} = sprintf("%06o",int($uid)) unless $uid eq "=";
             $gid{$name} = sprintf("%06o",int($gid)) unless $gid eq "=";
             $mode{$name} = sprintf("%06o",oct($mode)|$type_map{$type}) unless $mode eq "=";
         }          }
        $ok{"TRAILER!!!\0"} = 1;        undef %users;
        while (!eof STDIN) {        undef %groups;
                read STDIN, $header, 76;        # parse the cpio file
                die "bad magic" unless $header =~ m/^070707/;        my $hdrlen = 76;
                $namesize = oct(substr($header,59,6));        while (read(STDIN, my $header, $hdrlen)) {
                $filesize = oct(substr($header,65,11));            my ($name, $namesize, $filesize);
                read STDIN, $name, $namesize;            my $filepad = 0;
                # convert uid and gid to 0            if ($header =~ m/^07070[12]/) {
                substr($header, 24, 6) = $uid{$name} if defined($uid{$name});                # SVR4 ASCII format, convert to ODC
                substr($header, 30, 6) = $gid{$name} if defined($gid{$name});                if ($hdrlen == 76) {
                substr($header, 18, 6) = $mode{$name} if defined($mode{$name});                    # Read in rest of header and update header len for SVR4
                print ($header, $name) if $ok{$name};                    read(STDIN, $header, 110 - 76, 76);
                # copy-through the file data                    $hdrlen = 110;
                while ($filesize > 0) {                }
                        my $seg = 8192;                my $ino = hex(substr($header, 6, 8)) & 0x3ffff;
                        $seg = $filesize if $filesize < $seg;                my $mode = hex(substr($header, 14, 8)) & 0x3ffff;
                        undef $data;                my $uid = hex(substr($header, 22, 8)) & 0x3ffff;
                        read STDIN, $data, $seg;                my $gid = hex(substr($header, 30, 8)) & 0x3ffff;
                        print $data if $ok{$name};                my $nlink = hex(substr($header, 38, 8)) & 0x3ffff;
                        $filesize -= $seg;                my $mtime = hex(substr($header, 46, 8)) & 0xffffffff;
                }                $filesize = hex(substr($header, 54, 8)) & 0xffffffff;
                 my $dev_maj = hex(substr($header, 62, 8));
                 my $dev_min = hex(substr($header, 70, 8));
                 my $dev = &makedev($dev_maj, $dev_min) & 0x3ffff;
                 my $rdev_maj = hex(substr($header, 78, 8));
                 my $rdev_min = hex(substr($header, 86, 8));
                 my $rdev = &makedev($rdev_maj, $rdev_min) & 0x3ffff;
                 $namesize = hex(substr($header, 94, 8)) & 0x3ffff;
                 read(STDIN, $name, $namesize);
                 # Header + name is padded to a multiple of 4 bytes
                 my $namepad = (($hdrlen + $namesize + 3) & 0xfffffffc) - ($hdrlen + $namesize);
                 read(STDIN, my $padding, $namepad) if ($namepad);
                 # File data is padded to be a multiple of 4 bytes
                 $filepad = (($filesize + 3) & 0xfffffffc) - $filesize;
 
                 my $new_header = sprintf("070707%06o%06o%06o%06o%06o%06o%06o%011o%06o%011o", $dev, $ino, $mode, $uid, $gid, $nlink, $rdev, $mtime, $namesize, $filesize);
                 $header = $new_header;
             } elsif ($header =~ m/^070707/) {
                 # POSIX Portable ASCII Format
                 $namesize = oct(substr($header, 59, 6));
                 $filesize = oct(substr($header, 65, 11));
                 read(STDIN, $name, $namesize);
             } else {
                 die "bad magic";
             }
             # update uid, gid and mode (already in octal)
             substr($header, 24, 6) = $uid{$name} if exists $uid{$name};
             substr($header, 30, 6) = $gid{$name} if exists $gid{$name};
             substr($header, 18, 6) = $mode{$name} if exists $mode{$name};
             print($header, $name);
             # check for trailer at EOF
             last if $filesize == 0 && $name =~ /^TRAILER!!!\0/;
             # copy-through the file data
             while ($filesize > 0) {
                 my $seg = 8192;
                 $seg = $filesize if $filesize < $seg;
                 read(STDIN, my $data, $seg);
                 print $data;
                 $filesize -= $seg;
             }
             # If file data is padded, skip it
             read(STDIN, my $padding, $filepad) if ($filepad);
         }          }
           # pass through any padding at the end (blocksize-dependent)
           for (;;) {
               my $numread = read(STDIN, my $data, 8192);
               last unless $numread;
               print $data;
           }
         exit(0);          exit(0);
   
           sub makedev {
               (((($_[0] & 0xff)) << 24) | ($_[1] & 0xffffff));
           }
         __DATA__          __DATA__
 .  .
     # Append to the script the %files data      # Append to the script the %files data
Line 6570  pp_macos_files_bom () { Line 6761  pp_macos_files_bom () {
             ?) m="000$m";;              ?) m="000$m";;
             ??) m="00$m";;              ??) m="00$m";;
             ???) m="0$m";;              ???) m="0$m";;
            ?????*) pp_fatal "pp_macos_writebom: mode '$m' too long";;            ?????*) pp_error "pp_macos_writebom: mode '$m' too long";;
         esac          esac
   
         # convert owner,group into owner/group in octal          # convert owner,group into owner/group in octal
Line 6580  pp_macos_files_bom () { Line 6771  pp_macos_files_bom () {
   
         case $t in          case $t in
             f)              f)
                   test x"$m" = x"000-" && m=0644
                 echo ".$p       10$m    $owner  `                  echo ".$p       10$m    $owner  `
                     /usr/bin/cksum < "${pp_destdir}$p" |                      /usr/bin/cksum < "${pp_destdir}$p" |
                    awk '{print $2 "    " $1}'`";;                    awk '{print $2 "    " $1}'`"
                 ;;
             d)              d)
                echo ".${p%/}   4$m     $owner";;                test x"$m" = x"000-" && m=0755
                 echo ".${p%/}   4$m     $owner"
                 ;;
             s)              s)
                   test x"$m" = x"000-" && m=0755
                 rl=`/usr/bin/readlink "${pp_destdir}$p"`                  rl=`/usr/bin/readlink "${pp_destdir}$p"`
                 #test x"$rl" = x"$st" ||                  #test x"$rl" = x"$st" ||
                 #    pp_error "symlink mismatch $rl != $st"                  #    pp_error "symlink mismatch $rl != $st"
                 echo ".$p       12$m    $owner  `                  echo ".$p       12$m    $owner  `
                     /usr/bin/readlink -n "${pp_destdir}$p" |                      /usr/bin/readlink -n "${pp_destdir}$p" |
                     /usr/bin/cksum |                      /usr/bin/cksum |
                    awk '{print $2 "    " $1}'` $st";;                    awk '{print $2 "    " $1}'` $st"
                 ;;
         esac          esac
     done      done
 }  }
Line 6606  pp_macos_bom_fix_parents () { Line 6803  pp_macos_bom_fix_parents () {
                       print "$d\t40755\t0/0\n";                        print "$d\t40755\t0/0\n";
                   }                    }
                 }                  }
        m/^\S+/;        m/^(\S+)\s+(\d+)/;
        &chk(&dirname($&));'        if (oct($2) & 040000) {
             $seen{$1}++; # directory
         }
         &chk(&dirname($1));'
 }  }
   
 pp_macos_files_size () {  pp_macos_files_size () {
Line 6648  pp_macos_mkbom () { Line 6848  pp_macos_mkbom () {
     pp_warn "mkbom workaround: copying source files to staging area"      pp_warn "mkbom workaround: copying source files to staging area"
   
     bomstage=$pp_wrkdir/bom_stage      bomstage=$pp_wrkdir/bom_stage
       $pp_macos_sudo /bin/mkdir "$bomstage"
     while IFS=' ' read path mode ugid size cksumi linkpath; do      while IFS=' ' read path mode ugid size cksumi linkpath; do
         if test -h "$pp_destdir/$path"; then          if test -h "$pp_destdir/$path"; then
             $pp_macos_sudo /bin/ln -s "$linkpath" "$bomstage/$path"              $pp_macos_sudo /bin/ln -s "$linkpath" "$bomstage/$path"
Line 6667  pp_macos_mkbom () { Line 6868  pp_macos_mkbom () {
 }  }
   
 pp_backend_macos () {  pp_backend_macos () {
    typeset pkgdir Contents Resources lprojdir    : ${pp_macos_bundle_id:=$pp_macos_default_bundle_id_prefix$name}
     case "$pp_macos_pkg_type" in
         bundle) pp_backend_macos_bundle;;
         flat) pp_backend_macos_flat;;
         *) pp_error "unsupported package type $pp_macos_pkg_type";;
     esac
 }
 
 pp_backend_macos_bundle () {
     typeset pkgdir Contents Resources lprojdir svc
     typeset Info_plist Description_plist      typeset Info_plist Description_plist
    typeset bundle_vendor bundle_version size    typeset bundle_vendor bundle_version size cmp filelists
   
     mac_version=`sw_vers -productVersion`      mac_version=`sw_vers -productVersion`
     bundle_vendor=${pp_macos_bundle_vendor:-$vendor}      bundle_vendor=${pp_macos_bundle_vendor:-$vendor}
Line 6677  pp_backend_macos () { Line 6887  pp_backend_macos () {
     if test -z "$pp_macos_bundle_version"; then      if test -z "$pp_macos_bundle_version"; then
         bundle_version=`echo "$version.0.0.0" | sed -n -e 's/[^0-9.]//g' \          bundle_version=`echo "$version.0.0.0" | sed -n -e 's/[^0-9.]//g' \
             -e 's/^\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/p'`              -e 's/^\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/p'`
         #if test x"$bundle_version" != x"$version"; then  
         #    pp_warn "converted version from '$version' to '$bundle_version'"  
         #fi  
     else      else
         bundle_version="$pp_macos_bundle_version"          bundle_version="$pp_macos_bundle_version"
     fi      fi
Line 6691  pp_backend_macos () { Line 6898  pp_backend_macos () {
     Resources=$Contents/Resources      Resources=$Contents/Resources
     lprojdir=$Resources/en.lproj      lprojdir=$Resources/en.lproj
     mkdir $pkgdir $Contents $Resources $lprojdir ||      mkdir $pkgdir $Contents $Resources $lprojdir ||
        pp_fatal "Can't make package temporary directories"        pp_error "Can't make package temporary directories"
   
     echo "major: 1" > $Resources/package_version      echo "major: 1" > $Resources/package_version
     echo "minor: 0" >> $Resources/package_version      echo "minor: 0" >> $Resources/package_version
Line 6699  pp_backend_macos () { Line 6906  pp_backend_macos () {
     case $mac_version in      case $mac_version in
         "10.6"*)          "10.6"*)
             xattr -w "com.apple.TextEncoding" "macintosh;0" "$Resources/package_version"              xattr -w "com.apple.TextEncoding" "macintosh;0" "$Resources/package_version"
            xattr -w "com.apple.TextEncoding" "macintosh;0" "$Resources/PkgInfo"            xattr -w "com.apple.TextEncoding" "macintosh;0" "$Contents/PkgInfo"
             ;;              ;;
     esac      esac
   
       # Copy welcome file/dir for display at package install time.
       if test -n "$pp_macos_pkg_welcome"; then
           typeset sfx
           sfx=`echo "$pp_macos_pkg_welcome"|sed 's/^.*\.\([^\.]*\)$/\1/'`
           case "$sfx" in
               rtf|html|rtfd|txt) ;;
               *) sfx=txt;;
           esac
           cp -R ${pp_macos_pkg_welcome} $Resources/Welcome.$sfx
       fi
   
       # Copy readme file/dir for display at package install time.
       if test -n "$pp_macos_pkg_readme"; then
           typeset sfx
           sfx=`echo "$pp_macos_pkg_readme"|sed 's/^.*\.\([^\.]*\)$/\1/'`
           case "$sfx" in
               rtf|html|rtfd|txt) ;;
               *) sfx=txt;;
           esac
           cp -R ${pp_macos_pkg_readme} $Resources/ReadMe.$sfx
       fi
   
       # Copy license file/dir for display at package install time.
       if test -n "$pp_macos_pkg_license"; then
           typeset sfx
           sfx=`echo "$pp_macos_pkg_license"|sed 's/^.*\.\([^\.]*\)$/\1/'`
           case "$sfx" in
               rtf|html|rtfd|txt) ;;
               *) sfx=txt;;
           esac
           cp -R ${pp_macos_pkg_license} $Resources/License.$sfx
       fi
   
       # Add services (may modify %files)
       for svc in $pp_services .; do
           test . = "$svc" && continue
           pp_macos_add_service $svc
       done
   
       # Find file lists (%files.* includes ignore files)
       for cmp in $pp_components; do
           test -f $pp_wrkdir/%files.$cmp && filelists="$filelists${filelists:+ }$pp_wrkdir/%files.$cmp"
       done
   
     # compute the installed size      # compute the installed size
    size=`cat $pp_wrkdir/%files.* | pp_macos_files_size`    size=`cat $filelists | pp_macos_files_size`
   
     #-- Create Info.plist      #-- Create Info.plist
     Info_plist=$Contents/Info.plist      Info_plist=$Contents/Info.plist
Line 6713  pp_backend_macos () { Line 6964  pp_backend_macos () {
         key CFBundleGetInfoString string \          key CFBundleGetInfoString string \
             "${pp_macos_bundle_info_string:-$version $bundle_vendor}" \              "${pp_macos_bundle_info_string:-$version $bundle_vendor}" \
         key CFBundleIdentifier string \          key CFBundleIdentifier string \
            "${pp_macos_bundle_id:-$pp_macos_default_bundle_id_prefix$name}" \            "${pp_macos_bundle_id}" \
     key CFBundleName string "$name" \      key CFBundleName string "$name" \
         key CFBundleShortVersionString string "$bundle_version" \          key CFBundleShortVersionString string "$bundle_version" \
         key IFMajorVersion integer 1 \          key IFMajorVersion integer 1 \
Line 6745  pp_backend_macos () { Line 6996  pp_backend_macos () {
             key IFPkgDescriptionVersion string "$version" \              key IFPkgDescriptionVersion string "$version" \
         \} end-plist > $Description_plist          \} end-plist > $Description_plist
   
        # write Resources/files    # write Resources/files
    cat $pp_wrkdir/%files.* | awk '{print $6}' > $Resources/files    awk '{print $6}' $filelists > $Resources/files
   
     # write package size file      # write package size file
     printf \      printf \
Line 6755  InstalledSize $size Line 7006  InstalledSize $size
 CompressedSize 0  CompressedSize 0
 " > $Resources/$name.sizes  " > $Resources/$name.sizes
   
    # write Resources/postinstall    # write Resources/preinstall
     for cmp in $pp_components; do      for cmp in $pp_components; do
         if test -s $pp_wrkdir/%pre.$cmp; then          if test -s $pp_wrkdir/%pre.$cmp; then
             if test ! -s $Resources/preinstall; then              if test ! -s $Resources/preinstall; then
Line 6779  CompressedSize 0 Line 7030  CompressedSize 0
         fi          fi
     done      done
   
    # write Resources/postupgrade)    # write Resources/postupgrade
     for cmp in $pp_components; do      for cmp in $pp_components; do
         if test -s $pp_wrkdir/%postup.$cmp; then          if test -s $pp_wrkdir/%postup.$cmp; then
             if test ! -s $Resources/postupgrade; then              if test ! -s $Resources/postupgrade; then
Line 6791  CompressedSize 0 Line 7042  CompressedSize 0
         fi          fi
     done      done
   
    # write Resources/preremove)    # write Resources/preremove
     for cmp in $pp_components; do      for cmp in $pp_components; do
         if test -s $pp_wrkdir/%preun.$cmp; then          if test -s $pp_wrkdir/%preun.$cmp; then
             if test ! -s $Resources/preremove; then              if test ! -s $Resources/preremove; then
Line 6803  CompressedSize 0 Line 7054  CompressedSize 0
         fi          fi
     done      done
   
    # write Resources/postremove)    # write Resources/postremove
     for cmp in $pp_components; do      for cmp in $pp_components; do
         if test -s $pp_wrkdir/%postun.$cmp; then          if test -s $pp_wrkdir/%postun.$cmp; then
             if test ! -s $Resources/postremove; then              if test ! -s $Resources/postremove; then
Line 6821  CompressedSize 0 Line 7072  CompressedSize 0
         echo "requires=$pp_macos_requires" >> $Resources/uninstall          echo "requires=$pp_macos_requires" >> $Resources/uninstall
     fi      fi
   
       . $pp_wrkdir/%fixup
   
     # Create the bill-of-materials (Archive.bom)      # Create the bill-of-materials (Archive.bom)
    cat $pp_wrkdir/%files.* | pp_macos_files_bom | sort |    cat $filelists | pp_macos_files_bom | sort |
         pp_macos_bom_fix_parents > $pp_wrkdir/tmp.bomls          pp_macos_bom_fix_parents > $pp_wrkdir/tmp.bomls
   
     pp_macos_mkbom $pp_wrkdir/tmp.bomls $Contents/Archive.bom      pp_macos_mkbom $pp_wrkdir/tmp.bomls $Contents/Archive.bom
   
     # Create the cpio archive (Archive.pax.gz)      # Create the cpio archive (Archive.pax.gz)
     # On 10.5, we used "-f -" to write explicitly to stdout  
     (      (
     cd $pp_destdir &&      cd $pp_destdir &&
    cat $pp_wrkdir/%files.* | awk '{ print "." $6 }' | sed '/\/$/d' | sort | /bin/pax -w -f - | gzip -9 -c > $Contents/Archive.pax.gz    awk '{ print "." $6 }' $filelists | sed 's:/$::' | sort | /usr/bin/cpio -o | pp_macos_rewrite_cpio $filelists | gzip -9f -c > $Contents/Archive.pax.gz
     )      )
   
        $pp_macos_sudo rm -rf $pp_wrkdir/bom_stage    test -d $pp_wrkdir/bom_stage && $pp_macos_sudo rm -rf $pp_wrkdir/bom_stage
   
       rm -f ${name}-${version}.dmg
     hdiutil create -fs HFS+ -srcfolder $pkgdir -volname $name ${name}-${version}.dmg      hdiutil create -fs HFS+ -srcfolder $pkgdir -volname $name ${name}-${version}.dmg
 }  }
   
   pp_backend_macos_flat () {
       typeset pkgdir bundledir Resources lprojdir svc
       typeset Info_plist Description_plist
       typeset bundle_vendor bundle_version size numfiles cmp filelists
   
       mac_version=`sw_vers -productVersion`
       bundle_vendor=${pp_macos_bundle_vendor:-$vendor}
   
       if test -z "$pp_macos_bundle_version"; then
           bundle_version=`echo "$version.0.0.0" | sed -n -e 's/[^0-9.]//g' \
               -e 's/^\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/p'`
       else
           bundle_version="$pp_macos_bundle_version"
       fi
       source_version=`echo $version | sed 's/.*\.//'`
   
       # build the flat package layout
       pkgdir=$pp_wrkdir/pkg
       bundledir=$pp_wrkdir/pkg/$name.pkg
       Resources=$pkgdir/Resources
       lprojdir=$Resources/en.lproj
       mkdir $pkgdir $bundledir $Resources $lprojdir ||
           pp_error "Can't make package temporary directories"
   
       # Add services (may modify %files)
       for svc in $pp_services .; do
           test . = "$svc" && continue
           pp_macos_add_service $svc
       done
   
       # Find file lists (%files.* includes ignore files)
       for cmp in $pp_components; do
           test -f $pp_wrkdir/%files.$cmp && filelists="$filelists${filelists:+ }$pp_wrkdir/%files.$cmp"
       done
   
       # compute the installed size and number of files/dirs
       size=`cat $filelists | pp_macos_files_size`
       numfiles=`cat $filelists | wc -l`
       numfiles="${numfiles##* }"
   
       # Write Distribution file
       cat <<-. >$pkgdir/Distribution
           <?xml version="1.0" encoding="UTF-8"?>
           <installer-script minSpecVersion="1.000000" authoringTool="com.quest.rc.PolyPkg" authoringToolVersion="$pp_version" authoringToolBuild="$pp_revision">
               <title>$name $version</title>
               <options customize="never" allow-external-scripts="no"/>
               <domains enable_localSystem="true"/>
   .
       if test -n "$pp_macos_pkg_welcome"; then
           cp -R "${pp_macos_pkg_welcome}" $Resources
           echo "    <welcome file=\"${pp_macos_pkg_welcome##*/}\"/>" >>$pkgdir/Distribution
       fi
       if test -n "$pp_macos_pkg_readme"; then
           cp -R "${pp_macos_pkg_readme}" $Resources
           echo "    <readme file=\"${pp_macos_pkg_readme##*/}\"/>" >>$pkgdir/Distribution
       fi
       if test -n "$pp_macos_pkg_license"; then
           cp -R "${pp_macos_pkg_license}" $Resources
           echo "    <license file=\"${pp_macos_pkg_license##*/}\"/>" >>$pkgdir/Distribution
       fi
       cat <<-. >>$pkgdir/Distribution
               <choices-outline>
                   <line choice="choice0"/>
               </choices-outline>
               <choice id="choice0" title="$name $version">
                   <pkg-ref id="${pp_macos_bundle_id}"/>
               </choice>
               <pkg-ref id="${pp_macos_bundle_id}" installKBytes="$size" version="$version" auth="Root">#$name.pkg</pkg-ref>
           </installer-script>
   .
   
       # write scripts archive
       # XXX - missing preupgrade, preflight, postflight
       mkdir $pp_wrkdir/scripts
       for cmp in $pp_components; do
           if test -s $pp_wrkdir/%pre.$cmp; then
               if test ! -s $pp_wrkdir/scripts/preinstall; then
                   echo "#!/bin/sh" > $pp_wrkdir/scripts/preinstall
                   chmod +x $pp_wrkdir/scripts/preinstall
               fi
               cat $pp_wrkdir/%pre.$cmp >> $pp_wrkdir/scripts/preinstall
               echo : >> $pp_wrkdir/scripts/preinstall
           fi
           if test -s $pp_wrkdir/%post.$cmp; then
               if test ! -s $pp_wrkdir/scripts/postinstall; then
                   echo "#!/bin/sh" > $pp_wrkdir/scripts/postinstall
                   chmod +x $pp_wrkdir/scripts/postinstall
               fi
               cat $pp_wrkdir/%post.$cmp >> $pp_wrkdir/scripts/postinstall
               echo : >> $pp_wrkdir/scripts/postinstall
           fi
           if test -s $pp_wrkdir/%postup.$cmp; then
               if test ! -s $pp_wrkdir/scripts/postupgrade; then
                   echo "#!/bin/sh" > $pp_wrkdir/scripts/postupgrade
                   chmod +x $pp_wrkdir/scripts/postupgrade
               fi
               cat $pp_wrkdir/%postup.$cmp >> $pp_wrkdir/scripts/postupgrade
               echo : >> $pp_wrkdir/scripts/postupgrade
           fi
           # XXX - not supported
           if test -s $pp_wrkdir/%preun.$cmp; then
               if test ! -s $pp_wrkdir/scripts/preremove; then
                   echo "#!/bin/sh" > $pp_wrkdir/scripts/preremove
                   chmod +x $pp_wrkdir/scripts/preremove
               fi
               cat $pp_wrkdir/%preun.$cmp >> $pp_wrkdir/scripts/preremove
               echo : >> $pp_wrkdir/scripts/preremove
           fi
           # XXX - not supported
           if test -s $pp_wrkdir/%postun.$cmp; then
               if test ! -s $pp_wrkdir/scripts/postremove; then
                   echo "#!/bin/sh" > $pp_wrkdir/scripts/postremove
                   chmod +x $pp_wrkdir/scripts/postremove
               fi
               cat $pp_wrkdir/%postun.$cmp >> $pp_wrkdir/scripts/postremove
               echo : >> $pp_wrkdir/scripts/postremove
           fi
       done
       if test "`echo $pp_wrkdir/scripts/*`" != "$pp_wrkdir/scripts/*"; then
           # write scripts archive, scripts are mode 0755 uid/gid 0/0
           # resetting the owner and mode is not strictly required
           (
           cd $pp_wrkdir/scripts || pp_error "Can't cd to $pp_wrkdir/scripts"
           rm -f $pp_wrkdir/tmp.files.scripts
           for s in *; do
               echo "f 0755 0 0 - ./$s" >>$pp_wrkdir/tmp.files.scripts
           done
           find . -type f | /usr/bin/cpio -o | pp_macos_rewrite_cpio $pp_wrkdir/tmp.files.scripts | gzip -9f -c > $bundledir/Scripts
           )
       fi
   
       # Write PackageInfo file
       cat <<-. >$bundledir/PackageInfo
           <?xml version="1.0" encoding="UTF-8"?>
           <pkg-info format-version="2" identifier="${pp_macos_bundle_id}" version="$version" install-location="/" relocatable="false" overwrite-permissions="true" followSymLinks="true" auth="root">
               <payload installKBytes="$size" numberOfFiles="$numfiles"/>
   .
       if test -s $bundledir/Scripts; then
           echo "    <scripts>" >>$bundledir/PackageInfo
           for s in preflight postflight preinstall postinstall preupgrade postupgrade; do
               if test -s "$pp_wrkdir/scripts/$s"; then
                   echo "  <$s file=\"$s\"/>" >>$bundledir/PackageInfo
               fi
           done
           echo "    </scripts>" >>$bundledir/PackageInfo
       fi
       cat <<-. >>$bundledir/PackageInfo
           </pkg-info>
   .
   
       . $pp_wrkdir/%fixup
   
       # Create the bill-of-materials (Bom)
       cat $filelists | pp_macos_files_bom | sort |
           pp_macos_bom_fix_parents > $pp_wrkdir/tmp.bomls
       pp_macos_mkbom $pp_wrkdir/tmp.bomls $bundledir/Bom
   
       # Create the cpio payload
       (
       cd $pp_destdir || pp_error "Can't cd to $pp_destdir"
       awk '{ print "." $6 }' $filelists | sed 's:/$::' | sort | /usr/bin/cpio -o | pp_macos_rewrite_cpio $filelists | gzip -9f -c > $bundledir/Payload
       )
   
       test -d $pp_wrkdir/bom_stage && $pp_macos_sudo rm -rf $pp_wrkdir/bom_stage
   
       # Create the flat package with xar (like pkgutil --flatten does)
       # Note that --distribution is only supported by Mac OS X 10.6 and above
       xar_flags="--compression=bzip2 --no-compress Scripts --no-compress Payload"
       case $mac_version in
           "10.5"*) ;;
           *)       xar_flags="$xar_flags --distribution";;
       esac
       (cd $pkgdir && /usr/bin/xar $xar_flags -cf "../$name-$version.pkg" *)
   }
   
 pp_backend_macos_cleanup () {  pp_backend_macos_cleanup () {
     :      :
 }  }
   
 pp_backend_macos_names () {  pp_backend_macos_names () {
    echo ${name}.pkg    case "$pp_macos_pkg_type" in
         bundle) echo ${name}.pkg;;
         flat) echo ${name}-${version}.pkg;;
         *) pp_error "unsupported package type $pp_macos_pkg_type";;
     esac
 }  }
   
 pp_backend_macos_install_script () {  pp_backend_macos_install_script () {
Line 6908  pp_backend_macos_install_script () { Line 7340  pp_backend_macos_install_script () {
 }  }
   
 pp_backend_macos_init_svc_vars () {  pp_backend_macos_init_svc_vars () {
    :    pp_macos_start_services_after_install=false
     pp_macos_service_name=
     pp_macos_default_service_id_prefix="com.quest.rc."
     pp_macos_service_id=
     pp_macos_service_user=
     pp_macos_service_group=
     pp_macos_service_initgroups=
     pp_macos_service_umask=
     pp_macos_service_cwd=
     pp_macos_service_nice=
     pp_macos_svc_plist_file=
 }  }
   
   pp_macos_launchd_plist () {
       typeset svc svc_id
   
       svc="$1"
       svc_id="$2"
   
       set -- $cmd
   
       if [ -n "$pp_macos_svc_plist_file" ]; then
           echo "## Launchd plist file already defined at $pp_macos_svc_plist_file"
           return
       fi
   
       echo "## Generating the launchd plist file for $svc"
       pp_macos_svc_plist_file="$pp_wrkdir/$svc.plist"
       cat <<-. > $pp_macos_svc_plist_file
           <?xml version="1.0" encoding="UTF-8"?>
           <!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN
           http://www.apple.com/DTDs/PropertyList-1.0.dtd >
           <plist version="1.0">
           <dict>
               <key>Label</key>
               <string>$svc_id</string>
               <key>ProgramArguments</key>
               <array>
   .
       while test $# != 0; do
           printf "        <string>$1</string>\n" >> $pp_macos_svc_plist_file
           shift
       done
       cat <<-. >> $pp_macos_svc_plist_file
               </array>
               <key>KeepAlive</key>
               <true/>
   .
       if test -n "$pp_macos_service_user"; then
           printf "    <key>UserName</key>\n" >> $pp_macos_svc_plist_file
           printf "    <string>$pp_macos_service_user</string>\n" >> $pp_macos_svc_plist_file
       fi
       if test -n "$pp_macos_service_group"; then
           printf "    <key>GroupName</key>\n" >> $pp_macos_svc_plist_file
           printf "    <string>$pp_macos_service_group</string>\n" >> $pp_macos_svc_plist_file
       fi
       if test -n "$pp_macos_service_initgroups"; then
           printf "    <key>InitGroups</key>\n" >> $pp_macos_svc_plist_file
           printf "    <string>$pp_macos_service_initgroups</string>\n" >> $pp_macos_svc_plist_file
       fi
       if test -n "$pp_macos_service_umask"; then
           printf "    <key>Umask</key>\n" >> $pp_macos_svc_plist_file
           printf "    <string>$pp_macos_service_umask</string>\n" >> $pp_macos_svc_plist_file
       fi
       if test -n "$pp_macos_service_cwd"; then
           printf "    <key>WorkingDirectory</key>\n" >> $pp_macos_svc_plist_file
           printf "    <string>$pp_macos_service_cwd</string>\n" >> $pp_macos_svc_plist_file
       fi
       if test -n "$pp_macos_service_nice"; then
           printf "    <key>Nice</key>\n" >> $pp_macos_svc_plist_file
           printf "    <string>$pp_macos_service_nice</string>\n" >> $pp_macos_svc_plist_file
       fi
       cat <<-. >> $pp_macos_svc_plist_file
           </dict>
           </plist>
   .
   }
   
   pp_macos_add_service () {
       typeset svc svc_id plist_file plist_dir
   
       pp_load_service_vars "$1"
       svc=${pp_macos_service_name:-$1}
       svc_id=${pp_macos_service_id:-$pp_macos_default_service_id_prefix$svc}
   
       #-- create a plist file for svc
       pp_macos_launchd_plist "$svc" "$svc_id"
   
       #-- copy the plist file into place and add to %files
       plist_dir="/Library/LaunchDaemons"
       plist_file="$plist_dir/$svc_id.plist"
       mkdir -p "$pp_destdir/$plist_dir"
       cp "$pp_macos_svc_plist_file" "$pp_destdir/$plist_file"
       pp_add_file_if_missing "$plist_file"
   
       #-- add code to start the service on install
       ${pp_macos_start_services_after_install} && <<-. >> $pp_wrkdir/%post.$svc
           # start service '$svc' automatically after install
           launchctl load "$plist_file"
   .
   }
   
 pp_backend_macos_probe () {  pp_backend_macos_probe () {
     typeset name vers arch      typeset name vers arch
     case `sw_vers -productName` in      case `sw_vers -productName` in
Line 6926  pp_backend_macos_vas_platforms () { Line 7457  pp_backend_macos_vas_platforms () {
     echo "osx"    # XXX non-really sure what they do.. it should be "macos"      echo "osx"    # XXX non-really sure what they do.. it should be "macos"
 }  }
 pp_backend_macos_function () {  pp_backend_macos_function () {
    case $1 in    case "$1" in
         _pp_macos_search_unused) cat<<'.';;          _pp_macos_search_unused) cat<<'.';;
             # Find an unused value in the given path              # Find an unused value in the given path
             # args: path attribute minid [maxid]              # args: path attribute minid [maxid]

Removed from v.1.1.1.1  
changed lines
  Added in v.1.1.1.2


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>