summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Perez de Castro2024-04-22 12:20:56 +0300
committerAdrian Perez de Castro2024-04-22 12:28:32 +0300
commitcfedee428c65f40bc9cabc51b3300209c4485243 (patch)
treea2702660ec16a97771b581a833ef66f32a85fdd3
parentef93f303cf627a5f395486003aa75db729c6b165 (diff)
downloadaur-pswd.tar.gz
Fix to work with Python 3.x
-rw-r--r--.SRCINFO11
-rw-r--r--.gitignore4
-rw-r--r--PKGBUILD30
-rw-r--r--license.txt2
-rw-r--r--pswd-py3.diff194
5 files changed, 218 insertions, 23 deletions
diff --git a/.SRCINFO b/.SRCINFO
index 56eeaa6fd117..e33c84414267 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,17 +1,14 @@
-# Generated by makepkg 5.0.0
-# Mon Feb 8 12:00:31 UTC 2016
pkgbase = pswd
pkgdesc = A pseudo-random password generator
pkgver = 3.1.0
- pkgrel = 2
+ pkgrel = 3
url = https://github.com/dwaring87/pswd
arch = any
- license = custom
+ license = MIT
depends = python
source = https://github.com/dwaring87/pswd/archive/v3.1.0.tar.gz
- source = license.txt
+ source = pswd-py3.diff
sha512sums = d1b84bb3760d79c3e62558e6bed87c65c86d78ac4d0b3665b93f3986a7592ef5ce1889aecd7783993518bfad61b3a79c200d7798ddf7bf6810521b49eb0c3b0c
- sha512sums = 3396eb172dc6f467e153367492a14c89a1dcd06b0e445aacc71ab35f11984a9f2d666c40741b1b312c74fe54b81ca0e09a33643f63c97286d8ec13fd5f7df177
+ sha512sums = 7f353f42fb9692b076ac626d4f49e0ed57504216afef9d49264f14e22d19af629c89d1b2a9b0bc369cf1d6c4a8e162089a8446e7c307569b51ed455c18f9311d
pkgname = pswd
-
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 000000000000..218620e2fb38
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+*
+!/PKGBUILD
+!/.SRCINFO
+!/.gitignore
diff --git a/PKGBUILD b/PKGBUILD
index ba9cf4c3513e..95e33ce19e49 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,20 +1,22 @@
# Maintainer: Adrián Pérez de Castro <aperez@igalia.com>
-pkgname='pswd'
+
pkgdesc='A pseudo-random password generator'
-pkgver='3.1.0'
-pkgrel='2'
-arch=('any')
-license=('custom')
-depends=('python')
-url='https://github.com/dwaring87/pswd'
-source=("${url}/archive/v${pkgver}.tar.gz"
- license.txt)
+pkgname=pswd
+pkgver=3.1.0
+pkgrel=3
+arch=(any)
+license=(MIT)
+depends=(python)
+url=https://github.com/dwaring87/pswd
+source=("${url}/archive/v${pkgver}.tar.gz" pswd-py3.diff)
sha512sums=('d1b84bb3760d79c3e62558e6bed87c65c86d78ac4d0b3665b93f3986a7592ef5ce1889aecd7783993518bfad61b3a79c200d7798ddf7bf6810521b49eb0c3b0c'
- '3396eb172dc6f467e153367492a14c89a1dcd06b0e445aacc71ab35f11984a9f2d666c40741b1b312c74fe54b81ca0e09a33643f63c97286d8ec13fd5f7df177')
+ '7f353f42fb9692b076ac626d4f49e0ed57504216afef9d49264f14e22d19af629c89d1b2a9b0bc369cf1d6c4a8e162089a8446e7c307569b51ed455c18f9311d')
+
+prepare () {
+ patch -i"$srcdir/pswd-py3.diff" "$pkgname-$pkgver/python/pswd"
+}
package () {
- install -Dm644 "${srcdir}/license.txt" \
- "${pkgdir}/usr/share/licenses/${pkgname}/license.txt"
- cd "${pkgname}-${pkgver}/python"
- install -Dm755 pswd "${pkgdir}/usr/bin/pswd"
+ cd "$pkgname-$pkgver/python"
+ install -Dm755 pswd "$pkgdir/usr/bin/pswd"
}
diff --git a/license.txt b/license.txt
deleted file mode 100644
index ba516794df25..000000000000
--- a/license.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-The original author does not indicate which license the source code is used
-for the software. Therefore, it is assummed to be in the public domain.
diff --git a/pswd-py3.diff b/pswd-py3.diff
new file mode 100644
index 000000000000..5fec7b2eb077
--- /dev/null
+++ b/pswd-py3.diff
@@ -0,0 +1,194 @@
+--- pswd.bak 2014-12-05 03:17:30.000000000 +0200
++++ pswd 2024-04-22 12:27:24.795769267 +0300
+@@ -130,14 +130,14 @@
+
+ # Hash token K1 times using SHA256
+ if QUIET == False:
+- print "Generating User Token... (This is only done once)"
++ print("Generating User Token... (This is only done once)")
+ for i in range(0, K1):
+ if QUIET == False:
+ if i % 1000 == 0:
+ per = float(i) / float(K1)
+ pb(per)
+
+- token = hashlib.sha256(token).hexdigest()
++ token = hashlib.sha256(token.encode("ascii")).hexdigest()
+
+ # Save token to cache
+ f = open(CACHE_FILE,'a')
+@@ -145,7 +145,7 @@
+ f.close()
+
+ if QUIET == False:
+- print "";
++ print("");
+
+
+ # Return Final Step 1 Hash
+@@ -183,33 +183,31 @@
+ key = DOMAIN + PASSWORD + USER_TOKEN
+
+ # Hash the pswd K2-1 times using SHA256
+- pswd = key
++ pswd = key.encode("ascii")
+ for i in range(1, K2):
+- pswd = hashlib.sha256(pswd).hexdigest()
++ pswd = hashlib.sha256(pswd).hexdigest().encode("ascii")
+
+ # for the last hash: concatenate 2 hashes of pswd to lengthen the result
+- pswd = hashlib.sha256(pswd + "1").hexdigest() + hashlib.sha256(pswd + "2").hexdigest()
+-
++ pswd = hashlib.sha256(pswd + b"1").hexdigest() + hashlib.sha256(pswd + b"2").hexdigest()
++ pswd = pswd.encode("ascii")
+
+ # convert to Base64
+- pswd = base64.b64encode(pswd.decode("hex"))
++ pswd = base64.b64encode(pswd).decode("ascii")
+
+ # remove base64 characters: + / =
+ pswd = pswd.replace("+", "")
+ pswd = pswd.replace("/", "")
+ pswd = pswd.replace("=", "")
+
+-
+ # Trim the password to LENGTH
+ pswd = pswd[:LENGTH]
+
+-
+-
+ # generate nums string from the key
+- temp = hashlib.sha256(key + "numbers1").hexdigest() + \
+- hashlib.sha256(key + "numbers2").hexdigest() + \
+- hashlib.sha256(key + "numbers3").hexdigest() + \
+- hashlib.sha256(key + "numbers4").hexdigest()
++ key = key.encode("ascii")
++ temp = hashlib.sha256(key + b"numbers1").hexdigest() + \
++ hashlib.sha256(key + b"numbers2").hexdigest() + \
++ hashlib.sha256(key + b"numbers3").hexdigest() + \
++ hashlib.sha256(key + b"numbers4").hexdigest()
+
+
+ # pull out all digits from the hashed string
+@@ -236,7 +234,7 @@
+ num_index = num_index + 1 # increase num index
+ if (div <= 3): # <= 3 creates too many symbols
+ div = 4 # divide by at least 4
+- num_of_symbols = LENGTH / div
++ num_of_symbols = LENGTH // div
+
+ # loop to add each symbol
+ for i in range(0, num_of_symbols):
+@@ -431,9 +429,9 @@
+ # define command line options
+ try:
+ opts, args = getopt.getopt(argv, "u:p:d:n:csa:t:x:y:qh", ["user=", "password=", "domain=", "token=", "cache=", "gettoken", "help"])
+- except getopt.GetoptError, err:
+- print "ERROR: " + str(err)
+- print USAGE
++ except getopt.GetoptError as err:
++ print("ERROR: " + str(err))
++ print(USAGE)
+ sys.exit(2)
+
+
+@@ -449,7 +447,7 @@
+ try:
+ LENGTH = int(arg)
+ except ValueError:
+- print "ERROR: length must be an integer"
++ print("ERROR: length must be an integer")
+ sys.exit(2)
+ elif opt in ("-c"):
+ UPPERCASE = not UPPERCASE
+@@ -461,13 +459,13 @@
+ try:
+ K1 = int(arg)
+ except ValueError:
+- print "ERROR: -x must be an integer"
++ print("ERROR: -x must be an integer")
+ sys.exit(2)
+ elif opt in ("-y"):
+ try:
+ K2 = int(arg)
+ except ValueError:
+- print "ERROR: -y must be an integer"
++ print("ERROR: -y must be an integer")
+ sys.exit(2)
+ elif opt in ("-q"):
+ QUIET = True
+@@ -478,7 +476,7 @@
+ elif opt in ("--token", "-t"):
+ USER_TOKEN = arg
+ elif opt in ("--help", "-h"):
+- print USAGE
++ print(USAGE)
+ sys.exit(0)
+
+
+@@ -487,7 +485,7 @@
+
+
+ # Get User ID based on hash of USER
+- USER_ID = hashlib.sha256(USER).hexdigest()
++ USER_ID = hashlib.sha256(USER.encode("ascii")).hexdigest()
+
+
+
+@@ -500,16 +498,16 @@
+ # Parameter Checks
+ # Need USER and PASSWORD
+ if USER == "":
+- print "ERROR: user name must be provided with --user [user name]"
++ print("ERROR: user name must be provided with --user [user name]")
+ sys.exit(2)
+ elif PASSWORD == "":
+- print "ERROR: master password must be provided with --password [master password]"
++ print("ERROR: master password must be provided with --password [master password]")
+ sys.exit(2)
+
+ # Get or Generate a USER TOKEN
+ USER_TOKEN = getToken()
+
+- print USER_TOKEN
++ print(USER_TOKEN)
+
+ sys.exit(0)
+
+@@ -524,22 +522,22 @@
+
+ # Make sure USER and PASSWORD and DOMAIN are supplied
+ if USER == "":
+- print "ERROR: user name must be provided with --user [user name]"
++ print("ERROR: user name must be provided with --user [user name]")
+ sys.exit(2)
+ elif PASSWORD == "":
+- print "ERROR: master password must be provided with --password [master password]"
++ print("ERROR: master password must be provided with --password [master password]")
+ sys.exit(2)
+ elif DOMAIN == "":
+- print "ERROR: the domain must be provided with --domain [domain]"
++ print("ERROR: the domain must be provided with --domain [domain]")
+ sys.exit(2)
+
+
+ # Check LENGTH is within range
+ if LENGTH < MIN_LENGTH:
+- print "ERROR: the length cannot be less than " + str(MIN_LENGTH)
++ print("ERROR: the length cannot be less than " + str(MIN_LENGTH))
+ sys.exit(2)
+ elif LENGTH > MAX_LENGTH:
+- print "ERROR: the length cannot be greater than " + str(MAX_LENGTH)
++ print("ERROR: the length cannot be greater than " + str(MAX_LENGTH))
+ sys.exit(2)
+
+
+@@ -571,7 +569,7 @@
+
+
+ if QUIET == False:
+- print FINAL
++ print(FINAL)
+
+ # Attempt to copy the password to the user's clipboard
+ copy(FINAL)