OpenPKG CVS Repository
  http://cvs.openpkg.org/
  ____________________________________________________________________________

  Server: cvs.openpkg.org                  Name:   Christoph Schug
  Root:   /e/openpkg/cvs                   Email:  [EMAIL PROTECTED]
  Module: openpkg-src                      Date:   17-Mar-2003 13:22:59
  Branch: HEAD                             Handle: 2003031712225800

  Modified files:
    openpkg-src/openpkg     mkproxyrpm.pl openpkg.spec rpm.patch.bugfix
                            rpm.patch.feature rpm.patch.porting
                            rpm.patch.regen rpmtool rpmx.sh

  Log:
    Support for MacOS X (at least 10.0.4) - now I know what the guys at Apple
    meant with "Think different" ;-)

  Summary:
    Revision    Changes     Path
    1.5         +1  -1      openpkg-src/openpkg/mkproxyrpm.pl
    1.141       +120 -26    openpkg-src/openpkg/openpkg.spec
    1.2         +2  -2      openpkg-src/openpkg/rpm.patch.bugfix
    1.3         +2  -2      openpkg-src/openpkg/rpm.patch.feature
    1.4         +21 -2      openpkg-src/openpkg/rpm.patch.porting
    1.2         +2  -2      openpkg-src/openpkg/rpm.patch.regen
    1.17        +124 -17    openpkg-src/openpkg/rpmtool
    1.5         +1  -1      openpkg-src/openpkg/rpmx.sh
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: openpkg-src/openpkg/mkproxyrpm.pl
  ============================================================================
  $ cvs diff -u -r1.4 -r1.5 mkproxyrpm.pl
  --- openpkg-src/openpkg/mkproxyrpm.pl 30 Dec 2002 22:05:34 -0000      1.4
  +++ openpkg-src/openpkg/mkproxyrpm.pl 17 Mar 2003 12:22:58 -0000      1.5
  @@ -1,4 +1,4 @@
  -#!/bin/sh -- # -*- perl -*-
  [EMAIL PROTECTED]@/lib/openpkg/bash -- # -*- perl -*-
   eval 'exec perl -S $0 ${1+"$@"}'
       if $running_under_some_shell;
   ##
  @@ .
  patch -p0 <<'@@ .'
  Index: openpkg-src/openpkg/openpkg.spec
  ============================================================================
  $ cvs diff -u -r1.140 -r1.141 openpkg.spec
  --- openpkg-src/openpkg/openpkg.spec  10 Mar 2003 13:13:04 -0000      1.140
  +++ openpkg-src/openpkg/openpkg.spec  17 Mar 2003 12:22:58 -0000      1.141
  @@ -39,8 +39,8 @@
   #   o any cc(1)
   
   #   the package version and release
  -%define       V_openpkg 20030310
  -%define       R_openpkg 20030310
  +%define       V_openpkg 20030317
  +%define       R_openpkg 20030317
   
   #   the used software versions
   %define       V_rpm     4.0.2
  @@ -262,18 +262,21 @@
           FreeBSD/* ) l_build_path="/bin:/sbin:/usr/bin:/usr/sbin" ;;
           Linux/*   ) l_build_path="/bin:/sbin:/usr/bin:/usr/sbin" ;;
           SunOS/*   ) l_build_path="/bin:/sbin:/usr/bin:/usr/sbin:/usr/ccs/bin" ;;
  +        Darwin/*  ) l_build_path="/bin:/sbin:/usr/bin:/usr/sbin" ;;
           *         ) l_build_path="/bin:/sbin:/usr/bin:/usr/sbin" ;;
       esac
       case $plid in
           FreeBSD/* ) l_build_ldlp="/usr/lib" ;;
           Linux/*   ) l_build_ldlp="/lib:/usr/lib" ;;
           SunOS/*   ) l_build_ldlp="/usr/lib:/usr/ccs/lib" ;;
  +        Darwin/*  ) l_build_ldlp="/usr/lib" ;;
           *         ) l_build_ldlp="/usr/lib" ;;
       esac
       case $plid in
           FreeBSD/4* ) l_build_ulim="ulimit -H -S -f 262144 -d 262144 -m 262144 -s 
65536 -u 128" ;;
           Linux/2*   ) l_build_ulim="ulimit -H -S -f 262144 -d 262144 -m 262144 -v 
262144 -s 65536 -u 128" ;;
           SunOS/5.8* ) l_build_ulim="ulimit -H -S -f 262144 -d 262144 -s 65536" ;;
  +        Darwin/*   ) l_build_ulim=":" ;;
           *          ) l_build_ulim=":" ;;
       esac
       echo "l_build_path=\"$l_build_path\"; export l_build_path" >>.buildenv
  @@ -672,7 +675,7 @@
       #   and adjust RPM configuration files
       mv $RPM_BUILD_ROOT%{l_prefix}/bin/rpm \
          $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpm
  -    ( echo "#!/bin/sh";
  +    ( echo "#!%{l_prefix}/lib/openpkg/bash";
         echo "exec %{l_prefix}/lib/openpkg/rpm --rcfile %{l_prefix}/etc/openpkg/rpmrc 
\${1+\"[EMAIL PROTECTED]"}"
       ) >$RPM_BUILD_ROOT%{l_prefix}/bin/rpm
       chmod 755 $RPM_BUILD_ROOT%{l_prefix}/bin/rpm
  @@ -881,7 +884,7 @@
           eval "xuid=\"\$${class}uid\""
           eval "xgid=\"\$${class}gid\""
           if [ ".$xuid" = . ]; then
  -            xuid=`(getent passwd; cat /etc/passwd; ypcat passwd) 2>/dev/null |\
  +            xuid=`(getent passwd; cat /etc/passwd; ypcat passwd; nidump passwd .) 
2>/dev/null |\
                     grep "^${xusr}:" | awk -F: '{ print $3; }'`
               if [ ".$xuid" = . ]; then
                   #   seek for a reasonably uid/gid pair
  @@ -890,11 +893,11 @@
                   while [ ".$ok" = .0 ]; do
                       eval "u_exists=\$u_exists_$xuid"
                       if [ ".$u_exists" = . ]; then
  -                        u_exists=`(getent passwd; cat /etc/passwd; ypcat passwd) 
2>/dev/null | grep "^[^:]*:[^:]*:$xuid:"`
  +                        u_exists=`(getent passwd; cat /etc/passwd; ypcat passwd; 
nidump passwd .) 2>/dev/null | grep "^[^:]*:[^:]*:$xuid:"`
                       fi
                       eval "g_exists=\$g_exists_$xuid"
                       if [ ".$g_exists" = . ]; then
  -                        g_exists=`(getent group; cat /etc/group; ypcat group) 
2>/dev/null | grep "^[^:]*:[^:]*:$xuid:"`
  +                        g_exists=`(getent group; cat /etc/group; ypcat group; 
nidump group .) 2>/dev/null | grep "^[^:]*:[^:]*:$xuid:"`
                       fi
                       if [ ".$u_exists" = . -a ".$g_exists" = . ]; then
                           ok=1
  @@ -907,7 +910,7 @@
               fi
           fi
           if [ ".$xgid" = . ]; then
  -            xgid=`(getent group; cat /etc/group; ypcat group) 2>/dev/null |\
  +            xgid=`(getent group; cat /etc/group; ypcat group; nidump group .) 
2>/dev/null |\
                     grep "^${xgrp}:" | awk -F: '{ print $3; }'`
               if [ ".$xgid" = . ]; then
                   xgid="$xuid"
  @@ -944,7 +947,7 @@
           class="$1"; usr="$2"; uid="$3"; grp="$4"; gid="$5"
   
           #   check whether user already exists
  -        exists=`(getent passwd; cat /etc/passwd; ypcat passwd) 2>/dev/null | grep 
"^$usr:"`
  +        exists=`(getent passwd; cat /etc/passwd; ypcat passwd; nidump passwd .) 
2>/dev/null | grep "^$usr:"`
           if [ ".$exists" = . ]; then
               if [ ".$cusr" != ".root" ]; then
                   echo "openpkg:WARNING: skipping creation of OpenPKG $class user 
$usr" 1>&2
  @@ -978,27 +981,52 @@
                           
entry="${usr}:*:${uid}:${gid}:${realname}:${prefix}:${shell}"
                           update=":"
                           ;;
  +                    Darwin/* )
  +                        #   intentionally do nothing here
  +                        ;;
  +                esac
  +                case "$plid" in
  +                    Darwin/* )
  +                        niutil -create     . "/users/${usr}"
  +                        niutil -createprop . "/users/${usr}" passwd   "*"
  +                        niutil -createprop . "/users/${usr}" uid      "${uid}"
  +                        niutil -createprop . "/users/${usr}" gid      "${gid}"
  +                        niutil -createprop . "/users/${usr}" realname "${realname}"
  +                        niutil -createprop . "/users/${usr}" home     "${prefix}"
  +                        niutil -createprop . "/users/${usr}" shell    "${shell}"
  +                        ;;
  +                    * )
  +                        cp $file $file.bak && \
  +                        (grep -v '^+:' $file.bak; echo $entry; grep '^+:' 
$file.bak) >$file
  +                        rm -f $file.bak >/dev/null 2>&1
  +                        eval $update
  +                        ;;
                   esac
  -                cp $file $file.bak && \
  -                (grep -v '^+:' $file.bak; echo $entry; grep '^+:' $file.bak) >$file
  -                rm -f $file.bak >/dev/null 2>&1
  -                eval $update
               fi
           fi
   
           #   check whether group already exists
  -        exists=`(getent group; cat /etc/group; ypcat group) 2>/dev/null | grep 
"^$grp:"`
  +        exists=`(getent group; cat /etc/group; ypcat group; nidump group .) 
2>/dev/null | grep "^$grp:"`
           if [ ".$exists" = . ]; then
               if [ ".$cusr" != ".root" ]; then
                   echo "openpkg:WARNING: skipping creation of OpenPKG $class group 
$grp" 1>&2
                   echo "openpkg:WARNING: (would require root-privileges)" 1>&2
               else
  -                #   add entry to group database
  -                file=/etc/group
  -                entry="${grp}:*:${gid}:${usr}"
  -                cp $file $file.bak && \
  -                (grep -v '^+:' $file.bak; echo $entry; grep '^+:' $file.bak) >$file
  -                rm -f $file.bak >/dev/null 2>&1
  +                case "$plid" in
  +                    Darwin/* )
  +                        niutil -create     . "/groups/${grp}"
  +                        niutil -createprop . "/groups/${grp}" gid   "${gid}"
  +                        niutil -createprop . "/groups/${grp}" users "${usr}"
  +                        ;;
  +                    * )
  +                        #   add entry to group database
  +                        file=/etc/group
  +                        entry="${grp}:*:${gid}:${usr}"
  +                        cp $file $file.bak && \
  +                        (grep -v '^+:' $file.bak; echo $entry; grep '^+:' 
$file.bak) >$file
  +                        rm -f $file.bak >/dev/null 2>&1
  +                    ;;
  +                esac
               fi
           fi
       done
  @@ -1188,6 +1216,57 @@
                       )
                   fi
                   ;;
  +            Darwin/* )
  +                darwin_rc_dir="/System/Library/StartupItems/${name}"
  +                if [ ! -d ${darwin_rc_dir} ]; then
  +                    mkdir ${darwin_rc_dir}
  +                fi
  +
  +                #   make sure hierarchy is activated in /etc/hostconfig
  +                #   FIXME cs - simple and bad code here without any detection
  +                #              of exisiting entries
  +                echo "OPENPKG_${name}=-YES-" >> /etc/hostconfig
  +
  +                #   install transfer script
  +                if [ ! -f ${darwin_rc_dir}/${name} ]; then
  +                    rm -f ${darwin_rc_dir}/${name} >/dev/null 2>&1
  +                    ( echo "#!/bin/sh"
  +                      echo "#"
  +                      echo "#   /System/Library/StartupItems/${name}/${name}"
  +                      echo "#       -- startup transfer script for OpenPKG 
${prefix} hierarchy"
  +                      echo "#"
  +                      echo ""
  +                      echo "[ ! -f ${prefix}/etc/rc ] && exit 0"
  +                      echo ""
  +                      echo ". /etc/rc.common"
  +                      echo ""
  +                      echo "if [ "${OPENPKG_${name}:=-NO-}" = "-YES-" ]; then"
  +                      echo "    ConsoleMessage \"OpenPKG ${prefix} hierarchy\""
  +                      echo "    ${prefix}/etc/rc all start"
  +                      echo "fi"
  +                    ) >${darwin_rc_dir}/${name}
  +                    chmod 755 ${darwin_rc_dir}/${name}
  +                fi
  +                #   install startup parameter list
  +                if [ ! -f ${darwin_rc_dir}/StartupParameters.plist ]; then
  +                    rm -f ${darwin_rc_dir}/StartupParameters.plist >/dev/null 2>&1
  +                    (
  +                      echo "{"
  +                      echo "  Description     = \"OpenPKG ${prefix} hierarchy\";"
  +                      echo "  Provides        = (\"OpenPKG ${prefix}\");"
  +                      echo "  Requires        = (\"Disks\", \"Network 
Configuration\", \"Resolver\");"
  +                      echo "  Uses            = (\"Cron\");"
  +                      echo "  OrderPreference = \"Last\";"
  +                      echo "  Messages ="
  +                      echo "  {"
  +                      echo "    start = \"Starting OpenPKG ${prefix} hierarchy\";"
  +                      echo "    stop  = \"Stopping OpenPKG ${prefix} hierarchy\";"
  +                      echo "  };"
  +                      echo "}"
  +                    ) >${darwin_rc_dir}/StartupParameters.plist
  +                    chmod 644 ${darwin_rc_dir}/StartupParameters.plist
  +                fi
  +                ;;
           esac
       fi
   
  @@ -1197,7 +1276,7 @@
           echo "openpkg:WARNING: (would require root-privileges)" 1>&2
       else
           case "$plid" in
  -            FreeBSD/* | Linux/* )
  +            FreeBSD/* | Linux/* | Darwin/* )
                   exists=`grep "$prefix/etc/rc" /etc/crontab`
                   if [ ".$exists" = . ]; then
                       (   echo "# <OpenPKG prefix=$prefix pkg=openpkg>"
  @@ -1310,7 +1389,7 @@
           class="$1"; usr="$2"; uid="$3"; grp="$4"; gid="$5"
   
           #   check whether user already exists
  -        exists=`(getent passwd; cat /etc/passwd; ypcat passwd) 2>/dev/null | grep 
"^$usr:"`
  +        exists=`(getent passwd; cat /etc/passwd; ypcat passwd; nidump passwd .) 
2>/dev/null | grep "^$usr:"`
           if [ ".$exists" != . ]; then
               if [ ".$cusr" != ".root" ]; then
                   echo "openpkg:WARNING: skipping deletion of OpenPKG $class user 
$usr" 1>&2
  @@ -1339,12 +1418,15 @@
                           cp /etc/passwd /etc/passwd.bak && \
                           grep -v "^${usr}:" /etc/passwd.bak >/etc/passwd
                           ;;
  +                    Darwin/* )
  +                        niutil -destroy . "/users/${usr}"
  +                        ;;
                   esac
               fi
           fi
   
           #   check whether group already exists
  -        exists=`(getent group; cat /etc/group; ypcat group) 2>/dev/null | grep 
"^$grp:"`
  +        exists=`(getent group; cat /etc/group; ypcat group; nidump group .) 
2>/dev/null | grep "^$grp:"`
           if [ ".$exists" = . ]; then
               if [ ".$cusr" != ".root" ]; then
                   echo "openpkg:WARNING: skipping deletion of OpenPKG $class group 
$grp" 1>&2
  @@ -1353,9 +1435,16 @@
                   echo "openpkg:WARNING: skipping deletion of OpenPKG $class group 
$grp" 1>&2
                   echo "openpkg:WARNING: (would remove system standard group)" 1>&2
               else
  -                #   delete group entry
  -                cp /etc/group /etc/group.bak && \
  -                grep -v "^${grp}:" /etc/group.bak >/etc/group
  +                case "$plid" in
  +                    Darwin/* )
  +                        niutil -destroy . "/groups/${grp}"
  +                        ;;
  +                    * )
  +                        #   delete group entry
  +                        cp /etc/group /etc/group.bak && \
  +                        grep -v "^${grp}:" /etc/group.bak >/etc/group
  +                        ;;
  +                esac
               fi
           fi
       done
  @@ -1429,6 +1518,11 @@
                   rm -f /etc/rc2.d/S900${name} >/dev/null 2>&1
                   rm -f /etc/rc1.d/K100${name} >/dev/null 2>&1
                   ;;
  +            Darwin/* )
  +                cp /etc/hostconfig /etc/hostconfig.bak && \
  +                grep -v "^OPENPKG_${name}=" /etc/hostconfig.bak >/etc/hostconfig
  +                rm -rf /System/Library/StartupItems/${name} >/dev/null 2>&1
  +                ;;
           esac
       fi
   
  @@ -1438,7 +1532,7 @@
           echo "openpkg:WARNING: (would require root-privileges)" 1>&2
       else
           case "$plid" in
  -            FreeBSD/* | Linux/* )
  +            FreeBSD/* | Linux/* | Darwin/* )
                   exists=`grep "<OpenPKG prefix=$prefix pkg=openpkg>" /etc/crontab`
                   if [ ".$exists" != . ]; then
                       p=`echo $prefix | sed -e 's;/;\\\\/;g'`
  @@ .
  patch -p0 <<'@@ .'
  Index: openpkg-src/openpkg/rpm.patch.bugfix
  ============================================================================
  $ cvs diff -u -r1.1 -r1.2 rpm.patch.bugfix
  --- openpkg-src/openpkg/rpm.patch.bugfix      29 May 2002 19:56:14 -0000      1.1
  +++ openpkg-src/openpkg/rpm.patch.bugfix      17 Mar 2003 12:22:58 -0000      1.2
  @@ -1,7 +1,7 @@
   ##
   ##  rpm-4.0.2.patch.bugfix -- Annotated patch file
  -##  Copyright (c) 2000-2001 Cable & Wireless Deutschland GmbH
  -##  Copyright (c) 2000-2001 Ralf S. Engelschall <rse.com>
  +##  Copyright (c) 2000-2003 Cable & Wireless Deutschland GmbH
  +##  Copyright (c) 2000-2003 Ralf S. Engelschall <[EMAIL PROTECTED]>
   ##
   ##  This file assembles changes to existing RPM source files between
   ##  the original RedHat RPM and the OpenPKG RPM variant. It can be
  @@ .
  patch -p0 <<'@@ .'
  Index: openpkg-src/openpkg/rpm.patch.feature
  ============================================================================
  $ cvs diff -u -r1.2 -r1.3 rpm.patch.feature
  --- openpkg-src/openpkg/rpm.patch.feature     3 Jan 2003 18:01:40 -0000       1.2
  +++ openpkg-src/openpkg/rpm.patch.feature     17 Mar 2003 12:22:58 -0000      1.3
  @@ -1,7 +1,7 @@
   ##
   ##  rpm-4.0.2.patch.feature -- Annotated patch file
  -##  Copyright (c) 2000-2001 Cable & Wireless Deutschland GmbH
  -##  Copyright (c) 2000-2001 Ralf S. Engelschall <rse.com>
  +##  Copyright (c) 2000-2003 Cable & Wireless Deutschland GmbH
  +##  Copyright (c) 2000-2003 Ralf S. Engelschall <[EMAIL PROTECTED]>
   ##
   ##  This file assembles changes to existing RPM source files between
   ##  the original RedHat RPM and the OpenPKG RPM variant. It can be
  @@ .
  patch -p0 <<'@@ .'
  Index: openpkg-src/openpkg/rpm.patch.porting
  ============================================================================
  $ cvs diff -u -r1.3 -r1.4 rpm.patch.porting
  --- openpkg-src/openpkg/rpm.patch.porting     9 Jan 2003 13:38:24 -0000       1.3
  +++ openpkg-src/openpkg/rpm.patch.porting     17 Mar 2003 12:22:58 -0000      1.4
  @@ -1,7 +1,7 @@
   ##
   ##  rpm-4.0.2.patch.porting -- Annotated patch file
  -##  Copyright (c) 2000-2001 Cable & Wireless Deutschland GmbH
  -##  Copyright (c) 2000-2001 Ralf S. Engelschall <rse.com>
  +##  Copyright (c) 2000-2003 Cable & Wireless Deutschland GmbH
  +##  Copyright (c) 2000-2003 Ralf S. Engelschall <[EMAIL PROTECTED]>
   ##
   ##  This file assembles changes to existing RPM source files between
   ##  the original RedHat RPM and the OpenPKG RPM variant. It can be
  @@ -307,3 +307,22 @@
    # if defined __GNUC__ && __GNUC__ >= 2
    typedef __SIZE_TYPE__ __size_t;
    #  ifdef _XOPEN_SOURCE
  ++---------------------------------------------------------------------------
  +| Fix for Power Macs running MacOS X
  ++---------------------------------------------------------------------------
  +Index: lib/rpmrc.c
  +--- lib/rpmrc.c      Sat Mar 15 17:32:40 2003
  ++++ lib/rpmrc.c      Sat Mar 15 17:35:44 2003
  +@@ -949,6 +949,12 @@
  +                 }
  +                 strcat(un.sysname, cpR);
  +             }
  ++            /* fix up machine hardware name containing white-space as it
  ++             * happens to be on Power Macs running MacOS X
  ++             */
  ++            if (!strncmp(un.machine, "Power Macintosh", 15)) {
  ++                sprintf(un.machine, "powerpc");
  ++            }
  +         }
  + #else /* OPENPKG */
  + #if !defined(__linux__)
  @@ .
  patch -p0 <<'@@ .'
  Index: openpkg-src/openpkg/rpm.patch.regen
  ============================================================================
  $ cvs diff -u -r1.1 -r1.2 rpm.patch.regen
  --- openpkg-src/openpkg/rpm.patch.regen       29 May 2002 19:56:14 -0000      1.1
  +++ openpkg-src/openpkg/rpm.patch.regen       17 Mar 2003 12:22:58 -0000      1.2
  @@ -1,7 +1,7 @@
   ##
   ##  rpm-4.0.2.patch.regen -- Annotated patch file
  -##  Copyright (c) 2000-2001 Cable & Wireless Deutschland GmbH
  -##  Copyright (c) 2000-2001 Ralf S. Engelschall <rse.com>
  +##  Copyright (c) 2000-2003 Cable & Wireless Deutschland GmbH
  +##  Copyright (c) 2000-2003 Ralf S. Engelschall <[EMAIL PROTECTED]>
   ##
   ##  This file assembles changes to existing RPM source files between
   ##  the original RedHat RPM and the OpenPKG RPM variant. It can be
  @@ .
  patch -p0 <<'@@ .'
  Index: openpkg-src/openpkg/rpmtool
  ============================================================================
  $ cvs diff -u -r1.16 -r1.17 rpmtool
  --- openpkg-src/openpkg/rpmtool       30 Jan 2003 09:46:12 -0000      1.16
  +++ openpkg-src/openpkg/rpmtool       17 Mar 2003 12:22:58 -0000      1.17
  @@ -35,7 +35,7 @@
   fi
   if [ ".$1" = ".-h" -o ".$1" = ".--help" ]; then
       echo "This is $prog_name, version $prog_vers ($prog_date)"
  -    echo "Copyright (c) 2000-2001 Ralf S. Engelschall <[EMAIL PROTECTED]>"
  +    echo "Copyright (c) 2000-2003 Ralf S. Engelschall <[EMAIL PROTECTED]>"
       echo ''
       echo "Usage: $prog_name [<options>] [<cmd-name> [<cmd-options>] [<cmd-args>]]" 
       echo ''
  @@ -297,6 +297,9 @@
   platform_machine=`(uname -m) 2>/dev/null` ||\
   platform_machine=`(uname -p) 2>/dev/null` ||\
   platform_machine='unknown'
  +if [ ".$platform_machine" = ".Power Macintosh" ]; then      
  +    platform_machine=`(uname -p) 2>/dev/null`
  +fi
   platform_release=`(uname -r) 2>/dev/null` ||\
   platform_release='unknown'
   platform_system=`(uname -s) 2>/dev/null` ||\
  @@ -386,6 +389,18 @@
                               fi
                           fi
                           ;;
  +                    *:Darwin:*:* )
  +                        n=`/usr/sbin/sysctl hw.ncpu | awk '{ print $3; }'`
  +                        if [ ".$n" != . ]; then
  +                            if [ $n -gt 1 ]; then
  +                                n=`expr $n \* 2`
  +                                mflags="$mflags -j$n"
  +                                if [ ".$isgmake" = .no ]; then
  +                                    mflags="$mflags -B"
  +                                fi
  +                            fi
  +                        fi
  +                        ;;
                   esac
               fi
               echo "$mflags"
  @@ -792,7 +807,14 @@
   
           #   add user
           if [ ".$opt_a" = .yes ]; then
  -            exists=`grep "^$user:" /etc/passwd`
  +            case "$platform" in
  +                *:Darwin:*:* )
  +                    exists=`(cat /etc/passwd; nidump passwd .) 2>/dev/null | grep 
"^$user:"`
  +                    ;;
  +                * )
  +                    exists=`grep "^$user:" /etc/passwd`
  +                    ;;
  +            esac
               if [ ".$exists" != . ]; then
                   echo "$msgprefix:Error: user $user already exists" 1>&2
                   exit 1
  @@ -802,8 +824,16 @@
               uid=$opt_u
               ok=0
               while [ ".$ok" = .0 ]; do
  -                u_exists=`grep "^[^:]*:[^:]*:$uid:" /etc/passwd`
  -                g_exists=`grep "^[^:]*:[^:]*:$uid:" /etc/group`
  +                case "$platform" in
  +                    *:Darwin:*:* )
  +                        u_exists=`(cat /etc/passwd; nidump passwd .) 2>/dev/null | 
grep "^[^:]*:[^:]*:$uid:"`
  +                        g_exists=`(cat /etc/group;  nidump group  .) 2>/dev/null | 
grep "^[^:]*:[^:]*:$uid:"`
  +                        ;;
  +                    * )
  +                        u_exists=`grep "^[^:]*:[^:]*:$uid:" /etc/passwd`
  +                        g_exists=`grep "^[^:]*:[^:]*:$uid:" /etc/group`
  +                        ;;
  +                esac
                   if [ ".$u_exists" = . -a ".$g_exists" = . ]; then
                       ok=1
                       break
  @@ -836,14 +866,39 @@
                       echo "${user}:*:${uid}:${uid}:${opt_n}:${opt_d}:${opt_s}" 
>>/etc/passwd
                       (PATH="$PATH:/usr/sbin"; pwconv)
                       ;;
  +                *:Darwin:*:* )
  +                    niutil -create     . "/users/${user}"
  +                    niutil -createprop . "/users/${user}" passwd   "*"
  +                    niutil -createprop . "/users/${user}" uid      "${uid}"
  +                    niutil -createprop . "/users/${user}" gid      "${uid}"
  +                    niutil -createprop . "/users/${user}" realname "${opt_n}"
  +                    niutil -createprop . "/users/${user}" home     "${opt_d}"
  +                    niutil -createprop . "/users/${user}" shell    "${opt_s}"
  +                    ;;
               esac
   
               #   add corresponding entry to group database
  -            echo "${user}:*:${uid}:${user}" >>/etc/group
  +            case "$platform" in
  +                *:Darwin:*:* )
  +                    niutil -create     . "/groups/${user}"
  +                    niutil -createprop . "/groups/${user}" gid   "${uid}"
  +                    niutil -createprop . "/groups/${user}" users "${user}"
  +                    ;;
  +                * )
  +                    echo "${user}:*:${uid}:${user}" >>/etc/group
  +                    ;;
  +            esac
    
           #   remove user
           elif [ ".$opt_r" = .yes ]; then
  -            exists=`grep "^$user:" /etc/passwd`
  +            case "$platform" in
  +                *:Darwin:*:* )
  +                    exists=`(cat /etc/passwd; nidump passwd .) 2>/dev/null | grep 
"^$user:"`
  +                    ;;
  +                * )
  +                    exists=`grep "^$user:" /etc/passwd`
  +                    ;;
  +            esac
               if [ ".$exists" = . ]; then
                   echo "$msgprefix:Error: user $user does not exist" 1>&2
                   exit 1
  @@ -880,12 +935,22 @@
                       (PATH="$PATH:/usr/sbin"; pwconv)
                       rm -f /etc/passwd.old
                       ;;
  +                *:Darwin:*:* )
  +                    niutil -destroy . "/users/${user}"
  +                    ;;
               esac
   
               #   remove corresponding entry from group database
  -            cp /etc/group /etc/group.old
  -            grep -v "^${user}:" /etc/group.old >/etc/group
  -            rm -f /etc/group.old
  +            case "$platform" in
  +                *:Darwin:*:* )
  +                    niutil -destroy . "/groups/${user}"
  +                    ;;
  +                * )
  +                    cp /etc/group /etc/group.old
  +                    grep -v "^${user}:" /etc/group.old >/etc/group
  +                    rm -f /etc/group.old
  +                    ;;
  +            esac
           fi
           ;;
    
  @@ -902,7 +967,14 @@
   
           #   add group
           if [ ".$opt_a" = .yes ]; then
  -            exists=`grep "^$group:" /etc/group`
  +            case "$platform" in
  +                *:Darwin:*:* )
  +                    exists=`(cat /etc/group; nidump group .) 2>/dev/null | grep 
"^$user:"`
  +                    ;;
  +                * )
  +                    exists=`grep "^$group:" /etc/group`
  +                    ;;
  +            esac
               if [ ".$exists" != . ]; then
                   echo "$msgprefix:Error: group $group already exists" 1>&2
                   exit 1
  @@ -912,7 +984,14 @@
               gid=$opt_g
               ok=0
               while [ ".$ok" = .0 ]; do
  -                exists=`grep "^[^:]*:[^:]*:$gid:" /etc/group`
  +                case "$platform" in
  +                    *:Darwin:*:* )
  +                        exists=`(cat /etc/group; nidump group .) 2>/dev/null | grep 
"^[^:]*:[^:]*:$gid:"`
  +                        ;;
  +                    * )
  +                        exists=`grep "^[^:]*:[^:]*:$gid:" /etc/group`
  +                        ;;
  +                esac
                   if [ ".$exists" = . ]; then
                       ok=1
                       break
  @@ -920,21 +999,44 @@
                   gid=`expr $gid + 1`
               done
   
  -            #   add entry to group database
  -            echo "${group}:*:${gid}:$*" >>/etc/group
  +            #   add corresponding entry to group database
  +            case "$platform" in
  +                *:Darwin:*:* )
  +                    niutil -create     . "/groups/${group}"
  +                    niutil -createprop . "/groups/${group}" gid   "${gid}"
  +                    niutil -createprop . "/groups/${group}" users "${group}"
  +                    ;;
  +                * )
  +                    echo "${group}:*:${gid}:$*" >>/etc/group
  +                    ;;
  +            esac
   
           #   remove group
           elif [ ".$opt_r" = .yes ]; then
  -            exists=`grep "^$group:" /etc/group`
  +            case "$platform" in
  +                *:Darwin:*:* )
  +                    exists=`(cat /etc/group; nidump group .) 2>/dev/null | grep 
"^$group:"`
  +                    ;;
  +                * )
  +                    exists=`grep "^$group:" /etc/group`
  +                    ;;
  +            esac
               if [ ".$exists" = . ]; then
                   echo "$msgprefix:Error: group $group does not exist" 1>&2
                   exit 1
               fi
   
               #   remove entry from group database
  -            cp /etc/group /etc/group.old
  -            grep -v "^${group}:" /etc/group.old >/etc/group
  -            rm -f /etc/group.old
  +            case "$platform" in
  +                *:Darwin:*:* )
  +                    niutil -destroy . "/groups/${group}"
  +                    ;;
  +                * )
  +                    cp /etc/group /etc/group.old
  +                    grep -v "^${group}:" /etc/group.old >/etc/group
  +                    rm -f /etc/group.old
  +                    ;;
  +            esac
           fi
           ;;
   
  @@ -974,6 +1076,11 @@
                   cmd2="ps -ef -o pid,args" 
                   cmd3="ps -ef -o pid,ppid" 
                   ;;
  +            *:Darwin:*:* )
  +                cmd0="ps -ax -opid"
  +                cmd1="ps -ax -ocommand"
  +                cmd2="ps -ax -opid,command"
  +                cmd3="ps -ax -opid,ppid"
           esac
           #   try all signals in order   
           i=$#
  @@ .
  patch -p0 <<'@@ .'
  Index: openpkg-src/openpkg/rpmx.sh
  ============================================================================
  $ cvs diff -u -r1.4 -r1.5 rpmx.sh
  --- openpkg-src/openpkg/rpmx.sh       30 Dec 2002 22:05:34 -0000      1.4
  +++ openpkg-src/openpkg/rpmx.sh       17 Mar 2003 12:22:58 -0000      1.5
  @@ -1,4 +1,4 @@
  -#!/bin/sh
  [EMAIL PROTECTED]@/lib/openpkg/bash
   ##
   ##  rpmx.sh -- RPM eXtension (Shell Wrapper)
   ##  Copyright (c) 2001-2003 Ralf S. Engelschall <[EMAIL PROTECTED]>
  @@ .
______________________________________________________________________
The OpenPKG Project                                    www.openpkg.org
CVS Repository Commit List                     [EMAIL PROTECTED]

Reply via email to