/ programs / x86_64 / kdenlive
kdenlive
  1  #!/bin/sh
  2  
  3  # AM INSTALL SCRIPT VERSION 3.5
  4  set -u
  5  APP=kdenlive
  6  SITE="https://kdenlive.org"
  7  
  8  # CREATE DIRECTORIES AND ADD REMOVER
  9  [ -n "$APP" ] && mkdir -p "/opt/$APP/tmp" "/opt/$APP/icons" && cd "/opt/$APP/tmp" || exit 1
 10  printf "#!/bin/sh\nset -e\nrm -f /usr/local/bin/$APP\nrm -R -f /opt/$APP" > ../remove
 11  printf '\n%s' "rm -f /usr/local/share/applications/$APP-AM.desktop" >> ../remove
 12  chmod a+x ../remove || exit 1
 13  
 14  # DOWNLOAD AND PREPARE THE APP, $version is also used for updates
 15  version=$(curl -Ls https://kdenlive.org/en/download/ | grep -Eo "(http|https)://[a-zA-Z0-9./?=_%:-]*" | grep AppImage | head -1)
 16  wget "$version" || exit 1
 17  # Keep this space in sync with other installation scripts
 18  # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded.
 19  cd ..
 20  mv ./tmp/*mage ./"$APP"
 21  # Keep this space in sync with other installation scripts
 22  rm -R -f ./tmp || exit 1
 23  echo "$version" > ./version
 24  chmod a+x ./"$APP" || exit 1
 25  
 26  # LINK TO PATH
 27  ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP"
 28  
 29  # SCRIPT TO UPDATE THE PROGRAM
 30  cat >> ./AM-updater << 'EOF'
 31  #!/bin/sh
 32  set -u
 33  APP=kdenlive
 34  SITE="https://kdenlive.org"
 35  version0=$(cat "/opt/$APP/version")
 36  version=$(curl -Ls https://kdenlive.org/en/download/ | grep -Eo "(http|https)://[a-zA-Z0-9./?=_%:-]*" | grep AppImage | head -1)
 37  [ -n "$version" ] || { echo "Error getting link"; exit 1; }
 38  if command -v appimageupdatetool >/dev/null 2>&1; then
 39  	cd "/opt/$APP" || exit 1
 40  	appimageupdatetool -Or ./"$APP" && chmod a+x ./"$APP" && echo "$version" > ./version && exit 0
 41  fi
 42  if [ "$version" != "$version0" ]; then
 43  	mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1
 44  	notify-send "A new version of $APP is available, please wait"
 45  	wget "$version" || exit 1
 46  	# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded.
 47  	cd ..
 48  	mv --backup=t ./tmp/*mage ./"$APP"
 49  	chmod a+x ./"$APP" || exit 1
 50  	echo "$version" > ./version
 51  	rm -R -f ./*zs-old ./*.part ./tmp ./*~
 52  	notify-send "$APP is updated!"
 53  else
 54  	echo "Update not needed!"
 55  fi
 56  EOF
 57  chmod a+x ./AM-updater || exit 1
 58  
 59  # LAUNCHER & ICON
 60  ./"$APP" --appimage-extract *.desktop 1>/dev/null && mv ./squashfs-root/*.desktop ./"$APP".desktop
 61  ./"$APP" --appimage-extract .DirIcon 1>/dev/null && mv ./squashfs-root/.DirIcon ./DirIcon
 62  COUNT=0
 63  while [ "$COUNT" -lt 10 ]; do # Tries to get the actual icon/desktop if it is a symlink to another symlink
 64  	if [ -L ./"$APP".desktop ]; then
 65  		LINKPATH="$(readlink ./"$APP".desktop | sed 's|^\./||' 2>/dev/null)"
 66  		./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop
 67  	fi
 68  	if [ -L ./DirIcon ]; then
 69  		LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)"
 70  		./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./DirIcon
 71  	fi
 72  	[ ! -L ./"$APP".desktop ] && [ ! -L ./DirIcon ] && break
 73  	COUNT=$((COUNT + 1))
 74  done
 75  sed -i "s#Exec=[^ ]*#Exec=$APP#g; s#Icon=.*#Icon=/opt/$APP/icons/$APP#g" ./"$APP".desktop
 76  mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null
 77  rm -R -f ./squashfs-root
 78  
 79  # ROLLBACK SCRIPT
 80  cat >> /opt/"$APP"/"$APP"-rollback << 'EOF'
 81  #!/usr/bin/env bash
 82  
 83  APP=kdenlive
 84  rm -f ./rollback-args* ./AM-rollback
 85  
 86  # STABLE AND MORE RECENT VERSIONS
 87  STABLE=$(curl -Ls https://download.kde.org/stable/kdenlive/ | grep -o "[0-9][0-9]\.[0-9][0-9]" | uniq | sort -nr)
 88  for var in $STABLE; do
 89  	curl -Ls "https://download.kde.org/stable/kdenlive/$var/linux/" \
 90  	| tr '"' '\n' | grep -i "^kdenlive.*appimage$" | uniq | sort -nr >> "./rollback-args"
 91  done
 92  
 93  # ARCHIVED OLD RELEASES (THAT MAY NOT WORK)
 94  ARCHIVED=$(curl -Ls https://download.kde.org/Attic/kdenlive/ | grep -o "[0-9][0-9]\.[0-9][0-9]" | uniq | sort -nr)
 95  for var in $ARCHIVED; do
 96  	curl -Ls "https://download.kde.org/Attic/kdenlive/$var/linux/" \
 97  	| tr '"' '\n' | grep -i "^kdenlive.*appimage$" | uniq | sort -nr >> "./rollback-args"
 98  done
 99  
100  # LET ROLLBACK KDENLIVE
101  echo "-----------------------------------------------------------------------"
102  echo "You have chosen to roll back $APP."
103  echo "Rollback will be done from https://kdenlive.org"
104  echo "-----------------------------------------------------------------------"
105  echo "Select a version (read carefully) or press CTRL+C to abort:"
106  echo "-----------------------------------------------------------------------"
107  select d in $(cat "./rollback-args"); do
108  	test -n "$d" && break
109  	echo ">>> Invalid Selection"
110  done
111  
112  # PROCEEDE
113  rel=$(echo "$d" | cut -c 10- | cut -c -5)
114  if curl --output /dev/null --silent --head --fail "https://download.kde.org/stable/kdenlive/$rel/linux/$d" 1>/dev/null; then
115  	dl="https://download.kde.org/stable/kdenlive/$rel/linux/$d"
116  else
117  	dl="https://download.kde.org/Attic/kdenlive/$rel/linux/$d"
118  fi
119  cp ./AM-updater ./AM-rollback
120  sed -i 's/version0/#version0/g; s/appimageupdatetool -Or/#appimageupdatetool -Or/g;' ./AM-rollback
121  if wget --version | head -1 | grep -q ' 1.'; then
122  	sed -i "/wget /c\wget -q --no-verbose --show-progress --progress=bar \"$dl\"" ./AM-rollback
123  fi
124  ./AM-rollback
125  echo "$dl" > ./version
126  rm -f ./rollback-args* ./AM-rollback
127  echo ""
128  echo "ROLLBACK SUCCESSFUL!"
129  exit
130  EOF
131  chmod a+x /opt/"$APP"/"$APP"-rollback