My DpkgSearch.pl aim to really answer to my inspection. I want to see presence of de-installed file and are existing. Belong to an omission, the application is almost what I required to use to but... It did not use the Package Status akin to be "install" and "deinstall" a comparison between dpkg --get-selections did confirm it marshall all the install and de-install file.
The proof:
maxiste@ubuntu-devlpt:~/Documents/perl$ dpkg --get-selections | grep "deinstall" | wc -l
49
maxiste@ubuntu-devlpt:~/Documents/perl$ dpkg --get-selections | grep "install" | grep -v "deinstall" | wc -l
3055
echo $(( 3055 + 49 ))
3104
###
### Now with the application :
###
maxiste@ubuntu-devlpt:~/Documents/perl$ DSMD5Process=perl DSPkgStatus=deinstall DSDisplay=package DSSearch="^[a-zA-Z0-9]" DSIsRegExp=True DSLimit=0 ./DpkgSearch.pl | wc -l
3104
maxiste@ubuntu-devlpt:~/Documents/perl$ DSMD5Process=perl DSPkgStatus=install DSDisplay=package DSSearch="^[a-zA-Z0-9]" DSIsRegExp=True DSLimit=0 ./DpkgSearch.pl | wc -l
3104
Ok, it's not even make comparison between a "install" state and "deinstall" state.
So after looking at the code. I found why and in 5 things easy addable, make perl great to easily enhance this programmation. But where
2 Choices:
- Is it inside sub or function start()
- Is is inside sub or function ShowByItem()
As inside start:
At the foreach statement.
foreach my $line ( @lines )
{
$IsShowTime="False" ;
chomp($line);
if ( $MaxValuePrint > 0 )
{
if ( $IntCountMax <= ( $MaxValuePrint - 1 ) )
{
$IsShowTime="True" ;
}
$IntCountMax=$IntCountMax+$intStepAdd ;
}
else
{
$IsShowTime="True" ;
}
if ( $IsShowTime =~ /True/ )
{
$intStepAdd=ShowByItem($line , 0 ) ;
#^^^^^^^^^The entry is here and we can supply all the
# stuff to make the filtering of install and
# deinstall package. But how many line to add
# and probably adding twice whichs elements ?
}
}
or
inside ShowByItem()
sub ShowByItem
{
my $RegExpMode=$ENV{"DSIsRegExp"} ;
my $RegExpSearch=$ENV{"DSSearch"} ;
### to add to allow Package status to be considered.
my $PackageStatus=$ENV{"DSPkgStatus"} ; ### This one to add
my $StringMatching ;
my $intCountLine=0 ;
my $StrLine=$_[0] ;
my $intPosField=$_[1] ;
$StringMatching=per_line_matches( $StrLine , $intPosField );
### to add to allow Package status to be considered.
### It's the official location where a line contain
### "PACKAGE\t\tSTATUS\n" format
my $StrPackageStatus=per_line_matches( $StrLine , 1 ); ### This one to add
if ( $StrPackageStatus eq $PackageStatus ) ### This one to add
{
if ( $RegExpMode =~ /True/ )
{
if( $StringMatching =~ /$RegExpSearch/ )
{
$intCountLine=TypeShow( $StrLine , $intPosField ) ;
}
else
{
$intCountLine=0 ;
}
}
else
{
if( $RegExpSearch ne "" )
{
if( $StringMatching eq $RegExpSearch )
{
### At this level the Counting take or not the count, depending
### the number of match item being consider with variable DSLimit.
### Based on type of DSDisplay['package'] or DSDisplay['file']
### It query the number of line for DSLimit by package will certify
### to analyse more package than DSLimit. But in file showing
### we are not showing the package and only the file list.
### in a case DSLimit=10 .
### These can take more than 10 lines per package but not exceding
### the limit of 10 for showing 10 package, so $intCountLine will
### always serve to count package but does not lime by the time
### all the file being show.
$intCountLine=TypeShow( $StrLine , $intPosField ) ;
}
}
else
{
$intCountLine=TypeShow( $StrLine , $intPosField ) ; ;
}
}
}
else ### This one to add
{
$intCountLine=0 ; ### This one to add
}
return $intCountLine;
}
Underneath the fact is 5 things to add to make it possible. I give you one more hint and it's triviality and the reason we are showing and we are not showing everything look like an "If" condition that simply require it's counter-part and in 5 - One "if" and One "else" it require 3 others to ad and make the application view the difference between install and de-install.
like to note the behavior of the application at this function level. To return a number of line which is at least 1 or 0. Between showing something that fit inside the filter and 0, show nothing .
In the important thing you have:
- To create a variable and it's environment from prompt predefined-variable
- Get the value of the actual package and create the if for it.
So in point 1
my $PackageStatus=$ENV{"DSPkgStatus"} ;
In point 2
my $StrPackageStatus=per_line_matches( $StrLine , 1 );
The if
if ( $StrPackageStatus eq $PackageStatus )
All the code inside the brace of this if, the else in gift.
else ### This one to add
{
$intCountLine=0 ; ### This one to add
}
But those will getting from the github in Fnct.D won't even notice that problems.
And raise another point. Since we doubt having package in possible conflicts they are keep in dpkg database and still exist inside an configuration elsewhere ? Does it weight keeping them away but present. Sparing a size calculation to generate a size by package that include a size for de-installed package can eventually be an option since Perl is really handy.
I am showing information, because the other edge of this application is the will to store some search request and will not do all the digest or getting the information being re-executed again for the same query. Unless there is an update . But using an application in my Ubuntu installed via snap, the DB browser for sqlite is also possible to develop database with perl and directly with sqlite and doing my first table and the code for perl I fall in a question of validation for DpkgSearch and fall into this little error.
Table creation :
CREATE TABLE "PackageInformation" (
"PkID" INTEGER NOT NULL UNIQUE,
"PackageName" TEXT NOT NULL,
"PackageStatus" TEXT NOT NULL,
PRIMARY KEY("PkID" AUTOINCREMENT)
);
Being the first table it's important to not PackageStatus will be an only one introduction and in some it's true, if you have package being in the de-install statement inside dpkg it will enter into an insert with PackageStatus and "deinstall" and it have to be like this.
It's more important to say it be never being touch too to infirm in a table that do require to get a notice of it's state, it should exist a package that start into the mode of "install" into "deinstall" and will require to really make another PkID with this package-name and having PackageStatus being "deinstall". Because it answer installation need. And changing and PkId relation and it's content make the relation being false if you simply update the same package information with new data.
Because subsequent table will have correspondence. The Md5 table list depend of file and the digest but package too. And will depend of a valid installed package.
While there is no chance to have file in a list all empty, the presence of package-id, id by-file, the File table will also match from a PkId of PackageInformation but not those from the Md5 table.