aboutsummaryrefslogtreecommitdiff
path: root/trunk/src/repos
blob: 465714b4e63c9a25643cde5b16338ebbc471a402 (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
#!/bin/bash
#
# repos script got from
# http://software.jaos.org/BUILD/slapt-get/FAQ.html#slgFAQ17
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# any later version.
#
# changes by rhatto at riseup.net to fit http://slack.sarava.org needs
# 

function svn_add_meta {
  find *meta -exec svn add {} 2> /dev/null \;
  find . -name *meta -exec svn add {} 2> /dev/null \;
}

function gen_filelist {
  for file in `find | grep -e ".tgz$"`; do ls -l $file; done > FILELIST.TXT
  echo "Created new FILELIST.TXT"
  if [ -d "patches" ]; then
    for file in `find patches | grep -e ".tgz$"`; do ls -l $file; done > patches/FILE_LIST
    echo "Created new patches/FILE_LIST"
  fi
}

function gen_packages_txt {
   echo '' > PACKAGES.TXT
   find . -type f -name '*.meta' -exec cat {} \; >> PACKAGES.TXT
   cat PACKAGES.TXT | gzip -9 -c - > PACKAGES.TXT.gz
   echo "Created new PACKAGES.TXT and PACKAGES.TXT.gz"
   if [ -d "patches" ]; then
     find patches -type f -name '*.meta' -exec cat {} \; >> patches/PACKAGES.TXT
     cat patches/PACKAGES.TXT | gzip -9 -c - > patches/PACKAGES.TXT.gz
     echo "Created new patches/PACKAGES.TXT and patches/PACKAGES.TXT.gz"
   fi
}

function gen_md5_checksums {
   echo '' > CHECKSUMS.md5
   find . -type f -name '*.tgz' -exec md5sum {} \; >> CHECKSUMS.md5
   cat CHECKSUMS.md5 | gzip -9 -c - > CHECKSUMS.md5.gz
   echo "Created new CHECKSUMS.md5 and CHECKSUMS.md5.gz"
   if [ -d "patches" ]; then
     find patches -type f -name '*.tgz' -exec md5sum {} \; >> patches/CHECKSUMS.md5
     cat patches/CHECKSUMS.md5 | gzip -9 -c - > patches/CHECKSUMS.md5.gz
     echo "Created new patches/CHECKSUMS.md5 and patches/CHECKSUMS.md5.gz"
   fi
}

function gen_meta {
  if [ ! -f $1 ]; then
    echo "File not found: $1"
    exit 1;
  else
    echo "Processing $1"
  fi
  if [ "`echo $1|grep -E '(.*{1,})\-(.*[\.\-].*[\.\-].*).tgz[ ]{0,}$'`" == "" ]; then
    return;
  fi
  NAME=$(echo $1|sed -re "s/(.*\/)(.*.tgz)$/\2/")
  LOCATION=$(echo $1|sed -re "s/(.*)\/(.*.tgz)$/\1/")
  SIZE=$( expr `gunzip -l $1 | tail -n 1|awk '{print $1}'` / 1024 )
  USIZE=$( expr `gunzip -l $1 | tail -n 1|awk '{print $2}'` / 1024 )
  REQUIRED=$(tar xzfO $1 install/slack-required 2>/dev/null|xargs -r -iZ echo -n "Z,"|sed -e "s/,$//")
  CONFLICTS=$(tar xzfO $1 install/slack-conflicts 2>/dev/null|xargs -r -iZ echo -n "Z,"|sed -e "s/,$//")
  SUGGESTS=$(tar xzfO $1 install/slack-suggests 2>/dev/null|xargs -r )
  METAFILE=${NAME%tgz}meta
  echo "PACKAGE NAME:  $NAME" > $LOCATION/$METAFILE
  if [ -n "$DL_URL" ]; then
    echo "PACKAGE MIRROR:  $DL_URL" >> $LOCATION/$METAFILE
  fi
  echo "PACKAGE LOCATION:  $LOCATION" >> $LOCATION/$METAFILE
  echo "PACKAGE SIZE (compressed):  $SIZE K" >> $LOCATION/$METAFILE
  echo "PACKAGE SIZE (uncompressed):  $USIZE K" >> $LOCATION/$METAFILE
  echo "PACKAGE REQUIRED:  $REQUIRED" >> $LOCATION/$METAFILE
  echo "PACKAGE CONFLICTS:  $CONFLICTS" >> $LOCATION/$METAFILE
  echo "PACKAGE SUGGESTS:  $SUGGESTS" >> $LOCATION/$METAFILE
  echo "PACKAGE DESCRIPTION:" >> $LOCATION/$METAFILE
  tar xzfO $1 install/slack-desc | grep -E '\w+\:'|grep -v '^#' >> $LOCATION/$METAFILE
  echo "" >> $LOCATION/$METAFILE
}

function do_all {
  for pkg in `find . -type f -name '*.tgz' -print`; do
    gen_meta $pkg
  done
  $0 PACKAGESTXT
  $0 FILELIST
  $0 MD5
}

function show_usage {
  echo "`basename $0` [pkg [file]|all|new|svnmeta|PACKAGESTXT|FILELIST|MD5]"
}

case "$1" in
  pkg)
      if [ -n "$2" ]; then
        gen_meta $2
      else
        show_usage
      fi
    ;;
    all)
      do_all
    ;;
    new)
      for pkg in `find . -type f -name '*.tgz' -print`; do
        if [ ! -f ${pkg%tgz}meta ]; then
          gen_meta $pkg
        fi
      done
    ;;
    svnmeta)
      svn_add_meta
    ;;
    PACKAGESTXT)
      gen_packages_txt
    ;;
    FILELIST)
      gen_filelist
    ;;
    MD5)
      gen_md5_checksums
    ;;
    usage)
      show_usage
    ;;
    *)
      do_all
      svn_add_meta
    ;;
esac