]> Pileus Git - ~andy/sunrise/blob - scripts/use_desc_gen.sh
02e48b5e93d9bbd513d3e474c24b3539fe6449ec
[~andy/sunrise] / scripts / use_desc_gen.sh
1 #!/bin/sh
2 # Written by Douglas Goldstein <cardoe@gentoo.org>
3 # This code is hereby placed into the public domain
4 #
5 # $Id: use_desc_gen.sh,v 1.6 2008/08/23 21:28:28 robbat2 Exp $
6
7 usage() {
8         prog=$(basename $1)
9
10         echo "${prog} /path/to/portage/tree"
11         exit 1;
12 }
13
14 if [ $# -ne 1 ]; then
15         usage $0;
16 fi
17
18 if [ "x${1}" = "x-h" -o "x${1}" = "x--help" ]; then
19         usage $0;
20 fi
21
22 if [ ! -f "${1}/profiles/use.local.desc" ]; then
23         usage $0;
24 fi
25
26 pid=$(echo $$)
27
28 # make list of categories that we want to remove from current use.local.desc
29 #cat "${1}/profiles/use.local.desc" | sed '1,/# The following categories/d;/# End of metadata categories/,$d;s/^../^/' > /tmp/${pid}.grep
30
31 # we also want to remove comments and blank lines
32 #echo "^#" >> /tmp/${pid}.grep
33 #echo "^$" >> /tmp/${pid}.grep
34
35 # make list of categories to process with use_desc_gen (same as above without grep rule)
36 #cat "${1}/profiles/use.local.desc" | sed '1,/# The following categories/d;/# End of metadata categories/,$d;s/^..//' > /tmp/${pid}.categories
37
38 # take comments from existing use.local.desc
39 grep '^#' "${1}/profiles/use.local.desc" > /tmp/${pid}.use.local.desc
40 echo "" >> /tmp/${pid}.use.local.desc
41
42 # use list from step #1 to filter current use.local.desc and add un-converted categories to new use.local.desc
43 #grep -v -f /tmp/${pid}.grep "${1}/profiles/use.local.desc" > /tmp/${pid}.new.use
44
45 # the secret sauce, append to new use.local.desc
46 python scripts/use_desc_gen.py --repo_path "${1}" > /tmp/${pid}.new.use
47
48 # let's keep it sorted: use major category, minor category, and package name
49 # as primary, secondary, and tertiary sort keys, respectively
50 sort -t: -k1,1 -k2 /tmp/${pid}.new.use | sort -s -t/ -k1,1 \
51     >> /tmp/${pid}.use.local.desc
52
53 # clean up
54 #rm -rf /tmp/${pid}.categories
55 #rm -rf /tmp/${pid}.grep
56 rm -rf /tmp/${pid}.new.use
57
58 mv /tmp/${pid}.use.local.desc profiles/use.local.desc