idx int64 0 63k | question stringlengths 53 5.28k | target stringlengths 5 805 |
|---|---|---|
60,300 | def pkg_checksum ( binary , repo ) : md5 = "None" if repo == "slack_patches" and _meta_ . slack_rel == "stable" : CHECKSUMS_md5 = URL ( mirrors ( "CHECKSUMS.md5" , "patches/" ) ) . reading ( ) elif repo == "slack_patches" and _meta_ . slack_rel == "current" : CHECKSUMS_md5 = URL ( mirrors ( "CHECKSUMS.md5" , "" ) ) . reading ( ) elif repo == "slpkg" : CHECKSUMS_md5 = URL ( _meta_ . CHECKSUMS_link ) . reading ( ) else : lib = "{0}{1}_repo/CHECKSUMS.md5" . format ( _meta_ . lib_path , repo ) f = open ( lib , "r" ) CHECKSUMS_md5 = f . read ( ) f . close ( ) for line in CHECKSUMS_md5 . splitlines ( ) : if line . endswith ( "/{0}" . format ( binary ) ) : md5 = line . split ( ) [ 0 ] return md5 | Return checksum from CHECKSUMS . md5 file by repository |
60,301 | def library ( repo ) : pkg_list , packages = [ ] , "" if repo == "sbo" : if ( os . path . isfile ( _meta_ . lib_path + "{0}_repo/SLACKBUILDS.TXT" . format ( repo ) ) ) : packages = Utils ( ) . read_file ( _meta_ . lib_path + "{0}_repo/" "SLACKBUILDS.TXT" . format ( repo ) ) else : if ( os . path . isfile ( _meta_ . lib_path + "{0}_repo/PACKAGES.TXT" . format ( repo ) ) ) : packages = Utils ( ) . read_file ( _meta_ . lib_path + "{0}_repo/" "PACKAGES.TXT" . format ( repo ) ) for line in packages . splitlines ( ) : if repo == "sbo" : if line . startswith ( "SLACKBUILD NAME: " ) : pkg_list . append ( line [ 17 : ] . strip ( ) ) elif "local" not in repo : if line . startswith ( "PACKAGE NAME: " ) : pkg_list . append ( line [ 15 : ] . strip ( ) ) if repo == "local" : pkg_list = find_package ( "" , _meta_ . pkg_path ) return pkg_list | Load packages from slpkg library and from local |
60,302 | def info ( self , name , sbo_file ) : return URL ( self . sbo_url + name + sbo_file ) . reading ( ) | Read info file |
60,303 | def slackbuild ( self , name , sbo_file ) : return URL ( self . sbo_url + name + sbo_file ) . reading ( ) | Read SlackBuild file |
60,304 | def run ( self ) : self . files_exist ( ) self . info_file ( ) sources = self . sources if len ( sources ) > 1 and self . sbo_sources != sources : sources = self . sbo_sources BuildPackage ( self . script , sources , self . path , auto = True ) . build ( ) raise SystemExit ( ) | Build package and fix ordelist per checksum |
60,305 | def info_file ( self ) : sources = SBoGrep ( self . prgnam ) . source ( ) . split ( ) for source in sources : self . sbo_sources . append ( source . split ( "/" ) [ - 1 ] ) | Grab sources from . info file and store filename |
60,306 | def files_exist ( self ) : if not os . path . isfile ( self . path + self . script ) : print ( "\nslpkg: Error: SlackBuild archive.tar.gz not found\n" ) raise SystemExit ( ) for src in self . sources : if not os . path . isfile ( self . path + src ) : print ( "\nslpkg: Error: Source file '{0}' not found\n" . format ( src ) ) raise SystemExit ( ) | Check if SlackBuild archive . tar . gz and sources exist |
60,307 | def help_version ( self ) : if ( len ( self . args ) == 1 and self . args [ 0 ] in [ "-h" , "--help" ] and self . args [ 1 : ] == [ ] ) : options ( ) elif ( len ( self . args ) == 1 and self . args [ 0 ] in [ "-v" , "--version" ] and self . args [ 1 : ] == [ ] ) : prog_version ( ) else : usage ( "" ) | Help and version info |
60,308 | def command_update ( self ) : if len ( self . args ) == 1 and self . args [ 0 ] == "update" : Update ( ) . repository ( only = "" ) elif ( len ( self . args ) == 2 and self . args [ 0 ] == "update" and self . args [ 1 ] . startswith ( "--only=" ) ) : repos = self . args [ 1 ] . split ( "=" ) [ - 1 ] . split ( "," ) for rp in repos : if rp not in self . meta . repositories : repos . remove ( rp ) Update ( ) . repository ( repos ) else : usage ( "" ) | Update package lists repositories |
60,309 | def command_repo_add ( self ) : if len ( self . args ) == 3 and self . args [ 0 ] == "repo-add" : Repo ( ) . add ( self . args [ 1 ] , self . args [ 2 ] ) else : usage ( "" ) | Add custom repositories |
60,310 | def command_repo_remove ( self ) : if len ( self . args ) == 2 and self . args [ 0 ] == "repo-remove" : Repo ( ) . remove ( self . args [ 1 ] ) else : usage ( "" ) | Remove custom repositories |
60,311 | def command_upgrade ( self ) : if len ( self . args ) == 1 and self . args [ 0 ] == "upgrade" : Initialization ( False ) . upgrade ( only = "" ) elif ( len ( self . args ) == 2 and self . args [ 0 ] == "upgrade" and self . args [ 1 ] . startswith ( "--only=" ) ) : repos = self . args [ 1 ] . split ( "=" ) [ - 1 ] . split ( "," ) for rp in repos : if rp not in self . meta . repositories : repos . remove ( rp ) Initialization ( False ) . upgrade ( repos ) else : usage ( "" ) | Recreate repositories package lists |
60,312 | def command_health ( self ) : if len ( self . args ) == 1 and self . args [ 0 ] == "health" : PackageHealth ( mode = "" ) . test ( ) elif ( len ( self . args ) == 2 and self . args [ 0 ] == "health" and self . args [ 1 ] == "--silent" ) : PackageHealth ( mode = self . args [ 1 ] ) . test ( ) else : usage ( "" ) | Check package health |
60,313 | def command_deps_status ( self ) : image = "" for arg in self . args : if arg . startswith ( "--graph=" ) : image = arg . split ( "=" ) [ 1 ] if len ( self . args ) == 1 and self . args [ 0 ] == "deps-status" : DependenciesStatus ( image ) . show ( ) elif len ( self . args ) == 2 and self . args [ 0 ] == "deps-status" and image : DependenciesStatus ( image ) . show ( ) elif ( len ( self . args ) == 2 and self . args [ 0 ] == "deps-status" and "--tree" in self . args ) : DependenciesStatus ( image ) . tree ( ) elif ( len ( self . args ) == 3 and self . args [ 0 ] == "deps-status" and "--tree" in self . args and image ) : DependenciesStatus ( image ) . tree ( ) else : usage ( "" ) | Print dependencies status |
60,314 | def command_new_config ( self ) : if len ( self . args ) == 1 and self . args [ 0 ] == "new-config" : NewConfig ( ) . run ( ) else : usage ( "" ) | Manage . new configuration files |
60,315 | def auto_build ( self ) : options = [ "-a" , "--autobuild" ] if len ( self . args ) >= 3 and self . args [ 0 ] in options : AutoBuild ( self . args [ 1 ] , self . args [ 2 : ] , self . meta . path ) . run ( ) else : usage ( "" ) | Auto built tool |
60,316 | def pkg_list ( self ) : options = [ "-l" , "--list" ] flag = [ "--index" , "--installed" , "--name" ] name = INDEX = installed = False for arg in self . args [ 2 : ] : if flag [ 0 ] == arg : INDEX = True if flag [ 1 ] in arg : installed = True if flag [ 2 ] == arg : name = True if arg not in flag : usage ( "" ) raise SystemExit ( ) if ( len ( self . args ) > 1 and len ( self . args ) <= 5 and self . args [ 0 ] in options ) : if self . args [ 1 ] in self . meta . repositories : PackageManager ( binary = None ) . package_list ( self . args [ 1 ] , name , INDEX , installed ) else : usage ( self . args [ 1 ] ) else : usage ( "" ) | List of packages by repository |
60,317 | def pkg_upgrade ( self ) : options = [ "-c" , "--check" ] flags = [ "--upgrade" , "--skip=" , "--resolve-off" , "--checklist" , "--rebuild" ] flag , skip = self . __pkg_upgrade_flags ( flags ) if ( len ( self . args ) == 3 and self . args [ 0 ] in options and self . args [ 2 ] == flags [ 0 ] and self . args [ 1 ] in self . meta . repositories ) : if self . args [ 1 ] not in [ "slack" , "sbo" ] : BinaryInstall ( pkg_upgrade ( self . args [ 1 ] , skip , flag ) , self . args [ 1 ] , flag ) . start ( is_upgrade = True ) elif self . args [ 1 ] == "slack" : if self . meta . only_installed in [ "on" , "ON" ] : BinaryInstall ( pkg_upgrade ( "slack" , skip , flag ) , "slack" , flag ) . start ( is_upgrade = True ) else : Patches ( skip , flag ) . start ( ) elif self . args [ 1 ] == "sbo" : SBoInstall ( sbo_upgrade ( skip , flag ) , flag ) . start ( is_upgrade = True ) else : usage ( self . args [ 1 ] ) elif len ( self . args ) == 2 and self . args [ 0 ] in options : if self . args [ 1 ] == "ALL" : Updates ( repo = "" ) . ALL ( ) else : Updates ( self . args [ 1 ] ) . run ( ) elif ( len ( self . args ) >= 2 and self . args [ 0 ] in options and self . args [ 1 ] not in self . meta . repositories ) : usage ( self . args [ 1 ] ) else : usage ( "" ) | Check and upgrade packages by repository |
60,318 | def __pkg_upgrade_flags ( self , flags ) : flag , skip = [ ] , "" if flags [ 0 ] in self . args : for arg in self . args [ 3 : ] : if arg . startswith ( flags [ 1 ] ) : skip = Regex ( arg . split ( "=" ) [ 1 ] ) . get ( ) self . args . remove ( arg ) if arg in flags : flag . append ( arg ) if arg in self . args : self . args . remove ( arg ) return flag , skip | Manage flags for package upgrade option |
60,319 | def pkg_install ( self ) : flag = [ ] options = [ "-s" , "--sync" ] additional_options = [ "--resolve-off" , "--download-only" , "--directory-prefix=" , "--case-ins" , "--rebuild" , "--reinstall" , "--patches" ] for arg in self . args : if arg . startswith ( additional_options [ 2 ] ) : flag . append ( arg ) arg = "" if arg in additional_options : flag . append ( arg ) for ar in flag : if ar in self . args : self . args . remove ( ar ) if len ( self . args ) >= 3 and self . args [ 0 ] in options : if ( self . args [ 1 ] in self . meta . repositories and self . args [ 1 ] not in [ "sbo" ] ) : BinaryInstall ( self . args [ 2 : ] , self . args [ 1 ] , flag ) . start ( is_upgrade = False ) elif ( self . args [ 1 ] == "sbo" and self . args [ 1 ] in self . meta . repositories ) : SBoInstall ( self . args [ 2 : ] , flag ) . start ( is_upgrade = False ) else : usage ( self . args [ 1 ] ) else : usage ( "" ) | Install packages by repository |
60,320 | def pkg_tracking ( self ) : flag = [ ] options = [ "-t" , "--tracking" ] additional_options = [ "--check-deps" , "--graph=" , "--case-ins" ] for arg in self . args [ 2 : ] : if arg . startswith ( additional_options [ 1 ] ) : flag . append ( arg ) self . args . remove ( arg ) if arg in additional_options : flag . append ( arg ) for f in flag : if f in self . args : self . args . remove ( f ) for arg in self . args : if arg . startswith ( "--" ) : if arg not in additional_options : usage ( "" ) raise SystemExit ( ) if ( len ( self . args ) >= 3 and len ( self . args ) <= 3 and self . args [ 0 ] in options and self . args [ 1 ] in self . meta . repositories ) : TrackingDeps ( self . args [ 2 ] , self . args [ 1 ] , flag ) . run ( ) elif ( len ( self . args ) >= 2 and self . args [ 1 ] not in self . meta . repositories ) : usage ( self . args [ 1 ] ) else : usage ( "" ) | Tracking package dependencies |
60,321 | def sbo_network ( self ) : flag = [ ] options = [ "-n" , "--network" ] additional_options = [ "--checklist" , "--case-ins" ] for add in additional_options : if add in self . args : flag . append ( add ) self . args . remove ( add ) if ( len ( self . args ) == 2 and self . args [ 0 ] in options and "sbo" in self . meta . repositories ) : SBoNetwork ( self . args [ 1 ] , flag ) . view ( ) else : usage ( "sbo" ) | View slackbuilds packages |
60,322 | def pkg_blacklist ( self ) : blacklist = BlackList ( ) options = [ "-b" , "--blacklist" ] flag = [ "--add" , "--remove" ] command = [ "list" ] if ( len ( self . args ) == 2 and self . args [ 0 ] in options and self . args [ 1 ] == command [ 0 ] ) : blacklist . listed ( ) elif ( len ( self . args ) > 2 and self . args [ 0 ] in options and flag [ 0 ] in self . args ) : self . args . remove ( flag [ 0 ] ) blacklist . add ( self . args [ 1 : ] ) elif ( len ( self . args ) == 3 and self . args [ 0 ] in options and "ALL" in self . args and flag [ 1 ] in self . args ) : self . args . remove ( flag [ 1 ] ) blacklist . remove ( blacklist . get_black ( ) ) elif ( len ( self . args ) > 2 and self . args [ 0 ] in options and flag [ 1 ] in self . args ) : self . args . remove ( flag [ 1 ] ) blacklist . remove ( self . args [ 1 : ] ) else : usage ( "" ) | Manage blacklist packages |
60,323 | def pkg_queue ( self ) : queue = QueuePkgs ( ) options = [ "-q" , "--queue" ] flag = [ "--add" , "--remove" ] command = [ "list" , "build" , "install" , "build-install" ] if ( len ( self . args ) > 2 and self . args [ 0 ] in options and flag [ 0 ] in self . args ) : self . args . remove ( flag [ 0 ] ) queue . add ( self . args [ 1 : ] ) elif ( len ( self . args ) == 3 and self . args [ 0 ] in options and "ALL" in self . args and flag [ 1 ] in self . args ) : self . args . remove ( flag [ 1 ] ) queue . remove ( queue . packages ( ) ) elif ( len ( self . args ) > 2 and self . args [ 0 ] in options and flag [ 1 ] in self . args ) : self . args . remove ( flag [ 1 ] ) queue . remove ( self . args [ 1 : ] ) elif ( len ( self . args ) == 2 and self . args [ 0 ] in options and self . args [ 1 ] == command [ 0 ] ) : queue . listed ( ) elif ( len ( self . args ) == 2 and self . args [ 0 ] in options and self . args [ 1 ] == command [ 1 ] ) : queue . build ( ) elif ( len ( self . args ) == 2 and self . args [ 0 ] in options and self . args [ 1 ] == command [ 2 ] ) : queue . install ( ) elif ( len ( self . args ) == 2 and self . args [ 0 ] in options and self . args [ 1 ] == command [ 3 ] ) : queue . build ( ) queue . install ( ) else : usage ( "" ) | Manage packages in queue |
60,324 | def bin_install ( self ) : packages = self . args [ 1 : ] options = [ "-i" , "--installpkg" ] flag = "" flags = [ "--warn" , "--md5sum" , "--root" , "--infobox" , "--menu" , "--terse" , "--ask" , "--priority" , "--tagfile" ] if len ( self . args ) > 1 and self . args [ 0 ] in options : if self . args [ 1 ] in flags : flag = self . args [ 1 ] packages = self . args [ 2 : ] PackageManager ( packages ) . install ( flag ) else : usage ( "" ) | Install Slackware binary packages |
60,325 | def bin_upgrade ( self ) : packages = self . args [ 1 : ] options = [ "-u" , "--upgradepkg" ] flag = "" flags = [ "--dry-run" , "--install-new" , "--reinstall" , "--verbose" ] if len ( self . args ) > 1 and self . args [ 0 ] in options : if self . args [ 1 ] in flags : flag = self . args [ 1 ] packages = self . args [ 2 : ] PackageManager ( packages ) . upgrade ( flag ) else : usage ( "" ) | Install - upgrade Slackware binary packages |
60,326 | def bin_remove ( self ) : packages = self . args [ 1 : ] options = [ "-r" , "--removepkg" ] additional_options = [ "--deps" , "--check-deps" , "--tag" , "--checklist" ] flag , extra = "" , [ ] flags = [ "-warn" , "-preserve" , "-copy" , "-keep" ] if ( additional_options [ 1 ] in self . args and additional_options [ 0 ] not in self . args ) : self . args . append ( additional_options [ 0 ] ) if len ( self . args ) > 1 and self . args [ 0 ] in options : for additional in additional_options : if additional in self . args : extra . append ( additional ) self . args . remove ( additional ) packages = self . args [ 1 : ] for fl in flags : if fl in self . args : flag = self . args [ 1 ] packages = self . args [ 2 : ] PackageManager ( packages ) . remove ( flag , extra ) else : usage ( "" ) | Remove Slackware packages |
60,327 | def bin_find ( self ) : flag = [ ] options = [ "-f" , "--find" ] additional_options = [ "--case-ins" ] for arg in self . args : if arg in additional_options : flag . append ( arg ) self . args . remove ( arg ) packages = self . args [ 1 : ] if len ( self . args ) > 1 and self . args [ 0 ] in options : PackageManager ( packages ) . find ( flag ) else : usage ( "" ) | Find installed packages |
60,328 | def pkg_desc ( self ) : options = [ "-p" , "--desc" ] flag = [ "--color=" ] colors = [ "red" , "green" , "yellow" , "cyan" , "grey" ] tag = "" for arg in self . args : if arg . startswith ( flag [ 0 ] ) : tag = arg [ len ( flag [ 0 ] ) : ] self . args . remove ( arg ) break if tag and tag not in colors : print ( "\nslpkg: Error: Available colors {0}\n" . format ( colors ) ) raise SystemExit ( ) if ( len ( self . args ) == 3 and self . args [ 0 ] in options and self . args [ 1 ] in self . meta . repositories and tag in colors ) : PkgDesc ( self . args [ 2 ] , self . args [ 1 ] , tag ) . view ( ) elif ( len ( self . args ) == 3 and self . args [ 0 ] in options and self . args [ 1 ] in self . meta . repositories ) : PkgDesc ( self . args [ 2 ] , self . args [ 1 ] , paint = "" ) . view ( ) elif ( len ( self . args ) > 1 and self . args [ 0 ] in options and self . args [ 1 ] not in self . meta . repositories ) : usage ( self . args [ 1 ] ) else : usage ( "" ) | Print slack - desc by repository |
60,329 | def pkg_find ( self ) : flag = [ ] options = [ "-F" , "--FIND" ] additional_options = [ "--case-ins" ] for arg in self . args : if arg in additional_options : flag . append ( arg ) self . args . remove ( arg ) packages = self . args [ 1 : ] if len ( self . args ) > 1 and self . args [ 0 ] in options : FindFromRepos ( ) . find ( packages , flag ) else : usage ( "" ) | Find packages from all enabled repositories |
60,330 | def pkg_contents ( self ) : packages = self . args [ 1 : ] options = [ "-d" , "--display" ] if len ( self . args ) > 1 and self . args [ 0 ] in options : PackageManager ( packages ) . display ( ) else : usage ( "" ) | Print packages contents |
60,331 | def congiguration ( self ) : options = [ "-g" , "--config" ] command = [ "print" , "edit" , "reset" ] conf = Config ( ) if ( len ( self . args ) == 2 and self . args [ 0 ] in options and self . args [ 1 ] == command [ 1 ] ) : conf . edit ( ) elif ( len ( self . args ) == 2 and self . args [ 0 ] in options and self . args [ 1 ] == ( command [ 0 ] ) ) : conf . view ( ) elif ( len ( self . args ) == 2 and self . args [ 0 ] in options and self . args [ 1 ] == ( command [ 2 ] ) ) : conf . reset ( ) else : usage ( "" ) | Manage slpkg configuration file |
60,332 | def auto_detect ( self , args ) : suffixes = [ ".tgz" , ".txz" , ".tbz" , ".tlz" ] if ( not args [ 0 ] . startswith ( "-" ) and args [ 0 ] not in self . commands and args [ 0 ] . endswith ( tuple ( suffixes ) ) ) : packages , not_found = [ ] , [ ] for pkg in args : if pkg . endswith ( tuple ( suffixes ) ) : if os . path . isfile ( pkg ) : packages . append ( pkg ) else : not_found . append ( pkg ) if packages : Auto ( packages ) . select ( ) if not_found : for ntf in not_found : self . msg . pkg_not_found ( "" , ntf , "Not installed" , "" ) raise SystemExit ( ) | Check for already Slackware binary packages exist |
60,333 | def search_pkg ( name , repo ) : PACKAGES_TXT = Utils ( ) . read_file ( _meta_ . lib_path + "{0}_repo/" "PACKAGES.TXT" . format ( repo ) ) names = Utils ( ) . package_name ( PACKAGES_TXT ) blacklist = BlackList ( ) . packages ( pkgs = names , repo = repo ) for line in PACKAGES_TXT . splitlines ( ) : status ( 0 ) if line . startswith ( "PACKAGE NAME: " ) and len ( line ) > 16 : pkg_name = split_package ( line [ 15 : ] ) [ 0 ] . strip ( ) if name == pkg_name and name not in blacklist : return pkg_name | Search if package exists in PACKAGES . TXT file and return the name . |
60,334 | def data ( self ) : for pkg in self . installed : if os . path . isfile ( self . meta . pkg_path + pkg ) : name = split_package ( pkg ) [ 0 ] for log in self . logs : deps = Utils ( ) . read_file ( self . dep_path + log ) for dep in deps . splitlines ( ) : if name == dep : if name not in self . dmap . keys ( ) : self . dmap [ name ] = [ log ] if not self . count_pkg : self . count_pkg = 1 else : self . dmap [ name ] += [ log ] self . count_packages ( ) | Check all installed packages and create dictionary database |
60,335 | def count_packages ( self ) : packages = [ ] for pkg in self . dmap . values ( ) : packages += pkg self . count_dep += 1 self . count_pkg = len ( set ( packages ) ) | Count dependencies and packages |
60,336 | def show ( self ) : self . data ( ) print ( "" ) self . msg . template ( 78 ) print ( "| {0}{1}{2}" . format ( "Dependencies" , " " * 20 , "Packages" ) ) self . msg . template ( 78 ) for key , value in self . dmap . iteritems ( ) : print ( " {0}{1}{2}{3}{4}" . format ( self . green , key , self . endc , " " * ( 32 - len ( key ) ) , ", " . join ( value ) ) ) self . summary ( ) if self . image : Graph ( self . image ) . dependencies ( self . dmap ) | Show dependencies status |
60,337 | def tree ( self ) : self . msg . template ( 78 ) print ( "| Dependencies\n" "| -- Packages" ) self . msg . template ( 78 ) self . data ( ) for pkg , dep in self . dmap . iteritems ( ) : print ( "+ {0}{1}{2}" . format ( self . green , pkg , self . endc ) ) print ( "|" ) for d in dep : print ( "+-- {0}" . format ( d ) ) print ( "|" ) sys . stdout . write ( "\x1b[1A{0}\n" . format ( " " ) ) sys . stdout . flush ( ) self . summary ( ) if self . image : Graph ( self . image ) . dependencies ( self . dmap ) | Like tree view mode |
60,338 | def summary ( self ) : print ( "\nStatus summary" ) print ( "=" * 79 ) print ( "{0}found {1} dependencies in {2} packages.{3}\n" . format ( self . grey , self . count_dep , self . count_pkg , self . endc ) ) | Summary by packages and dependencies |
60,339 | def find ( self , pkg , flag ) : print ( "\nPackages with name matching [ {0}{1}{2} ]\n" . format ( self . cyan , ", " . join ( pkg ) , self . endc ) ) Msg ( ) . template ( 78 ) print ( "| {0} {1}{2}{3}" . format ( "Repository" , "Package" , " " * 54 , "Size" ) ) Msg ( ) . template ( 78 ) for repo in _meta_ . repositories : PACKAGES_TXT = PackageManager ( pkg ) . list_lib ( repo ) packages , sizes = PackageManager ( pkg ) . list_greps ( repo , PACKAGES_TXT ) for find , size in zip ( packages , sizes ) : for p in pkg : if "--case-ins" in flag : self . p_cache = p . lower ( ) self . find_cache = find . lower ( ) else : self . p_cache = p self . find_cache = find if self . p_cache in self . find_cache : if self . cache != repo : self . count_repo += 1 self . cache = repo self . count_pkg += 1 ver = self . sbo_version ( repo , find ) print ( " {0}{1}{2}{3}{4} {5}{6:>11}" . format ( self . cyan , repo , self . endc , " " * ( 12 - len ( repo ) ) , find + ver , " " * ( 53 - len ( find + ver ) ) , size ) ) print ( "\nFound summary" ) print ( "=" * 79 ) print ( "{0}Total found {1} packages in {2} repositories." "{3}\n" . format ( self . grey , self . count_pkg , self . count_repo , self . endc ) ) | Start to find packages and print |
60,340 | def sbo_version ( self , repo , find ) : ver = "" if repo == "sbo" : ver = "-" + SBoGrep ( find ) . version ( ) return ver | Add version to SBo packages |
60,341 | def add ( self , repo , url ) : repo_name = [ ] if not url . endswith ( "/" ) : url = url + "/" for line in self . custom_repositories_list . splitlines ( ) : line = line . lstrip ( ) if line and not line . startswith ( "#" ) : repo_name . append ( line . split ( ) [ 0 ] ) if ( repo in self . meta . repositories or repo in repo_name or repo in self . meta . default_repositories ) : print ( "\nRepository name '{0}' exist, select different name.\n" "View all repositories with command 'slpkg " "repo-list'.\n" . format ( repo ) ) raise SystemExit ( ) elif len ( repo ) > 6 : print ( "\nslpkg: Error: Maximum repository name length must be " "six (6) characters\n" ) raise SystemExit ( ) with open ( self . custom_repo_file , "a" ) as repos : new_line = " {0}{1}{2}\n" . format ( repo , " " * ( 10 - len ( repo ) ) , url ) repos . write ( new_line ) repos . close ( ) print ( "\nRepository '{0}' successfully added\n" . format ( repo ) ) raise SystemExit ( ) | Write custom repository name and url in a file |
60,342 | def remove ( self , repo ) : rem_repo = False with open ( self . custom_repo_file , "w" ) as repos : for line in self . custom_repositories_list . splitlines ( ) : repo_name = line . split ( ) [ 0 ] if repo_name != repo : repos . write ( line + "\n" ) else : print ( "\nRepository '{0}' successfully " "removed\n" . format ( repo ) ) rem_repo = True repos . close ( ) if not rem_repo : print ( "\nRepository '{0}' doesn't exist\n" . format ( repo ) ) raise SystemExit ( ) | Remove custom repository |
60,343 | def default_repository ( self ) : default_dict_repo = { } for line in self . default_repositories_list . splitlines ( ) : line = line . lstrip ( ) if not line . startswith ( "#" ) : if line . split ( ) [ 0 ] in self . DEFAULT_REPOS_NAMES : default_dict_repo [ line . split ( ) [ 0 ] ] = line . split ( ) [ 1 ] else : print ( "\nslpkg: Error: Repository name '{0}' is not " "default.\n Please check file: " "/etc/slpkg/default-repositories\n" . format ( line . split ( ) [ 0 ] ) ) raise SystemExit ( ) return default_dict_repo | Return dictionary with default repo name and url |
60,344 | def slack ( self ) : default = "http://mirrors.slackware.com/slackware/" if self . meta . arch . startswith ( "arm" ) : default = "http://ftp.arm.slackware.com/slackwarearm/" if os . path . isfile ( "/etc/slpkg/slackware-mirrors" ) : mirrors = Utils ( ) . read_file ( self . meta . conf_path + "slackware-mirrors" ) for line in mirrors . splitlines ( ) : line = line . rstrip ( ) if not line . startswith ( "#" ) and line : default = line . split ( ) [ - 1 ] if not default . endswith ( "/" ) : default += "/" return default | Official slackware repository |
60,345 | def view ( self ) : if self . sbo_url and self . name not in self . blacklist : self . prgnam = ( "{0}-{1}" . format ( self . name , self . sbo_version ) ) self . view_sbo ( ) while True : self . read_choice ( ) choice = { "r" : self . choice_README , "R" : self . choice_README , "s" : self . choice_SlackBuild , "S" : self . choice_SlackBuild , "f" : self . choice_info , "F" : self . choice_info , "o" : self . choice_doinst , "O" : self . choice_doinst , "d" : self . choice_download , "D" : self . choice_download , "download" : self . choice_download , "b" : self . choice_build , "B" : self . choice_build , "build" : self . choice_build , "i" : self . choice_install , "I" : self . choice_install , "install" : self . choice_install , "c" : self . choice_clear_screen , "C" : self . choice_clear_screen , "clear" : self . choice_clear_screen , "q" : self . choice_quit , "quit" : self . choice_quit , "Q" : self . choice_quit } try : choice [ self . choice ] ( ) except KeyError : pass else : self . msg . pkg_not_found ( "\n" , self . name , "Can't view" , "\n" ) raise SystemExit ( 1 ) | View SlackBuild package read or install them from slackbuilds . org |
60,346 | def choice_README ( self ) : README = ReadSBo ( self . sbo_url ) . readme ( "README" ) fill = self . fill_pager ( README ) self . pager ( README + fill ) | View README file |
60,347 | def choice_SlackBuild ( self ) : SlackBuild = ReadSBo ( self . sbo_url ) . slackbuild ( self . name , ".SlackBuild" ) fill = self . fill_pager ( SlackBuild ) self . pager ( SlackBuild + fill ) | View . SlackBuild file |
60,348 | def choice_info ( self ) : info = ReadSBo ( self . sbo_url ) . info ( self . name , ".info" ) fill = self . fill_pager ( info ) self . pager ( info + fill ) | View . info file |
60,349 | def choice_doinst ( self ) : if "doinst.sh" in self . sbo_files . split ( ) : doinst_sh = ReadSBo ( self . sbo_url ) . doinst ( "doinst.sh" ) fill = self . fill_pager ( doinst_sh ) self . pager ( doinst_sh + fill ) | View doinst . sh file |
60,350 | def choice_download ( self ) : Download ( path = "" , url = self . dwn_srcs , repo = "sbo" ) . start ( ) raise SystemExit ( ) | Download script . tar . gz and sources |
60,351 | def choice_install ( self ) : pkg_security ( [ self . name ] ) if not find_package ( self . prgnam , self . meta . pkg_path ) : self . build ( ) self . install ( ) delete ( self . build_folder ) raise SystemExit ( ) else : self . msg . template ( 78 ) self . msg . pkg_found ( self . prgnam ) self . msg . template ( 78 ) raise SystemExit ( ) | Download build and install package |
60,352 | def with_checklist ( self ) : data = [ ] if self . name == "ALL" : data = self . data else : for name in self . data : if self . name in name : data . append ( name ) if data : text = "Press 'spacebar' to choose SlackBuild for view" title = " SlackBuilds.org " backtitle = "{0} {1}" . format ( _meta_ . __all__ , _meta_ . __version__ ) status = False pkg = DialogUtil ( data , text , title , backtitle , status ) . checklist ( ) if pkg and len ( pkg ) > 1 : print ( "\nslpkg: Error: Choose only one package" ) raise SystemExit ( ) if pkg is None : raise SystemExit ( ) self . name = "" . join ( pkg ) os . system ( "clear" ) | Using dialog and checklist option |
60,353 | def fill_pager ( self , page ) : tty_size = os . popen ( "stty size" , "r" ) . read ( ) . split ( ) rows = int ( tty_size [ 0 ] ) - 1 lines = sum ( 1 for line in page . splitlines ( ) ) diff = rows - lines fill = "\n" * diff if diff > 0 : return fill else : return "" | Fix pager spaces |
60,354 | def error_uns ( self ) : self . FAULT = "" UNST = [ "UNSUPPORTED" , "UNTESTED" ] if "" . join ( self . source_dwn ) in UNST : self . FAULT = "" . join ( self . source_dwn ) | Check if package supported by arch before proceed to install |
60,355 | def build ( self ) : pkg_security ( [ self . name ] ) self . error_uns ( ) if self . FAULT : print ( "" ) self . msg . template ( 78 ) print ( "| Package {0} {1} {2} {3}" . format ( self . prgnam , self . red , self . FAULT , self . endc ) ) self . msg . template ( 78 ) else : sources = [ ] if not os . path . exists ( self . meta . build_path ) : os . makedirs ( self . meta . build_path ) if not os . path . exists ( self . _SOURCES ) : os . makedirs ( self . _SOURCES ) os . chdir ( self . meta . build_path ) Download ( self . meta . build_path , self . sbo_dwn . split ( ) , repo = "sbo" ) . start ( ) Download ( self . _SOURCES , self . source_dwn , repo = "sbo" ) . start ( ) script = self . sbo_dwn . split ( "/" ) [ - 1 ] for src in self . source_dwn : sources . append ( src . split ( "/" ) [ - 1 ] ) BuildPackage ( script , sources , self . meta . build_path , auto = False ) . build ( ) slack_package ( self . prgnam ) | Only build and create Slackware package |
60,356 | def listed ( self ) : print ( "\nPackages in the queue:\n" ) for pkg in self . packages ( ) : if pkg : print ( "{0}{1}{2}" . format ( self . meta . color [ "GREEN" ] , pkg , self . meta . color [ "ENDC" ] ) ) self . quit = True if self . quit : print ( "" ) | Print packages from queue |
60,357 | def add ( self , pkgs ) : queue_list = self . packages ( ) pkgs = list ( OrderedDict . fromkeys ( pkgs ) ) print ( "\nAdd packages in the queue:\n" ) with open ( self . queue_list , "a" ) as queue : for pkg in pkgs : find = sbo_search_pkg ( pkg ) if pkg not in queue_list and find is not None : print ( "{0}{1}{2}" . format ( self . meta . color [ "GREEN" ] , pkg , self . meta . color [ "ENDC" ] ) ) queue . write ( pkg + "\n" ) self . quit = True else : print ( "{0}{1}{2}" . format ( self . meta . color [ "RED" ] , pkg , self . meta . color [ "ENDC" ] ) ) self . quit = True queue . close ( ) if self . quit : print ( "" ) | Add packages in queue if not exist |
60,358 | def remove ( self , pkgs ) : print ( "\nRemove packages from the queue:\n" ) with open ( self . queue_list , "w" ) as queue : for line in self . queued . splitlines ( ) : if line not in pkgs : queue . write ( line + "\n" ) else : print ( "{0}{1}{2}" . format ( self . meta . color [ "RED" ] , line , self . meta . color [ "ENDC" ] ) ) self . quit = True queue . close ( ) if self . quit : print ( "" ) | Remove packages from queue |
60,359 | def build ( self ) : packages = self . packages ( ) if packages : for pkg in packages : if not os . path . exists ( self . meta . build_path ) : os . mkdir ( self . meta . build_path ) if not os . path . exists ( self . _SOURCES ) : os . mkdir ( self . _SOURCES ) sbo_url = sbo_search_pkg ( pkg ) sbo_dwn = SBoLink ( sbo_url ) . tar_gz ( ) source_dwn = SBoGrep ( pkg ) . source ( ) . split ( ) sources = [ ] os . chdir ( self . meta . build_path ) script = sbo_dwn . split ( "/" ) [ - 1 ] Download ( self . meta . build_path , sbo_dwn . split ( ) , repo = "sbo" ) . start ( ) for src in source_dwn : Download ( self . _SOURCES , src . split ( ) , repo = "sbo" ) . start ( ) sources . append ( src . split ( "/" ) [ - 1 ] ) BuildPackage ( script , sources , self . meta . build_path , auto = False ) . build ( ) else : print ( "\nPackages not found in the queue for building\n" ) raise SystemExit ( 1 ) | Build packages from queue |
60,360 | def install ( self ) : packages = self . packages ( ) if packages : print ( "" ) for pkg in packages : ver = SBoGrep ( pkg ) . version ( ) prgnam = "{0}-{1}" . format ( pkg , ver ) if find_package ( prgnam , self . meta . output ) : binary = slack_package ( prgnam ) PackageManager ( binary ) . upgrade ( flag = "--install-new" ) else : print ( "\nPackage {0} not found in the {1} for " "installation\n" . format ( prgnam , self . meta . output ) ) else : print ( "\nPackages not found in the queue for installation\n" ) raise SystemExit ( 1 ) | Install packages from queue |
60,361 | def pkg_upgrade ( repo , skip , flag ) : Msg ( ) . checking ( ) PACKAGES_TXT = RepoInit ( repo ) . fetch ( ) [ 0 ] pkgs_for_upgrade = [ ] data = repo_data ( PACKAGES_TXT , repo , flag = "" ) for pkg in installed ( ) : status ( 0.0005 ) inst_pkg = split_package ( pkg ) for name in data [ 0 ] : if name : repo_pkg = split_package ( name [ : - 4 ] ) if ( repo_pkg [ 0 ] == inst_pkg [ 0 ] and LooseVersion ( repo_pkg [ 1 ] ) > LooseVersion ( inst_pkg [ 1 ] ) and repo_pkg [ 3 ] >= inst_pkg [ 3 ] and inst_pkg [ 0 ] not in skip and repo_pkg [ 1 ] != "blacklist" ) : pkgs_for_upgrade . append ( repo_pkg [ 0 ] ) Msg ( ) . done ( ) if "--checklist" in flag : pkgs_for_upgrade = choose_upg ( pkgs_for_upgrade ) return pkgs_for_upgrade | Checking packages for upgrade |
60,362 | def split_package ( package ) : name = ver = arch = build = [ ] split = package . split ( "-" ) if len ( split ) > 2 : build = split [ - 1 ] build_a , build_b = "" , "" build_a = build [ : 1 ] if build [ 1 : 2 ] . isdigit ( ) : build_b = build [ 1 : 2 ] build = build_a + build_b arch = split [ - 2 ] ver = split [ - 3 ] name = "-" . join ( split [ : - 3 ] ) return [ name , ver , arch , build ] | Split package in name version arch and build tag . |
60,363 | def remove_repositories ( repositories , default_repositories ) : repos = [ ] for repo in repositories : if repo in default_repositories : repos . append ( repo ) return repos | Remove no default repositories |
60,364 | def update_repositories ( repositories , conf_path ) : repo_file = "{0}custom-repositories" . format ( conf_path ) if os . path . isfile ( repo_file ) : f = open ( repo_file , "r" ) repositories_list = f . read ( ) f . close ( ) for line in repositories_list . splitlines ( ) : line = line . lstrip ( ) if line and not line . startswith ( "#" ) : repositories . append ( line . split ( ) [ 0 ] ) return repositories | Upadate with user custom repositories |
60,365 | def names ( self ) : pkg_names = [ ] for line in self . SLACKBUILDS_TXT . splitlines ( ) : if line . startswith ( self . line_name ) : pkg_names . append ( line [ 17 : ] . strip ( ) ) return pkg_names | Grab all packages name |
60,366 | def source ( self ) : source , source64 , = "" , "" for line in self . SLACKBUILDS_TXT . splitlines ( ) : if line . startswith ( self . line_name ) : sbo_name = line [ 17 : ] . strip ( ) if line . startswith ( self . line_down ) : if sbo_name == self . name and line [ 21 : ] . strip ( ) : source = line [ 21 : ] if line . startswith ( self . line_down_64 ) : if sbo_name == self . name and line [ 28 : ] . strip ( ) : source64 = line [ 28 : ] return self . _select_source_arch ( source , source64 ) | Grab sources downloads links |
60,367 | def _select_source_arch ( self , source , source64 ) : src = "" if self . meta . arch == "x86_64" : if source64 : src = source64 else : src = source if self . meta . skip_unst in self . answer and source64 in self . unst : src = source else : if source : src = source if self . meta . skip_unst in self . answer and source in self . unst : src = source64 return src | Return sources by arch |
60,368 | def requires ( self ) : for line in self . SLACKBUILDS_TXT . splitlines ( ) : if line . startswith ( self . line_name ) : sbo_name = line [ 17 : ] . strip ( ) if line . startswith ( self . line_req ) : if sbo_name == self . name : return line [ 21 : ] . strip ( ) . split ( ) | Grab package requirements |
60,369 | def version ( self ) : for line in self . SLACKBUILDS_TXT . splitlines ( ) : if line . startswith ( self . line_name ) : sbo_name = line [ 17 : ] . strip ( ) if line . startswith ( self . line_ver ) : if sbo_name == self . name : return line [ 20 : ] . strip ( ) | Grab package version |
60,370 | def checksum ( self ) : md5sum , md5sum64 , = [ ] , [ ] for line in self . SLACKBUILDS_TXT . splitlines ( ) : if line . startswith ( self . line_name ) : sbo_name = line [ 17 : ] . strip ( ) if line . startswith ( self . line_md5_64 ) : if sbo_name == self . name and line [ 26 : ] . strip ( ) : md5sum64 = line [ 26 : ] . strip ( ) . split ( ) if line . startswith ( self . line_md5 ) : if sbo_name == self . name and line [ 19 : ] . strip ( ) : md5sum = line [ 19 : ] . strip ( ) . split ( ) return self . _select_md5sum_arch ( md5sum , md5sum64 ) | Grab checksum string |
60,371 | def _select_md5sum_arch ( self , md5sum , md5sum64 ) : if md5sum and md5sum64 : if self . meta . arch == "x86_64" : return md5sum64 else : return md5sum if md5sum : return md5sum else : return md5sum64 | Return checksums by arch |
60,372 | def description ( self ) : for line in self . SLACKBUILDS_TXT . splitlines ( ) : if line . startswith ( self . line_name ) : sbo_name = line [ 17 : ] . strip ( ) if line . startswith ( self . line_des ) : if sbo_name == self . name : return line [ 31 : ] . strip ( ) | Grab package verion |
60,373 | def check_exists_repositories ( repo ) : pkg_list = "PACKAGES.TXT" if repo == "sbo" : pkg_list = "SLACKBUILDS.TXT" if check_for_local_repos ( repo ) is True : pkg_list = "PACKAGES.TXT" return "" if not os . path . isfile ( "{0}{1}{2}" . format ( _meta_ . lib_path , repo , "_repo/{0}" . format ( pkg_list ) ) ) : return repo return "" | Checking if repositories exists by PACKAGES . TXT file |
60,374 | def check_for_local_repos ( repo ) : repos_dict = Repo ( ) . default_repository ( ) if repo in repos_dict : repo_url = repos_dict [ repo ] if repo_url . startswith ( "file:///" ) : return True | Check if repository is local |
60,375 | def slack ( self ) : log = self . log_path + "slack/" lib = self . lib_path + "slack_repo/" repo_name = log [ : - 1 ] . split ( "/" ) [ - 1 ] lib_file = "PACKAGES.TXT" md5_file = "CHECKSUMS.md5" log_file = "ChangeLog.txt" if not os . path . exists ( log ) : os . mkdir ( log ) if not os . path . exists ( lib ) : os . mkdir ( lib ) dirs = [ "core/" , "extra/" , "pasture/" , "patches/" ] for d in dirs : if not os . path . exists ( lib + d ) : os . mkdir ( lib + d ) PACKAGES_TXT = mirrors ( lib_file , "" ) FILELIST_TXT = "" CHECKSUMS_MD5 = mirrors ( md5_file , "" ) self . EXTRA = mirrors ( lib_file , dirs [ 1 ] ) self . EXT_CHECKSUMS = mirrors ( md5_file , dirs [ 1 ] ) self . PASTURE = mirrors ( lib_file , dirs [ 2 ] ) self . PAS_CHECKSUMS = mirrors ( md5_file , dirs [ 2 ] ) self . PATCHES = mirrors ( lib_file , dirs [ 3 ] ) self . PAT_CHECKSUMS = mirrors ( md5_file , dirs [ 3 ] ) ChangeLog_txt = mirrors ( log_file , "" ) if self . check : return self . checks_logs ( log , ChangeLog_txt ) self . down ( lib + dirs [ 0 ] , PACKAGES_TXT , repo_name ) self . down ( lib + dirs [ 0 ] , CHECKSUMS_MD5 , repo_name ) self . down ( lib + dirs [ 1 ] , self . EXTRA , repo_name ) self . down ( lib + dirs [ 1 ] , self . EXT_CHECKSUMS , repo_name ) if slack_ver ( ) != "14.0" : self . down ( lib + dirs [ 2 ] , self . PASTURE , repo_name ) self . down ( lib + dirs [ 2 ] , self . PAS_CHECKSUMS , repo_name ) self . down ( lib + dirs [ 3 ] , self . PATCHES , repo_name ) self . down ( lib + dirs [ 3 ] , self . PAT_CHECKSUMS , repo_name ) self . down ( log , ChangeLog_txt , repo_name ) self . remote ( log , ChangeLog_txt , lib , PACKAGES_TXT , CHECKSUMS_MD5 , FILELIST_TXT , repo_name ) self . merge ( lib , "PACKAGES.TXT" , [ "core/PACKAGES.TXT" , "extra/PACKAGES.TXT" , "pasture/PACKAGES.TXT" , "patches/PACKAGES.TXT" ] ) self . merge ( lib , "CHECKSUMS.md5" , [ "core/CHECKSUMS.md5" , "extra/CHECKSUMS.md5" , "pasture/CHECKSUMS.md5" , "patches/CHECKSUMS_md5" ] ) | Creating slack local libraries |
60,376 | def conrad ( self ) : repo = self . def_repos_dict [ "conrad" ] log = self . log_path + "conrad/" lib = self . lib_path + "conrad_repo/" repo_name = log [ : - 1 ] . split ( "/" ) [ - 1 ] lib_file = "PACKAGES.TXT" md5_file = "CHECKSUMS.md5" log_file = "ChangeLog.txt" if not os . path . exists ( log ) : os . mkdir ( log ) if not os . path . exists ( lib ) : os . mkdir ( lib ) PACKAGES_TXT = "{0}{1}" . format ( repo , lib_file ) FILELIST_TXT = "" CHECKSUMS_MD5 = "{0}{1}" . format ( repo , md5_file ) ChangeLog_txt = "{0}{1}" . format ( repo , log_file ) if self . check : return self . checks_logs ( log , ChangeLog_txt ) self . down ( lib , PACKAGES_TXT , repo_name ) self . down ( lib , CHECKSUMS_MD5 , repo_name ) self . down ( log , ChangeLog_txt , repo_name ) self . remote ( log , ChangeLog_txt , lib , PACKAGES_TXT , CHECKSUMS_MD5 , FILELIST_TXT , repo_name ) | Creating slackers local library |
60,377 | def remote ( self , * args ) : log_path = args [ 0 ] ChangeLog_txt = args [ 1 ] lib_path = args [ 2 ] PACKAGES_TXT = args [ 3 ] CHECKSUMS_MD5 = args [ 4 ] FILELIST_TXT = args [ 5 ] repo = args [ 6 ] if self . checks_logs ( log_path , ChangeLog_txt ) : self . file_remove ( log_path , ChangeLog_txt . split ( "/" ) [ - 1 ] ) self . file_remove ( lib_path , PACKAGES_TXT . split ( "/" ) [ - 1 ] ) self . file_remove ( lib_path , CHECKSUMS_MD5 . split ( "/" ) [ - 1 ] ) self . file_remove ( lib_path , FILELIST_TXT . split ( "/" ) [ - 1 ] ) if repo == "slack" : dirs = [ "core/" , "extra/" , "pasture/" ] for d in dirs : self . file_remove ( lib_path + d , "PACKAGES.TXT" ) self . file_remove ( lib_path + d , "CHECKSUMS.md5" ) self . down ( lib_path + "core/" , PACKAGES_TXT , repo ) self . down ( lib_path + "core/" , CHECKSUMS_MD5 , repo ) self . down ( lib_path + "extra/" , self . EXTRA , repo ) self . down ( lib_path + "extra/" , self . EXT_CHECKSUMS , repo ) if slack_ver ( ) != "14.0" : self . down ( lib_path + "pasture/" , self . PASTURE , repo ) self . down ( lib_path + "pasture/" , self . PAS_CHECKSUMS , repo ) if repo != "slack" : self . down ( lib_path , PACKAGES_TXT , repo ) self . down ( lib_path , CHECKSUMS_MD5 , repo ) self . down ( lib_path , FILELIST_TXT , repo ) self . down ( log_path , ChangeLog_txt , repo ) | Remove and recreate files |
60,378 | def file_remove ( self , path , filename ) : if os . path . isfile ( path + filename ) : os . remove ( path + filename ) | Check if filename exists and remove |
60,379 | def checks_logs ( self , log_path , url ) : local = "" filename = url . split ( "/" ) [ - 1 ] server = FileSize ( url ) . server ( ) if os . path . isfile ( log_path + filename ) : local = FileSize ( log_path + filename ) . local ( ) if server != local : return True return False | Checks ChangeLog . txt for changes |
60,380 | def upgrade ( self , only ) : repositories = self . meta . repositories if only : repositories = only for repo in repositories : changelogs = "{0}{1}{2}" . format ( self . log_path , repo , "/ChangeLog.txt" ) if os . path . isfile ( changelogs ) : os . remove ( changelogs ) if os . path . isdir ( self . lib_path + "{0}_repo/" . format ( repo ) ) : for f in ( os . listdir ( self . lib_path + "{0}_repo/" . format ( repo ) ) ) : files = "{0}{1}_repo/{2}" . format ( self . lib_path , repo , f ) if os . path . isfile ( files ) : os . remove ( files ) elif os . path . isdir ( files ) : shutil . rmtree ( files ) Update ( ) . repository ( only ) | Remove all package lists with changelog and checksums files and create lists again |
60,381 | def repository ( self , only ) : print ( "\nCheck and update repositories:\n" ) default = self . meta . default_repositories enabled = self . meta . repositories if only : enabled = only for repo in enabled : if check_for_local_repos ( repo ) is True : continue sys . stdout . write ( "{0}Check repository [{1}{2}{3}] ... " "{4}" . format ( self . meta . color [ "GREY" ] , self . meta . color [ "CYAN" ] , repo , self . meta . color [ "GREY" ] , self . meta . color [ "ENDC" ] ) ) sys . stdout . flush ( ) if repo in default : exec ( "{0}.{1}()" . format ( self . _init , repo ) ) sys . stdout . write ( self . done ) elif repo in enabled : Initialization ( False ) . custom ( repo ) sys . stdout . write ( self . done ) else : sys . stdout . write ( self . error ) print ( "" ) raise SystemExit ( ) | Update repositories lists |
60,382 | def checklist ( self ) : choice = [ ] for item in self . data : choice . append ( ( item , "" , self . status ) ) code , self . tags = self . d . checklist ( text = self . text , height = 20 , width = 65 , list_height = 13 , choices = choice , title = self . title , backtitle = self . backtitle ) if code == "ok" : self . unicode_to_string ( ) return self . ununicode if code in [ "cancel" , "esc" ] : self . exit ( ) | Run dialog checklist |
60,383 | def buildlist ( self , enabled ) : choice = [ ] for item in self . data : choice . append ( ( item , False ) ) for item in enabled : choice . append ( ( item , True ) ) items = [ ( tag , tag , sta ) for ( tag , sta ) in choice ] code , self . tags = self . d . buildlist ( text = self . text , items = items , visit_items = True , item_help = False , title = self . title ) if code == "ok" : self . unicode_to_string ( ) return self . ununicode if code in [ "cancel" , "esc" ] : self . exit ( ) | Run dialog buildlist |
60,384 | def unicode_to_string ( self ) : for tag in self . tags : self . ununicode . append ( str ( tag ) ) | Convert unicode in string |
60,385 | def sbo_upgrade ( skip , flag ) : Msg ( ) . checking ( ) upgrade_names = [ ] data = SBoGrep ( name = "" ) . names ( ) blacklist = BlackList ( ) . packages ( pkgs = data , repo = "sbo" ) for pkg in sbo_list ( ) : status ( 0.02 ) name = split_package ( pkg ) [ 0 ] ver = split_package ( pkg ) [ 1 ] if ( name in data and name not in skip and name not in blacklist ) : sbo_package = ( "{0}-{1}" . format ( name , SBoGrep ( name ) . version ( ) ) ) package = ( "{0}-{1}" . format ( name , ver ) ) if LooseVersion ( sbo_package ) > LooseVersion ( package ) : upgrade_names . append ( name ) Msg ( ) . done ( ) if "--checklist" in flag : upgrade_names = choose_upg ( upgrade_names ) return upgrade_names | Return packages for upgrade |
60,386 | def sbo_list ( ) : sbo_packages = [ ] for pkg in os . listdir ( _meta_ . pkg_path ) : if pkg . endswith ( "_SBo" ) : sbo_packages . append ( pkg ) return sbo_packages | Return all SBo packages |
60,387 | def delete_package ( path , packages ) : if _meta_ . del_all in [ "on" , "ON" ] : for pkg in packages : os . remove ( path + pkg ) | Remove downloaded packages |
60,388 | def delete ( build_folder ) : if _meta_ . del_build in [ "on" , "ON" ] and os . path . exists ( build_folder ) : shutil . rmtree ( build_folder ) | Delete build directory and all its contents . |
60,389 | def start ( self ) : self . store ( ) self . msg . done ( ) if self . upgrade_all : if "--checklist" in self . flag : self . dialog_checklist ( ) print ( "\nThese packages need upgrading:\n" ) self . msg . template ( 78 ) print ( "{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}" . format ( "| Package" , " " * 17 , "New Version" , " " * 8 , "Arch" , " " * 4 , "Build" , " " * 2 , "Repos" , " " * 10 , "Size" ) ) self . msg . template ( 78 ) print ( "Upgrading:" ) self . views ( ) unit , size = units ( self . comp_sum , self . uncomp_sum ) print ( "\nInstalling summary" ) print ( "=" * 79 ) print ( "{0}Total {1} {2} will be upgraded and {3} will be " "installed." . format ( self . meta . color [ "GREY" ] , self . count_upg , self . msg . pkg ( self . upgrade_all ) , self . count_added ) ) print ( "Need to get {0} {1} of archives." . format ( size [ 0 ] , unit [ 0 ] ) ) print ( "After this process, {0} {1} of additional disk space " "will be used.{2}" . format ( size [ 1 ] , unit [ 1 ] , self . meta . color [ "ENDC" ] ) ) print ( "" ) if self . msg . answer ( ) in [ "y" , "Y" ] : Download ( self . patch_path , self . dwn_links , repo = "slack" ) . start ( ) self . upgrade_all = self . utils . check_downloaded ( self . patch_path , self . upgrade_all ) self . upgrade ( ) self . kernel ( ) if self . meta . slackpkg_log in [ "on" , "ON" ] : self . slackpkg_update ( ) self . msg . reference ( self . installed , self . upgraded ) delete_package ( self . patch_path , self . upgrade_all ) self . update_lists ( ) else : slack_arch = "" if self . meta . arch == "x86_64" : slack_arch = "64" print ( "\nSlackware{0} '{1}' v{2} distribution is up to " "date\n" . format ( slack_arch , self . version , slack_ver ( ) ) ) | Install new patches from official Slackware mirrors |
60,390 | def store ( self ) : data = repo_data ( self . PACKAGES_TXT , "slack" , self . flag ) black = BlackList ( ) . packages ( pkgs = data [ 0 ] , repo = "slack" ) for name , loc , comp , uncomp in zip ( data [ 0 ] , data [ 1 ] , data [ 2 ] , data [ 3 ] ) : status ( 0.0003 ) repo_pkg_name = split_package ( name ) [ 0 ] if ( not os . path . isfile ( self . meta . pkg_path + name [ : - 4 ] ) and repo_pkg_name not in black and repo_pkg_name not in self . skip ) : self . dwn_links . append ( "{0}{1}/{2}" . format ( mirrors ( "" , "" ) , loc , name ) ) self . comp_sum . append ( comp ) self . uncomp_sum . append ( uncomp ) self . upgrade_all . append ( name ) self . count_upg += 1 if not find_package ( repo_pkg_name + self . meta . sp , self . meta . pkg_path ) : self . count_added += 1 self . count_upg -= 1 return self . count_upg | Store and return packages for upgrading |
60,391 | def kernel ( self ) : for core in self . upgrade_all : if "kernel" in core : if self . meta . default_answer in [ "y" , "Y" ] : answer = self . meta . default_answer else : print ( "" ) self . msg . template ( 78 ) print ( "| {0}*** HIGHLY recommended reinstall 'LILO' " "***{1}" . format ( self . meta . color [ "RED" ] , self . meta . color [ "ENDC" ] ) ) self . msg . template ( 78 ) try : answer = raw_input ( "\nThe kernel has been upgraded, " "reinstall `LILO` [y/N]? " ) except EOFError : print ( "" ) raise SystemExit ( ) if answer in [ "y" , "Y" ] : subprocess . call ( "lilo" , shell = True ) break | Check if kernel upgraded if true then reinstall lilo |
60,392 | def slackpkg_update ( self ) : NEW_ChangeLog_txt = URL ( mirrors ( "ChangeLog.txt" , "" ) ) . reading ( ) if os . path . isfile ( self . meta . slackpkg_lib_path + "ChangeLog.txt.old" ) : os . remove ( self . meta . slackpkg_lib_path + "ChangeLog.txt.old" ) if os . path . isfile ( self . meta . slackpkg_lib_path + "ChangeLog.txt" ) : shutil . copy2 ( self . meta . slackpkg_lib_path + "ChangeLog.txt" , self . meta . slackpkg_lib_path + "ChangeLog.txt.old" ) os . remove ( self . meta . slackpkg_lib_path + "ChangeLog.txt" ) with open ( self . meta . slackpkg_lib_path + "ChangeLog.txt" , "w" ) as log : log . write ( NEW_ChangeLog_txt ) log . close ( ) | This replace slackpkg ChangeLog . txt file with new from Slackware official mirrors after update distribution . |
60,393 | def update_lists ( self ) : print ( "{0}Update the package lists ?{1}" . format ( self . meta . color [ "GREEN" ] , self . meta . color [ "ENDC" ] ) ) print ( "=" * 79 ) if self . msg . answer ( ) in [ "y" , "Y" ] : Update ( ) . repository ( [ "slack" ] ) | Update packages list and ChangeLog . txt file after upgrade distribution |
60,394 | def log_head ( path , log_file , log_time ) : with open ( path + log_file , "w" ) as log : log . write ( "#" * 79 + "\n\n" ) log . write ( "File : " + log_file + "\n" ) log . write ( "Path : " + path + "\n" ) log . write ( "Date : " + time . strftime ( "%d/%m/%Y" ) + "\n" ) log . write ( "Time : " + log_time + "\n\n" ) log . write ( "#" * 79 + "\n\n" ) log . close ( ) | write headers to log file |
60,395 | def log_end ( path , log_file , sum_time ) : with open ( path + log_file , "a" ) as log : log . seek ( 2 ) log . write ( "#" * 79 + "\n\n" ) log . write ( "Time : " + time . strftime ( "%H:%M:%S" ) + "\n" ) log . write ( "Total build time : {0}\n" . format ( sum_time ) ) log . write ( " " * 38 + "E N D\n\n" ) log . write ( "#" * 79 + "\n\n" ) log . close ( ) | append END tag to a log file |
60,396 | def build_time ( start_time ) : diff_time = round ( time . time ( ) - start_time , 2 ) if diff_time <= 59.99 : sum_time = str ( diff_time ) + " Sec" elif diff_time > 59.99 and diff_time <= 3599.99 : sum_time = round ( diff_time / 60 , 2 ) sum_time_list = re . findall ( r"\d+" , str ( sum_time ) ) sum_time = ( "{0} Min {1} Sec" . format ( sum_time_list [ 0 ] , sum_time_list [ 1 ] ) ) elif diff_time > 3599.99 : sum_time = round ( diff_time / 3600 , 2 ) sum_time_list = re . findall ( r"\d+" , str ( sum_time ) ) sum_time = ( "{0} Hours {1} Min" . format ( sum_time_list [ 0 ] , sum_time_list [ 1 ] ) ) return sum_time | Calculate build time per package |
60,397 | def _create_md5_dict ( self ) : self . sbo_md5 = { } md5_lists = SBoGrep ( self . prgnam ) . checksum ( ) for src , md5 in zip ( self . sources , md5_lists ) : self . sbo_md5 [ src ] = md5 | Create md5 dictionary per source |
60,398 | def _makeflags ( self ) : if self . meta . makeflags in [ "on" , "ON" ] : cpus = multiprocessing . cpu_count ( ) os . environ [ "MAKEFLAGS" ] = "-j{0}" . format ( cpus ) | Set variable MAKEFLAGS with the numbers of processors |
60,399 | def _pass_variable ( self ) : pass_var = [ ] for var in os . environ . keys ( ) : expVAR = var . split ( "_" ) if expVAR [ 0 ] == self . prgnam . upper ( ) and expVAR [ 1 ] != "PATH" : pass_var . append ( "{0}={1}" . format ( expVAR [ 1 ] , os . environ [ var ] ) ) return pass_var | Return enviroment variables |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.