Magellan Linux

Diff of /trunk/pkgtools/mage2mysql.sh

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 805 by niro, Wed Feb 11 16:15:58 2009 UTC revision 1331 by niro, Tue May 31 17:44:01 2011 UTC
# Line 12  SQL_USER=mage Line 12  SQL_USER=mage
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  {  {
# Line 35  create_database() Line 35  create_database()
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)
# Line 92  evaluate_magefile() Line 92  evaluate_magefile()
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})"
# Line 113  evaluate_magefile() Line 113  evaluate_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
# Line 135  evaluate_magefile() Line 137  evaluate_magefile()
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,
# Line 150  evaluate_magefile() Line 153  evaluate_magefile()
153   flag   flag
154   )   )
155   VALUES (   VALUES (
156     '${id}',
157   '${PNAME}',   '${PNAME}',
158   '${PVER}',   '${PVER}',
159   '${PBUILD}',   '${PBUILD}',
# Line 163  evaluate_magefile() Line 167  evaluate_magefile()
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    

Legend:
Removed from v.805  
changed lines
  Added in v.1331