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