@@ -443,6 +443,156 @@ def check(self):
443443 self .check_not_exists ("public/" + prefix + "dists/" )
444444
445445
446+ class PublishUpdateAPIMultiDistToggle (APITest ):
447+ """
448+ POST /publish/:prefix with MultiDist=false, then PUT to enable MultiDist=true
449+ """
450+ fixtureGpg = True
451+
452+ def check (self ):
453+ repo_name = self .random_name ()
454+ self .check_equal (self .post (
455+ "/api/repos" , json = {"Name" : repo_name , "DefaultDistribution" : "bookworm" }).status_code , 201 )
456+
457+ d = self .random_name ()
458+ self .check_equal (self .upload ("/api/files/" + d ,
459+ "libboost-program-options-dev_1.49.0.1_i386.deb" , "pyspi_0.6.1-1.3.dsc" ,
460+ "pyspi_0.6.1-1.3.diff.gz" , "pyspi_0.6.1.orig.tar.gz" ,
461+ "pyspi-0.6.1-1.3.stripped.dsc" ).status_code , 200 )
462+
463+ task = self .post_task ("/api/repos/" + repo_name + "/file/" + d )
464+ self .check_task (task )
465+
466+ # Publish with MultiDist=false (default)
467+ prefix = self .random_name ()
468+ task = self .post_task (
469+ "/api/publish/" + prefix ,
470+ json = {
471+ "Architectures" : ["i386" , "source" ],
472+ "SourceKind" : "local" ,
473+ "Sources" : [{"Name" : repo_name }],
474+ "Signing" : DefaultSigningOptions ,
475+ "MultiDist" : False ,
476+ }
477+ )
478+ self .check_task (task )
479+
480+ repo_expected = {
481+ 'AcquireByHash' : False ,
482+ 'Architectures' : ['i386' , 'source' ],
483+ 'Codename' : '' ,
484+ 'Distribution' : 'bookworm' ,
485+ 'Label' : '' ,
486+ 'Origin' : '' ,
487+ 'NotAutomatic' : '' ,
488+ 'ButAutomaticUpgrades' : '' ,
489+ 'Path' : prefix + '/' + 'bookworm' ,
490+ 'Prefix' : prefix ,
491+ 'SkipContents' : False ,
492+ 'MultiDist' : False ,
493+ 'SourceKind' : 'local' ,
494+ 'Sources' : [{'Component' : 'main' , 'Name' : repo_name }],
495+ 'Storage' : '' ,
496+ 'Suite' : '' }
497+
498+ all_repos = self .get ("/api/publish" )
499+ self .check_equal (all_repos .status_code , 200 )
500+ self .check_in (repo_expected , all_repos .json ())
501+
502+ # With MultiDist=false packages are stored under pool/main/...
503+ self .check_exists ("public/" + prefix + "/dists/bookworm/Release" )
504+ self .check_exists ("public/" + prefix +
505+ "/dists/bookworm/main/binary-i386/Packages" )
506+ self .check_exists ("public/" + prefix +
507+ "/dists/bookworm/main/source/Sources" )
508+ self .check_exists (
509+ "public/" + prefix + "/pool/main/b/boost-defaults/libboost-program-options-dev_1.49.0.1_i386.deb" )
510+ self .check_exists (
511+ "public/" + prefix + "/pool/main/p/pyspi/pyspi-0.6.1-1.3.stripped.dsc" )
512+ # MultiDist-style per-distribution pool must not exist yet
513+ self .check_not_exists (
514+ "public/" + prefix + "/pool/bookworm/main/b/boost-defaults/libboost-program-options-dev_1.49.0.1_i386.deb" )
515+
516+ # Now update the published repo enabling MultiDist=true
517+ task = self .put_task (
518+ "/api/publish/" + prefix + "/bookworm" ,
519+ json = {
520+ "MultiDist" : True ,
521+ "Signing" : DefaultSigningOptions ,
522+ }
523+ )
524+ self .check_task (task )
525+
526+ repo_expected_multidist = {
527+ 'AcquireByHash' : False ,
528+ 'Architectures' : ['i386' , 'source' ],
529+ 'Codename' : '' ,
530+ 'Distribution' : 'bookworm' ,
531+ 'Label' : '' ,
532+ 'Origin' : '' ,
533+ 'NotAutomatic' : '' ,
534+ 'ButAutomaticUpgrades' : '' ,
535+ 'Path' : prefix + '/' + 'bookworm' ,
536+ 'Prefix' : prefix ,
537+ 'SkipContents' : False ,
538+ 'MultiDist' : True ,
539+ 'SourceKind' : 'local' ,
540+ 'Sources' : [{'Component' : 'main' , 'Name' : repo_name }],
541+ 'Storage' : '' ,
542+ 'Suite' : '' }
543+
544+ all_repos = self .get ("/api/publish" )
545+ self .check_equal (all_repos .status_code , 200 )
546+ self .check_in (repo_expected_multidist , all_repos .json ())
547+
548+ # After enabling MultiDist, packages are stored under pool/<distribution>/main/...
549+ self .check_exists ("public/" + prefix + "/dists/bookworm/Release" )
550+ self .check_exists ("public/" + prefix +
551+ "/dists/bookworm/main/binary-i386/Packages" )
552+ self .check_exists ("public/" + prefix +
553+ "/dists/bookworm/main/source/Sources" )
554+ self .check_exists (
555+ "public/" + prefix + "/pool/bookworm/main/b/boost-defaults/libboost-program-options-dev_1.49.0.1_i386.deb" )
556+ self .check_exists (
557+ "public/" + prefix + "/pool/bookworm/main/p/pyspi/pyspi-0.6.1-1.3.stripped.dsc" )
558+ # Flat pool must not exist while MultiDist is on
559+ self .check_not_exists (
560+ "public/" + prefix + "/pool/main/b/boost-defaults/libboost-program-options-dev_1.49.0.1_i386.deb" )
561+
562+ # Switch MultiDist back to false
563+ task = self .put_task (
564+ "/api/publish/" + prefix + "/bookworm" ,
565+ json = {
566+ "MultiDist" : False ,
567+ "Signing" : DefaultSigningOptions ,
568+ }
569+ )
570+ self .check_task (task )
571+
572+ repo_expected ["MultiDist" ] = False
573+ all_repos = self .get ("/api/publish" )
574+ self .check_equal (all_repos .status_code , 200 )
575+ self .check_in (repo_expected , all_repos .json ())
576+
577+ # Packages are back under the flat pool/main/...
578+ self .check_exists ("public/" + prefix + "/dists/bookworm/Release" )
579+ self .check_exists ("public/" + prefix +
580+ "/dists/bookworm/main/binary-i386/Packages" )
581+ self .check_exists ("public/" + prefix +
582+ "/dists/bookworm/main/source/Sources" )
583+ self .check_exists (
584+ "public/" + prefix + "/pool/main/b/boost-defaults/libboost-program-options-dev_1.49.0.1_i386.deb" )
585+ self .check_exists (
586+ "public/" + prefix + "/pool/main/p/pyspi/pyspi-0.6.1-1.3.stripped.dsc" )
587+ # Per-distribution pool must be gone
588+ self .check_not_exists (
589+ "public/" + prefix + "/pool/bookworm/main/b/boost-defaults/libboost-program-options-dev_1.49.0.1_i386.deb" )
590+
591+ task = self .delete_task ("/api/publish/" + prefix + "/bookworm" )
592+ self .check_task (task )
593+ self .check_not_exists ("public/" + prefix + "dists/" )
594+
595+
446596class PublishConcurrentUpdateAPITestRepo (APITest ):
447597 """
448598 PUT /publish/:prefix/:distribution (local repos), DELETE /publish/:prefix/:distribution
0 commit comments