Magellan Linux

Diff of /branches/mage-sql/usr/lib/mage/join-repos.sh

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

revision 1118 by niro, Sat Jul 17 10:49:21 2010 UTC revision 1119 by niro, Thu Jul 22 07:22:24 2010 UTC
# Line 57  fi Line 57  fi
57    
58  # first of all create all sufficient tables  # first of all create all sufficient tables
59  SQLQUERY="create table categories(id integer primary key, pcat text unique);"  SQLQUERY="create table categories(id integer primary key, pcat text unique);"
60  SQLQUERY+="create table packages(id integer primary key,pname text,pver text,pbuild text,pcat_id numeric,state text,provide text,pkgtype text);"  SQLQUERY+="create table packages(id integer primary key,pname text,pver text,pbuild text,pcat_id numeric,state text,provide text,pkgtype text,repo_id numeric);"
61  SQLQUERY+="create table packages_info(id integer primary key, pkg_id numeric, arch text, md5 text, mtime numeric, homepage text, description text, size numeric);"  SQLQUERY+="create table packages_info(id integer primary key, pkg_id numeric, arch text, md5 text, mtime numeric, homepage text, description text, size numeric);"
62  SQLQUERY+="create table depends(id integer primary key, pkg_id numeric, relation text, pcat_id numeric, pname text, pver text, pbuild text);"  SQLQUERY+="create table depends(id integer primary key, pkg_id numeric, relation text, pcat_id numeric, pname text, pver text, pbuild text);"
63  SQLQUERY+="create table sdepends(id integer primary key, pkg_id numeric, relation text, pcat_id numeric, pname text, pver text, pbuild text);"  SQLQUERY+="create table sdepends(id integer primary key, pkg_id numeric, relation text, pcat_id numeric, pname text, pver text, pbuild text);"
# Line 66  SQLQUERY+="create table virtual_defaults Line 66  SQLQUERY+="create table virtual_defaults
66  sql "${SQLQUERY}"  sql "${SQLQUERY}"
67    
68  # add table with all loaded repos  # add table with all loaded repos
69  SQLQUERY="create table repositories(id integer primary key, repository text);"  SQLQUERY="create table repositories(id integer primary key, name text);"
70  for db in ${REPOS}  for db in ${REPOS}
71  do  do
72   SQLQUERY+="insert into ${MAIN}.repositories(repository) values('${db}');"   SQLQUERY+="insert into ${MAIN}.repositories(name) values('${db}');"
73  done  done
74  sql "${SQLQUERY}"  sql "${SQLQUERY}"
75    
# Line 131  do Line 131  do
131   SQLQUERY+="attach database '${db}.${DBSUFFIX}' as ${db};"   SQLQUERY+="attach database '${db}.${DBSUFFIX}' as ${db};"
132    
133   # transitional copy of packages with corrected pcat_ids from main database   # transitional copy of packages with corrected pcat_ids from main database
134   SQLQUERY+="insert into ${MAIN}.packages(pname,pver,pbuild,pcat_id,state,provide,pkgtype)   SQLQUERY+="insert into ${MAIN}.packages(pname,pver,pbuild,pcat_id,state,provide,pkgtype,repo_id)
135   select ${db}.packages.pname,   select ${db}.packages.pname,
136   ${db}.packages.pver,   ${db}.packages.pver,
137   ${db}.packages.pbuild,   ${db}.packages.pbuild,
138   ${MAIN}.categories.id,   ${MAIN}.categories.id,
139   ${db}.packages.state,   ${db}.packages.state,
140   ${db}.packages.provide,   ${db}.packages.provide,
141   ${db}.packages.pkgtype   ${db}.packages.pkgtype,
142     ${MAIN}.repositories.id
143   from ${db}.packages   from ${db}.packages
144   inner join ${db}.categories   inner join ${db}.categories
145   on ${db}.categories.id=${db}.packages.pcat_id   on ${db}.categories.id=${db}.packages.pcat_id
146   inner join ${MAIN}.categories   inner join ${MAIN}.categories
147   on ${MAIN}.categories.pcat=${db}.categories.pcat;"   on ${MAIN}.categories.pcat=${db}.categories.pcat
148     inner join ${MAIN}.repositories
149     on ${MAIN}.repositories.name='${db}';"
150   # detach database   # detach database
151   SQLQUERY+="detach database ${db};"   SQLQUERY+="detach database ${db};"
152  done  done

Legend:
Removed from v.1118  
changed lines
  Added in v.1119