File life after a template
Updated 6 November 2026
A template does more than write a file: it binds the file to a package, marks its source, and takes responsibility for it in subsequent merges. From this follow a few rules that will save your nerves.
The service header
At the top of a file created by a template, the utilities write a block like:
#------------------------------------------------------------------------------ # Modified Calculate Utilities 3.7.6.8 # Processed template files: # /var/calculate/templates/merge/editor.sh # To modify this file, create a /etc/profile.d/editor.sh.clt template. #------------------------------------------------------------------------------
It serves three purposes. It says which templates took part in creating the file (when several are merged, this is the only way to know their origin). It suggests the right way to change something - create a .clt template, not edit the file by hand. And by it the utilities, at the next merge, recognize their part and cut it out, so that copies do not pile up: therefore the character from comment= must be a comment for the target program, otherwise the file becomes unreadable.
The file belongs to a package
A file created by a template bound to a package (mergepkg(), pkg(), <category>/<package>/…) is registered in the package's file list. You can check this with the regular Portage tools:
/etc/profile.d /etc/profile.d/editor.sh
sys-apps/baselayout-2.18-r1
sys-apps/openrc-0.63.3
Checking sys-apps/baselayout ... MTIME: /etc/mtab * 41 out of 42 files are good The last line is the overall ratio: which files end up in the mismatch list, and what the number will be, depends on which templates were merged on the system and what was changed by hand. Orient yourself by the list of paths, not by the number: they tell you where to look.
Note the output of equery b /etc/sysctl.conf: the file's belonging determines which package your template must be bound to - for /etc/sysctl.conf and files in /etc/sysctl.d it is sys-apps/openrc, not sys-apps/baselayout. The MTIME: /etc/mtab line is not counted as a mismatch: this file changes at system boot.
The good news: you do not need to "fool" the package manager - a correct template makes the file legal on its own. If qcheck reports a mismatch but the file was created by you, it appeared outside the package's control (for example, a "raw" template without mergepkg() while configuring the whole system) - fix the binding, do not repair checksums.
File protection and settings update
- protected - the file is not deleted when the package it belongs to is deleted. Use it for settings whose value outlives the package (for example, keys, caches, files created during installation).
- autoupdate - when the package is installed, a modified configuration file is transferred into the system at once; without it the change stays in "pending" and is applied through
dispatch-conf(cl-dispatch-conf), where you decide yourself what to accept. If the system already has a package file that you have modified, it will not be replaced silently - that is exactly whatdispatch-confis for. - force - delete an existing file before writing; enabled automatically together with symbolic.
- mirror - merge only if the configuration file already exists; if the target is set through link= and does not exist, the file is deleted. Convenient for templates that must "follow" a real file but not create it from scratch.
- chmod=, chown= - the rights and owner of the result; if not specified, the template's rights are used (or those of the original, if there was one).
When to delete or "clear"
- append=remove - deletes the file (for a directory - the directory with its contents). This is the regular way to remove what is no longer needed: a deleted template itself deletes nothing in the system.
- append=clear - zeroes the file (length 0); for a directory - deletes all its contents, keeping the directory itself.
There is no append=delete value; all deletion is described by these two methods together with remove/clear.
How to remove your template properly
Just deleting the file from /var/calculate/templates is not enough: the configuration file it created will stay in the system and will still be listed under the package. The order is:
- replace the template with a "deleting" one - append=remove with the same path=/name=, and apply the package configuration;
- delete the template itself;
- if the file belonged to a package, check its state:
equery f <package>, and reinstall the package if needed (emerge -1a <package>).
See also
- A template next to the file: .clt
- Template directories and storage layers
- Template syntax - protection and merging parameters.