Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 84790 Details for
Bug 130039
check gpg signature when using emerge-webrsync
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
my-emerge-webrsync
my-emerge-webrsync (text/plain), 8.32 KB, created by
Alon Bar-Lev (RETIRED)
on 2006-04-16 12:18:18 UTC
(
hide
)
Description:
my-emerge-webrsync
Filename:
MIME Type:
Creator:
Alon Bar-Lev (RETIRED)
Created:
2006-04-16 12:18:18 UTC
Size:
8.32 KB
patch
obsolete
>#!/bin/bash ># Copyright 1999-2006 Gentoo Foundation ># Distributed under the terms of the GNU General Public License v2 ># $Id: /var/cvsroot/gentoo-src/portage/bin/Attic/emerge-webrsync,v 1.8.2.4 2005/02/26 11:22:38 carpaski Exp $ ># Author: Karl Trygve Kalleberg <karltk@gentoo.org> ># Rewritten from the old, Perl-based emerge-webrsync script ># Author: Alon Bar-Lev <alon.barlev@gmail.com> ># Major rewrite from Karl's scripts. > ># ># gpg key import ># KEY_ID=0x7DDAD20D ># gpg --homedir /etc/portage/gnupg --keyserver subkeys.pgp.net --recv-keys $KEY_ID ># gpg --homedir /etc/portage/gnupg --edit-key $KEY_ID trust > ># If PORTAGE_NICENESS is overriden via the env then it will ># still pass through the portageq call and override properly. >PORTAGE_NICENESS="$(/usr/lib/portage/bin/portageq envvar PORTAGE_NICENESS)" >if [ -n "${PORTAGE_NICENESS}" ]; then > renice $PORTAGE_NICENESS $$ > /dev/null >fi > >source /usr/lib/portage/bin/isolated-functions.sh || exit 1 >FEATURES="$(/usr/lib/portage/bin/portageq envvar FEATURES)" >GENTOO_MIRRORS="${GENTOO_MIRRORS} $(/usr/lib/portage/bin/portageq gentoo_mirrors)" >PORTDIR="$(/usr/lib/portage/bin/portageq portdir)" >FETCHCOMMAND="$(/usr/lib/portage/bin/portageq envvar FETCHCOMMAND)" >USERLAND="$(/usr/lib/portage/bin/portageq envvar USERLAND)" >DISTDIR="$(/usr/lib/portage/bin/portageq envvar PORTAGE_TMPDIR)/emerge-webrsync" >PORTAGE_INST_UID="$(/usr/lib/portage/bin/portageq envvar PORTAGE_INST_UID)" >PORTAGE_INST_GID="$(/usr/lib/portage/bin/portageq envvar PORTAGE_INST_GID)" >WEBSYNC_VERIFY_SIGNATURE="$(/usr/lib/portage/bin/portageq envvar WEBSYNC_VERIFY_SIGNATURE)" >PORTAGE_GPG_HOME="$(/usr/lib/portage/bin/portageq envvar PORTAGE_GPG_HOME)" > >if [ -z "${WEBSYNC_VERIFY_SIGNATURE}" ]; then > WEBSYNC_VERIFY_SIGNATURE=0 >fi >if [ ${WEBSYNC_VERIFY_SIGNATURE} != 0 -a -z "${PORTAGE_GPG_HOME}" ]; then > echo "Error: Please set PORTAGE_GPG_HOME in make.conf" > exit 1 >fi > >do_verbose=0 > >get_portage_timestamp() { > local portage_current_timestamp=0 > > if [ -f "${PORTDIR}/metadata/timestamp.x" ]; then > portage_current_timestamp=$(cut -f 1 -d " " "${PORTDIR}/metadata/timestamp.x" ) > fi > > echo "${portage_current_timestamp}" >} > >fetch_file() { > local url="$1" > local file="$2" > local opts > > if [ "${FETCHCOMMAND/wget/}" != "${FETCHCOMMAND}" ]; then > opts="--continue" > > [ "${do_verbose}" == 0 ] && opts="$opts -q" > elif [ "${FETCHCOMMAND/curl/}" != "${FETCHCOMMAND}" ]; then > opts="--continue-at -" > > [ "${do_verbose}" == 0 ] && opts="$opts -s -f" > else > rm -f "${file}" > fi > > echo "Fetching file ${file}..." > > #already set DISTDIR= > if [ "${do_verbose}" == 0 ] ; then > URI="${url}" eval "${FETCHCOMMAND}" ${opts} > /dev/null && [ -s "${file}" ] > else > URI="${url}" eval "${FETCHCOMMAND}" ${opts} && [ -s "${file}" ] > fi >} > >check_file_digest() { > local digest="$1" > local file="$2" > local r=1 > > echo "Checking digest..." > > if type -p md5sum > /dev/null; then > md5sum -c $digest && r=0 > elif type -p md5 > /dev/null; then > [ "$(md5 -q $file)" == "$(cut -d \ -f 1 \"$digest\")" ] && r=0 > else > echo "Error: Cannot check digest" > echo "No suitable md5/md5sum binaries found" > fi > > return "${r}" >} > >check_file_signature() { > local signature="$1" > local file="$2" > local r=1 > > if [ ${WEBSYNC_VERIFY_SIGNATURE} != 0 ]; then > > echo "Checking signature..." > > if type -p gpg > /dev/null; then > gpg --homedir "${PORTAGE_GPG_HOME}" --verify "$signature" "$file" && r=0 > else > echo "Error: Cannot check signature" > echo "gpg binary not found" > fi > else > r=0 > fi > > return "${r}" >} > >get_snapshot_timestamp() { > local file="$1" > > tar --to-stdout -xf "${file}" portage/metadata/timestamp.x | cut -f 1 -d " " >} > >sync_local() { > local file="$1" > > echo "Syncing local tree..." > > if type -p tarsync &> /dev/null; then > if ! tarsync -v -s 1 -o portage -g portage -e /distfiles -e /packages -e /local "${file}" "${PORTDIR}"; then > echo "Error: tarsync failed; tarball is corrupt? (${file})" > return 1 > fi > else > echo "Note: tarsync was not found, you may consider emerge it..." > > if ! tar jxf "${file}"; then > echo "Error: tar failed to extract the image. tarball is corrupt? (${file})" > rm -fr portage > return 1 > fi > > # Free disk space > rm -f "${file}" > > # Make sure user and group file ownership is ${PORTAGE_INST_UID}:${PORTAGE_INST_GID} > chown -R ${PORTAGE_INST_UID:-0}:${PORTAGE_INST_GID:-0} portage > cd portage > rsync -av --progress --stats --delete --delete-after \ > --exclude='/distfiles' --exclude='/packages' \ > --exclude='/local' . "${PORTDIR%%/}" > cd .. > > echo "Cleaning up..." > rm -fr portage > fi > > if hasq metadata-transfer ${FEATURES} ; then > echo "Updating cache..." > emerge --metadata > fi >} > >do_snapshot() { > local ignore_timestamp="$1" > local date="$2" > > local r=1 > > local file="portage-${date}.tar.bz2" > local digest="${file}.md5sum" > local signature="${file}.gpgsig" > > local have_files=0 > local mirror > > echo "Trying to retrieve ${date} snapshot..." > > for mirror in ${GENTOO_MIRRORS} ; do > > [ -s "${file}" -a -s "${digest}" -a -s "${signature}" ] && \ > check_file_digest "${digest}" "${file}" && \ > check_file_signature "${signature}" "${file}" && \ > have_files=1 > > [ ${have_files} == 0 ] && \ > fetch_file "${mirror}/snapshots/${digest}" "${digest}" && \ > fetch_file "${mirror}/snapshots/${signature}" "${signature}" && \ > fetch_file "${mirror}/snapshots/${file}" "${file}" && \ > check_file_digest "${digest}" "${file}" && \ > check_file_signature "${signature}" "${file}" && \ > have_files=1 > > # > # If timestamp is invalid > # we want to try and retieve > # from a different mirror > # > if [ ${have_files} != 0 ]; then > > echo "Getting snapshot timetasmp..." > local snapshot_timestamp=$(get_snapshot_timestamp "${file}") > > if [ ${ignore_timestamp} == 0 ]; then > if [ ${snapshot_timestamp} -lt $(get_portage_timestamp) ]; then > echo "Warning: Portage is newer than snapshot" > have_files=0 > fi > else > if [ "${USERLAND}" == "BSD" ] || [ "${USERLAND}" == "Darwin" ] ; then > # NOT SURE THAT THIS WORKS!!! > # BSD developers please chekc > seconds=$(date -d "${date:0:4}-${date:4:2}-${date:6:2}" +"%s") > else > seconds=$(date -d "${date:0:4}-${date:4:2}-${date:6:2}" +"%s") > fi > > # > # Check that this snapshot > # is what it claims to be... > # > if [ ${snapshot_timestamp} -lt ${seconds} ] || \ > [ ${snapshot_timestamp} -gt $((${seconds}+ 2*86400)) ]; then > > echo "Warning: Snapshot timestamp is not in acceptable period." > have_files=0 > fi > fi > fi > > if [ ${have_files} != 0 ]; then > break; > else > # > # Remove files and use > # a diffeernt mirror > # > rm -f "${file}" "${digest}" "${signature}" > fi > done > > if [ ${have_files} != 0 ]; then > sync_local "${file}" && r=0 > else > echo "Warning: ${date} snapshot was not found." > fi > > rm -f "${file}" "${digest}" "${signature}" > return "${r}" >} > >do_latest_snapshot() { > local attempts=-1 > local r=1 > > echo "Fetching most recent snapshot..." > > while (( ${attempts} < 40 )) ; do > local day > local month > local year > local seconds > > attempts=$(( ${attempts} + 1 )) > > if [ "${USERLAND}" == "BSD" ] || [ "${USERLAND}" == "Darwin" ] ; then > local daysbefore=$(expr $(date +"%s") - 86400 \* ${attempts}) > day=$(date -r ${daysbefore} +"%d") > month=$(date -r ${daysbefore} +"%m") > year=$(date -r ${daysbefore} +"%Y") > > seconds="${daysbefore}" > else > day=$(date -d "-${attempts} day" +"%d") > month=$(date -d "-${attempts} day" +"%m") > year=$(date -d "-${attempts} day" +"%Y") > > seconds=$(date -d "${year}-${month}-${day}" +"%s") > fi > > if [ $seconds -lt $(($(get_portage_timestamp)-86400)) ]; then > echo "Note: Portage content is newer than available snapshots" > echo "use --revert option to overide." > r=0 > break; > fi > > if do_snapshot 0 "${year}${month}${day}"; then > r=0 > break; > fi > done > > return "${r}" >} > >main() { > local arg > local do_revert=0 > local revert_date > > [ ! -d "${DISTDIR}" ] && mkdir -p "${DISTDIR}" > cd "${DISTDIR}" > > for arg in $*; do > local v=${arg#*=} > case ${arg} in > --help) > echo "usage: $0 [options]" > echo " --verbose (-v) - verbose" > echo " --revert=yyyymmdd - revert to snapshot" > exit 0 > ;; > --verbose) > do_verbose=1 > ;; > -v) > do_verbose=1 > ;; > --revert=*) > do_revert=1 > revert_date=${v} > ;; > *) > echo "Error: Invalid arguments" > exit 1 > ;; > esac > done > > if [ ${do_revert} != 0 ]; then > do_snapshot 1 "${revert_date}" > else > do_latest_snapshot > fi >} > >main $* >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 130039
:
84701
|
84746
|
84790
|
100677
|
101532
|
115656
|
122073
|
122289
|
122290
|
127051