12 |
SQL_PASS=mage |
SQL_PASS=mage |
13 |
SQL_HOST=localhost |
SQL_HOST=localhost |
14 |
SQL_DB=mage |
SQL_DB=mage |
15 |
SQL_TABLE_PACKAGES=packages |
SQL_TABLE_PACKAGES=mg_packages |
16 |
SQL_TABLE_CATEGORIES=categories |
SQL_TABLE_CATEGORIES=mg_categories |
17 |
|
|
18 |
create_database() |
create_database() |
19 |
{ |
{ |
35 |
description text default NULL, |
description text default NULL, |
36 |
homepage varchar(255) default NULL, |
homepage varchar(255) default NULL, |
37 |
pkgtype varchar(255) default NULL, |
pkgtype varchar(255) default NULL, |
38 |
depend varchar(255) default NULL, |
depend text default NULL, |
39 |
sdepend varchar(255) default NULL, |
sdepend text default NULL, |
40 |
provide varchar(255) default NULL, |
provide text default NULL, |
41 |
time datetime NOT NULL, |
time datetime NOT NULL, |
42 |
flag int(1) NOT NULL default '1', |
flag int(1) NOT NULL default '1', |
43 |
PRIMARY KEY (id) |
PRIMARY KEY (id) |
92 |
|
|
93 |
# the description may contain some escape characters like ' and " |
# the description may contain some escape characters like ' and " |
94 |
# which break the above loop |
# which break the above loop |
95 |
DESCRIPTION="$(get_value_from_magefile DESCRIPTION ${MAGEFILE})" |
DESCRIPTION="$(get_value_from_magefile DESCRIPTION ${MAGEFILE} | sed "s:':\\\':g")" |
96 |
|
|
97 |
# get var from the name of the magefile |
# get var from the name of the magefile |
98 |
PCAT="$(magename2pcat ${MAGEFILE})" |
PCAT="$(magename2pcat ${MAGEFILE})" |
113 |
# get current time |
# get current time |
114 |
local time="$(date +%F\ %T)" |
local time="$(date +%F\ %T)" |
115 |
|
|
116 |
|
#get last primary key !!! |
117 |
|
|
118 |
# found, then update |
# found, then update |
119 |
if [[ ! -z ${id} ]] |
if [[ ! -z ${id} ]] |
120 |
then |
then |
137 |
else |
else |
138 |
# else import to database as new |
# else import to database as new |
139 |
mysqldo "INSERT INTO ${SQL_TABLE_PACKAGES} ( |
mysqldo "INSERT INTO ${SQL_TABLE_PACKAGES} ( |
140 |
|
id, |
141 |
pname, |
pname, |
142 |
pver, |
pver, |
143 |
pbuild, |
pbuild, |
153 |
flag |
flag |
154 |
) |
) |
155 |
VALUES ( |
VALUES ( |
156 |
|
'${id}', |
157 |
'${PNAME}', |
'${PNAME}', |
158 |
'${PVER}', |
'${PVER}', |
159 |
'${PBUILD}', |
'${PBUILD}', |
167 |
'${PROVIDE}', |
'${PROVIDE}', |
168 |
'${time}', |
'${time}', |
169 |
'1' |
'1' |
170 |
)" |
) ON DUPLICATE KEY UPDATE ${SQL_TABLE_PACKAGES} SET |
171 |
|
pname='${PNAME}', |
172 |
|
pver='${PVER}', |
173 |
|
pbuild='${PBUILD}', |
174 |
|
pcat='${pcatid}', |
175 |
|
state='${STATE}', |
176 |
|
description='${DESCRIPTION}', |
177 |
|
homepage='${HOMEPAGE}', |
178 |
|
pkgtype='${PKGTYPE}', |
179 |
|
depend='${DEPEND}', |
180 |
|
sdepend='${SDEPEND}', |
181 |
|
provide='${PROVIDE}', |
182 |
|
time='${time}', |
183 |
|
flag='1' |
184 |
|
WHERE id='${id}'" |
185 |
fi |
fi |
186 |
} |
} |
187 |
|
|