summarylogtreecommitdiffstats
path: root/geant4-full-debug.install
blob: bc082a4f2780f999ea7e6b75621d3734776c52f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
pre_upgrade(){
  G4LIBRARY_PATH=/opt/Geant4/Libraries
  G4LIBRARY_BACKUP=/opt/Geant4/Lib-backup
  file_check=/tmp/.G4_Library.tmp
  [ "$(ls -A $G4LIBRARY_PATH)" ] && mv $G4LIBRARY_PATH $G4LIBRARY_BACKUP && touch $file_check
}

post_upgrade(){
  G4LIBRARY_PATH=/opt/Geant4/Libraries
  G4LIBRARY_BACKUP=/opt/Geant4/Lib-backup
  file_check=/tmp/.G4_Library.tmp
  [ "$(ls $file_check)" ] && mkdir -p $G4LIBRARY_PATH && mv $G4LIBRARY_BACKUP/* $G4LIBRARY_PATH && rmdir $G4LIBRARY_BACKUP && rm $file_check

  #TODO: need to automatically cleanup old libraries from the Library folder

  PREVFILE=NONE
  PREVFILEBASE=NONE

  for file in $(ls /opt/Geant4/Libraries)
  do
      CURRFILEBASE=$(echo $file | sed -e "s/[0-9]*.[0-9]$//")
      CURRFILE=$file
      if [[ $CURRFILEBASE == $PREVFILEBASE ]]
      then
          sudo rm -Rf /opt/Geant4/Libraries/$PREVFILE && echo "removing old $PREVFILE"
      fi
      PREVFILE=$CURRFILE
      PREVFILEBASE=$CURRFILEBASE
      #echo "$CURRFILE $CURRFILEBASE $PREVFILE $PREVFILEBASE"
  done

}

post_install(){
  ln -s /usr/include/Geant4/CLHEP /usr/include/CLHEP
  ln -s /usr/include/Geant4/PTL /usr/include/PTL

#the following should not run when in PKGBUILD  geant4-full conflicts with geant4-full-debug
#  if [[ "$( pacman -Qq geant4-full )" == "geant4-full" ]]
#  echo "you have installed both geant4-full and geant4-full-debug"
#  echo "please check for PATH conflicts in /etc/profile.d/Geant4-debug.c/sh and /etc/profile.d/Geant4.c/sh"
#  fi
}

pre_remove(){
  echo "Backing up Geant4 Libraries. To remove them, please run\n $ sudo rm -Rf /opt/Geant4/Libraries"
  mv /opt/Geant4/Libraries /opt/Geant4/Lib-backup
}

post_remove(){
  rm /usr/include/CLHEP
  rm /usr/include/PTL
}