I follow the steps in this post to create a custom repository, but I want to rename it. I can't find any way to do it. Can you please help me?
Sounds like you want to know how to rename a package. There are two ways to do this. In this example, I'm going to change the name of cowsay
to mysay
From source
Download the debian (or ubuntu) source package, rename the files as appropriate, replace the old name with the new name in the debian/*
directory (that's what the sed
lines are doing, then build it with dpkg-buildpackage
.
Be a little careful, because some packages may have build rules which depend on the package name and may not be as trivial as cowsay. This is probably the toughest option.
apt source cowsay
mv cowsay-3.03+dfsg2 mysay-3.03+dfsg2
mv cowsay_3.03+dfsg2-8.dsc mysay_3.03+dfsg2-8.dsc
mv cowsay_3.03+dfsg2.orig.tar.gz mysay_3.03+dfsg2.orig.tar.gz
cd mysay-3.03+dfsg2/
sed -i 's/\bcowsay\b/mysay/g' debian/changelog debian/control
sed -i 's./debian/cowsay./debian/mysay.g' debian/rules
dpkg-buildpackage -uc -us
From binary
Get the *.deb you want to manually split the archive up, edit the control
file and then put it back togeather.
apt download cowsay
mkdir mysay && cd mysay
# Split everything up
ar -x ../cowsay_3.03+dfsg2-8_all.deb
mkdir control
tar -xf control.tar.xz -C control
# CHange the package name
sed -i 's/cowsay/mysay/' control/control
# Put the control file back togeather
cd control
tar -cf control.tar.xz *
mv control.tar.xz ../
cd ..
rm -r control
# Put the rest back togeather
ar r ../mysay_3.03+dfsg2-8_all.deb debian-binary control.tar.xz data.tar.xz
From binary (method 2)
This one simplifies the re-combining process. This is probably the easiest method.
apt download cowsay
ar x cowsay_3.03+dfsg2-8_all.deb
mkdir -p mysay/DEBIAN
tar -xf control.tar.xz -C mysay/DEBIAN
tar -xf data.tar.xz -C mysay/
sed -i 's/cowsay/mysay/' mysay/DEBIAN/control
dpkg-deb -b mysay
A few final notes:
If you try to install
cowsay
andmysay
on the same machine, one of the packages will fail. That's because they both supply the same files, so it's impossible for your system to know which owns it. A way to make this foolproof is to add aConflicts: cowsay
to the control file ofmysay
.Renaming packages is a little strange. It is sure to cause the conflicts mentioned above. I not sure I can picture a case where this is necessary.
-
-
However, I tried a similar approach with binary before and it didn't work. I changed the control file in the control.tar.xz directory of the archive, changing Package from the original name to my own. But when I call the dpkg-scanpackages command, the control file is once again changed to what it was before and it doesn't work. Update: it seems for some reason there's an archive inside the archive, so that's why it wasn't updated. Probably should work if processed carefully. – DiplomateProgrammer Nov 20 '20 at 9:06
bionic
/focal
)? The component (e.g.main
,universe
)? The path (e.g./usr/local/mydebs
)? – Stewart Nov 20 '20 at 7:51