Hello, here is my steps how to change name of rpm custom packer be default it is custom-linux. Steps: Prepare two session on machine where you will build classic rpm package. Now we have spec file and rpm package. Rename Name: commvault. You can check result by command: find. Thank you Filip Hasa. Share Tweet Share Share. Tnx for this. Damian Andre. Powered by inSided. Sign up Already have an account? Login Commvault Login. Login to the community Commvault Login.
A program written in a natively compiled programming language. It demonstrates a common process of compiling the source code into machine code and installing the resulting executables.
The file has these contents:. Populate the Name , Version , Release , and Summary directives:. Increment the initial value whenever updating the package without a change in the upstream release Version - such as when including a patch.
Reset Release to 1 when a new upstream release happens, for example, if bello version 0. The disttag macro is covered in RPM Macros. The License field is the Software License associated with the source code from the upstream release.
Follow this format for the License field: Fedora License Guidelines. The Source0 field provides URL to the upstream software source code. It should link directly to the version of software that is being packaged. BuildRequires specifies build-time dependencies for the package.
There is no building step for bello , because bash is a raw interpreted programming language, and the files are simply installed to their location on the system. Just delete this directive.
Requires specifies run-time dependencies for the package. The bello script requires only the bash shell environment to execute, so specify bash in this directive. Since this is software written in an interpreted programming language with no natively compiled extensions, add the BuildArch directive with the noarch value. This tells RPM that this package does not need to be bound to the processor architecture on which it is built. In our example we will use only a short description.
This usually involves expansion of compressed archives of the source code, application of patches, and, potentially, parsing of information provided in the source code for use in a later portion of the SPEC.
However, since a bash does not need to be built, simply remove what was provided by the template and leave this section blank. Here we should create any directories that will contain the installed files. Since for installing bello we only need to create the destination directory and install the executable bash script file there, we will use the install command. RPM macros allow us to do this without hardcoding paths. Within this section, you can indicate the role of various files using built-in macros.
This is useful for querying the package file manifest metadata using the rpm command. They log packaging changes, not software changes. You have now written an entire SPEC file for bello. The full SPEC file for bello now resembles:.
Before we start down this path, we need to address something somewhat unique about byte-compiled interpreted software. Since we will be byte-compiling this program, the shebang is no longer applicable because the resulting file will not contain the entry. This might seem silly for our small example but for large software projects with many thousands of lines of code, the performance increase of pre-byte-compiled code is sizeable. We will make a small shell script to call our byte compiled code to be the entry point into our software.
The Name is already specified because we provided that information to the command line for rpmdev-newspec. When a new upstream release happens for example, pello version 0.
We should note that this example URL has hard coded values in it that are possible to change in the future and are potentially even likely to change such as the release version 0. We can simplify this by only needing to update one field in the SPEC file and allowing it to be reused. Next up we have BuildRequires and Requires , each of which define something that is required by the package. However, BuildRequires is to tell rpmbuild what is needed by your package at build time and Requires is what is needed by your package at run time.
In this example we will need the python package in order to perform the byte-compile build process. We will also need the python package in order to execute the byte-compiled code at runtime and therefore need to define python as a requirement using the Requires directive. We will also need the bash package in order to execute the small entry-point script we will use here. Something we need to add here since this is software written in an interpreted programming language with no natively compiled extensions is a BuildArch entry that is set to noarch in order to tell RPM that this package does not need to be bound to the processor architecture that it is built using.
We will walk through them one by one just as we did with the previous items. Most often what happens here is the expansion of compressed archives of the source code, application of patches, and potentially parsing of information provided in the source code that is necessary in a later portion of the SPEC. Here we will perform a byte-compilation of our software.
For those who read the Preparing Software for Packaging section, this portion of the example should look familiar. However, our RPM Macros help us accomplish this task without having to hardcode paths.
We had previously discussed that since we will lose the context of a file with the shebang line in it when we byte compile that we will need to create a simple wrapper script in order to accomplish that task. The reason for showing the example option that we are is simply to demonstrate that the SPEC file itself is scriptable.
We will also need to actually install the byte-compiled file into a library directory on the system such that it can be accessed. Also, within this section you will sometimes need a built-in macro to provide context on a file. This can be useful for Systems Administrators and end users who might want to query the system with rpm about the resulting package.
This is not meant to be a log of what changed in the software from release to release, but specifically to packaging changes. Each change entry can contain multiple items and each item should start on a new line and begin with a - character.
Below is our example entry:. From there we have a - character before the Version-Release, which is an often used convention but not a requirement.
Then finally the Version-Release. In the next section we will cover how to build the RPM! When a new upstream release happens for example, cello version 2. However, we will add one to this grouping as it is closely related to the Source0 and that is our Patch0 which will list the first patch we need against our software.
We should note that this example URL has hard coded values in it that are possible to change in the future and are potentially even likely to change such as the release version 1. The next item is to provide a listing for the. We will need a listing of Patch0: cello-output-first-patch. In this example we will need the gcc and make packages in order to perform the compilation build process.
Runtime requirements are fortunately handled for us by rpmbuild because this program does not require anything outside of the core C standard libraries and we therefore will not need to define anything by hand as a Requires and can omit that directive. Since wrote a simple Makefile for our C implementation, we can simply use the GNU make command provided by rpmdev-newspec.
RPMs are built with the rpmbuild command. Different scenarios and desired outcomes require different combinations of arguments to rpmbuild. This section describes the two prime scenarios:. The rpmbuild command expects a certain directory and file structure.
This is the same structure as set up by the rpmdev-setuptree utility. The previous instructions also confirmed to the required structure. This includes the exact SPEC file, the source code, and all relevant patches.
This is useful for looking back in history and for debugging. To be able to build a binary RPM on a different hardware platform or architecture.
The -bs option stands for "build source". Building it from a SPEC file using the rpmbuild -bb command. The -bb option stands for "build binary". The output generated when creating a binary RPM is verbose, which is helpful for debugging. The output varies for different examples and corresponds to their SPEC files. For this tutorial, execute the rpm -Uvh commands above to continue interacting with the SPEC files and sources. To build bello , pello , and cello from their SPEC files, run:.
After creating a package, it is good to check its quality. Quality of the package, not of the software delivered within it. The main tool for this is rpmlint. Note that rpmlint has very strict guidelines, and sometimes it is acceptable and necessary to skip some of its Errors and Warnings, as shown in the following examples. For bello. It says that the URL listed in the Source0 directive is unreachable. This is expected, because the specified example. Presuming that we expect this URL to work in the future, we can ignore this warning.
Assuming the link will be working in the future, we can ignore this warning. The no-documentation and no-manual-page-for-binary warnings say that the RPM has no documentation or manual pages, because we did not provide any. There are many errors, because we intentionally wrote this SPEC file to be uncomplicated and to show what errors rpmlint can report.
For the sake of this example, we ignore these errors, but for packages going in production you need a good reason for ignoring this error. Assuming that we expect the URL to become valid in the future, we can ignore this error. Filesystem Hierarchy Standard. This directory is normally reserved for shared object files, which are binary files. This is an example of an rpmlint check for compliance with Filesystem Hierarchy Standard.
Normally, use RPM macros to ensure the correct placement of files. For the sake of this example, we can ignore this warning. Since this file contains the shebang , rpmlint expects the file to be executable. For the purpose of the example, leave this file without execute permissions and ignore this error.
The only warning for cello. Our RPMs are now ready and checked with rpmlint. This concludes the tutorial. This chapter covers topics that are beyond the scope of the introductory tutorial but are often useful in real-world RPM packaging. Signing a package is a way to secure the package for an end user.
Secure transport can be achieved with implementation of the HTTPS protocol, which can be done when the package is downloaded just before installing. However, the packages are often downloaded in advance and stored in local repositories before they are used.
The packages are signed to make sure no third party can alter the content of a package. Adding a signature to an already existing package. Replacing the signature on an already existing package. In most cases packages are built without a signature.
The signature is added just before the release of the package. In order to add another signature to the package package, use the --addsign option. With two signatures, the package makes its way to a retailer.
The retailer checks the signatures and, if they check out, adds their signature as well. The package now makes its way to a company that wishes to deploy the package.
After checking every signature on the package, they know that it is an authentic copy, unchanged since it was first created. The two pgp strings in the output of the rpm --checksig command show that the package has been signed twice. RPM makes it possible to add the same signature multiple times. The --addsign option does not check for multiple identical signatures. To change the public key without having to rebuild each package, use the --resign option. To sign a package at build-time, use the rpmbuild command with the --sign option.
This requires entering the PGP passphrase. The "Generating signature" message appears in both the binary and source packaging sections. The number following the message indicates that the signature added was created using PGP. When using the --sign option for rpmbuild , use only -bb or -ba options for package building. To verify the signature of a package, use the rpm command with --checksig option. For example:. When building multiple packages, use the following syntax to avoid entering the PGP passphrase multiple times.
For example when building the blather and bother packages, sign them by using the following:. Mock is a tool for building packages. It can build packages for different architectures and different Fedora or RHEL versions than the build host has. Mock creates chroots and builds packages in them. Its only task is to reliably populate a chroot and attempt to build a package in that chroot. Mock also offers a multi-package tool, mockchain , that can build chains of packages that depend on each other.
See —scm-enable in the documentation. From the upstream documentation. You can build for different distributions or releases just by specifying it on the command line. You simply specify the configuration you want to use minus the. For example, you could build our cello example for both RHEL 7 and Fedora 23 using the following commands without ever having to use different machines.
The build would succeed when you run rpmbuild because foo was needed to build and it was found on the system at build time.
However, if you took the SRPM to another system that lacked foo it would fail, causing an unexpected side effect. Mock solves this by first parsing the contents of the SRPM and installing the BuildRequires into its chroot which means that if you were missing the BuildRequires entry, the build would fail because mock would not know to install it and it would therefore not be present in the buildroot.
As you can see, mock is a fairly verbose tool. For more information, please consult the Mock upstream documentation. Something to note is that storing binary files in a VCS is not favorable because it will drastically inflate the size of the source repository as these tools are engineered to handle differentials in files often optimized for text files and this is not something that binary files lend themselves to so normally each whole binary file is stored.
As a side effect of this there are some clever utilities that are popular among upstream Open Source projects that work around this problem by either storing the SPEC file where the source code is in a VCS i.
In this section we will cover two different options for using a VCS system, git , for managing the contents that will ultimately be turned into a RPM package. One is called tito and the other is dist-git. Tito is an utility that assumes all the source code for the software that is going to be packaged is already in a git source control repository. This is good for those practicing a DevOps workflow as it allows for the team writing the software to maintain their normal Branching Workflow.
Tito will then allow for the software to be incrementally packaged, built in an automated fashion, and still provide a native installation experience for RPM based systems. Tito operates based on git tags and will manage tags for you if you elect to allow it, but can optionally operate under whatever tagging scheme you prefer as this functionality is configurable.
As we can see here, the spec file is at the root of the git repository and there is a rel-eng directory in the repository which is used by tito for general book keeping, configuration, and various advanced topics like custom tito modules. We can see in the directory layout that there is a sub-directory entitled packages which will store a file per package that tito manages in the repository as you can have many RPMs in a single git repository and tito will handle that just fine.
In this scenario however, we see only a single package listing and it should be noted that it matches the name of our spec file.
All of this is setup by the command tito init when the developers of dist-git first initialized their git repo to be managed by tito. We could then use the output as the installation point for some other component in the pipeline. Below is a simple example of commands that could accomplish this and they could be adapted to other environments. Note that the final command would need to be run with either sudo or root permissions and that much of the output has been omitted for brevity as the dependency list is quite long.
This concludes our simple example of how to use tito but it has many amazing features for traditional Systems Administrators, RPM Packagers, and DevOps Practitioners alike.
I would highly recommend consulting the upstream documentation found at the tito GitHub site for more information on how to quickly get started using it for your project as well as various advanced features it offers. The build system is then configured to pull the items that are listed as SourceX entries in the spec files in from this look-aside-cache, while the spec and patches remain in a version control system. There is also a helper command line tool to assist in this.
In an effort to not duplicate documentation, for more information on how to setup a system such as this please refer to the upstream dist-git docs. You can define your own macros. Below is an excerpt from the RPM Official Documentation , which provides a comprehensive reference on macros capabilities.
A parameterized macro contains an opts field. The shell output is set with set -x enabled. DhddsG use the --debug option, since rpmbuild deletes temporary files after successful build.
This displays the setup of environment variables, for example:. Only tar -xof is executed instead of tar -xvvof. This option has to be used as first. For example, if the package name is cello , but the source code is archived in hello The -c option can be used if the source code tarball does not contain any subdirectories and after unpacking, files from an archive fill the current directory.
The -c option creates the directory and steps into the archive expansion. An illustrative example:. Essentially, -D option means that following lines are not used:. The -T option disables expansion of the source code tarball by removing the following line from the script:. Option -b which stands for before expands specific sources before entering the working directory.
Find centralized, trusted content and collaborate around the technologies you use most. Connect and share knowledge within a single location that is structured and easy to search. I have been trying to create an rpm using a spec file.
I want to use github code with that. Any idea how can I do that? Do I need to add some other option to the spec file? It's not built-in. You're telling rpm where to claim the source can be found, but rpmbuild doesn't pull it for you. You'll need a wrapper script to do that, or look into something like spectool which should do it for you I haven't used it myself, sorry.
Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. How do I download github source code in my spec file Ask Question.
0コメント