Commit dc515cd4 authored by Antonio Terceiro's avatar Antonio Terceiro

major reorganization for reuse and consolidation

parent d5e0711c
/data /data
/public/doc /public/doc
/public/jquery.js /public/jquery.js
/.whitelist /config/whitelist
/chroots/*
Work chroots will be create in this directory by the setup script.
Files you may want to put in this directory:
- whitelist
- blacklist
#!/bin/sh
if [ -z "$dep8_base_dir" ]; then
if [ -f scripts/process-all-packages -a -f lib/environment.sh ]; then
dep8_base_dir="$(pwd)"
else
return 1
fi
fi
dep8_suite='unstable' # FIXME
dep8_data_dir="${dep8_base_dir}/data"
dep8_packages_dir="${dep8_data_dir}/packages"
dep8_config_dir="${dep8_base_dir}/config"
dep8_gnupg_dir="${dep8_base_dir}/gnupg"
dep8_chroots_dir="${dep8_base_dir}/chroots"
dep8_chroot_name="dep8-${dep8_suite}"
dep8_chroot_path="${dep8_chroots_dir}/${dep8_suite}"
#!/bin/sh
grep_packages() {
grep-dctrl "$@" "$dep8_chroot_path"/var/lib/apt/lists/*_debian_dists_${dep8_suite}_main_binary-`dpkg-architecture -qDEB_HOST_ARCH`_Packages
}
grep_sources() {
grep-dctrl "$@" "$dep8_chroot_path"/var/lib/apt/lists/*_debian_dists_${dep8_suite}_main_source_Sources
}
list_binaries() {
pkg="$1"
grep_packages -n -s Package -F Source,Package -X "$pkg"
}
check_version() {
# check source version for (available for this architecture) by looking at
# the first binary package built from that source package
local pkg="$1"
first_binary=$(list_binaries "$pkg" | head -n 1)
grep_packages -n -s Version -F Package -X "$first_binary"
}
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
set -e set -e
suite=unstable # FIXME should be an optional parameter base=$(readlink -f $(dirname $(readlink -f $0))/..)
chroot_path="$(pwd)/data/chroots/${suite}" . $base/lib/environment.sh
. $base/lib/functions.sh
grep-dctrl -n -s Package -F Testsuite autopkgtest "$chroot_path"/var/lib/apt/lists/*dists_${suite}_main_source_Sources | sort | uniq grep_sources -n -s Package -F Testsuite -X autopkgtest | sort | uniq
...@@ -2,12 +2,10 @@ ...@@ -2,12 +2,10 @@
set -e set -e
suite=unstable # FIXME base=$(readlink -f $(dirname $(readlink -f $0))/..)
chroot_name="dep8-$suite" . $base/lib/environment.sh
root=$(pwd) . $base/lib/functions.sh
data_root=$(pwd)/data
packages_root=$(pwd)/data/packages
chroot_root=$(pwd)/data/chroots
date=$(date --rfc-3339=date) date=$(date --rfc-3339=date)
global_tmp_dir=$(mktemp -d) global_tmp_dir=$(mktemp -d)
...@@ -27,7 +25,7 @@ process_package() { ...@@ -27,7 +25,7 @@ process_package() {
mkdir "$tmp_dir" mkdir "$tmp_dir"
# setup status "DB" # setup status "DB"
status_dir="${packages_root}/${pkg_dir}" status_dir="${dep8_packages_dir}/${pkg_dir}"
mkdir -p "$status_dir" mkdir -p "$status_dir"
# setup log # setup log
...@@ -65,7 +63,7 @@ do_process_package() { ...@@ -65,7 +63,7 @@ do_process_package() {
} }
needs_processing() { needs_processing() {
whitelist="${root}/.whitelist" local whitelist="${dep8_config_dir}/whitelist"
if [ -f "${whitelist}" ]; then if [ -f "${whitelist}" ]; then
if ! grep -q "^$1\$" "${whitelist}"; then if ! grep -q "^$1\$" "${whitelist}"; then
return 1 return 1
...@@ -102,9 +100,9 @@ check_dependencies() { ...@@ -102,9 +100,9 @@ check_dependencies() {
pkg="$1" pkg="$1"
binaries=$(list_binaries "$pkg") binaries=$(list_binaries "$pkg")
{ {
if ! schroot -d / -c "$chroot_name" -u root -- apt-get install --quiet --assume-yes --simulate $binaries 2>&1; then if ! schroot -d / -c "$dep8_chroot_name" -u root -- apt-get install --quiet --assume-yes --simulate $binaries 2>&1; then
for binary in $binaries; do for binary in $binaries; do
schroot -d / -c "$chroot_name" -u root -- apt-get -q -y --simulate install $binary 2>&1 schroot -d / -c "$dep8_chroot_name" -u root -- apt-get -q -y --simulate install $binary 2>&1
done done
fi fi
} | \ } | \
...@@ -112,18 +110,6 @@ check_dependencies() { ...@@ -112,18 +110,6 @@ check_dependencies() {
sort | uniq sort | uniq
} }
list_binaries() {
pkg="$1"
grep_packages -n -s Package -F Source,Package -X "$pkg"
}
grep_packages() {
grep-dctrl "$@" "$chroot_root"/"$suite"/var/lib/apt/lists/*_debian_dists_${suite}_main_binary-`dpkg-architecture -qDEB_HOST_ARCH`_Packages
}
grep_sources() {
grep-dctrl "$@" "$chroot_root"/"$suite"/var/lib/apt/lists/*_debian_dists_${suite}_main_source_Sources
}
first_banner= first_banner=
banner() { banner() {
...@@ -137,14 +123,6 @@ banner() { ...@@ -137,14 +123,6 @@ banner() {
echo echo
} }
check_version() {
# check source version for (available for this architecture) by looking at
# the first binary package built from that source package
local pkg="$1"
first_binary=$(list_binaries "$pkg" | head -n 1)
grep_packages -n -s Version -F Package -X "$first_binary"
}
record_status() { record_status() {
pkg="$1" pkg="$1"
status="$2" status="$2"
......
...@@ -2,43 +2,43 @@ ...@@ -2,43 +2,43 @@
set -e set -e
base=$(readlink -f $(dirname $(readlink -f $0))/..)
. $base/lib/environment.sh
if [ $(whoami) != root ]; then if [ $(whoami) != root ]; then
echo "This script mus be run as root" echo "This script must be run as root"
exit 1 exit 1
fi fi
suite='unstable' # FIXME
data_root=$(pwd)/data data_root=$(pwd)/data
chroot_root=${data_root}/chroots chroot_root=${data_root}/chroots
create_chroot() { create_chroot() {
local suite="$1" echo "Creating $dep8_suite chroot (may take a while)"
local path="$2"
echo "Creating $suite chroot (may take a while)"
# detect a local apt-cacher-ng cache running. # detect a local apt-cacher-ng cache running.
# 10.0.2.2 = default IP assigned to host system as seen from a kvm/virtualbox # 10.0.2.2 = default IP assigned to host system as seen from a kvm/virtualbox
# virtual machine # virtual machine
mirror= local mirror=
for ip in 127.0.0.1 10.0.2.2; do for ip in 127.0.0.1 10.0.2.2; do
if nc -z -w 1 $ip 3142; then if nc -z -w 1 $ip 3142; then
mirror=http://$ip:3142/debian mirror=http://$ip:3142/debian
fi fi
done done
debootstrap "$suite" "$path" $mirror debootstrap "$dep8_suite" "$dep8_chroot_path" $mirror
# do not download translations # do not download translations
echo 'Acquire::Languages "none";' > "${path}/etc/apt/apt.conf.d/99translations" echo 'Acquire::Languages "none";' > "${dep8_chroot_path}/etc/apt/apt.conf.d/99translations"
# add APT Source URIs # add APT Source URIs
sed -e 's/^deb\s/deb-src /' "${path}/etc/apt/sources.list" > "${path}/etc/apt/sources.list.d/sources.list" sed -e 's/^deb\s/deb-src /' "${dep8_chroot_path}/etc/apt/sources.list" > "${dep8_chroot_path}/etc/apt/sources.list.d/sources.list"
chroot "$path" apt-get update chroot "$dep8_chroot_path" apt-get update
echo 'debconf debconf/frontend select noninteractive' | chroot "$path" debconf-set-selections echo 'debconf debconf/frontend select noninteractive' | chroot "$dep8_chroot_path" debconf-set-selections
} }
update_chroot() { update_chroot() {
...@@ -51,21 +51,17 @@ update_chroot() { ...@@ -51,21 +51,17 @@ update_chroot() {
} }
setup_schroot() { setup_schroot() {
local suite="$1"
local chroot_name="$2"
local chroot_path="$3"
local data_dir=$(readlink -f ${data_root}) local data_dir=$(readlink -f ${data_root})
local user=$(stat -c %U "${data_dir}") local user=$(stat -c %U "${data_dir}")
if [ -z "$user" ]; then if [ -z "$user" ]; then
user=dep8 user=dep8
fi fi
cat > /etc/schroot/chroot.d/"${chroot_name}" <<EOF cat > /etc/schroot/chroot.d/"${dep8_chroot_name}" <<EOF
[$chroot_name] [$dep8_chroot_name]
type=directory type=directory
description=DEP-8 $suite chroot description=DEP-8 $dep8_suite chroot
directory=${chroot_path} directory=${dep8_chroot_path}
users=$user users=$user
groups=$user groups=$user
root-users=$user root-users=$user
...@@ -76,34 +72,29 @@ EOF ...@@ -76,34 +72,29 @@ EOF
} }
setup_suite() { setup_suite() {
local suite="$1"
# create chroot directory # create chroot directory
if [ ! -d "${chroot_root}" ]; then if [ ! -d "${dep8_chroots_dir}" ]; then
mkdir "${chroot_root}" mkdir "${dep8_chroots_dir}"
fi fi
chroot_name="dep8-${suite}" if schroot --list --all | grep -q "^source:${dep8_chroot_name}\$"; then
chroot_path="${chroot_root}/${suite}" echo "schroot setup for ${dep8_suite} already done, skipping"
if schroot --list --all | grep -q "^source:dep8-$suite\$"; then
echo "Suite ${suite} already set up, skipping"
else else
setup_schroot "$suite" "$chroot_name" "$chroot_path" setup_schroot
fi fi
local actual_chroot_path=$(schroot --config --chroot "$chroot_name" | grep '^directory=' | cut -d = -f 2) local actual_chroot_path=$(schroot --config --chroot "$dep8_chroot_name" | grep '^directory=' | cut -d = -f 2)
if [ -d "${actual_chroot_path}" ]; then if [ -d "${actual_chroot_path}" ]; then
update_chroot "$actual_chroot_path" update_chroot "$actual_chroot_path"
else else
if [ "$actual_chroot_path" = "${chroot_path}" ]; then if [ "$actual_chroot_path" = "${dep8_chroot_path}" ]; then
create_chroot "$suite" "$chroot_path" create_chroot
else else
echo "Chroot ${chroot_name} does not exit in custom location ${actual_chroot_path}. Please create it first." echo "Chroot ${dep8_chroot_name} does not exit in custom location ${actual_chroot_path}. Please create it first."
exit 1
fi fi
fi fi
} }
# FIXME turn this into a loop when more than one suite is supported setup_suite
setup_suite "$suite"
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
set -e set -e
base=$(readlink -f $(dirname $(readlink -f $0))/..)
. $base/lib/environment.sh
if [ $# -ne 1 ]; then if [ $# -ne 1 ]; then
echo "usage: $0 PACKAGE" echo "usage: $0 PACKAGE"
exit 1 exit 1
...@@ -16,11 +19,9 @@ cleanup() { ...@@ -16,11 +19,9 @@ cleanup() {
} }
trap cleanup INT TERM EXIT trap cleanup INT TERM EXIT
suite=unstable # FIXME this should be a parameter (?)
cd $tmpdir cd $tmpdir
schroot --chroot dep8-$suite -- apt-get source --download-only $package schroot --chroot "${dep8_chroot_name}" -- apt-get source --download-only $package
dpkg-source -x *.dsc dpkg-source -x *.dsc
source=$(find . -mindepth 1 -maxdepth 1 -type d) source=$(find . -mindepth 1 -maxdepth 1 -type d)
cd "$source" cd "$source"
adt-run --built-tree . --- adt-virt-schroot "dep8-$suite" adt-run --built-tree . --- adt-virt-schroot "${dep8_chroot_name}"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment