Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archive
blob: 56854de7ac32e3c5a8b5c92092a1df978c3be8e7 (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
#!/bin/sh

# to be periodically run on the master mirror

# this requires the master mirror to be on the same drive as the archive

master_mirror_root='/srv/http/mirror/mirror.archlinux32.org'
archive_root='/srv/http/mirror/archive.archlinux32.org'
lock_file='/tmp/archive.lock'

# get lock
if [ -f "${lock_file}" ] && kill -0 "$(cat "${lock_file}")"; then
  >&2 echo 'cannot get lock'
  exit
fi
echo "$$" >"${lock_file}"

# copy the isos
find "${master_mirror_root}/archisos" \
  -mindepth 1 \
  -maxdepth 1 \
  -type f \
| while read -r file; do
  if [ -z "${file##*sums}" ]; then
    diff -u "${file}" "${archive_root}/iso/${file##*/}" \
    | sed '
      s/^-\([^-][^-]\)/\1/
      t
      d
    ' \
    | sponge -a "${archive_root}/iso/${file##*/}"
  fi
  [ -f "${archive_root}/iso/${file##*/}" ] && continue
  ln "${file}" "${archive_root}/iso/${file##*/}"
done

# copy the packages
find "${master_mirror_root}/pool" \
  -mindepth 1 \
  -maxdepth 1 \
  -type f \
| sed '
  s,.*/\([^/]\)\([^/]*\)$,\0 \1 \1\2,
' \
| while read -r path initial file; do
  target="${archive_root}/packages/${initial}/${file%-*-*-*}/${file}"
  [ -f "${target}" ] && continue
  mkdir -p "${target%/*}"
  ln "${path}" "${target}"
done

# copy the repositories
todays_path=$(date '+%Y/%m/%d')
todays_path="${archive_root}/repos/${todays_path}"
if [ ! -d "${todays_path}" ]; then
  for arch in i486 i686 pentium4; do
    find "${master_mirror_root}/${arch}" \
      -mindepth 1 \
      -maxdepth 1 \
      -type d \
      -printf '%f\n' \
    | while read -r repo; do
      mkdir -p "${todays_path}/${arch}/${repo}"
      cp -a \
        "${master_mirror_root}/${arch}/${repo}/${repo}.db" \
        "${master_mirror_root}/${arch}/${repo}/${repo}.db.tar.gz" \
        "${master_mirror_root}/${arch}/${repo}/${repo}.files" \
        "${master_mirror_root}/${arch}/${repo}/${repo}.files.tar.gz" \
        "${todays_path}/${arch}/${repo}/"
    done
  done
  rm -f \
    "${archive_root}/repos/last" \
    "${archive_root}/repos/week" \
    "${archive_root}/repos/month"
  ln -s \
    "${todays_path}" \
    "${archive_root}/repos/last"
  first_of_month=$(
    find "${archive_root}/repos" -mindepth 3 -maxdepth 3 \
    | sed '
      s,^.*/\([^/]\+\)/\([^/]\+\)/\([^/]\+\)$,\1/\2 \3,
      t
      d
    ' \
    | sort -k1r,1 -k2,2 \
    | head -n1 \
    | tr ' ' '/'
  )
  ln -s \
    "${archive_root}/repos/${first_of_month}" \
    "${archive_root}/repos/month"
  first_of_week=$(
    find "${archive_root}/repos" -mindepth 3 -maxdepth 3 \
    | sed '
      s,^.*/\([^/]\+\)/\([^/]\+\)/\([^/]\+\)$,\1-\2-\3,
      t
      d
    ' \
    | sort \
    | tail -n7 \
    | while read -r date; do
      date '+%Y/%m/%d %G %V' -d "${date}"
    done \
    | sort -k2r,3 -k1,1 \
    | head -n1 \
    | cut -d' ' -f1
  )
  ln -s \
    "${archive_root}/repos/${first_of_week}" \
    "${archive_root}/repos/week"
fi

# release lock
rm -f "${lock_file}"