From: Fredrik Tolf Date: Sun, 6 Jan 2008 00:46:12 +0000 (+0100) Subject: Initial import. X-Git-Url: http://git.dolda2000.com/gitweb/?a=commitdiff_plain;h=9f26b93f6e237e1abcd9ff6ee7937eed6799dd70;p=dcp.git Initial import. --- 9f26b93f6e237e1abcd9ff6ee7937eed6799dd70 diff --git a/dcp-build b/dcp-build new file mode 100755 index 0000000..0b68bdd --- /dev/null +++ b/dcp-build @@ -0,0 +1,65 @@ +#!/bin/sh + +set -e + +usage() { + echo "usage: dcp-build [-Nh] REPODIR OUTDIR" +} + +rungit() { + ( + cd "$td/repo" + git "$@" + ) || false +} + +defdir=/srv/dcp +push=y + +while [ "${1:0:1}" = - ]; do + opt="${1:1}" + shift + if [ "$opt" = N ]; then + push=n + shift + elif [ "$opt" = h ]; then + usage + exit 0 + else + echo "dcp-build: unknown option '$opt'" >&2 + exit 1 + fi +done + +if [ $# -lt 2 ]; then + usage >&2 + exit 1 +fi + +repodir="$1" +outdir="$2" +shift 2 +if [[ "$repodir" != */* ]]; then + repodir="$defdir/${repodir}.git" +fi + +if [ ! -d "$repodir" ]; then + echo "dcp-build: could not find $repodir" >&2 + exit 1 +fi +if [ ! -d "$outdir" ]; then + echo "dcp-build: could not find $outdir" >&2 + exit 1 +fi + +td="$(mktemp -d /tmp/dcp-XXXXXX)" +exec >"$td/log" 2>"$td/err" +dcp-runenv "$repodir" "$td" + +rungit tag -f lastbuild +(cd "$td"; control/build) || false +cp -a "$td/output"/* "$outdir/" + +if [ "$push" = y ]; then rungit push --tags; fi + +rm -rf "$td" diff --git a/dcp-init b/dcp-init new file mode 100755 index 0000000..7bd3d7e --- /dev/null +++ b/dcp-init @@ -0,0 +1,236 @@ +#!/bin/bash + +set -e + +usage() { + echo "usage: dcp-init [-C key=val] [-d REPODIR] PACKAGE [PATCH...]" + echo " PATCH ::= [-p LEVEL] [-bB BRANCH] FILE" + echo " -b creates a new branch at the current patch" + echo " -B creates a new branch at the upstream sources" +} + +rungit() { + ( + cd "$td" + git "$@" + ) || false +} + +getaptsrc() { + mkdir "$td/apt-tmp" + (cd "$td/apt-tmp"; apt-get source "$1") || false + + echo Achtung + sleep 10 + + sdir= + for f in "$td/apt-tmp"/*; do + if [ -d "$f" ]; then + if [ -z "$sdir" ]; then + sdir="$f" + else + echo "dcp-init: got more than one directory from apt-get; cannot continue" >&2 + exit 1 + fi + fi + done + if [ -z "$sdir" ]; then + echo "dcp-init: could not find any source directory" >&2 + exit 1 + fi + mv "$sdir" "$td/src" + rm -rf "$td/apt-tmp" + + rungit add src +} + +initrepo() { + rungit init -q + mkdir "$td/control" + touch "$td/control/conf" + rungit add control + rungit commit -q -m "Initial repo" + rungit tag empty +} + +initbase() { + mkdir "$td/control/build.d" + mkdir "$td/control/update.d" + cat >"$td/control/functions" <"$td/control/build" <"$td/control/update" <"$td/control/build.d/99dpkg" <"$td/control/update.d/upstream" <>"$td/control/conf" + rungit add control/conf +} + +defdir=/srv/dcp +repodir= +confopts=() + +while [ "${1:0:1}" = - ]; do + opt="${1:1}" + shift + if [ "$opt" = d ]; then + repodir="$1" + shift + elif [ "$opt" = h ]; then + usage + exit 0 + elif [ "$opt" = C ]; then + confopts=("${confopts[@]}" "$1") + shift + else + echo "dcp-init: unknown option '$opt'" >&2 + exit 1 + fi +done + +if [ $# -lt 1 ]; then + usage >&2 + exit 1 +fi +pkg="$1" +shift +if [ -z "$repodir" ]; then repodir="$pkg"; fi +if [[ "$repodir" != */* ]]; then + repodir="$defdir/${repodir}.git" +fi + +td="$(mktemp -d "/tmp/dcp-XXXXXX")" +initrepo + +initbase +rungit commit -q -m "Base control files" + +if [ "${#confopts[@]}" -gt 0 ]; then + for opt in "${confopts[@]}"; do + key="${opt%%=*}" + val="${opt#*=}" + echo "$key $val" >>"$td/control/conf" + done + rungit add control/conf + rungit commit -q -m "Custom configuration file" +fi + +rungit checkout -q -b upstream empty +getaptsrc "$pkg" +rungit commit -q -m "Initial upstream import" +rungit checkout master +rungit merge -n upstream + +initapt +rungit commit -q -m "APT control files" + +initvals() { + level=0 +} +initvals +while [ $# -gt 0 ]; do + arg="$1" + shift + if [ "${arg:0:1}" = - ]; then + if [ "$arg" = -p ]; then + level="$1" + shift + elif [ "$arg" = -b ]; then + rungit checkout -q -b "$1" + shift + elif [ "$arg" = -B ]; then + rungit checkout -q -b "$1" upstream + else + echo "dcp-init: unknown patch option '$arg'" >&2 + exit 1 + fi + else + ( + if [[ "$arg" == *.gz ]]; then + zcat "$arg" + else + cat "$arg" + fi + ) | patch -d "$td/src" -p"$level" + rungit add src + rungit commit -q -m "Applied $(basename "$arg")" + initvals + fi +done + +git clone -q --bare "$td" "$repodir" + +rm -rf "$td" diff --git a/dcp-runenv b/dcp-runenv new file mode 100755 index 0000000..7bd3486 --- /dev/null +++ b/dcp-runenv @@ -0,0 +1,27 @@ +#!/bin/sh + +set -e + +usage() { + echo "usage: dcp-runenv REPODIR RUNDIR" +} + +if [ $# -lt 2 ]; then + usage >&2 + exit 1 +fi + +repodir="$1" +rundir="$2" +shift 2 + +if [ ! -d "$rundir" ]; then mkdir "$rundir"; fi + +git clone -q "$repodir" "$rundir/repo" +for b in "$rundir/repo/.git/refs/remotes/origin"/*; do + b="${b##*/}" + if [ "$b" = HEAD -o "$b" = master ]; then continue; fi + (cd "$rundir/repo"; git branch "$b" "origin/$b") || false +done +cp -a "$rundir/repo/control" "$rundir" +mkdir "$rundir/output" diff --git a/dcp-update b/dcp-update new file mode 100755 index 0000000..6b47b04 --- /dev/null +++ b/dcp-update @@ -0,0 +1,63 @@ +#!/bin/sh + +set -e + +usage() { + echo "usage: dcp-update [-Nh] REPODIR" +} + +rungit() { + ( + cd "$td/repo" + git "$@" + ) || false +} + +defdir=/srv/dcp +push=y + +while [ "${1:0:1}" = - ]; do + opt="${1:1}" + shift + if [ "$opt" = N ]; then + push=n + shift + elif [ "$opt" = h ]; then + usage + exit 0 + else + echo "dcp-update: unknown option '$opt'" >&2 + exit 1 + fi +done + +if [ $# -lt 1 ]; then + usage >&2 + exit 1 +fi + +repodir="$1" +shift +if [[ "$repodir" != */* ]]; then + repodir="$defdir/${repodir}.git" +fi + +if [ ! -d "$repodir" ]; then + echo "dcp-build: could not find $repodir" >&2 + exit 1 +fi + +td="$(mktemp -d /tmp/dcp-XXXXXX)" +exec >"$td/log" 2>"$td/err" +dcp-runenv "$repodir" "$td" + +lastrev="$(rungit rev-parse HEAD)" +(cd "$td"; control/update) || false +rungit checkout master +newrev="$(rungit rev-parse HEAD)" + +echo "update: $lastrev -> $newrev" + +if [ "$push" = y ]; then rungit push; fi + +rm -rf "$td" diff --git a/dcp-update-apt b/dcp-update-apt new file mode 100755 index 0000000..41d2553 --- /dev/null +++ b/dcp-update-apt @@ -0,0 +1,41 @@ +#!/bin/sh + +set -e + +usage() { + echo "usage: dcp-update-apt PACKAGE" +} + +getaptsrc() { + mkdir "apt-tmp" + (cd "apt-tmp"; apt-get source "$1") || false + + sdir= + for f in "apt-tmp"/*; do + if [ -d "$f" ]; then + if [ -z "$sdir" ]; then + sdir="$f" + else + echo "dcp-update-apt: got more than one directory from apt-get; cannot continue" >&2 + exit 1 + fi + fi + done + if [ -z "$sdir" ]; then + echo "dcp-update-apt: could not find any source directory" >&2 + exit 1 + fi + mv "$sdir" "src" + rm -rf "apt-tmp" + + git add src +} + +if [ $# -lt 1 ]; then + usage >&2 + exit 1 +fi + +git rm --quiet -r src +getaptsrc "$1" +git commit -q -m "Updated from upstream" || true