emerge-webrsync: use PORTAGE_REPOSITORIES var
authorZac Medico <zmedico@gentoo.org>
Mon, 22 Jul 2013 19:04:22 +0000 (12:04 -0700)
committerZac Medico <zmedico@gentoo.org>
Mon, 22 Jul 2013 19:04:22 +0000 (12:04 -0700)
Using this variable allows us to get all required configuration data
with a singe portageq envvar call.

bin/emerge-webrsync
misc/emerge-delta-webrsync
pym/portage/package/ebuild/config.py
pym/portage/package/ebuild/doebuild.py

index 6c8b240f6dbabc23a3ab7633032a482cf902eb4b..261e7df687a1275f35f97703d7de444fcf808b84 100755 (executable)
@@ -39,17 +39,20 @@ else
        eecho "could not find 'portageq'; aborting"
        exit 1
 fi
-eval $("${portageq}" envvar -v DISTDIR EPREFIX FEATURES \
+eval "$("${portageq}" envvar -v DISTDIR EPREFIX FEATURES \
        FETCHCOMMAND GENTOO_MIRRORS \
        PORTAGE_BIN_PATH PORTAGE_CONFIGROOT PORTAGE_GPG_DIR \
-       PORTAGE_NICENESS PORTAGE_RSYNC_EXTRA_OPTS \
+       PORTAGE_NICENESS PORTAGE_REPOSITORIES PORTAGE_RSYNC_EXTRA_OPTS \
        PORTAGE_RSYNC_OPTS PORTAGE_TMPDIR \
-       SYNC USERLAND http_proxy ftp_proxy)
+       SYNC USERLAND http_proxy ftp_proxy)"
 export http_proxy ftp_proxy
 
-gentoo_repo_location=$("${portageq}" get_repo_path "${EPREFIX}/" gentoo)
-if [[ -z ${gentoo_repo_location} ]]; then
-       eecho "Repository 'gentoo' not found"
+source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
+
+repo_name=gentoo
+repo_location=$(__repo_key "${repo_name}" location)
+if [[ -z ${repo_location} ]]; then
+       eecho "Repository '${repo_name}' not found"
        exit 1
 fi
 
@@ -59,8 +62,6 @@ if [ -n "${PORTAGE_NICENESS}" ]; then
        renice $PORTAGE_NICENESS $$ > /dev/null
 fi
 
-source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
-
 do_verbose=0
 do_debug=0
 keep=false
@@ -118,8 +119,8 @@ get_utc_second_from_string() {
 get_portage_timestamp() {
        local portage_current_timestamp=0
 
-       if [ -f "${gentoo_repo_location}/metadata/timestamp.x" ]; then
-               portage_current_timestamp=$(cut -f 1 -d " " "${gentoo_repo_location}/metadata/timestamp.x" )
+       if [ -f "${repo_location}/metadata/timestamp.x" ]; then
+               portage_current_timestamp=$(cut -f 1 -d " " "${repo_location}/metadata/timestamp.x" )
        fi
 
        echo "${portage_current_timestamp}"
@@ -206,19 +207,19 @@ sync_local() {
        if has usersync ${FEATURES} ; then
                case "${USERLAND}" in
                        BSD)
-                               ownership=$(stat -f '%Su:%Sg' "${gentoo_repo_location}")
+                               ownership=$(stat -f '%Su:%Sg' "${repo_location}")
                                ;;
                        *)
-                               ownership=$(stat -c '%U:%G' "${gentoo_repo_location}")
+                               ownership=$(stat -c '%U:%G' "${repo_location}")
                                ;;
                esac
        fi
 
        if type -P tarsync > /dev/null ; then
                local chown_opts="-o ${ownership%:*} -g ${ownership#*:}"
-               chown ${ownership} "${gentoo_repo_location}" > /dev/null 2>&1 || chown_opts=""
+               chown ${ownership} "${repo_location}" > /dev/null 2>&1 || chown_opts=""
                if ! tarsync $(vvecho -v) -s 1 ${chown_opts} \
-                       -e /distfiles -e /packages -e /local "${file}" "${gentoo_repo_location}"; then
+                       -e /distfiles -e /packages -e /local "${file}" "${repo_location}"; then
                        eecho "tarsync failed; tarball is corrupt? (${file})"
                        return 1
                fi
@@ -238,7 +239,7 @@ sync_local() {
                        rsync_opts+=" --owner --group"
                fi
                cd portage
-               rsync ${rsync_opts} . "${gentoo_repo_location%%/}"
+               rsync ${rsync_opts} . "${repo_location%%/}"
                cd ..
 
                __vecho "Cleaning up ..."
@@ -420,7 +421,7 @@ do_latest_snapshot() {
                                "snapshot. In order to force sync," \
                                "use the --revert option or remove" \
                                "the timestamp file located at" \
-                               "'${gentoo_repo_location}/metadata/timestamp.x'." | fmt -w 70 | \
+                               "'${repo_location}/metadata/timestamp.x'." | fmt -w 70 | \
                                while read -r line ; do
                                        ewarn "${line}"
                                done
@@ -474,9 +475,9 @@ main() {
                esac
        done
 
-       [[ -d ${gentoo_repo_location} ]] || mkdir -p "${gentoo_repo_location}"
-       if [[ ! -w ${gentoo_repo_location} ]] ; then
-               eecho "Repository 'gentoo' is not writable: ${gentoo_repo_location}"
+       [[ -d ${repo_location} ]] || mkdir -p "${repo_location}"
+       if [[ ! -w ${repo_location} ]] ; then
+               eecho "Repository '${repo_name}' is not writable: ${repo_location}"
                exit 1
        fi
 
index d4e9b84be884e8881d32c4b0e18a985e2a8f301f..b16982bb71a968117534c63cbc5451aeb427f717 100755 (executable)
@@ -36,22 +36,23 @@ else
        eecho "could not find 'portageq'; aborting"
        exit 1
 fi
-eval $("${portageq}" envvar -v DISTDIR EPREFIX FEATURES \
+eval "$("${portageq}" envvar -v DISTDIR EPREFIX FEATURES \
        FETCHCOMMAND GENTOO_MIRRORS \
        PORTAGE_BIN_PATH PORTAGE_CONFIGROOT PORTAGE_GPG_DIR \
-       PORTAGE_NICENESS PORTAGE_RSYNC_EXTRA_OPTS \
+       PORTAGE_NICENESS PORTAGE_REPOSITORIES PORTAGE_RSYNC_EXTRA_OPTS \
        PORTAGE_RSYNC_OPTS PORTAGE_TMPDIR \
-       USERLAND http_proxy ftp_proxy)
+       USERLAND http_proxy ftp_proxy)"
 export http_proxy ftp_proxy
 
-gentoo_repo_location=$("${portageq}" get_repo_path "${EPREFIX}/" gentoo)
-if [[ -z ${gentoo_repo_location} ]]; then
-       eecho "Repository 'gentoo' not found"
+source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 
+
+repo_name=gentoo
+repo_location=$(__repo_key "${repo_name}" location)
+if [[ -z ${repo_location} ]]; then
+       eecho "Repository '${repo_name}' not found"
        exit 1
 fi
 
-source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
-
 if [ -z "$NICENESS_PULLED" ]; then
        if [ -n "${PORTAGE_NICENESS}" ]; then
                export NICENESS_PULLED=asdf
@@ -115,9 +116,9 @@ if [ ${WEBSYNC_VERIFY_SIGNATURE} != 0 -a -z "${PORTAGE_GPG_DIR}" ]; then
        exit 1
 fi
 
-[[ -d ${gentoo_repo_location} ]] || mkdir -p "${gentoo_repo_location}"
-if [[ ! -w ${gentoo_repo_location} ]] ; then
-       eecho "Repository 'gentoo' is not writable: ${gentoo_repo_location}"
+[[ -d ${repo_location} ]] || mkdir -p "${repo_location}"
+if [[ ! -w ${repo_location} ]] ; then
+       eecho "Repository '${repo_name}' is not writable: ${repo_location}"
        exit 1
 fi
 
@@ -199,8 +200,8 @@ get_utc_second_from_string() {
 get_portage_timestamp() {
        local portage_current_timestamp=0
 
-       if [ -f "${gentoo_repo_location}/metadata/timestamp.x" ]; then
-               portage_current_timestamp=$(cut -f 1 -d " " "${gentoo_repo_location}/metadata/timestamp.x" )
+       if [ -f "${repo_location}/metadata/timestamp.x" ]; then
+               portage_current_timestamp=$(cut -f 1 -d " " "${repo_location}/metadata/timestamp.x" )
        fi
 
        echo "${portage_current_timestamp}"
@@ -299,19 +300,19 @@ sync_local() {
        if has usersync ${FEATURES} ; then
                case "${USERLAND}" in
                        BSD)
-                               ownership=$(stat -f '%Su:%Sg' "${gentoo_repo_location}")
+                               ownership=$(stat -f '%Su:%Sg' "${repo_location}")
                                ;;
                        *)
-                               ownership=$(stat -c '%U:%G' "${gentoo_repo_location}")
+                               ownership=$(stat -c '%U:%G' "${repo_location}")
                                ;;
                esac
        fi
 
        if type -P tarsync > /dev/null ; then
                local chown_opts="-o ${ownership%:*} -g ${ownership#*:}"
-               chown ${ownership} "${gentoo_repo_location}" > /dev/null 2>&1 || chown_opts=""
+               chown ${ownership} "${repo_location}" > /dev/null 2>&1 || chown_opts=""
                if ! tarsync $(__vecho -v) -s 1 ${chown_opts} \
-                       -e /distfiles -e /packages -e /local "${file}" "${gentoo_repo_location}"; then
+                       -e /distfiles -e /packages -e /local "${file}" "${repo_location}"; then
                        eecho "tarsync failed; tarball is corrupt? (${file})"
                        return 1
                fi
@@ -328,7 +329,7 @@ sync_local() {
                        rsync_opts+=" --owner --group"
                fi
                cd "${TMPDIR}"/portage
-               rsync ${rsync_opts} . "${gentoo_repo_location%%/}"
+               rsync ${rsync_opts} . "${repo_location%%/}"
                cd "${DISTDIR}"
 
                __vecho "Cleaning up ..."
@@ -504,7 +505,7 @@ do_latest_snapshot() {
                                "snapshot. In order to force sync," \
                                "use the --revert option or remove" \
                                "the timestamp file located at" \
-                               "'${gentoo_repo_location}/metadata/timestamp.x'." | fmt -w 70 | \
+                               "'${repo_location}/metadata/timestamp.x'." | fmt -w 70 | \
                                while read -r line ; do
                                        ewarn "${line}"
                                done
index 6871bdf0dc57d5b8da7eb34ed67db76ac044c448..7a359dbe9b84ea803cb7a7c025c20ffa85bd5ed6 100644 (file)
@@ -509,6 +509,9 @@ class config(object):
                        else:
                                self.repositories = repositories
 
+                       self['PORTAGE_REPOSITORIES'] = self.repositories.config_string()
+                       self.backup_changes('PORTAGE_REPOSITORIES')
+
                        #filling PORTDIR and PORTDIR_OVERLAY variable for compatibility
                        main_repo = self.repositories.mainRepo()
                        if main_repo is not None:
index 00159a5d248e734419c36f59802a57a763cc485e..667280ecd25d9f4faf7aa14d6a7a173f4696aeb3 100644 (file)
@@ -306,7 +306,6 @@ def doebuild_environment(myebuild, mydo, myroot=None, settings=None,
                repo = mydbapi.repositories.get_repo_for_location(mytree)
                mysettings['PORTDIR'] = repo.eclass_db.porttrees[0]
                mysettings['PORTAGE_ECLASS_LOCATIONS'] = repo.eclass_db.eclass_locations_string
-               mysettings['PORTAGE_REPOSITORIES'] = mydbapi.repositories.config_string()
                mysettings.configdict["pkg"]["PORTAGE_REPO_NAME"] = repo.name
 
        mysettings["PORTDIR"] = os.path.realpath(mysettings["PORTDIR"])