diff options
author | Michael Imhof <tantive@gentoo.org> | 2003-11-18 01:27:49 +0000 |
---|---|---|
committer | Michael Imhof <tantive@gentoo.org> | 2003-11-18 01:27:49 +0000 |
commit | 394930f255f51e158f56dac411e1092bdc3bfc23 (patch) | |
tree | 05defa44152b2ab6acd40e286be640e5b0f6c459 /app-admin | |
parent | Initial release. (diff) | |
download | gentoo-2-394930f255f51e158f56dac411e1092bdc3bfc23.tar.gz gentoo-2-394930f255f51e158f56dac411e1092bdc3bfc23.tar.bz2 gentoo-2-394930f255f51e158f56dac411e1092bdc3bfc23.zip |
Initial release.
Diffstat (limited to 'app-admin')
7 files changed, 375 insertions, 3 deletions
diff --git a/app-admin/gentoo-distfiles-mirror/ChangeLog b/app-admin/gentoo-distfiles-mirror/ChangeLog new file mode 100644 index 000000000000..3fd643e45418 --- /dev/null +++ b/app-admin/gentoo-distfiles-mirror/ChangeLog @@ -0,0 +1,10 @@ +# ChangeLog for app-admin/gentoo-distfiles-mirror +# Copyright 2000-2003 Gentoo Technologies, Inc.; Distributed under the GPL v2 +# $Header: /var/cvsroot/gentoo-x86/app-admin/gentoo-distfiles-mirror/ChangeLog,v 1.1 2003/11/18 01:27:39 tantive Exp $ + +*gentoo-distfiles-mirror-0.1_pre1 (18 Nov 2003) + + 18 Nov 2003; Michael Imhof <tantive@gentoo.org> gentoo-distfiles-mirror-0.1_pre1.ebuild, + files/0.1/apache.addon-module, files/0.1/portage-incremirror: + Initial release. + diff --git a/app-admin/gentoo-distfiles-mirror/Manifest b/app-admin/gentoo-distfiles-mirror/Manifest index 2d50dd896c60..806bf96f06dd 100644 --- a/app-admin/gentoo-distfiles-mirror/Manifest +++ b/app-admin/gentoo-distfiles-mirror/Manifest @@ -1,4 +1,6 @@ -MD5 f413498738b76c8c9a805977ee37b749 gentoo-distfiles-mirror-0.1_pre1.ebuild 587 +MD5 062f179e5022a4f448a61985b5208682 gentoo-distfiles-mirror-0.1_pre1.ebuild 1135 +MD5 beb9efce81ae2c582a621528fc783095 metadata.xml 373 +MD5 2944d13e25763e064986ab487fd93745 ChangeLog 473 MD5 d41d8cd98f00b204e9800998ecf8427e files/digest-gentoo-distfiles-mirror-0.1_pre1 0 -MD5 bca32d4fe3d0c293feb0d3f3d9437ffe files/0.1/apache.addon-module 220 -MD5 f47adcc959319ac4aa7f51ab7087df78 files/0.1/portage-incremirror 9222 +MD5 ffdcdd3880ffbb568f0453fade5df37f files/0.1/apache.addon-module 923 +MD5 c7714a7e35a5e1dd3dc15c89e66bef19 files/0.1/portage-incremirror 8266 diff --git a/app-admin/gentoo-distfiles-mirror/files/0.1/apache.addon-module b/app-admin/gentoo-distfiles-mirror/files/0.1/apache.addon-module new file mode 100644 index 000000000000..bdce5a6614ca --- /dev/null +++ b/app-admin/gentoo-distfiles-mirror/files/0.1/apache.addon-module @@ -0,0 +1,27 @@ +# +# This is the config snippet for gentoo-distfiles-mirror +# +# $Header: /var/cvsroot/gentoo-x86/app-admin/gentoo-distfiles-mirror/files/0.1/apache.addon-module,v 1.1 2003/11/18 01:27:39 tantive Exp $ + + RewriteEngine on + + # If the file exists locally, serve it and stop rewriting. + RewriteCond /var/www/distfiles/%{REQUEST_FILENAME} -f + RewriteRule ^/distfiles/(.+) /distfiles/$1 [L] + + # If the file doesn't exist locally, pass through to a + # ScriptAliasMatch that sends the request to a script that + # schedules it for downloading from a real mirror, and stop rewriting. + RewriteCond /var/www/distfiles/%{REQUEST_FILENAME} !-f + RewriteRule ^/distfiles/(.+) - [E=REQ_FILENAME:$1,E=REQ_REMOTEADDR:%{REMOTE_ADDR},PT] + ScriptAliasMatch ^/distfiles/(.+) /var/www/distfiles/portage-incremirror + + +<Directory "/var/www/distfiles"> + Options None +# AllowOverride None + Order allow,deny + Allow from all +</Directory> + + diff --git a/app-admin/gentoo-distfiles-mirror/files/0.1/portage-incremirror b/app-admin/gentoo-distfiles-mirror/files/0.1/portage-incremirror new file mode 100644 index 000000000000..6610ecbaad30 --- /dev/null +++ b/app-admin/gentoo-distfiles-mirror/files/0.1/portage-incremirror @@ -0,0 +1,292 @@ +#!/bin/bash + +# SCRIPT OPTIONS +O_DISTFILES="/var/www/distfiles" +O_MIRROR="http://gentoo.oregonstate.edu/distfiles" +O_DOWNQ="/var/www/distfiles/.queue" +O_LOGINFO="/usr/bin/logger -t gentoo-distfiles-mirror -p local5.info" +O_LOGERR="/usr/bin/logger -t gentoo-distfiles-mirror -p local5.err" +O_IMMEDIATE="TRUE" +O_IMMEDIATEQ="TRUE" +O_MINFREE="104857600" + +# SCRIPT PROPERTIES +VERSION="1.0.7" +P_DOWNQ="FALSE" +P_FORCE="FALSE" +P_FILE="" +P_REMOTE="" + +# EXIT CODES +E_OPTERROR=65 + +# FUNCTIONS +usage() { + echo "Usage: $(basename $0) [OPTIONS | FILE]" + echo "Incrementally build a distfiles mirror." + echo + echo " FILE specifies the file to provide, if FILE" + echo " is absent, no additions will be made to the" + echo " download queue, and no redirection will be" + echo " performed." + echo + echo " -d download files listed in download queue" + echo " -f force download of file even if it already exists" + echo " -h display this help and exit" + echo " -v output version information and exit" + echo + echo "Report bugs to <wolfwood@users.sourceforge.net>." + exit 0 +} + +version() { + echo "$(basename $0) $VERSION" + echo "Written by Nicholas D. Wolfwood." + echo + echo "Copyright (C) 2003 Free Software Foundation, Inc." + echo "This is free software; see the source for copying conditions. There is NO" + echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + exit 0 +} + +badopt() { + echo "$(basename $0): invalid option -- $OPTARG" + echo "Try '$(basename $0) -h' for more information." + exit $E_OPTERROR +} + +log() { + if [ "$1" = "info" ]; then + if [ -n "$O_LOGINFO" ]; then + $O_LOGINFO "${2}" + fi + elif [ "$1" = "err" -o "$1" = "error" ]; then + if [ -n "$O_LOGERR" ]; then + $O_LOGERR "${2}" + fi + elif [ "$1" = "all" ]; then + if [ -n "$O_LOGINFO" ]; then + $O_LOGINFO "${2}" + fi + if [ -n "$O_LOGERR" ]; then + $O_LOGERR "${2}" + fi + else + return 1 + fi + return 0 +} + +httpout() { + if [ -z "$1" ]; then + return 1 + else + echo -en "Content-Type: text/plain\n\n" + echo -e "${1}" + fi +} + +httpredirect() { + if [ -z "$1" ]; then + return 1 + else + echo -en "Location: ${1}\n" + echo -en "Content-Type: text/plain\n\n" + echo "The requested resource resides temporarily under a different URI: ${1}" + fi +} + +httpnotfound() { + echo -en "Status: 404 Not Found\n" + echo -en "Content-Type: text/plain\n\n" + echo "The server has not found anything matching the Request-URI." +} + +httpdownload() { + if [ -z "$1" ]; then + return 1 + else + if [ -n "$2" ]; then + echo -en "Content-Length: ${2}\n" + fi + echo -en "Content-Type: ${1}\n\n" + fi +} + +# PARSE OPTIONS +while getopts ":dfhv" Option +do + case $Option in + d) P_DOWNQ="TRUE"; break;; + f) P_FORCE="TRUE"; break;; + h) usage; break;; + v) version; break;; + *) badopt; break;; + esac +done +shift $(($OPTIND - 1)) + +# PARSE ARGUMENTS +if [ -n "$REQ_REMOTEADDR" ]; then + P_REMOTE="$REQ_REMOTEADDR" +fi +if [ -n "$REQ_FILENAME" ]; then + if [ ${#REQ_FILENAME} -ge 256 ]; then + log err "Failure on request for ${P_REMOTE}: request filename is too long." + exit 1 + else + P_FILE="$REQ_FILENAME" + fi +fi + +# MAIN +if [ "$P_DOWNQ" = "TRUE" ]; then + if [ -f "${O_DOWNQ}" ]; then + declare -a downq=( $(cat "${O_DOWNQ}") ) + if [ ${#downq[@]} -gt 0 ]; then + for i in $(seq 0 $((${#downq[@]} - 1))); do + if [ -n "${downq[$i]}" ]; then + if [ "$P_FORCE" = "TRUE" ]; then + /usr/bin/wget -qrP "${O_DISTFILES}/" "${O_MIRROR}/${downq[$i]}" + else + /usr/bin/wget -qP "${O_DISTFILES}/" "${O_MIRROR}/${downq[$i]}" + fi + retval=$? + + if [ $retval -ne 0 ]; then + if [ -f "${O_DISTFILES}/${downq[$i]}" ]; then + /bin/rm "${O_DISTFILES}/${downq[$i]}" + fi + log err "Failed download: wget exited code ${retval} on file: ${downq[$i]}" + else + /bin/chmod 0444 "${O_DISTFILES}/${downq[$i]}" + retval=$? + + if [ $retval -ne 0 ]; then + if [ -f "${O_DISTFILES}/${downq[$i]}" ]; then + /bin/rm "${O_DISTFILES}/${downq[$i]}" + fi + log err "Failed to chmod file: ${downq[$i]} (chmod exited code ${retval})" + else + log info "File downloaded successfully: ${downq[$i]}" + fi + fi + downq[$i]="" + fi + done + cat /dev/null >"$O_DOWNQ" + for i in $(seq 0 $((${#downq[@]} - 1))); do + if [ -n "${downq[$i]}" ]; then + echo "${downq[$i]}" >>"$O_DOWNQ" + fi + done + fi + else + log err "No download queue: ${O_DOWNQ}" + fi +else + if [ -n "$P_FILE" ]; then + if [ "$P_FORCE" = "FALSE" ]; then + if [ -f "${O_DISTFILES}/${P_FILE}" ]; then + httpout "File already exists." + exit 1 + fi + fi + + if [ "$P_FILE" != "index.html" ]; then + if [ "$O_IMMEDIATE" = "TRUE" ]; then + log info "Downloading file: ${P_FILE} and serving to ${P_REMOTE}" + + curl -is "${O_MIRROR}/${P_FILE}" | while read -r line; do + if [ ${#line} -eq 1 ]; then + echo "" + tee "${O_DISTFILES}/${P_FILE}" + break + else + case $line in + [Cc]ontent-[Ll]ength:*) + len=$(echo "$line" | sed -r -e 's/.*[Cc]ontent-[Ll]ength:[ ]*([0-9]+).*$/\1/'); + dsf=$(df -B1 "${O_DISTFILES}" | head -n2 | tail -n1 | awk '{ print $4 }'); + if [ "$(($dsf - $len))" -lt "${O_MINFREE}" ]; then + log err "Not enough free disk space for file: ${P_FILE} requested by ${P_REMOTE}" + httpredirect "${O_MIRROR}/${P_FILE}" + exit 1 + else + echo "$line" + fi;; + [Cc]ontent-[Tt]ype:*) echo "$line";; + esac + fi + done + retval=$? + + if [ $retval -ne 0 ]; then + if [ -f "${O_DISTFILES}/${P_FILE}" ]; then + /bin/rm "${O_DISTFILES}/${P_FILE}" + fi + log err "Failed download: curl | tee exited code ${retval} on file: ${P_FILE}" + httpnotfound + else + /bin/chmod 0444 "${O_DISTFILES}/${P_FILE}" + retval=$? + + if [ $retval -ne 0 ]; then + if [ -f "${O_DISTFILES}/${P_FILE}" ]; then + /bin/rm "${O_DISTFILES}/${P_FILE}" + fi + log err "Failed to chmod file: ${P_FILE} (chmod exited code ${retval}), file deleted." + else + if [ -s "${O_DISTFILES}/${P_FILE}" ]; then + log info "File downloaded: ${P_FILE} and served to ${P_REMOTE} successfully." + else + #ZERO LENGTH FAILURE + log info "Client ${P_REMOTE} canceled download of file: ${P_FILE}" + + retval=0 + if [ -f "${O_DISTFILES}/${P_FILE}" ]; then + /bin/rm "${O_DISTFILES}/${P_FILE}" + retval=$? + fi + if [ $retval -ne 0 ]; then + log err "Failed to delete file: ${P_FILE}, please do so ASAP." + else + log info "Download of file: ${P_FILE} for ${P_REMOTE} canceled, file deleted." + fi + + if [ "$O_IMMEDIATEQ" = "TRUE" ]; then + echo "$P_FILE" >>"$O_DOWNQ" + retval=$? + + if [ $retval -ne 0 ]; then + log err "Failed to queue file: ${P_FILE} for ${P_REMOTE} (echo exited code ${retval})" + else + log info "Queued file originally requested by ${P_REMOTE} for download: ${P_FILE}" + fi + fi + #END ZERO LENGTH FAILURE SECTION + fi + fi + fi + else + echo "$P_FILE" >>"$O_DOWNQ" + retval=$? + + if [ $retval -ne 0 ]; then + log err "Failed to queue file: ${P_FILE} for ${P_REMOTE} (echo exited code ${retval})" + else + log info "Queued file originally requested by ${P_REMOTE} for download: ${P_FILE}" + fi + + httpredirect "${O_MIRROR}/${P_FILE}" + fi + else + httpredirect "../listdistfiles/" + fi + exit 0 + else + httpout "No file specified for download." + exit 0 + fi +fi + +exit 0 diff --git a/app-admin/gentoo-distfiles-mirror/files/digest-gentoo-distfiles-mirror-0.1_pre1 b/app-admin/gentoo-distfiles-mirror/files/digest-gentoo-distfiles-mirror-0.1_pre1 new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/app-admin/gentoo-distfiles-mirror/files/digest-gentoo-distfiles-mirror-0.1_pre1 diff --git a/app-admin/gentoo-distfiles-mirror/gentoo-distfiles-mirror-0.1_pre1.ebuild b/app-admin/gentoo-distfiles-mirror/gentoo-distfiles-mirror-0.1_pre1.ebuild new file mode 100644 index 000000000000..dc83c5592816 --- /dev/null +++ b/app-admin/gentoo-distfiles-mirror/gentoo-distfiles-mirror-0.1_pre1.ebuild @@ -0,0 +1,30 @@ +# Copyright 1999-2003 Gentoo Technologies, Inc. +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/app-admin/gentoo-distfiles-mirror/gentoo-distfiles-mirror-0.1_pre1.ebuild,v 1.1 2003/11/18 01:27:39 tantive Exp $ + +S=${WORKDIR}/gentoo-distfiles-mirror-${PV/_pre1} +DESCRIPTION="Ebuild for setting up a Gentoo distfiles mirror" +HOMEPAGE="http://www.gentoo.org/doc/en/source_mirrors.xml" +IUSE="" + +DEPEND="virtual/glibc + >=net-www/apache-2.0.47" +RDEPEND=">=net-www/apache-2.0.47" + +SLOT="0" +LICENSE="GPL-2" +KEYWORDS="-*" + +src_install() { + insinto /var/www/distfiles + newins ${FILESDIR}/${PV/_pre1}/portage-incremirror portage-incremirror + chown apache:apache ${D}/var/www/distfiles + chmod 0755 ${D}/var/www/distfiles + chown apache:apache ${D}/var/www/distfiles/portage-incremirror + chmod 0744 ${D}/var/www/distfiles/portage-incremirror + insinto /etc/apache2/conf/modules.d + newins ${FILESDIR}/${PV/_pre1}/apache.addon-module 65_gentoo-distfiles-mirror.conf + touch ${D}/var/www/distfiles/.queue + chown apache:apache ${D}/var/www/distfiles/.queue + chmod 0644 ${D}/var/www/distfiles/.queue +} diff --git a/app-admin/gentoo-distfiles-mirror/metadata.xml b/app-admin/gentoo-distfiles-mirror/metadata.xml new file mode 100644 index 000000000000..2216ac015a32 --- /dev/null +++ b/app-admin/gentoo-distfiles-mirror/metadata.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd"> +<pkgmetadata> +<herd>cluster</herd> +<maintainer> + <email>tantive@gentoo.org</email> +<!-- <name>Michael Imhof</name> --> +<!-- <description>Release manager, patch manager</description> --> +</maintainer> +<!-- <longdescription></longdescription> --> +</pkgmetadata> |