Advertisement
Guest User

Untitled

a guest
Dec 13th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.16 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3.  
  4. # Made by fernandomaroto for EndeavourOS and Portergos.
  5. # Should work in any arch-based distros
  6. # Trying K.I.S.S filosophy
  7.  
  8. import subprocess
  9. import libcalamares
  10. from pathlib import Path
  11.  
  12. root_mount_point = libcalamares.globalstorage.value("rootMountPoint")
  13.  
  14. def update_db():
  15.  
  16. # Hope is simpler this way
  17.  
  18. START_HAVEGED = "haveged -w 1024"
  19. PACMAN_INIT = "pacman-key --init"
  20. PACMAN_POPULATE = "pacman-key --populate"
  21. PACMAN_REFRESH ="pacman-key --refresh-keys"
  22. STOP_HAVEGED = "pkill haveged"
  23. BACKUP_MIRROLIST = "cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak"
  24. #BEST_MIRRORS = "reflector --verbose --age 8 --fastest 128 --latest 64 --number 32 --sort rate --save /etc/pacman.d/mirrorlist"
  25. BEST_MIRRORS = "reflector --verbose -a1 -f10 -l70 -phttps --sort rate --save /etc/pacman.d/mirrorlist"
  26.  
  27. RANK_MIRRORS = "/usr/bin/update-mirrorlist"
  28.  
  29. # Update database, step by step in the running iso only. Necessary if running old iso version
  30. subprocess.call(START_HAVEGED.split(' '))
  31. subprocess.call(PACMAN_INIT.split(' '))
  32. subprocess.call(PACMAN_POPULATE.split(' '))
  33. subprocess.call(PACMAN_REFRESH.split(' '))
  34. subprocess.call(STOP_HAVEGED.split(' '))
  35. subprocess.call(BACKUP_MIRROLIST.split(' '))
  36.  
  37. #############################################################
  38. update_mirrors_installed = Path("/usr/bin/update-mirrorlist")
  39.  
  40. try:
  41. if not update_mirrors_installed.exists():
  42. subprocess.call(BEST_MIRRORS.split(' '))
  43. else:
  44. subprocess.call([RANK_MIRRORS, '||', BEST_MIRRORS], shell=True)
  45. except:
  46. pass
  47.  
  48. #############################################################
  49.  
  50.  
  51. # After the above there is no need to run cmds again in case the user tries to launch calamares a second time
  52.  
  53. try:
  54. open('/tmp/run_once', 'a')
  55. run_once.close()
  56. except:
  57. pass
  58.  
  59. def run():
  60. """
  61. Install base filesystem.
  62. """
  63.  
  64. # created new function above to update, populate, refresh, best mirrors etc
  65.  
  66. executed_before = Path("/tmp/run_once")
  67.  
  68. try:
  69. if not executed_before.exists():
  70. update_db()
  71. except:
  72. pass
  73.  
  74. # Install base system + endeavouros packages + copy necessary config files
  75.  
  76. PACSTRAP = "/usr/bin/pacstrap_calamares -c"
  77. PACKAGES = "base sudo grub endeavouros-keyring endeavouros-mirrorlist grub2-theme-endeavouros xterm"
  78. OLD_BASE = "mkinitcpio mkinitcpio-busybox mkinitcpio-nfs-utils cryptsetup device-mapper dhcpcd diffutils e2fsprogs inetutils jfsutils less linux linux-firmware logrotate lvm2 man-db man-pages mdadm nano netctl perl reiserfsprogs s-nail sysfsutils systemd-sysvcompat texinfo usbutils vi which xfsprogs"
  79.  
  80. RSYNC_CMD = "rsync -vaRI"
  81. CLEANER_SCRIPT = "/usr/bin/cleaner_script.sh"
  82. PACMAN_CONF = "/etc/pacman.conf"
  83. PACMAN_MIRRORS = "/etc/pacman.d/mirrorlist"
  84. PACMAN_HOOKS = "etc/pacman.d/hooks"
  85. OS_RELEASE = "/etc/os-release"
  86. LSB_RELEASE = "/etc/lsb-release"
  87. GRUB_CONF = "/etc/default/grub"
  88.  
  89. subprocess.call(PACSTRAP.split(' ') + [root_mount_point] + PACKAGES.split(' ') + OLD_BASE.split(' '))
  90.  
  91. # Will change to multiple files in one step, is gonna be harder for newbies?
  92.  
  93. subprocess.call(RSYNC_CMD.split(' ') + [CLEANER_SCRIPT] + [PACMAN_HOOKS] + [PACMAN_CONF] + [OS_RELEASE] + [GRUB_CONF] + [PACMAN_MIRRORS] + ["/tmp/run_once"] + [OS_RELEASE] + [LSB_RELEASE] + [root_mount_point])
  94.  
  95. #subprocess.call(RSYNC_CMD.split(' ') + [CLEANER_SCRIPT] + [root_mount_point])
  96. #subprocess.call(RSYNC_CMD.split(' ') + [PACMAN_CONF] + [root_mount_point])
  97. #subprocess.call(RSYNC_CMD.split(' ') + [OS_RELEASE] + [root_mount_point])
  98. #subprocess.call(RSYNC_CMD.split(' ') + [GRUB_CONF] + [root_mount_point])
  99. #subprocess.call(RSYNC_CMD.split(' ') + [PACMAN_MIRRORS] + [root_mount_point])
  100. #subprocess.call(RSYNC_CMD.split(' ') + ["/tmp/run_once"] + [root_mount_point])
  101. #subprocess.call(RSYNC_CMD.split(' ') + [OS_RELEASE] + [root_mount_point])
  102. #subprocess.call(RSYNC_CMD.split(' ') + [LSB_RELEASE] + [root_mount_point])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement