Update
This commit is contained in:
		
							parent
							
								
									f74485ce66
								
							
						
					
					
						commit
						0ca9d95fa1
					
				| 
						 | 
				
			
			@ -5,3 +5,4 @@
 | 
			
		|||
pkg/
 | 
			
		||||
src/
 | 
			
		||||
.idea/
 | 
			
		||||
refind-theme-lera-sugar
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										9
									
								
								PKGBUILD
								
								
								
								
							
							
						
						
									
										9
									
								
								PKGBUILD
								
								
								
								
							| 
						 | 
				
			
			@ -2,7 +2,7 @@
 | 
			
		|||
 | 
			
		||||
_gitname="$(basename $(pwd))"
 | 
			
		||||
pkgname=("melawy-$_gitname")
 | 
			
		||||
pkgver=r4.823ce12
 | 
			
		||||
pkgver=1.5
 | 
			
		||||
pkgrel=1
 | 
			
		||||
pkgdesc="$(head -n 2 README.md | tail -n 1)"
 | 
			
		||||
url="https://github.com/Melawy/$_gitname"
 | 
			
		||||
| 
						 | 
				
			
			@ -22,9 +22,14 @@ THEME_PATH="/usr/share/refind/themes"
 | 
			
		|||
 | 
			
		||||
install=$pkgname.install
 | 
			
		||||
 | 
			
		||||
# pkgver() {
 | 
			
		||||
# 	cd "$srcdir/$_gitname"
 | 
			
		||||
# 	printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
 | 
			
		||||
# }
 | 
			
		||||
 | 
			
		||||
pkgver() {
 | 
			
		||||
	cd "$srcdir/$_gitname"
 | 
			
		||||
	printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
 | 
			
		||||
	printf "1.%s" "$(git rev-list --count HEAD)"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
package() {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,100 @@
 | 
			
		|||
post_install() {
 | 
			
		||||
  THEME_NAME="melawy-lera-sugar"
 | 
			
		||||
  local install_dir="/usr/share/refind/themes/$THEME_NAME"
 | 
			
		||||
 | 
			
		||||
  echo "Searching rEFInd installation in EFI partition..."
 | 
			
		||||
  if ! __has_esp__; then
 | 
			
		||||
    echo "EFI partition not found" >&2
 | 
			
		||||
    exit 1
 | 
			
		||||
  fi
 | 
			
		||||
 | 
			
		||||
  REFIND_DIR=$(find "$ESP" -type d -iname refind)
 | 
			
		||||
  if ! [[ -d "${REFIND_DIR}" ]]; then
 | 
			
		||||
    echo "rEFInd not installed in $ESP" >&2
 | 
			
		||||
    exit 1
 | 
			
		||||
  fi
 | 
			
		||||
  echo "Found rEFInd in ${REFIND_DIR}"
 | 
			
		||||
 | 
			
		||||
  echo "Installing theme in ${REFIND_DIR}/themes"
 | 
			
		||||
  cd ${install_dir}
 | 
			
		||||
  install -D -m0644 -t "${REFIND_DIR}/themes/$THEME_NAME/" *.conf
 | 
			
		||||
  find . -exec install -D {} "${REFIND_DIR}/themes/$THEME_NAME/{}" \;
 | 
			
		||||
 | 
			
		||||
  REFIND_CONF_PATH="${REFIND_DIR}/refind.conf"
 | 
			
		||||
  EFI_THEME_PATH="${REFIND_DIR}/themes"
 | 
			
		||||
 | 
			
		||||
  RESULT=$(grep "theme" $REFIND_CONF_PATH)
 | 
			
		||||
 | 
			
		||||
  if [[ "$?" = "0" ]]; then
 | 
			
		||||
    CURRENT_THEME=$(echo $RESULT | cut -d"/" -f2)
 | 
			
		||||
    if [[ "$?" = "0" ]]; then
 | 
			
		||||
      sed -e "s/$CURRENT_THEME/$THEME_NAME/g" -i $REFIND_CONF_PATH
 | 
			
		||||
    fi
 | 
			
		||||
  else
 | 
			
		||||
    if [[ -z "$(tail -n 1 -c 1 $REFIND_CONF_PATH)" ]];then
 | 
			
		||||
      echo "include themes/$THEME_NAME/theme.conf" >> $REFIND_CONF_PATH
 | 
			
		||||
    else
 | 
			
		||||
      echo -e "\ninclude themes/$THEME_NAME/theme.conf" >> $REFIND_CONF_PATH
 | 
			
		||||
    fi
 | 
			
		||||
  fi
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
post_upgrade() {
 | 
			
		||||
  post_install
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
post_remove() {
 | 
			
		||||
  THEME_NAME="melawy-lera-sugar"
 | 
			
		||||
 | 
			
		||||
  echo "Removal of theme from EFI partition"
 | 
			
		||||
 | 
			
		||||
  echo "Searching rEFInd installation in EFI partition..."
 | 
			
		||||
  if ! __has_esp__; then
 | 
			
		||||
    echo "EFI partition not found" >&2
 | 
			
		||||
    exit 1
 | 
			
		||||
  fi
 | 
			
		||||
 | 
			
		||||
  REFIND_DIR=$(find "$ESP" -type d -iname refind)
 | 
			
		||||
  if ! [[ -d "${REFIND_DIR}" ]]; then
 | 
			
		||||
    echo "rEFInd not installed in $ESP" >&2
 | 
			
		||||
    exit 1
 | 
			
		||||
  fi
 | 
			
		||||
  echo "Found rEFInd in ${REFIND_DIR}"
 | 
			
		||||
 | 
			
		||||
  REFIND_CONF_PATH="${REFIND_DIR}/refind.conf"
 | 
			
		||||
  sed -i "/$THEME_NAME/d" $REFIND_CONF_PATH
 | 
			
		||||
 | 
			
		||||
  if ! [[ -d "${REFIND_DIR}/themes/$THEME_NAME" ]]; then
 | 
			
		||||
    echo "Theme already uninstalled"
 | 
			
		||||
    exit 0
 | 
			
		||||
  fi
 | 
			
		||||
 | 
			
		||||
  rm -r "${REFIND_DIR}/themes/$THEME_NAME"
 | 
			
		||||
  echo "Theme uninstalled from ${REFIND_DIR}/themes/$THEME_NAME"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# Copied from https://github.com/jaltuna/sbmok/master/verify.sh
 | 
			
		||||
# Verify EFI System Partition
 | 
			
		||||
__has_esp__() {
 | 
			
		||||
  __find_esp__
 | 
			
		||||
 | 
			
		||||
  mount "$ESP" &>/dev/null
 | 
			
		||||
  [[ -d "$ESP/EFI" ]] && return 0 || return 1
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
__find_esp__() {
 | 
			
		||||
  local parttype
 | 
			
		||||
  local fstype
 | 
			
		||||
  local device
 | 
			
		||||
 | 
			
		||||
  while read -r device; do
 | 
			
		||||
    read -r parttype fstype ESP <<<"$(lsblk -o "PARTTYPE,FSTYPE,MOUNTPOINT" "$device" 2>/dev/null | awk 'NR==2')"
 | 
			
		||||
 | 
			
		||||
    [[ "${parttype,,}" != "c12a7328-f81f-11d2-ba4b-00a0c93ec93b" ]] && continue
 | 
			
		||||
    [[ "${fstype,,}" != "vfat" ]] && continue
 | 
			
		||||
    [[ -z $(findmnt -sn "$ESP") ]] && continue
 | 
			
		||||
 | 
			
		||||
  done <<<"$(fdisk -l 2>/dev/null | grep -i efi | cut -d " " -f 1)"
 | 
			
		||||
 | 
			
		||||
  readonly ESP
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
		Reference in New Issue