IBM Support

About the ClearCase Magic file

Question & Answer


Question

Where do you find supplemental information for the IBM® Rational ClearCase (CC) documentation on the subject of the ClearCase Magic File on Microsoft® Windows, Linux® and UNIX?

Cause

More information will be required to get a better understanding of how CC Magic File works.

Answer

Review IBM Rational ClearCase Command Reference under the section titled, cc.magic,default.magic, or run cleartool man cc.magic from command line, for more information.

The purpose of the magic file is to have ClearCase 'type' the element correctly based on the contents of a given file. By 'type' we mean select a specific ClearCase Type Manager to manage the asset.



Below is an excerpt from a default.magic file:


    frame_document document file: -magic 0, "<MakerFile" ;


This line is interpreted as:

file-type-list: selection-expression

  • The first entry ("frame_document" and "document" in this example) can be any name that is chosen to describe the type or function of the file. Depending on the file type situation, each name on the list could match either an element type defined in a VOB or an icon name specified in an icon file.
  • The final name in the file-type-list, in this case "file", should always be a valid element type that exists in your VOBs.


Note:
The cleartool lstype -kind eltype -long command will list all the element types that are defined in a VOB.


Here is an example:


    %cleartool lstype -kind eltype -long
    element type "
    compressed_file"
    05-May-94.12:37:10 by USER (user.email)
    "Predefined element type used to represent a file in compressed format."
    type manager: z_whole_copy
    supertype: file
    meta-type of element: file element
    element type "
    compressed_text_file"
    05-May-94.12:37:10 by USER (user.email)
    "Predefined element type used to represent a text file in compressed format."
    type manager: z_text_file_delta
    supertype: text_file
    meta-type of element: file element
    element type "
    directory"
    05-May-94.12:37:10 by USER (user.email)
    "Predefined element type used to represent a directory."
    supertype: file_system_object
    meta-type of element: directory element
    element type "
    file"
    05-May-94.12:37:10 by USER (user.email)
    "Predefined element type used to represent a file."
    type manager: whole_copy
    supertype: file_system_object
    meta-type of element: file element
    element type "
    file_system_object"
    05-May-94.12:37:10 by USER (user.email)
    "Predefined element type used to represent a file system object."



SCENARIO 1: Adding a file to source control using the -eltype switch.

Example:


    %cleartool mkelem -eltype frame_document my_frame_doc

ClearCase will try to find the frame_document type in the VOBs list of types and will fail if this type has not been defined.

SCENARIO 2: Adding a file to source control without using the -eltype switch.


    %cleartool mkelem my_frame_doc

ClearCase will try to guess what type the file needs by using the default.magic file to perform the file typing.
  • If there is a local magic file in the default install directory for (/usr/atria/config/magic on UNIX or C:\Program Files\Rational\ClearCase\config\magic on Windows) ClearCase will search there first by default.
  • If the MAGIC_PATH variable is not set, the default search path is:

    $HOME/.magic:${ATRIAHOME:-/usr/atria}/config/magic

    On Windows, the path is: %clearcase_home%\config\magic
  • If MAGIC_PATH is set to a list of directories, ClearCase will search for files with a .magic suffix in these directories. It will not search the /usr/atria/config/magic/default.magic, it effectively overrides this file.

If an element type is not specified on the command line, mkelem tries to determine a type automatically by using "magic" files to perform file-typing. This involves a pattern-match on the new element's extension (and perhaps an examination of the file itself).

For the above selection of a Frame file, here is an excerpt from the magic file and an example of what will happen:

magic file:
-----------
frame_document document file: -magic 0, "<MakerFile" ;


1. No file type is listed with the mkelem so use selection-expression
2. Open the file and use "-magic 0, "<MakerFile" to determine the file type.
3. OK -- found "<MakerFile" in the files contents
4. OK -- use the first valid type that is found in the file-type-list. In this case "file".

Note: File is the only valid type in the VOB type list above.

PERSONAL MAGIC FILE: To use a personal magic file and have ClearCase type the file as one of your own defined types, without using '-eltype', perform the following:

EXAMPLE:

1a. Create a .magic directory in the user's home directory and create a file with .magic extension (UNIX only)


    % cd ~user

    % mkdir .magic

    % cd .magic

    % touch my.magic

    % ls
    my.magic



1b. Create a cc.magic file (in the same directory as the default.magic file) (WINDOWS only)



2. Create the element type in the VOB


    cleartool mkeltype -supertype compressed_file frame

    Comments for "frame"

    .

    Created element type "frame".



3. Edit the personal magic file adding the new line then stop and restart ClearCase

Example for Frame:


    # Check Magic Numbers
    frame_document document frame: -magic 0, "<MakerFile" ;


4. Use cleartool file to verify that the correct type is used when creating a new element of this type:

    %cleartool file template2.doc
    template2.doc: frame


5. Perform cleartool mkelem with the new type.

    %cleartool mkelem template2.doc
    Created element "template2.doc" (type "frame").
    Checked out "template2.doc" from version "/main/0".

Note: This element type must be defined in all VOBs that need to use it.


Caution: It is highly recommended that you not modify the default.magic file directly as the next time an upgrade is performed, a new default.magic file will be created and your changes will be lost. Creating a personal magic file with a name that is alphabetically before the "d" in the default.magic file name (such as cc.magic) will allow ClearCase to parse that file before the default. It is better to create a personal magic file and possibly setting the MAGIC_PATH variable instead.



[{"Product":{"code":"SSSH27","label":"Rational ClearCase"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Magic File","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"}],"Version":"7.1.2;8.0;8.0.1;9.0","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}},{"Product":{"code":"SSSH27","label":"Rational ClearCase"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Magic File","Platform":[{"code":"","label":""}],"Version":"","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

Modified date:
16 June 2018

UID

swg21122471