[HP-UX, Linux patch] Building Linux patch utility on HP-UX

SYMPTOM/SOLUTION:
PRODUCT: Linux patch Version 2.6.1 HP C/aC++ B3910B A.06.20 [May 13 2008] GNU Make
OP/SYS: HP-UX B.11.31 IA64
COMPONENT: Linux patch to work with Linux diff files
SOURCE: Philippe Vouters Fontainebleau/France
HIGH QUALITY MOBILES+TABLETS: http://android-land.fr
WHY NEEDING LINUX PATCH UTILITY ON HP-UX: There is a patch utility which comes up in standard with HP-UX. However, the sources input diff file is not suited for this tool when it comes from the Linux community. Hence the need to be able to run the Linux patch utility on HP-UX systems to rebuild Opensource codes with the latest sources diff when not already available as .depot.gz from http://hpux.connect.org.uk/.
SYMPTOMS and SOLUTIONS: If you download ../zip/patch-2.6.1.tar.gz which is the Linux patch V2.6.1 source code as found at http://kambing.ui.ac.id/gnu/patch/ modified to also also run on OpenVMS platforms, you will notice the following after you: aps39-13-root# gunzip patch-2.6.1.tar.gz aps39-13-root# tar -mxvf patch-2.6.1.tar aps39-13-root# cd patch-2.6.1/ aps39-13-root# ./configure that HP-UX supplied make returns an error. This proves you need GNU make for HP-UX which gzipped depot you can download from http://hpux.connect.org.uk/. You will have to gunzip the .depot.gz and swinstall it from the root account with: aps39-13-root# swinstall -s /absolute/path/to/make*.depot \* Now if you: aps39-13-root# export PATH=/usr/local/bin:$PATH aps39-13-root# gmake you will notice Linux patch Version 2.6.1 is missing gl/lib/strnlen.c, you can create with: aps39-13-root# cat > gl/lib/strnlen.c <<- EOF #include <config.h> #include <sys/types.h> size_t strnlen(const char *s, size_t maxlen) { size_t i=0; if (!s) return (size_t)-1; while (s[i] && i < maxlen) i++; return i; } EOF aps39-13-root# After you added gl/lib/strnlen.c file, you can rerun gmake which will compile this file and invoke ld to successfully build src/patch using all object files. Finally you can: aps39-13-root# gmake install This will install the just linked src/patch into /usr/local/bin and ./patch.man into /usr/local/share/man From now on and from any HP-UX account, each time you wish to run Linux patch, you can: % export PATH=/usr/local/bin:$PATH To view its man: % export MANPATH=/usr/local/share/man:$MANPATH % man patch
CHECKING SOLUTION: aps39-13-root# export MANPATH=/usr/local/share/man:$MANPATH aps39-13-root# man patch Reformatting entry. Wait... PATCH(1) PATCH(1) GNU NAME patch - apply a diff file to an original SYNOPSIS patch [options] [originalfile [patchfile]] but usually just patch -pnum <patchfile DESCRIPTION patch takes a patch file patchfile containing a difference listing produced by the diff program and applies those differences to one or more original files, producing patched versions. Normally the patched versions are put in place of the originals. Backups can be made; see the -b or --backup option. The names of the files to be patched are usually taken from the patch file, but if there's just one file to be patched it can be specified on the command line as originalfile. :tandard input aps39-13-root# aps39-13-root# patch -v patch 2.6.1 Copyright (C) 1988 Larry Wall Copyright (C) 2003, 2009 Free Software Foundation, Inc. This program comes with NO WARRANTY, to the extent permitted by law. You may redistribute copies of this program under the terms of the GNU General Public License. For more information about these matters, see the file named COPYING. written by Larry Wall and Paul Eggert aps39-13-root# Checking solution in real conditions: aps39-13-root# echo $PATH /usr/local/bin:/usr/sbin:/usr/bin: etc... aps39-13-root# 1/ Patching a single source file: aps39-13-root# gunzip awstats-7.0.diff.tar.gz aps39-13-root# tar -xmvf awstats-7.0.diff.tar x awstats.diff, 737 bytes, 2 tape blocks aps39-13-root# patch -p0 awstats.pl < awstats.diff patching file awstats.pl aps39-13-root# 2/ Patching a source directory tree: aps39-13-root# gunzip binutils-2.22.diff.tar.gz aps39-13-root# tar -xmvf binutils-2.22.diff.tar x binutils-2.22.diff, 13673 bytes, 27 tape blocks aps39-13-root# gunzip binutils-2.22.tar.gz aps39-13-root# tar -xmf binutils-2.22.tar aps39-13-root# patch -p1 -d binutils-2.22/ < binutils-2.22.diff patching file bfd/configure.com patching file bfd/dwarf2.c patching file bfd/elf.c patching file bfd/vms-misc.c patching file binutils/configure.com patching file binutils/readelf.c patching file binutils/strings.c patching file gas/app.c patching file gas/config/tc-ia64.c patching file gas/config/te-vms.c patching file gas/configure.com patching file gas/stabs.c patching file libiberty/configure.com aps39-13-root#
CONCLUSION: This Linux patch utility installation sounds very sane.
FALLOUT: Along with a Linux diff HP-UX installation whose latest sources you will find at http://ftp.gnu.org/gnu/diffutils/, this will also allow you to create Linux style patches on your HP-UX system for either internal purposes to share with your Linux, OpenVMS and/or Windows/MinGW/Cygwin colleagues, or directly with the Opensource community maintainers. To create Linux style diff patches, the command with Linux diff is: 1/ For a single file difference: $ diff -au oldfile newfile > file.diff 2/ For source directory trees difference $ diff -Naur olddir/ newdir/ > file.diff
REFERENCE: Linux diff and patch solution on OpenVMS: ../tima/OpenVMS-Latest_Linux_diff_and_patch_for_OpenVMS.html