1. #!/bin/sh
  2.  
  3. # loffice-freetype.sh: skip downloading external freetype (for use with alien's
  4. # libreoffice.SlackBuild).
  5.  
  6. FILE=libreoffice.SlackBuild
  7. BACKUP=$FILE.orig
  8. FREETYPE_INDEX=$(sed -n 's/^SOURCE\[\([0-9]\{1,\}\)\]=.*freetype.*/\1/p' $FILE)
  9. LAST_INDEX=$(sed -n 's/^SOURCE\[\([0-9]\{1,\}\)\].*/\1/p' $FILE | tail -1)
  10.  
  11. # Create a backup of the SlackBuild:
  12. printf "Backup: "
  13. cp -v $FILE $BACKUP || exit 1
  14.  
  15. # Remove freetype from SOURCE and SRCURL arrays:
  16. sed -i "/^SOURCE\[$FREETYPE_INDEX\]=/,/^SRCURL\[$FREETYPE_INDEX\]=/d" $FILE
  17.  
  18. # Adjust the rest of the index numbers to fill the gap:
  19. for ((i=$FREETYPE_INDEX; i<=$LAST_INDEX; i++)); do
  20.   sed -i "/^SOURCE\[$i\]=/s/$i/$((i-1))/" $FILE
  21.   sed -i "/^SRCURL\[$i\]=/s/$i/$((i-1))/" $FILE
  22. done