KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcm.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2021 Andrew Lutsenko, anlutsenko at gmail dot com
5 * Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21// kicad_curl.h *must be* included before any wxWidgets header to avoid conflicts
22// at least on Windows/msys2
25
26#include "core/wx_stl_compat.h"
27#include <env_vars.h>
29#include "build_version.h"
30#include "paths.h"
31#include "pcm.h"
32#include "pgm_base.h"
33#include "picosha2.h"
35#include <wx_filename.h>
36
37#include <fstream>
38#include <iomanip>
39#include <memory>
40#include <wx/dir.h>
41#include <wx/filefn.h>
42#include <wx/image.h>
43#include <wx/mstream.h>
44#include <wx/tokenzr.h>
45#include <wx/wfstream.h>
46#include <wx/zipstrm.h>
47
48
49const std::tuple<int, int, int> PLUGIN_CONTENT_MANAGER::m_kicad_version =
51
52
53class THROWING_ERROR_HANDLER : public nlohmann::json_schema::error_handler
54{
55 void error( const json::json_pointer& ptr, const json& instance,
56 const std::string& message ) override
57 {
58 throw std::invalid_argument( std::string( "At " ) + ptr.to_string() + ", value:\n"
59 + instance.dump() + "\n" + message + "\n" );
60 }
61};
62
63
65 std::function<void( int )> aAvailableUpdateCallback ) :
66 m_dialog( nullptr ),
67 m_availableUpdateCallback( aAvailableUpdateCallback )
68{
69 ReadEnvVar();
70
71 // Read and store pcm schema
72 wxFileName schema_file( PATHS::GetStockDataPath( true ), wxS( "pcm.v1.schema.json" ) );
73 schema_file.Normalize( FN_NORMALIZE_FLAGS | wxPATH_NORM_ENV_VARS );
74 schema_file.AppendDir( wxS( "schemas" ) );
75
76 std::ifstream schema_stream( schema_file.GetFullPath().fn_str() );
77 nlohmann::json schema;
78
79 try
80 {
81 schema_stream >> schema;
82 m_schema_validator.set_root_schema( schema );
83 }
84 catch( std::exception& e )
85 {
86 if( !schema_file.FileExists() )
87 {
88 wxLogError( wxString::Format( _( "schema file '%s' not found" ),
89 schema_file.GetFullPath() ) );
90 }
91 else
92 {
93 wxLogError( wxString::Format( _( "Error loading schema: %s" ), e.what() ) );
94 }
95 }
96
97 // Load currently installed packages
98 wxFileName f( PATHS::GetUserSettingsPath(), wxT( "installed_packages.json" ) );
99
100 if( f.FileExists() )
101 {
102 std::ifstream installed_stream( f.GetFullPath().fn_str() );
103 nlohmann::json installed;
104
105 try
106 {
107 installed_stream >> installed;
108
109 if( installed.contains( "packages" ) && installed["packages"].is_array() )
110 {
111 for( const auto& js_entry : installed["packages"] )
112 {
113 PCM_INSTALLATION_ENTRY entry = js_entry.get<PCM_INSTALLATION_ENTRY>();
114 m_installed.emplace( entry.package.identifier, entry );
115 }
116 }
117 }
118 catch( std::exception& e )
119 {
120 wxLogError( wxString::Format( _( "Error loading installed packages list: %s" ),
121 e.what() ) );
122 }
123 }
124
125 // As a fall back populate installed from names of directories
126
127 for( const wxString& dir : PCM_PACKAGE_DIRECTORIES )
128 {
129 wxFileName d( m_3rdparty_path, wxEmptyString );
130 d.AppendDir( dir );
131
132 if( d.DirExists() )
133 {
134 wxDir package_dir( d.GetPath() );
135
136 if( !package_dir.IsOpened() )
137 continue;
138
139 wxString subdir;
140 bool more = package_dir.GetFirst( &subdir, "", wxDIR_DIRS | wxDIR_HIDDEN );
141
142 while( more )
143 {
144 wxString actual_package_id = subdir;
145 actual_package_id.Replace( '_', '.' );
146
147 if( m_installed.find( actual_package_id ) == m_installed.end() )
148 {
150 wxFileName subdir_file( d.GetPath(), subdir );
151
152 // wxFileModificationTime bugs out on windows for directories
153 wxStructStat stat;
154 int stat_code = wxStat( subdir_file.GetFullPath(), &stat );
155
156 entry.package.name = subdir;
157 entry.package.identifier = actual_package_id;
158 entry.current_version = "0.0";
159 entry.repository_name = wxT( "<unknown>" );
160
161 if( stat_code == 0 )
162 entry.install_timestamp = stat.st_mtime;
163
164 PACKAGE_VERSION version;
165 version.version = "0.0";
166 version.status = PVS_STABLE;
168
169 entry.package.versions.emplace_back( version );
170
171 m_installed.emplace( actual_package_id, entry );
172 }
173
174 more = package_dir.GetNext( &subdir );
175 }
176 }
177 }
178
179 // Calculate package compatibility
180 std::for_each( m_installed.begin(), m_installed.end(),
181 [&]( std::pair<const wxString, PCM_INSTALLATION_ENTRY>& entry )
182 {
183 PreparePackage( entry.second.package );
184 } );
185}
186
187
189{
190 // Get 3rd party path
191 const ENV_VAR_MAP& env = Pgm().GetLocalEnvVariables();
192
193 if( std::optional<wxString> v = ENV_VAR::GetVersionedEnvVarValue( env, wxT( "3RD_PARTY" ) ) )
194 m_3rdparty_path = *v;
195 else
197}
198
199
200bool PLUGIN_CONTENT_MANAGER::DownloadToStream( const wxString& aUrl, std::ostream* aOutput,
201 PROGRESS_REPORTER* aReporter,
202 const size_t aSizeLimit )
203{
204 bool size_exceeded = false;
205
206 TRANSFER_CALLBACK callback = [&]( size_t dltotal, size_t dlnow, size_t ultotal, size_t ulnow )
207 {
208 if( aSizeLimit > 0 && ( dltotal > aSizeLimit || dlnow > aSizeLimit ) )
209 {
210 size_exceeded = true;
211
212 // Non zero return means abort.
213 return true;
214 }
215
216 if( dltotal > 1000 )
217 {
218 aReporter->SetCurrentProgress( dlnow / (double) dltotal );
219 aReporter->Report( wxString::Format( _( "Downloading %lld/%lld kB" ), dlnow / 1000,
220 dltotal / 1000 ) );
221 }
222 else
223 {
224 aReporter->SetCurrentProgress( 0.0 );
225 }
226
227 return !aReporter->KeepRefreshing();
228 };
229
230 KICAD_CURL_EASY curl;
231 curl.SetOutputStream( aOutput );
232 curl.SetURL( aUrl.ToUTF8().data() );
233 curl.SetFollowRedirects( true );
234 curl.SetTransferCallback( callback, 250000L );
235
236 int code = curl.Perform();
237
238 if( !aReporter->IsCancelled() )
239 aReporter->SetCurrentProgress( 1.0 );
240
241 if( code != CURLE_OK )
242 {
243 if( m_dialog )
244 {
245 if( code == CURLE_ABORTED_BY_CALLBACK && size_exceeded )
246 wxMessageBox( _( "Download is too large." ) );
247 else if( code != CURLE_ABORTED_BY_CALLBACK )
248 wxLogError( wxString( curl.GetErrorText( code ) ) );
249 }
250
251 return false;
252 }
253
254 return true;
255}
256
257
258bool PLUGIN_CONTENT_MANAGER::FetchRepository( const wxString& aUrl, PCM_REPOSITORY& aRepository,
259 PROGRESS_REPORTER* aReporter )
260{
261 std::stringstream repository_stream;
262
263 aReporter->SetTitle( _( "Fetching repository" ) );
264
265 if( !DownloadToStream( aUrl, &repository_stream, aReporter, 20480 ) )
266 {
267 if( m_dialog )
268 wxLogError( _( "Unable to load repository url" ) );
269
270 return false;
271 }
272
273 nlohmann::json repository_json;
274
275 try
276 {
277 repository_stream >> repository_json;
278
279 ValidateJson( repository_json, nlohmann::json_uri( "#/definitions/Repository" ) );
280
281 aRepository = repository_json.get<PCM_REPOSITORY>();
282 }
283 catch( const std::exception& e )
284 {
285 if( m_dialog )
286 {
287 wxLogError( wxString::Format( _( "Unable to parse repository: %s" ), e.what() ) );
288 wxLogError( _( "The given repository URL does not look like a valid KiCad package "
289 "repository. Please double check the URL." ) );
290 }
291
292 return false;
293 }
294
295 return true;
296}
297
298
299void PLUGIN_CONTENT_MANAGER::ValidateJson( const nlohmann::json& aJson,
300 const nlohmann::json_uri& aUri ) const
301{
302 THROWING_ERROR_HANDLER error_handler;
303 m_schema_validator.validate( aJson, error_handler, aUri );
304}
305
306
307bool PLUGIN_CONTENT_MANAGER::fetchPackages( const wxString& aUrl,
308 const std::optional<wxString>& aHash,
309 std::vector<PCM_PACKAGE>& aPackages,
310 PROGRESS_REPORTER* aReporter )
311{
312 std::stringstream packages_stream;
313
314 aReporter->SetTitle( _( "Fetching repository packages" ) );
315
316 if( !DownloadToStream( aUrl, &packages_stream, aReporter ) )
317 {
318 if( m_dialog )
319 wxLogError( _( "Unable to load repository packages url." ) );
320
321 return false;
322 }
323
324 std::istringstream isstream( packages_stream.str() );
325
326 if( aHash && !VerifyHash( isstream, *aHash ) )
327 {
328 if( m_dialog )
329 wxLogError( _( "Packages hash doesn't match. Repository may be corrupted." ) );
330
331 return false;
332 }
333
334 try
335 {
336 nlohmann::json packages_json = nlohmann::json::parse( packages_stream.str() );
337 ValidateJson( packages_json, nlohmann::json_uri( "#/definitions/PackageArray" ) );
338
339 aPackages = packages_json["packages"].get<std::vector<PCM_PACKAGE>>();
340 }
341 catch( std::exception& e )
342 {
343 if( m_dialog )
344 {
345 wxLogError( wxString::Format( _( "Unable to parse packages metadata:\n\n%s" ),
346 e.what() ) );
347 }
348
349 return false;
350 }
351
352 return true;
353}
354
355
356bool PLUGIN_CONTENT_MANAGER::VerifyHash( std::istream& aStream, const wxString& aHash ) const
357{
358 std::vector<unsigned char> bytes( picosha2::k_digest_size );
359
360 picosha2::hash256( std::istreambuf_iterator<char>( aStream ), std::istreambuf_iterator<char>(),
361 bytes.begin(), bytes.end() );
362 std::string hex_str = picosha2::bytes_to_hex_string( bytes.begin(), bytes.end() );
363
364 return aHash.compare( hex_str ) == 0;
365}
366
367
368const PCM_REPOSITORY&
369PLUGIN_CONTENT_MANAGER::getCachedRepository( const wxString& aRepositoryId ) const
370{
371 wxASSERT_MSG( m_repository_cache.find( aRepositoryId ) != m_repository_cache.end(),
372 wxT( "Repository is not cached." ) );
373
374 return m_repository_cache.at( aRepositoryId );
375}
376
377
378bool PLUGIN_CONTENT_MANAGER::CacheRepository( const wxString& aRepositoryId )
379{
380 if( m_repository_cache.find( aRepositoryId ) != m_repository_cache.end() )
381 return true;
382
383 const auto repository_tuple =
384 std::find_if( m_repository_list.begin(), m_repository_list.end(),
385 [&aRepositoryId]( const std::tuple<wxString, wxString, wxString>& t )
386 {
387 return std::get<0>( t ) == aRepositoryId;
388 } );
389
390 if( repository_tuple == m_repository_list.end() )
391 return false;
392
393 wxString url = std::get<2>( *repository_tuple );
394
395 nlohmann::json js;
396 PCM_REPOSITORY current_repo;
397 PCM_REPOSITORY& current_repo_ref = current_repo;
398
399 std::shared_ptr<PROGRESS_REPORTER> reporter;
400
401 if( m_dialog )
402 reporter = std::make_shared<WX_PROGRESS_REPORTER>( m_dialog, wxEmptyString, 1 );
403 else
404 reporter = m_updateBackgroundJob->m_reporter;
405
406 if( !FetchRepository( url, current_repo, reporter.get() ) )
407 return false;
408
409 bool packages_cache_exists = false;
410
411 // First load repository data from local filesystem if available.
412 wxFileName repo_cache = wxFileName( PATHS::GetUserCachePath(), wxT( "repository.json" ) );
413 repo_cache.AppendDir( wxT( "pcm" ) );
414 repo_cache.AppendDir( aRepositoryId );
415 wxFileName packages_cache( repo_cache.GetPath(), wxT( "packages.json" ) );
416
417 if( repo_cache.FileExists() && packages_cache.FileExists() )
418 {
419 std::ifstream repo_stream( repo_cache.GetFullPath().fn_str() );
420 PCM_REPOSITORY saved_repo;
421 try
422 {
423 repo_stream >> js;
424 saved_repo = js.get<PCM_REPOSITORY>();
425 }
426 catch( ... )
427 {
428 if( m_dialog )
429 wxLogError( _( "Failed to parse locally stored repository.json." ) );
430 }
431
432 if( saved_repo.packages.update_timestamp == current_repo.packages.update_timestamp )
433 {
434 // Cached repo is up to date, use data on disk
435 js.clear();
436 std::ifstream packages_cache_stream( packages_cache.GetFullPath().fn_str() );
437
438 try
439 {
440 packages_cache_stream >> js;
441 saved_repo.package_list = js["packages"].get<std::vector<PCM_PACKAGE>>();
442
443 for( size_t i = 0; i < saved_repo.package_list.size(); i++ )
444 {
445 PreparePackage( saved_repo.package_list[i] );
446 saved_repo.package_map[saved_repo.package_list[i].identifier] = i;
447 }
448
449 m_repository_cache[aRepositoryId] = std::move( saved_repo );
450
451 packages_cache_exists = true;
452 }
453 catch( ... )
454 {
455 if( m_dialog )
456 {
457 wxLogError( _( "Packages cache for current repository is corrupted, it will "
458 "be redownloaded." ) );
459 }
460 }
461 }
462 }
463
464 if( !packages_cache_exists )
465 {
466 // Cache doesn't exist or is out of date
467 if( !fetchPackages( current_repo.packages.url, current_repo.packages.sha256,
468 current_repo.package_list, reporter.get() ) )
469 {
470 return false;
471 }
472
473 for( size_t i = 0; i < current_repo.package_list.size(); i++ )
474 {
475 PreparePackage( current_repo.package_list[i] );
476 current_repo.package_map[current_repo.package_list[i].identifier] = i;
477 }
478
479 repo_cache.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL );
480
481 std::ofstream repo_cache_stream( repo_cache.GetFullPath().fn_str() );
482 repo_cache_stream << std::setw( 4 ) << nlohmann::json( current_repo ) << std::endl;
483
484 std::ofstream packages_cache_stream( packages_cache.GetFullPath().fn_str() );
485 js.clear();
486 js["packages"] = nlohmann::json( current_repo.package_list );
487 packages_cache_stream << std::setw( 4 ) << js << std::endl;
488
489 m_repository_cache[aRepositoryId] = std::move( current_repo );
490 current_repo_ref = m_repository_cache[aRepositoryId];
491 }
492
493 if( current_repo_ref.resources )
494 {
495 // Check resources file date, redownload if needed
496 PCM_RESOURCE_REFERENCE& resources = *current_repo_ref.resources;
497
498 wxFileName resource_file( repo_cache.GetPath(), wxT( "resources.zip" ) );
499
500 time_t mtime = 0;
501
502 if( resource_file.FileExists() )
503 mtime = wxFileModificationTime( resource_file.GetFullPath() );
504
505 if( mtime + 600 < getCurrentTimestamp() && mtime < (time_t) resources.update_timestamp )
506 {
507 std::ofstream resources_stream( resource_file.GetFullPath().fn_str(),
508 std::ios_base::binary );
509
510 reporter->SetTitle( _( "Downloading resources" ) );
511
512 // 100 Mb resource file limit
513 bool success = DownloadToStream( resources.url, &resources_stream, reporter.get(),
514 100 * 1024 * 1024 );
515
516 resources_stream.close();
517
518 if( success )
519 {
520 std::ifstream read_stream( resource_file.GetFullPath().fn_str(),
521 std::ios_base::binary );
522
523
524 if( resources.sha256 && !VerifyHash( read_stream, *resources.sha256 ) )
525 {
526 read_stream.close();
527
528 if( m_dialog )
529 {
530 wxLogError( _( "Resources file hash doesn't match and will not be used. "
531 "Repository may be corrupted." ) );
532 }
533
534 wxRemoveFile( resource_file.GetFullPath() );
535 }
536 }
537 else
538 {
539 // Not critical, just clean up the file
540 wxRemoveFile( resource_file.GetFullPath() );
541 }
542 }
543 }
544
545 updateInstalledPackagesMetadata( aRepositoryId );
546
547 return true;
548}
549
550
552{
553 const PCM_REPOSITORY* repository;
554
555 try
556 {
557 repository = &getCachedRepository( aRepositoryId );
558 }
559 catch( ... )
560 {
561 wxLogDebug( "Invalid/Missing repository " + aRepositoryId );
562 return;
563 }
564
565 for( std::pair<const wxString, PCM_INSTALLATION_ENTRY>& pair : m_installed )
566 {
567 PCM_INSTALLATION_ENTRY& entry = pair.second;
568
569 // If current package is not from this repository, skip it
570 if( entry.repository_id != aRepositoryId )
571 continue;
572
573 // If current package is no longer in this repository, keep it as is
574 if( repository->package_map.count( entry.package.identifier ) == 0 )
575 continue;
576
577 std::optional<PACKAGE_VERSION> current_version;
578
579 auto current_version_it =
580 std::find_if( entry.package.versions.begin(), entry.package.versions.end(),
581 [&]( const PACKAGE_VERSION& version )
582 {
583 return version.version == entry.current_version;
584 } );
585
586 if( current_version_it != entry.package.versions.end() )
587 current_version = *current_version_it; // copy
588
589 // Copy repository metadata into installation entry
590 entry.package = repository->package_list[repository->package_map.at( entry.package.identifier )];
591
592 // Insert current version if it's missing from repository metadata
593 current_version_it =
594 std::find_if( entry.package.versions.begin(), entry.package.versions.end(),
595 [&]( const PACKAGE_VERSION& version )
596 {
597 return version.version == entry.current_version;
598 } );
599
600 if( current_version_it == entry.package.versions.end() )
601 {
602 entry.package.versions.emplace_back( *current_version );
603
604 // Re-sort the versions by descending version
605 std::sort( entry.package.versions.begin(), entry.package.versions.end(),
606 []( const PACKAGE_VERSION& a, const PACKAGE_VERSION& b )
607 {
608 return a.parsed_version > b.parsed_version;
609 } );
610 }
611 }
612}
613
614
616{
617 // Parse package version strings
618 for( PACKAGE_VERSION& ver : aPackage.versions )
619 {
620 int epoch = 0, major = 0, minor = 0, patch = 0;
621
622 if( ver.version_epoch )
623 epoch = *ver.version_epoch;
624
625 wxStringTokenizer version_tokenizer( ver.version, wxT( "." ) );
626
627 major = wxAtoi( version_tokenizer.GetNextToken() );
628
629 if( version_tokenizer.HasMoreTokens() )
630 minor = wxAtoi( version_tokenizer.GetNextToken() );
631
632 if( version_tokenizer.HasMoreTokens() )
633 patch = wxAtoi( version_tokenizer.GetNextToken() );
634
635 ver.parsed_version = std::make_tuple( epoch, major, minor, patch );
636
637 // Determine compatibility
638 ver.compatible = true;
639
640 auto parse_version_tuple =
641 []( const wxString& version, int deflt )
642 {
643 int ver_major = deflt;
644 int ver_minor = deflt;
645 int ver_patch = deflt;
646
647 wxStringTokenizer tokenizer( version, wxT( "." ) );
648
649 ver_major = wxAtoi( tokenizer.GetNextToken() );
650
651 if( tokenizer.HasMoreTokens() )
652 ver_minor = wxAtoi( tokenizer.GetNextToken() );
653
654 if( tokenizer.HasMoreTokens() )
655 ver_patch = wxAtoi( tokenizer.GetNextToken() );
656
657 return std::tuple<int, int, int>( ver_major, ver_minor, ver_patch );
658 };
659
660 if( parse_version_tuple( ver.kicad_version, 0 ) > m_kicad_version )
661 ver.compatible = false;
662
663 if( ver.kicad_version_max
664 && parse_version_tuple( *ver.kicad_version_max, 999 ) < m_kicad_version )
665 ver.compatible = false;
666
667#ifdef __WXMSW__
668 wxString platform = wxT( "windows" );
669#endif
670#ifdef __WXOSX__
671 wxString platform = wxT( "macos" );
672#endif
673#ifdef __WXGTK__
674 wxString platform = wxT( "linux" );
675#endif
676
677 if( ver.platforms.size() > 0
678 && std::find( ver.platforms.begin(), ver.platforms.end(), platform )
679 == ver.platforms.end() )
680 {
681 ver.compatible = false;
682 }
683 }
684
685 // Sort by descending version
686 std::sort( aPackage.versions.begin(), aPackage.versions.end(),
687 []( const PACKAGE_VERSION& a, const PACKAGE_VERSION& b )
688 {
689 return a.parsed_version > b.parsed_version;
690 } );
691}
692
693
694const std::vector<PCM_PACKAGE>&
695PLUGIN_CONTENT_MANAGER::GetRepositoryPackages( const wxString& aRepositoryId ) const
696{
697 static std::vector<PCM_PACKAGE> empty{};
698
699 try
700 {
701 return getCachedRepository( aRepositoryId ).package_list;
702 }
703 catch( ... )
704 {
705 return empty;
706 }
707}
708
709
711{
712 // Clean up cache folder if repository is not in new list
713 for( const std::tuple<wxString, wxString, wxString>& entry : m_repository_list )
714 {
715 auto it = std::find_if( aRepositories.begin(), aRepositories.end(),
716 [&]( const auto& new_entry )
717 {
718 return new_entry.first == std::get<1>( entry );
719 } );
720
721 if( it == aRepositories.end() )
722 {
723 DiscardRepositoryCache( std::get<0>( entry ) );
724 }
725 }
726
727 m_repository_list.clear();
728 m_repository_cache.clear();
729
730 for( const std::pair<wxString, wxString>& repo : aRepositories )
731 {
732 std::string url_sha = picosha2::hash256_hex_string( repo.second );
733 m_repository_list.push_back( std::make_tuple( url_sha.substr( 0, 16 ), repo.first,
734 repo.second ) );
735 }
736}
737
738
739void PLUGIN_CONTENT_MANAGER::DiscardRepositoryCache( const wxString& aRepositoryId )
740{
741 if( m_repository_cache.count( aRepositoryId ) > 0 )
742 m_repository_cache.erase( aRepositoryId );
743
744 wxFileName repo_cache = wxFileName( PATHS::GetUserCachePath(), "" );
745 repo_cache.AppendDir( wxT( "pcm" ) );
746 repo_cache.AppendDir( aRepositoryId );
747
748 if( repo_cache.DirExists() )
749 repo_cache.Rmdir( wxPATH_RMDIR_RECURSIVE );
750}
751
752
753void PLUGIN_CONTENT_MANAGER::MarkInstalled( const PCM_PACKAGE& aPackage, const wxString& aVersion,
754 const wxString& aRepositoryId )
755{
756 // In case of package update remove old data but keep pinned state
757 bool pinned = false;
758
759 if( m_installed.count( aPackage.identifier ) )
760 {
761 pinned = m_installed.at( aPackage.identifier ).pinned;
762 MarkUninstalled( aPackage );
763 }
764
766 entry.package = aPackage;
767 entry.current_version = aVersion;
768 entry.repository_id = aRepositoryId;
769
770 try
771 {
772 if( !aRepositoryId.IsEmpty() )
773 entry.repository_name = getCachedRepository( aRepositoryId ).name;
774 else
775 entry.repository_name = _( "Local file" );
776 }
777 catch( ... )
778 {
779 entry.repository_name = _( "Unknown" );
780 }
781
783 entry.pinned = pinned;
784
785 m_installed.emplace( aPackage.identifier, entry );
786}
787
788
790{
791 m_installed.erase( aPackage.identifier );
792}
793
794
796 const wxString& aPackageId )
797{
798 bool installed = m_installed.find( aPackageId ) != m_installed.end();
799
800 if( aRepositoryId.IsEmpty() || !CacheRepository( aRepositoryId ) )
801 return installed ? PPS_INSTALLED : PPS_UNAVAILABLE;
802
803 const PCM_REPOSITORY* repo;
804
805 try
806 {
807 repo = &getCachedRepository( aRepositoryId );
808 }
809 catch( ... )
810 {
811 return installed ? PPS_INSTALLED : PPS_UNAVAILABLE;
812 }
813
814 if( repo->package_map.count( aPackageId ) == 0 )
815 return installed ? PPS_INSTALLED : PPS_UNAVAILABLE;
816
817 const PCM_PACKAGE& pkg = repo->package_list[repo->package_map.at( aPackageId )];
818
819 if( installed )
820 {
821 // Package is installed, check for available updates at the same or
822 // higher (numerically lower) version stability level
823 wxString update_version = GetPackageUpdateVersion( pkg );
824
825 return update_version.IsEmpty() ? PPS_INSTALLED : PPS_UPDATE_AVAILABLE;
826 }
827 else
828 {
829 // Find any compatible version
830 auto ver_it = std::find_if( pkg.versions.begin(), pkg.versions.end(),
831 []( const PACKAGE_VERSION& ver )
832 {
833 return ver.compatible;
834 } );
835
836 return ver_it == pkg.versions.end() ? PPS_UNAVAILABLE : PPS_AVAILABLE;
837 }
838}
839
840
842{
843 wxASSERT_MSG( m_installed.find( aPackage.identifier ) != m_installed.end(),
844 wxT( "GetPackageUpdateVersion called on a not installed package" ) );
845
846 const PCM_INSTALLATION_ENTRY& entry = m_installed.at( aPackage.identifier );
847
848 auto installed_ver_it = std::find_if(
849 entry.package.versions.begin(), entry.package.versions.end(),
850 [&]( const PACKAGE_VERSION& ver )
851 {
852 return ver.version == entry.current_version;
853 } );
854
855 wxASSERT_MSG( installed_ver_it != entry.package.versions.end(),
856 wxT( "Installed package version not found" ) );
857
858 auto ver_it = std::find_if( aPackage.versions.begin(), aPackage.versions.end(),
859 [&]( const PACKAGE_VERSION& ver )
860 {
861 return ver.compatible
862 && installed_ver_it->status >= ver.status
863 && installed_ver_it->parsed_version < ver.parsed_version;
864 } );
865
866 return ver_it == aPackage.versions.end() ? wxString( wxT( "" ) ) : ver_it->version;
867}
868
870{
871 return std::chrono::duration_cast<std::chrono::seconds>(
872 std::chrono::system_clock::now().time_since_epoch() ).count();
873}
874
875
877{
878 try
879 {
880 nlohmann::json js;
881 js["packages"] = nlohmann::json::array();
882
883 for( std::pair<const wxString, PCM_INSTALLATION_ENTRY>& pair : m_installed )
884 {
885 js["packages"].emplace_back( pair.second );
886 }
887
888 wxFileName f( PATHS::GetUserSettingsPath(), wxT( "installed_packages.json" ) );
889 std::ofstream stream( f.GetFullPath().fn_str() );
890
891 stream << std::setw( 4 ) << js << std::endl;
892 }
893 catch( nlohmann::detail::exception& )
894 {
895 // Ignore
896 }
897}
898
899
900const std::vector<PCM_INSTALLATION_ENTRY> PLUGIN_CONTENT_MANAGER::GetInstalledPackages() const
901{
902 std::vector<PCM_INSTALLATION_ENTRY> v;
903
904 std::for_each( m_installed.begin(), m_installed.end(),
905 [&v]( const std::pair<const wxString, PCM_INSTALLATION_ENTRY>& entry )
906 {
907 v.push_back( entry.second );
908 } );
909
910 std::sort( v.begin(), v.end(),
911 []( const PCM_INSTALLATION_ENTRY& a, const PCM_INSTALLATION_ENTRY& b )
912 {
913 return ( a.install_timestamp < b.install_timestamp )
914 || ( a.install_timestamp == b.install_timestamp
915 && a.package.identifier < b.package.identifier );
916 } );
917
918 return v;
919}
920
921
922const wxString&
923PLUGIN_CONTENT_MANAGER::GetInstalledPackageVersion( const wxString& aPackageId ) const
924{
925 wxASSERT_MSG( m_installed.find( aPackageId ) != m_installed.end(),
926 wxT( "Installed package not found." ) );
927
928 return m_installed.at( aPackageId ).current_version;
929}
930
931
932bool PLUGIN_CONTENT_MANAGER::IsPackagePinned( const wxString& aPackageId ) const
933{
934 if( m_installed.find( aPackageId ) == m_installed.end() )
935 return false;
936
937 return m_installed.at( aPackageId ).pinned;
938}
939
940
941void PLUGIN_CONTENT_MANAGER::SetPinned( const wxString& aPackageId, const bool aPinned )
942{
943 if( m_installed.find( aPackageId ) == m_installed.end() )
944 return;
945
946 m_installed.at( aPackageId ).pinned = aPinned;
947}
948
949
951 const wxString& aSearchTerm )
952{
953 wxArrayString terms = wxStringTokenize( aSearchTerm.Lower(), wxS( " " ), wxTOKEN_STRTOK );
954 int rank = 0;
955
956 const auto find_term_matches =
957 [&]( const wxString& str )
958 {
959 int result = 0;
960 wxString lower = str.Lower();
961
962 for( const wxString& term : terms )
963 {
964 if( lower.Find( term ) != wxNOT_FOUND )
965 result += 1;
966 }
967
968 return result;
969 };
970
971 // Match on package id
972 if( terms.size() == 1 && terms[0] == aPackage.identifier )
973 rank += 10000;
974
975 if( terms.size() == 1 && find_term_matches( aPackage.identifier ) )
976 rank += 1000;
977
978 // Match on package name
979 rank += 500 * find_term_matches( aPackage.name );
980
981 // Match on tags
982 for( const std::string& tag : aPackage.tags )
983 rank += 100 * find_term_matches( wxString( tag ) );
984
985 // Match on package description
986 rank += 10 * find_term_matches( aPackage.description );
987 rank += 10 * find_term_matches( aPackage.description_full );
988
989 // Match on author/maintainer
990 rank += find_term_matches( aPackage.author.name );
991
992 if( aPackage.maintainer )
993 rank += 3 * find_term_matches( aPackage.maintainer->name );
994
995 // Match on resources
996 for( const std::pair<const std::string, wxString>& entry : aPackage.resources )
997 {
998 rank += find_term_matches( entry.first );
999 rank += find_term_matches( entry.second );
1000 }
1001
1002 // Match on license
1003 if( terms.size() == 1 && terms[0] == aPackage.license )
1004 rank += 1;
1005
1006 return rank;
1007}
1008
1009
1010std::unordered_map<wxString, wxBitmap>
1012{
1013 std::unordered_map<wxString, wxBitmap> bitmaps;
1014
1015 wxFileName resources_file = wxFileName( PATHS::GetUserCachePath(), wxT( "resources.zip" ) );
1016 resources_file.AppendDir( wxT( "pcm" ) );
1017 resources_file.AppendDir( aRepositoryId );
1018
1019 if( !resources_file.FileExists() )
1020 return bitmaps;
1021
1022 wxFFileInputStream stream( resources_file.GetFullPath() );
1023 wxZipInputStream zip( stream );
1024
1025 if( !zip.IsOk() || zip.GetTotalEntries() == 0 )
1026 return bitmaps;
1027
1028 for( wxArchiveEntry* entry = zip.GetNextEntry(); entry; entry = zip.GetNextEntry() )
1029 {
1030 wxArrayString path_parts = wxSplit( entry->GetName(), wxFileName::GetPathSeparator(),
1031 (wxChar) 0 );
1032
1033 if( path_parts.size() != 2 || path_parts[1] != wxT( "icon.png" ) )
1034 continue;
1035
1036 try
1037 {
1038 wxMemoryInputStream image_stream( zip, entry->GetSize() );
1039 wxImage image( image_stream, wxBITMAP_TYPE_PNG );
1040 bitmaps.emplace( path_parts[0], wxBitmap( image ) );
1041 }
1042 catch( ... )
1043 {
1044 // Log and ignore
1045 wxLogTrace( wxT( "Error loading png bitmap for entry %s from %s" ), entry->GetName(),
1046 resources_file.GetFullPath() );
1047 }
1048 }
1049
1050 return bitmaps;
1051}
1052
1053
1054std::unordered_map<wxString, wxBitmap> PLUGIN_CONTENT_MANAGER::GetInstalledPackageBitmaps()
1055{
1056 std::unordered_map<wxString, wxBitmap> bitmaps;
1057
1058 wxFileName resources_dir_fn( m_3rdparty_path, wxEmptyString );
1059 resources_dir_fn.AppendDir( wxT( "resources" ) );
1060 wxDir resources_dir( resources_dir_fn.GetPath() );
1061
1062 if( !resources_dir.IsOpened() )
1063 return bitmaps;
1064
1065 wxString subdir;
1066 bool more = resources_dir.GetFirst( &subdir, wxEmptyString, wxDIR_DIRS | wxDIR_HIDDEN );
1067
1068 while( more )
1069 {
1070 wxFileName icon( resources_dir_fn.GetPath(), wxT( "icon.png" ) );
1071 icon.AppendDir( subdir );
1072
1073 if( icon.FileExists() )
1074 {
1075 wxString actual_package_id = subdir;
1076 actual_package_id.Replace( '_', '.' );
1077
1078 try
1079 {
1080 wxBitmap bitmap( icon.GetFullPath(), wxBITMAP_TYPE_PNG );
1081 bitmaps.emplace( actual_package_id, bitmap );
1082 }
1083 catch( ... )
1084 {
1085 // Log and ignore
1086 wxLogTrace( wxT( "Error loading png bitmap from %s" ), icon.GetFullPath() );
1087 }
1088 }
1089
1090 more = resources_dir.GetNext( &subdir );
1091 }
1092
1093 return bitmaps;
1094}
1095
1096
1098{
1099 // If the thread is already running don't create it again
1100 if( m_updateThread.joinable() )
1101 return;
1102
1103
1104 m_updateBackgroundJob = Pgm().GetBackgroundJobMonitor().Create( _( "PCM Update" ) );
1105
1106 m_updateThread = std::thread(
1107 [this]()
1108 {
1109 if( m_installed.size() == 0 )
1110 return;
1111
1112 int maxProgress = m_repository_list.size() + m_installed.size();
1113 m_updateBackgroundJob->m_reporter->SetNumPhases( maxProgress );
1114 m_updateBackgroundJob->m_reporter->Report( _( "Preparing to fetch repositories" ) );
1115
1116 // Only fetch repositories that have installed not pinned packages
1117 std::unordered_set<wxString> repo_ids;
1118
1119 for( std::pair<const wxString, PCM_INSTALLATION_ENTRY>& pair : m_installed )
1120 {
1121 if( !pair.second.pinned )
1122 repo_ids.insert( pair.second.repository_id );
1123 }
1124
1125 for( const auto& [ repository_id, name, url ] : m_repository_list )
1126 {
1127 m_updateBackgroundJob->m_reporter->AdvancePhase();
1128 if( repo_ids.count( repository_id ) == 0 )
1129 continue;
1130
1131 m_updateBackgroundJob->m_reporter->Report(
1132 _( "Fetching repository..." ) );
1133 CacheRepository( repository_id );
1134
1135 if( m_updateBackgroundJob->m_reporter->IsCancelled() )
1136 break;
1137 }
1138
1139 if( m_updateBackgroundJob->m_reporter->IsCancelled() )
1140 return;
1141
1142 // Count packages with updates
1143 int availableUpdateCount = 0;
1144
1145 m_updateBackgroundJob->m_reporter->Report( _( "Reviewing packages..." ) );
1146 for( std::pair<const wxString, PCM_INSTALLATION_ENTRY>& pair : m_installed )
1147 {
1148 PCM_INSTALLATION_ENTRY& entry = pair.second;
1149
1150 m_updateBackgroundJob->m_reporter->AdvancePhase();
1151
1152 if( m_repository_cache.find( entry.repository_id ) != m_repository_cache.end() )
1153 {
1155 entry.package.identifier );
1156
1157 if( state == PPS_UPDATE_AVAILABLE && !entry.pinned )
1158 availableUpdateCount++;
1159 }
1160
1161 if( m_updateBackgroundJob->m_reporter->IsCancelled() )
1162 return;
1163 }
1164
1166 m_updateBackgroundJob = nullptr;
1167
1168 // Update the badge on PCM button
1169 m_availableUpdateCallback( availableUpdateCount );
1170 } );
1171}
1172
1173
1175{
1176 if( m_updateThread.joinable() )
1177 {
1179 m_updateBackgroundJob->m_reporter->Cancel();
1180 m_updateThread.join();
1181 }
1182}
1183
1184
1186{
1187 // By the time object is being destroyed the thread should be
1188 // stopped already but just in case do it here too.
1190}
const char * name
Definition: DXF_plotter.cpp:57
wxString GetMajorMinorVersion()
Get only the major and minor version in a string major.minor.
const std::tuple< int, int, int > & GetMajorMinorPatchTuple()
Get the build version numbers as a tuple.
std::shared_ptr< BACKGROUND_JOB > Create(const wxString &aName)
Creates a background job with the given name.
void Remove(std::shared_ptr< BACKGROUND_JOB > job)
Removes the given background job from any lists and frees it.
int Perform()
Equivalent to curl_easy_perform.
bool SetTransferCallback(const TRANSFER_CALLBACK &aCallback, size_t aInterval)
bool SetURL(const std::string &aURL)
Set the request URL.
bool SetFollowRedirects(bool aFollow)
Enable the following of HTTP(s) and other redirects, by default curl does not follow redirects.
bool SetOutputStream(const std::ostream *aOutput)
const std::string GetErrorText(int aCode)
Fetch CURL's "friendly" error string for a given error code.
static wxString GetDefault3rdPartyPath()
Gets the default path for PCM packages.
Definition: paths.cpp:119
static wxString GetStockDataPath(bool aRespectRunFromBuildDir=true)
Gets the stock (install) data path, which is the base path for things like scripting,...
Definition: paths.cpp:140
static wxString GetUserCachePath()
Gets the stock (install) 3d viewer plugins path.
Definition: paths.cpp:344
static wxString GetUserSettingsPath()
Return the user configuration path used to store KiCad's configuration files.
Definition: paths.cpp:510
virtual ENV_VAR_MAP & GetLocalEnvVariables() const
Definition: pgm_base.cpp:923
virtual BACKGROUND_JOBS_MONITOR & GetBackgroundJobMonitor() const
Definition: pgm_base.h:146
time_t getCurrentTimestamp() const
Definition: pcm.cpp:869
const std::vector< PCM_PACKAGE > & GetRepositoryPackages(const wxString &aRepositoryId) const
Get the packages metadata from a previously cached repository.
Definition: pcm.cpp:695
void SetRepositoryList(const STRING_PAIR_LIST &aRepositories)
Set list of repositories.
Definition: pcm.cpp:710
void ValidateJson(const nlohmann::json &aJson, const nlohmann::json_uri &aUri=nlohmann::json_uri("#")) const
Validates json against a specific definition in the PCM schema.
Definition: pcm.cpp:299
wxWindow * m_dialog
Definition: pcm.h:395
std::unordered_map< wxString, PCM_REPOSITORY > m_repository_cache
Definition: pcm.h:399
const PCM_REPOSITORY & getCachedRepository(const wxString &aRepositoryId) const
Get the cached repository metadata.
Definition: pcm.cpp:369
int GetPackageSearchRank(const PCM_PACKAGE &aPackage, const wxString &aSearchTerm)
Get the approximate measure of how much given package matches the search term.
Definition: pcm.cpp:950
void MarkUninstalled(const PCM_PACKAGE &aPackage)
Mark package as uninstalled.
Definition: pcm.cpp:789
bool CacheRepository(const wxString &aRepositoryId)
Cache specified repository packages and other metadata.
Definition: pcm.cpp:378
void SaveInstalledPackages()
Saves metadata of installed packages to disk.
Definition: pcm.cpp:876
const std::vector< PCM_INSTALLATION_ENTRY > GetInstalledPackages() const
Get list of installed packages.
Definition: pcm.cpp:900
wxString m_3rdparty_path
Definition: pcm.h:397
void SetPinned(const wxString &aPackageId, const bool aPinned)
Set the pinned status of a package.
Definition: pcm.cpp:941
static void PreparePackage(PCM_PACKAGE &aPackage)
Parses version strings and calculates compatibility.
Definition: pcm.cpp:615
PLUGIN_CONTENT_MANAGER(std::function< void(int)> aAvailableUpdateCallbac)
Definition: pcm.cpp:64
bool DownloadToStream(const wxString &aUrl, std::ostream *aOutput, PROGRESS_REPORTER *aReporter, const size_t aSizeLimit=DEFAULT_DOWNLOAD_MEM_LIMIT)
Downloads url to an output stream.
Definition: pcm.cpp:200
std::thread m_updateThread
Definition: pcm.h:405
PCM_PACKAGE_STATE GetPackageState(const wxString &aRepositoryId, const wxString &aPackageId)
Get current state of the package.
Definition: pcm.cpp:795
std::map< wxString, PCM_INSTALLATION_ENTRY > m_installed
Definition: pcm.h:402
void RunBackgroundUpdate()
Runs a background update thread that checks for new package versions.
Definition: pcm.cpp:1097
std::unordered_map< wxString, wxBitmap > GetRepositoryPackageBitmaps(const wxString &aRepositoryId)
Get the icon bitmaps for repository packages.
Definition: pcm.cpp:1011
const wxString GetPackageUpdateVersion(const PCM_PACKAGE &aPackage)
Get the preferred package update version or empty string if there is none.
Definition: pcm.cpp:841
void MarkInstalled(const PCM_PACKAGE &aPackage, const wxString &aVersion, const wxString &aRepositoryId)
Mark package as installed.
Definition: pcm.cpp:753
nlohmann::json_schema::json_validator m_schema_validator
Definition: pcm.h:396
std::unordered_map< wxString, wxBitmap > GetInstalledPackageBitmaps()
Get the icon bitmaps for installed packages.
Definition: pcm.cpp:1054
const wxString & GetInstalledPackageVersion(const wxString &aPackageId) const
Get the current version of an installed package.
Definition: pcm.cpp:923
void updateInstalledPackagesMetadata(const wxString &aRepositoryId)
Updates metadata of installed packages from freshly fetched repo.
Definition: pcm.cpp:551
bool IsPackagePinned(const wxString &aPackageId) const
Returns pinned status of a package.
Definition: pcm.cpp:932
static const std::tuple< int, int, int > m_kicad_version
Definition: pcm.h:403
std::shared_ptr< BACKGROUND_JOB > m_updateBackgroundJob
Definition: pcm.h:407
void StopBackgroundUpdate()
Interrupts and joins() the update thread.
Definition: pcm.cpp:1174
STRING_TUPLE_LIST m_repository_list
Definition: pcm.h:400
bool fetchPackages(const wxString &aUrl, const std::optional< wxString > &aHash, std::vector< PCM_PACKAGE > &aPackages, PROGRESS_REPORTER *aReporter)
Downloads packages metadata to in memory stream, verifies hash and attempts to parse it.
Definition: pcm.cpp:307
std::function< void(int)> m_availableUpdateCallback
Definition: pcm.h:404
bool FetchRepository(const wxString &aUrl, PCM_REPOSITORY &aRepository, PROGRESS_REPORTER *aReporter)
Fetches repository metadata from given url.
Definition: pcm.cpp:258
void DiscardRepositoryCache(const wxString &aRepositoryId)
Discard in-memory and on-disk cache of a repository.
Definition: pcm.cpp:739
bool VerifyHash(std::istream &aStream, const wxString &aHash) const
Verifies SHA256 hash of a binary stream.
Definition: pcm.cpp:356
void ReadEnvVar()
Stores 3rdparty path from environment variables.
Definition: pcm.cpp:188
A progress reporter interface for use in multi-threaded environments.
virtual bool IsCancelled() const =0
virtual bool KeepRefreshing(bool aWait=false)=0
Update the UI (if any).
virtual void Report(const wxString &aMessage)=0
Display aMessage in the progress bar dialog.
virtual void SetTitle(const wxString &aTitle)=0
Change the title displayed on the window caption.
virtual void SetCurrentProgress(double aProgress)=0
Set the progress value to aProgress (0..1).
void error(const json::json_pointer &ptr, const json &instance, const std::string &message) override
Definition: pcm.cpp:55
static bool empty(const wxTextEntryBase *aCtrl)
#define _(s)
Functions related to environment variables, including help functions.
nlohmann::json json
Definition: gerbview.cpp:47
std::map< wxString, ENV_VAR_ITEM > ENV_VAR_MAP
std::function< int(size_t, size_t, size_t, size_t)> TRANSFER_CALLBACK
Wrapper interface around the curl_easy API/.
KICOMMON_API std::optional< wxString > GetVersionedEnvVarValue(const std::map< wxString, ENV_VAR_ITEM > &aMap, const wxString &aBaseName)
Attempts to retrieve the value of a versioned environment variable, such as KICAD8_TEMPLATE_DIR.
Definition: env_vars.cpp:83
std::vector< std::pair< wxString, wxString > > STRING_PAIR_LIST
Definition: pcm.h:78
PCM_PACKAGE_STATE
Definition: pcm.h:58
@ PPS_INSTALLED
Definition: pcm.h:61
@ PPS_UNAVAILABLE
Definition: pcm.h:60
@ PPS_UPDATE_AVAILABLE
Definition: pcm.h:64
@ PPS_AVAILABLE
Definition: pcm.h:59
const std::unordered_set< wxString > PCM_PACKAGE_DIRECTORIES({ "plugins", "footprints", "3dmodels", "symbols", "resources", "colors", "templates", "scripts" })
< Contains list of all valid directories that get extracted from a package archive
@ PVS_STABLE
Definition: pcm_data.h:54
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: pgm_base.cpp:1059
see class PGM_BASE
< Package version metadata Package metadata
Definition: pcm_data.h:75
bool compatible
Definition: pcm_data.h:90
wxString version
Definition: pcm_data.h:76
PCM_PACKAGE_VERSION_STATUS status
Definition: pcm_data.h:82
std::optional< wxString > kicad_version_max
Definition: pcm_data.h:85
std::optional< int > version_epoch
Definition: pcm_data.h:77
std::vector< std::string > platforms
Definition: pcm_data.h:83
wxString kicad_version
Definition: pcm_data.h:84
std::tuple< int, int, int, int > parsed_version
Definition: pcm_data.h:89
wxString name
Definition: pcm_data.h:64
Definition: pcm_data.h:139
wxString repository_name
Definition: pcm_data.h:143
PCM_PACKAGE package
Definition: pcm_data.h:140
uint64_t install_timestamp
Definition: pcm_data.h:144
wxString repository_id
Definition: pcm_data.h:142
wxString current_version
Definition: pcm_data.h:141
bool pinned
Definition: pcm_data.h:145
Repository reference to a resource.
Definition: pcm_data.h:96
wxString description
Definition: pcm_data.h:98
wxString description_full
Definition: pcm_data.h:99
wxString identifier
Definition: pcm_data.h:100
wxString license
Definition: pcm_data.h:104
std::vector< std::string > tags
Definition: pcm_data.h:106
STRING_MAP resources
Definition: pcm_data.h:105
std::optional< PCM_CONTACT > maintainer
Definition: pcm_data.h:103
wxString name
Definition: pcm_data.h:97
std::vector< PACKAGE_VERSION > versions
Definition: pcm_data.h:108
PCM_CONTACT author
Definition: pcm_data.h:102
Package installation entry.
Definition: pcm_data.h:123
PCM_RESOURCE_REFERENCE packages
Definition: pcm_data.h:125
std::vector< PCM_PACKAGE > package_list
Definition: pcm_data.h:131
wxString name
Definition: pcm_data.h:124
std::optional< PCM_RESOURCE_REFERENCE > resources
Definition: pcm_data.h:126
std::unordered_map< wxString, size_t > package_map
Definition: pcm_data.h:133
Repository metadata.
Definition: pcm_data.h:114
std::optional< wxString > sha256
Definition: pcm_data.h:116
uint64_t update_timestamp
Definition: pcm_data.h:117
#define FN_NORMALIZE_FLAGS
Default flags to pass to wxFileName::Normalize().
Definition: wx_filename.h:39