/[gli]/branches/overhaul/src/misc/mkvardb
Gentoo

Contents of /branches/overhaul/src/misc/mkvardb

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1532 - (show annotations) (download)
Sun Oct 22 00:08:21 2006 UTC (8 years, 7 months ago) by codeman
File size: 3882 byte(s)
adding a new branch for the overhaul of GLI

1 #!/bin/bash
2
3 PROG=$(basename ${0})
4 PORTDIR_OVERLAY="/usr/local/portage"
5 DB="/var/db/pkg"
6 filesindex=0
7
8 declare -a exclude
9 declare -a files
10
11 function usage {
12 echo "Usage: $PROG [options] <files>"
13 echo
14 echo "Options:"
15 echo " -h|--help Show this message"
16 echo " -c|--category <category> Specifies the category for the package to be created"
17 echo " -p|--pkgname <name> Specifies the name for the package to be created"
18 echo " -v|--version <version> Specifies the version for the package to be created"
19 echo " --provide <provide> Specifies the contents of the PROVIDES line in the ebuild"
20 echo " packaged. This option can be specified multiple times"
21 echo
22 echo "Parameters:"
23 echo " files These are the existing files that are to be packaged"
24 }
25
26 function create_ebuild {
27 VARDBDIR="${DB}/${category}/${pkgname}-${pkgver}"
28 EBUILD="${VARDBDIR}/${pkgname}-${pkgver}.ebuild"
29
30 mkdir -p $VARDBDIR
31 cat > $EBUILD <<EOE
32 # Copyright 1999-2005 Gentoo Foundation
33 # Distributed under the terms of the GNU General Public License v2
34 # \$Header: /var/cvsroot/gentoo/src/installer/src/misc/mkvardb,v 1.5 2005/08/23 13:47:34 agaffney Exp $
35
36 inherit eutils
37
38 DESCRIPTION="This is a sample skeleton ebuild file"
39 HOMEPAGE=""
40 SRC_URI=""
41 LICENSE=""
42 SLOT="0"
43 KEYWORDS="$(portageq envvar ARCH)"
44 IUSE=""
45 DEPEND=""
46 PROVIDE="${provide}"
47 EOE
48 }
49
50 function echo_parent_dirs {
51 dir=$1
52 while $(/bin/true); do
53 tmpdir=$(dirname ${dir})
54 [ "$tmpdir" = "/" ] && break
55 echo $tmpdir
56 dir=$tmpdir
57 done
58 }
59
60 function sort_dirs_and_files {
61 curdir=""
62
63 rm /tmp/mkvardb_filelist 2>/dev/null
64 for i in $(ls -1AR --color=no ${files[@]} | sed -e 's/:$//' | grep -ve '^$'$); do
65 if [ -d ${i} ]; then
66 if [ "${curdir}" != "$(dirname ${i})" ]; then
67 echo_parent_dirs ${i} >> /tmp/mkvardb_filelist
68 fi
69 echo ${i} >> /tmp/mkvardb_filelist
70 curdir=${i}
71 else
72 [ -d "${curdir}/${i}" ] && continue
73 echo "${curdir}/${i}" >> /tmp/mkvardb_filelist
74 fi
75 done
76 sort -u /tmp/mkvardb_filelist | sed -e 's://:/:'
77 }
78
79 function create_vardb {
80 VARDBDIR="${DB}/${category}/${pkgname}-${pkgver}"
81 # mkdir -p $VARDBDIR
82 cd $VARDBDIR
83 # cp $EBUILD $VARDBDIR
84 touch ASFLAGS CATEGORY CBUILD CC CDEPEND CFLAGS CHOST CONTENTS COUNTER CTARGET CXX CXXFLAGS DEPEND EXTRA_ECONF EXTRA_EINSTALL EXTRA_EMAKE FEATURES INHERITED IUSE LDFLAGS LDFLAGS LIBCFLAGS LIBCXXFLAGS LICENSE PDEPEND PF PKGUSE PROVIDE RDEPEND RESTRICT SLOT USE
85 echo ${category} > CATEGORY
86 echo $(portageq envvar CFLAGS) > CFLAGS
87 echo $(portageq envvar CHOST) > CHOST
88 echo $(portageq envvar CTARGET) > CTARGET
89 echo $(portageq envvar CXXFLAGS) > CXXFLAGS
90 echo eutils > INHERITED
91 echo ${pkgname}-${pkgver} > PF
92 echo 0 > SLOT
93 echo $(portageq envvar USE) > USE
94 echo ${provide} > PROVIDE
95 for i in $(sort_dirs_and_files); do
96 if [ -d ${i} ]; then
97 echo "dir ${i}" >> CONTENTS
98 else
99 time=$(stat -c %Y ${i})
100 md5=$(md5sum ${i} | cut -d ' ' -f 1)
101 echo "obj ${i} $md5 $time" >> CONTENTS
102 fi
103 done
104 }
105
106 # Parse args
107 params=${#}
108 while [ ${#} -gt 0 ]
109 do
110 a=${1}
111 shift
112 case "${a}" in
113
114 -h|--help)
115 usage
116 exit 0
117 ;;
118
119 -c|--category)
120 category=$1
121 shift
122 ;;
123
124 -p|--pkgname)
125 pkgname=$1
126 shift
127 ;;
128
129 -v|--pkgversion)
130 pkgver=$1
131 shift
132 ;;
133
134 --provide)
135 provide=$1
136 shift
137 ;;
138
139 -*)
140 echo "You have specified an invalid option: ${a}" 1>&2
141 usage
142 exit 1
143 ;;
144
145 *)
146 files[$filesindex]=$a
147 filesindex=$(expr $filesindex + 1)
148 ;;
149
150 esac
151 done
152
153 if [ "$category" = "" ]; then
154 echo "You must specify a category" 1>&2
155 usage
156 exit 1
157 fi
158 if [ "$pkgname" = "" ]; then
159 echo "You must specify a package name" 1>&2
160 usage
161 exit 1
162 fi
163 if [ "$pkgver" = "" ]; then
164 echo "You must specify a package version" 1>&2
165 usage
166 exit 1
167 fi
168 if [ $filesindex -eq 0 ]; then
169 echo "You must specify files to include in the package" 1>&2
170 usage
171 exit 1
172 fi
173
174 create_ebuild
175 create_vardb

Properties

Name Value
svn:eol-style native
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20