Advertisement
s243a

pinstall.sh arch_certs-1.0.1

Mar 19th, 2020
619
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.87 KB | None | 0 0
  1. #!/bin/bash
  2. if [[ "`pwd`" =~ .*initrd.* ]]; then
  3.   INSTALL_ROOT="/"
  4. else
  5.     [ -z "$INSTALL_ROOT" ] && INSTALL_ROOT="$(realpath .)"
  6.     INSTALL_ROOT="${INSTALL_ROOT%/}"
  7.     INSTALL_ROOT="${INSTALL_ROOT}/"
  8.     INSTALL_ROOT="${INSTALL_ROOT#/}"
  9. fi
  10.  
  11. chroot_cmd(){
  12.     if [ -z "$INSTALL_ROOT" ] || [ "$INSTALL_ROOT" = "/" ]; then
  13.       "$1" "${@:2}"
  14.     else
  15.       chroot "$@"
  16.     fi
  17. }
  18. stacktrace() {
  19.   local frame=0 LINE SUB FILE
  20.   while read LINE SUB FILE < <(caller "$frame"); do
  21.     printf '  %s @ %s:%s' "${SUB}" "${FILE}" "${LINE}"
  22.     ((frame++))
  23.   done
  24. }
  25. REPO_FILES=()
  26. url_base=https://mirror.archlinux32.org
  27. for db in core extra community core-testing extra-testing community-testing; do
  28.   if [ -f ${INSTALL_ROOT}var/packages/Packages-arch-32-$db ]; then
  29.     REPO_FILES+=(${INSTALL_ROOT}var/packages/Packages-arch-32-$db)
  30.     REPO_URLs+=("${url_base}")
  31.   fi
  32. done
  33. if [ -z "$DEPENDS_VIA_PINSTALL" ]; then
  34.   petget_cmd="$(stacktrace | grep petget/petget)"
  35.   DEPENDS_VIA_PINSTALL=no
  36.   [ ! -z "$petget_cmd" ] && DEPENDS_VIA_PINSTALL=yes
  37. fi
  38. if [ "$DEPENDS_VIA_PINSTALL" = yes ]; then
  39.  
  40.   for a_pkg in ca-certificates- ca-certificates-mozilla ca-certificates-utils-; do
  41.      [ ! -z "$(cat ${INSTALL_ROOT}var/packages/user-installed-packages ${INSTALL_ROOT}var/packages/woof-installed-packages | grep "^$a_pkg")" ] && continue
  42.     for a_dir in ${INSTALL_ROOT}var/tmp ${INSTALL_ROOT}root; do
  43.         while read pkg_path; do
  44.           [ "$pkg_path" = EOF ] && break
  45.           petget $pkg_path && break 3
  46.         done < <(find $a_dir/$a_pkg* 2>/dev/null; echo EOF )
  47.       #cat $repo1 $repo2 $repo3 | grep "^$a_pkg"
  48.     done
  49.     i=0
  50.     while [ $i -lt "${#REPO_FILES[@]}" ]; do
  51.       repo=${REPO_FILES[$i]}
  52.       repo_url=${REPO_URLs[$i]}
  53.  
  54.       { grep "^$a_pkg" $repo ; echo EOF; } | \
  55.         while read line; do
  56.           [ "$line" = EOF ] && break
  57.           read pkg_path pkg_fname < <(echo "$line" | cut -d '|' -f7,8 | tr '|' ' ')
  58.           grep "^$a_pkg" ${INSTALL_ROOT}var/packages/
  59.  
  60.           petget $repo_url/$pkg_path/$pkg_fname && break 2
  61.         done
  62.         i=$((i+1))
  63.     done  
  64.   done
  65. fi
  66.  
  67. #See: http://murga-linux.com/puppy/viewtopic.php?p=1050071#1050071
  68. mv /etc/ca-certificates.conf /etc/ca-certificates.conf_back_$$
  69. ( cd /usr/share/ca-certificates
  70.  find . -name '*.crt' | sed 's#^./##' > /etc/ca-certificates.conf
  71. )
  72.  
  73. #The following command is from: https://github.com/rbarrois/nss-systemcerts/blob/master/nss-systemcerts-import#L21
  74. [ ! -d /etc/pki/nssdb ] && chroot_cmd nss-systemcerts-import
  75.  
  76. #The following command is from: https://packages.debian.org/sid/all/ca-certificates
  77. chroot_cmd update-ca-certificates
  78.  
  79. #See:
  80. # http://murga-linux.com/puppy/viewtopic.php?p=1050966#1050966
  81. # https://wiki.archlinux.org/index.php/User:Grawity/Adding_a_trusted_CA_certificate#System-wide_%25E2%2580%2593_update-ca-certificates_%28Debian%2C_Ubuntu%29
  82. chroot_cmd update-ca-trust
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement