source: lliurex-up/trunk/fuentes/lliurex-up-pool-scripts/usr/bin/runpart-from-repository @ 2978

Last change on this file since 2978 was 2978, checked in by kbut, 4 years ago

wip

  • Property svn:executable set to *
File size: 2.2 KB
Line 
1#!/bin/bash
2POOLPATH=$1
3CHANGELOGSFOLDER="changelogs" 
4DEBSPATH="${POOLPATH}/pool" # /srv/mirror/prueba-changelog/pool
5TEMPFOLDERDEB=$(mktemp -d)
6UNCOMPRESSEDDEB="${TEMPFOLDERDEB}/deb/" #/tmp/temp654/deb
7
8function buildChangelog(){
9        DESTPATH="$1"
10        PACKAGESOURCENAME="$2"
11       
12
13        CHANGELOGFILE=$(find ${UNCOMPRESSEDDEB} -name changelog.Debian.gz)
14        test -e "${CHANGELOGFILE}" || CHANGELOGFILE=$(find ${UNCOMPRESSEDDEB} -name changelog.gz)
15        if [ -e "${CHANGELOGFILE}" ]; then
16                mkdir -p "${DESTPATH}"
17                gunzip "${CHANGELOGFILE}" || echo "${CHANGELOGFILE}"
18                cp "${CHANGELOGFILE%*.gz}" "${DESTPATH}/changelog"
19                mkdir -p "${DESTPATH}/token/"
20                touch "${DESTPATH}/token/${PACKAGESOURCENAME}.changelog"
21        else
22                PACKAGE="$(basename $DESTPATH)"
23                echo "Fail on $PACKAGE"
24        fi
25}
26
27function buildDesktopInfo(){
28        DESTPATH="$1"
29        PACKAGENAME="$2"
30        DESKTOPFILES=$(find ${UNCOMPRESSEDDEB} -name *.desktop)
31        if [ -e "${DESTPATH}/icons" ]; then
32                sed -i -e "/^$PACKAGENAME :/d" ${DESTPATH}/icons
33        fi
34        ICONS=""
35        for x in ${DESKTOPFILES}; do
36                AUX="$(rgrep -i 'Icon=' $x | sed -e '')"
37                if [ "$AUX" != "" ]; then
38                        mkdir -p "${DESTPATH}"
39                        echo "${PACKAGENAME} : $AUX" >> ${DESTPATH}/icons
40                fi
41        done
42        mkdir -p "${DESTPATH}/token/"
43        touch "${DESTPATH}/token/${PACKAGENAME}.icons"
44}
45
46
47for x in $(find $DEBSPATH -type f -printf "%P\n"); do #
48        rc=0
49        echo "$x" | grep -E -q "\.deb$" || rc=1 
50        if [ "$rc" != "0" ]; then
51                continue
52        fi
53        #FOLDERDEB=$(echo $x | sed -E -e "s/_all.deb$|_i386.deb$|_amd64.deb$//g")
54        FOLDERDEB=$(dirname $x)
55        PACKAGESOURCENAME=$(getinfofromdeb ${DEBSPATH}/$x '${Source}_${VersionWithoutEra}')
56        PACKAGENAME=$(getinfofromdeb ${DEBSPATH}/$x '${Package}')
57        if [ "${PACKAGESOURCENAME}" = "" ]; then
58                echo "Falla"
59                continue
60        fi
61        DESTPATH="${POOLPATH}/${CHANGELOGSFOLDER}/pool/${FOLDERDEB}/${PACKAGESOURCENAME}"
62        if [ ! -e "${DESTPATH}/token/${PACKAGESOURCENAME}.changelog" -o ! -e "${DESTPATH}/token/${PACKAGENAME}.icons" ] ; then
63                mkdir "${UNCOMPRESSEDDEB}"
64                dpkg -x "${DEBSPATH}/${x}" "${UNCOMPRESSEDDEB}"
65                [ -e "${DESTPATH}/token/${PACKAGESOURCENAME}.changelog" ] || buildChangelog $DESTPATH $PACKAGESOURCENAME
66                [ -e "${DESTPATH}/token/${PACKAGENAME}.icons" ] || buildDesktopInfo $DESTPATH $PACKAGENAME
67                rm -r ${UNCOMPRESSEDDEB}
68        fi
69done
70
Note: See TracBrowser for help on using the repository browser.