summaryrefslogtreecommitdiffstats
path: root/make-repo
blob: b9e15ca4f0bc2a93ea252d197ae39f90cb996390 (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
#!/usr/bin/sh

REPODIR=/var/www/lighttpd/repos/local
SCANPATH=.build
CLEAN=0

while [ $# -gt 0 ]
do
  OPTION=$1
  shift

  case $OPTION in
    -r|--repo-dir)
      REPODIR=$1
      shift
      ;;

    -c|--clean)
      CLEAN=1
      ;;

    -p|--path)
      SCANPATH=$1
      shift
      ;;

    -h|--help)
      echo "Create a local repository from the RPMs found in the scan-path.

usage: $0 [ options ]

options:
  -r --repo-dir     Specify output directory of created repository (default: $REPODIR)
  -c --clean        Clean repository before scanning path for files
  -p --path         Scan specified path for RPMs (default: $SCANPATH)

  -h --help         Show this help file"
      exit 1
      ;;
  esac
done

if [ ! -d $REPODIR ]
then
  mkdir -p $REPODIR
fi

if [ ! -w $REPODIR ]
then
  echo "You don't have access to $REPODIR" >&2
  exit 1
fi

if [ $CLEAN -eq 1 ]
then
  rm -rf $REPODIR/*
fi

find $SCANPATH \( -name '*.rpm' -a ! -path '*/.repo/*' \) -exec cp {} $REPODIR \;
createrepo -o $REPODIR $REPODIR

ls -lahR $REPODIR > $REPODIR/files.txt

IPADDR=$(ifconfig em1 | grep 'inet ' | sed -e 's,^\s\+inet \([0-9.]\+\).*$,\1,')

cat >$REPODIR/local.repo <<EOF
[local]
name=local
baseurl=http://$IPADDR/repos/local
enabled=1
gpgcheck=0
EOF