unixwz0r

yay-inst.c

Sep 16th, 2021 (edited)
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 4.19 KB | None | 0 0
  1. /*
  2.  *
  3.  * yay-inst.c Yay installation Program
  4.  * gcc yay-inst.c -o yay-inst  
  5.  * ./yay-inst
  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. // *** this should only be run in normal user and not ROOT
  52. void yay_inst(){
  53. printf("\n\n");
  54. printf(BLUE"To install packages from AUR you need to install Yay Package Manager. . .");
  55. printf(RED" PLEASE HIT "GREEN"ENTER"RED" TO PROCEED."GREEN"\n");
  56. getchar();
  57. printf("\n\n");
  58.     char buf[256];
  59.     char *argv[] = {
  60.                      "git", "clone", "https://aur.archlinux.org/yay.git",
  61.                      0,
  62.                    };
  63. pid_t pid = fork();
  64. if(pid == 0) {
  65.                    execv("/bin/git", argv);
  66. }                  
  67.  else {
  68.      waitpid(pid, NULL, 0);
  69.  }                
  70. }
  71. // ... cd yay
  72. void cd_yay(){
  73. printf(RED" PLEASE HIT "GREEN"ENTER"RED" TO PROCEED."GREEN"\n");
  74. getchar();
  75.  
  76.  
  77. char *dir = "yay"; // cd to  yay <dir>
  78. int ret;
  79. ret = chdir (dir);
  80. if (ret){ // same as ret!=0, means an error occurred and errno is set
  81.     fprintf(stderr, "error: %s\n", strerror(errno));
  82. }
  83. }
  84. void mkpkg_yay(){
  85.     char buf[256];
  86.     char *argv[] = {
  87.                      "makepkg", "-sri", "--noconfirm", "--needed",
  88.                      0,
  89.                    };
  90. pid_t pid = fork();
  91. if(pid == 0) {
  92.                    execv("/usr/bin/makepkg", argv);
  93. }                  
  94.  else {
  95.      waitpid(pid, NULL, 0);
  96.  }                
  97. }
  98. void yay_pkg(){
  99. printf("\n\n");
  100. printf(BLUE"This will install Timeshift and Timeshift Autosnap & Gnome Extensions ... ");
  101. printf(RED" PLEASE HIT "GREEN"ENTER"RED" TO PROCEED."GREEN"\n");
  102. getchar();
  103. printf("\n\n");
  104.                 char *argv[] = {
  105.                                   "yay",  "-S",
  106.                                   "timeshift",
  107.                                   "timeshift-autosnap",
  108.                                   "gnome-shell-extension-dash-to-dock-gnome40-git",
  109.                                   0,
  110.                               };
  111.  
  112. pid_t pid = fork();
  113. if(pid == 0) {
  114.                               execv("/usr/bin/yay", argv);
  115.                              
  116. }
  117.  else {
  118.     waitpid(pid, NULL, 0);
  119. }  
  120. }
  121.  
  122. int main( int argc, char **argv ){
  123.    
  124. yay_inst();
  125. cd_yay();
  126. mkpkg_yay();
  127. yay_pkg();
  128. return 0;
  129. }
  130.  
Add Comment
Please, Sign In to add comment