From: Mark Hymers Date: Tue, 26 Jul 2011 20:25:24 +0000 (+0100) Subject: Add some core table setup X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=890acc3c99565cfa61f24c75c49db4eeacc71fbb;p=dak.git Add some core table setup Signed-off-by: Mark Hymers --- diff --git a/setup/README b/setup/README index ccc26cf7..82ead70f 100644 --- a/setup/README +++ b/setup/README @@ -16,27 +16,35 @@ The following roles are assumed to exist: For the purposes of this document, we'll be working in /srv/dak Set up the dak user on both the system and in postgres: -sudo adduser dak -sudo addgroup ftpmaster -sudo addgroup dak ftpmaster -sudo -u postgres createuser -s dak +# sudo adduser dak +# sudo addgroup ftpmaster +# sudo addgroup dak ftpmaster +# sudo -u postgres createuser -s dak Set up the dak directory: -sudo mkdir /srv/dak -sudo chown dak:ftpmaster /srv/dak -sudo chmod 2775 /srv/dak +# sudo mkdir /srv/dak +# sudo chown dak:ftpmaster /srv/dak +# sudo chmod 2775 /srv/dak Become the dak user: -sudo -u dak -s -H +# sudo -u dak -s -H Create the additional roles: -createuser -S -R -D ftpmaster -createuser -S -R -D ftpteam -createuser -S -R -D ftptrainee +# createuser -S -R -D ftpmaster +# createuser -S -R -D ftpteam +# createuser -S -R -D ftptrainee Create an empty database with SQL_ASCII encoding: -createdb -T template0 -E SQL_ASCII -O dak projectb +# createdb -T template0 -E SQL_ASCII -O dak projectb Import the schema: -psql -f current_schema.sql -d projectb +# psql -f current_schema.sql -d projectb + +Set up some core data in projectb to get started (read the init_vars file if +you wish to customise various aspects): +# ./init_core + +Add some architectures you care about: +# dak admin architecture add i386 "Intel x86 port" +# dak admin architecture add amd64 "AMD64 port" diff --git a/setup/core-init.d/005_components b/setup/core-init.d/005_components new file mode 100755 index 00000000..d45ef868 --- /dev/null +++ b/setup/core-init.d/005_components @@ -0,0 +1,15 @@ +#!/bin/sh + +set -e +set -u + +echo "Creating components" + +psql -c "INSERT INTO component (name, description, meets_dfsg) + VALUES ('main', 'Main', TRUE)" >/dev/null + +psql -c "INSERT INTO component (name, description, meets_dfsg) + VALUES ('contrib', 'Contrib', TRUE)" >/dev/null + +psql -c "INSERT INTO component (name, description, meets_dfsg) + VALUES ('non-free', 'Software that fails to meet the DFSG', FALSE)" >/dev/null diff --git a/setup/core-init.d/010_queues b/setup/core-init.d/010_queues new file mode 100755 index 00000000..c00e13b9 --- /dev/null +++ b/setup/core-init.d/010_queues @@ -0,0 +1,28 @@ +#!/bin/sh + +set -e +set -u + +echo "Creating core queues" + +QUEUEBASE="${DAKBASE}/queue" + +psql -c "INSERT INTO policy_queue (queue_name, path, perms, change_perms, + generate_metadata, stay_of_execution, send_to_build_queues) + VALUES ('unchecked', '${QUEUEBASE}/unchecked', '0660', '0660', + FALSE, 86400, FALSE)" >/dev/null + +psql -c "INSERT INTO policy_queue (queue_name, path, perms, change_perms, + generate_metadata, stay_of_execution, send_to_build_queues) + VALUES ('new', '${QUEUEBASE}/new', '0660', '0660', + FALSE, 86400, FALSE)" >/dev/null + +psql -c "INSERT INTO policy_queue (queue_name, path, perms, change_perms, + generate_metadata, stay_of_execution, send_to_build_queues) + VALUES ('newstage', '${QUEUEBASE}/newstage', '0660', '0660', + FALSE, 86400, FALSE)" >/dev/null + +psql -c "INSERT INTO policy_queue (queue_name, path, perms, change_perms, + generate_metadata, stay_of_execution, send_to_build_queues) + VALUES ('byhand', '${QUEUEBASE}/byhand', '0660', '0660', + FALSE, 86400, FALSE)" >/dev/null diff --git a/setup/core-init.d/020_sections b/setup/core-init.d/020_sections new file mode 100755 index 00000000..b4c265fe --- /dev/null +++ b/setup/core-init.d/020_sections @@ -0,0 +1,66 @@ +#!/bin/sh + +echo "Creating default sections" + +set -e +set -u + +SECTIONS="admin +cli-mono +comm +database +debian-installer +debug +devel +doc +editors +electronics +embedded +fonts +games +gnome +gnu-r +gnustep +graphics +hamradio +haskell +httpd +interpreters +java +kde +kernel +libdevel +libs +lisp +localization +mail +math +misc +net +news +ocaml +oldlibs +otherosfs +perl +php +python +ruby +science +shells +sound +tasks +tex +text +utils +vcs +video +web +x11 +xfce +zope" + +for prefix in "" "contrib/" "non-free/"; do + for section in ${SECTIONS}; do + psql -c "INSERT INTO section (section) VALUES ('$prefix$section')" >/dev/null + done +done diff --git a/setup/core-init.d/025_priorities b/setup/core-init.d/025_priorities new file mode 100755 index 00000000..d49bb170 --- /dev/null +++ b/setup/core-init.d/025_priorities @@ -0,0 +1,14 @@ +#!/bin/sh + +echo "Creating default priorities" + +set -e +set -u + +psql -c "INSERT INTO priority (priority, level) VALUES ('required', 1)" >/dev/null +psql -c "INSERT INTO priority (priority, level) VALUES ('important', 2)" >/dev/null +psql -c "INSERT INTO priority (priority, level) VALUES ('standard', 3)" >/dev/null +psql -c "INSERT INTO priority (priority, level) VALUES ('optional', 4)" >/dev/null +psql -c "INSERT INTO priority (priority, level) VALUES ('extra', 5)" >/dev/null +psql -c "INSERT INTO priority (priority, level) VALUES ('source', 0)" >/dev/null + diff --git a/setup/core-init.d/030_corearch b/setup/core-init.d/030_corearch new file mode 100755 index 00000000..6f19e103 --- /dev/null +++ b/setup/core-init.d/030_corearch @@ -0,0 +1,13 @@ +#!/bin/sh + +set -e +set -u + +echo "Setting up source and all architectures" + +psql -c "INSERT INTO architecture (arch_string, description) + VALUES ('source', 'Source')" >/dev/null + +psql -c "INSERT INTO architecture (arch_string, description) + VALUES ('all', 'Architecture Independent')" >/dev/null + diff --git a/setup/core-init.d/040_keyrings b/setup/core-init.d/040_keyrings new file mode 100755 index 00000000..77065ef0 --- /dev/null +++ b/setup/core-init.d/040_keyrings @@ -0,0 +1,18 @@ +#!/bin/sh + +set -e +set -u + +echo "Setting up default keyrings" + +psql -c "INSERT INTO binary_acl (access_level) VALUES ('full')" >/dev/null +psql -c "INSERT INTO binary_acl (access_level) VALUES ('map')" >/dev/null + +psql -c "INSERT INTO source_acl (access_level) VALUES ('full')" >/dev/null +psql -c "INSERT INTO source_acl (access_level) VALUES ('dm')" >/dev/null + +psql -c "INSERT INTO keyrings (name, default_source_acl_id, default_binary_acl_id) + VALUES ('${DAKBASE}/keyrings/upload-keyring.gpg', + (SELECT id FROM binary_acl WHERE access_level = 'full'), + (SELECT id FROM source_acl WHERE access_level = 'full'))" >/dev/null + diff --git a/setup/core-init.d/050_overridetype b/setup/core-init.d/050_overridetype new file mode 100755 index 00000000..fc8ad166 --- /dev/null +++ b/setup/core-init.d/050_overridetype @@ -0,0 +1,11 @@ +#!/bin/sh + +set -e +set -u + +echo "Creating override types" + +psql -c "INSERT INTO override_type (type) VALUES ('deb')" >/dev/null +psql -c "INSERT INTO override_type (type) VALUES ('udeb')" >/dev/null +psql -c "INSERT INTO override_type (type) VALUES ('dsc')" >/dev/null + diff --git a/setup/core-init.d/060_archive b/setup/core-init.d/060_archive new file mode 100755 index 00000000..29383442 --- /dev/null +++ b/setup/core-init.d/060_archive @@ -0,0 +1,17 @@ +#!/bin/sh + +set -e +set -u + +POOLPATH="${DAKBASE}/ftp/pool" + +echo "Setting up archive and locations" +psql -c "INSERT INTO archive (name, origin_server, description) + VALUES ('${DAKHOST}', '${DAKFQDN}', 'Master server')" >/dev/null + +for component in main contrib non-free; do + psql -c "INSERT INTO location (path, type, component, archive) + VALUES ('${POOLPATH}', 'pool', + (SELECT id FROM component WHERE name = '${component}'), + (SELECT id FROM archive WHERE name = '${DAKHOST}'))" >/dev/null +done diff --git a/setup/core-init.d/070_srcformats b/setup/core-init.d/070_srcformats new file mode 100755 index 00000000..59c4394a --- /dev/null +++ b/setup/core-init.d/070_srcformats @@ -0,0 +1,10 @@ +#!/bin/sh + +set -e +set -u + +echo "Setting up source formats" + +psql -c "INSERT INTO src_format (format_name) VALUES ('1.0')" >/dev/null +psql -c "INSERT INTO src_format (format_name) VALUES ('3.0 (quilt)')" >/dev/null +psql -c "INSERT INTO src_format (format_name) VALUES ('3.0 (native)')" >/dev/null diff --git a/setup/core-init.d/080_metadatakeys b/setup/core-init.d/080_metadatakeys new file mode 100755 index 00000000..482b12e9 --- /dev/null +++ b/setup/core-init.d/080_metadatakeys @@ -0,0 +1,54 @@ +#!/bin/sh + +set -e +set -u + +echo "Setting up metadata key ordering" + +psql -c "INSERT INTO metadata_keys (key, ordering) VALUES ('Package', -2600)" >/dev/null +psql -c "INSERT INTO metadata_keys (key, ordering) VALUES ('Source', -2500)" >/dev/null +psql -c "INSERT INTO metadata_keys (key, ordering) VALUES ('Binary', -2400)" >/dev/null +psql -c "INSERT INTO metadata_keys (key, ordering) VALUES ('Version', -2300)" >/dev/null +psql -c "INSERT INTO metadata_keys (key, ordering) VALUES ('Essential', -2250)" >/dev/null +psql -c "INSERT INTO metadata_keys (key, ordering) VALUES ('Installed-Size', -2200)" >/dev/null +psql -c "INSERT INTO metadata_keys (key, ordering) VALUES ('Maintainer', -2100)" >/dev/null +psql -c "INSERT INTO metadata_keys (key, ordering) VALUES ('Uploaders', -2090)" >/dev/null +psql -c "INSERT INTO metadata_keys (key, ordering) VALUES ('Original-Maintainer', -2080)" >/dev/null +psql -c "INSERT INTO metadata_keys (key, ordering) VALUES ('Build-Depends', -2000)" >/dev/null +psql -c "INSERT INTO metadata_keys (key, ordering) VALUES ('Build-Depends-Indep', -1990)" >/dev/null +psql -c "INSERT INTO metadata_keys (key, ordering) VALUES ('Build-Conflicts', -1980)" >/dev/null +psql -c "INSERT INTO metadata_keys (key, ordering) VALUES ('Build-Conflicts-Indep', -1970)" >/dev/null +psql -c "INSERT INTO metadata_keys (key, ordering) VALUES ('Architecture', -1800)" >/dev/null +psql -c "INSERT INTO metadata_keys (key, ordering) VALUES ('Standards-Version', -1700)" >/dev/null +psql -c "INSERT INTO metadata_keys (key, ordering) VALUES ('Format', -1600)" >/dev/null +psql -c "INSERT INTO metadata_keys (key, ordering) VALUES ('Files', -1500)" >/dev/null +psql -c "INSERT INTO metadata_keys (key, ordering) VALUES ('Dm-Upload-Allowed', -1400)" >/dev/null +psql -c "INSERT INTO metadata_keys (key, ordering) VALUES ('Vcs-Browse', -1300)" >/dev/null +psql -c "INSERT INTO metadata_keys (key, ordering) VALUES ('Vcs-Hg', -1300)" >/dev/null +psql -c "INSERT INTO metadata_keys (key, ordering) VALUES ('Vcs-Darcs', -1300)" >/dev/null +psql -c "INSERT INTO metadata_keys (key, ordering) VALUES ('Vcs-Svn', -1300)" >/dev/null +psql -c "INSERT INTO metadata_keys (key, ordering) VALUES ('Vcs-Git', -1300)" >/dev/null +psql -c "INSERT INTO metadata_keys (key, ordering) VALUES ('Vcs-Browser', -1300)" >/dev/null +psql -c "INSERT INTO metadata_keys (key, ordering) VALUES ('Vcs-Arch', -1300)" >/dev/null +psql -c "INSERT INTO metadata_keys (key, ordering) VALUES ('Vcs-Bzr', -1300)" >/dev/null +psql -c "INSERT INTO metadata_keys (key, ordering) VALUES ('Vcs-Mtn', -1300)" >/dev/null +psql -c "INSERT INTO metadata_keys (key, ordering) VALUES ('Vcs-Cvs', -1300)" >/dev/null +psql -c "INSERT INTO metadata_keys (key, ordering) VALUES ('Checksums-Sha256', -1200)" >/dev/null +psql -c "INSERT INTO metadata_keys (key, ordering) VALUES ('Checksums-Sha1', -1200)" >/dev/null +psql -c "INSERT INTO metadata_keys (key, ordering) VALUES ('Replaces', -1100)" >/dev/null +psql -c "INSERT INTO metadata_keys (key, ordering) VALUES ('Provides', -1000)" >/dev/null +psql -c "INSERT INTO metadata_keys (key, ordering) VALUES ('Depends', -900)" >/dev/null +psql -c "INSERT INTO metadata_keys (key, ordering) VALUES ('Pre-Depends', -850)" >/dev/null +psql -c "INSERT INTO metadata_keys (key, ordering) VALUES ('Recommends', -800)" >/dev/null +psql -c "INSERT INTO metadata_keys (key, ordering) VALUES ('Suggests', -700)" >/dev/null +psql -c "INSERT INTO metadata_keys (key, ordering) VALUES ('Enhances', -650)" >/dev/null +psql -c "INSERT INTO metadata_keys (key, ordering) VALUES ('Conflicts', -600)" >/dev/null +psql -c "INSERT INTO metadata_keys (key, ordering) VALUES ('Breaks', -500)" >/dev/null +psql -c "INSERT INTO metadata_keys (key, ordering) VALUES ('Description', -400)" >/dev/null +psql -c "INSERT INTO metadata_keys (key, ordering) VALUES ('Origin', -300)" >/dev/null +psql -c "INSERT INTO metadata_keys (key, ordering) VALUES ('Bugs', -200)" >/dev/null +psql -c "INSERT INTO metadata_keys (key, ordering) VALUES ('Multi-Arch', -150)" >/dev/null +psql -c "INSERT INTO metadata_keys (key, ordering) VALUES ('Homepage', -100)" >/dev/null +psql -c "INSERT INTO metadata_keys (key, ordering) VALUES ('Tag', 300)" >/dev/null +psql -c "INSERT INTO metadata_keys (key, ordering) VALUES ('Package-Type', 400)" >/dev/null +psql -c "INSERT INTO metadata_keys (key, ordering) VALUES ('Installer-Menu-Item', 500)" >/dev/null diff --git a/setup/init_core b/setup/init_core new file mode 100644 index 00000000..dd6c0756 --- /dev/null +++ b/setup/init_core @@ -0,0 +1,5 @@ +#!/bin/sh + +. init_vars + +run-parts --exit-on-error core-init.d/ diff --git a/setup/init_vars b/setup/init_vars new file mode 100644 index 00000000..cd4a3f0b --- /dev/null +++ b/setup/init_vars @@ -0,0 +1,20 @@ +#!/bin/sh + +# The following variables are required by these scripts: + +## DAKBASE: The directory in which the dak install is to exist +DAKBASE=${DAKBASE:-/srv/dak} +export DAKBASE + +## DAKFQDN: The fqdn of the dak host +DAKFQDN=${DAKFQDN:-$(hostname -f)} +export DAKFQDN + +## DAKHOST: The short name used for the dak host +DAKHOST=${DAKHOST:-$(hostname)} +export DAKHOST + +## PGDATABASE: The postgresql database to use +## (other PG* variables can also be exported by the user if needed) +PGDATABASE=${PGDATABASE:-projectb} +export PGDATABASE