The software of the Gentoo system is provided to the user in the form of source code, so the installation software is installed in the form of compiled source code.
Using emerge software package management tools to install software is still very convenient (automatic dependency resolution, the software after installation can be well recognized by the system and other software), but editing (Secondary Development) the source code downloaded by emerge cannot be compiled and installed due to hash issues. This article uses OpenSSH as an example to illustrate how to solve this problem.
OpenSSH is a commonly used remote login software. By default, emerge installation will leak the software version information, as shown below:
You can see the OpenSSH_5.9p1-hpn13v11lpk, OpenSSL 2.2.2j 10 May 2012 and other version information (where OpenSSL 2.2.2j 10 May 2012 is a modified version ).
The analysis summarizes a method:
1. Download the OpenSSH package from emerge (-F indicates only downloading and not installing it)
As you can see, three software packages are downloaded and the (rmd160, sha1, sha256)
2. Modify the downloaded package information (not limited to version)
2.1 change openssh-5.9p1.tar.gz version information
As you can see, if openssh_5.9p1 is not found in the unzipped source code using grep, continue searching:
Change the version in the source code file of the version information (I changed all OpenSSH to SSH, 5.9 to 3.3, and P1 to P9)
In addition, the grep search keyword is still incorrect. For the correct information, see:
After modification, package the changed source code into a openssh-5.9p1.tar.gz (replace the openssh-5.9p1.tar.gz downloaded by emerge-f)
2.2 modify version information in openssh-5.9p1-hpn13v11.diff.gz and openssh-lpk-5.9p1-0.3.14.patch.gz
I changed all OpenSSH to SSH, 5.9 to 3.3, P1 to P9, hpn13v11 to-BB-, and LPK to CC.
So far, it is expected that the SSH version information will change from OpenSSH_5.9p1-hpn13v11lpk to SSH_3.3p9-bb-cc after completion
For the openssh-5.9p1-hpn13v11.diff.gz I changed
Is my changed openssh-lpk-5.9p1-0.3.14.patch.gz
3. Change portage manifest
The changed package cannot be directly used for emerge installation and cannot pass emerge checksum detection.
My method is to find the rmd160, sha1, and sha256 of the software package recorded in the portage and change it to the modified rmd160, sha1, and sha256 of the software package.
In this way, the modified software package can be successfully verified by emerge.
Portage record openssh-5.9p1.tar.gz rmd160, openssh-5.9p1-hpn13v11.diff.gz and openssh-lpk-5.9p1-0.3.14.patch.gz value files are:/usr/portage/net-MISC/OpenSSH/manifest.
This document only demonstrates openssh-5.9p1.tar.gz rmd160)
3.1 Use the OpenSSL tool to calculate the rmd160, sha1, sha256 (and file size of the openssh-5.9p1.tar.gz rmd160)
3.2 Replace the value in/usr/portage/net-MISC/OpenSSH/manifest with the calculated value (remember the file size)
3.3 openssh-5.9p1-hpn13v11.diff.gz and openssh-lpk-5.9p1-0.3.14.patch.gz
4. Install the modified Software
Run emerge OpenSSH directly (if an error occurs, check your previous behavior :))
5. Results (compare the first figure in this article, version information from the previous OpenSSH_5.9p1-hpn13v11lpk to the SSH_3.3p9-bb-cc)
6. Here comes the wood ....