mirror of https://github.com/Chizi123/Arch-autobuild-repo.git

Chizi123
2019-08-23 46a733bf8137cf574ab3ce84cff220cef3e1c7ea
commit | author | age
00a98f 1 #!/bin/bash
C 2
a45f88 3 #Number of old packages to store, should be at least 1
C 4 NUM_BACK=5
b6a1d2 5 #remote details
JG 6 RUSER=joelgrun
7 RLOC=35.225.177.191
8 RPATH=/var/www/joelg.cf/html/x86_64/
a45f88 9
00a98f 10 function newest_matching_file
C 11 {
12     # Use ${1-} instead of $1 in case 'nounset' is set
13     local -r glob_pattern=${1-}
14
15     if (( $# != 1 )) ; then
16         echo 'usage: newest_matching_file GLOB_PATTERN' >&2
17         return 1
18     fi
19
20     # To avoid printing garbage if no files match the pattern, set
21     # 'nullglob' if necessary
22     local -i need_to_unset_nullglob=0
23     if [[ ":$BASHOPTS:" != *:nullglob:* ]] ; then
24         shopt -s nullglob
25         need_to_unset_nullglob=1
26     fi
27
28     newest_file=
29     for file in $glob_pattern ; do
30         [[ -z $newest_file || $file -nt $newest_file ]] \
31             && newest_file=$file
32     done
33
34     # To avoid unexpected behaviour elsewhere, unset nullglob if it was
35     # set by this function
36     (( need_to_unset_nullglob )) && shopt -u nullglob
37
38     # Use printf instead of echo in case the file name begins with '-'
39     [[ -n $newest_file ]] && printf '%s\n' "$newest_file"
40
41     return 0
42 }
43
a45f88 44 function oldest_matching_file
C 45 {
46     # Use ${1-} instead of $1 in case 'nounset' is set
47     local -r glob_pattern=${1-}
48
49     if (( $# != 1 )) ; then
50         echo 'usage: oldest_matching_file GLOB_PATTERN' >&2
51         return 1
52     fi
53
54     # To avoid printing garbage if no files match the pattern, set
55     # 'nullglob' if necessary
56     local -i need_to_unset_nullglob=0
57     if [[ ":$BASHOPTS:" != *:nullglob:* ]] ; then
58         shopt -s nullglob
59         need_to_unset_nullglob=1
60     fi
61
62     oldest_file=
63     for file in $glob_pattern ; do
64         [[ -z $oldest_file || $file -ot $oldest_file ]] \
65             && oldest_file=$file
66     done
67
68     # To avoid unexpected behaviour elsewhere, unset nullglob if it was
69     # set by this function
70     (( need_to_unset_nullglob )) && shopt -u nullglob
71
72     # Use printf instead of echo in case the file name begins with '-'
73     [[ -n $oldest_file ]] && printf '%s\n' "$oldest_file"
74
75     return 0
76 }
77
99cd84 78 #update system
C 79 sudo pacman -Syu --noconfirm
80
81 #go to build directory
48a8a8 82 cd $(dirname "$(realpath $0)")
99cd84 83
C 84 #Remove old packages
990bd0 85 #git rm -r x86_64/*
JG 86 #rm -r x86_64
87 #mkdir x86_64
48a8a8 88
7df843 89 #dependencies
C 90 cd dependencies
01b1e0 91 for d in `find . -maxdepth 1 -not -path '*/\.*' -type d`
00a98f 92 do
99cd84 93     #Only do package directories
01b1e0 94     if [ "$d" = "./x86_64" ] || [ "$d" = "." ]; then
0969d0 95         continue
C 96     fi
00a98f 97     cd $d
99cd84 98     #update package to latest from AUR
019ddc 99     git pull -f
7df843 100     makepkg -si --noconfirm
990bd0 101     if [ $? = 0 ]; then
JG 102         latest=$(newest_matching_file '*.pkg.tar.xz')
103         while [ $NUM_BACK \< $(find . -name "*.pkg.tar.xz" | wc -l) ]
104         do
105             oldest=$(oldest_matching_file '*.pkg.tar.xz')
106             rm $oldest
107         done
108         cd ..
109         rm ../x86_64/"$d"*".pkg.tar.xz"
110         ln $d/$latest ../x86_64/$latest
111     else
112         cd ..
113     fi
114     #    repo-add ../Chizi123.db.tar.xz ../x86_64/$latest
7df843 115 done
C 116 cd ..
117
118 #main packages
119 for d in `find . -maxdepth 1 -not -path '*/\.*' -type d`
120 do
121     #Only do package directories
a45f88 122     if [ "$d" = "./x86_64" ] || [ "$d" = "." ] || [ "$d" = "./dependencies" ]; then
7df843 123         continue
C 124     fi
125     cd $d
126     #update package to latest from AUR
019ddc 127     git pull -f
01b1e0 128     makepkg -s --noconfirm
990bd0 129     if [ $? = 0 ]; then
JG 130         latest=$(newest_matching_file '*.pkg.tar.xz')
131         while [ $NUM_BACK \< $(find . -name "*.pkg.tar.xz" | wc -l) ]
132         do
133             oldest=$(oldest_matching_file '*.pkg.tar.xz')
134             rm $oldest
135         done
136         cd ..
137         rm x86_64/"$d"*".pkg.tar.xz"
138         ln $d/$latest x86_64/$latest
139     else
140         cd ..
141     fi
142     #    repo-add ./Chizi123.db.tar.xz x86_64/$latest
00a98f 143 done
C 144
990bd0 145 repo-add Chizi123.db.tar.xz x86_64/*
99cd84 146 ln Chizi123.db.tar.xz x86_64/Chizi123.db
C 147 ln Chizi123.files.tar.xz x86_64/Chizi123.files
48a8a8 148 git add x86_64
C 149 git commit -m "'$(date +%d/%m/%y-%H:%M)'"
150 git push
46a733 151 <<<<<<< HEAD
b6a1d2 152 rsync -ah x86_64 $RUSER@$RLOC:$RPATH
46a733 153 =======
61ff4f 154 rsync -ah --delete x86_64 $RUSER@$RLOC:$RPATH
46a733 155 >>>>>>> 019ddc4837c10dc233d49bd517b6f08ef1e53519