diff options
author | Jorge Manuel B. S. Vicetto (jmbsvicetto) <jmbsvicetto@gentoo.org> | 2008-10-06 22:23:23 +0000 |
---|---|---|
committer | Jorge Manuel B. S. Vicetto (jmbsvicetto) <jmbsvicetto@gentoo.org> | 2008-10-06 22:23:23 +0000 |
commit | 88baf420f3cf85ab303d586dbdb2428e35b84ac8 (patch) | |
tree | 4751b71e05b5de27f31e2406e781cd5e53137688 /scripts | |
parent | Removed kde ebuilds as the work was moved to the kde overlay. (diff) | |
download | jmbsvicetto-88baf420f3cf85ab303d586dbdb2428e35b84ac8.tar.gz jmbsvicetto-88baf420f3cf85ab303d586dbdb2428e35b84ac8.tar.bz2 jmbsvicetto-88baf420f3cf85ab303d586dbdb2428e35b84ac8.zip |
Added some scripts to the repo.
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/change_slot | 78 | ||||
-rwxr-xr-x | scripts/change_slot_first | 103 |
2 files changed, 181 insertions, 0 deletions
diff --git a/scripts/change_slot b/scripts/change_slot new file mode 100755 index 0000000..02514c9 --- /dev/null +++ b/scripts/change_slot @@ -0,0 +1,78 @@ +# +# 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 "change - really change? [Y] to apply" + exit +} + +# Change slot +change_slot () { + sed -e "s/^${OLD_SLOT}$/${NEW_SLOT}/" "${package}/SLOT" + + if [[ ${CHANGE} == "Y" ]]; then + sed -i -e "s/^${OLD_SLOT}$/${NEW_SLOT}/" "${package}/SLOT" + fi +} + +# Run the vdb +run_vdb() { + + # Get categories from the VDB + categories=$(find "${VDBDIR}" -mindepth 1 -maxdepth 1 -type d) + for category in ${categories[@]}; do + + # For each category + packages=$(find "${category}" -mindepth 1 -maxdepth 1 -type d) + for package in ${packages[@]}; do + + # If package was installed from the repo + name=$(cat ${package}/repository) + if [[ "${name}" == "${REPO}" ]]; then + echo "package: ${package} - matches ${REPO}" + change_slot + fi + done + done +} + + +############### +# Get options and commands +############### +[[ -z "$*" ]] && show_options + +SCRIPT_ARGS="$*" +REPO="${1}" +OLD_SLOT="${2}" +NEW_SLOT="${3}" +CHANGE="${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})" + +run_vdb 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[@]}" |