aboutsummaryrefslogtreecommitdiffstats
path: root/builddb_instructions.txt
blob: 7ad1c85dc0a8130bf07f4cd3f9078e69e1a96de4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
User Info
-------------------------------------------------------------------------------
USE mysql; 

CREATE USER 'root'@'192.168.1.10' identified BY 'password'; 

CREATE USER 'root'@'nucleus.berzerkula.org' identified BY 'password'; 

SELECT host, 
       USER, 
       password 
FROM   mysql.USER;

Grant Info
-------------------------------------------------------------------------------
SHOW grants FOR 'root'@'192.168.1.10'; 
GRANT SELECT, INSERT, UPDATE, DELETE ON a8_srv_build.* TO 'root'@'192.168.1.10' 
IDENTIFIED BY 'password'; 

GRANT SELECT, INSERT, UPDATE, DELETE ON a8_srv_build.* TO 'root'@ 
'nucleus.berzerkula.org' IDENTIFIED BY 'password'; 

SHOW grants FOR 'root'@'192.168.1.10';

==================
New Relational DB:
==================

Create database/tables (Include table/column comments here as required)
-------------------------------------------------------------------------------
CREATE DATABASE A8_srv_build;
USE A8_srv_build;

CREATE TABLE pkg
  (
     id      INT PRIMARY KEY NOT NULL auto_increment,
     seq     INT,
     name    VARCHAR(40),
     version VARCHAR(40)
  );

CREATE TABLE pkg_cfg
  (
     pkg_id    INT REFERENCES pkg (id),
     configure VARCHAR(2048)
  ); 

CREATE TABLE pkg_bld
  (
     pkg_id INT REFERENCES pkg (id),
     build  VARCHAR(2048)
  ); 

CREATE TABLE pkg_nst
  (
     pkg_id  INT REFERENCES pkg (id),
     install VARCHAR(2048)
  );

CREATE TABLE pkg_set
  (
     pkg_id INT REFERENCES pkg (id),
     setup  TEXT
  );
  
CREATE TABLE pkg_not
  (
     pkg_id INT REFERENCES pkg (id),
     notes  VARCHAR(2048)
  );

CREATE TABLE pkg_url
  (
     pkg_id INT REFERENCES pkg (id),
     url    VARCHAR(2048)
  );


======================
Comments for DB/Tables
======================

View comments:
-------------------------------------------------------------------------------
SELECT table_name,
       table_comment
FROM   information_schema.tables
WHERE  table_schema = 'A8_srv_build';

SELECT column_comment
FROM   information_schema.columns
WHERE  table_name = 'PKG';

SELECT column_comment
FROM   information_schema.columns
WHERE  table_name = 'PKG_CFG';

SELECT column_comment
FROM   information_schema.columns
WHERE  table_name = 'PKG_BLD';

SELECT column_comment
FROM   information_schema.columns
WHERE  table_name = 'PKG_NST';

SELECT column_comment
FROM   information_schema.columns
WHERE  table_name = 'PKG_SET';

SELECT column_comment
FROM   information_schema.columns
WHERE  table_name = 'PKG_NOT';

SELECT column_comment
FROM   information_schema.columns
WHERE  table_name = 'PKG_URL';

Alter comments (TABLES):
-------------------------------------------------------------------------------
ALTER TABLE pkg comment =
'Package ID (from jHALFS build order) with name and version';

ALTER TABLE pkg_bld comment = 'Build instructions';
ALTER TABLE pkg_cfg comment = 'Configure instructions';
ALTER TABLE pkg_not comment = 'Notes for package';
ALTER TABLE pkg_nst comment = 'Install instructions';
ALTER TABLE pkg_set comment = 'Setup instructions';
ALTER TABLE pkg_url comment = 'URLs for package';

Alter comments (COLUMNS):
-------------------------------------------------------------------------------
ALTER TABLE `pkg`
  CHANGE `id` `id` INT(11) NOT NULL auto_increment comment 'unique id';
ALTER TABLE `pkg`
  CHANGE `seq` `seq` INT(11) DEFAULT NULL comment 'sequence in build order';

ALTER TABLE `pkg`
  CHANGE `name` `name` VARCHAR(40) DEFAULT NULL comment 'name of package';

ALTER TABLE `pkg`
  CHANGE `version` `version` VARCHAR(40) DEFAULT NULL comment 'version number';

ALTER TABLE `pkg_cfg`
  CHANGE `pkg_id` `pkg_id` INT(11) DEFAULT NULL comment
  'unique id referenced in PKG';

ALTER TABLE `pkg_cfg`
  CHANGE `configure` `configure` VARCHAR(2048) DEFAULT NULL comment
  'configure commands';

ALTER TABLE `pkg_bld`
  CHANGE `pkg_id` `pkg_id` INT(11) DEFAULT NULL comment
  'unique id referenced in PKG';

ALTER TABLE `pkg_bld`
  CHANGE `build` `build` VARCHAR(2048) DEFAULT NULL comment 'build commands';

ALTER TABLE `pkg_nst`
  CHANGE `pkg_id` `pkg_id` INT(11) DEFAULT NULL comment
  'unique id referenced in PKG';

ALTER TABLE `pkg_nst`
  CHANGE `install` `install` VARCHAR(2048) DEFAULT NULL comment
  'install commands';

ALTER TABLE `pkg_set`
  CHANGE `pkg_id` `pkg_id` INT(11) DEFAULT NULL comment
  'unique id referenced in PKG';

ALTER TABLE `pkg_set`
  CHANGE `setup` `setup` TEXT DEFAULT NULL comment 'setup commands';

ALTER TABLE `pkg_not`
  CHANGE `pkg_id` `pkg_id` INT(11) DEFAULT NULL comment
  'unique id referenced in PKG';

ALTER TABLE `pkg_not`
  CHANGE `notes` `notes` VARCHAR(2048) DEFAULT NULL comment 'important notes';

ALTER TABLE `pkg_url`
  CHANGE `pkg_id` `pkg_id` INT(11) DEFAULT NULL comment
  'unique id referenced in PKG';

ALTER TABLE `pkg_url`
  CHANGE `url` `url` VARCHAR(2048) DEFAULT NULL comment 'urls for download';

====================================================
Load PKG table with data from csv (from spreadsheet)
====================================================
Load data in file:
-------------------------------------------------------------------------------
LOAD DATA INFILE '/home/kb0iic/new_server_build/PKG.csv' INTO TABLE PKG FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' (seq,name,version);

Populate id's into other tables' pkg_id's:
-------------------------------------------------------------------------------
INSERT INTO pkg_cfg
            (pkg_id,
             configure)
SELECT id,
       ""
FROM   pkg;

INSERT INTO pkg_bld
            (pkg_id,
             build)
SELECT id,
       ""
FROM   pkg;

INSERT INTO pkg_nst
            (pkg_id,
             install)
SELECT id,
       ""
FROM   pkg;

INSERT INTO pkg_set
            (pkg_id,
             setup)
SELECT id,
       ""
FROM   pkg;

INSERT INTO pkg_not
            (pkg_id,
             notes)
SELECT id,
       ""
FROM   pkg;

INSERT INTO pkg_url
            (pkg_id,
             url)
SELECT id,
       ""
FROM   pkg;

==============
Insert records
==============
Use transaction (with last insert ID):
-------------------------------------------------------------------------------
SET autocommit = 0;
START TRANSACTION;
INSERT INTO pkg
            (id,
             seq,
             name,
             version)
VALUES     (NULL,
            '999',
            'TEST',
            '1.2.3');

INSERT INTO pkg_cfg
            (pkg_id,
             configure)
VALUES     (Last_insert_id(),
            './configure --prefix=/usr');

INSERT INTO pkg_bld
            (pkg_id,
             build)
VALUES     (Last_insert_id(),
            'make');

INSERT INTO pkg_nst
            (pkg_id,
             install)
VALUES     (Last_insert_id(),
            'make -j1 install');

INSERT INTO pkg_set
            (pkg_id,
             setup)
VALUES     (Last_insert_id(),
            'cat blah > /tmp/test');

INSERT INTO pkg_not
            (pkg_id,
             notes)
VALUES     (Last_insert_id(),
            'May want to strip files');

INSERT INTO pkg_url
            (pkg_id,
             url)
VALUES     (Last_insert_id(),
            'http://url.to.pkg/pkg.tar.gz');

COMMIT; (or ROLLBACK; if mistake)

===================
Update package info
===================
Update all tables:
-------------------------------------------------------------------------------
UPDATE pkg,
       pkg_cfg,
       pkg_bld,
       pkg_nst,
       pkg_set,
       pkg_not,
       pkg_url
SET    pkg.seq = '999',
       pkg.name = 'TEST',
       pkg.version = '1.2.3',
       pkg_cfg.configure = './configure --prefix=/usr',
       pkg_bld.build = 'make',
       pkg_nst.install = 'make -j1 install',
       pkg_set.setup = 'cat blah > /tmp/test',
       pkg_not.notes = 'May want to strip files',
       pkg_url.url = 'http://url.to.pkg/pkg.tar.gz'
WHERE  pkg_cfg.pkg_id = pkg.id
       AND pkg_bld.pkg_id = pkg.id
       AND pkg_nst.pkg_id = pkg.id
       AND pkg_set.pkg_id = pkg.id
       AND pkg_not.pkg_id = pkg.id
       AND pkg_url.pkg_id = pkg.id
       AND pkg.name = 'TEST';
			 
=============
Delete Record
=============
Delete:
-------------------------------------------------------------------------------
DELETE pkg,
       pkg_cfg,
       pkg_bld,
       pkg_nst,
       pkg_set,
       pkg_not,
       pkg_url
FROM   pkg,
       pkg_cfg,
       pkg_bld,
       pkg_nst,
       pkg_set,
       pkg_not,
       pkg_url
WHERE  pkg_cfg.pkg_id = pkg.id
       AND pkg_bld.pkg_id = pkg.id
       AND pkg_nst.pkg_id = pkg.id
       AND pkg_set.pkg_id = pkg.id
       AND pkg_not.pkg_id = pkg.id
       AND pkg_url.pkg_id = pkg.id
       AND pkg.name = 'TEST';

=============
Select Record
=============
Select:
-------------------------------------------------------------------------------
SELECT id,
       seq,
       name,
       version,
       configure,
       build,
       install,
       setup,
       notes,
       url
FROM   pkg,
       pkg_cfg,
       pkg_bld,
       pkg_nst,
       pkg_set,
       pkg_not,
       pkg_url
WHERE  pkg_cfg.pkg_id = pkg.id
       AND pkg_bld.pkg_id = pkg.id
       AND pkg_nst.pkg_id = pkg.id
       AND pkg_set.pkg_id = pkg.id
       AND pkg_not.pkg_id = pkg.id
       AND pkg_url.pkg_id = pkg.id
ORDER  BY seq ASC