# UBUNTU
Run the following in a ubuntu:focal Docker container.

Install dependencies:
```sh
apt-get update
apt-get install devscripts
apt-get build-dep libkrb5-3
```

Clone the repo:
```sh
# Make sure the HEAD of the branch has the latest version of libkrb5-3 in the Ubuntu repositories
git clone -b ubuntu/focal-updates git://git.launchpad.net/ubuntu/+source/krb5
cd krb5
```

Remove the patch file:
```sh
rm debian/patches/upstream/0014-Remove-support-for-single-DES-and-CRC.patch
```

Remove the following line from debian/patches/series:
```
upstream/0014-Remove-support-for-single-DES-and-CRC.patch
```

Add the following line to debian/libk5crypto3.symbols
(right below `krb5int_nfold@k5crypto_3_MIT 1.10+dfsg~alpha1`):
```
mit_crc32@k5crypto_3_MIT 1.6.dfsg.2
```

Now would be a good time to do a git commit, if you wish to keep your changes
persistently.

Go up one directory and run:
```sh
tar -zcvf krb5_1.17.orig.tar.gz --exclude=debian --exclude=.git krb5/
```

Go back into the krb5 directory and run:
```
debuild -uc -us
```

Install all newly built shared libraries except for \*-dev and \*-dbg
```sh
dpkg -i \
    libgssapi-krb5-2_1.17-6ubuntu4.1_amd64.deb \
    libgssrpc4_1.17-6ubuntu4.1_amd64.deb \
    libk5crypto3_1.17-6ubuntu4.1_amd64.deb \
    libkadm5clnt-mit11_1.17-6ubuntu4.1_amd64.deb \
    libkadm5srv-mit11_1.17-6ubuntu4.1_amd64.deb \
    libkdb5-9_1.17-6ubuntu4.1_amd64.deb \
    libkrad0_1.17-6ubuntu4.1_amd64.deb \
    libkrb5-3_1.17-6ubuntu4.1_amd64.deb \
    libkrb5support0_1.17-6ubuntu4.1_amd64.deb
```

## Installing on clients
Paste the following into /etc/apt/preferences.d/99-csclub:
```
Package: *
Pin: origin debian.csclub.uwaterloo.ca
Pin-Priority: 1001
```

Then:
```sh
apt update
apt install --reinstall -o Dpkg::Options::="--force-overwrite" \
    libgssapi-krb5-2 libgssrpc4 libk5crypto3 libkadm5clnt-mit11 libkadm5srv-mit11 libkdb5-9 libkrad0 libkrb5-3 libkrb5support0
```

# DEBIAN
Run the following in a debian:bullseye Docker container.

Install dependencies and configure git:
```sh
apt install git devscripts
apt-get build-dep libkrb5-3
git config --global user.name 'Your Name'
git config --global user.email 'your@email.com'
```

Clone the repo and revert some commits:
```sh
git clone -b bullseye https://salsa.debian.org/debian/krb5.git
cd krb5
git revert c341a330e9a69c447277eebbd425551175c8ed1d
git revert 2063ff09b384d466c15aca8970c01d074230c815
# This will have conflicts
git revert fb2dada5eb89c4cd4e39dedd6dbb7dbd5e94f8b8 -X theirs
rm .gitignore
git add .
git revert --continue
```

Build the package:
```sh
cd ..
tar -zcvf krb5_1.18.3.orig.tar.gz --exclude=.git --exclude=debian krb5/
cd krb5
debuild -uc -us
```

Install all newly built shared libraries except for \*-dev and \*-dbg
```sh
cd ..
dpkg -i \
    libgssapi-krb5-2_1.18.3-6+deb11u1_amd64.deb \
    libgssrpc4_1.18.3-6+deb11u1_amd64.deb \
    libk5crypto3_1.18.3-6+deb11u1_amd64.deb \
    libkadm5clnt-mit12_1.18.3-6+deb11u1_amd64.deb \
    libkadm5srv-mit12_1.18.3-6+deb11u1_amd64.deb \
    libkdb5-10_1.18.3-6+deb11u1_amd64.deb \
    libkrad0_1.18.3-6+deb11u1_amd64.deb \
    libkrb5-3_1.18.3-6+deb11u1_amd64.deb \
    libkrb5support0_1.18.3-6+deb11u1_amd64.deb
```

## Installing on clients
Paste the following into /etc/apt/preferences.d/99-csclub:
```
Package: *
Pin: origin debian.csclub.uwaterloo.ca
Pin-Priority: 1001
```

Then:
```sh
apt update
apt install --reinstall libgssapi-krb5-2 libgssrpc4 libk5crypto3 libkadm5clnt-mit12 libkadm5srv-mit12 libkdb5-10 libkrad0 libkrb5-3 libkrb5support0
```