s243a

generate_pkg_file_lists_expected.sh

Dec 20th, 2020
1,247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.16 KB | None | 0 0
  1. #/bin/bash
  2. CWD="$(realpath .)"
  3. output_file=${1:-./pkg_contents_list_files}
  4. if [ $# -eq 0 ]; then
  5.   set -- /var/packages/user-installed-packages /var/packages/woof-installed-packages
  6. fi
  7. shift
  8. function replace_extension(){
  9.     while read a_record; do
  10.       case
  11.     done
  12. }
  13. rm "$output_file"
  14. for a_file_path in "$@"; do
  15.   a_file_path="$(realpath "$a_file")"
  16.   a_file=$(basename "$a_file_path")
  17.   a_dir="$(dirname "$a_file")"
  18.   cd "$a_dir"
  19.   #We can 't foward Standard error
  20.   old_setting=${-//[^x]/} #https://stackoverflow.com/questions/14564746/in-bash-how-to-get-the-current-status-of-set-x
  21.   case "$a_file" in
  22.   */builtin_files)
  23.     cut -f2,3,8 -d '|' "$a_file" | sed -n 's#$#\|builtin_files\|#g' | sed -r 's#(^.*)(\|[^[|]+)(.deb|.pet)\|#\2.list\1#g' >> output_file
  24.     ;;
  25.   */packages)
  26.     cut -f2,3,8 -d '|' "$a_file" | sed -n 's#$#\|builtin_files\|#g' | sed -r 's#(^.*)(\|[^[|]+)(.deb|.pet)\|#\2.list\1#g' >> output_file
  27.     ;;
  28.   */dpkg)
  29.     cut -f2,3,8 -d '|' "$a_file" | sed -n 's#$#\|builtin_files\|#g' | sed -r 's#(^.*)(\|[^[|]+)(.deb|.pet)\|#\2.list\1#g' >> output_file
  30.     ;;
  31.   esac
  32.   if [[ -n "$old_setting" ]]; then set -x; else set +x; fi
  33. done
  34.  
Advertisement
Add Comment
Please, Sign In to add comment