summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJorge Manuel B. S. Vicetto (jmbsvicetto) <jmbsvicetto@gentoo.org>2008-10-06 22:23:23 +0000
committerJorge Manuel B. S. Vicetto (jmbsvicetto) <jmbsvicetto@gentoo.org>2008-10-06 22:23:23 +0000
commit88baf420f3cf85ab303d586dbdb2428e35b84ac8 (patch)
tree4751b71e05b5de27f31e2406e781cd5e53137688 /scripts/change_slot_first
parentRemoved kde ebuilds as the work was moved to the kde overlay. (diff)
downloadjmbsvicetto-88baf420f3cf85ab303d586dbdb2428e35b84ac8.tar.gz
jmbsvicetto-88baf420f3cf85ab303d586dbdb2428e35b84ac8.tar.bz2
jmbsvicetto-88baf420f3cf85ab303d586dbdb2428e35b84ac8.zip
Added some scripts to the repo.
Diffstat (limited to 'scripts/change_slot_first')
-rwxr-xr-xscripts/change_slot_first103
1 files changed, 103 insertions, 0 deletions
diff --git a/scripts/change_slot_first b/scripts/change_slot_first
new file mode 100755
index 0000000..a324dc6
--- /dev/null
+++ b/scripts/change_slot_first
@@ -0,0 +1,103 @@
+#
+# change_slot script
+#
+# 2008/10/05
+# Jorge Manuel B. S. Vicetto (jmbsvicetto@gentoo.org)
+
+
+###############
+# Constants
+###############
+VDBDIR=$(portageq vdb_path)
+
+
+###############
+# Functions
+###############
+
+# Show options screen
+show_options () {
+
+# Present options
+ echo "Usage: $0 repo old_slot new_slot"
+ echo "repo - The repo name as specified in ${repo}/profiles/repo_name"
+ echo "old_slot - The slot to be replaced"
+ echo "new_slot - The new slot to use"
+ echo "inst_version - Installed package version to update the slot"
+ exit
+}
+
+# Find repo path
+find_repo () {
+
+ for overlay in $(portageq portdir_overlay | tr ' ' '\n'); do
+ path=$(grep -H ${REPO} ${overlay}/profiles/repo_name 2>/dev/null)
+ if [[ ${path} =~ "${REPO}" ]]; then
+ repo_path=${path%/profiles/repo_name:${REPO}}
+ fi
+ done
+}
+
+# Get repo categories
+read_categories () {
+ while read category; do
+ categories=( "${categories[@]}" "${category}" )
+ done < "${repo_path}/profiles/categories"
+}
+
+# Change slot
+change_slot () {
+ for category in ${categories[@]}; do
+ # For each category, read the list of packages
+ packages=$(find "${repo_path}/${category}" -mindepth 1 -maxdepth 1 -type d)
+# echo "category ${category} has ${packages[@]}"
+
+ # For each package, change the slot
+ for dir in ${packages[@]}; do
+ package=$(basename ${dir})
+ files=$(find "${repo_path}/${category}/${package}/" -iname "${package}*.ebuild")
+
+ # skip category/packages without ebuilds
+ if [[ ${files} != "" ]]; then
+ # for each file (there might be more than one ebuild
+ for file in ${files[@]}; do
+
+ if [[ "${INST_VERSION}" == "" ]]; then
+ version=$(basename ${file})
+ version=${version%.ebuild}
+ version=${version%-r*}
+ else
+ version=${package}-${INST_VERSION}
+ fi
+
+ sed -e "s/^${OLD_SLOT}$/${NEW_SLOT}/" "${VDBDIR}/${category}/${version}/SLOT"
+# sed -i -e "s/^${OLD_SLOT}$/${NEW_SLOT}/" "${VDBDIR}/${category}/${version}/SLOT"
+ done
+ fi
+ done
+ done
+}
+
+
+###############
+# Get options and commands
+###############
+[[ -z "$*" ]] && show_options
+
+SCRIPT_ARGS="$*"
+REPO="${1}"
+OLD_SLOT="${2}"
+NEW_SLOT="${3}"
+INST_VERSION="${4}"
+
+if ([[ -z "${REPO}" ]] || [[ -z "${OLD_SLOT}" ]] || [[ -z "${NEW_SLOT}" ]]); then
+ show_options
+fi
+
+echo "You've asked to update all packages from repo ${REPO} in ${VDBDIR} by changing the old_slot (${OLD_SLOT}) to new_slot (${NEW_SLOT})"
+
+find_repo
+read_categories
+change_slot
+
+#echo "categories: ${categories[@]}"