You are not logged in.

#1 2011-02-27 12:13:17

leniviy
Member
Registered: 2009-05-23
Posts: 177

[SOLVED] Oracle patches for Arch

I tried to install oracle clients (10201_client_linux32.zip, linux_11gR2_client.zip), and like others got this error:

libclntsh.so: undefined reference to `ntusini'

Here's the solution:
Unzip the directory 'client'
Make sure your current directory contains 'client'
run this script: makepatches :

#!/bin/bash

set -e

fn_findcandidates() {
  rm -rf candidates && mkdir candidates

  set "*.mk" "*/*.mk" \
    "deinstall" "*/deinstall" \
    "init.cssd" "*/init.cssd" \
    "gennttab" "*/gennttab" \
    "genagtsh" "*/genagtsh" \
    "localconfig.sbs" "*/localconfig.sbs"

  local i=0
  find client -name "*.jar" | while read -r jarpath; do
    LANG=C unzip -qq -l "$jarpath" "$@" | {
      set --
      while read -r x d t f; do
        case "$d $t" in
          ????-??-??' '??:??)
            if unzip -p "$jarpath" "$f" | grep "/usr/bin/awk\|/bin/basename\|/usr/bin/tr" >/dev/null; then
              set -- "$@" "$f"
            fi
            ;;
        esac
      done
      if [ $# -gt 0 ]; then
        echo "$@"
        mkdir -p candidates/$i/old
        echo "$jarpath" > candidates/$i/jar.txt
        unzip -o -d candidates/$i/old "$jarpath" "$@"
        cp -r candidates/$i/old candidates/$i/new
      fi
    }
    [ ! -d "candidates/$i" ] || i=$((i+1))
  done
}

fn_autopatchcandidates() {
  (
  cd candidates
  # replace AWK=/usr/bin/awk
  for d in *; do
    find "$d/new" -type f | xargs sed -i -e '/PLATFORM = .Linux./!b; :m1; n' -e 's|AWK=.*/bin/awk|AWK=/bin/awk|;t;b m1' || true
  done
  for d in *; do
    find "$d/new" -type f | xargs sed -i -e '/\(PLATFORM = .SunOS.\|else\)/!b; :m1; n' -e 's|AWK=.*/usr.*/bin/awk|AWK="/usr"/bin/awk|;t;b m1' || true
  done

  # replace /usr/bin/tr
  for d in *; do
    find "$d/new" -name "*.mk" | xargs sed -i "s|^TR=/usr/bin/tr$|TR=/bin/tr|" 2>/dev/null || true
  done
  for d in *; do
    find "$d/new" -type f | xargs sed -i -e 's|\(.Linux. = ./bin/uname. . .. \)TR=/usr/bin/tr|\1TR=/bin/tr|' -e 's|\(on linux tr is at \)/usr/bin/tr|\1/bin/tr|' || true
  done
  for d in *; do
    find "$d/new" -type f | xargs sed -i 's|\(-z ..TR. .. then TR=.\)/usr/bin/tr|\1/bin/tr|' || true
  done

  # replace /bin/basename
  for d in *; do
    find "$d/new" -type f | xargs sed -i 's|`/bin/basename |`basename |' || true
  done
  for d in *; do
    find "$d/new" -name init.cssd | xargs sed -i 's|BASENAME=/bin/basename|BASENAME=basename|' 2>/dev/null || true
  done
  for d in *; do
    find "$d/new" -type f | xargs sed -i 's|\(-z ..BASENAME. .. then BASENAME=.\)/bin/basename|\1basename|' || true
  done

  #for d in *; do
  #  diff -ur $d/old $d/new || true
  #done
  )
}

if true; then
  # find in archives
  fn_findcandidates

  # try to replace known patterns
  fn_autopatchcandidates

  # check remaining
  for d in candidates/*; do
    if grep -R "/usr/bin/awk\|/bin/basename\|/usr/bin/tr" "$d/new"; then
      echo "some bad paths remaining"
      return 1
    fi
  done

  # make patches
  ( rm -rf patches && mkdir patches
    cd candidates
    for d in *; do
      ( cd $d && cat jar.txt && ( diff -ur old new || true) ) >../patches/$d.patch
    done
  )
fi

It will create and fill directory 'patches'. You can put the patches to your source pkg or whatever.
Then run another script: applypatches :

#!/bin/bash

set -e

fn_patchzip() {
  local patchfile="$1"
  local zipfile=`head -1 "$patchfile"`
  local errors=
 
  mkdir -p tmp
  
  cat "$patchfile" | sed -e 's|^+++ new/\([^    ]*\).*|\1|;t;D' | {
    set --
    while read -r f; do
      set -- "$@" "$f"
    done

    test "$1" || {
      echo "fn_patchzip: invalid patch" >&2
      return 1
    }

    unzip -o -d tmp "$zipfile" "$@" >/dev/null
    
    patchfile=$(cd $(dirname -- "$patchfile") && pwd)/$(basename -- "$patchfile")
    zipfile=$(cd $(dirname -- "$zipfile") && pwd)/$(basename -- "$zipfile")
    cd tmp

    if errors="`patch -Np1 -i "$patchfile" 2>&1`"; then
      zip "$zipfile" "$@"
    else
      patch -Np1 -R -i "$patchfile" >/dev/null 2>&1 || {
        echo "$errors" >&2
        return 1
      }
    fi
  } || return 1
}

for p in patches/*; do
  fn_patchzip "$p"
done

When new oracle version released, makepatches must be modified

Last edited by leniviy (2011-02-27 12:19:20)


Arch 64, xfce4

Offline

Board footer

Powered by FluxBB