Open-source Languages & Tools for z/OS

 View Only
  • 1.  Installing git for z/OS

    Posted 07-10-2017 12:00

    Installing git for z/OS can be a challenge for systems programmers without much Unix System Services (USS) experience. This article provides relatively detailed instructions, as well as a script that can help automate the process.

    Before starting, you’ll need to go to the Rocket Open Source Languages and Tools for z/OS page and create a (free) Rocket Community account, if you don’t already have one. That will enable you to access all of the open source tool downloads.

    These instructions assume that:

    • You will first download the installation files to a Windows system.
    • You know how to transfer binary files from a Windows system to a z/OS Unix file system.

    Here we go!

    • Create a folder on Windows into which you will save the installation files before transferring them to z/OS.

    • Download the 4 necessary files off the Rocket download site, for gzip, bash, git and perl. The file names (at the time of this posting) should be:

      • gzip-1.6-edc_b0005.160229.tar
      • bash-4.3_b018.170518.tar.gz
      • git-2.3.5_b013.161229.tar.gz
      • perl-5.24.0_b005.170601.tar.gz
    • In the same folder, save this file attachment: helper.tar (31.5 KB)

    • Create a directory on USS where you will put all the installation files. It can be a subdirectory of your home directory.

    • Binary transfer all 5 of the files from Windows to the USS directory.

    • cd into the directory on USS that contains the installation files.

    • Untar the helper script, using the following command. This will create the file install.sh.

      tar -xoUXf helper.tar

    • By default, install.sh will install the software into the directory that contains the installation files. If you want to install elsewhere, edit install.sh and change the value of INSTALL_DIR at the top of the script.

    • Run install.sh, like this:

      ./install.sh

    This will install all the software and create some additional scripts:

    • uninstall.sh
    • remove_dist.sh
    • environment.sh

    To set up the environment to use git you must ‘source’ environment.sh. You do that with this command:

    . ./environment.sh
    

    Look very carefully at that command line – It’s using the “dot” command to cause bash to read the contents of the file You are must not run the script; you must source it.

    At this point you can use git. If you just type git you should get a help message.

    Once you are satisfied that git is working properly, you can delete the installation files, using ./remove_dist.sh.

    Appendix: install.sh

    Here’s the source code for the install.sh script contained in helper.tar.

    #! /bin/sh
    
    # If you want to install the tools in a directory other than 
    # the download directory, change INSTALL_DIR to point to it.
    INSTALL_DIR=`pwd`
    
    if [[ ! -d $INSTALL_DIR ]] ; then
      echo making $INSTALL_DIR
      mkdir $INSTALL_DIR
      if [[ ! -d $INSTALL_DIR ]] ; then
        echo unable to create installation directory $INSTALL_DIR
        exit 1;
      fi
    fi
    
    unpack() {
      distfile=$1
      targetdir=$2
      if [[ ! -f $distfile ]] ; then
        echo "distribution file $distfile does not exist"
        return 1
      fi
      if [[ ! -d $targetdir ]] ; then
        echo "$targetdir is not a directory"
        return 1
      fi
    
      $INSTALL_DIR/bin/gzip -c -d <$distfile | tar -C $targetdir -xoUXf -
      if [[ $? != 0 ]] ; then
        echo "unpacking $distfile into $targetdir failed"
        return 1
      fi
    
      return 0;
    }
    
    echo "installing gzip, bash, perl and git into $INSTALL_DIR"
    
    gzipdist=gzip-1.6-edc_b0005.160229.tar
    bashdist=bash-4.3_b018.170518.tar.gz
    gitdist=git-2.3.5_b013.161229.tar.gz
    perldist=perl-5.24.0_b005.170601.tar.gz
    
    # Install gzip. It is NOT compressed.
    tar -C $INSTALL_DIR -xoUXf $gzipdist
    
    if [[ ! -f $INSTALL_DIR/bin/gzip ]] ; then
      echo "installation failed for gzip"
      exit 1
    else
      echo "gzip installed"
    fi
    
    # Unpack the files for bash, git and perl
    
    unpack $bashdist $INSTALL_DIR
    unpack $gitdist $INSTALL_DIR
    unpack $perldist $INSTALL_DIR
    
    # Make sure that the permissions are correct
    find $INSTALL_DIR/lib -type f -exec chmod 644 {} \; 
    find $INSTALL_DIR/lib -type f -name '*.so' -exec chmod 755 {} \; 
    
    # Update environment.sh with the install location
    cat >environment.sh <<EOF 
    # These lines can be added to the user's ~/.profile or they can be sourced as needed.
    
    # Set the various PATHS to find the code for bash, git and perl
    export PATH=$INSTALL_DIR/bin:\$PATH
    export MANPATH=\$MANPATH:$INSTALL_DIR/man
    export PERL5LIB=$INSTALL_DIR/lib/perl5:\$PERL5LIB
    export LIBPATH=$INSTALL_DIR/lib/perl5/5.24.0/os390/CORE:\$LIBPATH
    
    export GIT_SHELL=$INSTALL_DIR/bin/bash
    export GIT_EXEC_PATH=$INSTALL_DIR/libexec/git-core
    export GIT_TEMPLATE_DIR=$INSTALL_DIR/share/git-core/templates
    
    # Set up the enhanced ASCII support flags
    export _CEE_RUNOPTS="FILETAG(AUTOCVT,AUTOTAG) POSIX(ON)"
    export _BPXK_AUTOCVT=ON
    export _TAG_REDIR_ERR=txt
    export _TAG_REDIR_IN=txt
    export _TAG_REDIR_OUT=txt
    EOF
    
    # create the uninstall script
    cat >uninstall.sh <<EOF
    #! /bin/sh
    rm environment.sh remove_dist.sh
    cd $INSTALL_DIR
    rm -rf bin lib libexec man share  README
    EOF
    chmod +x uninstall.sh
    
    cat >remove_dist.sh <<EOF
    #! /bin/sh
    # remove the download files after installation
    rm -f $gzipdist $bashdist $gitdist $perldist
    EOF
    chmod +x remove_dist.sh
    
    # Run the perl path change script
    cd $INSTALL_DIR/bin
    ./change_pwd_perl.sh