2 * Copyright (c) 1992, Brian Berliner and Jeff Polk
3 * Copyright (c) 1989-1992, Brian Berliner
5 * You may distribute under the terms of the GNU General Public License as
6 * specified in the README file that comes with the CVS 1.4 kit.
8 * Create Administration.
10 * Creates a CVS administration directory based on the argument repository; the
11 * "Entries" file is prefilled from the "initrecord" argument.
16 /* update_dir includes dir as its last component. */
19 Create_Admin (dir, update_dir, repository, tag, date)
35 fprintf (stderr, "%c-> Create_Admin (%s, %s, %s, %s, %s) in %s\n",
36 (server_active) ? 'S' : ' ',
37 dir, update_dir, repository, tag ? tag : "",
38 date ? date : "", wd);
46 (void) sprintf (tmp, "%s/%s", dir, CVSADM);
48 (void) strcpy (tmp, CVSADM);
50 error (1, 0, "there is a version in %s already", update_dir);
54 /* record the current cvs root for later use */
56 Create_Root (dir, CVSroot);
58 (void) sprintf (tmp, "%s/%s", dir, CVSADM_REP);
60 (void) strcpy (tmp, CVSADM_REP);
61 fout = fopen (tmp, "w+");
64 if (update_dir[0] == '\0')
65 error (1, errno, "cannot open %s", tmp);
67 error (1, errno, "cannot open %s/%s", update_dir, CVSADM_REP);
74 * If the Repository file is to hold a relative path, try to strip off
75 * the leading CVSroot argument.
81 (void) sprintf (path, "%s/", CVSroot);
82 if (strncmp (repository, path, strlen (path)) == 0)
83 cp = repository + strlen (path);
87 if (fprintf (fout, "%s\n", cp) < 0)
89 if (update_dir[0] == '\0')
90 error (1, errno, "write to %s failed", tmp);
92 error (1, errno, "write to %s/%s failed", update_dir, CVSADM_REP);
94 if (fclose (fout) == EOF)
96 if (update_dir[0] == '\0')
97 error (1, errno, "cannot close %s", tmp);
99 error (1, errno, "cannot close %s/%s", update_dir, CVSADM_REP);
102 /* now, do the Entries file */
104 (void) sprintf (tmp, "%s/%s", dir, CVSADM_ENT);
106 (void) strcpy (tmp, CVSADM_ENT);
107 fout = fopen (tmp, "w+");
110 if (update_dir[0] == '\0')
111 error (1, errno, "cannot open %s", tmp);
113 error (1, errno, "cannot open %s/%s", update_dir, CVSADM_ENT);
115 if (fclose (fout) == EOF)
117 if (update_dir[0] == '\0')
118 error (1, errno, "cannot close %s", tmp);
120 error (1, errno, "cannot close %s/%s", update_dir, CVSADM_ENT);
123 /* Create a new CVS/Tag file */
124 WriteTag (dir, tag, date);
126 #ifdef SERVER_SUPPORT
129 server_set_sticky (update_dir, repository, tag, date);
130 server_template (update_dir, repository);
135 fprintf (stderr, "%c<- Create_Admin\n",
136 (server_active) ? 'S' : ' ');