This repository was archived by the owner on Jul 21, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbionic-kernel.cron
More file actions
executable file
·122 lines (95 loc) · 3.53 KB
/
Copy pathbionic-kernel.cron
File metadata and controls
executable file
·122 lines (95 loc) · 3.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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
#!/bin/bash
BASE_DIR=/var/local/bionic-kernel
create_sources() {
printf "## This file is automatically generated, DO NOT EDIT\ndeb file:$1 ./" > /etc/apt/sources.list.d/bionic-kernel.list
}
get_version() {
local PACKAGE=$1
local MAINT=$2
apt-cache madison ${PACKAGE} | grep -i "${MAINT}" | head -1 | cut -d \| -f 2
}
get_depends() {
local PACKAGE=$1
local EXCLUDE=$2
local LATEST_DEPENDS=$(apt-cache show ${PACKAGE} | grep -A6 "Maintainer: Ubuntu" | grep -oP '(?<=Depends: ).*')
local DEPENDS=
local OLD_IFS=$IFS
local IFS=', '
for DEP in $LATEST_DEPENDS; do
if [[ ${EXCLUDE} == "" ]] || echo $DEP | grep -qvP $EXCLUDE; then
DEPENDS="${DEPENDS}, ${DEP}"
fi
done
IFS=$OLD_IFS
DEPENDS=${DEPENDS#", "}
echo -n $DEPENDS
}
make_equiv() {
local PACKAGE=$1
local EXCLUDE=$2
# Get the most recent kernel version
LATEST_VERSION=$(get_version ${PACKAGE} Ubuntu)
if [[ -z $LATEST_VERSION ]]; then
echo "Ubuntu ${PACKAGE} package not found"
return 1
fi
CURRENT_VERSION=$(get_version ${PACKAGE} Local)
if [[ ! -z $CURRENT_VERSION ]] && ! dpkg --compare-versions $LATEST_VERSION gt $CURRENT_VERSION; then
echo "Not updating ${PACKAGE}, already latest version (${LATEST_VERSION})"
return 1
fi
echo "Creating ${PACKAGE}:${LATEST_VERSION}"
DEPENDS=$(get_depends ${PACKAGE} ${EXCLUDE})
cat > ${PACKAGE} <<EOF
Section: kernel
Priority: optional
Standards-Version: 3.9.2
Package: ${PACKAGE}
Version: ${LATEST_VERSION}
Maintainer: Local <root@localhost>
Depends: ${DEPENDS}
Architecture: amd64
Description: Installs ${PACKAGE} Ubuntu Bionic package in Deepin
EOF
equivs-build ${PACKAGE}
rm ${PACKAGE}
}
make_release() {
# Scan the packages
dpkg-scanpackages -m -a amd64 . > Packages
gzip --keep --force -9 Packages
cat > Release <<EOF
Origin: Bionic Kernel
Label: Bionic Kernel
Suite: bionic-kernel
Architectures: amd64
Components: main
Description: Bionic Kernel for Deepin
EOF
echo -e "Date: `LANG=C date -Ru`" >> Release
# Release must contain MD5 sums of all repository files (in a simple repo just the Packages and Packages.gz files)
echo -e 'MD5Sum:' >> Release
printf ' '$(md5sum Packages.gz | cut --delimiter=' ' --fields=1)' %16d Packages.gz' $(wc --bytes Packages.gz | cut --delimiter=' ' --fields=1) >> Release
printf '\n '$(md5sum Packages | cut --delimiter=' ' --fields=1)' %16d Packages' $(wc --bytes Packages | cut --delimiter=' ' --fields=1) >> Release
# Release must contain SHA256 sums of all repository files (in a simple repo just the Packages and Packages.gz files)
echo -e '\nSHA256:' >> Release
printf ' '$(sha256sum Packages.gz | cut --delimiter=' ' --fields=1)' %16d Packages.gz' $(wc --bytes Packages.gz | cut --delimiter=' ' --fields=1) >> Release
printf '\n '$(sha256sum Packages | cut --delimiter=' ' --fields=1)' %16d Packages' $(wc --bytes Packages | cut --delimiter=' ' --fields=1) >> Release
gpg --homedir ${BASE_DIR}/.gnupg --clearsign --digest-algo SHA512 --local-user root@localhost -o InRelease --yes Release
rm Release
}
main() {
apt update
create_sources $BASE_DIR
pushd ${BASE_DIR}
make_equiv linux-image-generic linux-firmware
make_equiv linux-headers-generic
make_equiv linux-image-generic-hwe-18.04 linux-firmware
make_equiv linux-headers-generic-hwe-18.04
make_release
popd
apt update
}
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
main "$@"
fi