<commit_before># ipkg-lib.pl
# Functions for synology IPKG package management

use POSIX;
chop($system_arch = `uname -m`);
$package_dir = "/var/db/pkg";
$has_update_system = 1;
$no_package_install = 1;

sub list_package_system_commands
{
return ("ipkg");
}

# list_packages([package]*)
# Fills the array %packages with a list of all packages
# ipkg extension: if ALL is specified list also uninstalled packages
sub list_packages
{
local $i = 0;
local $arg = join(" ", map { quotemeta($_) } @_);
%packages = ( );
&open_execute_command(PKGINFO, "ipkg info", 1, 1);
while(<PKGINFO>) {
		$_ =~ s/\r|\n//g;
		local ($param, $val) = split(/: /, $_);
		if ($param eq 'Package') {
			$name=$val;
		} elsif ($param eq 'Version') {
			$version=$val;
		} elsif ($param eq 'Description') {
			$desc=$val;
		} elsif ($param eq 'Section') {
			$class=$val;
		} elsif ($param eq 'Installed-Time') {
			$inst=$val;
		} elsif ($val eq '') {
		    next if (! $inst && $arg ne "ALL");
			$packages{$i,'name'} = $name;
			$packages{$i,'version'} = $version;
			$packages{$i,'desc'} = $desc;
			$packages{$i,'install'} = $inst;  
			#$packages{$i,'class'} = $class; 
			# generate categories from names, lib and x
			$name =~ m/^(..[^-0-9]*)/;
			local $cat= $1;
			if ($class =~ m/^(audio|editor|games)/) {
				$cat=$1;
			} elsif ($cat =~ m/^(audio|auto|diff|lib|ffmpeg|gnu|gtk|perl|net|ncurses)/) {
				$cat=$1;
			} elsif ($cat =~ /^x|motif/ && $desc =~ /X |Xorg|X11|XDMCP|Xinerama|Athena|Motif/) {
				$cat = "x11";
			} elsif ($cat =~ /^x/ && $desc eq "") {
				$cat = "x";
			} elsif ($cat =~ /^(amavisdesmtp|fetchmail|mail|mini|mutt|mpop|msmtp|pop|postfix|postgrey|procmail|putmail|qpopper|sendmail|xmail)$/ ) {
				$cat = "mail";
			} elsif ($cat =~ /^(arc|bzi2p|cabextract|cpio|freeze|gzip|lha|lzo|p7|tar|upx|unarj|xz|zip|zlib|zoo|unzip|unrar)$/) {
				$cat = "archiver";
			} elsif ($cat =~ /^(apache|cherokee|hiawatha|lighttpd|minihttpd|mod|thttpd)$|^shell/) {
				$cat = "www";
			} 
			$packages{$i,'class'} = $cat; 
			$inst='';
			$i++;
			}
		}
close(PKGINFO);
return $i;
}


# package_info(package)
# Returns an array of package information in the order
#  name, class, description, arch, version, vendor, installtime
sub package_info
{
local $qm = quotemeta($_[0]);
local $out = &backquote_command("ipkg info $_[0] 2>&1", 1);
return () if ($?);
local @rv = ( $_[0] );
push(@rv, $out =~ /Section: (.+)/i);<commit_msg>fix category mail<commit_after># ipkg-lib.pl
# Functions for synology IPKG package management

use POSIX;
chop($system_arch = `uname -m`);
$package_dir = "/var/db/pkg";
$has_update_system = 1;
$no_package_install = 1;

sub list_package_system_commands
{
return ("ipkg");
}

# list_packages([package]*)
# Fills the array %packages with a list of all packages
# ipkg extension: if ALL is specified list also uninstalled packages
sub list_packages
{
local $i = 0;
local $arg = join(" ", map { quotemeta($_) } @_);
%packages = ( );
&open_execute_command(PKGINFO, "ipkg info", 1, 1);
while(<PKGINFO>) {
		$_ =~ s/\r|\n//g;
		local ($param, $val) = split(/: /, $_);
		if ($param eq 'Package') {
			$name=$val;
		} elsif ($param eq 'Version') {
			$version=$val;
		} elsif ($param eq 'Description') {
			$desc=$val;
		} elsif ($param eq 'Section') {
			$class=$val;
		} elsif ($param eq 'Installed-Time') {
			$inst=$val;
		} elsif ($val eq '') {
		    next if (! $inst && $arg ne "ALL");
			$packages{$i,'name'} = $name;
			$packages{$i,'version'} = $version;
			$packages{$i,'desc'} = $desc;
			$packages{$i,'install'} = $inst;  
			#$packages{$i,'class'} = $class; 
			# generate categories from names, lib and x
			$name =~ m/^(..[^-0-9]*)/;
			local $cat= $1;
			if ($class =~ m/^(audio|editor|games)/) {
				$cat=$1;
			} elsif ($cat =~ m/^(audio|auto|diff|lib|ffmpeg|gnu|gtk|perl|net|ncurses)/) {
				$cat=$1;
			} elsif ($cat =~ /^x|motif/ && $desc =~ /X |Xorg|X11|XDMCP|Xinerama|Athena|Motif/) {
				$cat = "x11";
			} elsif ($cat =~ /^x/ && $desc eq "") {
				$cat = "x";
			} elsif ($cat =~ /^(amavisd|esmtp|fetchmail|mail|mini|mutt|mpop|msmtp|pop|postfix|postgrey|procmail|putmail|qpopper|sendmail|xmail)$/ ) {
				$cat = "mail";
			} elsif ($cat =~ /^(arc|bzi2p|cabextract|cpio|freeze|gzip|lha|lzo|p7|tar|upx|unarj|xz|zip|zlib|zoo|unzip|unrar)$/) {
				$cat = "archiver";
			} elsif ($cat =~ /^(apache|cherokee|hiawatha|lighttpd|minihttpd|mod|thttpd)$|^shell/) {
				$cat = "www";
			} 
			$packages{$i,'class'} = $cat; 
			$inst='';
			$i++;
			}
		}
close(PKGINFO);
return $i;
}


# package_info(package)
# Returns an array of package information in the order
#  name, class, description, arch, version, vendor, installtime
sub package_info
{
local $qm = quotemeta($_[0]);
local $out = &backquote_command("ipkg info $_[0] 2>&1", 1);
return () if ($?);
local @rv = ( $_[0] );
push(@rv, $out =~ /Section: (.+)/i);
{'fraction_non_alphanumeric': 0.21953238154355473, 'fraction_numerical': 0.009104076143182288, 'mean_word_length': 4.072402938090241, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5791136', 'n_tokens_mistral': 2175, 'n_tokens_neox': 1968, 'n_words': 411}