summaryrefslogtreecommitdiff
path: root/sync.sh
blob: a7b47e63a9c6ca278c1a7c9b3493d1d82e4b810a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#!/bin/bash

finalPortsDirs=(/usr/src/ports/{cpan2crux,manual}Ports)

d=$(
  find "${finalPortsDirs[@]}" -mindepth 2 "(" -name ".*" -type d -prune -false ")" -o -type d -not -name ".*"
)

if [ -n "$d" ]
then
  echo "dirs:"
  echo "$d"
  exit -1
fi

l=$(
  find "${finalPortsDirs[@]}" -type l
)

if [ -n "$l" ]
then
  echo "links:"
  echo "$l"
  exit -1
fi

if [ -d /usr/src/ports/.work ]; then
  rm -f /usr/src/ports/.work/{REPO,index.html}
  ls -1 /usr/src/ports/.work | \
    while read -r s; do
      if [ ! -h "/usr/src/ports/.work/${s}" ]; then
        echo "/usr/src/ports/.work/${s} ist kein Symlink!"
        exit -1
      fi
      rm /usr/src/ports/.work/$s
    done
  rmdir /usr/src/ports/.work
fi
mkdir /usr/src/ports/.work

for dir in $(find "${finalPortsDirs[@]}" -mindepth 1 -maxdepth 1 -type d)
do
  for file in Pkgfile .md5sum .footprint .signature
  do
    if [ ! -f $dir/$file ]
    then
      echo "$dir/$file gibt es nicht, sollte es aber!"
      exit -1
    fi
  done
  if [ ! $(grep -c "^\s*name=" $dir/Pkgfile) -eq 1 ]
  then
    echo "$dir/Pkgfile hat \"name=..\" nicht genau ein Mal!"
    exit -1
  fi
  if [ ! "$(grep "^\s*name=" $dir/Pkgfile | cut -d = -f 2)" == "$(basename "$dir")" ]
  then
    echo "$dir/Pkgfile behauptet zu $(grep "^\s*name=" $dir/Pkgfile | cut -d = -f 2) zu gehören!"
    exit -1
  fi
  if [ ! $(grep -c "^\s*#\s*Maintainer:\s\+Erich Eckner, crux at eckner dot net\s*\$" $dir/Pkgfile) -eq 1 ]
  then
    echo "$dir/Pkgfile behauptet nicht von Erich gepflegt zu werden!"
    exit -1
  fi
  if [ ! $(grep -c "\susr/man/" $dir/.footprint) -eq 0 ]
  then
    echo "$dir erzeugt Manpages in /usr/man statt /usr/share/man!"
    exit -1
  fi
  ergs=$(
    prtverify $dir \
    | grep -v "$(
      sed '
        s@^# !suid \(\S\+\)$@ suid file found: \1$@
        t
        d
      ' $dir/Pkgfile
    )"
  )
  if [ -n "$ergs" ]
  then
    echo "prtverify meckert $dir an:"
    echo "$ergs"
    exit -1
  fi
  signErr="$(
    cd $dir
    if ! signify -C -x .signature &> /dev/null
    then
      sudo -u pkgmk fakeroot pkgmk -cs 2>&1 | \
        grep -v '^=======> Signature ok\.$'
    fi
  )"
  if [ -n "${signErr}" ]
  then
    >&2 echo "signify meckert $dir an:"
    echo "${signErr}"
    exit -1
  fi
  ln -s ${dir} /usr/src/ports/.work/${dir##*/}
done

for file in deepthought.pub deepthought.httpup; do
  ln -s /usr/src/ports/{,.work/}${file}
done

for dir in "${finalPortsDirs[@]}"; do
  httpup-repgen ${dir}
done

for dir in "${finalPortsDirs[@]}"; do
  cat ${dir}/REPO
done | \
  sort > \
  /usr/src/ports/.work/REPO

git -C /usr/src/ports commit -m 'new ports uploaded' -- '*/REPO'
knock-knock
git -C /usr/src/ports push

portspage --title="Erich Eckner's CRUX Ports" --header="/usr/src/ports/head" /usr/src/ports/.work | \
  grep -v ">\." | \
  sed 's|/usr/src/ports/\.work/\([^/]*\)/|/\1/Pkgfile|' | \
  sed 's|\(<td><b>Description</b></td>\)|\1<td><b>Experimental?</b></td>|' | \
  sed 's@^\(\s*<tr class="\(odd\|even\)">\(<td>.*</td>\)\{3\}\)\(<td>[0-9]\{4\}\(-[0-9]\{2\}\)\{2\}</td></tr>\)$@\1<td>EXPERIMENTELL</td>\4@' | \
  while read -r s
  do
    if echo "${s}" | grep -q "EXPERIMENTELL"
    then
      if echo "${s}" | grep -q "https://opensources\.eckner\.net/"
      then
        s="${s/EXPERIMENTELL/yes}"
      else
        s="${s/EXPERIMENTELL/&nbsp;}"
      fi
    fi
    echo "${s}"
  done > \
  /usr/src/ports/.work/index.html

export RSYNC_RSH=ssh
knock-knock
rsync -aLvzzc --delete --delete-excluded \
  --exclude "*tar.gz" \
  --exclude "*tar.bz2" \
  --exclude "*.gem" \
  --exclude "*tgz" \
  --exclude "*.zip" \
  --exclude "sync.sh" \
  --exclude "lastVersion.sh" \
  --exclude "checkVersions" \
  --exclude "head" \
  --exclude ".ht*" \
  --exclude "*CVS/" \
  --include ".md5sum" \
  --include ".footprint" \
  --include ".signature" \
  --exclude ".*" \
    /usr/src/ports/.work/ ecknernet@eckner.net:crux.eckner.net