emerge-webrsync and emerge-delta-webrsync: Stop using PORTDIR.
authorArfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org>
Tue, 16 Jul 2013 22:09:37 +0000 (00:09 +0200)
committerArfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org>
Tue, 16 Jul 2013 22:09:37 +0000 (00:09 +0200)
bin/emerge-webrsync
misc/emerge-delta-webrsync

index cd8653788878d38e072af67d87141933b0f7d912..6c8b240f6dbabc23a3ab7633032a482cf902eb4b 100755 (executable)
@@ -43,10 +43,16 @@ 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_RSYNC_OPTS PORTAGE_TMPDIR PORTDIR \
+       PORTAGE_RSYNC_OPTS PORTAGE_TMPDIR \
        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"
+       exit 1
+fi
+
 # If PORTAGE_NICENESS is overriden via the env then it will
 # still pass through the portageq call and override properly.
 if [ -n "${PORTAGE_NICENESS}" ]; then
@@ -112,8 +118,8 @@ get_utc_second_from_string() {
 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" )
+       if [ -f "${gentoo_repo_location}/metadata/timestamp.x" ]; then
+               portage_current_timestamp=$(cut -f 1 -d " " "${gentoo_repo_location}/metadata/timestamp.x" )
        fi
 
        echo "${portage_current_timestamp}"
@@ -200,19 +206,19 @@ sync_local() {
        if has usersync ${FEATURES} ; then
                case "${USERLAND}" in
                        BSD)
-                               ownership=$(stat -f '%Su:%Sg' "${PORTDIR}")
+                               ownership=$(stat -f '%Su:%Sg' "${gentoo_repo_location}")
                                ;;
                        *)
-                               ownership=$(stat -c '%U:%G' "${PORTDIR}")
+                               ownership=$(stat -c '%U:%G' "${gentoo_repo_location}")
                                ;;
                esac
        fi
 
        if type -P tarsync > /dev/null ; then
                local chown_opts="-o ${ownership%:*} -g ${ownership#*:}"
-               chown ${ownership} "${PORTDIR}" > /dev/null 2>&1 || chown_opts=""
+               chown ${ownership} "${gentoo_repo_location}" > /dev/null 2>&1 || chown_opts=""
                if ! tarsync $(vvecho -v) -s 1 ${chown_opts} \
-                       -e /distfiles -e /packages -e /local "${file}" "${PORTDIR}"; then
+                       -e /distfiles -e /packages -e /local "${file}" "${gentoo_repo_location}"; then
                        eecho "tarsync failed; tarball is corrupt? (${file})"
                        return 1
                fi
@@ -232,7 +238,7 @@ sync_local() {
                        rsync_opts+=" --owner --group"
                fi
                cd portage
-               rsync ${rsync_opts} . "${PORTDIR%%/}"
+               rsync ${rsync_opts} . "${gentoo_repo_location%%/}"
                cd ..
 
                __vecho "Cleaning up ..."
@@ -414,7 +420,7 @@ do_latest_snapshot() {
                                "snapshot. In order to force sync," \
                                "use the --revert option or remove" \
                                "the timestamp file located at" \
-                               "'${PORTDIR}/metadata/timestamp.x'." | fmt -w 70 | \
+                               "'${gentoo_repo_location}/metadata/timestamp.x'." | fmt -w 70 | \
                                while read -r line ; do
                                        ewarn "${line}"
                                done
@@ -468,9 +474,9 @@ main() {
                esac
        done
 
-       [[ -d ${PORTDIR} ]] || mkdir -p "${PORTDIR}"
-       if [[ ! -w ${PORTDIR} ]] ; then
-               eecho "PORTDIR is not writable: ${PORTDIR}"
+       [[ -d ${gentoo_repo_location} ]] || mkdir -p "${gentoo_repo_location}"
+       if [[ ! -w ${gentoo_repo_location} ]] ; then
+               eecho "Repository 'gentoo' is not writable: ${gentoo_repo_location}"
                exit 1
        fi
 
index 9c27702e3b264fbbebf244aa2ad7e5eb9ea2fbf9..d4e9b84be884e8881d32c4b0e18a985e2a8f301f 100755 (executable)
@@ -40,10 +40,16 @@ 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_RSYNC_OPTS PORTAGE_TMPDIR PORTDIR \
+       PORTAGE_RSYNC_OPTS PORTAGE_TMPDIR \
        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"
+       exit 1
+fi
+
 source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
 
 if [ -z "$NICENESS_PULLED" ]; then
@@ -109,9 +115,9 @@ if [ ${WEBSYNC_VERIFY_SIGNATURE} != 0 -a -z "${PORTAGE_GPG_DIR}" ]; then
        exit 1
 fi
 
-[[ -d ${PORTDIR} ]] || mkdir -p "${PORTDIR}"
-if [[ ! -w ${PORTDIR} ]] ; then
-       eecho "PORTDIR is not writable: ${PORTDIR}"
+[[ -d ${gentoo_repo_location} ]] || mkdir -p "${gentoo_repo_location}"
+if [[ ! -w ${gentoo_repo_location} ]] ; then
+       eecho "Repository 'gentoo' is not writable: ${gentoo_repo_location}"
        exit 1
 fi
 
@@ -193,8 +199,8 @@ get_utc_second_from_string() {
 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" )
+       if [ -f "${gentoo_repo_location}/metadata/timestamp.x" ]; then
+               portage_current_timestamp=$(cut -f 1 -d " " "${gentoo_repo_location}/metadata/timestamp.x" )
        fi
 
        echo "${portage_current_timestamp}"
@@ -293,19 +299,19 @@ sync_local() {
        if has usersync ${FEATURES} ; then
                case "${USERLAND}" in
                        BSD)
-                               ownership=$(stat -f '%Su:%Sg' "${PORTDIR}")
+                               ownership=$(stat -f '%Su:%Sg' "${gentoo_repo_location}")
                                ;;
                        *)
-                               ownership=$(stat -c '%U:%G' "${PORTDIR}")
+                               ownership=$(stat -c '%U:%G' "${gentoo_repo_location}")
                                ;;
                esac
        fi
 
        if type -P tarsync > /dev/null ; then
                local chown_opts="-o ${ownership%:*} -g ${ownership#*:}"
-               chown ${ownership} "${PORTDIR}" > /dev/null 2>&1 || chown_opts=""
+               chown ${ownership} "${gentoo_repo_location}" > /dev/null 2>&1 || chown_opts=""
                if ! tarsync $(__vecho -v) -s 1 ${chown_opts} \
-                       -e /distfiles -e /packages -e /local "${file}" "${PORTDIR}"; then
+                       -e /distfiles -e /packages -e /local "${file}" "${gentoo_repo_location}"; then
                        eecho "tarsync failed; tarball is corrupt? (${file})"
                        return 1
                fi
@@ -322,7 +328,7 @@ sync_local() {
                        rsync_opts+=" --owner --group"
                fi
                cd "${TMPDIR}"/portage
-               rsync ${rsync_opts} . "${PORTDIR%%/}"
+               rsync ${rsync_opts} . "${gentoo_repo_location%%/}"
                cd "${DISTDIR}"
 
                __vecho "Cleaning up ..."
@@ -498,7 +504,7 @@ do_latest_snapshot() {
                                "snapshot. In order to force sync," \
                                "use the --revert option or remove" \
                                "the timestamp file located at" \
-                               "'${PORTDIR}/metadata/timestamp.x'." | fmt -w 70 | \
+                               "'${gentoo_repo_location}/metadata/timestamp.x'." | fmt -w 70 | \
                                while read -r line ; do
                                        ewarn "${line}"
                                done