Writing a Java Class to Manage RPM Package Content

A look inside RPM packages and how to use Java to extract information.
Adding a GUI Interface

Now our basic class structure, which is able to manipulate headers of RPM packages, is in place, and it would be a good idea to add a minimal GUI interface to it. We will build this very simple interface using the Java Swing package, available with either JDK 1.1 or JDK 1.2.

This very simple GUI interface is managed by the RpmFilePanel.Java class. This class inherits the basic JPanel graphical component and divides the screen into three parts using a Java BorderLayout:

  • URL input field to input the RPM input file location in URL format

  • scrollable ListBox to display the RPM file information

  • button bar containing a “load” button, which proceeds with the URL RPM file loading Let's now explain how the GUI interface RpmFilePanel Java class interacts with the RpmFile class.

Starting the Java Application

The RpmFilePanel.java file contains a static main method to launch the Swing frame inside a Java application. You can use the JDK Java utility from the shell to start it:

java rpm.RpmFilePanel

Warning: you should have compiled the Java package and installed it in a location accessible from your CLASSPATH.

You should provide a valid RPM package file in URL form and type it into the URL field as shown below. Finally, pushing on the Load button will:

  • instantiate a new RpmFile instance

  • call the set_rpmFileName method with the RPM of URL field

  • call the get_rpmReport method and display its String Vector result into the Swing List box as shown below

Figure 4 shows the screen layout after querying an RPM package.

Figure 4. RPM Screenshot

When you need to build the provided source package, you may use either a JDK 1.1 version or a JDK 1.2.2 version. If you use JDK1.1, the prerequisite is to download the Swing package from Sun's site.

Conclusion

Using Java to analyse RPM file formats may be useful, and it gives you cross-platform portability, which may help you display RPM file contents on heterogeneous platforms. This basic tool may easily be enhanced, for instance to convert RPM contents into other formats or extract other parts of an RPM package.

Resources

email: jymengant@ifrance.com

Jean-Yves Mengant (jymengant@ifrance.com) is Chief Architect at SEFAS Technologies in Paris, France. He has been a professional programmer for more than 20 years on multiple OSes (MVS, Linux), languages (assemblers, C, C++, Java and Perl) and software topics (Network, Tp Monitors and GUI interfaces). He has used Linux systems professionally for programming tasks since 1995 and kernel 1.2, and the Java language since 1996 and JDK 1.0.

______________________

White Paper
Fabric-Based Computing Enables Optimized Hyperscale Data Centers

Today’s modular x86 servers are compute-centric, designed as a least common denominator to support a wide range of IT workloads. Those generic, virtualized IT workloads have much different resource optimization requirements than hyperscale and cloud applications. They have resulted in a “one size fits all” enterprise IT architecture that is not optimized for a specific set of IT workloads, and especially not emerging hyperscale workloads, such as web applications, big data, and object storage. In this report, you will learn how shifting the focus from traditional compute-centric IT architectures to an innovative disaggregated fabric-based architecture can optimize and scale your data center.

Learn More

Sponsored by AMD

White Paper
Red Hat White Paper: Using an Open Source Framework to Catch the Bad Guy

Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6

Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.

Learn more about catching the bad guy in this free white paper.

Learn More

Sponsored by DLT Solutions