Commit 5f69a803 authored by Thierry Laurion's avatar Thierry Laurion
Browse files

Merge branch 'master' into 'sdcard_initrd_support'

# Conflicts:
#   config/chroot_local-includes/usr/share/initramfs-tools/hooks/sdcard
parents dbdab953 0fb5e2b8
......@@ -114,6 +114,7 @@ TORPROJECT_MIRROR="$(apt-mirror torproject)"
perl -pi \
-E \
"s|^(deb(?:-src)?\s+)https?://ftp[.]us[.]debian[.]org/debian/?(\s+)|\$1$DEBIAN_MIRROR\$2| ; \
s|^(deb(?:-src)?\s+)https?://security[.]debian[.]org/debian-security/?(\s+)|\$1$DEBIAN_SECURITY_MIRROR\$2| ; \
s|^(deb(?:-src)?\s+)https?://deb[.]torproject[.]org/torproject[.]org/?(\s+)|\$1$TORPROJECT_MIRROR\$2|" \
config/chroot_sources/*.chroot \
|| fatal "APT mirror substitution failed with exit code $?"
......
This diff is collapsed.
......@@ -37,21 +37,16 @@ Pin: release o=Debian,n=sid
Pin-Priority: 999
Explanation: src:firmware-nonfree
Package: firmware-linux firmware-linux-nonfree firmware-atheros firmware-brcm80211 firmware-intel-sound firmware-ipw2x00 firmware-iwlwifi firmware-libertas firmware-misc-nonfree firmware-realtek firmware-ti-connectivity
Package: firmware-linux firmware-linux-nonfree firmware-amd-graphics firmware-atheros firmware-brcm80211 firmware-intel-sound firmware-ipw2x00 firmware-iwlwifi firmware-libertas firmware-misc-nonfree firmware-realtek firmware-ti-connectivity
Pin: release o=Debian,n=sid
Pin-Priority: 990
Explanation: Exception to src:firmware-nonfree pinning due to Debian#928631
Package: firmware-amd-graphics
Pin: release o=Debian,n=stretch-backports
Pin-Priority: 990
Package: firmware-zd1211
Pin: release o=Debian,n=sid
Pin-Priority: 999
Package: fonts-noto*
Pin: release o=Debian,n=sid
Pin: release o=Debian,n=buster
Pin-Priority: 999
Explanation: src:gdk-pixbuf
......@@ -61,7 +56,7 @@ Pin-Priority: -1
Explanation: not available in Stretch; XXX:Buster: remove this entry
Package: hunspell-id hunspell-tr
Pin: release o=Debian,n=sid
Pin: release o=Debian,n=buster
Pin-Priority: 990
Package: intel-microcode
......@@ -73,12 +68,11 @@ Pin: release o=Debian,n=stretch-backports
Pin-Priority: 999
Package: linux-compiler-* linux-headers-* linux-image-* linux-kbuild-* linux-source-*
Pin: release o=Debian,n=sid
Pin: release o=Debian,n=buster
Pin-Priority: 999
Explanation: We ship our custom-built Thunderbird for now, see #6156
Package: thunderbird* calendar-google-provider
Pin: origin deb.tails.boum.org
Package: linux-compiler-* linux-headers-* linux-image-* linux-kbuild-* linux-source-*
Pin: release l=Debian-Security,n=buster/updates
Pin-Priority: 999
Explanation: src:libdrm
......@@ -130,10 +124,6 @@ Package: tails-installer
Pin: origin deb.tails.boum.org
Pin-Priority: 999
Package: tor tor-geoipdb
Pin: release o=TorProject,n=tor-experimental-0.4.0.x-stretch
Pin-Priority: 999
Package: virtualbox*
Pin: release o=Debian,n=stretch-backports
Pin-Priority: 999
......
......@@ -13,7 +13,7 @@ echo "Install the Tor Browser"
# a new browser profile we can simply copy the profile directory
# without duplicating all extensions.
. /usr/local/lib/tails-shell-library/tor-browser.sh
# Import install_fake_package
# Import install_fake_package and strip_nondeterminism_wrapper
. /usr/local/lib/tails-shell-library/build.sh
download_and_verify_files() {
......@@ -217,6 +217,13 @@ apply_prefs_hacks() {
perl -pi -E \
's/^(pref\("browser.uiCustomization.state",.*\\"loop-button\\")/$1,\\"stop-reload-button\\"/' \
defaults/preferences/000-tor-browser.js
# Hide the security level button in the unsafe browser (#16735)
UNSAFE_BROWSER_PREFS=/usr/share/tails/chroot-browsers/unsafe-browser/prefs.js
echo "\n// Hide the security level button" >> "${UNSAFE_BROWSER_PREFS}"
grep -E '^pref\("browser.uiCustomization.state"' defaults/preferences/000-tor-browser.js | \
perl -p -E 's/(.*)\\"security-level-button\\",/user_$1/' >> "${UNSAFE_BROWSER_PREFS}"
# Append our custom prefs
cat /usr/share/tails/tor-browser-prefs.js \
>> defaults/preferences/000-tor-browser.js
......@@ -269,7 +276,7 @@ install_debian_extensions() {
destination="${1}"
shift
apt-get install --yes "${@}"
ln -s /usr/share/webext/ublock-origin/ \
ln -s '/usr/share/mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}/uBlock0@raymondhill.net' \
"${destination}"/'uBlock0@raymondhill.net'
patch -p1 < /usr/share/tails/uBlock-disable-autoUpdate.diff
}
......@@ -280,7 +287,7 @@ create_default_profile() {
tbb_extensions_dir="${2}"
destination="${3}"
rsync -a --exclude bookmarks.html --exclude extensions \
rsync -a --exclude extensions \
"${tbb_profile}"/ "${destination}"/
mkdir -p "${destination}"/extensions
......
......@@ -11,14 +11,9 @@ echo "Localize each supported browser locale"
# Import language_code_from_locale()
. /usr/local/lib/tails-shell-library/localization.sh
# Import strip_nondeterminism_wrapper() and ensure_hook_dependency_is_installed()
. /usr/local/lib/tails-shell-library/build.sh
# Import TAILS_WIKI_SUPPORTED_LANGUAGES
. /etc/amnesia/environment
ensure_hook_dependency_is_installed p7zip imagemagick
BROWSER_LOCALIZATION_DIR="/usr/share/tails/browser-localization"
DESCRIPTIONS_FILE="${BROWSER_LOCALIZATION_DIR}/descriptions"
LOCALE_PROFILES_DIR="/etc/tor-browser/locale-profiles/"
......
#!/bin/sh
set -e
set -u
echo "Patching the Thunderbird account setup wizard"
# Import strip_nondeterminism_wrapper
. /usr/local/lib/tails-shell-library/build.sh
OMNI_JA=/usr/share/thunderbird/omni.ja
/usr/share/tails/build/patch-thunderbird \
"$OMNI_JA" \
/usr/share/tails/build/thunderbird-patches
strip_nondeterminism_wrapper \
--type zip \
--timestamp "$SOURCE_DATE_EPOCH" \
"$OMNI_JA" 2>/dev/null
......@@ -39,6 +39,8 @@ for modules_dir in /lib/modules/*/extra ; do
fi
done
strip --strip-debug /lib/modules/*/extra/aufs.ko
depmod "${KERNEL_VERSION}-${arch}"
rm -r /usr/src/aufs4-standalone
rm -r "/usr/src/linux-source-${KERNEL_SOURCE_VERSION}"
......@@ -4,18 +4,9 @@ set -e
echo "Set up Tor Browser bookmarks"
# Import ensure_hook_dependency_is_installed()
. /usr/local/lib/tails-shell-library/build.sh
ensure_hook_dependency_is_installed sqlite3
# Create a symlink to places.sqlite in browser profile from a
# dedicated "bookmarks" directory, so that it can be easily made
# persistent
mkdir -p /etc/skel/.mozilla/firefox/bookmarks
ln -s /home/amnesia/.mozilla/firefox/bookmarks/places.sqlite \
/etc/skel/.tor-browser/profile.default/places.sqlite
# Create the bookmarks database
sqlite3 /etc/skel/.mozilla/firefox/bookmarks/places.sqlite \
< /etc/skel/.mozilla/firefox/bookmarks/places.sqlite.in
rm /etc/skel/.mozilla/firefox/bookmarks/places.sqlite.in
......@@ -121,7 +121,7 @@ time_is_in_valid_tor_range() {
local curdate="$1"
local vstart="$2"
vendcons=$(date -ud "${vstart} -0230" +'%F %T')
vendcons=$(date -ud "${vstart} -0255" +'%F %T')
order="${vstart}
${curdate}
${vendcons}"
......
PRAGMA foreign_keys=OFF;
PRAGMA user_version=35;
BEGIN TRANSACTION;
CREATE TABLE moz_places ( id INTEGER PRIMARY KEY, url LONGVARCHAR, title LONGVARCHAR, rev_host LONGVARCHAR, visit_count INTEGER DEFAULT 0, hidden INTEGER DEFAULT 0 NOT NULL, typed INTEGER DEFAULT 0 NOT NULL, favicon_id INTEGER, frecency INTEGER DEFAULT -1 NOT NULL, last_visit_date INTEGER , guid TEXT, foreign_count INTEGER DEFAULT 0 NOT NULL, url_hash INTEGER DEFAULT 0 NOT NULL );
INSERT INTO "moz_places" VALUES(1,'https://tails.boum.org/',NULL,'gro.muob.sliat.',0,0,0,NULL,140,NULL,NULL,1,0);
INSERT INTO "moz_places" VALUES(2,'file:///usr/share/doc/tails/website/index.en.html',NULL,'.',0,0,0,NULL,140,NULL,NULL,1,0);
INSERT INTO "moz_places" VALUES(3,'https://webmail.no-log.org/',NULL,'gro.gol-on.liambew.',0,0,0,NULL,140,NULL,NULL,1,0);
INSERT INTO "moz_places" VALUES(4,'https://mail.riseup.net/',NULL,'ten.puesir.liam.',0,0,0,NULL,140,NULL,NULL,1,0);
INSERT INTO "moz_places" VALUES(5,'https://webmail.boum.org/',NULL,'gro.muob.liambew.',0,0,0,NULL,140,NULL,NULL,1,0);
INSERT INTO "moz_places" VALUES(6,'https://check.torproject.org/',NULL,'gro.tcejorprot.kcehc.',0,0,0,NULL,140,NULL,NULL,1,0);
INSERT INTO "moz_places" VALUES(7,'https://www.torproject.org/',NULL,'gro.tcejorprot.www.',0,0,0,NULL,140,NULL,NULL,1,0);
INSERT INTO "moz_places" VALUES(8,'https://tor.stackexchange.com/',NULL,'moc.egnahcxekcats.rot.',0,0,0,NULL,140,NULL,NULL,1,0);
INSERT INTO "moz_places" VALUES(9,'place:sort=8&maxResults=10',NULL,'.',0,0,0,NULL,0,NULL,NULL,1,0);
INSERT INTO "moz_places" VALUES(10,'place:type=6&sort=14&maxResults=10',NULL,'.',0,0,0,NULL,0,NULL,NULL,1,0);
CREATE TABLE moz_historyvisits ( id INTEGER PRIMARY KEY, from_visit INTEGER, place_id INTEGER, visit_date INTEGER, visit_type INTEGER, session INTEGER);
CREATE TABLE moz_inputhistory ( place_id INTEGER NOT NULL, input LONGVARCHAR NOT NULL, use_count INTEGER, PRIMARY KEY (place_id, input));
CREATE TABLE moz_hosts ( id INTEGER PRIMARY KEY, host TEXT NOT NULL UNIQUE, frecency INTEGER, typed INTEGER NOT NULL DEFAULT 0, prefix TEXT);
INSERT INTO "moz_hosts" VALUES(1,'tails.boum.org',140,0,NULL);
INSERT INTO "moz_hosts" VALUES(2,'webmail.no-log.org',140,0,NULL);
INSERT INTO "moz_hosts" VALUES(3,'mail.riseup.net',140,0,NULL);
INSERT INTO "moz_hosts" VALUES(4,'webmail.boum.org',140,0,NULL);
INSERT INTO "moz_hosts" VALUES(5,'check.torproject.org',140,0,NULL);
INSERT INTO "moz_hosts" VALUES(6,'torproject.org',140,0,NULL);
INSERT INTO "moz_hosts" VALUES(7,'tor.stackexchange.com',140,0,NULL);
CREATE TABLE moz_bookmarks ( id INTEGER PRIMARY KEY, type INTEGER, fk INTEGER DEFAULT NULL, parent INTEGER, position INTEGER, title LONGVARCHAR, keyword_id INTEGER, folder_type TEXT, dateAdded INTEGER, lastModified INTEGER, guid TEXT);
INSERT INTO "moz_bookmarks" VALUES(1,2,NULL,0,0,'',NULL,NULL,0,0,'root________');
INSERT INTO "moz_bookmarks" VALUES(2,2,NULL,1,0,'Bookmarks Menu',NULL,NULL,0,0,'menu________');
INSERT INTO "moz_bookmarks" VALUES(3,2,NULL,1,1,'Bookmarks Toolbar',NULL,NULL,0,0,'toolbar_____');
INSERT INTO "moz_bookmarks" VALUES(4,2,NULL,1,2,'Tags',NULL,NULL,0,0,'tags________');
INSERT INTO "moz_bookmarks" VALUES(5,2,NULL,1,3,'Other Bookmarks',NULL,NULL,0,0,'unfiled_____');
INSERT INTO "moz_bookmarks" VALUES(6,2,NULL,1,4,'mobile',NULL,NULL,0,0,'mobile______');
INSERT INTO "moz_bookmarks" VALUES(7,1,1,2,4,'Tails',NULL,NULL,0,0,NULL);
INSERT INTO "moz_bookmarks" VALUES(8,1,2,2,5,'Tails documentation (offline)',NULL,NULL,0,0,NULL);
INSERT INTO "moz_bookmarks" VALUES(9,2,NULL,2,2,'Webmail',NULL,NULL,0,0,NULL);
INSERT INTO "moz_bookmarks" VALUES(10,1,3,9,0,'no-log.org',NULL,NULL,0,0,NULL);
INSERT INTO "moz_bookmarks" VALUES(11,1,4,9,1,'riseup.net',NULL,NULL,0,0,NULL);
INSERT INTO "moz_bookmarks" VALUES(12,1,5,9,2,'boum.org',NULL,NULL,0,0,NULL);
INSERT INTO "moz_bookmarks" VALUES(13,2,NULL,2,3,'Tor',NULL,NULL,0,0,NULL);
INSERT INTO "moz_bookmarks" VALUES(14,1,6,13,0,'Tor Check',NULL,NULL,0,0,NULL);
INSERT INTO "moz_bookmarks" VALUES(15,1,7,13,1,'Tor Project',NULL,NULL,0,0,NULL);
INSERT INTO "moz_bookmarks" VALUES(16,1,8,13,2,'Tor Stack Exchange',NULL,NULL,0,0,NULL);
INSERT INTO "moz_bookmarks" VALUES(17,1,9,3,0,'Most Visited',NULL,NULL,0,0,NULL);
INSERT INTO "moz_bookmarks" VALUES(18,1,10,2,0,'Recent Tags',NULL,NULL,0,0,NULL);
INSERT INTO "moz_bookmarks" VALUES(19,3,NULL,2,1,NULL,NULL,NULL,0,0,NULL);
CREATE TABLE moz_keywords ( id INTEGER PRIMARY KEY AUTOINCREMENT, keyword TEXT UNIQUE, place_id INTEGER, post_data TEXT);
CREATE TABLE moz_favicons ( id INTEGER PRIMARY KEY, url LONGVARCHAR UNIQUE, data BLOB, mime_type VARCHAR(32), expiration LONG);
CREATE TABLE moz_anno_attributes ( id INTEGER PRIMARY KEY, name VARCHAR(32) UNIQUE NOT NULL);
INSERT INTO "moz_anno_attributes" VALUES(1,'mobile/bookmarksRoot');
INSERT INTO "moz_anno_attributes" VALUES(2,'Places/SmartBookmark');
CREATE TABLE moz_annos ( id INTEGER PRIMARY KEY, place_id INTEGER NOT NULL, anno_attribute_id INTEGER, mime_type VARCHAR(32) DEFAULT NULL, content LONGVARCHAR, flags INTEGER DEFAULT 0, expiration INTEGER DEFAULT 0, type INTEGER DEFAULT 0, dateAdded INTEGER DEFAULT 0, lastModified INTEGER DEFAULT 0);
CREATE TABLE moz_items_annos ( id INTEGER PRIMARY KEY, item_id INTEGER NOT NULL, anno_attribute_id INTEGER, mime_type VARCHAR(32) DEFAULT NULL, content LONGVARCHAR, flags INTEGER DEFAULT 0, expiration INTEGER DEFAULT 0, type INTEGER DEFAULT 0, dateAdded INTEGER DEFAULT 0, lastModified INTEGER DEFAULT 0);
INSERT INTO "moz_items_annos" VALUES(1,6,1,NULL,'1',0,4,1,1071790224,1071790224);
INSERT INTO "moz_items_annos" VALUES(2,17,2,NULL,'MostVisited',0,4,3,0,0);
INSERT INTO "moz_items_annos" VALUES(3,18,2,NULL,'RecentTags',0,4,3,0,0);
ANALYZE sqlite_master;
INSERT INTO "sqlite_stat1" VALUES('moz_bookmarks','moz_bookmarks_guid_uniqueindex','6 1');
INSERT INTO "sqlite_stat1" VALUES('moz_bookmarks','moz_bookmarks_itemlastmodifiedindex','6 6 3');
INSERT INTO "sqlite_stat1" VALUES('moz_bookmarks','moz_bookmarks_parentindex','6 3 1');
INSERT INTO "sqlite_stat1" VALUES('moz_bookmarks','moz_bookmarks_itemindex','6 6 6');
CREATE INDEX moz_places_url_hashindex ON moz_places (url_hash);
CREATE INDEX moz_places_faviconindex ON moz_places (favicon_id);
CREATE INDEX moz_places_hostindex ON moz_places (rev_host);
CREATE INDEX moz_places_visitcount ON moz_places (visit_count);
CREATE INDEX moz_places_frecencyindex ON moz_places (frecency);
CREATE INDEX moz_places_lastvisitdateindex ON moz_places (last_visit_date);
CREATE UNIQUE INDEX moz_places_guid_uniqueindex ON moz_places (guid);
CREATE INDEX moz_historyvisits_placedateindex ON moz_historyvisits (place_id, visit_date);
CREATE INDEX moz_historyvisits_fromindex ON moz_historyvisits (from_visit);
CREATE INDEX moz_historyvisits_dateindex ON moz_historyvisits (visit_date);
CREATE INDEX moz_bookmarks_itemindex ON moz_bookmarks (fk, type);
CREATE INDEX moz_bookmarks_parentindex ON moz_bookmarks (parent, position);
CREATE INDEX moz_bookmarks_itemlastmodifiedindex ON moz_bookmarks (fk, lastModified);
CREATE UNIQUE INDEX moz_bookmarks_guid_uniqueindex ON moz_bookmarks (guid);
CREATE UNIQUE INDEX moz_keywords_placepostdata_uniqueindex ON moz_keywords (place_id, post_data);
CREATE UNIQUE INDEX moz_annos_placeattributeindex ON moz_annos (place_id, anno_attribute_id);
CREATE UNIQUE INDEX moz_items_annos_itemattributeindex ON moz_items_annos (item_id, anno_attribute_id);
COMMIT;
<?xml version='1.0' encoding='UTF-8' ?>
<account version='1.0'>
<account>
<protocol>prpl-irc</protocol>
<name>XXX_NICK_XXX@irc.oftc.net</name>
<statuses>
<status type='available' name='Available' active='true'>
<attributes/>
</status>
<status type='away' name='Away' active='false'>
<attributes/>
</status>
<status type='offline' name='Offline' active='false'>
<attributes/>
</status>
</statuses>
<settings>
<setting name='username' type='string'>XXX_NICK_XXX</setting>
<setting name='encoding' type='string'>UTF-8,ISO-8859-1</setting>
<setting name='realname' type='string'>XXX_NICK_XXX</setting>
<setting name='port' type='int'>6697</setting>
<setting name='ssl' type='bool'>1</setting>
</settings>
<settings ui='gtk-gaim'>
<setting name='auto-login' type='bool'>0</setting>
</settings>
<current_error/>
</account>
<account>
<protocol>prpl-irc</protocol>
<name>XXX_NICK_XXX@127.0.0.1</name>
<statuses>
<status type='available' name='Available' active='true'>
<attributes/>
</status>
<status type='away' name='Away' active='false'>
<attributes/>
</status>
<status type='offline' name='Offline' active='false'>
<attributes/>
</status>
</statuses>
<settings>
<setting name='username' type='string'>XXX_NICK_XXX</setting>
<setting name='encoding' type='string'>UTF-8,ISO-8859-1</setting>
<setting name='realname' type='string'>XXX_NICK_XXX</setting>
<setting name='port' type='int'>6668</setting>
<setting name='ssl' type='bool'>0</setting>
</settings>
<settings ui='gtk-gaim'>
<setting name='auto-login' type='bool'>0</setting>
</settings>
<proxy>
<type>none</type>
</proxy>
<current_error/>
</account>
</account>
<?xml version='1.0' encoding='UTF-8' ?>
<purple version='1.0'>
<privacy>
<account proto='prpl-irc' name='XXX_NICK_XXX@irc.oftc.net' mode='1'/>
</privacy>
</purple>
......@@ -25,3 +25,14 @@
/* Hide HTTPS Everywhere button in the toolbar */
#https-everywhere-button { display: none; }
/* Hide the uBlock sidebar, that's opened on first launch
References:
- https://github.com/gorhill/uBlock/releases/tag/1.16.6
- https://github.com/uBlock-LLC/uBlock/issues/1764 */
vbox#sidebar-box[sidebarcommand="_UUID~ADDON_-sidebar-action"] {
display: none !important;
}
vbox#sidebar-box[sidebarcommand="ublock0_raymondhill_net-sidebar-action"] {
display: none !important;
}
ENV{ID_FS_LABEL}=="TailsData", ENV{UDISKS_IGNORE}="1"
# We set UDISKS_IGNORE on the TailsData partition of the live boot
# device to hide it in GNOME apps. This prevents spurious notifications
# being shown when setting up persistence.
ENV{ID_FS_LABEL}=="TailsData", PROGRAM="/lib/bilibop/test $devnode", ENV{UDISKS_IGNORE}="1"
#!/bin/sh
# List of at least 2000 possible nicknames
NICKS_LIST=/usr/share/tails/firstnames.txt
# returns true with probability $1
prob()
{
# sh doesn't have bash's $RANDOM, so we implement it
RANDOM=$(expr $(od -Anv -N4 -tu4 /dev/urandom) % 32768)
# we compare with > instead of <= due to mismatch between bash and bc
# on what values true and false have.
return $(echo "scale = 10; ${RANDOM}/32767 > ${1}" | bc)
}
leet_nick()
{
# we leave the first letter due to restrictions on nicks in IRC
first=$(expr substr ${1} 1 1)
rest=${1#?}
rest=$(echo "${rest}" | tr 'e' '3' | tr 'i' '1' | tr 'o' '0')
echo "${first}${rest}"
}
generate_nick()
{
NICK=$(/usr/local/bin/lc.py -g 1 --min 4 --max 10 "${NICKS_LIST}")
if prob 0.90; then
NICK=$(echo "${NICK}" | tr '[:upper:]' '[:lower:]')
fi
if prob 0.05; then
if prob 0.50; then
NICK="${NICK}_"
else
NICK="${NICK}^"
fi
fi
if prob 0.05; then
NICK=$(leet_nick "${NICK}")
fi
echo ${NICK}
}
Configure_pidgin ()
{
echo "- configuring Pidgin"
NICK=$(generate_nick)
for file in accounts.xml blist.xml ; do
sudo -H -u "${LIVE_USERNAME}" sed -i'' "s,XXX_NICK_XXX,${NICK}," "/home/${LIVE_USERNAME}/.purple/${file}"
done
# Creating state file
touch /var/lib/live/config/pidgin
}
Configure_pidgin
#!/usr/bin/python3
# The MIT License
#
# Copyright (c) 2011 Christopher Pound
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
# lc.py -- language confluxer (http://www.ruf.rice.edu/~pound/lc.py)
#
# - Written by Christopher Pound (pound@rice.edu), July 1993.
# - Loren Miller suggested I make sure lc starts by picking a
# letter pair that was at the beginning of a data word, Oct 95.
# - Cleaned it up a little bit, March 95; more, September 01
# - Python version, Jul 09
#
# The datafile should be a bunch of words from some language
# with minimal punctuation or garbage (# starts a comment).
from optparse import OptionParser
import random
import re
import sys
class Pseudolanguage:
def __init__(self, **dict):
"""Set up a new pseudolanguage"""
dict.setdefault('name', '')
self.name = dict['name']
self.parsed = False
self.data = {}
self.inits = {}
self.pairs = {}
def incorporate(self, files):
"""Load list of files for this pseudolanguage into self.data"""
self.parsed = False
for f in files:
words = []
with open(f) as text:
for line in text:
line = line.strip()
line = re.sub(r"#.*", "", line)
words.extend(re.split(r"\s+", line))
self.data[f] = words
def delete(self, files):
"""Delete a list of languages from self.data"""
self.parsed = False
for f in files:
del self.data[f]
def parse(self):
"""Parse pseudolanguage's data into self.inits and self.pairs"""
if not self.parsed:
self.inits.clear()
self.pairs.clear()
for f in self.data:
for word in self.data[f]:
word += ' '
if len(word) > 3:
if word[0:2] in self.inits:
self.inits[word[0:2]].append(word[2:3])
else:
self.inits[word[0:2]] = [word[2:3]]
pos = 0
while pos < len(word)-2:
if word[pos:pos+2] in self.pairs:
self.pairs[word[pos:pos+2]].append(word[pos+2])
else:
self.pairs[word[pos:pos+2]] = [word[pos+2]]
pos = pos + 1
self.parsed = True
def dump(self):
"""Print the current parsed data; use pickle for inflatable dumps"""
self.parse()
print('name = """', self.name, '"""')
print("dump = { 'inits': ", self.inits, ",")
print("'pairs': ", self.pairs, " }")
def generate(self, number, min, max):
"""Generate list of words of min and max lengths"""
self.parse()
wordlist = []
while len(wordlist) < number:
word = random.choice(list(self.inits.keys()))
while word.find(' ') == -1:
word += random.choice(self.pairs[word[-2:]])
word = word.strip()
if len(word) >= min and len(word) <= max:
wordlist.append(word)
return wordlist
if __name__ == '__main__':
usage = "usage: %prog [options] datafile1 [datafile2 ...]"
parser = OptionParser(usage=usage, version="%prog 1.0")
parser.add_option("-d", "--dump", action="store_true",
dest="dump", default=False,
help="Dump internal representation of the pseudolanguage")
parser.add_option("-g", "--generate", type="int", dest="num",
help="Generate specified number of words")
parser.add_option("--min", type="int", dest="min", default=3,
help="Set the minimum length of each word")
parser.add_option("--max", type="int", dest="max", default=9,
help="Set the maximum length of each word")
parser.add_option("--name", dest="name", default=' ',
help="Set the name of the pseudolanguage")
(options, args) = parser.parse_args()
aLanguage = Pseudolanguage(name=options.name)
aLanguage.incorporate(args)
if options.dump:
aLanguage.dump()
else:
results = aLanguage.generate(options.num, options.min, options.max)
for word in results:
print(word)
......@@ -25,8 +25,6 @@ from tailslib.additionalsoftware import ( # NOQA: E402
get_packages_list_path,
filter_package_details)
_ = gettext.gettext
UI_FILE = "/usr/share/tails/additional-software/configuration-window.ui"
......
......@@ -270,9 +270,8 @@ class Volume(object):
None) # cancellable
unmounted_at_least_once = True
except GLib.Error as e:
if "org.freedesktop.UDisks2.Error.NotMounted" in e.message:
if not unmounted_at_least_once:
logger.warning("Failed to unmount volume %s: %s", self.device_file, e.message)
# Ignore "not mounted" error if the volume was already unmounted
if e.domain == "udisks-error-quark" and e.code == UDisks.Error.NOT_MOUNTED and unmounted_at_least_once:
return
raise
......@@ -322,8 +321,22 @@ class Volume(object):
loop.call_set_autoclear_sync(True,
GLib.Variant('a{sv}', {}), # options
None) # cancellable
self.unmount()
self.backing_volume.lock()
try:
self.unmount()
self.backing_volume.lock()
</