blob: a51a1d1c6f02a95bc12a7c848ecb9af94b784003 [file] [log] [blame]
Sergio Slobodrian86843702017-09-05 23:22:39 -04001#!/bin/bash
Zack Williams41513bf2018-07-07 20:08:35 -07002# Copyright 2017-present Open Networking Foundation
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
Sergio Slobodrian86843702017-09-05 23:22:39 -040015
16debDir="deb_files"
17
18rm -f deb_info.txt
19rm -f debFiles.txt
20rm -f sortedDebs.txt
21
22# Create the paackage information file for further processing by Python
23ls $debDir/*.deb | sed -e 's~deb_files/~~' > debFiles.txt
24
25
26for i in `cat debFiles.txt`
27do
28 pkgName=""
29 deps=""
30 pkgName=`dpkg -I $debDir/$i | egrep "^[ ]*Package:" | sed -e 's/Package://' | sed -e 's/\([ ]\+\)\|\([ ]\+$\)//'`
31 deps=`dpkg -I $debDir/$i | grep Depends: | sed -e 's/Depends://' | sed -e 's/\([ ]\+\)\|\([ ]\+$\)//'`
32 deps=`echo $deps | sed -e 's/|/,/g' | sed -e 's/([^)]\+)//g' | sed -e 's/:any//g' | sed -e 's/,//g'`
33 deps=`echo $deps | sed -e 's/[ ]\+/ /g' | sed -e 's/\(^[ ]\+\)\|\([ ]\+$\)//' | sed -e 's/ /,/g'`
34 #deps=`echo $deps | sed -e 's/^\(.\)/"\1/' | sed -e 's/\(.\)$/\1"/' | sed -s 's/,/","/g'`
35 echo "${pkgName}:${i}:${deps}" >> deb_info.txt
36done
37rm -f debFiles.txt
38
39# Now launch the python scrip that sorts the files based on the dependencies.
40./sort_packages.py > sortedDebs.txt
41
42rm -f deb_info.txt