diff options
author | Eddy Petrișor <eddy.petrisor@gmail.com> | 2008-03-02 06:36:06 +0200 |
---|---|---|
committer | Eddy Petrișor <eddy.petrisor@gmail.com> | 2008-03-02 06:53:22 +0200 |
commit | f58559cf780a239413ddb83e97b97baffc932bf6 (patch) | |
tree | 1e2e3688a0e106c0a57001d23329a24daeadf097 | |
parent | 15858ea18dc276d1bc3d8dc1724a00ed264757bb (diff) | |
download | pbuilder-f58559cf780a239413ddb83e97b97baffc932bf6.tar pbuilder-f58559cf780a239413ddb83e97b97baffc932bf6.tar.gz |
Add support for sources.list.d and validate autodetection.
A the system might use sources.list.d, but might miss sources.list
entirely. All the relevant files are concatenated and the first deb
source is picked from that list.
When the autodection fails, make sure the responsability to insert
the valid information drops on the shoulders of the user.
Even if the shell is non-interactive, add some mirror.
Signed-off-by: Eddy Petrișor <eddy.petrisor@gmail.com>
-rwxr-xr-x | debian/pbuilder.postinst | 41 | ||||
-rw-r--r-- | debian/pbuilder.templates | 13 |
2 files changed, 46 insertions, 8 deletions
diff --git a/debian/pbuilder.postinst b/debian/pbuilder.postinst index e2f5a39..4de5873 100755 --- a/debian/pbuilder.postinst +++ b/debian/pbuilder.postinst @@ -26,24 +26,49 @@ case "$1" in CONFFILE=/etc/pbuilderrc # if there is a custom file, then we shouldn't touch it - if [ -f "$CONFFILE" ] ; then + if [ -f "$CONFFILE" ] + then CURRENTMIRROR=$(grep -E "^MIRRORSITE=" "$CONFFILE" | sed 's#MIRRORSITE=##g') - [ "$CURRENTMIRROR" = "_" ] || exit 0 + [ -z "$CURRENTMIRROR" ] || exit 0 else - # FIXME: try creating a file only with the MIRRORSITE line + # TODO: try creating a file only with the MIRRORSITE line cp "/usr/share/doc/pbuilder/examples/pbuilderrc" "$CONFFILE" - MIRRORSITE="_" + MIRRORSITE="" + db_set pbuilder/mirrorsite "" fi + db_input medium pbuilder/mirrorsite || [ $? = 30 ] + db_go + db_get pbuilder/mirrorsite MIRRORSITE="$RET" - if [ "$MIRRORSITE" = "_" ] + # the "_" alternative is just a safety net, + # but that should really never happen + if [ -z "$MIRRORSITE" ] || [ "$MIRRORSITE" = "_" ] then - MIRRORSITE=$(grep -E '^deb ' /etc/apt/sources.list | head -n 1 | awk '{print $2;}') + TMPSRC=`mktemp` + SRCLISTDIR=/etc/apt/sources.list.d + [ -f /etc/apt/sources.list ] && cat /etc/apt/sources.list > "$TMPSRC" || true + [ -f $SRCLISTDIR/*.sources.list ] && cat $SRCLISTDIR/*.sources.list >> "$TMPSRC" || true + MIRRORSITE=$(grep -E '^deb ' "$TMPSRC" | head -n 1 | awk '{print $2;}') + rm -f "$TMPSRC" + while [ -z "$MIRRORSITE" ] + do + db_input pbuilder/nomirror || true + db_input high pbuilder/mirrorsite && RETCODE=$? || RETCODE=$? + db_go + + # if the interface is non-interactive, still set a valid mirror + if [ $RETCODE = 30 ] + then + MIRRORSITE="http://ftp.debian.org/debian" + else + db_get pbuilder/mirrorsite + MIRRORSITE="$RET" + fi + done db_set pbuilder/mirrorsite "$MIRRORSITE" - db_input medium pbuilder/mirrorsite || true - db_go fi TMPFILE=`mktemp` diff --git a/debian/pbuilder.templates b/debian/pbuilder.templates index 2c36d2f..3887e41 100644 --- a/debian/pbuilder.templates +++ b/debian/pbuilder.templates @@ -3,3 +3,16 @@ Type: string Default: _ _Description: Default mirror site: Please enter the default mirror you want to be used by pbuilder. + . + If you leave this field blank, there will be one attempt to autodetect + this information. If this attempt fails, you will be prompted to insert + valid mirror information. + . + Here is a valid mirror example: http://ftp.debian.org/debian + +Template: pbuilder/nomirror +Type: error +_Description: Default mirror not found + Mirror information detection failed and the user provided no mirror information. + . + Please enter valid mirror information. |