Class: Yast::AddOnCreatorClass
- Inherits:
-
Module
- Object
- Module
- Yast::AddOnCreatorClass
- Defined in:
- ../../src/modules/AddOnCreator.rb
Instance Method Summary (collapse)
-
- (Object) AskForPassphrase(message, failure)
Report the error with failed gpg and ask for possible new entering of pw.
-
- (Object) BuildAddOn
Write all add-on-creator settings.
-
- (Object) CommitCurrentProduct
save the data with current configuration into global list + reset the current product map.
-
- (Object) CopyRPMs(in_path, base_path)
Copy the packages from the source directory to target.
-
- (Object) create_argument_lists(stdout)
converts the output of find command (=possibly big string with each file on one line), to the list of smaller strings (<128kB), each with space separated file names.
-
- (Object) CreateAddOnStructure(base_path)
Create the directory structure of the Add-On.
-
- (Object) CreateDirectoryYaSTFiles(base_path)
Create directory.yast files (the last step).
-
- (Object) CreateISOImage(dir_path, iso_p, name)
Create an ISO image of the product.
-
- (Object) CreateMD5SUMS(base_path)
Create MD5SUMS files.
-
- (Object) CreatePatternFullName(pattern, file)
if file is true, it creates the file name for the pattern, otherwise the Pat value.
-
- (Object) dir_has_files(dir)
helper to check if directory contains any files (-type f).
-
- (Object) Export
Export the settings about current Add-On product.
-
- (Object) FillContentDefaults
this is used during the workflow, not in the write! TODO change name…
-
- (Object) GenerateArchiveFiles(base_path)
Generate ARCHIVES.gz, INDEX.gz and ls-lR.gz.
-
- (Object) GenerateChangelog(base_path)
Generate Changelog for the product.
-
- (Object) GenerateDirectories(base_path)
generate the paths of media, data and description dirs.
-
- (Object) GenerateGPGKey(data)
Generate the key pair.
-
- (Object) GeneratePackageDescriptions
Generate the package descriptions using create_package_descr.
-
- (Object) GenerateReleasePackage(base_path)
Use BuildService tools to create -release package with product info.
-
- (Object) GetKeyUID(key)
read the user's ID for given GPG key.
-
- (Object) GetLangCodes(country)
return list of language codes, optionally together with country code.
-
- (Object) GetProductInfo(xml, merge_with_current)
Get the map describing product.xml and produce better readable YCP map (only changes are written when saving project, this means 'apply changes').
- - (Object) gzip_installed
- - (Object) Import(settings)
-
- (Object) ImportExistingProduct(dir_path)
import the data from existing add-on.
- - (Object) main
-
- (Object) Modified
Data was modified?.
-
- (Object) PrepareBuild
prepare the data of current product for a build (neccessary because input packages could get changed).
-
- (Object) Read
Initialize the settings for add-on-creator.
-
- (Object) read_secret_keys
read the list of available secret keys.
-
- (Object) ReadContentFile(file_path)
read the content file given by file name.
-
- (Object) ReadPackagesFile(file_path)
read the package description (package.lang) file.
-
- (Object) ReadPatternFile(file_path)
read the pattern given by file name (obsolete, use ReadPatternsFile instead).
-
- (Array) ReadPatternsFile(file_path)
read all the patterns defined in given file.
-
- (Object) ReadProductXML(prod_file_path)
import the data from given xml file.
-
- (Object) ResetCurrentProduct
Reset all settings related to current product.
-
- (Object) SelectProduct(product)
select the given product: fill in the global variables specific for the given product.
-
- (Object) SignAddOn(base_path, key)
Sign current Add-On product.
-
- (Object) uncompress_file(file_path)
Take a path to compressed file as argument and return path to uncompressed one.
-
- (Object) UpdateContentMap(content_list)
Take list of content-file data and update global content_map.
-
- (Object) Write
Write all AddOn products configurations.
-
- (Object) WriteContentFile(base_path, content_data)
Write the content file.
-
- (Object) WriteInfoFile(info_dir, info)
write info.txt file.
-
- (Object) WriteLicensesFiles(descr_path, base_path, files)
Write the text of available licenses to correct places.
-
- (Object) WriteMediaFiles(base_path, m_files, _next)
Write the media.n/media files.
-
- (Object) WritePackageDescriptions(descr_path, descr)
Write the package descriptions edited by user.
-
- (Object) WritePatchesFiles(base_path, p_files)
Create the patches files.
-
- (Object) WritePatterns(descr_path, base_path)
Write all files with patterns definitions.
-
- (Object) WriteProductsFiles(base_path, p_files)
Create the products file TODO editor - see ExpertSettingsDialog3.
-
- (Object) WriteServicepackArchive(base_path)
Generate servicepack.tar.gz archive for bootable media.
-
- (Object) WriteStringFiles(base_path, files)
Write the readme/COPYING/COPYRIGHT…
-
- (Object) WriteWorkflow(base_path, desc_path, packages, y2update_p)
Write the modification of installation workflow.
Instance Method Details
- (Object) AskForPassphrase(message, failure)
Report the error with failed gpg and ask for possible new entering of pw
3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 |
# File '../../src/modules/AddOnCreator.rb', line 3277 def AskForPassphrase(, failure) pw = nil info_term = failure ? VBox( HSpacing(70), # error label Left(Label(_("Signing of the product failed."))), == "" ? VSpacing(0) : RichText( Builtins.mergestring( Builtins.splitstring(String.EscapeTags(), "\n"), "<br>" ) ) ) : VSpacing() input_term = failure ? HBox( Left( CheckBox( Id(:again), Opt(:notify), # checkbox label _("Try again with different passphrase") ) ), Password(Id(:pw1), "") ) : VBox(Password(Id(:pw1), )) UI.OpenDialog( Opt(:decorated), HBox( HSpacing(0.5), VBox( info_term, input_term, PushButton(Id(:ok), Opt(:key_F10), Label.OKButton), VSpacing(0.5) ), HSpacing(0.5) ) ) UI.ChangeWidget(Id(:pw1), :Enabled, !failure) ret = :cancel begin ret = UI.UserInput if ret == :again enabled = Convert.to_boolean(UI.QueryWidget(Id(:pw1), :Enabled)) UI.ChangeWidget(Id(:pw1), :Enabled, !enabled) end if ret == :ok if UI.QueryWidget(Id(:pw1), :Enabled) == true pw = Convert.to_string(UI.QueryWidget(Id(:pw1), :Value)) end end end until ret == :ok || ret == :cancel UI.CloseDialog pw end |
- (Object) BuildAddOn
Write all add-on-creator settings
3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 |
# File '../../src/modules/AddOnCreator.rb', line 3871 def BuildAddOn base_output_path = Ops.get_string( @current_product, "base_output_path", "" ) # AddOnCreator Build dialog caption caption = _("Creating the Add-On") stages = [ # Progress stage _("Write the content file"), # Progress stage _("Create the structure of the add-on"), # Progress stage _("Write the patterns"), # Progress stage _("Copy the packages"), # Progress stage _("Generate the release package"), # Progress stage _("Create MD5 sums"), # Progress stage _("Sign resulting product") ] steps = [ # Progress step _("Writing the content file..."), # Progress step _("Creating the structure of the add-on..."), # Progress stage _("Writing the patterns..."), # Progress step _("Copying the packages..."), # Progress stage _("Generating the release package..."), # Progress step _("Creating MD5 sums..."), # Progress stage _("Signing resulting product...") ] if Ops.get_boolean(@current_product, "iso", false) # Progress stage stages = Builtins.add(stages, _("Create ISO image")) # Progress step steps = Builtins.add(steps, _("Creating ISO image...")) end # Progress finished steps = Builtins.add(steps, _("Finished")) Progress.New(caption, " ", Builtins.size(stages), stages, steps, "") Progress.NextStage # when building ISO, target directory is defined by iso_path: # let's use base_output_path for gathering data needed for iso creation if Ops.get_boolean(@current_product, "iso", false) iso_path = Ops.get_string(@current_product, "iso_path", "") if iso_path == "" Ops.set(@current_product, "iso_path", base_output_path) if !@only_sign_product base_output_path = Ops.add(@tmpdir, "/output") if FileUtils.Exists(base_output_path) SCR.Execute( path(".target.bash"), Builtins.sformat("/bin/rm -rf '%1'", base_output_path) ) end SCR.Execute(path(".target.mkdir"), base_output_path) end elsif !FileUtils.Exists(iso_path) SCR.Execute(path(".target.mkdir"), iso_path) end end if @only_sign_product GenerateDirectories(base_output_path) Progress.NextStage Progress.NextStage Progress.NextStage Progress.NextStage else if !WriteContentFile(base_output_path, @content) # Error message (do not translate 'content' Report.Error(_("Cannot write content file.")) return false end WriteStringFiles( base_output_path, Ops.get_map(@current_product, "readme_files", {}) ) WriteStringFiles( base_output_path, Ops.get_map(@current_product, "copying_files", {}) ) WriteStringFiles( base_output_path, Ops.get_map(@current_product, "copyright_files", {}) ) Progress.NextStage if !CreateAddOnStructure(base_output_path) # Error message Report.Error(_("Cannot create the output directory structure.")) return false end WritePatchesFiles( base_output_path, Ops.get_list(@current_product, "patches_files", []) ) WriteProductsFiles( base_output_path, Ops.get_list(@current_product, "products_files", []) ) WriteMediaFiles( base_output_path, Ops.get_list(@current_product, "media_files", []), Ops.get_string(@current_product, "nextmedia", "") ) WriteInfoFile( Ops.get(@full_media_paths, 0, ""), Ops.get_string(@current_product, "info", "") ) Progress.NextStage WritePatterns(@full_descr_path, base_output_path) Progress.NextStage CopyRPMs( Ops.get_string(@current_product, "rpm_path", ""), base_output_path ) Progress.NextStage GenerateReleasePackage(base_output_path) WritePackageDescriptions( @full_descr_path, Ops.get_map(@current_product, "packages_descr", {}) ) WriteLicensesFiles( @full_descr_path, base_output_path, Ops.get_map(@current_product, "license_files", {}) ) WriteWorkflow( base_output_path, Ops.get_string(@current_product, "workflow_path", ""), Ops.get_list(@current_product, "y2update_packages", []), Ops.get_string(@current_product, "y2update_path", "") ) Progress.NextStage GenerateArchiveFiles(base_output_path) end Progress.NextStage if Ops.get_boolean(@current_product, "changelog", false) GenerateChangelog(base_output_path) end WriteServicepackArchive(base_output_path) if !SignAddOn( base_output_path, Ops.get_string(@current_product, "gpg_key", "") ) return false end CreateMD5SUMS(base_output_path) CreateDirectoryYaSTFiles(base_output_path) if Ops.get_boolean(@current_product, "iso", false) Progress.NextStage CreateISOImage( base_output_path, Ops.get_string(@current_product, "iso_path", ""), Ops.get_string(@current_product, "iso_name", "") ) end Progress.NextStage ResetCurrentProduct() true end |
- (Object) CommitCurrentProduct
save the data with current configuration into global list + reset the current product map
3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 |
# File '../../src/modules/AddOnCreator.rb', line 3713 def CommitCurrentProduct Builtins.y2milestone("saving current product to the global list") product_info_values = {} Builtins.foreach(@product_info) do |key, desc| if Ops.get(desc, "value") != nil Ops.set( product_info_values, key, { "value" => Ops.get(desc, "value") } ) end end modified_product = Builtins.union( @current_product, # Commit is after everything was entered { "content_map" => @content_map, "product_info_values" => product_info_values, "available_packages" => @available_packages, "arch_directories" => @arch_directories, "package2filename" => @package2filename, "srcpackage2filename" => @srcpackage2filename, "generated" => true } ) if @selected_product == -1 @add_on_products = Builtins.add(@add_on_products, modified_product) else i = -1 @add_on_products = Builtins.maplist(@add_on_products) do |product| i = Ops.add(i, 1) i == @selected_product ? deep_copy(modified_product) : deep_copy(product) end end ResetCurrentProduct() @modified = true nil end |
- (Object) CopyRPMs(in_path, base_path)
Copy the packages from the source directory to target
2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 |
# File '../../src/modules/AddOnCreator.rb', line 2634 def CopyRPMs(in_path, base_path) return true if in_path == "" return false if !FileUtils.Exists(base_path) || !FileUtils.Exists(in_path) # packages in the directories with arch name if @arch_directories != [] Builtins.foreach(@arch_directories) do |arch| dir = Ops.add(Ops.add(in_path, "/"), arch) if FileUtils.Exists(dir) Builtins.y2milestone( "copying from %1 to %2...", dir, @full_data_path ) SCR.Execute( path(".target.bash_output"), Builtins.sformat("/bin/cp -r -- '%1' '%2/'", dir, @full_data_path) ) end end # packages not in directories but we have asked them for arch's elsif @available_packages != {} Builtins.foreach(@available_packages) do |arch, pa| out_dir = Ops.add(Ops.add(@full_data_path, "/"), arch) if arch != "ZZZ_imported" && arch != "ZZZ_required" && FileUtils.Exists(out_dir) Builtins.y2milestone("copying packages of '%1' architecture", arch) # arch_directories will be needed later for CreateMD5SUMS and # resign_packages @arch_directories = Convert.convert( Builtins.union(@arch_directories, [arch]), :from => "list", :to => "list <string>" ) if Ops.greater_than(Builtins.size(@package2filename), 0) && arch != "src" Builtins.y2debug("package names known") Builtins.foreach( Convert.convert(pa, :from => "list", :to => "list <string>") ) do |p| SCR.Execute( path(".target.bash"), Builtins.sformat( "/bin/cp -- '%1' '%2/'", Ops.get_string(@package2filename, [arch, p], ""), out_dir ) ) end elsif Ops.greater_than(Builtins.size(@srcpackage2filename), 0) && arch == "src" Builtins.y2debug("source packages, names known") Builtins.foreach( Convert.convert(pa, :from => "list", :to => "list <string>") ) do |p| SCR.Execute( path(".target.bash"), Builtins.sformat( "/bin/cp -- '%1' '%2/'", Ops.get_string(@srcpackage2filename, [arch, p], ""), out_dir ) ) end else Builtins.y2debug("package names not known, using wildcard") Builtins.foreach( Convert.convert(pa, :from => "list", :to => "list <string>") ) do |p| SCR.Execute( path(".target.bash"), Builtins.sformat( "/bin/cp -- '%1/%2'*.rpm '%3/'", in_path, p, out_dir ) ) end end end end end true end |
- (Object) create_argument_lists(stdout)
converts the output of find command (=possibly big string with each file on one line), to the list of smaller strings (<128kB), each with space separated file names
1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 |
# File '../../src/modules/AddOnCreator.rb', line 1665 def create_argument_lists(stdout) ret = [] return deep_copy(ret) if stdout == nil || stdout == "" # approximately maximum size of parameters list passed to rpm kbytes = 120 # looks like pre-sorting helps to fasten rpm call found = Builtins.sort(Builtins.splitstring(stdout, "\n")) if Ops.less_or_equal(Ops.divide(Builtins.size(stdout), 1024), kbytes) ret = [Builtins.mergestring(found, " ")] else line = "" Builtins.foreach(found) do |file| line = Ops.add(Ops.add(line, file), " ") if Ops.greater_than(Ops.divide(Builtins.size(line), 1024), kbytes) ret = Builtins.add(ret, line) line = "" end end if Ops.less_or_equal(Ops.divide(Builtins.size(line), 1024), kbytes) ret = Builtins.add(ret, line) end end deep_copy(ret) end |
- (Object) CreateAddOnStructure(base_path)
Create the directory structure of the Add-On
2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 |
# File '../../src/modules/AddOnCreator.rb', line 2228 def CreateAddOnStructure(base_path) return false if !FileUtils.Exists(base_path) GenerateDirectories(base_path) # create the media's directories Builtins.foreach(@full_media_paths) do |dir| SCR.Execute(path(".target.mkdir"), dir) end # create the data dir if Ops.get(@content_map, "DATADIR", "") == "" Builtins.y2error( "DATADIR is : %1", Ops.get(@content_map, "DATADIR", "") ) return false end SCR.Execute(path(".target.mkdir"), @full_data_path) # create the dirs for packages Builtins.foreach(@available_packages) do |arch_dir, pa| if arch_dir != "ZZZ_imported" && arch_dir != "ZZZ_required" SCR.Execute( path(".target.mkdir"), Ops.add(Ops.add(@full_data_path, "/"), arch_dir) ) end end if @arch_directories == [] SCR.Execute(path(".target.mkdir"), @full_descr_path) true end |
- (Object) CreateDirectoryYaSTFiles(base_path)
Create directory.yast files (the last step)
3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 |
# File '../../src/modules/AddOnCreator.rb', line 3627 def CreateDirectoryYaSTFiles(base_path) return false if !FileUtils.Exists(base_path) Builtins.y2milestone("creating directory.yast files...") Builtins.foreach( Convert.convert( Builtins.merge([base_path, @full_descr_path], @full_media_paths), :from => "list", :to => "list <string>" ) ) do |dir| SCR.Execute( path(".target.bash_output"), Builtins.sformat( "cd '%1'; ls -A1 -p | grep -v 'directory.yast' > directory.yast", dir ), { "LANG" => "C" } ) end Builtins.y2milestone("... done") true end |
- (Object) CreateISOImage(dir_path, iso_p, name)
Create an ISO image of the product
3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 |
# File '../../src/modules/AddOnCreator.rb', line 3652 def CreateISOImage(dir_path, iso_p, name) return true if !Ops.get_boolean(@current_product, "iso", false) return false if !FileUtils.Exists(dir_path) || !FileUtils.Exists(iso_p) if name == "" name = Builtins.sformat( "%1-%2", Builtins.tolower(Ops.get(@content_map, "NAME", "addon")), Ops.get(@content_map, "VERSION", "") ) end name = Ops.add(name, ".iso") if !Builtins.issubstring(name, ".iso") Ops.set(@current_product, "iso_name", name) # ?? Builtins.y2milestone( "creating iso image '%1/%2' from '%3' with mkisofs...", iso_p, name, dir_path ) # possible options -allow-leading-dots cmd = Builtins.sformat( "mkisofs -r -J -l -o '%1/%2' '%3'", iso_p, name, dir_path ) out = Convert.to_map(SCR.Execute(path(".target.bash_output"), cmd)) if Ops.get_integer(out, "exit", 0) != 0 Builtins.y2warning("%1 returned %2", cmd, out) end Builtins.y2milestone("... done") true end |
- (Object) CreateMD5SUMS(base_path)
Create MD5SUMS files
3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 |
# File '../../src/modules/AddOnCreator.rb', line 3175 def CreateMD5SUMS(base_path) return false if !FileUtils.Exists(base_path) # after CopyRPMs, arch_directories contains list of directories with RPM's dirs_for_md5 = Builtins.maplist(@arch_directories) do |arch_dir| Ops.add(Ops.add(@full_data_path, "/"), arch_dir) end dirs_for_md5 = Builtins.add(dirs_for_md5, @full_descr_path) Builtins.foreach(dirs_for_md5) do |full_path| if dir_has_files(full_path) Builtins.y2milestone("creating MDBSUM in %1", full_path) # whole dir was copied -> also with original MD5SUMS if FileUtils.Exists(Ops.add(full_path, "/MD5SUMS")) SCR.Execute( path(".target.bash"), Builtins.sformat( "cd '%1'; chmod +w . MD5SUMS; rm MD5SUMS", full_path ) ) end command = Builtins.sformat( "cd '%1'; md5sum -- * > MD5SUMS", full_path ) out2 = Convert.to_map( SCR.Execute(path(".target.bash_output"), command, { "LANG" => "C" }) ) if Ops.get_integer(out2, "exit", 0) != 0 Builtins.y2error("%1 failed: %2", command, out2) end end end # sha1sums of descriptions out = Convert.to_map( SCR.Execute( path(".target.bash_output"), Builtins.sformat("ls -A1 '%1'", @full_descr_path) ) ) Builtins.foreach( Builtins.splitstring(Ops.get_string(out, "stdout", ""), "\n") ) do |file| next if file == "" || file == "MD5SUMS" Builtins.y2milestone("creating sha1sum of %1", file) out = Convert.to_map( SCR.Execute( path(".target.bash_output"), Builtins.sformat( "cd '%1' && sha1sum -- %2", @full_descr_path, String.Quote(file) ), { "LANG" => "C" } ) ) command = Builtins.sformat( "echo 'META SHA1 %1' >> '%2/content'", Builtins.deletechars(Ops.get_string(out, "stdout", ""), "\n"), base_path ) SCR.Execute(path(".target.bash"), command, { "LANG" => "C" }) end # sha1sums of the rest of interesting files Builtins.foreach( [ "installation.xml", "license.tar.gz", "y2update.tgz", "media.1/info.txt" ] ) do |file| if FileUtils.Exists(Ops.add(Ops.add(base_path, "/"), file)) Builtins.y2milestone("creating sha1sum of %1", file) out = Convert.to_map( SCR.Execute( path(".target.bash_output"), Builtins.sformat( "cd '%1' && sha1sum -- %2", base_path, String.Quote(file) ), { "LANG" => "C" } ) ) command = Builtins.sformat( "echo 'HASH SHA1 %1' >> '%2/content'", Builtins.deletechars(Ops.get_string(out, "stdout", ""), "\n"), base_path ) SCR.Execute(path(".target.bash"), command, { "LANG" => "C" }) end end true end |
- (Object) CreatePatternFullName(pattern, file)
if file is true, it creates the file name for the pattern, otherwise the Pat value
1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 |
# File '../../src/modules/AddOnCreator.rb', line 1045 def CreatePatternFullName(pattern, file) pattern = deep_copy(pattern) Builtins.sformat( "%1%5%2%5%3%6%4%7", Ops.get_string(pattern, "name", ""), Ops.get_string(pattern, "version", ""), Ops.get_string(pattern, "release", ""), Ops.get_string(pattern, "arch", ""), file ? "-" : " ", file ? "." : " ", file ? ".pat" : "" ) end |
- (Object) dir_has_files(dir)
helper to check if directory contains any files (-type f)
3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 |
# File '../../src/modules/AddOnCreator.rb', line 3158 def dir_has_files(dir) return false if !FileUtils.Exists(dir) out = Convert.to_map( SCR.Execute( path(".target.bash_output"), Builtins.sformat("cd '%1'; find -maxdepth 1 -type f | wc -l", dir) ) ) count = Builtins.tointeger( Builtins.deletechars(Ops.get_string(out, "stdout", "0"), "\n") ) count != nil && Ops.greater_than(count, 0) end |
- (Object) Export
Export the settings about current Add-On product
4077 4078 4079 4080 |
# File '../../src/modules/AddOnCreator.rb', line 4077 def Export Builtins.y2warning("not implemented") {} end |
- (Object) FillContentDefaults
this is used during the workflow, not in the write! TODO change name…
1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 |
# File '../../src/modules/AddOnCreator.rb', line 1692 def FillContentDefaults # AddOnCreator Build dialog caption caption = _("Generating Product Data") stages = [ # Progress stage _("Find package directories") ] steps = [ # Progress step _("Looking for package directories...") ] if !@clone stages = Builtins.union( stages, [ # Progress stage _("Check package architectures"), # Progress stage _("Generate content file defaults") ] ) steps = Builtins.union( steps, [ # Progress step _("Checking package architectures..."), # Progress step _("Generating content file defaults...") ] ) end stages = Builtins.union( stages, [ # Progress stage _("Generate package descriptions") ] ) steps = Builtins.union( steps, [ # Progress step _("Generate package descriptions") ] ) Progress.New( caption, " ", Builtins.size(stages), Convert.convert(stages, :from => "list", :to => "list <string>"), Convert.convert(steps, :from => "list", :to => "list <string>"), # help text _("<b>Wait while generating data for add-on...</b><br/>\n") ) Progress.NextStage arch_map = {} rpm_path = Ops.get_string(@current_product, "rpm_path", "") # 1. find the used architectures cmd = Builtins.sformat("cd '%1'; find -maxdepth 1 -type d", rpm_path) out = {} if rpm_path != "" out = Convert.to_map(SCR.Execute(path(".target.bash_output"), cmd)) end @arch_directories = [] Builtins.foreach( Builtins.splitstring(Ops.get_string(out, "stdout", ""), "\n") ) do |d| splitdir = Builtins.splitstring(d, "/") arch_dir = Ops.get_string(splitdir, 1, "") if Builtins.contains(@allowed_archs, arch_dir) || arch_dir == "src" @arch_directories = Builtins.add(@arch_directories, arch_dir) end end Progress.NextStage # name of -release packages, if found release_packages = [] if !@clone # 2. get the list of architectures from RPM's if rpm_path != "" out = Convert.to_map( SCR.Execute( path(".target.bash_output"), Builtins.sformat("find '%1' -name '*.rpm'", rpm_path) ) ) end Builtins.y2milestone("asking the RPM's for ARCH and NAME...") # for which architectures are the packages built package_architectures = {} Builtins.foreach( Builtins.splitstring(Ops.get_string(out, "stdout", ""), "\n") ) do |f| next if f == "" out = Convert.to_map( SCR.Execute( path(".target.bash_output"), Builtins.sformat( "rpm -q -p '%1' --qf \"%%{ARCH}\n" + "%%{NAME}\n" + "%%|SOURCERPM?{bin}:{src}|\"", f ) ) ) lines = Builtins.splitstring(Ops.get_string(out, "stdout", ""), "\n") arch = Ops.get_string(lines, 0, "") name = Ops.get_string(lines, 1, "") sourcerpm = Ops.get_string(lines, 2, "") # 'arch' is directory where to put final package arch = "src" if sourcerpm == "src" if name != "" && arch != "" Ops.set( @available_packages, arch, Builtins.add(Ops.get(@available_packages, arch, []), name) ) if !Builtins.haskey(@package2filename, arch) Ops.set(@package2filename, arch, {}) end if !Builtins.haskey(@srcpackage2filename, arch) Ops.set(@srcpackage2filename, arch, {}) end if arch != "src" Ops.set(@package2filename, [arch, name], f) Ops.set(package_architectures, arch, 1) else Ops.set(@srcpackage2filename, [arch, name], f) end end if name != "" && Ops.greater_than(Builtins.size(name), 8) && Builtins.issubstring(name, "-release") Builtins.y2milestone("release package found: %1, %2", name, f) release_packages = Builtins.add(release_packages, f) end end Builtins.y2milestone("... done") Progress.NextStage # 3. add 'guessed' ARCH.base values to the content file if @content_map != {} || arch_map != {} @content = [] # new proposal Builtins.foreach(@content_descr) do |key, entry| if Ops.get(@content_map, key, "") != "" Ops.set(entry, "value", Ops.get(@content_map, key, "")) end if key == "BASEARCHS" archs = Builtins.mergestring(@arch_directories, " ") if @arch_directories == [] archs = Builtins.mergestring( Builtins.maplist(package_architectures) { |a, v| a }, " " ) end Ops.set(entry, "value", archs) end if key == "DISTRIBUTION" && Ops.get(@content_map, key, "") == "" Ops.set( entry, "value", Ops.add( Ops.add(Ops.get(@content_map, "NAME", ""), " "), Ops.get(@content_map, "VERSION", "") ) ) end @content = Builtins.add(@content, entry) end end required_rpm_path = Ops.get_string( @current_product, "required_rpm_path", "" ) # 4. read the list of packages, not present on AddOn if required_rpm_path != "" && required_rpm_path != rpm_path out = Convert.to_map( SCR.Execute( path(".target.bash_output"), Builtins.sformat("cd '%1'; find -name '*.rpm'", required_rpm_path) ) ) Builtins.y2milestone("asking the RPM's for NAME...") inputs = create_argument_lists(Ops.get_string(out, "stdout", "")) output = "" Builtins.foreach(inputs) do |input| cmd2 = Builtins.sformat( "cd '%1'; rpm --qf \"%%{NAME}\n\" -qp %2", required_rpm_path, input ) out = Convert.to_map(SCR.Execute(path(".target.bash_output"), cmd2)) output = Ops.add( Ops.add(output, Ops.get_string(out, "stdout", "")), "\n" ) end # remove empty strings and duplicates Ops.set( @available_packages, "ZZZ_required", Builtins.toset(Builtins.filter(Builtins.splitstring(output, "\n")) do |name| name != "" end) ) Builtins.y2milestone("... done") end Progress.NextStage else out = Convert.to_map( SCR.Execute( path(".target.bash_output"), Builtins.sformat("find %1 -name '*-release*'", rpm_path) ) ) Builtins.foreach( Builtins.splitstring(Ops.get_string(out, "stdout", ""), "\n") ) do |f| next if f == "" out = Convert.to_map( SCR.Execute( path(".target.bash_output"), Builtins.sformat( "rpm -q -p %1 --qf \"%%{NAME}\n%%|SOURCERPM?{bin}:{src}|\"", f ) ) ) lines = Builtins.splitstring(Ops.get_string(out, "stdout", ""), "\n") name = Ops.get_string(lines, 0, "") sourcerpm = Ops.get_string(lines, 1, "") if sourcerpm != "src" && name != "" && Ops.greater_than(Builtins.size(name), 8) && Builtins.issubstring(name, "-release") Builtins.y2milestone("release package found: %1, %2", name, f) release_packages = Builtins.add(release_packages, f) end end end if rpm_path == "" Progress.Finish return end reldir = Ops.add(@tmpdir, "/release") if release_packages != [] # when release package is present, do not offer to change it Ops.set(@current_product, "generate_release_package", false) end requireslist = [] # read the product info contained in release package Builtins.foreach(release_packages) do |release_package| # use 'reldir' only for one package SCR.Execute(path(".target.bash"), Ops.add("rm -rf ", reldir)) SCR.Execute(path(".target.mkdir"), reldir) SCR.Execute( path(".target.bash"), Builtins.sformat("cp -- %1 %2", release_package, reldir) ) SCR.Execute( path(".target.bash"), Builtins.sformat( "cd %1; rpm2cpio %2 | cpio -imud 2>/dev/null", reldir, Builtins.substring( release_package, Ops.add(Builtins.findlastof(release_package, "/"), 1) ) ) ) out = Convert.to_map( SCR.Execute( path(".target.bash_output"), Builtins.sformat( "ls -A1 %1/release/etc/products.d/*.prod 2>/dev/null", @tmpdir ) ) ) out_l = Builtins.splitstring(Ops.get_string(out, "stdout", ""), "\n") prod_file = Ops.get_string(out_l, 0, "") # we care about the first one if prod_file == "" # release package does not contain .prod, it may be flavor package: # check for product dependencies # rpm -qp --requires `path to rpm` | grep product out = Convert.to_map( SCR.Execute( path(".target.bash_output"), Builtins.sformat( "rpm -qp --requires %1 | grep \"product(.*)\"", release_package ) ) ) # line is e.g. 'product(SUSE_SLED-SP3-dvd5) = 11-2', which means # name-SPpatchlevel-flavor flag version-release, where # only name, flag and version are mandatory re = "^product[(]+([^-]*)[-]*(SP[0-9]*)*[-]*([^-]*)[)]+[ \t]*([<=>]+)[ \t]*([0-9]*)[-]*(.*)$" Builtins.foreach( Builtins.splitstring(Ops.get_string(out, "stdout", ""), "\n") ) do |prodline| next if prodline == "" tokens = Builtins.regexptokenize(prodline, re) # = ["SUSE_SLED","SP3","dvd5","=","11","2"] for above example flag = "EQ" if Ops.get_string(tokens, 3, "") == ">" flag = "GE" elsif Ops.get_string(tokens, 3, "") == "<" flag = "LT" end requiremap = { "name" => Ops.get_string(tokens, 0, ""), "version" => Ops.get_string(tokens, 4, ""), "flag" => flag } if Ops.get_string(tokens, 1, "") != "" Ops.set( requiremap, "patchlevel", Builtins.substring(Ops.get_string(tokens, 1, ""), 2) ) end if Ops.get_string(tokens, 2, "") != "" Ops.set(requiremap, "flavor", Ops.get_string(tokens, 2, "")) end if Ops.get_string(tokens, 5, "") != "" Ops.set(requiremap, "release", Ops.get_string(tokens, 5, "")) end Builtins.y2milestone("requiremap: %1", requiremap) requireslist = Builtins.add(requireslist, requiremap) end next end Builtins.y2milestone("reading product info from %1", prod_file) # read the prod file info and add it into the template @product_xml = ReadProductXML(prod_file) # translate product_xml map into product_info @product_info = GetProductInfo(@product_xml, true) end if requireslist != [] Ops.set( @product_info, "requires", Ops.get(@product_info_descr, "requires", {}) ) Ops.set(@product_info, ["requires", "value"], requireslist) end # generate tmp package descriptions... if (@generate_descriptions || !@clone) && FileUtils.Exists("/usr/bin/create_package_descr") Builtins.y2milestone("creating packages descriptions...") cmd = Builtins.sformat( "/usr/bin/create_package_descr -d '%1' -C -F -o %2", rpm_path, @tmpdir ) SCR.Execute(path(".target.bash"), cmd, { "LANG" => "C" }) Builtins.y2milestone("... done") end out = Convert.to_map( SCR.Execute( path(".target.bash_output"), Builtins.sformat("ls -A1 %1/packages.* 2>/dev/null", @tmpdir) ) ) lang = "en" packages_descr = Ops.get_map(@current_product, "packages_descr", {}) Builtins.foreach( Builtins.splitstring(Ops.get_string(out, "stdout", ""), "\n") ) do |file| f = Builtins.splitstring(file, ".") lang = Ops.get_string(f, Ops.subtract(Builtins.size(f), 1), "en") if lang == "gz" # fortunatelly, there is no 'gz' locale... if Ops.greater_than(Builtins.size(f), 2) lang = Ops.get_string(f, Ops.subtract(Builtins.size(f), 2), "en") else next end end next if file == "" || lang == "DU" || lang == "FL" if Ops.get_map(packages_descr, lang, {}) == {} Ops.set(packages_descr, lang, ReadPackagesFile(file)) next end package_names = Builtins.mapmap(Ops.get_map(packages_descr, lang, {})) do |p, d| { Ops.get(Builtins.splitstring(p, " "), 0, p) => p } end # now, we need to merge old data from packages_descr with currently # generated ones (TODO this works only for packages.en) Builtins.foreach( Convert.convert( ReadPackagesFile(file), :from => "map", :to => "map <string, map>" ) ) do |p, d| if !Builtins.haskey(Ops.get_map(packages_descr, lang, {}), p) Builtins.y2debug("new package %1", d) Ops.set(packages_descr, [lang, p], d) name = Ops.get(Builtins.splitstring(p, " "), 0, p) if Ops.get_string(package_names, name, "") != "" Builtins.y2milestone( "replacing saved '%1' with present '%2'", Ops.get_string(package_names, name, ""), p ) Ops.set( packages_descr, lang, Builtins.remove( Ops.get_map(packages_descr, lang, {}), Ops.get_string(package_names, name, "") ) ) end end end end Ops.set(@current_product, "packages_descr", packages_descr) # we need the list of packages (for patterns), but asking # rpm would be slow, so let's get it from (already existing) descriptions if @clone Builtins.y2milestone( "gathering available_packages from descriptions..." ) Builtins.foreach(Ops.get_map(packages_descr, lang, {})) do |p, d| next if p == "___global___" pkg_list = Builtins.splitstring(Ops.get_string(d, "Pkg", ""), " ") arch = Ops.get_string( pkg_list, Ops.subtract(Builtins.size(pkg_list), 1), "noarch" ) Ops.set( @available_packages, arch, Builtins.add(Ops.get(@available_packages, arch, []), p) ) end end Progress.NextStage nil end |
- (Object) GenerateArchiveFiles(base_path)
Generate ARCHIVES.gz, INDEX.gz and ls-lR.gz
2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 |
# File '../../src/modules/AddOnCreator.rb', line 2351 def GenerateArchiveFiles(base_path) if !Package.Installed("inst-source-utils") && !FileUtils.Exists("/usr/bin/mk_listings") Builtins.y2error( "inst-source-utils not installed and mk_listings not present" ) return false end return false if !FileUtils.Exists(base_path) out = Convert.to_map( SCR.Execute( path(".target.bash_output"), Builtins.sformat("cd '%1';mk_listings .", base_path) ) ) if Ops.get_string(out, "stderr", "") != "" Builtins.y2warning("mk_listings returns %1", out) end true end |
- (Object) GenerateChangelog(base_path)
Generate Changelog for the product
3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 |
# File '../../src/modules/AddOnCreator.rb', line 3063 def GenerateChangelog(base_path) if !Package.Installed("inst-source-utils") && !FileUtils.Exists("/usr/bin/mk_changelog") Builtins.y2error( "inst-source-utils not installed and mk_changelog not present" ) return false end return false if !FileUtils.Exists(base_path) out = Convert.to_map( SCR.Execute( path(".target.bash_output"), Builtins.sformat("cd '%1'; mk_changelog", base_path), { "ROOT_ON_CD" => Ops.get(@content_map, "DATADIR", "") } ) ) if Ops.get_string(out, "stderr", "") != "" Builtins.y2warning("mk_changelog returns %1", out) end true end |
- (Object) GenerateDirectories(base_path)
generate the paths of media, data and description dirs
2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 |
# File '../../src/modules/AddOnCreator.rb', line 2204 def GenerateDirectories(base_path) i = 1 no_of_medias = 1 while Ops.less_or_equal(i, no_of_medias) media_path = Builtins.sformat("%1/media.%2", base_path, i) @full_media_paths = Builtins.add(@full_media_paths, media_path) i = Ops.add(i, 1) end @full_data_path = Builtins.sformat( "%1/%2", base_path, Ops.get(@content_map, "DATADIR", "") ) @full_descr_path = Builtins.sformat( "%1/%2", base_path, Ops.get(@content_map, "DESCRDIR", "") ) nil end |
- (Object) GenerateGPGKey(data)
Generate the key pair
1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 |
# File '../../src/modules/AddOnCreator.rb', line 1074 def GenerateGPGKey(data) data = deep_copy(data) data_cont = Builtins.sformat( "Key-Type: %1\n", Ops.get(data, "Key-Type", "") ) data = Builtins.remove(data, "Key-Type") Builtins.foreach(data) do |key, val| if val != "" data_cont = Ops.add(data_cont, Builtins.sformat("%1: %2\n", key, val)) end end # save the needed data to file data_path = Ops.add(@tmpdir, "/gen-key-data") SCR.Write(path(".target.string"), data_path, data_cont) out = Convert.to_map( SCR.Execute( path(".target.bash_output"), Ops.add("gpg --batch --gen-key ", data_path) ) ) if Ops.get_integer(out, "exit", 0) != 0 Builtins.y2warning("error calling gpg: %1", out) return "" end SCR.Execute(path(".target.remove"), data_path) @gpg_keys = read_secret_keys Ops.get(@gpg_keys, Ops.subtract(Builtins.size(@gpg_keys), 1), "") end |
- (Object) GeneratePackageDescriptions
Generate the package descriptions using create_package_descr
2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 |
# File '../../src/modules/AddOnCreator.rb', line 2264 def GeneratePackageDescriptions return false if !FileUtils.Exists("/usr/bin/create_package_descr") command = Builtins.sformat( "/usr/bin/create_package_descr -d %1 -C -F -o %2", @full_data_path, @full_descr_path ) SCR.Execute(path(".target.bash_output"), command, { "LANG" => "C" }) true end |
- (Object) GenerateReleasePackage(base_path)
Use BuildService tools to create -release package with product info
2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 |
# File '../../src/modules/AddOnCreator.rb', line 2722 def GenerateReleasePackage(base_path) if !Ops.get_boolean(@current_product, "generate_release_package", false) Builtins.y2milestone("release package should not be generated") return true end if !Package.Install("obs-productconverter") # error report Report.Error( _( "Failed to install obs-productconverter package.\nRelease package will not be generated." ) ) return false end if !FileUtils.Exists(@full_data_path) Builtins.y2error("path '%1' does not exist", @full_data_path) return false end # release packages names and architectures release_packages = {} # 1. update product_xml map using product_info and content, # write the result into temporary .prod file name = Ops.get(@content_map, "NAME", "add-on") submap = deep_copy(@product_xml) if Ops.greater_than( Builtins.size( Ops.get_list(@product_xml, ["productdefinition", 0, "products"], []) ), 0 ) submap = Ops.get_map( @product_xml, ["productdefinition", 0, "products", 0], {} ) end submap = Ops.get_map(submap, ["product", 0], {}) Ops.set(submap, "id", name) Ops.set(submap, ["name", 0, @content_key], name) Ops.set( submap, ["version", 0, @content_key], Ops.get(@content_map, "VERSION", "1.0") ) Ops.set( submap, ["vendor", 0, @content_key], Ops.get(@content_map, "VENDOR", "") ) Builtins.foreach(["release", "summary", "description"]) do |key| if Ops.get_string(@product_info, [key, "value"], "") == "" Ops.set(@product_info, [key, "value"], key == "release" ? "0" : name) end Ops.set( submap, [key, 0, @content_key], Ops.get_string(@product_info, [key, "value"], "") ) end if Ops.get_string(@product_info, ["releasenotes", "value"], "") != "" i = -1 Builtins.foreach(Ops.get_list(submap, ["urls", 0, "url"], [])) do |url| i = Ops.add(i, 1) if Ops.get_string(url, "name", "") == "releasenotes" Ops.set( submap, ["urls", 0, "url", i, @content_key], Ops.get_string(@product_info, ["releasenotes", "value"], "") ) end end if i == -1 Ops.set( submap, "urls", [ { "url" => [ { "name" => "releasenotes", @content_key => Ops.get_string( @product_info, ["releasenotes", "value"], "" ) } ] } ] ) end end # write the dependency stuff dependency = [] Builtins.foreach(@product_info) do |key, desc| if Ops.get_string(desc, "type", "") == "dependency" Builtins.foreach(Ops.get_list(desc, "value", [])) do |dep| dependency = Builtins.add( dependency, Builtins.add(dep, "relationship", key) ) end end end mediasets = [] if Ops.greater_than(Builtins.size(dependency), 0) mediasets = [ { "media" => [ { "productdependency" => dependency, "type" => Ops.get_string( @product_info, ["media type", "value"], "dvd" ), "flavor" => Ops.get_string( @product_info, ["flavor", "value"], "dvd" ), "name" => name, "product" => name } ] } ] end @product_xml = { "productdefinition" => [ { "products" => [{ "product" => [submap] }], "mediasets" => mediasets } ] } prod_file_path = Builtins.sformat("%1/%2.product", @tmpdir, name) SCR.Write( path(".anyxml"), { "file" => prod_file_path, "xml" => @product_xml, "args" => { "XMLDecl" => "<?xml version=\"1.0\" encoding=\"UTF-8\"?>", "ForceContent" => 1, "ForceArray" => 1, "KeepRoot" => 1, "ContentKey" => @content_key, "KeyAttr" => [] } } ) product_dir = Ops.add(Ops.add(@tmpdir, "/"), name) SCR.Execute(path(".target.mkdir"), product_dir) # 2. call bs_productconvert to generate a spec file for -release package out = Convert.to_map( SCR.Execute( path(".target.bash_output"), Builtins.sformat( "/usr/lib/obs/server/bs_productconvert %1 %2 %3", prod_file_path, product_dir, name ) ) ) if Ops.get_integer(out, "exit", 0) != 0 Builtins.y2error( "bs_productconvert failed with %1", Ops.get_string(out, "stderr", "") ) SCR.Execute(path(".target.remove"), prod_file_path) SCR.Execute( path(".target.bash"), Builtins.sformat("rm -rf '%1'", product_dir) ) return false end # 3. build the release package from generated .spec file cmd = Builtins.sformat( "rpmbuild -bb `find -L %1 -name %2-release.spec`", @tmpdir, name ) out = Convert.to_map( SCR.Execute(path(".target.bash_output"), cmd, { "LANG" => "C" }) ) if Ops.get_integer(out, "exit", 0) != 0 # error popup Report.Error( Builtins.sformat( _("Build of release package failed with\n'%1'."), Ops.get_string(out, "stderr", "") ) ) Builtins.y2error("command '%1' failed with: \n%2", cmd, out) else Builtins.foreach( Builtins.splitstring(Ops.get_string(out, "stdout", ""), "\n") ) do |line| if Ops.greater_than(Builtins.size(line), 8) && Builtins.substring(line, 0, 7) == "Wrote: " ll = Builtins.splitstring(line, " \t\n") package = Ops.get_string(ll, 1, "") if package != "" && FileUtils.Exists(package) Builtins.y2milestone("release package: %1", package) out = Convert.to_map( SCR.Execute( path(".target.bash_output"), Builtins.sformat("rpm -q -p %1 --qf \"%%{ARCH}\"", package) ) ) Ops.set( release_packages, package, Ops.get_string(out, "stdout", "") ) end end end end # 4. copy the release package to the correct place Builtins.foreach(release_packages) do |package_path, arch| # create arch directory if it does not exist if !Builtins.contains(@arch_directories, arch) @arch_directories = Builtins.add(@arch_directories, arch) SCR.Execute( path(".target.mkdir"), Ops.add(Ops.add(@full_data_path, "/"), arch) ) end SCR.Execute( path(".target.bash"), Builtins.sformat( "/bin/cp -r -- %1 '%2/%3'", package_path, @full_data_path, arch ) ) end # 5. generate metadata for new package Builtins.y2milestone( "updating packages descriptions after adding release packages" ) cmd = Builtins.sformat( "/usr/bin/create_package_descr -d %1 -C -F -o %2", @full_data_path, @tmpdir ) if SCR.Execute(path(".target.bash"), cmd, { "LANG" => "C" }) != 0 Builtins.y2error("'%1' failed", cmd) end # 6. delete the tmp files, so it doesn't mess possible next builds SCR.Execute(path(".target.remove"), prod_file_path) SCR.Execute( path(".target.bash"), Builtins.sformat("rm -rf '%1'", product_dir) ) true end |
- (Object) GetKeyUID(key)
read the user's ID for given GPG key
3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 |
# File '../../src/modules/AddOnCreator.rb', line 3824 def GetKeyUID(key) out = Convert.to_map( SCR.Execute( path(".target.bash_output"), Builtins.sformat( "gpg --list-secret-keys %1 | grep uid | sed -e 's/^uid[ ]*//'", key ) ) ) name = Builtins.deletechars(Ops.get_string(out, "stdout", ""), "\n") name == nil ? "" : name end |
- (Object) GetLangCodes(country)
return list of language codes, optionally together with country code
1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 |
# File '../../src/modules/AddOnCreator.rb', line 1019 def GetLangCodes(country) key = country ? "with_country" : "languages" cut = country ? "cut -f 1 -d . | cut -f 1 -d @" : "cut -f 1 -d _" if Ops.get(@lang_codes, key) == nil out = Convert.to_map( SCR.Execute( path(".target.bash_output"), Ops.add("locale -a | ", cut), { "LANG" => "C" } ) ) Ops.set( @lang_codes, key, Builtins.filter( Builtins.toset( Builtins.splitstring(Ops.get_string(out, "stdout", ""), "\n") ) ) { |l| l != "" && l != "C" && l != "POSIX" } ) end Ops.get_list(@lang_codes, key, []) end |
- (Object) GetProductInfo(xml, merge_with_current)
Get the map describing product.xml and produce better readable YCP map (only changes are written when saving project, this means 'apply changes')
902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 |
# File '../../src/modules/AddOnCreator.rb', line 902 def GetProductInfo(xml, merge_with_current) xml = deep_copy(xml) # (because it is 'merge_with_current', product_info can # be used as global variable, reflecting current state) retmap = merge_with_current ? deep_copy(@product_info) : deep_copy(@product_info_descr) prod_map = {} if Ops.greater_than( Builtins.size( Ops.get_list(xml, ["productdefinition", 0, "products"], []) ), 0 ) prod_map = Ops.get_map( xml, ["productdefinition", 0, "products", 0, "product", 0], {} ) else prod_map = Ops.get_map(xml, ["product", 0], {}) end # maso, ze? # only simple values are supported here, something nested # deeper (e.g. linguas) will not work Builtins.foreach(retmap) do |key, desc| if Builtins.haskey(prod_map, key) val = Ops.get_string(prod_map, [key, 0, @content_key], "") if val != "" if merge_with_current # set the new value only when there is nothing # present in product_info[key]: # in case we are editing existing add-on product # configuration, there can be some modifications # saved, and they are preferred if Ops.get_string(retmap, [key, "value"], "") == "" Ops.set(retmap, [key, "value"], val) else # manual modifications present -> generate # this is used when product xml was read from rpm Ops.set(@current_product, "generate_release_package", true) end else Ops.set(retmap, [key, "value"], val) end end end end # ok, let's try to read at least release notes url Builtins.foreach(Ops.get_list(prod_map, ["urls", 0, "url"], [])) do |url| if Ops.get_string(url, "name", "") == "releasenotes" if !merge_with_current || Ops.get_string(retmap, ["releasenotes", "value"], "") == "" Ops.set( retmap, ["releasenotes", "value"], Ops.get_string(url, @content_key, "") ) end end end # read the product dependencies which may be in mediasets section mediamap = Ops.get_map( xml, ["productdefinition", 0, "mediasets", 0, "media", 0], {} ) Builtins.foreach(Ops.get_list(mediamap, "productdependency", [])) do |dep| key = Ops.get_string(dep, "relationship", "") if Ops.get_list(retmap, [key, "value"], []) == [] Ops.set(retmap, [key, "value"], []) end Ops.set( retmap, [key, "value"], Builtins.add( Ops.get_list(retmap, [key, "value"], []), Builtins.remove(dep, "relationship") ) ) end # flavor may be in mediasets section if !merge_with_current && Ops.get_string(retmap, ["flavor", "value"], "") == "" if Ops.get_string(mediamap, "flavor", "") != "" Ops.set( retmap, ["flavor", "value"], Ops.get_string(mediamap, "flavor", "") ) end end Builtins.y2milestone("product_info: %1", retmap) deep_copy(retmap) end |
- (Object) gzip_installed
853 854 855 856 857 858 |
# File '../../src/modules/AddOnCreator.rb', line 853 def gzip_installed if @gzip_is_installed == nil @gzip_is_installed = Package.Installed("gzip") end @gzip_is_installed end |
- (Object) Import(settings)
4082 4083 4084 4085 4086 |
# File '../../src/modules/AddOnCreator.rb', line 4082 def Import(settings) settings = deep_copy(settings) Builtins.y2warning("not implemented") false end |
- (Object) ImportExistingProduct(dir_path)
import the data from existing add-on
1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 |
# File '../../src/modules/AddOnCreator.rb', line 1397 def ImportExistingProduct(dir_path) @content = ReadContentFile(Ops.add(dir_path, "/content")) Ops.set( @current_product, "rpm_path", Builtins.sformat( "%1/%2", dir_path, Ops.get(@content_map, "DATADIR", "") ) ) # - read patterns descr_path = Builtins.sformat( "%1/%2", dir_path, Ops.get(@content_map, "DESCRDIR", "") ) out = Convert.to_map( SCR.Execute( path(".target.bash_output"), Builtins.sformat( "ls -A1 %1/*.pat %1/*.pat.gz 2>/dev/null", descr_path ) ) ) patterns = {} Builtins.foreach( Builtins.splitstring(Ops.get_string(out, "stdout", ""), "\n") ) do |f| next if f == "" Builtins.foreach(ReadPatternsFile(f)) do |pat| if pat != {} full_name = Ops.get_string(pat, "Pat", "") pt = Builtins.splitstring(full_name, " ") if full_name != "" Ops.set(pat, "name", Ops.get(pt, 0, "")) Ops.set(pat, "version", Ops.get(pt, 1, "")) Ops.set(pat, "release", Ops.get(pt, 2, "")) Ops.set(pat, "arch", Ops.get(pt, 3, "")) Ops.set(patterns, full_name, pat) end end end end Ops.set(@current_product, "patterns", patterns) if !@generate_descriptions SCR.Execute( path(".target.bash"), Builtins.sformat("/bin/rm -f %1/packages*", @tmpdir) ) # save packages* files to tmpdir, they will be imported later SCR.Execute( path(".target.bash"), Builtins.sformat("/bin/cp -- '%1/'packages* %2", descr_path, @tmpdir) ) end extra = Ops.add(descr_path, "/EXTRA_PROV") if FileUtils.Exists(extra) cont = Convert.to_string(SCR.Read(path(".target.string"), extra)) if cont != nil Ops.set(@current_product, "extra_prov", cont) Ops.set(@current_product, "extra_prov_file", extra) end end # read README Builtins.foreach(["README", "README.DOS", "LIESMICH", "LIESMICH.DOS"]) do |readme| readme_path = Ops.add(Ops.add(dir_path, "/"), readme) if FileUtils.Exists(readme_path) Builtins.y2milestone("Importing readme file '%1'", readme_path) cont = Convert.to_string( SCR.Read(path(".target.string"), readme_path) ) if cont != nil Ops.set(@current_product, ["readme_files", readme], cont) end end end # read the license files license_path = Ops.add(dir_path, "/media.1/license.zip") out = {} # license.zip is obsolete if FileUtils.Exists(license_path) SCR.Execute( path(".target.bash_output"), Builtins.sformat("/usr/bin/unzip -o %1 -d %2", license_path, @tmpdir) ) out = Convert.to_map( SCR.Execute( path(".target.bash_output"), Builtins.sformat("ls -A1 %1/license*.txt 2>/dev/null", @tmpdir) ) ) elsif FileUtils.Exists(Ops.add(dir_path, "/license.tar.gz")) SCR.Execute( path(".target.bash_output"), Builtins.sformat( "/bin/tar -zxf %1/license.tar.gz -C %2", dir_path, @tmpdir ) ) out = Convert.to_map( SCR.Execute( path(".target.bash_output"), Builtins.sformat("ls -A1 %1/license*.txt 2>/dev/null", @tmpdir) ) ) elsif FileUtils.IsDirectory(Ops.add(dir_path, "/media.1/license")) == true out = Convert.to_map( SCR.Execute( path(".target.bash_output"), Builtins.sformat( "ls -A1 %1/media.1/license/license*.txt 2>/dev/null", dir_path ) ) ) # extract license.txt from EULA.txt # (no other need to read EULA, it should be just license.txt + packages) elsif FileUtils.Exists(Ops.add(dir_path, "/EULA.txt")) SCR.Execute( path(".target.bash"), Builtins.sformat( "/bin/cp -- %1/EULA.txt %2/license.txt", dir_path, @tmpdir ) ) out = Convert.to_map( SCR.Execute( path(".target.bash_output"), Builtins.sformat("ls -A1 %1/license*.txt 2>/dev/null", @tmpdir) ) ) end if out != {} Builtins.foreach( Builtins.splitstring(Ops.get_string(out, "stdout", ""), "\n") ) do |f| next if f == "" name = Builtins.substring(f, Ops.add(Builtins.findlastof(f, "/"), 1)) if Builtins.issubstring(name, ".txt") name = Builtins.regexpsub(name, "^(.*).txt$", "\\1") end Builtins.y2milestone("Importing license file '%1'", f) cont = Convert.to_string(SCR.Read(path(".target.string"), f)) if cont != nil Ops.set(@current_product, ["license_files", name], cont) end end end out = Convert.to_map( SCR.Execute( path(".target.bash_output"), Builtins.sformat("ls -A1 %1/COPYING* 2>/dev/null", dir_path) ) ) Builtins.foreach( Builtins.splitstring(Ops.get_string(out, "stdout", ""), "\n") ) do |f| next if f == "" name = Builtins.substring(f, Ops.add(Builtins.findlastof(f, "/"), 1)) Builtins.y2milestone("Importing COPYING file '%1'", f) cont = Convert.to_string(SCR.Read(path(".target.string"), f)) Ops.set(@current_product, ["copying_files", name], cont) if cont != nil end out = Convert.to_map( SCR.Execute( path(".target.bash_output"), Builtins.sformat("ls -A1 %1/COPYRIGHT* 2>/dev/null", dir_path) ) ) Builtins.foreach( Builtins.splitstring(Ops.get_string(out, "stdout", ""), "\n") ) do |f| next if f == "" name = Builtins.substring(f, Ops.add(Builtins.findlastof(f, "/"), 1)) Builtins.y2milestone("Importing COPYRIGHT file '%1'", f) cont = Convert.to_string(SCR.Read(path(".target.string"), f)) if cont != nil Ops.set(@current_product, ["copyright_files", name], cont) end end # read the info.txt info_path = Ops.add(dir_path, "/media.1/info.txt") if FileUtils.Exists(info_path) info = Convert.to_string(SCR.Read(path(".target.string"), info_path)) info = "" if info == nil Ops.set(@current_product, "info", info) end # read the content of media.n dirs out = Convert.to_map( SCR.Execute( path(".target.bash_output"), Builtins.sformat("ls -A1 -d %1/media.* 2>/dev/null", dir_path) ) ) if Ops.get_string(out, "stdout", "") != "" products_files = [] media_files = [] patches_files = [] Builtins.foreach( Builtins.splitstring(Ops.get_string(out, "stdout", ""), "\n") ) do |d| next if d == "" products_path = Ops.add(d, "/products") if FileUtils.Exists(products_path) Builtins.y2milestone("Importing products file '%1'", products_path) products_files = Builtins.add( products_files, Convert.to_string(SCR.Read(path(".target.string"), products_path)) ) else products_files = Builtins.add(products_files, "") end media_path = Ops.add(d, "/media") if FileUtils.Exists(media_path) Builtins.y2milestone("Importing media file '%1'", media_path) media_files = Builtins.add( media_files, Convert.to_string(SCR.Read(path(".target.string"), media_path)) ) else media_files = Builtins.add(media_files, "") end patches_path = Ops.add(d, "/patches") if FileUtils.Exists(patches_path) Builtins.y2milestone("Importing patches file '%1'", patches_path) patches_files = Builtins.add( patches_files, Convert.to_string(SCR.Read(path(".target.string"), patches_path)) ) else patches_files = Builtins.add(patches_files, "") end end Ops.set(@current_product, "products_files", products_files) Ops.set(@current_product, "media_files", media_files) Ops.set(@current_product, "patches_files", patches_files) end desc_path = Ops.add(dir_path, "/installation.xml") if FileUtils.Exists(desc_path) Ops.set(@current_product, "workflow_path", desc_path) end workflow_packages_path = Ops.add(dir_path, "/y2update.tgz") if FileUtils.Exists(workflow_packages_path) Ops.set(@current_product, "y2update_path", workflow_packages_path) end true end |
- (Object) main
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 |
# File '../../src/modules/AddOnCreator.rb', line 35 def main Yast.import "UI" textdomain "add-on-creator" Yast.import "Arch" Yast.import "Directory" Yast.import "FileUtils" Yast.import "Label" Yast.import "Mode" Yast.import "Package" Yast.import "PackageSystem" Yast.import "PackagesDescr" Yast.import "Progress" Yast.import "Report" Yast.import "String" # where the configurations are stored @add_on_products_file = Ops.add(Directory.vardir, "/add_on_products.ycp") # list of all configured AddOn products @add_on_products = [] # map of the Add-On product currently in use @current_product = { # path to output directory "base_output_path" => "", # path to directory with RPM's "rpm_path" => nil, # path to directory with RPM's, used only for building patterns # and not present on AddOn "required_rpm_path" => "", # map of patterns for current product "patterns" => {}, # description of packages (initially generated by create_package_descr "packages_descr" => {}, # the contents of products files "products_files" => [], # the contents of media files "media_files" => [], # the contents of patches files "patches_files" => [], # the contents of info.txt file "info" => "", # content of readme files "readme_files" => { "README" => "" }, # content of license files (in media.1 dir) "license_files" => { "license" => "" }, "copying_files" => { "COPYING" => "" }, "copyright_files" => { "COPYRIGHT" => "" }, # the contents of EXTRA_PROV file "extra_prov" => "", # path to the file with EXTRA_PROV data "extra_prov_file" => "", # the contents of nextmedia file "nextmedia" => "", # paths with packages to be archived in y2update.tgz "y2update_packages" => [], # path with y2update.tgz (alternative to y2update_packages) "y2update_path" => "", # path to file with installation workflow (installation.xml) "workflow_path" => "", # if iso image should be created from the final Add-On "iso" => false, # where the iso image should be put "iso_path" => "", # name of the iso image file "iso_name" => "", # also sign all rpm's (see bug #287447) "resign_packages" => false, # current GPG key "gpg_key" => "", # if we should generate -release package containing .prod file "generate_release_package" => true } # skeleton for current_product map (with keys and default values) @current_product_skel = deep_copy(@current_product) @selected_product = -1 # variables from content file + their description @content = [] @allowed_archs = [ "ppc", "ppc64", "ia64", "x86_64", "i686", "i586", "i486", "i386", "noarch" ] @content_descr = { "CONTENTSTYLE" => { "key" => "CONTENTSTYLE", # label of content file key "label" => _("Content file style"), # help text for content file CONTENTSTYLE key "help" => _( "Must be the first tag of the content file." ), "value" => "11", "mandatory" => true }, "NAME" => { "key" => "NAME", # label of content file key "label" => _("Product name"), # help text for content file 'NAME' key "help" => _( "For internal usage. Same restrictions as for package names apply." ), "mandatory" => true }, "BASEARCHS" => { "key" => "BASEARCHS", # label of content file BASEARCHS key "label" => _( "Product architectures" ), # help text for content file 'BASEARCHS' key "help" => _( "Space-separated list of product architectures. Matches the available product-release packages architectures. " ), "mandatory" => true }, "VERSION" => { "key" => "VERSION", # label of content file 'VERSION' key "label" => _( "Product version and release" ), # help text for content file 'VERSION' key "help" => _( "Product version and release as in RPM <tt>major.minor-release</tt>." ), "value" => "1", "mandatory" => true }, "RELEASE" => { "key" => "RELEASE", # table item label "label" => _("Release number"), "value" => "0", "mandatory" => true }, "DISTRIBUTION" => { "key" => "DISTRIBUTION", # label of content file key "label" => _("Distribution name"), # help text for content file 'DISTRIBUTION' key "help" => _( "Some string denoting the distribution. The same string is most probably used in the .rpms to denote the distribution. Usually a composition of the name, version and architecture." ) }, "DESCRDIR" => { "key" => "DESCRDIR", # label of content file key "label" => _( "Package description directory" ), "value" => "suse/setup/descr", # help text for content file 'DESCRDIR' key "help" => _( "Package description directory (relative to product directory)." ), "mandatory" => true }, "DATADIR" => { "key" => "DATADIR", # label of content file key "label" => _("Package data directory"), # help text for content file 'DATADIR' key "help" => _( "Package data directory (relative to product directory)." ), "value" => "suse", "mandatory" => true }, "LABEL" => { "key" => "LABEL", # label of content file key "label" => _("Label"), # help text for content file '' key "help" => _( "UTF-8 encoded label. Default label if <b>LINGUAS</b> is omitted or no default language can be determined." ) }, "LINGUAS" => { "key" => "LINGUAS", # label of content file 'LINGUAS' key "label" => _("Languages"), # help text for content file 'LINGUAS' key "help" => _( "ISO language code or language code_country code." ) }, "LANGUAGE" => { "key" => "LANGUAGE", # label of content file 'LANGUAGE' key "label" => _( "Default language" ), # help text for content file 'LANGUAGE' key "help" => _( "Default language code." ), "type" => "combo", "allowed_values" => nil }, "PATTERNS" => { "key" => "PATTERNS", # label of content file 'PATTERNS' key "label" => _( "Preselected patterns" ), # help text for content file 'PATTERNS' key "help" => _( "List of patterns preselected by the product." ) }, "VENDOR" => { "key" => "VENDOR", # label of content file key "label" => _("Vendor name"), # help text for content file 'VENDOR' key "help" => _( "Vendor name (free form)." ), "mandatory" => true }, "RELNOTESURL" => { "key" => "RELNOTESURL", # label of content file 'RELNOTESURL' key "label" => _( "Release notes URL" ), # help text for content file 'RELNOTESURL' key "help" => _( "URL from which to fetch release notes." ) }, "UPDATEURLS" => { "key" => "UPDATEURLS", # label of content file 'UPDATEURLS' key "label" => _("Update URL"), # help text for content file 'UPDATEURLS' key "help" => _( "URL of the update source." ) } } # skeletons for special keys in content file @content_specials = { "LABEL" => { # label of content file LABEL.lang key "label" => _( "Language-specific label" ), # help text for content file 'LABEL.lang' key "help" => _( "UTF-8-encoded <b>LABEL</b>. <tt>lang</tt> has the same syntax as the <b>LINGUAS</b> values. For each language in <b>LINGUAS</b>, a matching <b>LABEL.lang</b> is expected." ), "helplabel" => "LABEL.lang" } } # desctiption of pattern keys @pattern_descr = { "name" => { "internal" => true }, "version" => { "label" => _("Version"), "internal" => true, "adapt_name" => true, "defval" => "1.0" }, "release" => { "label" => _("Release"), "internal" => true, "adapt_name" => true, "defval" => "1" }, "arch" => { "label" => _("Architecture"), "internal" => true, "type" => "combo", "allowed_values" => @allowed_archs, "adapt_name" => true, "defval" => "noarch" }, "Pat" => { "single_line" => true }, "Ver" => { "defval" => "5.0", "single_line" => true }, "Sum" => { "label" => _("Summary"), # help text for 'Sum' pattern key "help" => _( "One line label in the default language" ), # help text for 'Sum.lang' pattern key "lang_help" => _( "One line language-specific label." ), "single_line" => true }, "Des" => { # label for 'Des' pattern key "label" => _("Description"), "type" => "multiline", # help text for 'Des' pattern key "help" => _( "Multiple line description in the default language" ), # help text for 'Des.lang' pattern key "lang_help" => _( "Multiple line description, language-specific." ) }, "Cat" => { # label for 'Cat' pattern key "label" => _("Category"), # help text for 'Cat' pattern key "help" => _( "One line category in the default language used to group patterns. Categories are intended for the user and can be specified freely." ), # help text for 'Cat.lang' pattern key "lang_help" => _( "Language-specific version of the category." ), "single_line" => true }, "Vis" => { # label for 'Vis' pattern key "label" => _("Visibility"), # help text for 'Vis' pattern key "help" => _( "Set whether the pattern should be visible in the user interface." ), "type" => "boolean", "defval" => true, "single_line" => true }, "Prq" => { # label for 'Prq' pattern key "label" => _("Packages"), # help text for 'Prq' pattern key "help" => _( "List of packages to install." ), "type" => "package-list", "defval" => [] }, "Prc" => { # label for 'Prc' pattern key "label" => _("Recommended packages"), # help text for 'Prc' pattern key "help" => _( "These packages are installed by default but can be removed without complaint." ), "type" => "package-list", "defval" => [] }, "Psg" => { # label for 'Prs' pattern key "label" => _("Suggested packages"), # help text for 'Prs' pattern key "help" => _( "These are just hints for an application and not handled during dependency resolution." ), "type" => "package-list", "defval" => [] }, "Ico" => { # label for 'Ico' pattern key "label" => _("Icon filename"), # help text for 'Ico' pattern key "help" => _( "If unspecified, the pattern name is used \n instead (with blanks in the name replaced by underscores). If the filename does not include a .png or .jpg extension, .png is appended. If no path is specified, icons are searched for in the theme icon path (first /usr/share/YaST2/theme/current/icons/32x32/apps/ then /usr/share/YaST2/theme/current/icons/48x48/apps/). Absolute and relative paths (to the theme path /usr/share/YaST2/theme/current/) are allowed." ), "type" => "file-name", "defval" => "", "single_line" => true }, "Ord" => { # label for 'Ord' pattern key "label" => _("Pattern Order"), # help text for 'Ord' pattern key "help" => _( "This three-digit integer value defines the order of the pattern when listing multiple patterns in the user interface." ), "defval" => "", "single_line" => true, "type" => "integer", "range" => [100, 9999] }, "Req" => { # label for 'Req' pattern key "label" => _("Required patterns"), # help text for 'Req' pattern key "help" => _( "Patterns that need to be installed together with this pattern." ), "defval" => "", "type" => "pattern-list" }, "Prv" => { # label for 'Prv' pattern key "label" => _("Provided patterns"), # help text for 'Prv' pattern key "help" => _( "Capabilities this pattern provides. They can be used to match <b>REQUIRES</b> from others. Every resolvable has a provide by default--its own name and edition. For example, package <i>bar-1.42-1</i> provides the capability <tt>bar = 1.42-1</tt>." ), "defval" => "", "type" => "pattern-list" }, "Con" => { # label for 'Con' pattern key "label" => _("Conflicting patterns"), # help text for 'Con' pattern key "help" => _( "This pattern cannot be installed if the specified resolvable or one that provides the capability is installed." ), "defval" => "", "type" => "pattern-list" }, "Obs" => { # label for 'Obs' pattern key "label" => _("Patterns made obsolete"), # help text for 'Obs' pattern key "help" => _( "When this pattern is installed, it uninstalls any \nother patterns marked as obsolete here." ), "defval" => "", "type" => "pattern-list" }, "Rec" => { # label for 'Rec' pattern key "label" => _("Recommended patterns"), # help text for 'Rec' pattern key "help" => _( "A weak version of REQUIRES. If recommended patterns cannot be installed, no error is shown." ), "defval" => "", "type" => "pattern-list" }, "Sup" => { # label for 'Sup' pattern key "label" => _("Supplemented patterns"), # help text for 'Sup' pattern key "help" => _( "A reverse <b>Rec</b>. This pattern is installed if the specified capability is provided by an installed resolvable. The dependency resolver installs it. Uninstalling it is silently accepted." ), "defval" => "", "type" => "pattern-list" }, "Sug" => { # label for 'Sug' pattern key "label" => _("Suggested patterns"), # help text for 'Sug' pattern key "help" => _( "These are just hints for an application and not handled during dependency resolution." ), "defval" => "", "type" => "pattern-list" }, "Fre" => { # label for 'Fre' pattern key "label" => _("Freshen"), # help text for 'Fre' pattern key "help" => _( "The current pattern is only considered for installation if the pattern specified here is installed." ), "defval" => "", "type" => "pattern-list" }, # TODO during editing, remove from Prc and Prs packages contained in Prq # TODO add some key for sorting, so output file is readable "Ext" => { # label for 'Ext' pattern key "label" => _("Extends"), "defval" => "", "type" => "pattern-list" }, "Inc" => { # label for 'Inc' pattern key "label" => _("Includes"), "defval" => "", "type" => "pattern-list" }, "Enh" => { # label for 'Exnh pattern key "label" => _("Enhanced patterns"), "defval" => "", "type" => "pattern-list" }, "Pcn" => { # label for 'Pcn' pattern key "label" => _("Conflicting packages"), "type" => "package-list", "defval" => [] }, "Pob" => { # label for 'Pob' pattern key "label" => _("Obsolete packages"), "type" => "package-list", "defval" => [] }, "Pfr" => { # label for 'Pfr' pattern key "label" => _("Freshened packages"), "type" => "package-list", "defval" => [] }, "Psp" => { # label for 'Psp' pattern key "label" => _("Supplemented packages"), "type" => "package-list", "defval" => [] }, "Pen" => { # label for 'Pen' pattern key "label" => _("Enhanced packages"), "type" => "package-list", "defval" => [] } } # description of keys in package description files @description_descr = { "Pkg" => { # label for 'Pkg' key "label" => _("Package") }, "Des" => { # label for 'Des' key "label" => _("Description"), # help text for 'Des' key "help" => _( "Multiple line package description." ), "type" => "multiline", "defval" => "-" }, "Sum" => { # label for 'Sum' key "label" => _("Summary"), # help text for 'Sum' key "help" => _( "The package summary (label), a one line description of the package." ), "single_line" => true, "defval" => "-" }, "Ins" => { # label for 'Ins' key "label" => _("Installation Notification"), # help text for 'Ins' key "help" => _( "An informal message shown to the user if the package is selected, such as a test version warning or a commercial license." ), "type" => "multiline" }, "Del" => { # label for 'Del' key "label" => _("Deletion Notification"), # help text for 'Del' key "help" => _( "An informal message shown to the user if the package is selected for deletion, such as a warning that the system is unusable without the package." ), "type" => "multiline" }, "Eul" => { # label for 'Eul' key "label" => _("EULA"), # help text for 'Eul' key "help" => _( "Text of the EULA. This text is displayed before the package installation. If the user does not accept the EULA, the package is not installed." ), "type" => "multiline" } } # script used for signing rpm's @expect_script = "#!/usr/bin/expect --\n" + "exp_internal 0\n" + "\n" + "set stat 0\n" + "foreach rpm $argv {\n" + " spawn -noecho rpm --delsign $rpm\n" + " expect {\n" + "\teof {}\n" + " }\n" + " spawn -noecho rpm --define \"_signature gpg\" --define \"_gpg_name %1\" --define \"_gpgbin /usr/bin/gpg\" --resign $rpm\n" + " expect \"pass phrase:\" {send \"%2\r\"}\n" + " expect {\n" + "\t\"is good.\" {send \"\n" + "\"}\n" + "\teof {}\n" + " }\n" + " wait\n" + " spawn -noecho rpm --define \"_signature gpg\" --define \"_gpg_name %1\" --define \"_gpgbin /usr/bin/gpg\" --checksig $rpm\n" + " expect {\n" + "\t-re \": .*(gpg|pgp).*OK\" {continue;}\n" + "\teof {set stat 1;}\n" + " }\n" + "}\n" + "exit $stat" # just key:value mapping based on content list @content_map = {} # info for product.xml @product_info_descr = { "requires" => { "key" => "requires", # label of key "label" => _("Products that must be installed"), # help text for 'REQUIRES' key "help" => _( "<p>Resolvables that must be installed on the system to meet product requirements.</p>" ), "type" => "dependency" }, "provides" => { "key" => "provides", # label of PROVIDES key "label" => _("Provided products"), # help text for 'PROVIDES' key "help" => _( "Capabilities this product provides. They can be used to match <b>requires</b> from others." ), "type" => "dependency" }, "conflicts" => { "key" => "conflicts", # label of 'CONFLICTS' key "label" => _("Conflicting products"), # help text for 'CONFLICTS' key "help" => _( "This resolvable cannot be installed if the specified resolvable or one that provides the capability is installed." ), "type" => "dependency" }, "obsoletes" => { "key" => "obsoletes", # label of 'OBSOLETES' key "label" => _("Products made obsolete"), # help text for 'OBSOLETES' key "help" => _( "When this resolvable is installed, it uninstalls any other resolvable with a name matching this keyword." ), "type" => "dependency" }, "recommends" => { "key" => "recommends", # label of 'RECOMMENDS' key "label" => _("Recommended products"), # help text for 'RECOMMENDS' key "help" => _( "A weak version of <b>requires</b>. An attempt is made to fulfill <b>RECOMMENDS</b>, but they are silently ignored if no match is possible." ), "type" => "dependency" }, "suggests" => { "key" => "suggests", # label of 'SUGGESTS' key "label" => _("Suggested products"), # help text for 'SUGGESTS' key "help" => _( "These are just hints for an application and not handled during dependency resolution." ), "type" => "dependency" }, "release" => { "key" => "release", # table item label "label" => _("Release number") }, "releasenotes" => { "key" => "releasenotes", # table item label "label" => _("The URL for release notes RPM") }, "description" => { "key" => "description", # table item label "label" => _("Product description") }, "patchlevel" => { "key" => "patchlevel", # table item label "label" => _("Patch level") }, "summary" => { "key" => "summary", # table item label "label" => _("Product summary") }, "productline" => { "key" => "productline", # table item label "label" => _("Product line"), # help text for 'productline' key "help" => _( "A short name for the product, which does not change between service packs and versions." ) }, "updaterepokey" => { "key" => "updaterepokey", # table item label "label" => _("Update repository key") }, "media type" => { "key" => "media type", # table item label "label" => _("Type of media"), # help text for media type "help" => _( "Type of media that will be used for target product. Possible values are: cd, ftp, dvd5, dvd9." ) }, "flavor" => { "key" => "flavor", # table item label "label" => _("Product flavor"), # help text for media type "help" => _( "Description of the flavor or variant of a product, e.g. DVD, FTP, Live" ) } } # save the structure of product_info, but not the values @product_info = {} # the content of .prod file, as read using any_xml agent @product_xml = {} # if we have 'source add-on' to base the new one on @clone = false # path to directory with existing product (which is being cloned) @import_path = "" # if the descriptions of packages should be generated # (false have only sense when cloning where they could be read from # description files of cloned product) @generate_descriptions = false # if final Add-On should be bootable (feature not implemented) @bootable = false # tmp directory @tmpdir = "" # full paths to media directories (media.n) @full_media_paths = [] # architecture specific directory names of target product @arch_directories = [] # full path to descr directory @full_descr_path = "" # full path to data directory @full_data_path = "" # current GPG key #global string gpg_key = ""; # passphrases to unlock secret key (mapping GPG key:pass) @passphrases = {} @gpg_keys = [] # packages from current AddOn available for the pattern @available_packages = {} # mapping of package name to full file name @package2filename = {} # mapping of source package name to full file name @srcpackage2filename = {} # if we want only to sign existing product (and possibly create iso of it) @only_sign_product = false # if pattern files should be compressed @compress_patterns = false # if pattern definitions should be merged into one file TODO @merge_patterns = false # if package description files should be compressed @compress_package_descriptions = false # Data was modified? @modified = false @gzip_is_installed = nil @lang_codes = { "languages" => nil, "with_country" => nil } # argument for any_xml agent: key indicating content of element without # attributes @content_key = "__yast_content__" end |
- (Object) Modified
Data was modified?
862 863 864 865 |
# File '../../src/modules/AddOnCreator.rb', line 862 def Modified Builtins.y2debug("modified=%1", @modified) @modified end |
- (Object) PrepareBuild
prepare the data of current product for a build (neccessary because input packages could get changed)
3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 |
# File '../../src/modules/AddOnCreator.rb', line 3840 def PrepareBuild if !Ops.get_boolean(@current_product, "generated", false) FillContentDefaults() # TODO not everything generated by FillContentDefaults is needed? end key = Ops.get_string(@current_product, "gpg_key", "") if Ops.get_boolean(@current_product, "ask_for_passphrase", false) && key != "" && Ops.get_string(@passphrases, key, "") == "" && !Mode.commandline name = GetKeyUID(key) # ask for pw now %1 is key id, %2 user name Ops.set( @passphrases, key, AskForPassphrase( Builtins.sformat( _("Enter passphrase for GPG key %1\n(%2)"), key, name ), false ) ) end nil end |
- (Object) Read
Initialize the settings for add-on-creator
1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 |
# File '../../src/modules/AddOnCreator.rb', line 1110 def Read if !PackageSystem.CheckAndInstallPackagesInteractive( ["inst-source-utils"] ) return false end @gpg_keys = read_secret_keys out = Convert.to_map( SCR.Execute(path(".target.bash_output"), "/usr/bin/id --user") ) if Ops.get_string(out, "stdout", "") != "0\n" && Ops.get_string(out, "stdout", "") != "" out = Convert.to_map( SCR.Execute(path(".target.bash_output"), "echo $HOME") ) home = Builtins.getenv("HOME") if home != "" && home != nil @add_on_products_file = Ops.add(home, "/add_on_products.ycp") end end # Read the info of configured AddOns if FileUtils.Exists(@add_on_products_file) all_products = Convert.convert( SCR.Read(path(".target.ycp"), @add_on_products_file), :from => "any", :to => "list <map>" ) @add_on_products = deep_copy(all_products) if all_products != nil else Ops.set(@current_product, "gpg_key", Ops.get(@gpg_keys, 0, "")) end # fill uninitialized values in content descriptions i = 0 Builtins.foreach(@content_descr) do |key, entry| if Ops.get(entry, "allowed_values") == nil # TODO add a handlers for filling the values if key == "LANGUAGE" Ops.set(@content_descr, [key, "allowed_values"], GetLangCodes(true)) else Ops.set(@content_descr, [key, "allowed_values"], []) end end if key == "DEFAULTBASE" Ops.set(@content_descr, [key, "value"], Arch.architecture) end defval = Convert.to_string( SCR.Read(Builtins.add(path(".sysconfig.add-on-creator"), key)) ) if defval != nil && defval != "" Builtins.y2milestone("using default value for %1: %2", key, defval) Ops.set(@content_descr, [key, "value"], defval) end i = Ops.add(i, 1) end @tmpdir = Directory.tmpdir if SCR.Read(path(".sysconfig.add-on-creator.COMPRESS_PATTERNS")) == "yes" @compress_patterns = true end if SCR.Read( path(".sysconfig.add-on-creator.COMPRESS_PACKAGE_DESCRIPTIONS") ) == "yes" @compress_package_descriptions = true end if @product_xml == {} # read the template file @product_xml = ReadProductXML( Ops.add(Directory.datadir, "/add-on-creator/template.prod") ) end # fill the inital values @product_info = deep_copy(@product_info_descr) true end |
- (Object) read_secret_keys
read the list of available secret keys
1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 |
# File '../../src/modules/AddOnCreator.rb', line 1060 def read_secret_keys out = Convert.to_map( SCR.Execute( path(".target.bash_output"), "gpg --list-secret-keys|grep '^sec'|sed -e 's/.*\\///;s/ .*//g;'" ) ) Builtins.filter( Builtins.splitstring(Ops.get_string(out, "stdout", ""), "\n") ) { |k| k != "" } end |
- (Object) ReadContentFile(file_path)
read the content file given by file name
1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 |
# File '../../src/modules/AddOnCreator.rb', line 1194 def ReadContentFile(file_path) ret = [] Builtins.y2milestone("Importing content file '%1'", file_path) SCR.RegisterAgent( path(".content"), term( :ag_ini, term( :IniAgent, file_path, { "options" => ["global_values", "flat"], "comments" => ["^#.*", "^[ \t]*$"], "params" => [ { "match" => [ "^[ \t]*([a-zA-Z0-9_.]+)[ \t]+(.*[^ \t]|)[ \t]*$", "%s %s" ] } ] } ) ) ) keys = SCR.Dir(path(".content")) Builtins.foreach(keys) do |key| val = Convert.to_string(SCR.Read(Builtins.add(path(".content"), key))) next if val == nil entry = Ops.get(@content_descr, key, {}) if entry == {} && Builtins.issubstring(key, ".") entry = Ops.get_map( @content_specials, Builtins.substring(key, 0, Builtins.findfirstof(key, ".")), {} ) end if entry != {} Ops.set(entry, "key", key) Ops.set(entry, "value", val) ret = Builtins.add(ret, entry) Ops.set(@content_map, key, val) end end SCR.UnregisterAgent(path(".content")) # + fill the rest Builtins.foreach(@content_descr) do |key, entry| ret = Builtins.add(ret, entry) if !Builtins.contains(keys, key) end deep_copy(ret) end |
- (Object) ReadPackagesFile(file_path)
read the package description (package.lang) file
1389 1390 1391 1392 1393 |
# File '../../src/modules/AddOnCreator.rb', line 1389 def ReadPackagesFile(file_path) Builtins.y2milestone("Importing package description '%1'", file_path) PackagesDescr.Read(uncompress_file(file_path)) end |
- (Object) ReadPatternFile(file_path)
read the pattern given by file name (obsolete, use ReadPatternsFile instead)
1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 |
# File '../../src/modules/AddOnCreator.rb', line 1291 def ReadPatternFile(file_path) Builtins.y2milestone("Importing pattern '%1'", file_path) file_path = uncompress_file(file_path) ret = {} pt = Convert.to_map(SCR.Read(path(".pattern"), file_path)) Builtins.foreach( Convert.convert(pt, :from => "map", :to => "map <string, any>") ) do |key, val| if Ops.get_string(@pattern_descr, [key, "type"], "") == "package-list" Ops.set( ret, key, Builtins.splitstring(Builtins.sformat("%1", val), "\n") ) # make the packages included in imported pattern available for UI Ops.set( @available_packages, "ZZZ_imported", Builtins.union( Ops.get(@available_packages, "ZZZ_imported", []), Ops.get_list(ret, key, []) ) ) else Ops.set(ret, key, val) end end Builtins.foreach(@pattern_descr) do |key, descr| if !Builtins.haskey(ret, key) && !Ops.get_boolean(descr, "internal", false) Builtins.y2debug("adding empty key '%1'...", key) # do not add default values - maybe imported pattern # ignored them intentionally Ops.set(ret, key, "") end end deep_copy(ret) end |
- (Array) ReadPatternsFile(file_path)
read all the patterns defined in given file
1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 |
# File '../../src/modules/AddOnCreator.rb', line 1334 def ReadPatternsFile(file_path) Builtins.y2milestone("Importing pattern '%1'", file_path) file_path = uncompress_file(file_path) retlist = [] pts = Convert.convert( SCR.Read(path(".pattern.list"), file_path), :from => "any", :to => "list <map>" ) Builtins.foreach(pts) do |pt| ret = {} Builtins.foreach( Convert.convert(pt, :from => "map", :to => "map <string, any>") ) do |key, val| if Ops.get_string(@pattern_descr, [key, "type"], "") == "package-list" Ops.set( ret, key, Builtins.splitstring(Builtins.sformat("%1", val), "\n") ) # make the packages included in pattern available for UI Ops.set( @available_packages, "ZZZ_imported", Builtins.union( Ops.get(@available_packages, "ZZZ_imported", []), Ops.get_list(ret, key, []) ) ) else Ops.set(ret, key, val) end end # add empty values for keys not present in imported pattern Builtins.foreach(@pattern_descr) do |key, descr| if !Builtins.haskey(ret, key) && !Ops.get_boolean(descr, "internal", false) Builtins.y2debug("adding empty key '%1'...", key) # do not add default values - maybe imported pattern # ignored them intentionally if Ops.get_string(@pattern_descr, [key, "type"], "") == "package-list" Ops.set(ret, key, []) else Ops.set(ret, key, "") end end end retlist = Builtins.add(retlist, ret) if ret != {} end deep_copy(retlist) end |
- (Object) ReadProductXML(prod_file_path)
import the data from given xml file
871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 |
# File '../../src/modules/AddOnCreator.rb', line 871 def ReadProductXML(prod_file_path) ret = {} if !FileUtils.Exists(prod_file_path) Builtins.y2warning("no such file %1", prod_file_path) return deep_copy(ret) end # read rest of config.xml using more generic agent anyxml = Convert.to_map( SCR.Read( path(".anyxml"), { "file" => prod_file_path, "args" => { "ForceArray" => 1, "KeepRoot" => 1, "KeyAttr" => [], "ForceContent" => 1, "ContentKey" => @content_key } } ) ) ret = Convert.convert(anyxml, :from => "map", :to => "map <string, any>") deep_copy(ret) end |
- (Object) ResetCurrentProduct
Reset all settings related to current product
3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 |
# File '../../src/modules/AddOnCreator.rb', line 3690 def ResetCurrentProduct @current_product = deep_copy(@current_product_skel) @generate_descriptions = false @clone = false @available_packages = {} @package2filename = {} @srcpackage2filename = {} # TODO move into current_product as well? @content = [] @content_map = {} # reset global variables, that are generated for each product @full_media_paths = [] @full_descr_path = "" @full_data_path = "" nil end |
- (Object) SelectProduct(product)
select the given product: fill in the global variables specific for the given product
3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 |
# File '../../src/modules/AddOnCreator.rb', line 3757 def SelectProduct(product) product = deep_copy(product) @current_product = deep_copy(product) @content_map = Ops.get_map(product, "content_map", {}) product_info_values = Ops.get_map(product, "product_info_values", {}) Builtins.foreach(@product_info_descr) do |key, desc| if Ops.get(product_info_values, [key, "value"]) != nil Ops.set(desc, "value", Ops.get(product_info_values, [key, "value"])) end Ops.set(@product_info, key, desc) end # generate content from content_map @content = [] Builtins.foreach(@content_descr) do |key, entry| if Ops.get(@content_map, key, "") != "" Ops.set(entry, "value", Ops.get(@content_map, key, "")) end @content = Builtins.add(@content, entry) end Builtins.foreach(@content_map) do |key, val| if !Builtins.haskey(@content_descr, key) && Builtins.issubstring(key, ".") Builtins.y2debug("key %1 not in descr", key) entry = Ops.get_map( @content_specials, Builtins.substring(key, 0, Builtins.findfirstof(key, ".")), {} ) Ops.set(entry, "key", key) Ops.set(entry, "value", val) @content = Builtins.add(@content, entry) end end @available_packages = Ops.get_map(product, "available_packages", {}) @arch_directories = Ops.get_list(product, "arch_directories", []) @package2filename = Ops.get_map(product, "package2filename", {}) @srcpackage2filename = Ops.get_map(product, "srcpackage2filename", {}) nil end |
- (Object) SignAddOn(base_path, key)
Sign current Add-On product
3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 |
# File '../../src/modules/AddOnCreator.rb', line 3343 def SignAddOn(base_path, key) passphrase = Ops.get_string(@passphrases, key, "") if key == "" || passphrase == "" Builtins.y2warning( "No GPG key or passphrase provided - signing skipped" ) return true end command = Builtins.sformat( "gpg --list-secret-keys %1|grep '^sec'|sed -e 's/.*\\///;s/ .*//g;'|head -n 1", key ) out = Convert.to_map( SCR.Execute(path(".target.bash_output"), command, { "LANG" => "C" }) ) local_key = Builtins.deletechars(Ops.get_string(out, "stdout", "0"), "\n") # see /usr/share/doc/packages/gpg2/DETAILS for gpg --list-secret-keys --with-colons # file name of exported key: keyid-creation date of the selfsignature (ie. e85fc3fc-4c1b74be) out = Convert.to_map( SCR.Execute( path(".target.bash_output"), Builtins.sformat( "gpg --list-secret-keys --with-colons %1| grep %2 | gawk -F: '{print $6}'", key, local_key ) ) ) creation_date = Builtins.tointeger( Builtins.deletechars(Ops.get_string(out, "stdout", "0"), "\n") ) creation_date_s = Builtins.substring( Builtins.tohexstring(creation_date), 2 ) # use hex string without leading 0x # save the passphrase pw_path = Ops.add(@tmpdir, "/pw") SCR.Write(path(".target.string"), pw_path, passphrase) # export the key: command = Builtins.sformat( "gpg --export -a %1 > '%2/gpg-pubkey-%1-%3.asc'", Builtins.tolower(local_key), base_path, creation_date_s ) SCR.Execute(path(".target.bash"), command, { "LANG" => "C" }) # make a sha1 sum of that key (content file is modified last time) out = Convert.to_map( SCR.Execute( path(".target.bash_output"), Builtins.sformat("cd '%1'; ls -A1 gpg-pubkey*", base_path) ) ) Builtins.foreach( Builtins.splitstring(Ops.get_string(out, "stdout", ""), "\n") ) do |file| next if file == "" out = Convert.to_map( SCR.Execute( path(".target.bash_output"), Builtins.sformat( "cd '%1' && sha1sum -- %2", base_path, String.Quote(file) ), { "LANG" => "C" } ) ) command2 = Builtins.sformat( "echo 'KEY SHA1 %1' >> '%2/content'", Builtins.deletechars(Ops.get_string(out, "stdout", ""), "\n"), base_path ) SCR.Execute(path(".target.bash"), command2, { "LANG" => "C" }) end Builtins.y2milestone("signing content file...") while true # sign the content file SCR.Execute( path(".target.bash"), Builtins.sformat("rm -f '%1/content.asc'", base_path) ) out = Convert.to_map( SCR.Execute( path(".target.bash_output"), Builtins.sformat( "gpg --batch --no-tty --passphrase-fd 0 --detach-sign -u %1 -a '%2/content' < %3", local_key, base_path, pw_path ) ) ) if Ops.get_integer(out, "exit", 0) != 0 if Mode.commandline Report.Error(Ops.get_string(out, "stderr", "")) else passphrase = AskForPassphrase( Ops.get_string(out, "stderr", ""), true ) if passphrase != nil SCR.Write(path(".target.string"), pw_path, passphrase) next end end SCR.Execute(path(".target.remove"), pw_path) Builtins.y2milestone("correct passphrase not provided") return false else break end end Builtins.y2milestone("... done") SCR.Execute( path(".target.bash"), Builtins.sformat( "gpg --export -a %1 > '%2/content.key'", local_key, base_path ) ) # sign the packages if Ops.get_boolean(@current_product, "resign_packages", false) Builtins.y2milestone("signing the packages...") expect = Ops.add(@tmpdir, "/sign.ex") SCR.Write( path(".target.string"), expect, Builtins.sformat(@expect_script, key, passphrase) ) dirs = Builtins.maplist(@arch_directories) do |arch_dir| Ops.add(Ops.add(@full_data_path, "/"), arch_dir) end Builtins.foreach(dirs) do |full_path| if dir_has_files(full_path) cmd2 = Builtins.sformat( "LANG=C expect %1 %2/*.rpm", expect, full_path ) out = Convert.to_map(SCR.Execute(path(".target.bash_output"), cmd2)) end end Builtins.y2milestone("... done") SCR.Execute(path(".target.bash"), Builtins.sformat("rm %1", expect)) # after signing packages checksums have been changed: # run create_package_descr again and take new 'packages' file Builtins.y2milestone("updating packages descriptions...") cmd = Builtins.sformat( "/usr/bin/create_package_descr -d %1 -C -F -o %2", @full_data_path, @tmpdir ) if SCR.Execute(path(".target.bash"), cmd, { "LANG" => "C" }) == 0 cmd = Builtins.sformat( "/bin/cp -- %1/packages '%2'", @tmpdir, @full_descr_path ) SCR.Execute(path(".target.bash"), cmd, { "LANG" => "C" }) if @compress_package_descriptions SCR.Execute( path(".target.bash"), Builtins.sformat("gzip %1/packages", @full_descr_path) ) end # ... don't forget to update checksums of new packages file (bnc#484695) # 1. MD5SUMS in DESCR directory (probably obsolete anyway) SCR.Execute( path(".target.bash"), Builtins.sformat("rm -f %1/MD5SUMS", @full_descr_path) ) cmd = Builtins.sformat( "cd '%1'; md5sum -- * > MD5SUMS", @full_descr_path ) out = Convert.to_map( SCR.Execute(path(".target.bash_output"), cmd, { "LANG" => "C" }) ) if Ops.get_integer(out, "exit", 0) != 0 Builtins.y2error("'%1' failed: %2", cmd, out) end # 2. SHA1SUM of 'packages' belongs to content file file = @compress_package_descriptions ? "packages.gz" : "packages" out = Convert.to_map( SCR.Execute( path(".target.bash_output"), Builtins.sformat( "cd '%1' && sha1sum -- %2", @full_descr_path, String.Quote(file) ), { "LANG" => "C" } ) ) sha1sum = Builtins.deletechars( Ops.get_string(out, "stdout", ""), "\n" ) cmd = Builtins.sformat( "sed --in-place 's/^META SHA1 .* %1$/META SHA1 %2/' %3/content", file, sha1sum, base_path ) out = Convert.to_map( SCR.Execute(path(".target.bash_output"), cmd, { "LANG" => "C" }) ) if Ops.get_integer(out, "exit", 0) != 0 Builtins.y2error("'%1' failed: %2", cmd, out) else Builtins.y2milestone("'content' modified, signing it again...") # 3. finally, sign the content file again... # (alternatively, content could be signed as the last step, # but there's some nice functionality to really ask for correct password # at the beginning of the function...) SCR.Execute( path(".target.bash"), Builtins.sformat("rm -f '%1/content.asc'", base_path) ) cmd = Builtins.sformat( "gpg --batch --no-tty --passphrase-fd 0 --detach-sign -u %1 -a '%2/content' < %3", local_key, base_path, pw_path ) out = Convert.to_map( SCR.Execute(path(".target.bash_output"), cmd, { "LANG" => "C" }) ) if Ops.get_integer(out, "exit", 0) != 0 Builtins.y2error("'%1' failed: %2", cmd, out) end Builtins.y2milestone("... done") end else Builtins.y2warning("'%1' failed", cmd) end Builtins.y2milestone("... done (packages descriptions)") end # sign products file products_path = Ops.add(Ops.get(@full_media_paths, 0, ""), "/products") if FileUtils.Exists(products_path) Builtins.y2milestone("signing products file...") SCR.Execute( path(".target.bash"), Builtins.sformat("rm -f '%1.asc'", products_path) ) SCR.Execute( path(".target.bash"), Builtins.sformat( "gpg --batch --no-tty --passphrase-fd 0 --detach-sign -u %1 -a '%2' < %3", local_key, products_path, pw_path ) ) SCR.Execute( path(".target.bash"), Builtins.sformat( "gpg --export -a %1 > '%2.key'", local_key, products_path ) ) Builtins.y2milestone("... done") end SCR.Execute(path(".target.remove"), pw_path) true end |
- (Object) uncompress_file(file_path)
Take a path to compressed file as argument and return path to uncompressed one\
1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 |
# File '../../src/modules/AddOnCreator.rb', line 1252 def uncompress_file(file_path) ret = file_path if Builtins.substring( file_path, Ops.subtract(Builtins.size(file_path), 3), 3 ) == ".gz" && gzip_installed full = Builtins.splitstring(file_path, "/") file = Ops.get_string(full, Ops.subtract(Builtins.size(full), 1), "") if !FileUtils.Exists(Ops.add(Ops.add(@tmpdir, "/"), file)) SCR.Execute( path(".target.bash"), Builtins.sformat("cp -- %1 %2/", file_path, @tmpdir) ) end o = Convert.to_map( SCR.Execute( path(".target.bash_output"), Builtins.sformat("cd %1; gunzip %2", @tmpdir, file) ) ) if Ops.get_integer(o, "exit", 1) == 0 ret = Ops.add( Ops.add(@tmpdir, "/"), Builtins.substring(file, 0, Ops.subtract(Builtins.size(file), 3)) ) else Builtins.y2warning( "gunzip failed with %1 (%2)", Ops.get_integer(o, "exit", 0), Ops.get_string(o, "stderr", "") ) end end ret end |
- (Object) UpdateContentMap(content_list)
Take list of content-file data and update global content_map. If argument is empty, global 'content' list is used as an input.
1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 |
# File '../../src/modules/AddOnCreator.rb', line 1000 def UpdateContentMap(content_list) content_list = deep_copy(content_list) if content_list == nil || content_list == [] content_list = deep_copy(@content) end Builtins.foreach(content_list) do |entry| if Ops.get_string(entry, "value", "") != "" Ops.set( @content_map, Ops.get_string(entry, "key", ""), Ops.get_string(entry, "value", "") ) end end deep_copy(@content_map) end |
- (Object) Write
Write all AddOn products configurations
3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 |
# File '../../src/modules/AddOnCreator.rb', line 3801 def Write @add_on_products = Builtins.maplist(@add_on_products) do |product| # these could be generated, no need to save... Builtins.foreach( [ "available_packages", "arch_directories", "package2filename", "srcpackage2filename", "generated" ] ) do |key| if Builtins.haskey(product, key) product = Builtins.remove(product, key) end end deep_copy(product) end Builtins.y2milestone("writing list of configured products") SCR.Write(path(".target.ycp"), @add_on_products_file, @add_on_products) end |
- (Object) WriteContentFile(base_path, content_data)
Write the content file
2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 |
# File '../../src/modules/AddOnCreator.rb', line 2147 def WriteContentFile(base_path, content_data) content_data = deep_copy(content_data) return false if !FileUtils.Exists(base_path) file = "" Builtins.foreach(content_data) do |entry| if Ops.get_string(entry, "value", "") != "" if Ops.get_string(entry, "key", "") != "CONTENTSTYLE" file = Ops.add( file, Builtins.sformat( "%1 %2\n", Ops.get_string(entry, "key", ""), Ops.get_string(entry, "value", "") ) ) end Ops.set( @content_map, Ops.get_string(entry, "key", ""), Ops.get_string(entry, "value", "") ) end end # CONTENTSTYLE must be first key... file = Ops.add( Builtins.sformat( "CONTENTSTYLE %1\n", Ops.get(@content_map, "CONTENTSTYLE", "11") ), file ) SCR.Write(path(".target.string"), Ops.add(base_path, "/content"), file) end |
- (Object) WriteInfoFile(info_dir, info)
write info.txt file
2459 2460 2461 2462 2463 2464 |
# File '../../src/modules/AddOnCreator.rb', line 2459 def WriteInfoFile(info_dir, info) if info != "" && info != nil SCR.Write(path(".target.string"), Ops.add(info_dir, "/info.txt"), info) end true end |
- (Object) WriteLicensesFiles(descr_path, base_path, files)
Write the text of available licenses to correct places
2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 |
# File '../../src/modules/AddOnCreator.rb', line 2471 def WriteLicensesFiles(descr_path, base_path, files) files = deep_copy(files) if !FileUtils.Exists(base_path) Builtins.y2warning("no %1 directory exists...", base_path) return false end Builtins.y2milestone("writing licenses...") ret = true cmd = "" Builtins.foreach(files) do |file, cont| if cont != "" pos = Builtins.findlastof(file, ".") if pos == nil || Builtins.substring(file, pos) != ".txt" file = Ops.add(file, ".txt") end cmd = Ops.add(Ops.add(cmd, " "), file) ret = ret && SCR.Write( path(".target.string"), Ops.add(Ops.add(@tmpdir, "/"), file), cont ) if file == "license.txt" SCR.Write( path(".target.string"), Ops.add(@tmpdir, "/EULA.txt"), cont ) end end end # tar + gzip the licenses into one file if ret && cmd != "" cmd = Builtins.sformat( "cd %1; tar -czf %2/license.tar.gz license*.txt", @tmpdir, base_path ) out = Convert.to_map(SCR.Execute(path(".target.bash_output"), cmd)) if Ops.get_string(out, "stderr", "") != "" Builtins.y2warning("%1 returned %2", cmd, out) ret = false end end # merge the license of packages into EULA.txt if !FileUtils.Exists(Ops.add(@tmpdir, "/EULA.txt")) SCR.Execute( path(".target.bash"), Builtins.sformat("touch %1/EULA.txt", @tmpdir) ) end if FileUtils.Exists("/usr/bin/packages2eula.pl") SCR.Execute( path(".target.bash_output"), Builtins.sformat( "/usr/bin/packages2eula.pl -p %1/packages.en -o %2/EULA.txt 2>/dev/null", descr_path, @tmpdir ) ) end if Ops.greater_than(FileUtils.GetSize(Ops.add(@tmpdir, "/EULA.txt")), 0) SCR.Execute( path(".target.bash"), Builtins.sformat("cp -- %1/EULA.txt %2/", @tmpdir, base_path) ) end ret end |
- (Object) WriteMediaFiles(base_path, m_files, _next)
Write the media.n/media files
2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 |
# File '../../src/modules/AddOnCreator.rb', line 2421 def WriteMediaFiles(base_path, m_files, _next) m_files = deep_copy(m_files) return false if !FileUtils.Exists(base_path) i = 1 m_files = [""] if m_files == [] Builtins.foreach(m_files) do |cont| media_path = Ops.add(base_path, Builtins.sformat("/media.%1", i)) if cont == "" media_id = "" out = Convert.to_map( SCR.Execute(path(".target.bash_output"), "date +%Y%m%d%H%M%S") ) media_id = Builtins.deletechars( Ops.get_string(out, "stdout", ""), "\n" ) cont = Ops.add( Ops.add(Ops.get(@content_map, "VENDOR", ""), "\n"), media_id ) cont = Ops.add(Ops.add(cont, "\n"), Builtins.size(m_files)) if i == 1 end SCR.Write(path(".target.string"), Ops.add(media_path, "/media"), cont) # write nextmedia file if not empty if i == 1 && _next != "" SCR.Write( path(".target.string"), Ops.add(media_path, "/nextmedia"), _next ) end i = Ops.add(i, 1) end true end |
- (Object) WritePackageDescriptions(descr_path, descr)
Write the package descriptions edited by user
2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 |
# File '../../src/modules/AddOnCreator.rb', line 2279 def WritePackageDescriptions(descr_path, descr) descr = deep_copy(descr) return false if !FileUtils.Exists(descr_path) Builtins.y2milestone("writing package description files...") ret = true return ret if descr == {} Builtins.foreach( Convert.convert(descr, :from => "map", :to => "map <string, map>") ) do |lang, data| file_path = Ops.add(Ops.add(descr_path, "/packages."), lang) ret = ret && PackagesDescr.Write( file_path, Convert.convert(data, :from => "map", :to => "map <string, any>") ) Builtins.y2debug("file '%1' written, retval: %2", file_path, ret) if @compress_package_descriptions && gzip_installed Builtins.y2debug( "compressing %1 file: %2", file_path, SCR.Execute( path(".target.bash"), Builtins.sformat("gzip %1", file_path) ) ) end end if ret # copy the rest of files, generated earlier SCR.Execute( path(".target.bash"), Builtins.sformat( "/bin/rm -f '%1/packages' '%1/packages.DU*' '%1/packages.FL*'", descr_path ) ) Builtins.foreach(["packages", "packages.DU", "packages.FL"]) do |file| pth = Ops.add(Ops.add(@tmpdir, "/"), file) Builtins.y2debug("processing '%1'", pth) compress = false if !FileUtils.Exists(pth) && FileUtils.Exists(Ops.add(pth, ".gz")) pth = Ops.add(pth, ".gz") elsif @compress_package_descriptions compress = true end cmd = Builtins.sformat("/bin/cp -- %1 '%2'", pth, descr_path) SCR.Execute(path(".target.bash"), cmd, { "LANG" => "C" }) if compress SCR.Execute( path(".target.bash"), Builtins.sformat("gzip %1/%2", descr_path, file) ) end end end extra_prov = Ops.get_string(@current_product, "extra_prov", "") if extra_prov != "" && extra_prov != nil SCR.Write( path(".target.string"), Ops.add(descr_path, "/EXTRA_PROV"), extra_prov ) end Builtins.y2milestone("... done") ret end |
- (Object) WritePatchesFiles(base_path, p_files)
Create the patches files
2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 |
# File '../../src/modules/AddOnCreator.rb', line 2378 def WritePatchesFiles(base_path, p_files) p_files = deep_copy(p_files) return false if !FileUtils.Exists(base_path) i = 1 Builtins.foreach(p_files) do |cont| file_path = Ops.add(base_path, Builtins.sformat("/media.%1/patches", i)) SCR.Write(path(".target.string"), file_path, cont) if cont != "" i = Ops.add(i, 1) end true end |
- (Object) WritePatterns(descr_path, base_path)
Write all files with patterns definitions
2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 |
# File '../../src/modules/AddOnCreator.rb', line 2545 def WritePatterns(descr_path, base_path) if !FileUtils.Exists(base_path) || !FileUtils.Exists(descr_path) Builtins.y2warning( "%1 or %2 directory not available...", base_path, descr_path ) return false end ret = true names = [] Builtins.foreach(Ops.get_map(@current_product, "patterns", {})) do |full_name, pattern| filename = CreatePatternFullName(pattern, true) next if filename == "" names = Builtins.add(names, filename) file = Builtins.sformat( "=Ver: %1\n\n=Pat: %2\n", Ops.get_string( pattern, "Ver", Ops.get_string(@pattern_descr, ["Ver", "defval"], "") ), Ops.get_string(pattern, "Pat", "") ) pattern = Builtins.remove(Builtins.remove(pattern, "Ver"), "Pat") Builtins.foreach( Convert.convert(pattern, :from => "map", :to => "map <string, any>") ) do |key, val| descr = Ops.get(@pattern_descr, key, {}) # substring (key,0,3) is because of Des.lang, Sum.lang and Cat.lang shortkey = Builtins.substring(key, 0, 3) if Ops.get(@pattern_descr, shortkey, {}) != {} && Builtins.substring(key, 3, 1) == "." descr = Ops.get(@pattern_descr, shortkey, {}) end if val == nil || val == "" || val == [] || Ops.get_boolean(descr, "internal", false) next end file = Ops.add(file, "\n") if file != "" if Ops.get_string(descr, "type", "") == "boolean" val = Convert.to_boolean(val) ? "true" : "false" elsif Ops.get_string(descr, "type", "") == "package-list" val = Builtins.mergestring( Convert.convert(val, :from => "any", :to => "list <string>"), "\n" ) end if Ops.get_boolean(descr, "single_line", false) file = Ops.add(file, Builtins.sformat("=%1: %2\n", key, val)) else file = Ops.add(file, Builtins.sformat("+%1:\n%2\n-%1:\n", key, val)) end end Builtins.y2milestone( "writing pattern %1/%2: %3", descr_path, filename, SCR.Write( path(".target.string"), Ops.add(Ops.add(descr_path, "/"), filename), file ) ) if @compress_patterns && gzip_installed Builtins.y2debug( "compressing pattern file: %1", SCR.Execute( path(".target.bash"), Builtins.sformat("gzip %1/%2", descr_path, filename) ) ) end end if names != [] ret = SCR.Write( path(".target.string"), Ops.add(descr_path, "/patterns"), Builtins.mergestring(names, "\n") ) end ret end |
- (Object) WriteProductsFiles(base_path, p_files)
Create the products file TODO editor - see ExpertSettingsDialog3
2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 |
# File '../../src/modules/AddOnCreator.rb', line 2393 def WriteProductsFiles(base_path, p_files) p_files = deep_copy(p_files) return false if !FileUtils.Exists(base_path) i = 1 p_files = [""] if p_files == [] Builtins.foreach(p_files) do |cont| if cont == "" cont = Ops.add( Ops.add(Ops.add("/\t", Ops.get(@content_map, "NAME", "")), " "), Ops.get(@content_map, "VERSION", "") ) end SCR.Write( path(".target.string"), Builtins.sformat("%1/media.%2/products", base_path, i), cont ) i = Ops.add(i, 1) end true end |
- (Object) WriteServicepackArchive(base_path)
Generate servicepack.tar.gz archive for bootable media
3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 |
# File '../../src/modules/AddOnCreator.rb', line 3088 def WriteServicepackArchive(base_path) return false if !FileUtils.Exists(base_path) ret = true return ret if !@bootable spdir = Ops.add(@tmpdir, "/servicepack") SCR.Execute(path(".target.mkdir"), spdir) SCR.Execute( path(".target.bash"), Builtins.sformat("cp -- '%1/content'* %2/", base_path, spdir) ) SCR.Execute( path(".target.bash"), Builtins.sformat("cp -- '%1/gpg-pubkey'* %2/", base_path, spdir) ) SCR.Execute( path(".target.bash"), Builtins.sformat("cp -r -- '%1/media.1' %2/", base_path, spdir) ) # copy descriptions (with the stucture) descr_path = Builtins.sformat( "%1/%2", spdir, Ops.get(@content_map, "DESCRDIR", "") ) SCR.Execute(path(".target.mkdir"), descr_path) SCR.Execute( path(".target.bash"), Builtins.sformat("cp -- '%1/'* '%2/'", @full_descr_path, descr_path) ) if Ops.get_string(@current_product, "workflow_path", "") != "" SCR.Execute( path(".target.bash"), Builtins.sformat( "cp -- '%1/installation.xml' '%2/'", base_path, spdir ) ) end if FileUtils.Exists(Ops.add(base_path, "/y2update.tgz")) SCR.Execute( path(".target.bash"), Builtins.sformat("cp -- '%1/y2update.tgz' '%2'", base_path, spdir) ) end # finally, create the archive cmd = Builtins.sformat( "cd '%1'; tar -czf '%2/servicepack.tar.gz' .", spdir, base_path ) Builtins.y2debug("tar cmd: %1", cmd) out = Convert.to_map(SCR.Execute(path(".target.bash_output"), cmd)) if Ops.get_string(out, "stderr", "") != "" Builtins.y2warning("%1 returned %2", cmd, out) ret = false end ret end |
- (Object) WriteStringFiles(base_path, files)
Write the readme/COPYING/COPYRIGHT… files in base_path
2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 |
# File '../../src/modules/AddOnCreator.rb', line 2185 def WriteStringFiles(base_path, files) files = deep_copy(files) return false if !FileUtils.Exists(base_path) ret = true Builtins.foreach(files) do |file, cont| if cont != "" ret = ret && SCR.Write( path(".target.string"), Ops.add(Ops.add(base_path, "/"), file), cont ) end end ret end |
- (Object) WriteWorkflow(base_path, desc_path, packages, y2update_p)
Write the modification of installation workflow
3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 |
# File '../../src/modules/AddOnCreator.rb', line 3001 def WriteWorkflow(base_path, desc_path, packages, y2update_p) packages = deep_copy(packages) return false if !FileUtils.Exists(base_path) ret = true if desc_path != "" && FileUtils.Exists(desc_path) Builtins.y2milestone( "writing %1 as %2/installation.xml", desc_path, base_path ) SCR.Execute( path(".target.bash"), Builtins.sformat( "cp -- '%1' '%2/installation.xml'", desc_path, base_path ) ) end if y2update_p != "" SCR.Execute( path(".target.bash"), Builtins.sformat( "cp -- '%1' '%2/y2update.tgz'", y2update_p, base_path ) ) elsif packages != [] y2update_dir = Ops.add(@tmpdir, "/y2update") SCR.Execute(path(".target.mkdir"), y2update_dir) Builtins.foreach(packages) do |p| Builtins.y2milestone("extracting %1", p) cmd2 = Builtins.sformat( "cd '%1'; rpm2cpio %2 | cpio -imud 2>&1", y2update_dir, p ) Builtins.y2debug("extracting rpm: %1", cmd2) out2 = Convert.to_map(SCR.Execute(path(".target.bash_output"), cmd2)) if Ops.get_string(out2, "stderr", "") != "" Builtins.y2warning("%1 returned %2", cmd2, out2) end end cmd = Builtins.sformat( "cd '%2'; tar -czf '%1/y2update.tgz' .", base_path, y2update_dir ) Builtins.y2debug("tar cmd: %1", cmd) out = Convert.to_map(SCR.Execute(path(".target.bash_output"), cmd)) if Ops.get_string(out, "stderr", "") != "" Builtins.y2warning("%1 returned %2", cmd, out) ret = false end end ret end |