Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into app_icon
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Jul 1, 2015
2 parents 0626f77 + aa1e3ad commit 914b3d4
Show file tree
Hide file tree
Showing 16 changed files with 281 additions and 39 deletions.
16 changes: 0 additions & 16 deletions library/desktop/groups/network_devices.desktop

This file was deleted.

10 changes: 3 additions & 7 deletions library/general/src/fillup/sysconfig.yast2
Expand Up @@ -84,14 +84,10 @@ PKGMGR_AUTO_CHECK="yes"
PKGMGR_VERIFY_SYSTEM="no"

## Type: list(yes,no)
## Default: "no"
## Default: "yes"
#
# By default the recommended packages for already installed packages are not taken into
# account, i.e. they are not automatically selected for installation.
# Set this option to "yes" if you want to reevaluate which packages are recommended, e.g. to
# get the language dependent packages for an additional language or hardware related packages
# if the hardware has changed.
PKGMGR_REEVALUATE_RECOMMENDED="no"
# Install also the weak, recommended, dependencies.
PKGMGR_RECOMMENDED="yes"

## Type: list(yes,no)
## Default: "no"
Expand Down
12 changes: 12 additions & 0 deletions library/general/src/modules/Directory.rb
Expand Up @@ -54,6 +54,7 @@ def main
@agentdir = Ops.add(@execcompdir, "/servers_non_y2")

# Directory for data
# @deprecated since it does not honor Y2DIR. Use #find_data_file instead
@datadir = Ops.add(@yast2dir, "/data")
@ydatadir = @datadir

Expand Down Expand Up @@ -117,13 +118,24 @@ def Directory
nil
end

# Find an existing file in any of the YaST data directories
#
# @param relative_path [String] name of the file to find
# @return [String] full path of the file if it's found, nil otherwise
def find_data_file(relative_path)
possible_paths = Yast.y2paths.map { |p| File.join(p, "data", relative_path) }
possible_paths.find { |p| File.exist?(p) }
end

publish variable: :bindir, type: "string"
publish variable: :ybindir, type: "string"
publish variable: :logdir, type: "string"
publish variable: :vardir, type: "string"
publish variable: :etcdir, type: "string"
publish variable: :agentdir, type: "string"
# @deprecated since it does not honor Y2DIR. Use #find_data_file instead
publish variable: :datadir, type: "string"
# @deprecated since it's an alias for the deprecated #datadir
publish variable: :ydatadir, type: "string"
publish variable: :schemadir, type: "string"
publish variable: :includedir, type: "string"
Expand Down
4 changes: 4 additions & 0 deletions library/general/src/modules/Linuxrc.rb
Expand Up @@ -31,6 +31,10 @@

module Yast
class LinuxrcClass < Module
# Disables filesystem snapshots (fate#317973)
# Possible values: all, post, pre, single
DISABLE_SNAPSHOTS = "disable_snapshots"

def main
Yast.import "Mode"
Yast.import "Stage"
Expand Down
1 change: 1 addition & 0 deletions library/general/test/Makefile.am
Expand Up @@ -2,6 +2,7 @@ TESTS = \
asciifile_test.rb \
auto_client_test.rb \
dialog_test.rb \
directory_test.rb \
event_dispatcher_test.rb \
finish_client_test.rb \
hooks_test.rb \
Expand Down
1 change: 1 addition & 0 deletions library/general/test/data/data_file.txt
@@ -0,0 +1 @@
Data file content
27 changes: 27 additions & 0 deletions library/general/test/directory_test.rb
@@ -0,0 +1,27 @@
#! /usr/bin/env rspec

require_relative "test_helper"

Yast.import "Directory"

describe Yast::Directory do
describe ".find_data_file" do
subject(:file_path) { Yast::Directory.find_data_file(file) }

context "when file does not exist" do
let(:file) { "does_not_exist.txt" }

it "returns nil" do
expect(file_path).to be_nil
end
end

context "when the file is present" do
let(:file) { "data_file.txt" }

it "returns the full path" do
expect(IO.read(file_path)).to eq "Data file content"
end
end
end
end
8 changes: 6 additions & 2 deletions library/system/src/clients/view_anymsg.rb
Expand Up @@ -28,7 +28,9 @@
# Author: Klaus Kaempf <kkaempf@suse.de>
#
# $Id$
#

require "yast/core_ext"

# Reads a \n separated list of filenames from
# /var/lib/YaST2/filenames
# Lines starting with "#" are ignored (comments)
Expand All @@ -44,6 +46,8 @@
# The default is either given as WFM::Args(0) or is the file last viewed.
module Yast
class ViewAnymsgClient < Client
using Yast::CoreExt::AnsiString

def main
Yast.import "UI"
textdomain "base"
Expand Down Expand Up @@ -184,7 +188,7 @@ def main

if file_content
# remove ANSI color escape sequences
file_content.gsub!(/\e\[(\d|;|\[)+m/, "")
file_content.remove_ansi_sequences
# remove remaining ASCII control characters (ASCII 0-31 and 127 (DEL))
# except new line (LF = 0xa) and carriage return (CR = 0xd)
file_content.tr!("\u0000-\u0009\u000b\u000c\u000e-\u001f\u007f", "")
Expand Down
43 changes: 40 additions & 3 deletions library/system/src/lib/yast2/fs_snapshot.rb
Expand Up @@ -58,6 +58,8 @@ def initialize
class FsSnapshot
include Yast::Logger

Yast.import "Linuxrc"

FIND_CONFIG_CMD = "/usr/bin/snapper --no-dbus --root=%{root} list-configs | grep \"^root \" >/dev/null"
CREATE_SNAPSHOT_CMD = "/usr/lib/snapper/installation-helper --step 5 --root-prefix=%{root} --snapshot-type %{snapshot_type} --description \"%{description}\""
LIST_SNAPSHOTS_CMD = "LANG=en_US.UTF-8 /usr/bin/snapper --no-dbus --root=%{root} list"
Expand All @@ -82,13 +84,41 @@ def self.configured?
@configured = out["exit"] == 0
end

# Creates a new 'single' snapshot
# Returns whether creating the given snapshot type is allowed
# Information is taken from Linuxrc (DISABLE_SNAPSHOTS)
# * "all" - all snapshot types are temporarily disabled
# * "around" - before and after calling YaST
# * "single" - single snapshot at a given point
#
# @param [Symbol] one of :around (for :post and :pre snapshots) or :single
# @return [Boolean] if snapshot should be created
def self.create_snapshot?(snapshot_type)
disable_snapshots = Yast::Linuxrc.value_for(Yast::LinuxrcClass::DISABLE_SNAPSHOTS)

# Feature is not defined on Linuxrc commandline
return true if disable_snapshots.nil? || disable_snapshots.empty?

disable_snapshots = disable_snapshots.downcase.tr("-_.", "").split(",")

if [:around, :single].include?(snapshot_type)
return false if disable_snapshots.include?("all")
return !disable_snapshots.include?(snapshot_type.to_s)
else
raise ArgumentError, "Unsupported snapshot type #{snapshot_type.inspect}, " \
"supported are :around and :single"
end
end

# Creates a new 'single' snapshot unless disabled by user
#
# @param description [String] Snapshot's description.
# @return [FsSnapshot] The created snapshot.
#
# @see FsSnapshot.create
# @see FsSnapshot.create_snapshot?
def self.create_single(description)
return nil unless create_snapshot?(:single)

create(:single, description)
end

Expand All @@ -98,11 +128,14 @@ def self.create_single(description)
# @return [FsSnapshot] The created snapshot.
#
# @see FsSnapshot.create
# @see FsSnapshot.create_snapshot?
def self.create_pre(description)
return nil unless create_snapshot?(:around)

create(:pre, description)
end

# Creates a new 'post' snapshot
# Creates a new 'post' snapshot unless disabled by user
#
# Each 'post' snapshot corresponds with a 'pre' one.
#
Expand All @@ -111,8 +144,12 @@ def self.create_pre(description)
# @return [FsSnapshot] The created snapshot.
#
# @see FsSnapshot.create
# @see FsSnapshot.create_snapshot?
def self.create_post(description, previous_number)
return nil unless create_snapshot?(:around)

previous = find(previous_number)

if previous
create(:post, description, previous)
else
Expand All @@ -121,7 +158,7 @@ def self.create_post(description, previous_number)
end
end

# Creates a new snapshot
# Creates a new snapshot unless disabled by user
#
# It raises an exception if Snapper is not configured or if snapshot
# creation fails.
Expand Down

0 comments on commit 914b3d4

Please sign in to comment.