File hardlink_duplicates.sh of Package eclipse-archdep

# hardlink duplicates:
# add files that should not be hardlinked here:
function hardlink_duplicates() {
  IFS="
"
  # get all duplicates:
  for dup in $(fdupes -r -n -1 .)
  do
    IFS="
";
    # handle each duplicate-tuple
    for file in $dup
    do
      # the first file will be taken as the original file
      if [ -z "$ORIG_FILE" ]
      then
        ORIG_FILE=$file;
      else
        # test, whether file is on the ignore list:
        if [ -n "$IGNORE_FILENAMES" ]
        then
          for ignorefile in "$IGNORE_FILENAMES"
          do
            if  echo "$ORIG_FILE" | grep "$ignorefile" || echo "$file" | grep "$ignorefile"
            then
              printf '%%-55s -> %s                -- #IGNORED\n' $ORIG_FILE $file >> %{_builddir}/HARDLINKS.txt
              IGNORE=true
            fi
            break
          done
        fi
        if [ "$IGNORE" = false ]
        then
          # link file
          ln -f $ORIG_FILE $file;
          printf '%%-65s -> %s\n' $ORIG_FILE $file >> %{_builddir}/HARDLINKS.txt
        fi
        IGNORE=false
      fi;
    done;
    ORIG_FILE="";
    IFS="
";
  done
  IFS="
"
}
openSUSE Build Service is sponsored by