Informing the IBM Community

Open Source Updates

0
(0)

To continue my series of articles on Open Source on the IBM i.
A couple of months ago I wrote a PowerWire article on how we should now be managing, and keeping up to date, our open source, which can be found here.

For those of you, like myself, who have been working on this server for many, many years, we have become en-grained in how we manage software on the IBM i. Licensed programs, PTFs, cume packages etc. Well, as I stated in my previous article, for open source, this has now all changed.
In this article, I would like to show how we can find out which open source packages have updates available, and how we can schedule updates to fit in with our existing operating system fix procedures.

Access for Client Solutions

As shown in my previous article, the ACS product has been enhanced to allow us to manage open source packages.
While this is great, there is no way to schedule any updates.

Top Tip: Remember, you have to have *ALLOBJ authority to run any of the open source package management commands

Updating

As you may have noticed, the ACS product uses the YUM package management utility to update our installed packages.
So, if we use a shell session, we can run YUM with the ‘check-update’ parameter. This will check with the IBM repository for any updates that may be available for packages that we have installed.
This will not perform any updates, it simply gives us a list of packages that have updates available for installation.

 

 

Wow, another Node.js update available, need to get that installed!
If we are now ready to install all the available updates we run the YUM update. Again, this will check the IBM repository and update all the packages we have installed.

YUM Log

If you have any problems with YUM, a good place to start is its log. YUM’s log can be found on the IFS in directory /QOpenSys/var/log. I’m using Midnight Commander to show the log on our server below.
If you need further details on the excellent utility Midnight Commander, my PowerWire article can be found here.

CL Program

In this section I will demonstrate how we can piece together all the above practices into a CL program, which can then be scheduled to run along with your existing PTF fix procedures.
The pseudo-code for this program is as follows:
• Check if there are any packages to update sending the output to a text file in our IFS
• Copy the text file to a multi member text file, keeping a record of the updates found
• The member in the previous step, will be named with the date of the package check to give an audit of when updates occurred
• Produce a spool file of the package updates
• Create a PDF of the above for auditing reasons
• Run the package updates
Firstly, we need to create a stream file in the IFS that is used to stop the CL program from prompting us if we want to update packages.

You can use either nano from a shell or EDTF from a 5250 command line – EDTF ‘/tmp/yes’ – just place a y in this file

/********************************************************************/

/*                                                                  */

/*  Automate OSS Package Updates                                    */

/*                                                                  */

/*  Andy Youens                                                     */

/*  © 1990 – 2019 FormaServe Systems Ltd                            */

/*                                                                  */

/********************************************************************/

Start:      Pgm

 

Dcl        &Date        *char      6

Dcl        &Mbr         *char     10

Dcl        &IFSDir      *Char    256  Value( ‘/oss/logs/‘ )

Dcl        &Time        *Char      6

Dcl        &FullName    *Char    256

Dcl        &PDFName     *Char    640

 

Dcl        &MsgId         *Char             7

Dcl        &MsgDta        *Char           256

Dcl        &MsgF          *Char            10

Dcl        &MsgfLib       *Char            10

Dcl        &ErrorSw       *Lgl

 

Copyright  ‘© 1990 – 2019 FormaServe Systems Ltd.’

 

MonMsg     Cpf0000 Exec(Goto Error)

 

RtvSysVal  QDate  &Date

RtvSysVal  QTime  &Time

 

ChgVar     &Mbr   (‘Log_’ || &Date )

ChgVar     &FullName (‘/QSYS.LIB/POWERWIRE.LIB/OSS_LOG.FILE/’ +

||  &Mbr |< ‘.MBR’)

 

CrtPf      FILE(PowerWire/OSS_log) RCDLEN(512) TEXT(‘OSS +

Audit Log ‘) MAXMBRS(*NOMAX)

 

MonMsg     (Cpf5813 Cpf7302) /* Aleady exists – dont care!  */

 

/*              Remove previous log                                           */

RmvLnk     ‘/oss/logs/yumupdates.log’

Monmsg     CPFA0A9 /* Dont care if not there  */

 

/*              Check if there are any updates                                */

QSH        CMD(‘/QOpenSys/pkgs/bin/yum check-update > +

/oss/logs/yumupdates.log’)

 

/*              Copy log file to physical file                                */

Cpy        OBJ(‘/oss/logs/yumupdates.log’) ToObj(&fullname) +

Replace(*Yes) DtaFmt(*Text)

 

/*              Produce spool of packages to be updated                       */

CpyF       FROMFILE(PowerWire/OSS_Log) TOFILE(*LIBL/QSYSPRT) +

FROMMBR(&Mbr)

 

/*              Build PDF name – Uses Date & Time to make unique              */

ChgVar     &PdfName (&IFSDir |< ‘Yum Update Log ‘ || &Date || +

‘_’ || &Time |< ‘.pdf’)

 

/*              Create PDF for auditing purposes                              */

CpySplF    File(QSYSPRT) ToFile(*ToStmf) Job(*) SplNbr(*Last) +

ToStmf(&PdfNameWscst(*Pdf) StmfOpt(*Replace)

 

/*              Update packages                                               */

QSH        CMD(‘/QOpenSys/pkgs/bin/yum update < /tmp/yes >> +

/tmp/os002‘)

 

/*  All Done – ‘Omers!    */

Return

 

Error:      If         Cond(&ErrorSw) Then(SndPgmMsg  MsgID(Cpf9999) +

MsgF(QCpfMsg) MsgType(*Escape))

 

ChgVar     &ErrorSw    ‘1’

 

Error2:     RcvMsg     MsgType(*Diag) MsgDta(&MsgDta) MsgID(&MsgID) +

MsgF(&MsgF) SndMsgFLib(&MsgFLib)

If         (&MsgID =   ‘ ‘) Goto Error3

SndPgmMsg  MsgID(&MsgID) MsgF(&MsgFLib/&Msgf) MsgDta(&MsgDta) +

MsgType(*Diag)

Goto       Error2

 

Error3:     RcvMsg     MsgType(*Excp) MsgDta(&MsgDta) MsgID(&MsgID) +

MsgF(&MsgF) SndMsgFLib(&MsgFLib)

SndPgmMsg  MsgID(&MsgID) MsgF(&MsgFLib/&MsgF) MsgDta(&MsgDta) +

MsgType(*Escape)

 

End:        EndPgm

 

Here we can see the PDF output from the above CL program.  The file name includes the date and time the program was run.

It shows an audit of what packages needed updating.

Conclusion

Hopefully, this article has given you an insight on how we can include our Open Source package management updates alongside our existing fix procedures.
We all need to embrace the open source offerings provided by IBM. The more we use, the more they will give us!
If you have any open source questions, let me know.

Andy Youens is an IBM i consultant/instructor at Milton Keynes, UK-based FormaServe Systems with over 36 years IBM midrange experience.

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.