CVS experience talks

zhaozj2021-02-17  47

CVS experience talks

Author: Gong Tianyi

CVS is an abbreviation for the Concurrent Version System for version management. The role in multiplayer team is more obvious. The basic work idea of ​​CVS is this: Create a repository on one server, and many source processes of many different items can be stored in the warehouse. The source program is managed by the warehouse administrator. In this way, it seems that only one person is like a file. Avoid conflicts. Each user first uses the warehouse to download the project file in the warehouse to the local. Any modification of the user is first conducted locally, then submitted by the CVS command and is unified by the CVS warehouse administrator. This will do tracking file changes, conflict control, and more.

Since CVS is based on SCCS and RCS based on the original UNIX system, CVS is mostly used in the Linux system. The server-side settings in this article are also linux as an example.

First, the installation of the CVS server

First confirm that the system is installed in the system: [root @ localhost /] # rpm -qa | grep cvs CVS-1.11.2-cvSHome.7x.1 If the command output is similar to the above output, the system has been installed with CVS, otherwise You need to install the CVS RPM package from the installation CD, or download it at http://www.cvshome.org.

1. Establish CVSROOT

Directory, because here involves the permissions issues read and written on the file in CVSROOT, the relatively simple method is to create a group, then build a account belonging to the group, and the user who has read and write will belong to this group. Suppose we built a group called CVS, the username is CVSROOT. The order and user's order is as follows

#groupadd cvs #adduser cvsroot

The generated user host directory is in / home / cvsroot (adjusted according to your own system)

2, use cvsroot users to log in, modify the permissions of / home / cvsroot (cvsroot), and pay the authority with the same group:

$ chmod 771. (or 770 should also)

Note: This part of the work is done according to the documentation, there must be no trial, I will do it in the later version of the tutorial after doing the test. If you have this experience, please give me, thank you.

3. Create a CVS warehouse (still a cvsroot user), with the following command:

$ cvs -d / home / cvsroot init

4. Log in as root, modify /etc/inetd.conf (using Xinetd's system without this file) and / etc / service

If you use inetd, add: Cvsserver Stream TCP NOWAIT ROOT / USR / BIN / CVS CVS -F - Allow-root = / Home / CVSROOT PSERVER

Note: The above line is a single line, / usr / bin / cvs should be your CVS version of the command path, please adjust according to your system. / Home / CVSROOT is the path to the cvsroot you created, and also adjust it according to the contents of the part of the directory above.

If you are using Xinetd's system, you need to create file CVSPSERVER in /etc/xinetd.d/ directory (this name can be defined by yourself), the content is as follows: # Default: on # Description: The CVS Server sessions;

Service cvsserver {socket_type = stream wait = no user = root server = / usr / bin / cvs server_args = -f --allow-root = / cvsroot pserver log_on_failure = userid online = 192.168.0.0/24}

The only_from is used to restrict access, and can be not or modified according to the actual situation. Modify this file permission:

# chmod 644 CVSPSERVER

Join / etc / services:

Cvsserver 2401 / TCP

Note: CVSServer is any name, but cannot be reinable with the existing service, but also to modify the first item of /etc/inetd.conf above.

5, add users who can use CVS to CVS group:

Modify / etc / group as root, add the username of CVS to the CVS group, such as what I want to let the user Laser and Gumpwu can use the CVS service, then the / etc / group after the modification should have the following line:

CVS: x: 105: Laser, gumpwu

GID on your system may not be 105, there is no relationship. Mainly to separate the Laser and Gumpwu to the last colon with a comma. Of course, like the distribution of the RedHat has tools like LinuxConf, do this will be simpler.

6, restart inetd to take effect:

#killall -hup inetd

If you are using Xinetd's system: # /etc/rc.d/init.d/xined restart

Then look at whether the CVS server has been running: [root @ localhost /] # netstat -lnp | grep 2401 TCP 0 0 0.0.0.0:2401 0.0.0.0.0:0:2401 0.0.0.0:0:0:2401 0.0.0.0:0:0:241 / xinetd The CVS server has run.

Second, manage CVS servers

The server can be used, and now everyone is most concerned how to manage the server, for example, I want some people to read and / or write the permissions of the CVS warehouse, but don't want to give it system permissions?

It is not difficult, there is a cvsroot directory in the cvs administrator user (in the cvsroot user), this directory has three profiles, passwd, readers, Writers, we can configure CVS by setting these three files. The server, the following is the role of these files, respectively:

Passwd: CVS user user list file, its format is very like shadow file:

{CVS User Name}: [Encrypted Password]: [Equivalent System User Name]

If you want a user just a CVS user, not a system user, then you have to set this file, then this file may not exist after you have installed, you need to create a CVS administrator user, of course, according to the format, second The field is the user's encryption password, which is encrypted with Crypt (3). You can write a program to do encryption, you can also use the lazy way I introduced: first create a system user, name, and CVS users. The password is ready to give it a CVS user password. After creation, copy the second field from / etc / shadow to the second field, and then remove this user. This method is more convenient to deal with fewer users, and people are not suitable, and there are also safety hazards of conflict conditions, and Root privileges, it is not good. However, the equivalent is. Write a small program is not difficult, you can search for the LinuxForum programming version, have a friend has written a post above. The third field is an equivalent system username. In fact, it is to assign an equivalent system user with a CVS user. Look at the following example you understand its function.

Readers: A user list file with CVS read rights. It is a one-dimensional list. Users in this file have only read permissions for CVS.

Writers: a list of users with CVS write permissions. Like readers, it is a one-dimensional list. Users in this file have write access to CVS.

The above three files may not exist when the default installation, you need to create it yourself, ok, now let us use an example to teach. Suppose we have the following users to use CVS:

Laser, gumpwu, henry, betty, anonymous.

Where Laser and Gumpwu are system users, and Henry, Betty, Anonymous we don't want to give system user privileges, and Betty and Anonymous are read-only users, and Anonymous is even more than. So well, let's do some ready to work, first create a CVSPUB user, this user's responsibility is to read and write CVS warehouses on behalf of all non-system users.

#adduser ...

Then edit the / etc / group, let CVSPUB users in the CVS group, while adding other users with system user privileges to the CVS group. (See above)

Then edit the cvsroot / passwd file in the CVS Administrator's Catalog, add the following line:

Laser: $ xxefajfka; faffa33: CVSPUB GUMPU: $ AJFAAL; 323R0OFeeanv: CVSPUB HENRY: $ FAJKDPAIEJE: CVSPUB BETTY: FJKAL; FFjieInfn /: CVSPUB Anonymous :: CVSPUB

Note: The second field above (separator is :) is a secret text password, you want to use the program or use my dirt.

Edit the readers file, add the following line:

Anonymous Betty

Edit the Writers file, add the following line:

Laser gumpwu henry

Note: Users in Writers cannot be in Readers, or they cannot upload update files.

For users who use CVS to modify its environment variables, such as Laser users' environment variables, open the .bash_profile file under / home / laser (Laser's host directory), join cvsroot = / home / cvsroot evter cvsroot

You can create a CVS project with a Laser. If you want root to use, you can modify the / etc / profile file.

Now we have set it well, so how to use it, I have written a simplest (estimate is also the most common) command introduction:

First, establish a new CVS project, usually there are some project files, so we can generate a new CVS project with the following steps:

Enter your existing project directory, such as CVSTest: $ cd cvstest running command: $ cvs import -m "this is a cvstest project" cvstest v_0_0_1 start Description: IMPORT is one of the commands of CVS, indicating input to CVS warehouse project files. The string behind the -m parameter is a description text, and write some meaningful things. If you do not add -M parameters, then CVS will automatically run an editor (generally VI, but can change to you by modifying environment variable editor) I like to use the editor.) Let you enter information, cvstest is the project name (actually a warehouse name, which is stored in the warehouse named after this name.) V_0_0_1 is the total mark of this branch. Nothing is used (or is not common.) Start is a tag of the input level of the import logo file, no use. This way we have built a CVS warehouse.

The folder for establishing a CVS warehouse should be "clean" folder, that is, only the source code file and the documentation described, and should not include the compiled file code, etc.!

Third, use CVS

WinCVS is a good CVS client software, in http://cnpack.cosoft.org.cn/down/wincvsdailyGuide.pdf can download the user's usage manual. It is not described here.

Fourth, use the CVS management project

I am working on the company's ERP project. When I didn't use CVS, I have repeatedly modified the same procedure due to different developers, and the program is imminent.

Since this project uses the Java development under the Linux platform, the development tool JBulider is supported by the project management. As the main programmer, I decided to use CVS to make version control, first refer to the above, I have established CVS service on the Linux server, then I pass my local project file to the server.

For example: My project files Under F: / ERP, I uploaded the ERP.jpx file, the Default folder, and the src folder to the server / usr / local / erp, then log in to the Linux server, the user who logs in CVS users, their environment variables are correct (my username admin) #CD / usr / local / erp #cvs import -m "this is a a aired process" ERP V_0_0_1 Start "ERP V_0_0_1 START

Such a CVS warehouse called ERP is established.

The member of the development team can then be downloaded to the location with WinCVS:

Open WinCVS Click Toolbar Create -> CREATE A New Repository ... pop-up window In Grenral Enter the cvsroot fills in admin@192.168.1.9: / home / cvsroot where admin is the user of CVS, in this example is also Linux system User, 192.168.1.9 is the address of the server, / Home / CVSROOT is the main directory of CVS, refer to above. Select CVS 1.10 (Standard) in the "Passwd File on the CVS Server" User Version.

After confirming, point toolbar admin -> login ... will prompt the password, enter the password, look at the status bar of WinCVS. If prompt

***** CVS EXITED NORMALLY with CODE 0 *****

Indicates that login is normal.

Click Tools Create -> Checkout Module ... Pop-up dialog, where Enter the module name and path on the server fills in ERP, that is, our CVS Warehouse, which is the ERP, Local Folder to Checkout to Choose To download the local directory, I chose F: / myerp.

Other projects can be default, they can be downloaded locally, and there is an ERP folder in f: / myerp /, the file structure and F: / ERP are the same.

Use JBulider to open the ERP.JPX file under the F: / MyERP / ERP / under this project file.

In JBuilder's toolbar Team -> Select Project VCS pop-up dialog, select CVS

For the file you want to modify, in the middle of the Project View, click Right Key, Explore the shortcut menu, select CVS -> CVS Edit "xxxx.java (file name)"

The first use may prompt the CVS server password.

Select CVS -> Update "xxxx.java" before modifying

After modification, select CVS -> Commit "xxxx.java (file name)"

In this way, the modified file is saved to the CVS server, and the purpose of Update is to download, compare the file. Keep the latest version every time you modify it.

CVS actually has a good effect in project management, and carefully studys the CVS command, which can better play the ability of CVS on version control.

My QQ is 20896, welcome everyone to exchange, or discuss it on my forum http://www.laoer.com

Reference: "CVS Simple Guide" Author: He Weiping, "CVS Server Quick Guide" Author: He Weiping

转载请注明原文地址:https://www.9cbs.com/read-29608.html

New Post(0)