Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Step:FrontRunner
libreoffice-share-linker
link-to-ooo-home
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File link-to-ooo-home of Package libreoffice-share-linker
#!/usr/bin/env bash usage() { echo "This script (un)links or unlinks the given to/from libreoffice home" echo echo "Usage: ${0##*/} [--unlink] filelist" } change_linking() { local libdir="$1" local filelist="$2" local linkfile="" local linkdir="" # Decide if we are linking or wiping first if ${link_mode}; then # Grab all files from the proper folder for file in `cat ${filelist} | grep "/usr/share/libreoffice" | sort`; do # if we get ourselves folder then just create it # it might not be around so lets be safe if [[ -d "${file}" ]] ; then dirname="${file/${datadir}/${libdir}}" # if the location is already there skip it if [[ ! -e "${dirname}" ]]; then mkdir -p "${dirname}" chmod --reference="${file}" "${dirname}" fi continue fi linkfile="${file/${datadir}/${libdir}}" # if the file is already there, skip it # this is true when the parent folder is link if [[ ! -e "${linkfile}" ]]; then ln -sf "${file}" "${linkfile}" || exit 1 fi done else # first just remove the symlinks for file in `cat ${filelist} | grep "/usr/share/libreoffice" | sort`; do linkfile=${file/${datadir}/${libdir}} if [[ -L "${linkfile}" && ! -r "${linkfile}" && ! -d "${linkfile}" ]]; then rm -f "${linkfile}" || exit 1 fi done # continue by wiping out all EMPTY dirs # we have to be sure it is not owned by anything else # doing in 2nd run to ensure avoiding collisions for file in `cat ${filelist} | grep "/usr/share/libreoffice" | sort`; do linkdir="${file/${datadir}/${libdir}}" if [[ -d "${linkdir}" && -z `ls "${linkdir}"/* 2>/dev/null` ]]; then # check if nothing else owns the dir if [[ $(rpm -qf "${file}" 2>/dev/null |wc -l) == 0 ]]; then rmdir "${linkdir}" || exit 1 fi fi done leftover_dirs=" /usr/share/libreoffice/help /usr/share/libreoffice/program /usr/share/libreoffice/share /usr/share/libreoffice " for i in ${leftover_dirs}; do if [[ -d ${i} && ! "$(ls -A ${i})" ]]; then rmdir "${i}" || exit 1 fi done fi } # Global VARS link_mode=true datadir=/usr/share libdirs=( "/usr/lib/" "/usr/lib64/" "/usr/lib32/" ) if [[ "$1" == "--unlink" ]]; then link_mode=false shift fi if [[ "$1" == "--help" ]]; then usage exit 0 fi # Verify we have just one left argument which is the filelist if [[ $# > 1 || ! -f "$1" ]]; then usage exit 1 fi for libdir in ${libdirs[@]}; do # for each dir verify there is libreoffice folder, otherwise skip if [[ ! -d "${libdir}/libreoffice/" ]]; then continue fi change_linking ${libdir} $1 # remove dangling links as they might happen when migratin from older # libreoffice versions find ${libdir}/libreoffice -type l -xtype l -delete done
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor