|
From: <no...@so...> - 2002-10-11 20:47:31
|
Patches item #593359, was opened at 2002-08-09 20:47 You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=312694&aid=593359&group_id=12694 Category: None Group: None >Status: Closed >Resolution: Duplicate Priority: 5 Submitted By: Mark Harig (mharig) >Assigned to: Wes Hardaker (hardaker) Summary: net-snmp.spec and related files Initial Comment: This message has the following sections: A. Quick instructions (for proof of concept) B. Some details about the files C. Testing the generated .rpm file A. Quick instructions for using these files - 1. Download these three files into a directory (empty or otherwise, but empty is simplest). 2. Enter 'make' at your shell prompt. 'make' will attempt to build a net-snmp .rpm file. Respond to the CVS login prompt with nothing (i.e., simply press <enter> or <return>), and respond to the usual 'configure' prompts that net-snmp requires. 3. If all goes well (i.e, no configuration, build, or installation problems), then you should find your net-snmp .rpm file in the 'rpm/RPMS' directory tree. Install your .rpm file with: rpm -U rpm/RPMS/<arch>/net-snmp-<version>- 1.<arch>.rpm ======================================= B. Some details about the three files 'Makefile', 'net-snmp.spec', and 'install-net-snmp.spec' - Makefile: Updating an RPM package file (.rpm) requires a specific directory structure and a compressed source-file archive (.tar.gz). The Makefile is available to make sure that the .rpm file is updated in a dependent fashion (i.e., when some of the files that the .rpm file depends on have changed, the .rpm file gets regenerated). It is intended to make the creation of the .rpm file easier and less error prone. It also is a template that can be adapted fairly easily to help create .rpm files for other packages. It assumes that you have six capabilities: 1) An internet connection 2) CVS 3) rpm - I have used version 4.0.4. This version might be necessary to use all of the macros that the .spec file references. 4) GNU make 5) tar 6) gzip Once you have this Makefile, and net-snmp.spec and install-net-snmp.spec, you can build a net-snmp .rpm file simply by entering 'make' at your prompt: 1) 'make' attempts to download the net-snmp source files from the SourceForge CVS repository. When you are prompted for a login, simply press Return/Enter to enter an empty login (anonymous login). CVS should then download the source code from the CVS repository. 2) 'make' will then create the directory structure needed by 'rpm' and create a compressed archive (.tar.gz) in that directory tree. 3) 'rpm' expects to find this .tar.gz file (in a particular directory). It then: - uncompresses and untars the .tar.gz file (this is how the rpm chicken-and-egg problem is solved) - configures - the usual net-snmp configuration prompts will need to be responded to. - builds (i.e., "makes") 4) If all goes well, then rpm attempts to 'make install' the net-snmp files into a temporary (i.e., relocatable) directory structure, and then collects the "built" files into a .rpm file. Additional Makefile considerations: 1) Which release of net-snmp do you want to build? By default, when 'make' performs a checkout of the net-snmp source files from the SourcForge CVS repository, it retrieves the revisions tagged 'Beta'. Unfortunately, the net-snmp project does not have any normalized repository tagging policy that I could figure out. Ideally, the source files would be regularly tagged to identify the latest snapshot (otherwise, we could fall back to simply the latest revisions checked in). Until such time as a tagging policy can be established, most users will simply want to use the tag for release 5.0.3, i.e. 'Ext-5-0-3'. To select which release you would like to create .rpm file from simply define (override) the makefile 'VERSION' macro at the shell prompt, for example, $ make VERSION=Ext-5-0-3 ... 2) Which architecture are you building the net-snmp software on? This determines whether your .rpm file is .noarch.rpm, .i386.rpm, i686.rpm, hppa1.1.rpm, etc. The default is 'i386'. You can specify which platform you are building the .rpm file for by setting the ARCH macro appropropriately when you run 'make', for example, $ make VERSION=Ext-5-0-3 ARCH=i386 ... 3) Where do you want to install the net-snmp, by default? (The installer of your .rpm file can still override this default value using the rpm command line option '--prefix'.) This can be changed by defining the makefile 'PREFIX' macro when 'make' is run, for example, $ make VERSION=Ext-5-0-3 ARCH=i386 PREFIX=/usr/local net-snmp.spec: This file is intended as a more-fleshed-out template than what is provided in the documentation at www.rpm.org. While it has been customized for net-snmp, it should be possible for someone to reuse the .spec file for other projects (say, opensnmp :), after making fairly trivial modifications to it. This might prove NOT to be the case as people attempt to port it to other, non-Linux platforms. Porting almost always brings up problems that are impossible to anticipate. install-net-snmp.spec: This is a .spec-file fragment, much like 'make' includes makefile fragments, via 'include foo.mak', 'include foo.mk', or 'include foo.d' (dependency files). It is indirectly included by net-snmp.spec using the '%file -f install-net-snmp.spec' macro call. It lists the net-snmp files that are installed by the .rpm file, along with assorted directives describing particular files as documentation, configuration, directories, etc. There are two reasons I separated this file from net-snmp.spec: 1) It might become possible to generate this file automatically from the net-snmp Makefiles. This would be desirable because at present it will be necessary to maintain (at least) two files: this .spec file, install-net-snmp.spec, and at least one Makefile. Every time the Makefile(s) change the list of files that are installed via 'make install', the install-net-snmp.spec file will need to be updated also. This is error prone since it becomes easy to update the former without remember to update the latter. If the Makefile(s) could generate this file from the same list of installed files that 'make install' uses, then generating install-net-snmp.spec could be automated. 2) But why make it a separate file, instead of keeping the contents inside 'net-snmp.spec'? Because the list might be (almost certainly is) platform dependent. At present, the file is named 'install-net-snmp.spec', but it might be changed to 'install-`config.guess`.spec', i.e., be platform specific. net-snmp.spec could then include the file with '%file -f install-%{_target}.spec, i.e., include a platform-specific file, without additional modification of 'net-snmp.spec'. ================================== C. Testing the generated .rpm file - Once an RPM package file has been generated, it should be checked to make sure that I haven't made mistakes in generating the list of files. I tested the list of files that the .rpm file installs by comparing them with those installed by the standard 'make install' (which is a platform-specific list of files, I expect). The list that the .rpm file installs differs from the 'make install' process in that I added the assorted files whose names are in capital letters in the top-level net-snmp directory, i.e., AGENT.txt, COPYING, ChangeLog, etc. These are installed in the rpm-specific document directory. On Red Hat Linux, this directory is /usr/share/doc. So, if you installed net-snmp-5.0.3 on RH Linux, these documentation files would be installed in /usr/share/doc/net-snmp-5.0.3. When the 'make' process has been completed, you should find a .rpm file in the architecture- specific RPM directory, as described above. That is, in the directory that contains the Makefile, net-snmp.spec, and install-net-snmp.spec, there should be a directory named 'rpm' which was created by the Makefile. That directory, in turn contains the directories BUILD, RPMS, SOURCES SPECS, and SRPMS. These are needed by 'rpm' when creating the .rpm file, and are created by the Makefile so that building the .rpm is relocatable. In the rpm/RPMS subdirectory, an architecture- specific directory (by default, 'i386') will have been created. That directory will contain the .rpm file. I will leave off the path to the .rpm file in the tests below, for brevity, but you will need to either specify that path, or set your current directory (i.e. "cd to") to that directory. - Test 1: Check the list of files that have been designated as configuration files: $ rpm -qcp net-snmp-5_0_3-1.i386.rpm Files that have been designated as configuration files will be preserved when a package is deleted or upgraded, if they have been changed. This allows the user to compare their customizations for configuration across version upgrades. I guessed at which files should be designated as configuration files. If the list is incorrect, then 'install-net-snmp.spec' will needed to be edited. - Test 2: Check the list of documentation files. This list allows a user to quickly locate documentation for a package. $ rpm -qdp net-snmp-5_0_3-1.i386.rpm Again, this list should be checked to see if any mistakes were made. - Test 3: Check the complete list of files that would be installed by the .rpm file - $ rpm -qlp net-snmp-5_0_3-1.i386.rpm This will list all files installed by the .rpm file, except for the symbolic links (i.e., 'snmpinform'), which are created after the package is installed. - Test 4: Check to see what post-installation and pre-uninstallation scripts will be run during installation and uninstallation: $ rpm -qp --scripts net-snmp-5_0_3-1.i386.rpm - Test 5: Check to see that the package can be installed in a directory other than the default directories listed by the '-qlp' option: $ mkdir /tmp/foo $ rpm -U --prefix=/tmp/foo net-snmp-5_0_3-1.i386.rpm - Test 6: Check to see that changed configuration files are preserved when the package is uninstalled: $ vi /tmp/foo/share/snmp/mib2c-old-api.conf $ rpm -e net-snmp warning: /tmp/bar/share/snmp/mib2c.old-api.conf saved as /tmp/bar/share/snmp/mib2c.old-api.conf.rpmsave If I think of more tests I will send them along. === end of message === ---------------------------------------------------------------------- Comment By: Mark Harig (mharig) Date: 2002-08-22 16:11 Message: Logged In: YES user_id=555886 In the places in the text where I refer to: net-snmp-5_0_3-1.i386.rpm it should read: net-snmp-5.0.3-1.i386.rpm ---- ---------------------------------------------------------------------- Comment By: Mark Harig (mharig) Date: 2002-08-14 13:31 Message: Logged In: YES user_id=555886 Test 10: Check the file permissions of the files in the .rpm package file: $ rpm -qlvp net-snmp-5_0_3-1.i386.rpm At present, the permissions of the header files (*.h), manual pages (*.1, *.3, *.5, and *.8), configuration files (*.conf), text files (*.txt), and the files in the share/snmp/snmpconf-data directory tree have the 'execute' permission bit turned on for user, group, and world. This bit should probably be turned off for all of these files. It would need to be turned off in the SourceForge CVS repository ',v' files. ---------------------------------------------------------------------- Comment By: Mark Harig (mharig) Date: 2002-08-13 10:06 Message: Logged In: YES user_id=555886 Notes about side effects of building the net-snmp .rpm file: Because the net-snmp.spec and Makefile have been written to support a relocatable net-snmp .rpm package file, building the .rpm file should have few uncontained side effects. In the normal course of building the .rpm file, the following side effects should occur: 1. A subdirectory named 'rpm' will be created in the directory that contains the Makefile and .spec files. Much of the work of building the .rpm file will be done in the directory tree created inside this 'rpm' directory. Once the .rpm file has been created, you can simply remove the 'rpm' directory, if you want. 'make clean' will do this for you. 2. The files that are to be installed by the .rpm file are temporarily created in a directory in /var/tmp (this directory likely varies depending on your O/S and rpm version). The directory that is created is automatically deleted once the .rpm file has been built. If the .rpm fails to build for some reason, then temporary scripts that rpm creates may be found in /var/tmp with the name 'rpm-tmp.nnnnn', where 'n' is a sequence of digits. These scripts may sometimes be useful in debugging an rpm .spec file, and may be safely deleted by the user. ---------------------------------------------------------------------- Comment By: Mark Harig (mharig) Date: 2002-08-13 09:53 Message: Logged In: YES user_id=555886 Corrected the prefix used in the pre/post scripts. Added code to run 'ldconfig' after the files are installed. Added a post-uninstall script to run 'ldconfig' after the package is removed. You can apply this patch with the following commands: $ cd /directory/that/contains/net-snmp.spec $ patch -p0 < net-snmp.spec.patch ---------------------------------------------------------------------- Comment By: Mark Harig (mharig) Date: 2002-08-13 09:39 Message: Logged In: YES user_id=555886 The third patch to the Makefile. This one does not fix any errors. It replaces 'rpm' with 'rpmbuild', which accepts more rpm build options than the simple 'rpm' command, plus it is a bit more self-documenting. Also, the '@' was removed from the command sequence that downloads the source code and creates a .tar.gz file. You can avoid this, and other 'make' clutter, by using make's '-s' option: $ make -s This patch should be applied after the previous patches, and a 'Preq' has been added to the patch file to help safe guard for this. ---------------------------------------------------------------------- Comment By: Mark Harig (mharig) Date: 2002-08-13 09:25 Message: Logged In: YES user_id=555886 - Test 7: Check the information header for the net-snmp package: $ rpm -qip net-snmp-5_0_3-1.i386.rpm or, once the package is installed: $ rpm -qi net-snmp This header information needs to be checked for correctness and completeness, in particular, are there additional instructions that need to be told to the user of the rpm package? - Test 8: Check on the list of requirements for the net-snmp rpm package: $ rpm -qp --requires net-snmp-5_0_3-1.i386.rpm Are there any additional packages that net-snmp requires (prerequisites)? These packages, along with version numbers, can be listed in the net-snmp.spec file so that rpm will check for those packages and the version numbers. For example, the net-snmp package could require Perl, version 5 or later. If it was not installed already, then the installation of the net-snmp package would halt with an error message. - Test 9: Check the group affiliation of the net-snmp package: $ rpm -qg "System Environment/Daemons" Note that the quotes are required and the string is case sensitive. Check for net-snmp in the list of packages. ---------------------------------------------------------------------- Comment By: Mark Harig (mharig) Date: 2002-08-12 15:37 Message: Logged In: YES user_id=555886 A note about the executable programs generated by 'rpm': By default (and I do NOT know a way to prevent this), after building the executable programs, 'rpm' runs the script 'brp-strip'. This script, in turn, runs the 'strip' command with the option '-g', which the documentation for the 'strip' command says: -g --strip-debug Remove debugging symbols only. For this reason (i.e., because the net-snmp executable programs are stripped), you should not expect these files to be identical to those generated by the net-snmp 'make', 'make install' process. BTW, I do not know if the 'brp-strip' command varies from platform to platform or for different versions of rpm, but in case it does, I am using rpm 4.0.4, running on Red Hat Linux 7.1. Also, I am using GNU 'strip', version 2.10.91. ---------------------------------------------------------------------- Comment By: Mark Harig (mharig) Date: 2002-08-12 15:11 Message: Logged In: YES user_id=555886 Corrected another mistake. I was mistakenly not accounting for the fact that '$Name' was being substituted (with the tag used at cvs checkout or update) twice, so my comparison for an empty tag was invalid. With this fix, a "run-time" check is done to see whether a 'sed' command returns an empty string. If it does, then no tag was defined during 'cvs checkout' or 'cvs update', or from the command line using 'make VERSION=...'. In that case, we assume that the user wants to check out the HEAD revision of all files, and we name the resulting .rpm file: net-snmp-Beta-1.<arch>.rpm, where <arch> is whatever architecture the user specified, or 'i386', if no architecture was specified. Also, some comments were corrected/improved. This patch file should be applied AFTER the previous patch file, and it should be applied with essentially the same command sequence, i.e., $ cd /directory/that/has/Makefile and Makefile.patch2 $ patch -p0 < Makefile.patch2 I have added the 'Prereq: ifeq ($(tag)' to the head of this second patch to prevent the patches from being applied in the wrong order. ---------------------------------------------------------------------- Comment By: Mark Harig (mharig) Date: 2002-08-12 13:32 Message: Logged In: YES user_id=555886 Here is a (small) patch for the Makefile that is included in the .tar.gz file. It does the following: 1. Fixes a Makefile syntax error in a macro definition ('tag = ...') and in conditional ('ifeq...') 2. Corrects references to 'viewcvs' to 'net-snmp'. 3. Corrects a small grammar error. The patch can be applied to the Makefile with the following commands: $ cd /directory/that/contains/Makefile and Makefile.patch $ patch -p0 < Makefile.patch ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=312694&aid=593359&group_id=12694 |