This documents will introduce update-hash
to update MD5 checksum. There will be an applied example of Helloworld software release after the introduction.
In order to update the MD5 checksum, it involves 2 relevant files: update-hash and buildout.hash.cfg
. The following introduction can also be found in SlapOS repository or in your Theia project:
update-hash
Introduction
update-hash
is a tool to assist software release developers in the management of buildout.hash.cfg
files.
A lot of recipes which uses hashing for referenced files. Updating the hash results in part uninstallation and installation, which is desired behaviour, as the file might have to be redownloaded. By using update-hash
with buildout.hash.cfg
the developer does not have to do the calculations and updates manually, just calling the tool is enough.
Generally each Buildout profile which references some file shall use this approach to improve development process and minimise risk of using incorrect data from such entires.
Working with buildout.hash.cfg
buildout.hash.cfg
files are buildout-style simplified configparser files to have a easy way to update MD5 hashes of provided files for download. They look like:
[section]
md5sum = <hash>
filename = <relative-path>
Where <hash>
is an automatically calculated checksum of <relative-path>
.
Then buildout.hash.cfg
can be included in software profile by extends
of [buildout]
section, and the section's md5sum
and filename
can be used.
Special cases of filename
key
In case if section recipe has special unwanted behaviour for filename
field the _update_hash_filename_
key can be used like:
[section]
md5sum = <hash>
_update_hash_filename_ = <relative-path>
Working with update-hash
In order to update the buildout.hash.cfg
one just need to call update-hash
while being in the directory containing the file.
Helloworld Example
Locate script: update-hash
In this project, update-hash
is located in /srv/slapgrid/slappart49/srv/project/slapos/update-hash, you will have a similar path.
Locate buildout.hash.cfg
In this helloworld software, buildout.hash.cfg
is located in /srv/slapgrid/slappart49/srv/project/slapos/software/helloworld/buildout.hash.cfg. There is one md5sum of one section needed to be updated:
[instance-profile]
is defined from ~/helloworld/software.cfg as a section name
instance.cfg.in
is the relative path of the file
md5sum
can be recalculated automatically by calling update-hash
Call update-hash
To demonstrate how to call update-hash
, we can remove the hash value in buildout.hash.cfg temporarily.
Since we are about to update the hash for helloworld software release, and buildout.hash.cfg is located directly under ~/software/helloworld directory, we are expected to go to the directory, just be asides buildout.hash.cfg:
Open a terminal by hit Ctrl + Shift + ` , and go to helloworld directory:
cd $PWD/slapos/software/helloworld/
As we have known the location of update-hash
script, which is located just under slapos/ and at the same directory as software/, we can call the script by:
../../update-hash
As long as you hit the return for this command, you will immediately have your md5sum
in buildout.hash.cfg: