unixwz0r

thlinst.c (trying to get yay setup in the installer)

Sep 16th, 2021 (edited)
635
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 8.13 KB | None | 0 0
  1. /*
  2.  *
  3.  * thlinst.c Arch Linux installer Program
  4.  * gcc thlinst.c -o thlinst  
  5.  * ./thlinst
  6.  * The Tux Hat Linux Project By: Gary Perreault, Vince Ford, Cody & Will.
  7.  * 2013-2021
  8.  *
  9.  *
  10.  * Copyright (c) 2021, The Tux Hat Linux Project Team.
  11.  * All rights reserved.
  12.  *
  13.  * Redistribution and use in source and binary forms, with or without
  14.  * modification, are permitted provided that the following conditions are met:
  15.  *
  16.  * 1. Redistributions of source code must retain the above copyright notice, this
  17.  * list of conditions and the following disclaimer.
  18.  * 2. Redistributions in binary form must reproduce the above copyright notice,
  19.  * this list of conditions and the following disclaimer in the documentation
  20.  * and/or other materials provided with the distribution.
  21.  *
  22.  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  23.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  24.  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  25.  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
  26.  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  27.  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  28.  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  29.  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30.  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  31.  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32.  *
  33.  * The views and conclusions contained in the software and documentation are those
  34.  * of the authors and should not be interpreted as representing official policies,
  35.  * either expressed or implied, of the FreeBSD Project.
  36.  */
  37. #include <unistd.h> // chdir  
  38. #include <errno.h> // strerror
  39. #include <ncurses.h>
  40. #include <stdio.h>
  41. #include <stdlib.h>
  42. #include <sys/utsname.h>
  43. #include <unistd.h>
  44. #include <string.h>
  45. #include <errno.h>
  46. #include <sys/wait.h>
  47. #define RED     "\x1b[31m" // Colours for the logo to make it pretty!
  48. #define GREEN   "\x1b[32m"
  49. #define BLUE    "\x1b[34m"
  50. #define RESET   "\x1b[0m"
  51.  
  52. /* Tux Hat Linux Installer Banner */
  53. void print_logo(){
  54.  
  55. printf(GREEN"╔═══════════════════════════════════════════════════════════════════╗\n");
  56. printf(GREEN"║                     Tux Hat Linux Base Installer                  "GREEN"║\n");
  57. printf(GREEN"║                     (c) 2021 - FreeBSD Licensed                   "GREEN"║\n");
  58. printf(GREEN"║                         By: Gary Perreault                        "GREEN"║\n");
  59. printf(GREEN"╚═══════════════════════════════════════════════════════════════════╝"RESET"\n");
  60. printf("\n\n");
  61. printf(GREEN" Welcome to the THL Arch Linux Installer Program, the system will pacman update --> upgrade --> copy the packages & programs +  configuration . . ."GREEN"\n");
  62. printf("\n\n");
  63. printf(RED" PLEASE HIT "GREEN"ENTER"RED" TO PROCEED."GREEN"\n");
  64. getchar();
  65. }
  66.  
  67. /* This function does pacman -Syy to update Arch Linux  */
  68. void pacman_update(){
  69. printf("\n\n");
  70. printf(BLUE"Arch Linux is about to Pacman Update .. ");
  71. printf(RED" PLEASE HIT "GREEN"ENTER"RED" TO PROCEED."GREEN"\n");
  72. getchar();
  73. printf("\n\n");
  74.                 char *argv[] = {
  75.                                   "pacman",  "-Syy",
  76.                                   0,
  77.                               };
  78.  
  79. pid_t pid = fork();
  80. if(pid == 0) {
  81.                               execv("/usr/bin/pacman", argv);
  82.                              
  83. }
  84.  else {
  85.     waitpid(pid, NULL, 0);
  86.  }                            
  87. }
  88.  
  89. /* This function does pacman -Syu to upgrade Arch Linux */
  90. void pacman_upgrade(){
  91. printf("\n\n");
  92. printf(BLUE"Pacman Upgrade .. ");
  93. printf(RED" PLEASE HIT "GREEN"ENTER"RED" TO PROCEED."GREEN"\n");
  94. getchar();
  95. printf("\n\n");
  96.                 char *argv[] = {
  97.                                   "pacman",  "-Syu",
  98.                                   0,
  99.                               };
  100.  
  101. pid_t pid = fork();
  102. if(pid == 0) {
  103.                               execv("/usr/bin/pacman", argv);
  104.                              
  105. }
  106.  else {
  107.     waitpid(pid, NULL, 0);
  108.  }                            
  109. }
  110.  
  111. /* This function does pacman -S to all the packages you need for the Skel */
  112. void base_inst(){
  113. printf("\n\n");
  114. printf(BLUE"This is the Base Packages for Arch Linux base, base-devel, Grub, Gnome, GDM, Drivers, Kernel, wayland & X11, and extra useful packages .. ");
  115. printf(RED" PLEASE HIT "GREEN"ENTER"RED" TO PROCEED."GREEN"\n");
  116. getchar();
  117. printf("\n\n");
  118.                 char *argv[] = {
  119.                                   "pacman",  "-S",
  120.                                   "base",
  121.                                   "base-devel",
  122.                                   "linux-firmware",
  123.                                   "nano",
  124.                                   "gnome",
  125.                                   "gdm",
  126.                                   "intel-ucode",
  127.                                   "geany",
  128.                                   "vim",
  129.                                   "intel-media-driver",
  130.                                   "firefox",
  131.                                   "libva-intel-driver",
  132.                                   "openshot",
  133.                                   "mc",
  134.                                   "zsh",
  135.                                   "gimp",
  136.                                   "alsa-utils",
  137.                                   "pulseaudio",
  138.                                   "pulseaudio-bluetooth",
  139.                                   "bluez",
  140.                                   "bluez-utils",
  141.                                   "git",
  142.                                   "neofetch",
  143.                                   "mc",
  144.                                   "tmux",
  145.                                   "scrot",
  146.                                   "grub",
  147.                                   "efibootmgr",
  148.                                   "networkmanager",
  149.                                   "network-manager-applet",
  150.                                   "dialog",
  151.                                   "wpa_supplicant",
  152.                                   "xdg-utils",
  153.                                   "xdg-user-dirs",
  154.                                   "inetutils",
  155.                                   0,
  156.                               };
  157.  
  158. pid_t pid = fork();
  159. if(pid == 0) {
  160.                               execv("/usr/bin/pacman", argv);
  161.                              
  162. }
  163.  else {
  164.     waitpid(pid, NULL, 0);
  165.  }                            
  166. }
  167.  
  168. /* This Function will run 4 runlevel of cp -v of 4 files being copied to /usr/local/bin for bsdboxdwm status*/
  169. void yay_inst(){
  170. printf("\n\n");
  171. printf(BLUE"To install packages from AUR you need to install Yay Package Manager. . .");
  172. printf(RED" PLEASE HIT "GREEN"ENTER"RED" TO PROCEED."GREEN"\n");
  173. getchar();
  174. printf("\n\n");
  175.     char buf[256];
  176.     char *argv[] = {
  177.                      "git", "clone", "https://aur.archlinux.org/yay.git",
  178.                      0,
  179.                    };
  180. pid_t pid = fork();
  181. if(pid == 0) {
  182.                    execv("/bin/git", argv);
  183. }                  
  184.  else {
  185.      waitpid(pid, NULL, 0);
  186.  }                
  187. }
  188. // ... cd yay
  189. void cd_yay(){
  190. printf(RED" PLEASE HIT "GREEN"ENTER"RED" TO PROCEED."GREEN"\n");
  191. getchar();
  192.  
  193.  
  194. char *dir = "yay"; // cd to  yay <dir>
  195. int ret;
  196. ret = chdir (dir);
  197. if (ret){ // same as ret!=0, means an error occurred and errno is set
  198.     fprintf(stderr, "error: %s\n", strerror(errno));
  199. }
  200. }
  201. void mkpkg_yay(){
  202.     char buf[256];
  203.     char *argv[] = {
  204.                      "makepkg", "-sri", "--noconfirm", "--needed",
  205.                      0,
  206.                    };
  207. pid_t pid = fork();
  208. if(pid == 0) {
  209.                    execv("makepkg", argv);
  210. }                  
  211.  else {
  212.      waitpid(pid, NULL, 0);
  213.  }                
  214. }
  215. /* This function just thank you for trying out the project ;) */
  216. void thank_you(){
  217.     printf("\n\n");
  218.     printf(RED"Thank You for trying out "BLUE"Tux Hat Linux"RED"!"RESET"\n");
  219.     printf("\n\n");
  220.    
  221.  
  222. }
  223.  
  224.                      
  225.  
  226. int main( int argc, char **argv ){
  227.    
  228. print_logo();
  229. pacman_update();
  230. pacman_upgrade();
  231. base_inst();
  232. yay_inst();
  233. cd_yay();
  234. mkpkg_yay();
  235. thank_you();
  236. return 0;
  237. }
  238.  
Add Comment
Please, Sign In to add comment